This source file includes following definitions.
- odm_QueryRxPwrPercentage
- odm_SignalScaleMapping
- odm_EVMdbToPercentage
- odm_RxPhyStatus92CSeries_Parsing
- odm_Process_RSSIForDM
- ODM_PhyStatusQuery_92CSeries
- ODM_PhyStatusQuery
- ODM_ConfigRFWithHeaderFile
- ODM_ConfigRFWithTxPwrTrackHeaderFile
- ODM_ConfigBBWithHeaderFile
1
2
3
4
5
6
7
8 #include "odm_precomp.h"
9
10 #define READ_AND_CONFIG_MP(ic, txt) (ODM_ReadAndConfig_MP_##ic##txt(pDM_Odm))
11 #define READ_AND_CONFIG READ_AND_CONFIG_MP
12 #define GET_VERSION_MP(ic, txt) (ODM_GetVersion_MP_##ic##txt())
13 #define GET_VERSION(ic, txt) (pDM_Odm->bIsMPChip?GET_VERSION_MP(ic, txt):GET_VERSION_TC(ic, txt))
14
15 static u8 odm_QueryRxPwrPercentage(s8 AntPower)
16 {
17 if ((AntPower <= -100) || (AntPower >= 20))
18 return 0;
19 else if (AntPower >= 0)
20 return 100;
21 else
22 return 100 + AntPower;
23
24 }
25
26 s32 odm_SignalScaleMapping(PDM_ODM_T pDM_Odm, s32 CurrSig)
27 {
28 s32 RetSig = 0;
29
30 if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO) {
31 if (CurrSig >= 51 && CurrSig <= 100)
32 RetSig = 100;
33 else if (CurrSig >= 41 && CurrSig <= 50)
34 RetSig = 80 + ((CurrSig - 40)*2);
35 else if (CurrSig >= 31 && CurrSig <= 40)
36 RetSig = 66 + (CurrSig - 30);
37 else if (CurrSig >= 21 && CurrSig <= 30)
38 RetSig = 54 + (CurrSig - 20);
39 else if (CurrSig >= 10 && CurrSig <= 20)
40 RetSig = 42 + (((CurrSig - 10) * 2) / 3);
41 else if (CurrSig >= 5 && CurrSig <= 9)
42 RetSig = 22 + (((CurrSig - 5) * 3) / 2);
43 else if (CurrSig >= 1 && CurrSig <= 4)
44 RetSig = 6 + (((CurrSig - 1) * 3) / 2);
45 else
46 RetSig = CurrSig;
47 }
48
49 return RetSig;
50 }
51
52 static u8 odm_EVMdbToPercentage(s8 Value)
53 {
54
55
56
57 s8 ret_val;
58
59 ret_val = Value;
60 ret_val /= 2;
61
62
63
64
65 if (ret_val >= 0)
66 ret_val = 0;
67 if (ret_val <= -33)
68 ret_val = -33;
69
70 ret_val = 0 - ret_val;
71 ret_val *= 3;
72
73 if (ret_val == 99)
74 ret_val = 100;
75
76 return ret_val;
77 }
78
79 static void odm_RxPhyStatus92CSeries_Parsing(
80 PDM_ODM_T pDM_Odm,
81 struct odm_phy_info *pPhyInfo,
82 u8 *pPhyStatus,
83 struct odm_packet_info *pPktinfo
84 )
85 {
86 u8 i, Max_spatial_stream;
87 s8 rx_pwr[4], rx_pwr_all = 0;
88 u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT;
89 u8 RSSI, total_rssi = 0;
90 bool isCCKrate = false;
91 u8 rf_rx_num = 0;
92 u8 LNA_idx, VGA_idx;
93 PPHY_STATUS_RPT_8192CD_T pPhyStaRpt = (PPHY_STATUS_RPT_8192CD_T)pPhyStatus;
94
95 isCCKrate = pPktinfo->data_rate <= DESC_RATE11M;
96 pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_A] = -1;
97 pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1;
98
99
100 if (isCCKrate) {
101 u8 cck_agc_rpt;
102
103 pDM_Odm->PhyDbgInfo.NumQryPhyStatusCCK++;
104
105
106
107
108
109 cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a ;
110
111
112
113 LNA_idx = ((cck_agc_rpt & 0xE0)>>5);
114 VGA_idx = (cck_agc_rpt & 0x1F);
115 rx_pwr_all = odm_CCKRSSI_8723B(LNA_idx, VGA_idx);
116 PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
117 if (PWDB_ALL > 100)
118 PWDB_ALL = 100;
119
120 pPhyInfo->rx_pwd_ba11 = PWDB_ALL;
121 pPhyInfo->bt_rx_rssi_percentage = PWDB_ALL;
122 pPhyInfo->recv_signal_power = rx_pwr_all;
123
124
125
126
127 {
128 u8 SQ, SQ_rpt;
129
130 if (pPhyInfo->rx_pwd_ba11 > 40 && !pDM_Odm->bInHctTest)
131 SQ = 100;
132 else {
133 SQ_rpt = pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all;
134
135 if (SQ_rpt > 64)
136 SQ = 0;
137 else if (SQ_rpt < 20)
138 SQ = 100;
139 else
140 SQ = ((64-SQ_rpt) * 100) / 44;
141
142 }
143
144
145 pPhyInfo->signal_quality = SQ;
146 pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_A] = SQ;
147 pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1;
148 }
149 } else {
150 pDM_Odm->PhyDbgInfo.NumQryPhyStatusOFDM++;
151
152
153
154
155
156 for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++) {
157
158 if (pDM_Odm->RFPathRxEnable & BIT(i))
159 rf_rx_num++;
160
161
162
163 rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain&0x3F)*2) - 110;
164
165
166 pPhyInfo->rx_pwr[i] = rx_pwr[i];
167
168
169 RSSI = odm_QueryRxPwrPercentage(rx_pwr[i]);
170 total_rssi += RSSI;
171
172
173 pPhyInfo->rx_mimo_signal_strength[i] = (u8) RSSI;
174
175
176 pPhyInfo->rx_snr[i] = pDM_Odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2);
177 }
178
179
180
181
182
183 rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1)&0x7f)-110;
184
185 PWDB_ALL_BT = PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
186
187
188 pPhyInfo->rx_pwd_ba11 = PWDB_ALL;
189
190 pPhyInfo->bt_rx_rssi_percentage = PWDB_ALL_BT;
191 pPhyInfo->rx_power = rx_pwr_all;
192 pPhyInfo->recv_signal_power = rx_pwr_all;
193
194 {
195
196
197
198 if (pPktinfo->data_rate >= DESC_RATEMCS8 && pPktinfo->data_rate <= DESC_RATEMCS15)
199 Max_spatial_stream = 2;
200 else
201 Max_spatial_stream = 1;
202
203 for (i = 0; i < Max_spatial_stream; i++) {
204
205
206
207 EVM = odm_EVMdbToPercentage((pPhyStaRpt->stream_rxevm[i]));
208
209
210
211
212
213 {
214 if (i == ODM_RF_PATH_A)
215 pPhyInfo->signal_quality = (u8)(EVM & 0xff);
216
217 pPhyInfo->rx_mimo_signal_quality[i] = (u8)(EVM & 0xff);
218 }
219 }
220 }
221
222 ODM_ParsingCFO(pDM_Odm, pPktinfo, pPhyStaRpt->path_cfotail);
223
224 }
225
226
227
228 if (isCCKrate) {
229 #ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
230 pPhyInfo->SignalStrength = (u8)PWDB_ALL;
231 #else
232 pPhyInfo->signal_strength = (u8)(odm_SignalScaleMapping(pDM_Odm, PWDB_ALL));
233 #endif
234 } else {
235 if (rf_rx_num != 0) {
236 #ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
237 total_rssi /= rf_rx_num;
238 pPhyInfo->signal_strength = (u8)total_rssi;
239 #else
240 pPhyInfo->signal_strength = (u8)(odm_SignalScaleMapping(pDM_Odm, total_rssi /= rf_rx_num));
241 #endif
242 }
243 }
244
245
246
247 }
248
249 static void odm_Process_RSSIForDM(
250 PDM_ODM_T pDM_Odm, struct odm_phy_info *pPhyInfo, struct odm_packet_info *pPktinfo
251 )
252 {
253
254 s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK, UndecoratedSmoothedOFDM, RSSI_Ave;
255 u8 isCCKrate = 0;
256 u8 RSSI_max, RSSI_min, i;
257 u32 OFDM_pkt = 0;
258 u32 Weighting = 0;
259 PSTA_INFO_T pEntry;
260
261
262 if (pPktinfo->station_id == 0xFF)
263 return;
264
265 pEntry = pDM_Odm->pODM_StaInfo[pPktinfo->station_id];
266
267 if (!IS_STA_VALID(pEntry))
268 return;
269
270 if ((!pPktinfo->bssid_match))
271 return;
272
273 if (pPktinfo->is_beacon)
274 pDM_Odm->PhyDbgInfo.NumQryBeaconPkt++;
275
276 isCCKrate = ((pPktinfo->data_rate <= DESC_RATE11M)) ? true : false;
277 pDM_Odm->RxRate = pPktinfo->data_rate;
278
279
280 if (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV) {
281
282 }
283
284
285
286 UndecoratedSmoothedCCK = pEntry->rssi_stat.UndecoratedSmoothedCCK;
287 UndecoratedSmoothedOFDM = pEntry->rssi_stat.UndecoratedSmoothedOFDM;
288 UndecoratedSmoothedPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB;
289
290 if (pPktinfo->to_self || pPktinfo->is_beacon) {
291
292 if (!isCCKrate) {
293 if (pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B] == 0) {
294 RSSI_Ave = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A];
295 pDM_Odm->RSSI_A = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A];
296 pDM_Odm->RSSI_B = 0;
297 } else {
298
299
300 pDM_Odm->RSSI_A = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A];
301 pDM_Odm->RSSI_B = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B];
302
303 if (
304 pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A] >
305 pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B]
306 ) {
307 RSSI_max = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A];
308 RSSI_min = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B];
309 } else {
310 RSSI_max = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B];
311 RSSI_min = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A];
312 }
313
314 if ((RSSI_max-RSSI_min) < 3)
315 RSSI_Ave = RSSI_max;
316 else if ((RSSI_max-RSSI_min) < 6)
317 RSSI_Ave = RSSI_max - 1;
318 else if ((RSSI_max-RSSI_min) < 10)
319 RSSI_Ave = RSSI_max - 2;
320 else
321 RSSI_Ave = RSSI_max - 3;
322 }
323
324
325 if (UndecoratedSmoothedOFDM <= 0)
326 UndecoratedSmoothedOFDM = pPhyInfo->rx_pwd_ba11;
327 else {
328 if (pPhyInfo->rx_pwd_ba11 > (u32)UndecoratedSmoothedOFDM) {
329 UndecoratedSmoothedOFDM =
330 ((UndecoratedSmoothedOFDM*(Rx_Smooth_Factor-1)) +
331 RSSI_Ave)/Rx_Smooth_Factor;
332 UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM + 1;
333 } else {
334 UndecoratedSmoothedOFDM =
335 ((UndecoratedSmoothedOFDM*(Rx_Smooth_Factor-1)) +
336 RSSI_Ave)/Rx_Smooth_Factor;
337 }
338 }
339
340 pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT0;
341
342 } else {
343 RSSI_Ave = pPhyInfo->rx_pwd_ba11;
344 pDM_Odm->RSSI_A = (u8) pPhyInfo->rx_pwd_ba11;
345 pDM_Odm->RSSI_B = 0;
346
347
348 if (UndecoratedSmoothedCCK <= 0)
349 UndecoratedSmoothedCCK = pPhyInfo->rx_pwd_ba11;
350 else {
351 if (pPhyInfo->rx_pwd_ba11 > (u32)UndecoratedSmoothedCCK) {
352 UndecoratedSmoothedCCK =
353 ((UndecoratedSmoothedCCK*(Rx_Smooth_Factor-1)) +
354 pPhyInfo->rx_pwd_ba11)/Rx_Smooth_Factor;
355 UndecoratedSmoothedCCK = UndecoratedSmoothedCCK + 1;
356 } else {
357 UndecoratedSmoothedCCK =
358 ((UndecoratedSmoothedCCK*(Rx_Smooth_Factor-1)) +
359 pPhyInfo->rx_pwd_ba11)/Rx_Smooth_Factor;
360 }
361 }
362 pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap<<1;
363 }
364
365
366 {
367
368 if (pEntry->rssi_stat.ValidBit >= 64)
369 pEntry->rssi_stat.ValidBit = 64;
370 else
371 pEntry->rssi_stat.ValidBit++;
372
373 for (i = 0; i < pEntry->rssi_stat.ValidBit; i++)
374 OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i)&BIT0;
375
376 if (pEntry->rssi_stat.ValidBit == 64) {
377 Weighting = ((OFDM_pkt<<4) > 64)?64:(OFDM_pkt<<4);
378 UndecoratedSmoothedPWDB = (Weighting*UndecoratedSmoothedOFDM+(64-Weighting)*UndecoratedSmoothedCCK)>>6;
379 } else {
380 if (pEntry->rssi_stat.ValidBit != 0)
381 UndecoratedSmoothedPWDB = (OFDM_pkt*UndecoratedSmoothedOFDM+(pEntry->rssi_stat.ValidBit-OFDM_pkt)*UndecoratedSmoothedCCK)/pEntry->rssi_stat.ValidBit;
382 else
383 UndecoratedSmoothedPWDB = 0;
384 }
385
386 pEntry->rssi_stat.UndecoratedSmoothedCCK = UndecoratedSmoothedCCK;
387 pEntry->rssi_stat.UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM;
388 pEntry->rssi_stat.UndecoratedSmoothedPWDB = UndecoratedSmoothedPWDB;
389
390
391
392
393
394 }
395
396 }
397 }
398
399
400
401
402
403 static void ODM_PhyStatusQuery_92CSeries(
404 PDM_ODM_T pDM_Odm,
405 struct odm_phy_info *pPhyInfo,
406 u8 *pPhyStatus,
407 struct odm_packet_info *pPktinfo
408 )
409 {
410
411 odm_RxPhyStatus92CSeries_Parsing(pDM_Odm, pPhyInfo, pPhyStatus, pPktinfo);
412
413 if (!pDM_Odm->RSSI_test)
414 odm_Process_RSSIForDM(pDM_Odm, pPhyInfo, pPktinfo);
415 }
416
417 void ODM_PhyStatusQuery(
418 PDM_ODM_T pDM_Odm,
419 struct odm_phy_info *pPhyInfo,
420 u8 *pPhyStatus,
421 struct odm_packet_info *pPktinfo
422 )
423 {
424
425 ODM_PhyStatusQuery_92CSeries(pDM_Odm, pPhyInfo, pPhyStatus, pPktinfo);
426 }
427
428
429
430
431
432
433 HAL_STATUS ODM_ConfigRFWithHeaderFile(
434 PDM_ODM_T pDM_Odm,
435 ODM_RF_Config_Type ConfigType,
436 ODM_RF_RADIO_PATH_E eRFPath
437 )
438 {
439 ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
440 ("===>ODM_ConfigRFWithHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip"));
441 ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
442 ("pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n",
443 pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface, pDM_Odm->BoardType));
444
445 if (ConfigType == CONFIG_RF_RADIO)
446 READ_AND_CONFIG(8723B, _RadioA);
447 else if (ConfigType == CONFIG_RF_TXPWR_LMT)
448 READ_AND_CONFIG(8723B, _TXPWR_LMT);
449
450 return HAL_STATUS_SUCCESS;
451 }
452
453 HAL_STATUS ODM_ConfigRFWithTxPwrTrackHeaderFile(PDM_ODM_T pDM_Odm)
454 {
455 ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
456 ("===>ODM_ConfigRFWithTxPwrTrackHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip"));
457 ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
458 ("pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n",
459 pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface, pDM_Odm->BoardType));
460
461 if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO)
462 READ_AND_CONFIG(8723B, _TxPowerTrack_SDIO);
463
464 return HAL_STATUS_SUCCESS;
465 }
466
467 HAL_STATUS ODM_ConfigBBWithHeaderFile(
468 PDM_ODM_T pDM_Odm, ODM_BB_Config_Type ConfigType
469 )
470 {
471 ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
472 ("===>ODM_ConfigBBWithHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip"));
473 ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
474 ("pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n",
475 pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface, pDM_Odm->BoardType));
476
477 if (ConfigType == CONFIG_BB_PHY_REG)
478 READ_AND_CONFIG(8723B, _PHY_REG);
479 else if (ConfigType == CONFIG_BB_AGC_TAB)
480 READ_AND_CONFIG(8723B, _AGC_TAB);
481 else if (ConfigType == CONFIG_BB_PHY_REG_PG)
482 READ_AND_CONFIG(8723B, _PHY_REG_PG);
483
484 return HAL_STATUS_SUCCESS;
485 }
486