summaryrefslogtreecommitdiffstats
path: root/jni/ConfigFmThs.h
blob: 0a791f77be0f860a27126b22bf5745e67b661a2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * 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__