blob: 0a791f77be0f860a27126b22bf5745e67b661a2c [file] [log] [blame]
/*
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of The Linux Foundation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __CONFIG_FM_THS_H__
#define __CONFIG_FM_THS_H__
#include <cstring>
#include "FmConst.h"
#include "ConfFileParser.h"
#define MAX_GRPS 3
#define MAX_SRCH_PARAMS 8
#define MAX_AF_PARAMS 3
#define SINR_SAMPLES_CNT_MIN 0
#define SINR_SAMPLES_CNT_MAX 255
#define SINR_FIRST_STAGE_MIN -128
#define SINR_FIRST_STAGE_MAX 127
#define RMSSI_FIRST_STAGE_MIN -128
#define RMSSI_FIRST_STAGE_MAX 127
#define INTF_LOW_TH_MIN 0
#define INTF_LOW_TH_MAX 255
#define INTF_HIGH_TH_MIN 0
#define INTF_HIGH_TH_MAX 255
#define SRCH_ALGO_TYPE_MIN 0
#define SRCH_ALGO_TYPE_MAX 1
#define SINR_FINAL_STAGE_MIN -128
#define SINR_FINAL_STAGE_MAX 127
#define AF_RMSSI_TH_MIN 0
#define AF_RMSSI_TH_MAX 65535
#define AF_RMSSI_SAMPLES_MIN 0
#define AF_RMSSI_SAMPLES_MAX 255
#define GOOD_CH_RMSSI_TH_MIN -128
#define GOOD_CH_RMSSI_TH_MAX 127
const unsigned char MAX_HYBRID_SRCH_PARAMS = 2;
struct NAME_MAP
{
const char name[50];
const int num;
};
enum PERFORMANCE_GRPS
{
AF_THS,
SRCH_THS,
HYBRD_SRCH_LIST,
};
enum PERFORMANCE_SRCH_PARAMS
{
SRCH_ALGO_TYPE,
CF0_TH,
SINR_FIRST_STAGE,
SINR,
RMSSI_FIRST_STAGE,
INTF_LOW_TH,
INTF_HIGH_TH,
SINR_SAMPLES,
};
enum PERFORMANCE_AF_PARAMS
{
AF_RMSSI_TH,
AF_RMSSI_SAMPLES,
GOOD_CH_RMSSI_TH,
};
enum HYBRID_SRCH_PARAMS
{
FREQ_LIST,
SINR_LIST,
};
//Keep this list in sorted order (ascending order in terms of "name")
//Don't change the name of GRPS, if changed please also change accordingly
//file: fm_srch_af_th.conf
static struct NAME_MAP GRPS_MAP[] =
{
{"AFTHRESHOLDS", AF_THS},
{"HYBRIDSEARCHLIST", HYBRD_SRCH_LIST},
{"SEARCHTHRESHOLDS", SRCH_THS},
};
//Keep this list in sorted order (ascending order in terms of "name")
//Don't change the name of SEARCH thresholds,
//if changed please also change accordingly
//file: fm_srch_af_th.conf
static struct NAME_MAP SEACH_PARAMS_MAP[] =
{
{"Cf0Th12", CF0_TH},
{"IntfHighTh", INTF_HIGH_TH},
{"IntfLowTh", INTF_LOW_TH},
{"RmssiFirstStage", RMSSI_FIRST_STAGE},
{"SearchAlgoType", SRCH_ALGO_TYPE},
{"Sinr", SINR},
{"SinrFirstStage", SINR_FIRST_STAGE},
{"SinrSamplesCnt", SINR_SAMPLES},
};
//Keep this list in sorted order (ascending order in terms of "name")
//Don't change the name of SEARCH thresholds,
//if changed please also change accordingly
//file: fm_srch_af_th.conf
static struct NAME_MAP AF_PARAMS_MAP[] =
{
{"AfRmssiSamplesCnt", AF_RMSSI_SAMPLES},
{"AfRmssiTh", AF_RMSSI_TH},
{"GoodChRmssiTh", GOOD_CH_RMSSI_TH},
};
static struct NAME_MAP HYBRD_SRCH_MAP[] =
{
{"Freqs", FREQ_LIST},
{"Sinrs", SINR_LIST},
};
class ConfigFmThs {
private:
group_table *keyfile;
void set_srch_ths(UINT fd);
void set_af_ths(UINT fd);
unsigned int extract_comma_sep_freqs(char *freqs, unsigned int **freqs_arr, const char *str);
unsigned int extract_comma_sep_sinrs(char *sinrs, signed char **sinrs_arr, const char *str);
void set_hybrd_list(UINT fd);
public:
ConfigFmThs();
~ConfigFmThs();
void SetRxSearchAfThs(const char *file, UINT fd);
};
#endif //__CONFIG_FM_THS_H__