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