1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
15 #define _HAL_COM_PHYCFG_C_
17 #include <drv_types.h>
18 #include <rtw_debug.h>
21 u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 Band, u8 RfPath,
22 u8 TxNum, enum RATE_SECTION RateSection)
24 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
27 if (RfPath > ODM_RF_PATH_D)
29 DBG_871X("Invalid Rf Path %d in PHY_GetTxPowerByRateBase()\n", RfPath);
33 if (Band == BAND_ON_2_4G)
35 switch (RateSection) {
37 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0];
40 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1];
43 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2];
46 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3];
49 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4];
52 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5];
54 case VHT_1SSMCS0_1SSMCS9:
55 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][6];
57 case VHT_2SSMCS0_2SSMCS9:
58 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][7];
60 case VHT_3SSMCS0_3SSMCS9:
61 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][8];
63 case VHT_4SSMCS0_4SSMCS9:
64 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9];
67 DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n",
68 RateSection, RfPath, TxNum);
73 else if (Band == BAND_ON_5G)
75 switch (RateSection) {
77 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][0];
80 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][1];
83 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][2];
86 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][3];
89 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][4];
91 case VHT_1SSMCS0_1SSMCS9:
92 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][5];
94 case VHT_2SSMCS0_2SSMCS9:
95 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][6];
97 case VHT_3SSMCS0_3SSMCS9:
98 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][7];
100 case VHT_4SSMCS0_4SSMCS9:
101 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][8];
104 DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n",
105 RateSection, RfPath, TxNum);
111 DBG_871X("Invalid Band %d in PHY_GetTxPowerByRateBase()\n", Band);
118 phy_SetTxPowerByRateBase(
119 struct adapter * Adapter,
122 enum RATE_SECTION RateSection,
127 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
129 if (RfPath > ODM_RF_PATH_D)
131 DBG_871X("Invalid Rf Path %d in phy_SetTxPowerByRatBase()\n", RfPath);
135 if (Band == BAND_ON_2_4G)
137 switch (RateSection) {
139 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0] = Value;
142 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1] = Value;
145 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2] = Value;
148 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3] = Value;
151 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4] = Value;
154 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5] = Value;
156 case VHT_1SSMCS0_1SSMCS9:
157 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][6] = Value;
159 case VHT_2SSMCS0_2SSMCS9:
160 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][7] = Value;
162 case VHT_3SSMCS0_3SSMCS9:
163 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][8] = Value;
165 case VHT_4SSMCS0_4SSMCS9:
166 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9] = Value;
169 DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n",
170 RateSection, RfPath, TxNum);
174 else if (Band == BAND_ON_5G)
176 switch (RateSection) {
178 pHalData->TxPwrByRateBase5G[RfPath][TxNum][0] = Value;
181 pHalData->TxPwrByRateBase5G[RfPath][TxNum][1] = Value;
184 pHalData->TxPwrByRateBase5G[RfPath][TxNum][2] = Value;
187 pHalData->TxPwrByRateBase5G[RfPath][TxNum][3] = Value;
190 pHalData->TxPwrByRateBase5G[RfPath][TxNum][4] = Value;
192 case VHT_1SSMCS0_1SSMCS9:
193 pHalData->TxPwrByRateBase5G[RfPath][TxNum][5] = Value;
195 case VHT_2SSMCS0_2SSMCS9:
196 pHalData->TxPwrByRateBase5G[RfPath][TxNum][6] = Value;
198 case VHT_3SSMCS0_3SSMCS9:
199 pHalData->TxPwrByRateBase5G[RfPath][TxNum][7] = Value;
201 case VHT_4SSMCS0_4SSMCS9:
202 pHalData->TxPwrByRateBase5G[RfPath][TxNum][8] = Value;
205 DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n",
206 RateSection, RfPath, TxNum);
212 DBG_871X("Invalid Band %d in phy_SetTxPowerByRateBase()\n", Band);
217 phy_StoreTxPowerByRateBase(
218 struct adapter *padapter
223 /* DBG_871X("===>%s\n", __func__); */
225 for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; ++path)
227 base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_11M);
228 phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, CCK, RF_1TX, base);
229 /* DBG_871X("Power index base of 2.4G path %d 1Tx CCK = > 0x%x\n", path, base); */
231 base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_54M);
232 phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, OFDM, RF_1TX, base);
233 /* DBG_871X("Power index base of 2.4G path %d 1Tx OFDM = > 0x%x\n", path, base); */
235 base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_MCS7);
236 phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, HT_MCS0_MCS7, RF_1TX, base);
237 /* DBG_871X("Power index base of 2.4G path %d 1Tx MCS0-7 = > 0x%x\n", path, base); */
239 base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_2TX, MGN_MCS15);
240 phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, HT_MCS8_MCS15, RF_2TX, base);
241 /* DBG_871X("Power index base of 2.4G path %d 2Tx MCS8-15 = > 0x%x\n", path, base); */
243 base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_3TX, MGN_MCS23);
244 phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, HT_MCS16_MCS23, RF_3TX, base);
245 /* DBG_871X("Power index base of 2.4G path %d 3Tx MCS16-23 = > 0x%x\n", path, base); */
247 base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_VHT1SS_MCS7);
248 phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, VHT_1SSMCS0_1SSMCS9, RF_1TX, base);
249 /* DBG_871X("Power index base of 2.4G path %d 1Tx VHT1SS = > 0x%x\n", path, base); */
251 base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_2TX, MGN_VHT2SS_MCS7);
252 phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, VHT_2SSMCS0_2SSMCS9, RF_2TX, base);
253 /* DBG_871X("Power index base of 2.4G path %d 2Tx VHT2SS = > 0x%x\n", path, base); */
255 base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_3TX, MGN_VHT3SS_MCS7);
256 phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, VHT_3SSMCS0_3SSMCS9, RF_3TX, base);
257 /* DBG_871X("Power index base of 2.4G path %d 3Tx VHT3SS = > 0x%x\n", path, base); */
259 base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_1TX, MGN_54M);
260 phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, OFDM, RF_1TX, base);
261 /* DBG_871X("Power index base of 5G path %d 1Tx OFDM = > 0x%x\n", path, base); */
263 base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_1TX, MGN_MCS7);
264 phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, HT_MCS0_MCS7, RF_1TX, base);
265 /* DBG_871X("Power index base of 5G path %d 1Tx MCS0~7 = > 0x%x\n", path, base); */
267 base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_2TX, MGN_MCS15);
268 phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, HT_MCS8_MCS15, RF_2TX, base);
269 /* DBG_871X("Power index base of 5G path %d 2Tx MCS8~15 = > 0x%x\n", path, base); */
271 base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_3TX, MGN_MCS23);
272 phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, HT_MCS16_MCS23, RF_3TX, base);
273 /* DBG_871X("Power index base of 5G path %d 3Tx MCS16~23 = > 0x%x\n", path, base); */
275 base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_1TX, MGN_VHT1SS_MCS7);
276 phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, VHT_1SSMCS0_1SSMCS9, RF_1TX, base);
277 /* DBG_871X("Power index base of 5G path %d 1Tx VHT1SS = > 0x%x\n", path, base); */
279 base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_2TX, MGN_VHT2SS_MCS7);
280 phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, VHT_2SSMCS0_2SSMCS9, RF_2TX, base);
281 /* DBG_871X("Power index base of 5G path %d 2Tx VHT2SS = > 0x%x\n", path, base); */
283 base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_3TX, MGN_VHT2SS_MCS7);
284 phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, VHT_3SSMCS0_3SSMCS9, RF_3TX, base);
285 /* DBG_871X("Power index base of 5G path %d 3Tx VHT3SS = > 0x%x\n", path, base); */
288 /* DBG_871X("<===%s\n", __func__); */
292 PHY_GetRateSectionIndexOfTxPowerByRate(
293 struct adapter *padapter,
298 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
299 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
302 if (pDM_Odm->PhyRegPgVersion == 0)
306 case rTxAGC_A_Rate18_06: index = 0; break;
307 case rTxAGC_A_Rate54_24: index = 1; break;
308 case rTxAGC_A_CCK1_Mcs32: index = 6; break;
309 case rTxAGC_B_CCK11_A_CCK2_11:
310 if (BitMask == bMaskH3Bytes)
312 else if (BitMask == 0x000000ff)
316 case rTxAGC_A_Mcs03_Mcs00: index = 2; break;
317 case rTxAGC_A_Mcs07_Mcs04: index = 3; break;
318 case rTxAGC_A_Mcs11_Mcs08: index = 4; break;
319 case rTxAGC_A_Mcs15_Mcs12: index = 5; break;
320 case rTxAGC_B_Rate18_06: index = 8; break;
321 case rTxAGC_B_Rate54_24: index = 9; break;
322 case rTxAGC_B_CCK1_55_Mcs32: index = 14; break;
323 case rTxAGC_B_Mcs03_Mcs00: index = 10; break;
324 case rTxAGC_B_Mcs07_Mcs04: index = 11; break;
325 case rTxAGC_B_Mcs11_Mcs08: index = 12; break;
326 case rTxAGC_B_Mcs15_Mcs12: index = 13; break;
328 DBG_871X("Invalid RegAddr 0x3%x in PHY_GetRateSectionIndexOfTxPowerByRate()", RegAddr);
337 PHY_GetRateValuesOfTxPowerByRate(
338 struct adapter *padapter,
351 case rTxAGC_A_Rate18_06:
352 case rTxAGC_B_Rate18_06:
353 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_6M);
354 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_9M);
355 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_12M);
356 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_18M);
357 for (i = 0; i < 4; ++ i)
359 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
360 ((Value >> (i * 8)) & 0xF));
365 case rTxAGC_A_Rate54_24:
366 case rTxAGC_B_Rate54_24:
367 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_24M);
368 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_36M);
369 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_48M);
370 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_54M);
371 for (i = 0; i < 4; ++ i)
373 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
374 ((Value >> (i * 8)) & 0xF));
379 case rTxAGC_A_CCK1_Mcs32:
380 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M);
381 PwrByRateVal[0] = (s8) ((((Value >> (8 + 4)) & 0xF)) * 10 +
382 ((Value >> 8) & 0xF));
386 case rTxAGC_B_CCK11_A_CCK2_11:
387 if (BitMask == 0xffffff00)
389 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M);
390 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_5_5M);
391 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_11M);
392 for (i = 1; i < 4; ++ i)
394 PwrByRateVal[i - 1] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
395 ((Value >> (i * 8)) & 0xF));
399 else if (BitMask == 0x000000ff)
401 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_11M);
402 PwrByRateVal[0] = (s8) ((((Value >> 4) & 0xF)) * 10 +
408 case rTxAGC_A_Mcs03_Mcs00:
409 case rTxAGC_B_Mcs03_Mcs00:
410 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS0);
411 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS1);
412 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS2);
413 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS3);
414 for (i = 0; i < 4; ++ i)
416 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
417 ((Value >> (i * 8)) & 0xF));
422 case rTxAGC_A_Mcs07_Mcs04:
423 case rTxAGC_B_Mcs07_Mcs04:
424 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS4);
425 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS5);
426 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS6);
427 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS7);
428 for (i = 0; i < 4; ++ i)
430 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
431 ((Value >> (i * 8)) & 0xF));
436 case rTxAGC_A_Mcs11_Mcs08:
437 case rTxAGC_B_Mcs11_Mcs08:
438 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS8);
439 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS9);
440 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS10);
441 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS11);
442 for (i = 0; i < 4; ++ i)
444 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
445 ((Value >> (i * 8)) & 0xF));
450 case rTxAGC_A_Mcs15_Mcs12:
451 case rTxAGC_B_Mcs15_Mcs12:
452 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS12);
453 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS13);
454 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS14);
455 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS15);
456 for (i = 0; i < 4; ++ i)
458 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
459 ((Value >> (i * 8)) & 0xF));
465 case rTxAGC_B_CCK1_55_Mcs32:
466 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M);
467 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M);
468 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_5_5M);
469 for (i = 1; i < 4; ++ i)
471 PwrByRateVal[i - 1] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
472 ((Value >> (i * 8)) & 0xF));
481 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M);
482 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M);
483 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_5_5M);
484 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_11M);
485 for (i = 0; i < 4; ++ i)
487 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
488 ((Value >> (i * 8)) & 0xF));
497 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_6M);
498 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_9M);
499 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_12M);
500 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_18M);
501 for (i = 0; i < 4; ++ i)
503 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
504 ((Value >> (i * 8)) & 0xF));
513 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_24M);
514 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_36M);
515 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_48M);
516 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_54M);
517 for (i = 0; i < 4; ++ i)
519 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
520 ((Value >> (i * 8)) & 0xF));
529 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS0);
530 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS1);
531 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS2);
532 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS3);
533 for (i = 0; i < 4; ++ i)
535 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
536 ((Value >> (i * 8)) & 0xF));
545 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS4);
546 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS5);
547 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS6);
548 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS7);
549 for (i = 0; i < 4; ++ i)
551 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
552 ((Value >> (i * 8)) & 0xF));
561 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS8);
562 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS9);
563 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS10);
564 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS11);
565 for (i = 0; i < 4; ++ i)
567 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
568 ((Value >> (i * 8)) & 0xF));
577 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS12);
578 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS13);
579 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS14);
580 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS15);
581 for (i = 0; i < 4; ++ i)
583 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
584 ((Value >> (i * 8)) & 0xF));
593 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS0);
594 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS1);
595 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS2);
596 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS3);
597 for (i = 0; i < 4; ++ i)
599 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
600 ((Value >> (i * 8)) & 0xF));
609 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS4);
610 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS5);
611 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS6);
612 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS7);
613 for (i = 0; i < 4; ++ i)
615 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
616 ((Value >> (i * 8)) & 0xF));
625 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS8);
626 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS9);
627 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS0);
628 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS1);
629 for (i = 0; i < 4; ++ i)
631 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
632 ((Value >> (i * 8)) & 0xF));
641 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS2);
642 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS3);
643 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS4);
644 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS5);
645 for (i = 0; i < 4; ++ i)
647 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
648 ((Value >> (i * 8)) & 0xF));
657 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS6);
658 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS7);
659 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS8);
660 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS9);
661 for (i = 0; i < 4; ++ i)
663 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
664 ((Value >> (i * 8)) & 0xF));
673 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS16);
674 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS17);
675 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS18);
676 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS19);
677 for (i = 0; i < 4; ++ i)
679 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
680 ((Value >> (i * 8)) & 0xF));
689 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS20);
690 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS21);
691 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS22);
692 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS23);
693 for (i = 0; i < 4; ++ i)
695 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
696 ((Value >> (i * 8)) & 0xF));
705 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS0);
706 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS1);
707 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS2);
708 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS3);
709 for (i = 0; i < 4; ++ i)
711 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
712 ((Value >> (i * 8)) & 0xF));
721 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS4);
722 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS5);
723 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS6);
724 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS7);
725 for (i = 0; i < 4; ++ i)
727 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
728 ((Value >> (i * 8)) & 0xF));
737 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS8);
738 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS9);
739 for (i = 0; i < 2; ++ i)
741 PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 +
742 ((Value >> (i * 8)) & 0xF));
748 DBG_871X("Invalid RegAddr 0x%x in %s()\n", RegAddr, __func__);
754 PHY_StoreTxPowerByRateNew(
755 struct adapter *padapter,
764 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
765 u8 i = 0, rateIndex[4] = {0}, rateNum = 0;
766 s8 PwrByRateVal[4] = {0};
768 PHY_GetRateValuesOfTxPowerByRate(padapter, RegAddr, BitMask, Data, rateIndex, PwrByRateVal, &rateNum);
770 if (Band != BAND_ON_2_4G && Band != BAND_ON_5G)
772 DBG_871X("Invalid Band %d\n", Band);
776 if (RfPath > ODM_RF_PATH_D)
778 DBG_871X("Invalid RfPath %d\n", RfPath);
782 if (TxNum > ODM_RF_PATH_D)
784 DBG_871X("Invalid TxNum %d\n", TxNum);
788 for (i = 0; i < rateNum; ++i)
790 if (rateIndex[i] == PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS0) ||
791 rateIndex[i] == PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS1))
796 pHalData->TxPwrByRateOffset[Band][RfPath][TxNum][rateIndex[i]] = PwrByRateVal[i];
801 PHY_StoreTxPowerByRateOld(
802 struct adapter * padapter,
808 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
809 u8 index = PHY_GetRateSectionIndexOfTxPowerByRate(padapter, RegAddr, BitMask);
811 pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][index] = Data;
812 /* DBG_871X("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n", pHalData->pwrGroupCnt, */
813 /* pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0]); */
817 PHY_InitTxPowerByRate(
818 struct adapter *padapter
821 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
822 u8 band, rfPath, TxNum, rate;
824 for (band = BAND_ON_2_4G; band <= BAND_ON_5G; ++band)
825 for (rfPath = 0; rfPath < TX_PWR_BY_RATE_NUM_RF; ++rfPath)
826 for (TxNum = 0; TxNum < TX_PWR_BY_RATE_NUM_RF; ++TxNum)
827 for (rate = 0; rate < TX_PWR_BY_RATE_NUM_RATE; ++rate)
828 pHalData->TxPwrByRateOffset[band][rfPath][TxNum][rate] = 0;
832 PHY_StoreTxPowerByRate(
833 struct adapter *padapter,
842 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
843 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
845 if (pDM_Odm->PhyRegPgVersion > 0)
847 PHY_StoreTxPowerByRateNew(padapter, Band, RfPath, TxNum, RegAddr, BitMask, Data);
849 else if (pDM_Odm->PhyRegPgVersion == 0)
851 PHY_StoreTxPowerByRateOld(padapter, RegAddr, BitMask, Data);
853 if (RegAddr == rTxAGC_A_Mcs15_Mcs12 && pHalData->rf_type == RF_1T1R)
854 pHalData->pwrGroupCnt++;
855 else if (RegAddr == rTxAGC_B_Mcs15_Mcs12 && pHalData->rf_type != RF_1T1R)
856 pHalData->pwrGroupCnt++;
859 DBG_871X("Invalid PHY_REG_PG.txt version %d\n", pDM_Odm->PhyRegPgVersion);
864 phy_ConvertTxPowerByRateInDbmToRelativeValues(
865 struct adapter *padapter
868 u8 base = 0, i = 0, value = 0,
869 band = 0, path = 0, txNum = 0;
870 u8 cckRates[4] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M},
871 ofdmRates[8] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M},
872 mcs0_7Rates[8] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7},
873 mcs8_15Rates[8] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15},
874 mcs16_23Rates[8] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23},
875 vht1ssRates[10] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4,
876 MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9},
877 vht2ssRates[10] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4,
878 MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9},
879 vht3ssRates[10] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4,
880 MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9};
882 /* DBG_871X("===>PHY_ConvertTxPowerByRateInDbmToRelativeValues()\n"); */
884 for (band = BAND_ON_2_4G; band <= BAND_ON_5G; ++band)
886 for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_D; ++path)
888 for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum)
891 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_11M);
892 for (i = 0; i < sizeof(cckRates); ++i)
894 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, cckRates[i]);
895 PHY_SetTxPowerByRate(padapter, band, path, txNum, cckRates[i], value - base);
899 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_54M);
900 for (i = 0; i < sizeof(ofdmRates); ++i)
902 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, ofdmRates[i]);
903 PHY_SetTxPowerByRate(padapter, band, path, txNum, ofdmRates[i], value - base);
907 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_MCS7);
908 for (i = 0; i < sizeof(mcs0_7Rates); ++i)
910 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, mcs0_7Rates[i]);
911 PHY_SetTxPowerByRate(padapter, band, path, txNum, mcs0_7Rates[i], value - base);
915 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_MCS15);
916 for (i = 0; i < sizeof(mcs8_15Rates); ++i)
918 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, mcs8_15Rates[i]);
919 PHY_SetTxPowerByRate(padapter, band, path, txNum, mcs8_15Rates[i], value - base);
923 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_MCS23);
924 for (i = 0; i < sizeof(mcs16_23Rates); ++i)
926 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, mcs16_23Rates[i]);
927 PHY_SetTxPowerByRate(padapter, band, path, txNum, mcs16_23Rates[i], value - base);
931 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_VHT1SS_MCS7);
932 for (i = 0; i < sizeof(vht1ssRates); ++i)
934 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, vht1ssRates[i]);
935 PHY_SetTxPowerByRate(padapter, band, path, txNum, vht1ssRates[i], value - base);
939 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_VHT2SS_MCS7);
940 for (i = 0; i < sizeof(vht2ssRates); ++i)
942 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, vht2ssRates[i]);
943 PHY_SetTxPowerByRate(padapter, band, path, txNum, vht2ssRates[i], value - base);
947 base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_VHT3SS_MCS7);
948 for (i = 0; i < sizeof(vht3ssRates); ++i)
950 value = PHY_GetTxPowerByRate(padapter, band, path, txNum, vht3ssRates[i]);
951 PHY_SetTxPowerByRate(padapter, band, path, txNum, vht3ssRates[i], value - base);
957 /* DBG_871X("<===PHY_ConvertTxPowerByRateInDbmToRelativeValues()\n"); */
961 * This function must be called if the value in the PHY_REG_PG.txt(or header)
962 * is exact dBm values
965 PHY_TxPowerByRateConfiguration(
966 struct adapter * padapter
969 phy_StoreTxPowerByRateBase(padapter);
970 phy_ConvertTxPowerByRateInDbmToRelativeValues(padapter);
974 PHY_SetTxPowerIndexByRateSection(
975 struct adapter * padapter,
981 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
983 if (RateSection == CCK)
985 u8 cckRates[] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M};
986 if (pHalData->CurrentBandType == BAND_ON_2_4G)
987 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
988 cckRates, sizeof(cckRates)/sizeof(u8));
991 else if (RateSection == OFDM)
993 u8 ofdmRates[] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M};
994 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
995 ofdmRates, sizeof(ofdmRates)/sizeof(u8));
998 else if (RateSection == HT_MCS0_MCS7)
1000 u8 htRates1T[] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7};
1001 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
1002 htRates1T, sizeof(htRates1T)/sizeof(u8));
1005 else if (RateSection == HT_MCS8_MCS15)
1007 u8 htRates2T[] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15};
1008 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
1009 htRates2T, sizeof(htRates2T)/sizeof(u8));
1012 else if (RateSection == HT_MCS16_MCS23)
1014 u8 htRates3T[] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23};
1015 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
1016 htRates3T, sizeof(htRates3T)/sizeof(u8));
1019 else if (RateSection == HT_MCS24_MCS31)
1021 u8 htRates4T[] = {MGN_MCS24, MGN_MCS25, MGN_MCS26, MGN_MCS27, MGN_MCS28, MGN_MCS29, MGN_MCS30, MGN_MCS31};
1022 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
1023 htRates4T, sizeof(htRates4T)/sizeof(u8));
1026 else if (RateSection == VHT_1SSMCS0_1SSMCS9)
1028 u8 vhtRates1T[] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4,
1029 MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9};
1030 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
1031 vhtRates1T, sizeof(vhtRates1T)/sizeof(u8));
1034 else if (RateSection == VHT_2SSMCS0_2SSMCS9)
1036 u8 vhtRates2T[] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4,
1037 MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9};
1039 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
1040 vhtRates2T, sizeof(vhtRates2T)/sizeof(u8));
1042 else if (RateSection == VHT_3SSMCS0_3SSMCS9)
1044 u8 vhtRates3T[] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4,
1045 MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9};
1047 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
1048 vhtRates3T, sizeof(vhtRates3T)/sizeof(u8));
1050 else if (RateSection == VHT_4SSMCS0_4SSMCS9)
1052 u8 vhtRates4T[] = {MGN_VHT4SS_MCS0, MGN_VHT4SS_MCS1, MGN_VHT4SS_MCS2, MGN_VHT4SS_MCS3, MGN_VHT4SS_MCS4,
1053 MGN_VHT4SS_MCS5, MGN_VHT4SS_MCS6, MGN_VHT4SS_MCS7, MGN_VHT4SS_MCS8, MGN_VHT4SS_MCS9};
1055 PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel,
1056 vhtRates4T, sizeof(vhtRates4T)/sizeof(u8));
1060 DBG_871X("Invalid RateSection %d in %s", RateSection, __func__);
1070 u8 channel5G[CHANNEL_MAX_NUMBER_5G] =
1071 {36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 100, 102, 104, 106, 108, 110, 112,
1072 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 149, 151,
1073 153, 155, 157, 159, 161, 163, 165, 167, 168, 169, 171, 173, 175, 177};
1080 *ChannelIdx = Channel -1;
1086 for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i)
1088 if (channel5G[i] == Channel) {
1099 PHY_GetTxPowerIndexBase(
1100 struct adapter * padapter,
1103 enum CHANNEL_WIDTH BandWidth,
1108 struct hal_com_data * pHalData = GET_HAL_DATA(padapter);
1109 u8 i = 0; /* default set to 1S */
1111 u8 chnlIdx = (Channel-1);
1113 if (HAL_IsLegalChannel(padapter, Channel) == false)
1116 DBG_871X("Illegal channel!!\n");
1119 *bIn24G = phy_GetChnlIndex(Channel, &chnlIdx);
1121 /* DBG_871X("[%s] Channel Index: %d\n", (*bIn24G?"2.4G":"5G"), chnlIdx); */
1123 if (*bIn24G) /* 3 ============================== 2.4 G ============================== */
1125 if (IS_CCK_RATE(Rate))
1127 txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx];
1129 else if (MGN_6M <= Rate)
1131 txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx];
1135 DBG_871X("PHY_GetTxPowerIndexBase: INVALID Rate.\n");
1138 /* DBG_871X("Base Tx power(RF-%c, Rate #%d, Channel Index %d) = 0x%X\n", */
1139 /* ((RFPath == 0)?'A':'B'), Rate, chnlIdx, txPower); */
1142 if ((MGN_6M <= Rate && Rate <= MGN_54M) && ! IS_CCK_RATE(Rate))
1144 txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
1145 /* DBG_871X("+PowerDiff 2.4G (RF-%c): (OFDM-1T) = (%d)\n", ((RFPath == 0)?'A':'B'), pHalData->OFDM_24G_Diff[RFPath][TX_1S]); */
1147 /* BW20-1S, BW20-2S */
1148 if (BandWidth == CHANNEL_WIDTH_20)
1150 if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1151 txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
1152 if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1153 txPower += pHalData->BW20_24G_Diff[RFPath][TX_2S];
1154 if ((MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1155 txPower += pHalData->BW20_24G_Diff[RFPath][TX_3S];
1156 if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1157 txPower += pHalData->BW20_24G_Diff[RFPath][TX_4S];
1159 /* DBG_871X("+PowerDiff 2.4G (RF-%c): (BW20-1S, BW20-2S, BW20-3S, BW20-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
1160 /* pHalData->BW20_24G_Diff[RFPath][TX_1S], pHalData->BW20_24G_Diff[RFPath][TX_2S], */
1161 /* pHalData->BW20_24G_Diff[RFPath][TX_3S], pHalData->BW20_24G_Diff[RFPath][TX_4S]); */
1163 /* BW40-1S, BW40-2S */
1164 else if (BandWidth == CHANNEL_WIDTH_40)
1166 if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1167 txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
1168 if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1169 txPower += pHalData->BW40_24G_Diff[RFPath][TX_2S];
1170 if ((MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1171 txPower += pHalData->BW40_24G_Diff[RFPath][TX_3S];
1172 if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1173 txPower += pHalData->BW40_24G_Diff[RFPath][TX_4S];
1175 /* DBG_871X("+PowerDiff 2.4G (RF-%c): (BW40-1S, BW40-2S, BW40-3S, BW40-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
1176 /* pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S], */
1177 /* pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]); */
1179 /* Willis suggest adopt BW 40M power index while in BW 80 mode */
1180 else if (BandWidth == CHANNEL_WIDTH_80)
1182 if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1183 txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
1184 if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1185 txPower += pHalData->BW40_24G_Diff[RFPath][TX_2S];
1186 if ((MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1187 txPower += pHalData->BW40_24G_Diff[RFPath][TX_3S];
1188 if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1189 txPower += pHalData->BW40_24G_Diff[RFPath][TX_4S];
1191 /* DBG_871X("+PowerDiff 2.4G (RF-%c): (BW40-1S, BW40-2S, BW40-3S, BW40-4T) = (%d, %d, %d, %d) P.S. Current is in BW 80MHz\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
1192 /* pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S], */
1193 /* pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]); */
1196 else /* 3 ============================== 5 G ============================== */
1200 txPower = pHalData->Index5G_BW40_Base[RFPath][chnlIdx];
1204 DBG_871X("===> mpt_ProQueryCalTxPower_Jaguar: INVALID Rate.\n");
1207 /* DBG_871X("Base Tx power(RF-%c, Rate #%d, Channel Index %d) = 0x%X\n", */
1208 /* ((RFPath == 0)?'A':'B'), Rate, chnlIdx, txPower); */
1211 if ((MGN_6M <= Rate && Rate <= MGN_54M) && ! IS_CCK_RATE(Rate))
1213 txPower += pHalData->OFDM_5G_Diff[RFPath][TX_1S];
1214 /* DBG_871X("+PowerDiff 5G (RF-%c): (OFDM-1T) = (%d)\n", ((RFPath == 0)?'A':'B'), pHalData->OFDM_5G_Diff[RFPath][TX_1S]); */
1217 /* BW20-1S, BW20-2S */
1218 if (BandWidth == CHANNEL_WIDTH_20)
1220 if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1221 txPower += pHalData->BW20_5G_Diff[RFPath][TX_1S];
1222 if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1223 txPower += pHalData->BW20_5G_Diff[RFPath][TX_2S];
1224 if ((MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1225 txPower += pHalData->BW20_5G_Diff[RFPath][TX_3S];
1226 if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1227 txPower += pHalData->BW20_5G_Diff[RFPath][TX_4S];
1229 /* DBG_871X("+PowerDiff 5G (RF-%c): (BW20-1S, BW20-2S, BW20-3S, BW20-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
1230 /* pHalData->BW20_5G_Diff[RFPath][TX_1S], pHalData->BW20_5G_Diff[RFPath][TX_2S], */
1231 /* pHalData->BW20_5G_Diff[RFPath][TX_3S], pHalData->BW20_5G_Diff[RFPath][TX_4S]); */
1233 /* BW40-1S, BW40-2S */
1234 else if (BandWidth == CHANNEL_WIDTH_40)
1236 if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1237 txPower += pHalData->BW40_5G_Diff[RFPath][TX_1S];
1238 if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1239 txPower += pHalData->BW40_5G_Diff[RFPath][TX_2S];
1240 if ((MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1241 txPower += pHalData->BW40_5G_Diff[RFPath][TX_3S];
1242 if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1243 txPower += pHalData->BW40_5G_Diff[RFPath][TX_4S];
1245 /* DBG_871X("+PowerDiff 5G(RF-%c): (BW40-1S, BW40-2S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
1246 /* pHalData->BW40_5G_Diff[RFPath][TX_1S], pHalData->BW40_5G_Diff[RFPath][TX_2S], */
1247 /* pHalData->BW40_5G_Diff[RFPath][TX_3S], pHalData->BW40_5G_Diff[RFPath][TX_4S]); */
1249 /* BW80-1S, BW80-2S */
1250 else if (BandWidth == CHANNEL_WIDTH_80)
1252 /* <20121220, Kordan> Get the index of array "Index5G_BW80_Base". */
1253 u8 channel5G_80M[CHANNEL_MAX_NUMBER_5G_80M] = {42, 58, 106, 122, 138, 155, 171};
1254 for (i = 0; i < sizeof(channel5G_80M)/sizeof(u8); ++i)
1255 if (channel5G_80M[i] == Channel)
1258 txPower = pHalData->Index5G_BW80_Base[RFPath][chnlIdx];
1260 if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1261 txPower += + pHalData->BW80_5G_Diff[RFPath][TX_1S];
1262 if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1263 txPower += pHalData->BW80_5G_Diff[RFPath][TX_2S];
1264 if ((MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1265 txPower += pHalData->BW80_5G_Diff[RFPath][TX_3S];
1266 if ((MGN_MCS23 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1267 txPower += pHalData->BW80_5G_Diff[RFPath][TX_4S];
1269 /* DBG_871X("+PowerDiff 5G(RF-%c): (BW80-1S, BW80-2S, BW80-3S, BW80-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
1270 /* pHalData->BW80_5G_Diff[RFPath][TX_1S], pHalData->BW80_5G_Diff[RFPath][TX_2S], */
1271 /* pHalData->BW80_5G_Diff[RFPath][TX_3S], pHalData->BW80_5G_Diff[RFPath][TX_4S]); */
1279 PHY_GetTxPowerTrackingOffset(
1280 struct adapter *padapter,
1285 struct hal_com_data * pHalData = GET_HAL_DATA(padapter);
1286 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
1289 if (pDM_Odm->RFCalibrateInfo.TxPowerTrackControl == false)
1292 if ((Rate == MGN_1M) ||(Rate == MGN_2M)||(Rate == MGN_5_5M)||(Rate == MGN_11M))
1294 offset = pDM_Odm->Remnant_CCKSwingIdx;
1295 /* DBG_871X("+Remnant_CCKSwingIdx = 0x%x\n", RFPath, Rate, pDM_Odm->Remnant_CCKSwingIdx); */
1299 offset = pDM_Odm->Remnant_OFDMSwingIdx[RFPath];
1300 /* DBG_871X("+Remanant_OFDMSwingIdx[RFPath %u][Rate 0x%x] = 0x%x\n", RFPath, Rate, pDM_Odm->Remnant_OFDMSwingIdx[RFPath]); */
1308 PHY_GetRateIndexOfTxPowerByRate(
1315 case MGN_1M: index = 0; break;
1316 case MGN_2M: index = 1; break;
1317 case MGN_5_5M: index = 2; break;
1318 case MGN_11M: index = 3; break;
1319 case MGN_6M: index = 4; break;
1320 case MGN_9M: index = 5; break;
1321 case MGN_12M: index = 6; break;
1322 case MGN_18M: index = 7; break;
1323 case MGN_24M: index = 8; break;
1324 case MGN_36M: index = 9; break;
1325 case MGN_48M: index = 10; break;
1326 case MGN_54M: index = 11; break;
1327 case MGN_MCS0: index = 12; break;
1328 case MGN_MCS1: index = 13; break;
1329 case MGN_MCS2: index = 14; break;
1330 case MGN_MCS3: index = 15; break;
1331 case MGN_MCS4: index = 16; break;
1332 case MGN_MCS5: index = 17; break;
1333 case MGN_MCS6: index = 18; break;
1334 case MGN_MCS7: index = 19; break;
1335 case MGN_MCS8: index = 20; break;
1336 case MGN_MCS9: index = 21; break;
1337 case MGN_MCS10: index = 22; break;
1338 case MGN_MCS11: index = 23; break;
1339 case MGN_MCS12: index = 24; break;
1340 case MGN_MCS13: index = 25; break;
1341 case MGN_MCS14: index = 26; break;
1342 case MGN_MCS15: index = 27; break;
1343 case MGN_MCS16: index = 28; break;
1344 case MGN_MCS17: index = 29; break;
1345 case MGN_MCS18: index = 30; break;
1346 case MGN_MCS19: index = 31; break;
1347 case MGN_MCS20: index = 32; break;
1348 case MGN_MCS21: index = 33; break;
1349 case MGN_MCS22: index = 34; break;
1350 case MGN_MCS23: index = 35; break;
1351 case MGN_MCS24: index = 36; break;
1352 case MGN_MCS25: index = 37; break;
1353 case MGN_MCS26: index = 38; break;
1354 case MGN_MCS27: index = 39; break;
1355 case MGN_MCS28: index = 40; break;
1356 case MGN_MCS29: index = 41; break;
1357 case MGN_MCS30: index = 42; break;
1358 case MGN_MCS31: index = 43; break;
1359 case MGN_VHT1SS_MCS0: index = 44; break;
1360 case MGN_VHT1SS_MCS1: index = 45; break;
1361 case MGN_VHT1SS_MCS2: index = 46; break;
1362 case MGN_VHT1SS_MCS3: index = 47; break;
1363 case MGN_VHT1SS_MCS4: index = 48; break;
1364 case MGN_VHT1SS_MCS5: index = 49; break;
1365 case MGN_VHT1SS_MCS6: index = 50; break;
1366 case MGN_VHT1SS_MCS7: index = 51; break;
1367 case MGN_VHT1SS_MCS8: index = 52; break;
1368 case MGN_VHT1SS_MCS9: index = 53; break;
1369 case MGN_VHT2SS_MCS0: index = 54; break;
1370 case MGN_VHT2SS_MCS1: index = 55; break;
1371 case MGN_VHT2SS_MCS2: index = 56; break;
1372 case MGN_VHT2SS_MCS3: index = 57; break;
1373 case MGN_VHT2SS_MCS4: index = 58; break;
1374 case MGN_VHT2SS_MCS5: index = 59; break;
1375 case MGN_VHT2SS_MCS6: index = 60; break;
1376 case MGN_VHT2SS_MCS7: index = 61; break;
1377 case MGN_VHT2SS_MCS8: index = 62; break;
1378 case MGN_VHT2SS_MCS9: index = 63; break;
1379 case MGN_VHT3SS_MCS0: index = 64; break;
1380 case MGN_VHT3SS_MCS1: index = 65; break;
1381 case MGN_VHT3SS_MCS2: index = 66; break;
1382 case MGN_VHT3SS_MCS3: index = 67; break;
1383 case MGN_VHT3SS_MCS4: index = 68; break;
1384 case MGN_VHT3SS_MCS5: index = 69; break;
1385 case MGN_VHT3SS_MCS6: index = 70; break;
1386 case MGN_VHT3SS_MCS7: index = 71; break;
1387 case MGN_VHT3SS_MCS8: index = 72; break;
1388 case MGN_VHT3SS_MCS9: index = 73; break;
1389 case MGN_VHT4SS_MCS0: index = 74; break;
1390 case MGN_VHT4SS_MCS1: index = 75; break;
1391 case MGN_VHT4SS_MCS2: index = 76; break;
1392 case MGN_VHT4SS_MCS3: index = 77; break;
1393 case MGN_VHT4SS_MCS4: index = 78; break;
1394 case MGN_VHT4SS_MCS5: index = 79; break;
1395 case MGN_VHT4SS_MCS6: index = 80; break;
1396 case MGN_VHT4SS_MCS7: index = 81; break;
1397 case MGN_VHT4SS_MCS8: index = 82; break;
1398 case MGN_VHT4SS_MCS9: index = 83; break;
1400 DBG_871X("Invalid rate 0x%x in %s\n", Rate, __func__);
1408 PHY_GetTxPowerByRate(
1409 struct adapter *padapter,
1416 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
1418 u8 rateIndex = PHY_GetRateIndexOfTxPowerByRate(Rate);
1420 if ((padapter->registrypriv.RegEnableTxPowerByRate == 2 && pHalData->EEPROMRegulatory == 2) ||
1421 padapter->registrypriv.RegEnableTxPowerByRate == 0)
1424 if (Band != BAND_ON_2_4G && Band != BAND_ON_5G)
1426 DBG_871X("Invalid band %d in %s\n", Band, __func__);
1429 if (RFPath > ODM_RF_PATH_D)
1431 DBG_871X("Invalid RfPath %d in %s\n", RFPath, __func__);
1434 if (TxNum >= RF_MAX_TX_NUM)
1436 DBG_871X("Invalid TxNum %d in %s\n", TxNum, __func__);
1439 if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE)
1441 DBG_871X("Invalid RateIndex %d in %s\n", rateIndex, __func__);
1445 value = pHalData->TxPwrByRateOffset[Band][RFPath][TxNum][rateIndex];
1452 PHY_SetTxPowerByRate(
1453 struct adapter *padapter,
1461 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
1462 u8 rateIndex = PHY_GetRateIndexOfTxPowerByRate(Rate);
1464 if (Band != BAND_ON_2_4G && Band != BAND_ON_5G)
1466 DBG_871X("Invalid band %d in %s\n", Band, __func__);
1469 if (RFPath > ODM_RF_PATH_D)
1471 DBG_871X("Invalid RfPath %d in %s\n", RFPath, __func__);
1474 if (TxNum >= RF_MAX_TX_NUM)
1476 DBG_871X("Invalid TxNum %d in %s\n", TxNum, __func__);
1479 if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE)
1481 DBG_871X("Invalid RateIndex %d in %s\n", rateIndex, __func__);
1485 pHalData->TxPwrByRateOffset[Band][RFPath][TxNum][rateIndex] = Value;
1489 PHY_SetTxPowerLevelByPath(
1490 struct adapter *Adapter,
1495 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1496 bool bIsIn24G = (pHalData->CurrentBandType == BAND_ON_2_4G);
1498 /* if (pMgntInfo->RegNByteAccess == 0) */
1501 PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, CCK);
1503 PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, OFDM);
1504 PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, HT_MCS0_MCS7);
1506 if (pHalData->NumTotalRFPath >= 2)
1508 PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, HT_MCS8_MCS15);
1514 PHY_SetTxPowerIndexByRateArray(
1515 struct adapter * padapter,
1517 enum CHANNEL_WIDTH BandWidth,
1526 for (i = 0; i < RateArraySize; ++i)
1528 powerIndex = PHY_GetTxPowerIndex(padapter, RFPath, Rates[i], BandWidth, Channel);
1529 PHY_SetTxPowerIndex(padapter, powerIndex, RFPath, Rates[i]);
1534 phy_GetWorldWideLimit(
1538 s8 min = LimitTable[0];
1541 for (i = 0; i < MAX_REGULATION_NUM; ++i) {
1542 if (LimitTable[i] < min)
1543 min = LimitTable[i];
1550 phy_GetChannelIndexOfTxPowerLimit(
1555 s8 channelIndex = -1;
1556 u8 channel5G[CHANNEL_MAX_NUMBER_5G] =
1557 {36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 100, 102, 104, 106, 108, 110, 112,
1558 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 149, 151,
1559 153, 155, 157, 159, 161, 163, 165, 167, 168, 169, 171, 173, 175, 177};
1561 if (Band == BAND_ON_2_4G)
1563 channelIndex = Channel - 1;
1565 else if (Band == BAND_ON_5G)
1567 for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i)
1569 if (channel5G[i] == Channel)
1575 DBG_871X("Invalid Band %d in %s", Band, __func__);
1578 if (channelIndex == -1)
1579 DBG_871X("Invalid Channel %d of Band %d in %s", Channel, Band, __func__);
1581 return channelIndex;
1585 PHY_GetTxPowerLimit(
1586 struct adapter * Adapter,
1588 enum BAND_TYPE Band,
1589 enum CHANNEL_WIDTH Bandwidth,
1595 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1596 s16 band = -1, regulation = -1, bandwidth = -1,
1597 rateSection = -1, channel = -1;
1598 s8 powerLimit = MAX_POWER_INDEX;
1600 if ((Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory != 1) ||
1601 Adapter->registrypriv.RegEnableTxPowerLimit == 0)
1602 return MAX_POWER_INDEX;
1604 switch (Adapter->registrypriv.RegPwrTblSel)
1607 regulation = TXPWR_LMT_ETSI;
1610 regulation = TXPWR_LMT_MKK;
1613 regulation = TXPWR_LMT_FCC;
1617 regulation = TXPWR_LMT_WW;
1621 regulation = (Band == BAND_ON_2_4G) ? pHalData->Regulation2_4G
1622 : pHalData->Regulation5G;
1626 /* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", Adapter->registrypriv.RegPwrTblSel, regulation); */
1629 if (Band == BAND_ON_2_4G) band = 0;
1630 else if (Band == BAND_ON_5G) band = 1;
1632 if (Bandwidth == CHANNEL_WIDTH_20) bandwidth = 0;
1633 else if (Bandwidth == CHANNEL_WIDTH_40) bandwidth = 1;
1634 else if (Bandwidth == CHANNEL_WIDTH_80) bandwidth = 2;
1635 else if (Bandwidth == CHANNEL_WIDTH_160) bandwidth = 3;
1639 case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M:
1643 case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M:
1644 case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M:
1648 case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3:
1649 case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7:
1653 case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11:
1654 case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15:
1658 case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19:
1659 case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23:
1663 case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27:
1664 case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31:
1668 case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2:
1669 case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5:
1670 case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8:
1671 case MGN_VHT1SS_MCS9:
1675 case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2:
1676 case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5:
1677 case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8:
1678 case MGN_VHT2SS_MCS9:
1682 case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2:
1683 case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5:
1684 case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8:
1685 case MGN_VHT3SS_MCS9:
1689 case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2:
1690 case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5:
1691 case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8:
1692 case MGN_VHT4SS_MCS9:
1697 DBG_871X("Wrong rate 0x%x\n", DataRate);
1701 if (Band == BAND_ON_5G && rateSection == 0)
1702 DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate);
1704 /* workaround for wrong index combination to obtain tx power limit, */
1705 /* OFDM only exists in BW 20M */
1706 if (rateSection == 1)
1709 /* workaround for wrong index combination to obtain tx power limit, */
1710 /* CCK table will only be given in BW 20M */
1711 if (rateSection == 0)
1714 /* workaround for wrong indxe combination to obtain tx power limit, */
1715 /* HT on 80M will reference to HT on 40M */
1716 if ((rateSection == 2 || rateSection == 3) && Band == BAND_ON_5G && bandwidth == 2) {
1720 if (Band == BAND_ON_2_4G)
1721 channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, Channel);
1722 else if (Band == BAND_ON_5G)
1723 channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, Channel);
1724 else if (Band == BAND_ON_BOTH)
1726 /* BAND_ON_BOTH don't care temporarily */
1729 if (band == -1 || regulation == -1 || bandwidth == -1 ||
1730 rateSection == -1 || channel == -1)
1732 /* DBG_871X("Wrong index value to access power limit table [band %d][regulation %d][bandwidth %d][rf_path %d][rate_section %d][chnlGroup %d]\n", */
1733 /* band, regulation, bandwidth, RfPath, rateSection, channelGroup); */
1735 return MAX_POWER_INDEX;
1738 if (Band == BAND_ON_2_4G) {
1739 s8 limits[10] = {0}; u8 i = 0;
1740 for (i = 0; i < MAX_REGULATION_NUM; i++)
1741 limits[i] = pHalData->TxPwrLimit_2_4G[i][bandwidth][rateSection][channel][RfPath];
1743 powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) :
1744 pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channel][RfPath];
1746 } else if (Band == BAND_ON_5G) {
1747 s8 limits[10] = {0}; u8 i = 0;
1748 for (i = 0; i < MAX_REGULATION_NUM; ++i)
1749 limits[i] = pHalData->TxPwrLimit_5G[i][bandwidth][rateSection][channel][RfPath];
1751 powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) :
1752 pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channel][RfPath];
1754 DBG_871X("No power limit table of the specified band\n");
1756 /* combine 5G VHT & HT rate */
1757 /* 5G 20M and 40M HT and VHT can cross reference */
1759 if (Band == BAND_ON_5G && powerLimit == MAX_POWER_INDEX) {
1760 if (bandwidth == 0 || bandwidth == 1) {
1761 RT_TRACE(COMP_INIT, DBG_LOUD, ("No power limit table of the specified band %d, bandwidth %d, ratesection %d, rf path %d\n",
1762 band, bandwidth, rateSection, RfPath));
1763 if (rateSection == 2)
1764 powerLimit = pHalData->TxPwrLimit_5G[regulation]
1765 [bandwidth][4][channelGroup][RfPath];
1766 else if (rateSection == 4)
1767 powerLimit = pHalData->TxPwrLimit_5G[regulation]
1768 [bandwidth][2][channelGroup][RfPath];
1769 else if (rateSection == 3)
1770 powerLimit = pHalData->TxPwrLimit_5G[regulation]
1771 [bandwidth][5][channelGroup][RfPath];
1772 else if (rateSection == 5)
1773 powerLimit = pHalData->TxPwrLimit_5G[regulation]
1774 [bandwidth][3][channelGroup][RfPath];
1778 /* DBG_871X("TxPwrLmt[Regulation %d][Band %d][BW %d][RFPath %d][Rate 0x%x][Chnl %d] = %d\n", */
1779 /* regulation, pHalData->CurrentBandType, Bandwidth, RfPath, DataRate, Channel, powerLimit); */
1784 phy_CrossReferenceHTAndVHTTxPowerLimit(
1785 struct adapter * padapter
1788 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
1789 u8 regulation, bw, channel, rateSection;
1792 for (regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation)
1794 for (bw = 0; bw < MAX_5G_BANDWITH_NUM; ++bw)
1796 for (channel = 0; channel < CHANNEL_MAX_NUMBER_5G; ++channel)
1798 for (rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection)
1800 tempPwrLmt = pHalData->TxPwrLimit_5G[regulation][bw][rateSection][channel][ODM_RF_PATH_A];
1801 if (tempPwrLmt == MAX_POWER_INDEX)
1803 u8 baseSection = 2, refSection = 6;
1804 if (bw == 0 || bw == 1) { /* 5G 20M 40M VHT and HT can cross reference */
1805 /* DBG_871X("No power limit table of the specified band %d, bandwidth %d, ratesection %d, channel %d, rf path %d\n", */
1806 /* 1, bw, rateSection, channel, ODM_RF_PATH_A); */
1807 if (rateSection >= 2 && rateSection <= 9) {
1808 if (rateSection == 2)
1813 else if (rateSection == 3)
1818 else if (rateSection == 4)
1823 else if (rateSection == 5)
1828 else if (rateSection == 6)
1833 else if (rateSection == 7)
1838 else if (rateSection == 8)
1843 else if (rateSection == 9)
1848 pHalData->TxPwrLimit_5G[regulation][bw][baseSection][channel][ODM_RF_PATH_A] =
1849 pHalData->TxPwrLimit_5G[regulation][bw][refSection][channel][ODM_RF_PATH_A];
1852 /* DBG_871X("use other value %d", tempPwrLmt); */
1862 PHY_ConvertTxPowerLimitToPowerIndex(
1863 struct adapter * Adapter
1866 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1867 u8 BW40PwrBasedBm2_4G = 0x2E;
1868 u8 regulation, bw, channel, rateSection;
1869 s8 tempValue = 0, tempPwrLmt = 0;
1872 /* DBG_871X("=====> PHY_ConvertTxPowerLimitToPowerIndex()\n"); */
1874 phy_CrossReferenceHTAndVHTTxPowerLimit(Adapter);
1876 for (regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation)
1878 for (bw = 0; bw < MAX_2_4G_BANDWITH_NUM; ++bw)
1880 for (channel = 0; channel < CHANNEL_MAX_NUMBER_2G; ++channel)
1882 for (rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection)
1884 tempPwrLmt = pHalData->TxPwrLimit_2_4G[regulation][bw][rateSection][channel][ODM_RF_PATH_A];
1886 for (rfPath = ODM_RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath)
1888 if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE)
1890 if (rateSection == 5) /* HT 4T */
1891 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, BAND_ON_2_4G, rfPath, RF_4TX, HT_MCS24_MCS31);
1892 else if (rateSection == 4) /* HT 3T */
1893 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, BAND_ON_2_4G, rfPath, RF_3TX, HT_MCS16_MCS23);
1894 else if (rateSection == 3) /* HT 2T */
1895 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, BAND_ON_2_4G, rfPath, RF_2TX, HT_MCS8_MCS15);
1896 else if (rateSection == 2) /* HT 1T */
1897 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, BAND_ON_2_4G, rfPath, RF_1TX, HT_MCS0_MCS7);
1898 else if (rateSection == 1) /* OFDM */
1899 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, BAND_ON_2_4G, rfPath, RF_1TX, OFDM);
1900 else if (rateSection == 0) /* CCK */
1901 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, BAND_ON_2_4G, rfPath, RF_1TX, CCK);
1904 BW40PwrBasedBm2_4G = Adapter->registrypriv.RegPowerBase * 2;
1906 if (tempPwrLmt != MAX_POWER_INDEX) {
1907 tempValue = tempPwrLmt - BW40PwrBasedBm2_4G;
1908 pHalData->TxPwrLimit_2_4G[regulation][bw][rateSection][channel][rfPath] = tempValue;
1916 /* DBG_871X("<===== PHY_ConvertTxPowerLimitToPowerIndex()\n"); */
1920 PHY_InitTxPowerLimit(
1921 struct adapter * Adapter
1924 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1927 /* DBG_871X("=====> PHY_InitTxPowerLimit()!\n"); */
1929 for (i = 0; i < MAX_REGULATION_NUM; ++i)
1931 for (j = 0; j < MAX_2_4G_BANDWITH_NUM; ++j)
1932 for (k = 0; k < MAX_RATE_SECTION_NUM; ++k)
1933 for (m = 0; m < CHANNEL_MAX_NUMBER_2G; ++m)
1934 for (l = 0; l < MAX_RF_PATH_NUM; ++l)
1935 pHalData->TxPwrLimit_2_4G[i][j][k][m][l] = MAX_POWER_INDEX;
1938 for (i = 0; i < MAX_REGULATION_NUM; ++i)
1940 for (j = 0; j < MAX_5G_BANDWITH_NUM; ++j)
1941 for (k = 0; k < MAX_RATE_SECTION_NUM; ++k)
1942 for (m = 0; m < CHANNEL_MAX_NUMBER_5G; ++m)
1943 for (l = 0; l < MAX_RF_PATH_NUM; ++l)
1944 pHalData->TxPwrLimit_5G[i][j][k][m][l] = MAX_POWER_INDEX;
1947 /* DBG_871X("<===== PHY_InitTxPowerLimit()!\n"); */
1951 PHY_SetTxPowerLimit(
1952 struct adapter * Adapter,
1962 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1963 u8 regulation = 0, bandwidth = 0, rateSection = 0,
1965 s8 powerLimit = 0, prevPowerLimit, channelIndex;
1967 /* DBG_871X("Index of power limit table [band %s][regulation %s][bw %s][rate section %s][rf path %s][chnl %s][val %s]\n", */
1968 /* Band, Regulation, Bandwidth, RateSection, RfPath, Channel, PowerLimit); */
1970 if (!GetU1ByteIntegerFromStringInDecimal((s8 *)Channel, &channel) ||
1971 !GetU1ByteIntegerFromStringInDecimal((s8 *)PowerLimit, &powerLimit))
1973 DBG_871X("Illegal index of power limit table [chnl %s][val %s]\n", Channel, PowerLimit);
1976 powerLimit = powerLimit > MAX_POWER_INDEX ? MAX_POWER_INDEX : powerLimit;
1978 if (eqNByte(Regulation, (u8 *)("FCC"), 3)) regulation = 0;
1979 else if (eqNByte(Regulation, (u8 *)("MKK"), 3)) regulation = 1;
1980 else if (eqNByte(Regulation, (u8 *)("ETSI"), 4)) regulation = 2;
1981 else if (eqNByte(Regulation, (u8 *)("WW13"), 4)) regulation = 3;
1983 if (eqNByte(RateSection, (u8 *)("CCK"), 3) && eqNByte(RfPath, (u8 *)("1T"), 2))
1985 else if (eqNByte(RateSection, (u8 *)("OFDM"), 4) && eqNByte(RfPath, (u8 *)("1T"), 2))
1987 else if (eqNByte(RateSection, (u8 *)("HT"), 2) && eqNByte(RfPath, (u8 *)("1T"), 2))
1989 else if (eqNByte(RateSection, (u8 *)("HT"), 2) && eqNByte(RfPath, (u8 *)("2T"), 2))
1991 else if (eqNByte(RateSection, (u8 *)("HT"), 2) && eqNByte(RfPath, (u8 *)("3T"), 2))
1993 else if (eqNByte(RateSection, (u8 *)("HT"), 2) && eqNByte(RfPath, (u8 *)("4T"), 2))
1995 else if (eqNByte(RateSection, (u8 *)("VHT"), 3) && eqNByte(RfPath, (u8 *)("1T"), 2))
1997 else if (eqNByte(RateSection, (u8 *)("VHT"), 3) && eqNByte(RfPath, (u8 *)("2T"), 2))
1999 else if (eqNByte(RateSection, (u8 *)("VHT"), 3) && eqNByte(RfPath, (u8 *)("3T"), 2))
2001 else if (eqNByte(RateSection, (u8 *)("VHT"), 3) && eqNByte(RfPath, (u8 *)("4T"), 2))
2005 DBG_871X("Wrong rate section!\n");
2010 if (eqNByte(Bandwidth, (u8 *)("20M"), 3)) bandwidth = 0;
2011 else if (eqNByte(Bandwidth, (u8 *)("40M"), 3)) bandwidth = 1;
2012 else if (eqNByte(Bandwidth, (u8 *)("80M"), 3)) bandwidth = 2;
2013 else if (eqNByte(Bandwidth, (u8 *)("160M"), 4)) bandwidth = 3;
2015 if (eqNByte(Band, (u8 *)("2.4G"), 4))
2017 channelIndex = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, channel);
2019 if (channelIndex == -1)
2022 prevPowerLimit = pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A];
2024 if (powerLimit < prevPowerLimit)
2025 pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] = powerLimit;
2027 /* DBG_871X("2.4G Band value : [regulation %d][bw %d][rate_section %d][chnl %d][val %d]\n", */
2028 /* regulation, bandwidth, rateSection, channelIndex, pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A]); */
2030 else if (eqNByte(Band, (u8 *)("5G"), 2))
2032 channelIndex = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, channel);
2034 if (channelIndex == -1)
2037 prevPowerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A];
2039 if (powerLimit < prevPowerLimit)
2040 pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] = powerLimit;
2042 /* DBG_871X("5G Band value : [regulation %d][bw %d][rate_section %d][chnl %d][val %d]\n", */
2043 /* regulation, bandwidth, rateSection, channel, pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A]); */
2047 DBG_871X("Cannot recognize the band info in %s\n", Band);
2053 PHY_GetTxPowerIndex(
2054 struct adapter * padapter,
2057 enum CHANNEL_WIDTH BandWidth,
2061 return PHY_GetTxPowerIndex_8723B(padapter, RFPath, Rate, BandWidth, Channel);
2065 PHY_SetTxPowerIndex(
2066 struct adapter * padapter,
2072 PHY_SetTxPowerIndex_8723B(padapter, PowerIndex, RFPath, Rate);
2076 Hal_ChannelPlanToRegulation(
2077 struct adapter * Adapter,
2081 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
2082 pHalData->Regulation2_4G = TXPWR_LMT_WW;
2083 pHalData->Regulation5G = TXPWR_LMT_WW;
2085 switch (ChannelPlan)
2087 case RT_CHANNEL_DOMAIN_WORLD_NULL:
2088 pHalData->Regulation2_4G = TXPWR_LMT_WW;
2090 case RT_CHANNEL_DOMAIN_ETSI1_NULL:
2091 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2093 case RT_CHANNEL_DOMAIN_FCC1_NULL:
2094 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2096 case RT_CHANNEL_DOMAIN_MKK1_NULL:
2097 pHalData->Regulation2_4G = TXPWR_LMT_MKK;
2099 case RT_CHANNEL_DOMAIN_ETSI2_NULL:
2100 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2102 case RT_CHANNEL_DOMAIN_FCC1_FCC1:
2103 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2104 pHalData->Regulation5G = TXPWR_LMT_FCC;
2106 case RT_CHANNEL_DOMAIN_WORLD_ETSI1:
2107 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2108 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2110 case RT_CHANNEL_DOMAIN_MKK1_MKK1:
2111 pHalData->Regulation2_4G = TXPWR_LMT_MKK;
2112 pHalData->Regulation5G = TXPWR_LMT_MKK;
2114 case RT_CHANNEL_DOMAIN_WORLD_KCC1:
2115 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2116 pHalData->Regulation5G = TXPWR_LMT_MKK;
2118 case RT_CHANNEL_DOMAIN_WORLD_FCC2:
2119 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2120 pHalData->Regulation5G = TXPWR_LMT_FCC;
2122 case RT_CHANNEL_DOMAIN_WORLD_FCC3:
2123 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2124 pHalData->Regulation5G = TXPWR_LMT_FCC;
2126 case RT_CHANNEL_DOMAIN_WORLD_FCC4:
2127 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2128 pHalData->Regulation5G = TXPWR_LMT_FCC;
2130 case RT_CHANNEL_DOMAIN_WORLD_FCC5:
2131 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2132 pHalData->Regulation5G = TXPWR_LMT_FCC;
2134 case RT_CHANNEL_DOMAIN_WORLD_FCC6:
2135 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2136 pHalData->Regulation5G = TXPWR_LMT_FCC;
2138 case RT_CHANNEL_DOMAIN_FCC1_FCC7:
2139 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2140 pHalData->Regulation5G = TXPWR_LMT_FCC;
2142 case RT_CHANNEL_DOMAIN_WORLD_ETSI2:
2143 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2144 pHalData->Regulation5G = TXPWR_LMT_FCC;
2146 case RT_CHANNEL_DOMAIN_WORLD_ETSI3:
2147 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2148 pHalData->Regulation5G = TXPWR_LMT_FCC;
2150 case RT_CHANNEL_DOMAIN_MKK1_MKK2:
2151 pHalData->Regulation2_4G = TXPWR_LMT_MKK;
2152 pHalData->Regulation5G = TXPWR_LMT_FCC;
2154 case RT_CHANNEL_DOMAIN_MKK1_MKK3:
2155 pHalData->Regulation2_4G = TXPWR_LMT_MKK;
2156 pHalData->Regulation5G = TXPWR_LMT_FCC;
2158 case RT_CHANNEL_DOMAIN_FCC1_NCC1:
2159 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2160 pHalData->Regulation5G = TXPWR_LMT_FCC;
2162 case RT_CHANNEL_DOMAIN_FCC1_NCC2:
2163 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2164 pHalData->Regulation5G = TXPWR_LMT_FCC;
2166 case RT_CHANNEL_DOMAIN_GLOBAL_NULL:
2167 pHalData->Regulation2_4G = TXPWR_LMT_WW;
2168 pHalData->Regulation5G = TXPWR_LMT_WW;
2170 case RT_CHANNEL_DOMAIN_ETSI1_ETSI4:
2171 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2172 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2174 case RT_CHANNEL_DOMAIN_FCC1_FCC2:
2175 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2176 pHalData->Regulation5G = TXPWR_LMT_FCC;
2178 case RT_CHANNEL_DOMAIN_FCC1_NCC3:
2179 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2180 pHalData->Regulation5G = TXPWR_LMT_FCC;
2182 case RT_CHANNEL_DOMAIN_WORLD_ETSI5:
2183 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2184 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2186 case RT_CHANNEL_DOMAIN_FCC1_FCC8:
2187 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2188 pHalData->Regulation5G = TXPWR_LMT_FCC;
2190 case RT_CHANNEL_DOMAIN_WORLD_ETSI6:
2191 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2192 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2194 case RT_CHANNEL_DOMAIN_WORLD_ETSI7:
2195 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2196 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2198 case RT_CHANNEL_DOMAIN_WORLD_ETSI8:
2199 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2200 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2202 case RT_CHANNEL_DOMAIN_WORLD_ETSI9:
2203 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2204 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2206 case RT_CHANNEL_DOMAIN_WORLD_ETSI10:
2207 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2208 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2210 case RT_CHANNEL_DOMAIN_WORLD_ETSI11:
2211 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2212 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2214 case RT_CHANNEL_DOMAIN_FCC1_NCC4:
2215 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2216 pHalData->Regulation5G = TXPWR_LMT_FCC;
2218 case RT_CHANNEL_DOMAIN_WORLD_ETSI12:
2219 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2220 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2222 case RT_CHANNEL_DOMAIN_FCC1_FCC9:
2223 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2224 pHalData->Regulation5G = TXPWR_LMT_FCC;
2226 case RT_CHANNEL_DOMAIN_WORLD_ETSI13:
2227 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2228 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2230 case RT_CHANNEL_DOMAIN_FCC1_FCC10:
2231 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2232 pHalData->Regulation5G = TXPWR_LMT_FCC;
2234 case RT_CHANNEL_DOMAIN_REALTEK_DEFINE: /* Realtek Reserve */
2235 pHalData->Regulation2_4G = TXPWR_LMT_WW;
2236 pHalData->Regulation5G = TXPWR_LMT_WW;
2243 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
2245 static char file_path_bs[PATH_MAX];
2247 #define GetLineFromBuffer(buffer) strsep(&buffer, "\n")
2250 phy_ConfigMACWithParaFile(
2251 struct adapter *Adapter,
2255 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
2256 int rlen = 0, rtStatus = _FAIL;
2257 char *szLine, *ptmp;
2258 u32 u4bRegOffset, u4bRegValue, u4bMove;
2260 if (!(Adapter->registrypriv.load_phy_file & LOAD_MAC_PARA_FILE))
2263 memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
2265 if ((pHalData->mac_reg_len == 0) && (pHalData->mac_reg == NULL))
2267 rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName);
2269 if (rtw_is_file_readable(file_path_bs) == true)
2271 rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
2274 rtStatus = _SUCCESS;
2275 pHalData->mac_reg = vzalloc(rlen);
2276 if (pHalData->mac_reg) {
2277 memcpy(pHalData->mac_reg, pHalData->para_file_buf, rlen);
2278 pHalData->mac_reg_len = rlen;
2281 DBG_871X("%s mac_reg alloc fail !\n", __func__);
2288 if ((pHalData->mac_reg_len != 0) && (pHalData->mac_reg != NULL)) {
2289 memcpy(pHalData->para_file_buf, pHalData->mac_reg, pHalData->mac_reg_len);
2290 rtStatus = _SUCCESS;
2293 DBG_871X("%s(): Critical Error !!!\n", __func__);
2297 if (rtStatus == _SUCCESS)
2299 ptmp = pHalData->para_file_buf;
2300 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
2302 if (!IsCommentString(szLine))
2304 /* Get 1st hex value as register offset */
2305 if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
2307 if (u4bRegOffset == 0xffff)
2312 /* Get 2nd hex value as register value. */
2314 if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
2316 rtw_write8(Adapter, u4bRegOffset, (u8)u4bRegValue);
2324 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName);
2331 phy_ConfigBBWithParaFile(
2332 struct adapter *Adapter,
2337 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
2338 int rlen = 0, rtStatus = _FAIL;
2339 char *szLine, *ptmp;
2340 u32 u4bRegOffset, u4bRegValue, u4bMove;
2342 u32 *pBufLen = NULL;
2344 if (!(Adapter->registrypriv.load_phy_file & LOAD_BB_PARA_FILE))
2349 case CONFIG_BB_PHY_REG:
2350 pBuf = pHalData->bb_phy_reg;
2351 pBufLen = &pHalData->bb_phy_reg_len;
2353 case CONFIG_BB_AGC_TAB:
2354 pBuf = pHalData->bb_agc_tab;
2355 pBufLen = &pHalData->bb_agc_tab_len;
2358 DBG_871X("Unknown ConfigType!! %d\r\n", ConfigType);
2362 memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
2364 if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL))
2366 rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName);
2368 if (rtw_is_file_readable(file_path_bs) == true)
2370 rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
2373 rtStatus = _SUCCESS;
2374 pBuf = vzalloc(rlen);
2376 memcpy(pBuf, pHalData->para_file_buf, rlen);
2381 case CONFIG_BB_PHY_REG:
2382 pHalData->bb_phy_reg = pBuf;
2384 case CONFIG_BB_AGC_TAB:
2385 pHalData->bb_agc_tab = pBuf;
2390 DBG_871X("%s(): ConfigType %d alloc fail !\n", __func__, ConfigType);
2397 if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) {
2398 memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
2399 rtStatus = _SUCCESS;
2402 DBG_871X("%s(): Critical Error !!!\n", __func__);
2406 if (rtStatus == _SUCCESS)
2408 ptmp = pHalData->para_file_buf;
2409 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
2411 if (!IsCommentString(szLine))
2413 /* Get 1st hex value as register offset. */
2414 if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
2416 if (u4bRegOffset == 0xffff)
2420 else if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe)
2424 else if (u4bRegOffset == 0xfd)
2428 else if (u4bRegOffset == 0xfc)
2432 else if (u4bRegOffset == 0xfb)
2436 else if (u4bRegOffset == 0xfa)
2440 else if (u4bRegOffset == 0xf9)
2445 /* Get 2nd hex value as register value. */
2447 if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
2449 /* DBG_871X("[BB-ADDR]%03lX =%08lX\n", u4bRegOffset, u4bRegValue); */
2450 PHY_SetBBReg(Adapter, u4bRegOffset, bMaskDWord, u4bRegValue);
2452 if (u4bRegOffset == 0xa24)
2453 pHalData->odmpriv.RFCalibrateInfo.RegA24 = u4bRegValue;
2455 /* Add 1us delay between BB/RF register setting. */
2464 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName);
2471 phy_DecryptBBPgParaFile(
2472 struct adapter * Adapter,
2479 char *BufOfLines, *ptmp;
2481 /* DBG_871X("=====>phy_DecryptBBPgParaFile()\n"); */
2482 /* 32 the ascii code of the first visable char, 126 the last one */
2483 for (i = 0; i < 95; ++i)
2484 map[i] = (u8) (94 - i);
2488 for (BufOfLines = GetLineFromBuffer(ptmp); BufOfLines != NULL; BufOfLines = GetLineFromBuffer(ptmp))
2490 /* DBG_871X("Encrypted Line: %s\n", BufOfLines); */
2492 for (j = 0; j < strlen(BufOfLines); ++j)
2494 currentChar = BufOfLines[j];
2496 if (currentChar == '\0')
2499 currentChar -= (u8) ((((i + j) * 3) % 128));
2501 BufOfLines[j] = map[currentChar - 32] + 32;
2503 /* DBG_871X("Decrypted Line: %s\n", BufOfLines); */
2504 if (strlen(BufOfLines) != 0)
2506 BufOfLines[strlen(BufOfLines)] = '\n';
2511 phy_ParseBBPgParaFile(
2512 struct adapter * Adapter,
2516 int rtStatus = _SUCCESS;
2517 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
2518 char *szLine, *ptmp;
2519 u32 u4bRegOffset, u4bRegMask, u4bRegValue;
2521 bool firstLine = true;
2523 u8 band = 0, rf_path = 0;
2525 /* DBG_871X("=====>phy_ParseBBPgParaFile()\n"); */
2527 if (Adapter->registrypriv.RegDecryptCustomFile == 1)
2528 phy_DecryptBBPgParaFile(Adapter, buffer);
2531 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
2533 if (!IsCommentString(szLine))
2535 if (isAllSpaceOrTab(szLine, sizeof(*szLine)))
2538 /* Get header info (relative value or exact value) */
2541 if (eqNByte(szLine, (u8 *)("#[v1]"), 5))
2544 pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0';
2545 /* DBG_871X("This is a new format PHY_REG_PG.txt\n"); */
2547 else if (eqNByte(szLine, (u8 *)("#[v0]"), 5))
2549 pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0';
2550 /* DBG_871X("This is a old format PHY_REG_PG.txt ok\n"); */
2554 DBG_871X("The format in PHY_REG_PG are invalid %s\n", szLine);
2558 if (eqNByte(szLine + 5, (u8 *)("[Exact]#"), 8))
2560 pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE;
2561 /* DBG_871X("The values in PHY_REG_PG are exact values ok\n"); */
2565 else if (eqNByte(szLine + 5, (u8 *)("[Relative]#"), 11))
2567 pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_RELATIVE_VALUE;
2568 /* DBG_871X("The values in PHY_REG_PG are relative values ok\n"); */
2574 DBG_871X("The values in PHY_REG_PG are invalid %s\n", szLine);
2579 if (pHalData->odmpriv.PhyRegPgVersion == 0)
2581 /* Get 1st hex value as register offset. */
2582 if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
2585 if (u4bRegOffset == 0xffff)
2590 /* Get 2nd hex value as register mask. */
2591 if (GetHexValueFromString(szLine, &u4bRegMask, &u4bMove))
2596 if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE)
2598 /* Get 3rd hex value as register value. */
2599 if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
2601 PHY_StoreTxPowerByRate(Adapter, 0, 0, 1, u4bRegOffset, u4bRegMask, u4bRegValue);
2602 /* DBG_871X("[ADDR] %03X =%08X Mask =%08x\n", u4bRegOffset, u4bRegValue, u4bRegMask); */
2609 else if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE)
2611 u32 combineValue = 0;
2612 u8 integer = 0, fraction = 0;
2614 if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove))
2620 if (fraction == 5) integer += 1;
2621 combineValue |= (((integer / 10) << 4) + (integer % 10));
2622 /* DBG_871X(" %d", integer); */
2624 if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove))
2630 if (fraction == 5) integer += 1;
2632 combineValue |= (((integer / 10) << 4) + (integer % 10));
2633 /* DBG_871X(" %d", integer); */
2635 if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove))
2641 if (fraction == 5) integer += 1;
2643 combineValue |= (((integer / 10) << 4) + (integer % 10));
2644 /* DBG_871X(" %d", integer); */
2646 if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove))
2652 if (fraction == 5) integer += 1;
2654 combineValue |= (((integer / 10) << 4) + (integer % 10));
2655 /* DBG_871X(" %d", integer); */
2656 PHY_StoreTxPowerByRate(Adapter, 0, 0, 1, u4bRegOffset, u4bRegMask, combineValue);
2658 /* DBG_871X("[ADDR] 0x%3x = 0x%4x\n", u4bRegOffset, combineValue); */
2662 else if (pHalData->odmpriv.PhyRegPgVersion > 0)
2666 if (eqNByte(szLine, "0xffff", 6))
2669 if (!eqNByte("#[END]#", szLine, 7))
2671 /* load the table label info */
2672 if (szLine[0] == '#')
2675 if (eqNByte(szLine, "#[2.4G]" , 7))
2677 band = BAND_ON_2_4G;
2680 else if (eqNByte(szLine, "#[5G]", 5))
2687 DBG_871X("Invalid band %s in PHY_REG_PG.txt\n", szLine);
2691 rf_path = szLine[index] - 'A';
2692 /* DBG_871X(" Table label Band %d, RfPath %d\n", band, rf_path); */
2694 else /* load rows of tables */
2696 if (szLine[1] == '1')
2698 else if (szLine[1] == '2')
2700 else if (szLine[1] == '3')
2702 else if (szLine[1] == '4')
2706 DBG_871X("Invalid row in PHY_REG_PG.txt %c\n", szLine[1]);
2710 while (szLine[index] != ']')
2712 ++index;/* skip ] */
2714 /* Get 2nd hex value as register offset. */
2716 if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
2721 /* Get 2nd hex value as register mask. */
2722 if (GetHexValueFromString(szLine, &u4bRegMask, &u4bMove))
2727 if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE)
2729 /* Get 3rd hex value as register value. */
2730 if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
2732 PHY_StoreTxPowerByRate(Adapter, band, rf_path, tx_num, u4bRegOffset, u4bRegMask, u4bRegValue);
2733 /* DBG_871X("[ADDR] %03X (tx_num %d) =%08X Mask =%08x\n", u4bRegOffset, tx_num, u4bRegValue, u4bRegMask); */
2740 else if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE)
2742 u32 combineValue = 0;
2743 u8 integer = 0, fraction = 0;
2745 if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove))
2751 if (fraction == 5) integer += 1;
2752 combineValue |= (((integer / 10) << 4) + (integer % 10));
2753 /* DBG_871X(" %d", integer); */
2755 if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove))
2761 if (fraction == 5) integer += 1;
2763 combineValue |= (((integer / 10) << 4) + (integer % 10));
2764 /* DBG_871X(" %d", integer); */
2766 if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove))
2772 if (fraction == 5) integer += 1;
2774 combineValue |= (((integer / 10) << 4) + (integer % 10));
2775 /* DBG_871X(" %d", integer); */
2777 if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove))
2783 if (fraction == 5) integer += 1;
2785 combineValue |= (((integer / 10) << 4) + (integer % 10));
2786 /* DBG_871X(" %d", integer); */
2787 PHY_StoreTxPowerByRate(Adapter, band, rf_path, tx_num, u4bRegOffset, u4bRegMask, combineValue);
2789 /* DBG_871X("[ADDR] 0x%3x (tx_num %d) = 0x%4x\n", u4bRegOffset, tx_num, combineValue); */
2796 /* DBG_871X("<=====phy_ParseBBPgParaFile()\n"); */
2801 phy_ConfigBBWithPgParaFile(
2802 struct adapter *Adapter,
2805 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
2806 int rlen = 0, rtStatus = _FAIL;
2808 if (!(Adapter->registrypriv.load_phy_file & LOAD_BB_PG_PARA_FILE))
2811 memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
2813 if ((pHalData->bb_phy_reg_pg_len == 0) && (pHalData->bb_phy_reg_pg == NULL))
2815 rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName);
2817 if (rtw_is_file_readable(file_path_bs) == true)
2819 rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
2822 rtStatus = _SUCCESS;
2823 pHalData->bb_phy_reg_pg = vzalloc(rlen);
2824 if (pHalData->bb_phy_reg_pg) {
2825 memcpy(pHalData->bb_phy_reg_pg, pHalData->para_file_buf, rlen);
2826 pHalData->bb_phy_reg_pg_len = rlen;
2829 DBG_871X("%s bb_phy_reg_pg alloc fail !\n", __func__);
2836 if ((pHalData->bb_phy_reg_pg_len != 0) && (pHalData->bb_phy_reg_pg != NULL)) {
2837 memcpy(pHalData->para_file_buf, pHalData->bb_phy_reg_pg, pHalData->bb_phy_reg_pg_len);
2838 rtStatus = _SUCCESS;
2841 DBG_871X("%s(): Critical Error !!!\n", __func__);
2845 if (rtStatus == _SUCCESS)
2847 /* DBG_871X("phy_ConfigBBWithPgParaFile(): read %s ok\n", pFileName); */
2848 phy_ParseBBPgParaFile(Adapter, pHalData->para_file_buf);
2852 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName);
2859 PHY_ConfigRFWithParaFile(
2860 struct adapter *Adapter,
2865 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
2866 int rlen = 0, rtStatus = _FAIL;
2867 char *szLine, *ptmp;
2868 u32 u4bRegOffset, u4bRegValue, u4bMove;
2871 u32 *pBufLen = NULL;
2873 if (!(Adapter->registrypriv.load_phy_file & LOAD_RF_PARA_FILE))
2879 pBuf = pHalData->rf_radio_a;
2880 pBufLen = &pHalData->rf_radio_a_len;
2883 pBuf = pHalData->rf_radio_b;
2884 pBufLen = &pHalData->rf_radio_b_len;
2887 DBG_871X("Unknown RF path!! %d\r\n", eRFPath);
2891 memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
2893 if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL))
2895 rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName);
2897 if (rtw_is_file_readable(file_path_bs) == true)
2899 rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
2902 rtStatus = _SUCCESS;
2903 pBuf = vzalloc(rlen);
2905 memcpy(pBuf, pHalData->para_file_buf, rlen);
2911 pHalData->rf_radio_a = pBuf;
2914 pHalData->rf_radio_b = pBuf;
2919 DBG_871X("%s(): eRFPath =%d alloc fail !\n", __func__, eRFPath);
2926 if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) {
2927 memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
2928 rtStatus = _SUCCESS;
2931 DBG_871X("%s(): Critical Error !!!\n", __func__);
2935 if (rtStatus == _SUCCESS)
2937 /* DBG_871X("%s(): read %s successfully\n", __func__, pFileName); */
2939 ptmp = pHalData->para_file_buf;
2940 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
2942 if (!IsCommentString(szLine))
2944 /* Get 1st hex value as register offset. */
2945 if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
2947 if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe)
2948 { /* Deay specific ms. Only RF configuration require delay. */
2951 else if (u4bRegOffset == 0xfd)
2954 for (i = 0;i<100;i++)
2955 udelay(MAX_STALL_TIME);
2957 else if (u4bRegOffset == 0xfc)
2960 for (i = 0;i<20;i++)
2961 udelay(MAX_STALL_TIME);
2963 else if (u4bRegOffset == 0xfb)
2967 else if (u4bRegOffset == 0xfa)
2971 else if (u4bRegOffset == 0xf9)
2975 else if (u4bRegOffset == 0xffff)
2980 /* Get 2nd hex value as register value. */
2982 if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
2984 PHY_SetRFReg(Adapter, eRFPath, u4bRegOffset, bRFRegOffsetMask, u4bRegValue);
2986 /* Temp add, for frequency lock, if no delay, that may cause */
2987 /* frequency shift, ex: 2412MHz => 2417MHz */
2988 /* If frequency shift, the following action may works. */
2989 /* Fractional-N table in radio_a.txt */
2990 /* 0x2a 0x00001 channel 1 */
2991 /* 0x2b 0x00808 frequency divider. */
3002 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName);
3009 initDeltaSwingIndexTables(
3010 struct adapter *Adapter,
3019 #define STR_EQUAL_5G(_band, _path, _sign, _rate, _chnl) \
3020 ((strcmp(Band, _band) == 0) && (strcmp(Path, _path) == 0) && (strcmp(Sign, _sign) == 0) &&\
3021 (strcmp(Rate, _rate) == 0) && (strcmp(Channel, _chnl) == 0)\
3023 #define STR_EQUAL_2G(_band, _path, _sign, _rate) \
3024 ((strcmp(Band, _band) == 0) && (strcmp(Path, _path) == 0) && (strcmp(Sign, _sign) == 0) &&\
3025 (strcmp(Rate, _rate) == 0)\
3028 #define STORE_SWING_TABLE(_array, _iteratedIdx) \
3029 for (token = strsep(&Data, delim); token != NULL; token = strsep(&Data, delim))\
3031 sscanf(token, "%d", &idx);\
3032 _array[_iteratedIdx++] = (u8)idx;\
3035 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
3036 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
3037 PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
3043 /* DBG_871X("===>initDeltaSwingIndexTables(): Band: %s;\nPath: %s;\nSign: %s;\nChannel: %s;\nRate: %s;\n, Data: %s;\n", */
3044 /* Band, Path, Sign, Channel, Rate, Data); */
3046 if (STR_EQUAL_2G("2G", "A", "+", "CCK"))
3048 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P, j);
3050 else if (STR_EQUAL_2G("2G", "A", "-", "CCK"))
3052 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, j);
3054 else if (STR_EQUAL_2G("2G", "B", "+", "CCK"))
3056 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, j);
3058 else if (STR_EQUAL_2G("2G", "B", "-", "CCK"))
3060 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, j);
3062 else if (STR_EQUAL_2G("2G", "A", "+", "ALL"))
3064 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P, j);
3066 else if (STR_EQUAL_2G("2G", "A", "-", "ALL"))
3068 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N, j);
3070 else if (STR_EQUAL_2G("2G", "B", "+", "ALL"))
3072 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P, j);
3074 else if (STR_EQUAL_2G("2G", "B", "-", "ALL"))
3076 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N, j);
3078 else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "0"))
3080 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[0], j);
3082 else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "0"))
3084 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[0], j);
3086 else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "0"))
3088 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[0], j);
3090 else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "0"))
3092 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[0], j);
3094 else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "1"))
3096 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[1], j);
3098 else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "1"))
3100 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[1], j);
3102 else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "1"))
3104 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[1], j);
3106 else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "1"))
3108 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[1], j);
3110 else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "2"))
3112 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[2], j);
3114 else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "2"))
3116 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[2], j);
3118 else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "2"))
3120 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[2], j);
3122 else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "2"))
3124 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[2], j);
3126 else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "3"))
3128 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[3], j);
3130 else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "3"))
3132 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[3], j);
3134 else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "3"))
3136 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[3], j);
3138 else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "3"))
3140 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[3], j);
3144 DBG_871X("===>initDeltaSwingIndexTables(): The input is invalid!!\n");
3149 PHY_ConfigRFWithTxPwrTrackParaFile(
3150 struct adapter * Adapter,
3154 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
3155 int rlen = 0, rtStatus = _FAIL;
3156 char *szLine, *ptmp;
3159 if (!(Adapter->registrypriv.load_phy_file & LOAD_RF_TXPWR_TRACK_PARA_FILE))
3162 memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
3164 if ((pHalData->rf_tx_pwr_track_len == 0) && (pHalData->rf_tx_pwr_track == NULL))
3166 rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName);
3168 if (rtw_is_file_readable(file_path_bs) == true)
3170 rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
3173 rtStatus = _SUCCESS;
3174 pHalData->rf_tx_pwr_track = vzalloc(rlen);
3175 if (pHalData->rf_tx_pwr_track) {
3176 memcpy(pHalData->rf_tx_pwr_track, pHalData->para_file_buf, rlen);
3177 pHalData->rf_tx_pwr_track_len = rlen;
3180 DBG_871X("%s rf_tx_pwr_track alloc fail !\n", __func__);
3187 if ((pHalData->rf_tx_pwr_track_len != 0) && (pHalData->rf_tx_pwr_track != NULL)) {
3188 memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_track, pHalData->rf_tx_pwr_track_len);
3189 rtStatus = _SUCCESS;
3192 DBG_871X("%s(): Critical Error !!!\n", __func__);
3196 if (rtStatus == _SUCCESS)
3198 /* DBG_871X("%s(): read %s successfully\n", __func__, pFileName); */
3200 ptmp = pHalData->para_file_buf;
3201 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
3203 if (! IsCommentString(szLine))
3205 char band[5]="", path[5]="", sign[5] = "";
3206 char chnl[5]="", rate[10]="";
3207 char data[300]=""; /* 100 is too small */
3209 if (strlen(szLine) < 10 || szLine[0] != '[')
3212 strncpy(band, szLine+1, 2);
3213 strncpy(path, szLine+5, 1);
3214 strncpy(sign, szLine+8, 1);
3216 i = 10; /* szLine+10 */
3217 if (! ParseQualifiedString(szLine, &i, rate, '[', ']')) {
3218 /* DBG_871X("Fail to parse rate!\n"); */
3220 if (! ParseQualifiedString(szLine, &i, chnl, '[', ']')) {
3221 /* DBG_871X("Fail to parse channel group!\n"); */
3223 while (szLine[i] != '{' && i < strlen(szLine))
3225 if (! ParseQualifiedString(szLine, &i, data, '{', '}')) {
3226 /* DBG_871X("Fail to parse data!\n"); */
3229 initDeltaSwingIndexTables(Adapter, band, path, sign, chnl, rate, data);
3235 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName);
3242 phy_ParsePowerLimitTableFile(
3243 struct adapter * Adapter,
3247 u32 i = 0, forCnt = 0;
3248 u8 loadingStage = 0, limitValue = 0, fraction = 0;
3249 char *szLine, *ptmp;
3250 int rtStatus = _SUCCESS;
3251 char band[10], bandwidth[10], rateSection[10],
3252 regulation[TXPWR_LMT_MAX_REGULATION_NUM][10], rfPath[10], colNumBuf[10];
3255 DBG_871X("===>phy_ParsePowerLimitTableFile()\n");
3257 if (Adapter->registrypriv.RegDecryptCustomFile == 1)
3258 phy_DecryptBBPgParaFile(Adapter, buffer);
3261 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
3264 if (IsCommentString(szLine)) {
3268 if (loadingStage == 0) {
3269 for (forCnt = 0; forCnt < TXPWR_LMT_MAX_REGULATION_NUM; ++forCnt)
3270 memset((void *) regulation[forCnt], 0, 10);
3271 memset((void *) band, 0, 10);
3272 memset((void *) bandwidth, 0, 10);
3273 memset((void *) rateSection, 0, 10);
3274 memset((void *) rfPath, 0, 10);
3275 memset((void *) colNumBuf, 0, 10);
3277 if (szLine[0] != '#' || szLine[1] != '#')
3280 /* skip the space */
3282 while (szLine[i] == ' ' || szLine[i] == '\t')
3285 szLine[--i] = ' '; /* return the space in front of the regulation info */
3287 /* Parse the label of the table */
3288 if (! ParseQualifiedString(szLine, &i, band, ' ', ',')) {
3289 DBG_871X("Fail to parse band!\n");
3292 if (! ParseQualifiedString(szLine, &i, bandwidth, ' ', ',')) {
3293 DBG_871X("Fail to parse bandwidth!\n");
3296 if (! ParseQualifiedString(szLine, &i, rfPath, ' ', ',')) {
3297 DBG_871X("Fail to parse rf path!\n");
3300 if (! ParseQualifiedString(szLine, &i, rateSection, ' ', ',')) {
3301 DBG_871X("Fail to parse rate!\n");
3307 else if (loadingStage == 1)
3309 if (szLine[0] != '#' || szLine[1] != '#')
3312 /* skip the space */
3314 while (szLine[i] == ' ' || szLine[i] == '\t')
3317 if (!eqNByte((u8 *)(szLine + i), (u8 *)("START"), 5)) {
3318 DBG_871X("Lost \"## START\" label\n");
3324 else if (loadingStage == 2)
3326 if (szLine[0] != '#' || szLine[1] != '#')
3329 /* skip the space */
3331 while (szLine[i] == ' ' || szLine[i] == '\t')
3334 if (! ParseQualifiedString(szLine, &i, colNumBuf, '#', '#')) {
3335 DBG_871X("Fail to parse column number!\n");
3339 if (!GetU1ByteIntegerFromStringInDecimal(colNumBuf, &colNum))
3342 if (colNum > TXPWR_LMT_MAX_REGULATION_NUM) {
3343 DBG_871X("unvalid col number %d (greater than max %d)\n",
3344 colNum, TXPWR_LMT_MAX_REGULATION_NUM);
3348 for (forCnt = 0; forCnt < colNum; ++forCnt)
3350 u8 regulation_name_cnt = 0;
3352 /* skip the space */
3353 while (szLine[i] == ' ' || szLine[i] == '\t')
3356 while (szLine[i] != ' ' && szLine[i] != '\t' && szLine[i] != '\0')
3357 regulation[forCnt][regulation_name_cnt++] = szLine[i++];
3358 /* DBG_871X("regulation %s!\n", regulation[forCnt]); */
3360 if (regulation_name_cnt == 0) {
3361 DBG_871X("unvalid number of regulation!\n");
3368 else if (loadingStage == 3)
3370 char channel[10] = {0}, powerLimit[10] = {0};
3373 /* the table ends */
3374 if (szLine[0] == '#' && szLine[1] == '#') {
3376 while (szLine[i] == ' ' || szLine[i] == '\t')
3379 if (eqNByte((u8 *)(szLine + i), (u8 *)("END"), 3)) {
3384 DBG_871X("Wrong format\n");
3385 DBG_871X("<===== phy_ParsePowerLimitTableFile()\n");
3390 if ((szLine[0] != 'c' && szLine[0] != 'C') ||
3391 (szLine[1] != 'h' && szLine[1] != 'H')) {
3392 DBG_871X("Meet wrong channel => power limt pair\n");
3395 i = 2;/* move to the location behind 'h' */
3397 /* load the channel number */
3399 while (szLine[i] >= '0' && szLine[i] <= '9') {
3400 channel[cnt] = szLine[i];
3404 /* DBG_871X("chnl %s!\n", channel); */
3406 for (forCnt = 0; forCnt < colNum; ++forCnt)
3408 /* skip the space between channel number and the power limit value */
3409 while (szLine[i] == ' ' || szLine[i] == '\t')
3412 /* load the power limit value */
3415 memset((void *) powerLimit, 0, 10);
3416 while ((szLine[i] >= '0' && szLine[i] <= '9') || szLine[i] == '.')
3418 if (szLine[i] == '.') {
3419 if ((szLine[i+1] >= '0' && szLine[i+1] <= '9')) {
3420 fraction = szLine[i+1];
3424 DBG_871X("Wrong fraction in TXPWR_LMT.txt\n");
3431 powerLimit[cnt] = szLine[i];
3436 if (powerLimit[0] == '\0') {
3437 powerLimit[0] = '6';
3438 powerLimit[1] = '3';
3442 if (!GetU1ByteIntegerFromStringInDecimal(powerLimit, &limitValue))
3447 if (fraction == '5')
3450 /* the value is greater or equal to 100 */
3451 if (limitValue >= 100) {
3452 powerLimit[cnt++] = limitValue/100 + '0';
3455 if (limitValue >= 10) {
3456 powerLimit[cnt++] = limitValue/10 + '0';
3460 powerLimit[cnt++] = '0';
3463 powerLimit[cnt++] = limitValue + '0';
3465 /* the value is greater or equal to 10 */
3466 else if (limitValue >= 10) {
3467 powerLimit[cnt++] = limitValue/10 + '0';
3469 powerLimit[cnt++] = limitValue + '0';
3471 /* the value is less than 10 */
3473 powerLimit[cnt++] = limitValue + '0';
3475 powerLimit[cnt] = '\0';
3478 /* DBG_871X("ch%s => %s\n", channel, powerLimit); */
3480 /* store the power limit value */
3481 PHY_SetTxPowerLimit(Adapter, (u8 *)regulation[forCnt], (u8 *)band,
3482 (u8 *)bandwidth, (u8 *)rateSection, (u8 *)rfPath, (u8 *)channel, (u8 *)powerLimit);
3488 DBG_871X("Abnormal loading stage in phy_ParsePowerLimitTableFile()!\n");
3494 DBG_871X("<===phy_ParsePowerLimitTableFile()\n");
3499 PHY_ConfigRFWithPowerLimitTableParaFile(
3500 struct adapter *Adapter,
3504 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
3505 int rlen = 0, rtStatus = _FAIL;
3507 if (!(Adapter->registrypriv.load_phy_file & LOAD_RF_TXPWR_LMT_PARA_FILE))
3510 memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
3512 if ((pHalData->rf_tx_pwr_lmt_len == 0) && (pHalData->rf_tx_pwr_lmt == NULL))
3514 rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName);
3516 if (rtw_is_file_readable(file_path_bs) == true)
3518 rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
3521 rtStatus = _SUCCESS;
3522 pHalData->rf_tx_pwr_lmt = vzalloc(rlen);
3523 if (pHalData->rf_tx_pwr_lmt) {
3524 memcpy(pHalData->rf_tx_pwr_lmt, pHalData->para_file_buf, rlen);
3525 pHalData->rf_tx_pwr_lmt_len = rlen;
3528 DBG_871X("%s rf_tx_pwr_lmt alloc fail !\n", __func__);
3535 if ((pHalData->rf_tx_pwr_lmt_len != 0) && (pHalData->rf_tx_pwr_lmt != NULL)) {
3536 memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_lmt, pHalData->rf_tx_pwr_lmt_len);
3537 rtStatus = _SUCCESS;
3540 DBG_871X("%s(): Critical Error !!!\n", __func__);
3544 if (rtStatus == _SUCCESS)
3546 /* DBG_871X("%s(): read %s ok\n", __func__, pFileName); */
3547 rtStatus = phy_ParsePowerLimitTableFile(Adapter, pHalData->para_file_buf);
3551 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName);
3557 void phy_free_filebuf(struct adapter *padapter)
3559 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
3561 if (pHalData->mac_reg)
3562 vfree(pHalData->mac_reg);
3563 if (pHalData->bb_phy_reg)
3564 vfree(pHalData->bb_phy_reg);
3565 if (pHalData->bb_agc_tab)
3566 vfree(pHalData->bb_agc_tab);
3567 if (pHalData->bb_phy_reg_pg)
3568 vfree(pHalData->bb_phy_reg_pg);
3569 if (pHalData->bb_phy_reg_mp)
3570 vfree(pHalData->bb_phy_reg_mp);
3571 if (pHalData->rf_radio_a)
3572 vfree(pHalData->rf_radio_a);
3573 if (pHalData->rf_radio_b)
3574 vfree(pHalData->rf_radio_b);
3575 if (pHalData->rf_tx_pwr_track)
3576 vfree(pHalData->rf_tx_pwr_track);
3577 if (pHalData->rf_tx_pwr_lmt)
3578 vfree(pHalData->rf_tx_pwr_lmt);