Venkateshwarlu Domakonda | acdd9a4 | 2015-03-24 10:28:37 +0530 | [diff] [blame] | 1 | /* |
| 2 | Copyright (c) 2015, The Linux Foundation. All rights reserved. |
| 3 | |
| 4 | Redistribution and use in source and binary forms, with or without |
| 5 | modification, are permitted provided that the following conditions are |
| 6 | met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above |
| 10 | copyright notice, this list of conditions and the following |
| 11 | disclaimer in the documentation and/or other materials provided |
| 12 | with the distribution. |
| 13 | * Neither the name of The Linux Foundation nor the names of its |
| 14 | contributors may be used to endorse or promote products derived |
| 15 | from this software without specific prior written permission. |
| 16 | |
| 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #ifndef __CONFIG_FM_THS_H__ |
| 31 | #define __CONFIG_FM_THS_H__ |
| 32 | |
| 33 | #include <cstring> |
| 34 | #include "FM_Const.h" |
| 35 | #include "ConfFileParser.h" |
| 36 | |
| 37 | #define MAX_GRPS 4 |
| 38 | #define MAX_SRCH_PARAMS 8 |
| 39 | #define MAX_AF_PARAMS 3 |
| 40 | #define MAX_BAND_PARAMS 3 |
| 41 | |
| 42 | #define SINR_SAMPLES_CNT_MIN 0 |
| 43 | #define SINR_SAMPLES_CNT_MAX 255 |
| 44 | #define SINR_FIRST_STAGE_MIN -128 |
| 45 | #define SINR_FIRST_STAGE_MAX 127 |
| 46 | #define RMSSI_FIRST_STAGE_MIN -128 |
| 47 | #define RMSSI_FIRST_STAGE_MAX 127 |
| 48 | #define INTF_LOW_TH_MIN 0 |
| 49 | #define INTF_LOW_TH_MAX 255 |
| 50 | #define INTF_HIGH_TH_MIN 0 |
| 51 | #define INTF_HIGH_TH_MAX 255 |
| 52 | #define SRCH_ALGO_TYPE_MIN 0 |
| 53 | #define SRCH_ALGO_TYPE_MAX 1 |
| 54 | #define SINR_FINAL_STAGE_MIN -128 |
| 55 | #define SINR_FINAL_STAGE_MAX 127 |
| 56 | |
| 57 | #define AF_RMSSI_TH_MIN 0 |
| 58 | #define AF_RMSSI_TH_MAX 65535 |
| 59 | #define AF_RMSSI_SAMPLES_MIN 0 |
| 60 | #define AF_RMSSI_SAMPLES_MAX 255 |
| 61 | #define GOOD_CH_RMSSI_TH_MIN -128 |
| 62 | #define GOOD_CH_RMSSI_TH_MAX 127 |
| 63 | #define FM_DE_EMP75 0 |
| 64 | #define FM_DE_EMP50 1 |
| 65 | #define FM_CHSPACE_200_KHZ 0 |
| 66 | #define FM_CHSPACE_100_KHZ 1 |
| 67 | #define FM_CHSPACE_50_KHZ 2 |
| 68 | |
| 69 | const unsigned char MAX_HYBRID_SRCH_PARAMS = 2; |
| 70 | |
| 71 | struct NAME_MAP |
| 72 | { |
| 73 | const char name[50]; |
| 74 | const int num; |
| 75 | }; |
| 76 | |
| 77 | enum PERFORMANCE_GRPS |
| 78 | { |
| 79 | AF_THS, |
| 80 | SRCH_THS, |
| 81 | HYBRD_SRCH_LIST, |
| 82 | BAND_CFG, |
| 83 | }; |
| 84 | |
| 85 | enum BAND_CFG_PARAMS |
| 86 | { |
| 87 | RADIO_BAND, |
| 88 | EMPHASIS, |
| 89 | CHANNEL_SPACING, |
| 90 | }; |
| 91 | |
| 92 | enum PERFORMANCE_SRCH_PARAMS |
| 93 | { |
| 94 | SRCH_ALGO_TYPE, |
| 95 | CF0_TH, |
| 96 | SINR_FIRST_STAGE, |
| 97 | SINR, |
| 98 | RMSSI_FIRST_STAGE, |
| 99 | INTF_LOW_TH, |
| 100 | INTF_HIGH_TH, |
| 101 | SINR_SAMPLES, |
| 102 | }; |
| 103 | |
| 104 | enum PERFORMANCE_AF_PARAMS |
| 105 | { |
| 106 | AF_RMSSI_TH, |
| 107 | AF_RMSSI_SAMPLES, |
| 108 | GOOD_CH_RMSSI_TH, |
| 109 | }; |
| 110 | |
| 111 | enum HYBRID_SRCH_PARAMS |
| 112 | { |
| 113 | FREQ_LIST, |
| 114 | SINR_LIST, |
| 115 | }; |
| 116 | |
| 117 | //Keep this list in sorted order (ascending order in terms of "name") |
| 118 | //Don't change the name of GRPS, if changed please also change accordingly |
| 119 | //file: fm_srch_af_th.conf |
| 120 | static struct NAME_MAP GRPS_MAP[] = |
| 121 | { |
| 122 | {"AFTHRESHOLDS", AF_THS}, |
| 123 | {"BANDCONFIG", BAND_CFG}, |
| 124 | {"HYBRIDSEARCHLIST", HYBRD_SRCH_LIST}, |
| 125 | {"SEARCHTHRESHOLDS", SRCH_THS}, |
| 126 | }; |
| 127 | |
| 128 | static struct NAME_MAP BAND_CFG_MAP[] = |
| 129 | { |
| 130 | {"ChSpacing", CHANNEL_SPACING}, |
| 131 | {"Emphasis", EMPHASIS}, |
| 132 | {"RadioBand", RADIO_BAND}, |
| 133 | }; |
| 134 | |
| 135 | //Keep this list in sorted order (ascending order in terms of "name") |
| 136 | //Don't change the name of SEARCH thresholds, |
| 137 | //if changed please also change accordingly |
| 138 | //file: fm_srch_af_th.conf |
| 139 | static struct NAME_MAP SEACH_PARAMS_MAP[] = |
| 140 | { |
| 141 | {"Cf0Th12", CF0_TH}, |
| 142 | {"IntfHighTh", INTF_HIGH_TH}, |
| 143 | {"IntfLowTh", INTF_LOW_TH}, |
| 144 | {"RmssiFirstStage", RMSSI_FIRST_STAGE}, |
| 145 | {"SearchAlgoType", SRCH_ALGO_TYPE}, |
| 146 | {"Sinr", SINR}, |
| 147 | {"SinrFirstStage", SINR_FIRST_STAGE}, |
| 148 | {"SinrSamplesCnt", SINR_SAMPLES}, |
| 149 | }; |
| 150 | |
| 151 | //Keep this list in sorted order (ascending order in terms of "name") |
| 152 | //Don't change the name of SEARCH thresholds, |
| 153 | //if changed please also change accordingly |
| 154 | //file: fm_srch_af_th.conf |
| 155 | static struct NAME_MAP AF_PARAMS_MAP[] = |
| 156 | { |
| 157 | {"AfRmssiSamplesCnt", AF_RMSSI_SAMPLES}, |
| 158 | {"AfRmssiTh", AF_RMSSI_TH}, |
| 159 | {"GoodChRmssiTh", GOOD_CH_RMSSI_TH}, |
| 160 | }; |
| 161 | |
| 162 | static struct NAME_MAP HYBRD_SRCH_MAP[] = |
| 163 | { |
| 164 | {"Freqs", FREQ_LIST}, |
| 165 | {"Sinrs", SINR_LIST}, |
| 166 | }; |
| 167 | |
| 168 | class ConfigFmThs { |
| 169 | private: |
| 170 | group_table *keyfile; |
| 171 | void set_srch_ths(UINT fd); |
| 172 | void set_af_ths(UINT fd); |
| 173 | unsigned int extract_comma_sep_freqs(char *freqs, unsigned int **freqs_arr, const char *str); |
| 174 | unsigned int extract_comma_sep_sinrs(char *sinrs, signed char **sinrs_arr, const char *str); |
| 175 | void set_hybrd_list(UINT fd); |
| 176 | void set_band_cfgs(UINT fd); |
| 177 | public: |
| 178 | ConfigFmThs(); |
| 179 | ~ConfigFmThs(); |
| 180 | void SetRxSearchAfThs(const char *file, UINT fd); |
| 181 | }; |
| 182 | |
| 183 | #endif //__CONFIG_FM_THS_H__ |