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 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
20 #define _HAL_COM_PHYCFG_C_
22 #include <drv_types.h>
28 // Map Tx power index into dBm according to
29 // current HW model, for example, RF and PA, and
30 // current wireless mode.
31 // By Bruce, 2008-01-29.
36 IN WIRELESS_MODE WirelessMode,
44 // Tested by MP, we found that CCK Index 0 equals to -7dbm, OFDM legacy equals to -8dbm.
46 // The mapping may be different by different NICs. Do not use this formula for what needs accurate result.
47 // By Bruce, 2008-01-29.
56 case WIRELESS_MODE_N_24G:
60 default: //for MacOSX compiler warning
64 PwrOutDbm = TxPwrIdx / 2 + Offset; // Discard the decimal part.
70 PHY_GetTxPowerByRateBase(
75 IN RATE_SECTION RateSection
78 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
81 if ( RfPath > ODM_RF_PATH_D )
83 DBG_871X("Invalid Rf Path %d in PHY_GetTxPowerByRateBase()\n", RfPath );
87 if ( Band == BAND_ON_2_4G )
89 switch ( RateSection ) {
91 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0];
94 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1];
97 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2];
100 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3];
103 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4];
106 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5];
108 case VHT_1SSMCS0_1SSMCS9:
109 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][6];
111 case VHT_2SSMCS0_2SSMCS9:
112 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][7];
114 case VHT_3SSMCS0_3SSMCS9:
115 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][8];
117 case VHT_4SSMCS0_4SSMCS9:
118 value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9];
121 DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n",
122 RateSection, RfPath, TxNum );
127 else if ( Band == BAND_ON_5G )
129 switch ( RateSection ) {
131 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][0];
134 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][1];
137 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][2];
140 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][3];
143 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][4];
145 case VHT_1SSMCS0_1SSMCS9:
146 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][5];
148 case VHT_2SSMCS0_2SSMCS9:
149 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][6];
151 case VHT_3SSMCS0_3SSMCS9:
152 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][7];
154 case VHT_4SSMCS0_4SSMCS9:
155 value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][8];
158 DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n",
159 RateSection, RfPath, TxNum );
165 DBG_871X("Invalid Band %d in PHY_GetTxPowerByRateBase()\n", Band );
172 phy_SetTxPowerByRateBase(
176 IN RATE_SECTION RateSection,
181 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
183 if ( RfPath > ODM_RF_PATH_D )
185 DBG_871X("Invalid Rf Path %d in phy_SetTxPowerByRatBase()\n", RfPath );
189 if ( Band == BAND_ON_2_4G )
191 switch ( RateSection ) {
193 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0] = Value;
196 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1] = Value;
199 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2] = Value;
202 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3] = Value;
205 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4] = Value;
208 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5] = Value;
210 case VHT_1SSMCS0_1SSMCS9:
211 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][6] = Value;
213 case VHT_2SSMCS0_2SSMCS9:
214 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][7] = Value;
216 case VHT_3SSMCS0_3SSMCS9:
217 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][8] = Value;
219 case VHT_4SSMCS0_4SSMCS9:
220 pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9] = Value;
223 DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n",
224 RateSection, RfPath, TxNum );
228 else if ( Band == BAND_ON_5G )
230 switch ( RateSection ) {
232 pHalData->TxPwrByRateBase5G[RfPath][TxNum][0] = Value;
235 pHalData->TxPwrByRateBase5G[RfPath][TxNum][1] = Value;
238 pHalData->TxPwrByRateBase5G[RfPath][TxNum][2] = Value;
241 pHalData->TxPwrByRateBase5G[RfPath][TxNum][3] = Value;
244 pHalData->TxPwrByRateBase5G[RfPath][TxNum][4] = Value;
246 case VHT_1SSMCS0_1SSMCS9:
247 pHalData->TxPwrByRateBase5G[RfPath][TxNum][5] = Value;
249 case VHT_2SSMCS0_2SSMCS9:
250 pHalData->TxPwrByRateBase5G[RfPath][TxNum][6] = Value;
252 case VHT_3SSMCS0_3SSMCS9:
253 pHalData->TxPwrByRateBase5G[RfPath][TxNum][7] = Value;
255 case VHT_4SSMCS0_4SSMCS9:
256 pHalData->TxPwrByRateBase5G[RfPath][TxNum][8] = Value;
259 DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n",
260 RateSection, RfPath, TxNum );
266 DBG_871X("Invalid Band %d in phy_SetTxPowerByRateBase()\n", Band );
271 phy_StoreTxPowerByRateBaseOld(
275 HAL_DATA_TYPE *pHalData = GET_HAL_DATA( pAdapter );
280 rawValue = ( u16 ) ( pHalData->MCSTxPowerLevelOriginalOffset[0][7] >> 8 ) & 0xFF;
281 base = ( rawValue >> 4 ) * 10 + ( rawValue & 0xF );
282 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_A, CCK, RF_1TX, base );
284 rawValue = ( u16 ) ( pHalData->MCSTxPowerLevelOriginalOffset[0][1] >> 24 ) & 0xFF;
285 base = ( rawValue >> 4 ) * 10 + ( rawValue & 0xF );
286 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_A, OFDM, RF_1TX, base );
288 rawValue = ( u16 ) ( pHalData->MCSTxPowerLevelOriginalOffset[0][3] >> 24 ) & 0xFF;
289 base = ( rawValue >> 4 ) * 10 + ( rawValue & 0xF );
290 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_A, HT_MCS0_MCS7, RF_1TX, base );
292 rawValue = ( u16 ) ( pHalData->MCSTxPowerLevelOriginalOffset[0][5] >> 24 ) & 0xFF;
293 base = ( rawValue >> 4) * 10 + ( rawValue & 0xF );
294 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_A, HT_MCS8_MCS15, RF_2TX, base );
296 rawValue = ( u16 ) ( pHalData->MCSTxPowerLevelOriginalOffset[0][7] & 0xFF );
297 base = ( rawValue >> 4 ) * 10 + ( rawValue & 0xF );
298 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_B, CCK, RF_1TX, base );
300 rawValue = ( u16 ) ( pHalData->MCSTxPowerLevelOriginalOffset[0][9] >> 24 ) & 0xFF;
301 base = ( rawValue >> 4 ) * 10 + ( rawValue & 0xF );
302 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_B, OFDM, RF_1TX, base );
304 rawValue = ( u16 ) ( pHalData->MCSTxPowerLevelOriginalOffset[0][11] >> 24 ) & 0xFF;
305 base = ( rawValue >> 4 ) * 10 + ( rawValue & 0xF );
306 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_B, HT_MCS0_MCS7, RF_1TX, base );
308 rawValue = ( u16 ) ( pHalData->MCSTxPowerLevelOriginalOffset[0][13] >> 24 ) & 0xFF;
309 base = ( rawValue >> 4 ) * 10 + ( rawValue & 0xF );
310 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_B, HT_MCS8_MCS15, RF_2TX, base );
314 phy_StoreTxPowerByRateBase(
318 u8 path = 0, base = 0, index = 0;
320 //DBG_871X( "===>%s\n", __FUNCTION__ );
322 for ( path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; ++path )
324 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_2_4G, path, RF_1TX, MGN_11M );
325 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, path, CCK, RF_1TX, base );
326 //DBG_871X("Power index base of 2.4G path %d 1Tx CCK = > 0x%x\n", path, base );
328 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_2_4G, path, RF_1TX, MGN_54M );
329 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, path, OFDM, RF_1TX, base );
330 //DBG_871X("Power index base of 2.4G path %d 1Tx OFDM = > 0x%x\n", path, base );
332 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_2_4G, path, RF_1TX, MGN_MCS7 );
333 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, path, HT_MCS0_MCS7, RF_1TX, base );
334 //DBG_871X("Power index base of 2.4G path %d 1Tx MCS0-7 = > 0x%x\n", path, base );
336 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_2_4G, path, RF_2TX, MGN_MCS15 );
337 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, path, HT_MCS8_MCS15, RF_2TX, base );
338 //DBG_871X("Power index base of 2.4G path %d 2Tx MCS8-15 = > 0x%x\n", path, base );
340 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_2_4G, path, RF_3TX, MGN_MCS23 );
341 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, path, HT_MCS16_MCS23, RF_3TX, base );
342 //DBG_871X("Power index base of 2.4G path %d 3Tx MCS16-23 = > 0x%x\n", path, base );
344 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_2_4G, path, RF_1TX, MGN_VHT1SS_MCS7 );
345 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, path, VHT_1SSMCS0_1SSMCS9, RF_1TX, base );
346 //DBG_871X("Power index base of 2.4G path %d 1Tx VHT1SS = > 0x%x\n", path, base );
348 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_2_4G, path, RF_2TX, MGN_VHT2SS_MCS7 );
349 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, path, VHT_2SSMCS0_2SSMCS9, RF_2TX, base );
350 //DBG_871X("Power index base of 2.4G path %d 2Tx VHT2SS = > 0x%x\n", path, base );
352 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_2_4G, path, RF_3TX, MGN_VHT3SS_MCS7 );
353 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, path, VHT_3SSMCS0_3SSMCS9, RF_3TX, base );
354 //DBG_871X("Power index base of 2.4G path %d 3Tx VHT3SS = > 0x%x\n", path, base );
356 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_5G, path, RF_1TX, MGN_54M );
357 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_5G, path, OFDM, RF_1TX, base );
358 //DBG_871X("Power index base of 5G path %d 1Tx OFDM = > 0x%x\n", path, base );
360 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_5G, path, RF_1TX, MGN_MCS7 );
361 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_5G, path, HT_MCS0_MCS7, RF_1TX, base );
362 //DBG_871X("Power index base of 5G path %d 1Tx MCS0~7 = > 0x%x\n", path, base );
364 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_5G, path, RF_2TX, MGN_MCS15 );
365 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_5G, path, HT_MCS8_MCS15, RF_2TX, base );
366 //DBG_871X("Power index base of 5G path %d 2Tx MCS8~15 = > 0x%x\n", path, base );
368 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_5G, path, RF_3TX, MGN_MCS23 );
369 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_5G, path, HT_MCS16_MCS23, RF_3TX, base );
370 //DBG_871X("Power index base of 5G path %d 3Tx MCS16~23 = > 0x%x\n", path, base );
372 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_5G, path, RF_1TX, MGN_VHT1SS_MCS7 );
373 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_5G, path, VHT_1SSMCS0_1SSMCS9, RF_1TX, base );
374 //DBG_871X("Power index base of 5G path %d 1Tx VHT1SS = > 0x%x\n", path, base );
376 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_5G, path, RF_2TX, MGN_VHT2SS_MCS7 );
377 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_5G, path, VHT_2SSMCS0_2SSMCS9, RF_2TX, base );
378 //DBG_871X("Power index base of 5G path %d 2Tx VHT2SS = > 0x%x\n", path, base );
380 base = PHY_GetTxPowerByRate( pAdapter, BAND_ON_5G, path, RF_3TX, MGN_VHT2SS_MCS7 );
381 phy_SetTxPowerByRateBase( pAdapter, BAND_ON_5G, path, VHT_3SSMCS0_3SSMCS9, RF_3TX, base );
382 //DBG_871X("Power index base of 5G path %d 3Tx VHT3SS = > 0x%x\n", path, base );
385 //DBG_871X("<===%s\n", __FUNCTION__ );
389 PHY_GetRateSectionIndexOfTxPowerByRate(
390 IN PADAPTER pAdapter,
395 HAL_DATA_TYPE *pHalData = GET_HAL_DATA( pAdapter );
396 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
399 if ( pDM_Odm->PhyRegPgVersion == 0 )
403 case rTxAGC_A_Rate18_06: index = 0; break;
404 case rTxAGC_A_Rate54_24: index = 1; break;
405 case rTxAGC_A_CCK1_Mcs32: index = 6; break;
406 case rTxAGC_B_CCK11_A_CCK2_11:
407 if ( BitMask == 0xffffff00 )
409 else if ( BitMask == 0x000000ff )
413 case rTxAGC_A_Mcs03_Mcs00: index = 2; break;
414 case rTxAGC_A_Mcs07_Mcs04: index = 3; break;
415 case rTxAGC_A_Mcs11_Mcs08: index = 4; break;
416 case rTxAGC_A_Mcs15_Mcs12: index = 5; break;
417 case rTxAGC_B_Rate18_06: index = 8; break;
418 case rTxAGC_B_Rate54_24: index = 9; break;
419 case rTxAGC_B_CCK1_55_Mcs32: index = 14; break;
420 case rTxAGC_B_Mcs03_Mcs00: index = 10; break;
421 case rTxAGC_B_Mcs07_Mcs04: index = 11; break;
422 case rTxAGC_B_Mcs11_Mcs08: index = 12; break;
423 case rTxAGC_B_Mcs15_Mcs12: index = 13; break;
425 DBG_871X("Invalid RegAddr 0x3%x in PHY_GetRateSectionIndexOfTxPowerByRate()", RegAddr );
434 PHY_GetRateValuesOfTxPowerByRate(
435 IN PADAPTER pAdapter,
440 OUT s8* PwrByRateVal,
444 HAL_DATA_TYPE *pHalData = GET_HAL_DATA( pAdapter );
445 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
450 case rTxAGC_A_Rate18_06:
451 case rTxAGC_B_Rate18_06:
452 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_6M );
453 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_9M );
454 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_12M );
455 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_18M );
456 for ( i = 0; i < 4; ++ i )
458 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
459 ( ( Value >> (i * 8) ) & 0xF ) );
464 case rTxAGC_A_Rate54_24:
465 case rTxAGC_B_Rate54_24:
466 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_24M );
467 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_36M );
468 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_48M );
469 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_54M );
470 for ( i = 0; i < 4; ++ i )
472 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
473 ( ( Value >> (i * 8) ) & 0xF ) );
478 case rTxAGC_A_CCK1_Mcs32:
479 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_1M );
480 PwrByRateVal[0] = ( s8 ) ( ( ( ( Value >> (8 + 4) ) & 0xF ) ) * 10 +
481 ( ( Value >> 8 ) & 0xF ) );
485 case rTxAGC_B_CCK11_A_CCK2_11:
486 if ( BitMask == 0xffffff00 )
488 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_2M );
489 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_5_5M );
490 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_11M );
491 for ( i = 1; i < 4; ++ i )
493 PwrByRateVal[i - 1] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
494 ( ( Value >> (i * 8) ) & 0xF ) );
498 else if ( BitMask == 0x000000ff )
500 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_11M );
501 PwrByRateVal[0] = ( s8 ) ( ( ( ( Value >> 4 ) & 0xF ) ) * 10 +
507 case rTxAGC_A_Mcs03_Mcs00:
508 case rTxAGC_B_Mcs03_Mcs00:
509 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS0 );
510 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS1 );
511 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS2 );
512 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS3 );
513 for ( i = 0; i < 4; ++ i )
515 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
516 ( ( Value >> (i * 8) ) & 0xF ) );
521 case rTxAGC_A_Mcs07_Mcs04:
522 case rTxAGC_B_Mcs07_Mcs04:
523 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS4 );
524 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS5 );
525 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS6 );
526 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS7 );
527 for ( i = 0; i < 4; ++ i )
529 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
530 ( ( Value >> (i * 8) ) & 0xF ) );
535 case rTxAGC_A_Mcs11_Mcs08:
536 case rTxAGC_B_Mcs11_Mcs08:
537 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS8 );
538 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS9 );
539 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS10 );
540 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS11 );
541 for ( i = 0; i < 4; ++ i )
543 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
544 ( ( Value >> (i * 8) ) & 0xF ) );
549 case rTxAGC_A_Mcs15_Mcs12:
550 case rTxAGC_B_Mcs15_Mcs12:
551 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS12 );
552 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS13 );
553 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS14 );
554 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS15 );
555 for ( i = 0; i < 4; ++ i )
557 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
558 ( ( Value >> (i * 8) ) & 0xF ) );
564 case rTxAGC_B_CCK1_55_Mcs32:
565 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_1M );
566 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_2M );
567 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_5_5M );
568 for ( i = 1; i < 4; ++ i )
570 PwrByRateVal[i - 1] = ( s8 ) ( ( ( ( Value >> ( i * 8 + 4) ) & 0xF ) ) * 10 +
571 ( ( Value >> ( i * 8) ) & 0xF ) );
580 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_1M );
581 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_2M );
582 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_5_5M );
583 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_11M );
584 for ( i = 0; i < 4; ++ i )
586 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
587 ( ( Value >> (i * 8) ) & 0xF ) );
596 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_6M );
597 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_9M );
598 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_12M );
599 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_18M );
600 for ( i = 0; i < 4; ++ i )
602 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
603 ( ( Value >> (i * 8) ) & 0xF ) );
612 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_24M );
613 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_36M );
614 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_48M );
615 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_54M );
616 for ( i = 0; i < 4; ++ i )
618 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
619 ( ( Value >> (i * 8) ) & 0xF ) );
628 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS0 );
629 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS1 );
630 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS2 );
631 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS3 );
632 for ( i = 0; i < 4; ++ i )
634 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
635 ( ( Value >> (i * 8) ) & 0xF ) );
644 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS4 );
645 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS5 );
646 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS6 );
647 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS7 );
648 for ( i = 0; i < 4; ++ i )
650 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
651 ( ( Value >> (i * 8) ) & 0xF ) );
660 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS8 );
661 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS9 );
662 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS10 );
663 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS11 );
664 for ( i = 0; i < 4; ++ i )
666 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
667 ( ( Value >> (i * 8) ) & 0xF ) );
676 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS12 );
677 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS13 );
678 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS14 );
679 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS15 );
680 for ( i = 0; i < 4; ++ i )
682 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
683 ( ( Value >> (i * 8) ) & 0xF ) );
692 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS0 );
693 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS1 );
694 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS2 );
695 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS3 );
696 for ( i = 0; i < 4; ++ i )
698 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
699 ( ( Value >> (i * 8) ) & 0xF ) );
708 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS4 );
709 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS5 );
710 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS6 );
711 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS7 );
712 for ( i = 0; i < 4; ++ i )
714 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
715 ( ( Value >> (i * 8) ) & 0xF ) );
724 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS8 );
725 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT1SS_MCS9 );
726 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS0 );
727 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS1 );
728 for ( i = 0; i < 4; ++ i )
730 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
731 ( ( Value >> (i * 8) ) & 0xF ) );
740 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS2 );
741 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS3 );
742 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS4 );
743 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS5 );
744 for ( i = 0; i < 4; ++ i )
746 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
747 ( ( Value >> (i * 8) ) & 0xF ) );
756 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS6 );
757 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS7 );
758 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS8 );
759 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS9 );
760 for ( i = 0; i < 4; ++ i )
762 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
763 ( ( Value >> (i * 8) ) & 0xF ) );
772 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS16 );
773 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS17 );
774 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS18 );
775 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS19 );
776 for ( i = 0; i < 4; ++ i )
778 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
779 ( ( Value >> (i * 8) ) & 0xF ) );
788 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS20 );
789 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS21 );
790 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS22 );
791 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_MCS23 );
792 for ( i = 0; i < 4; ++ i )
794 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
795 ( ( Value >> (i * 8) ) & 0xF ) );
804 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS0 );
805 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS1 );
806 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS2 );
807 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS3 );
808 for ( i = 0; i < 4; ++ i )
810 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
811 ( ( Value >> (i * 8) ) & 0xF ) );
820 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS4 );
821 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS5 );
822 RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS6 );
823 RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS7 );
824 for ( i = 0; i < 4; ++ i )
826 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
827 ( ( Value >> (i * 8) ) & 0xF ) );
836 RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS8 );
837 RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate( MGN_VHT3SS_MCS9 );
838 for ( i = 0; i < 2; ++ i )
840 PwrByRateVal[i] = ( s8 ) ( ( ( ( Value >> (i * 8 + 4) ) & 0xF ) ) * 10 +
841 ( ( Value >> (i * 8) ) & 0xF ) );
847 DBG_871X("Invalid RegAddr 0x%x in %s()\n", RegAddr, __FUNCTION__);
853 PHY_StoreTxPowerByRateNew(
854 IN PADAPTER pAdapter,
863 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
864 u8 i = 0, rateIndex[4] = {0}, rateNum = 0;
865 s8 PwrByRateVal[4] = {0};
867 PHY_GetRateValuesOfTxPowerByRate( pAdapter, RegAddr, BitMask, Data, rateIndex, PwrByRateVal, &rateNum );
869 if ( Band != BAND_ON_2_4G && Band != BAND_ON_5G )
871 DBG_871X("Invalid Band %d\n", Band );
875 if ( RfPath > ODM_RF_PATH_D )
877 DBG_871X("Invalid RfPath %d\n", RfPath );
881 if ( TxNum > ODM_RF_PATH_D )
883 DBG_871X("Invalid TxNum %d\n", TxNum );
887 for ( i = 0; i < rateNum; ++i )
889 if ( rateIndex[i] == PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS0) ||
890 rateIndex[i] == PHY_GetRateIndexOfTxPowerByRate( MGN_VHT2SS_MCS1) )
895 pHalData->TxPwrByRateOffset[Band][RfPath][TxNum][rateIndex[i]] = PwrByRateVal[i];
900 PHY_StoreTxPowerByRateOld(
901 IN PADAPTER pAdapter,
907 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
908 u8 index = PHY_GetRateSectionIndexOfTxPowerByRate( pAdapter, RegAddr, BitMask );
910 pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][index] = Data;
911 //DBG_871X("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n", pHalData->pwrGroupCnt,
912 // pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0]);
916 PHY_InitTxPowerByRate(
920 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
921 u8 band = 0, rfPath = 0, TxNum = 0, rate = 0, i = 0, j = 0;
923 if ( IS_HARDWARE_TYPE_8188E( pAdapter ) || IS_HARDWARE_TYPE_8723A( pAdapter ) )
925 for ( i = 0; i < MAX_PG_GROUP; ++i )
926 for ( j = 0; j < 16; ++j )
927 pHalData->MCSTxPowerLevelOriginalOffset[i][j] = 0;
931 for ( band = BAND_ON_2_4G; band <= BAND_ON_5G; ++band )
932 for ( rfPath = 0; rfPath < TX_PWR_BY_RATE_NUM_RF; ++rfPath )
933 for ( TxNum = 0; TxNum < TX_PWR_BY_RATE_NUM_RF; ++TxNum )
934 for ( rate = 0; rate < TX_PWR_BY_RATE_NUM_RATE; ++rate )
935 pHalData->TxPwrByRateOffset[band][rfPath][TxNum][rate] = 0;
940 PHY_StoreTxPowerByRate(
941 IN PADAPTER pAdapter,
950 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
951 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
953 if ( pDM_Odm->PhyRegPgVersion > 0 )
955 PHY_StoreTxPowerByRateNew( pAdapter, Band, RfPath, TxNum, RegAddr, BitMask, Data );
957 else if ( pDM_Odm->PhyRegPgVersion == 0 )
959 PHY_StoreTxPowerByRateOld( pAdapter, RegAddr, BitMask, Data );
961 if ( RegAddr == rTxAGC_A_Mcs15_Mcs12 && pHalData->rf_type == RF_1T1R )
962 pHalData->pwrGroupCnt++;
963 else if ( RegAddr == rTxAGC_B_Mcs15_Mcs12 && pHalData->rf_type != RF_1T1R )
964 pHalData->pwrGroupCnt++;
967 DBG_871X("Invalid PHY_REG_PG.txt version %d\n", pDM_Odm->PhyRegPgVersion );
972 phy_ConvertTxPowerByRateByBase(
983 for ( i = 3; i >= 0; --i )
985 if ( i >= Start && i <= End )
987 // Get the exact value
988 TempValue = ( u8 ) ( *pData >> ( i * 8 ) ) & 0xF;
989 TempValue += ( ( u8 ) ( ( *pData >> ( i * 8 + 4 ) ) & 0xF ) ) * 10;
991 // Change the value to a relative value
992 TempValue = ( TempValue > BaseValue ) ? TempValue - BaseValue : BaseValue - TempValue;
996 TempValue = ( u8 ) ( *pData >> ( i * 8 ) ) & 0xFF;
1000 TempData |= TempValue;
1008 PHY_ConvertTxPowerByRateInDbmToRelativeValuesOld(
1009 IN PADAPTER pAdapter
1012 HAL_DATA_TYPE *pHalData = GET_HAL_DATA( pAdapter );
1015 //DBG_871X("===>PHY_ConvertTxPowerByRateInDbmToRelativeValuesOld()\n" );
1018 base = PHY_GetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_A, RF_1TX, CCK );
1019 phy_ConvertTxPowerByRateByBase(
1020 &( pHalData->MCSTxPowerLevelOriginalOffset[0][6] ), 1, 1, base );
1021 phy_ConvertTxPowerByRateByBase(
1022 &( pHalData->MCSTxPowerLevelOriginalOffset[0][7] ), 1, 3, base );
1025 base = PHY_GetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_A, RF_1TX, OFDM );
1026 phy_ConvertTxPowerByRateByBase(
1027 &( pHalData->MCSTxPowerLevelOriginalOffset[0][0] ), 0, 3, base );
1028 phy_ConvertTxPowerByRateByBase(
1029 &( pHalData->MCSTxPowerLevelOriginalOffset[0][1] ), 0, 3, base );
1032 base = PHY_GetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_A, RF_1TX, HT_MCS0_MCS7 );
1033 phy_ConvertTxPowerByRateByBase(
1034 &( pHalData->MCSTxPowerLevelOriginalOffset[0][2] ), 0, 3, base );
1035 phy_ConvertTxPowerByRateByBase(
1036 &( pHalData->MCSTxPowerLevelOriginalOffset[0][3] ), 0, 3, base );
1039 base = PHY_GetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_A, RF_2TX, HT_MCS8_MCS15 );
1040 phy_ConvertTxPowerByRateByBase(
1041 &( pHalData->MCSTxPowerLevelOriginalOffset[0][4] ), 0, 3, base );
1042 phy_ConvertTxPowerByRateByBase(
1043 &( pHalData->MCSTxPowerLevelOriginalOffset[0][5] ), 0, 3, base );
1046 base = PHY_GetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_B, RF_1TX, CCK );
1047 phy_ConvertTxPowerByRateByBase(
1048 &( pHalData->MCSTxPowerLevelOriginalOffset[0][14] ), 1, 3, base );
1049 phy_ConvertTxPowerByRateByBase(
1050 &( pHalData->MCSTxPowerLevelOriginalOffset[0][15] ), 0, 0, base );
1053 base = PHY_GetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_B, RF_1TX, OFDM );
1054 phy_ConvertTxPowerByRateByBase(
1055 &( pHalData->MCSTxPowerLevelOriginalOffset[0][8] ), 0, 3, base );
1056 phy_ConvertTxPowerByRateByBase(
1057 &( pHalData->MCSTxPowerLevelOriginalOffset[0][9] ), 0, 3, base );
1060 base = PHY_GetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_B, RF_1TX, HT_MCS0_MCS7 );
1061 phy_ConvertTxPowerByRateByBase(
1062 &( pHalData->MCSTxPowerLevelOriginalOffset[0][10] ), 0, 3, base );
1063 phy_ConvertTxPowerByRateByBase(
1064 &( pHalData->MCSTxPowerLevelOriginalOffset[0][11] ), 0, 3, base );
1067 base = PHY_GetTxPowerByRateBase( pAdapter, BAND_ON_2_4G, ODM_RF_PATH_B, RF_2TX, HT_MCS8_MCS15 );
1068 phy_ConvertTxPowerByRateByBase(
1069 &( pHalData->MCSTxPowerLevelOriginalOffset[0][12] ), 0, 3, base );
1070 phy_ConvertTxPowerByRateByBase(
1071 &( pHalData->MCSTxPowerLevelOriginalOffset[0][13] ), 0, 3, base );
1073 //DBG_871X("<===PHY_ConvertTxPowerByRateInDbmToRelativeValuesOld()\n" );
1077 phy_ConvertTxPowerByRateInDbmToRelativeValues(
1078 IN PADAPTER pAdapter
1081 HAL_DATA_TYPE *pHalData = GET_HAL_DATA( pAdapter );
1082 u8 base = 0, i = 0, value = 0,
1083 band = 0, path = 0, txNum = 0, index = 0,
1084 startIndex = 0, endIndex = 0;
1085 u8 cckRates[4] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M},
1086 ofdmRates[8] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M},
1087 mcs0_7Rates[8] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7},
1088 mcs8_15Rates[8] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15},
1089 mcs16_23Rates[8] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23},
1090 vht1ssRates[10] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4,
1091 MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9},
1092 vht2ssRates[10] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4,
1093 MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9},
1094 vht3ssRates[10] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4,
1095 MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9};
1097 //DBG_871X("===>PHY_ConvertTxPowerByRateInDbmToRelativeValues()\n" );
1099 for ( band = BAND_ON_2_4G; band <= BAND_ON_5G; ++band )
1101 for ( path = ODM_RF_PATH_A; path <= ODM_RF_PATH_D; ++path )
1103 for ( txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum )
1106 base = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, MGN_11M );
1107 for ( i = 0; i < sizeof( cckRates ); ++i )
1109 value = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, cckRates[i] );
1110 PHY_SetTxPowerByRate( pAdapter, band, path, txNum, cckRates[i], value - base );
1114 base = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, MGN_54M );
1115 for ( i = 0; i < sizeof( ofdmRates ); ++i )
1117 value = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, ofdmRates[i] );
1118 PHY_SetTxPowerByRate( pAdapter, band, path, txNum, ofdmRates[i], value - base );
1122 base = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, MGN_MCS7 );
1123 for ( i = 0; i < sizeof( mcs0_7Rates ); ++i )
1125 value = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, mcs0_7Rates[i] );
1126 PHY_SetTxPowerByRate( pAdapter, band, path, txNum, mcs0_7Rates[i], value - base );
1130 base = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, MGN_MCS15 );
1131 for ( i = 0; i < sizeof( mcs8_15Rates ); ++i )
1133 value = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, mcs8_15Rates[i] );
1134 PHY_SetTxPowerByRate( pAdapter, band, path, txNum, mcs8_15Rates[i], value - base );
1138 base = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, MGN_MCS23 );
1139 for ( i = 0; i < sizeof( mcs16_23Rates ); ++i )
1141 value = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, mcs16_23Rates[i] );
1142 PHY_SetTxPowerByRate( pAdapter, band, path, txNum, mcs16_23Rates[i], value - base );
1146 base = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, MGN_VHT1SS_MCS7 );
1147 for ( i = 0; i < sizeof( vht1ssRates ); ++i )
1149 value = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, vht1ssRates[i] );
1150 PHY_SetTxPowerByRate( pAdapter, band, path, txNum, vht1ssRates[i], value - base );
1154 base = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, MGN_VHT2SS_MCS7 );
1155 for ( i = 0; i < sizeof( vht2ssRates ); ++i )
1157 value = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, vht2ssRates[i] );
1158 PHY_SetTxPowerByRate( pAdapter, band, path, txNum, vht2ssRates[i], value - base );
1162 base = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, MGN_VHT3SS_MCS7 );
1163 for ( i = 0; i < sizeof( vht3ssRates ); ++i )
1165 value = PHY_GetTxPowerByRate( pAdapter, band, path, txNum, vht3ssRates[i] );
1166 PHY_SetTxPowerByRate( pAdapter, band, path, txNum, vht3ssRates[i], value - base );
1172 //DBG_871X("<===PHY_ConvertTxPowerByRateInDbmToRelativeValues()\n" );
1176 * This function must be called if the value in the PHY_REG_PG.txt(or header)
1177 * is exact dBm values
1180 PHY_TxPowerByRateConfiguration(
1181 IN PADAPTER pAdapter
1184 HAL_DATA_TYPE *pHalData = GET_HAL_DATA( pAdapter);
1186 phy_StoreTxPowerByRateBase( pAdapter );
1187 phy_ConvertTxPowerByRateInDbmToRelativeValues( pAdapter );
1191 PHY_SetTxPowerIndexByRateSection(
1192 IN PADAPTER pAdapter,
1198 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1200 if ( RateSection == CCK )
1202 u8 cckRates[] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M};
1203 if ( pHalData->CurrentBandType == BAND_ON_2_4G )
1204 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1205 cckRates, sizeof(cckRates)/sizeof(u8) );
1208 else if ( RateSection == OFDM )
1210 u8 ofdmRates[] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M};
1211 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1212 ofdmRates, sizeof(ofdmRates)/sizeof(u8));
1215 else if ( RateSection == HT_MCS0_MCS7 )
1217 u8 htRates1T[] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7};
1218 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1219 htRates1T, sizeof(htRates1T)/sizeof(u8));
1222 else if ( RateSection == HT_MCS8_MCS15 )
1224 u8 htRates2T[] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15};
1225 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1226 htRates2T, sizeof(htRates2T)/sizeof(u8));
1229 else if ( RateSection == HT_MCS16_MCS23 )
1231 u1Byte htRates3T[] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23};
1232 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1233 htRates3T, sizeof(htRates3T)/sizeof(u1Byte));
1236 else if ( RateSection == HT_MCS24_MCS31 )
1238 u1Byte htRates4T[] = {MGN_MCS24, MGN_MCS25, MGN_MCS26, MGN_MCS27, MGN_MCS28, MGN_MCS29, MGN_MCS30, MGN_MCS31};
1239 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1240 htRates4T, sizeof(htRates4T)/sizeof(u1Byte));
1243 else if ( RateSection == VHT_1SSMCS0_1SSMCS9 )
1245 u8 vhtRates1T[] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4,
1246 MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9};
1247 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1248 vhtRates1T, sizeof(vhtRates1T)/sizeof(u8));
1251 else if ( RateSection == VHT_2SSMCS0_2SSMCS9 )
1253 u8 vhtRates2T[] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4,
1254 MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9};
1256 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1257 vhtRates2T, sizeof(vhtRates2T)/sizeof(u8));
1259 else if ( RateSection == VHT_3SSMCS0_3SSMCS9 )
1261 u1Byte vhtRates3T[] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4,
1262 MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9};
1264 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1265 vhtRates3T, sizeof(vhtRates3T)/sizeof(u1Byte));
1267 else if ( RateSection == VHT_4SSMCS0_4SSMCS9 )
1269 u1Byte vhtRates4T[] = {MGN_VHT4SS_MCS0, MGN_VHT4SS_MCS1, MGN_VHT4SS_MCS2, MGN_VHT4SS_MCS3, MGN_VHT4SS_MCS4,
1270 MGN_VHT4SS_MCS5, MGN_VHT4SS_MCS6, MGN_VHT4SS_MCS7, MGN_VHT4SS_MCS8, MGN_VHT4SS_MCS9};
1272 PHY_SetTxPowerIndexByRateArray( pAdapter, RFPath, pHalData->CurrentChannelBW, Channel,
1273 vhtRates4T, sizeof(vhtRates4T)/sizeof(u1Byte));
1277 DBG_871X("Invalid RateSection %d in %s", RateSection, __FUNCTION__ );
1287 u8 channel5G[CHANNEL_MAX_NUMBER_5G] =
1288 {36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,100,102,104,106,108,110,112,
1289 114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,149,151,
1290 153,155,157,159,161,163,165,167,168,169,171,173,175,177};
1292 BOOLEAN bIn24G=_TRUE;
1297 *ChannelIdx = Channel -1;
1303 for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i)
1305 if ( channel5G[i] == Channel) {
1316 PHY_GetTxPowerIndexBase(
1317 IN PADAPTER pAdapter,
1320 IN CHANNEL_WIDTH BandWidth,
1325 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1326 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
1327 u8 i = 0; //default set to 1S
1329 u8 chnlIdx = (Channel-1);
1331 if (HAL_IsLegalChannel(pAdapter, Channel) == _FALSE)
1334 DBG_871X("Illegal channel!!\n");
1337 *bIn24G = phy_GetChnlIndex(Channel, &chnlIdx);
1339 //DBG_871X("[%s] Channel Index: %d\n", (*bIn24G?"2.4G":"5G"), chnlIdx);
1341 if (*bIn24G) //3 ============================== 2.4 G ==============================
1343 if ( IS_CCK_RATE(Rate) )
1345 txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx];
1347 else if ( MGN_6M <= Rate )
1349 txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx];
1353 DBG_871X("PHY_GetTxPowerIndexBase: INVALID Rate.\n");
1356 //DBG_871X("Base Tx power(RF-%c, Rate #%d, Channel Index %d) = 0x%X\n",
1357 // ((RFPath==0)?'A':'B'), Rate, chnlIdx, txPower);
1360 if ( (MGN_6M <= Rate && Rate <= MGN_54M) && ! IS_CCK_RATE(Rate) )
1362 txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
1363 //DBG_871X("+PowerDiff 2.4G (RF-%c): (OFDM-1T) = (%d)\n", ((RFPath==0)?'A':'B'), pHalData->OFDM_24G_Diff[RFPath][TX_1S]);
1366 if (BandWidth == CHANNEL_WIDTH_20)
1368 if ( (MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1369 txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
1370 if ( (MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1371 txPower += pHalData->BW20_24G_Diff[RFPath][TX_2S];
1372 if ( (MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1373 txPower += pHalData->BW20_24G_Diff[RFPath][TX_3S];
1374 if ( (MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1375 txPower += pHalData->BW20_24G_Diff[RFPath][TX_4S];
1377 //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'),
1378 // pHalData->BW20_24G_Diff[RFPath][TX_1S], pHalData->BW20_24G_Diff[RFPath][TX_2S],
1379 // pHalData->BW20_24G_Diff[RFPath][TX_3S], pHalData->BW20_24G_Diff[RFPath][TX_4S]);
1382 else if (BandWidth == CHANNEL_WIDTH_40)
1384 if ( (MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1385 txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
1386 if ( (MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1387 txPower += pHalData->BW40_24G_Diff[RFPath][TX_2S];
1388 if ( (MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1389 txPower += pHalData->BW40_24G_Diff[RFPath][TX_3S];
1390 if ( (MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1391 txPower += pHalData->BW40_24G_Diff[RFPath][TX_4S];
1393 //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'),
1394 // pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S],
1395 // pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]);
1397 // Willis suggest adopt BW 40M power index while in BW 80 mode
1398 else if ( BandWidth == CHANNEL_WIDTH_80 )
1400 if ( (MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1401 txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
1402 if ( (MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1403 txPower += pHalData->BW40_24G_Diff[RFPath][TX_2S];
1404 if ( (MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1405 txPower += pHalData->BW40_24G_Diff[RFPath][TX_3S];
1406 if ( (MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1407 txPower += pHalData->BW40_24G_Diff[RFPath][TX_4S];
1409 //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'),
1410 // pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S],
1411 // pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]);
1414 else //3 ============================== 5 G ==============================
1416 if ( MGN_6M <= Rate )
1418 txPower = pHalData->Index5G_BW40_Base[RFPath][chnlIdx];
1422 DBG_871X("===> mpt_ProQueryCalTxPower_Jaguar: INVALID Rate.\n");
1425 //DBG_871X("Base Tx power(RF-%c, Rate #%d, Channel Index %d) = 0x%X\n",
1426 // ((RFPath==0)?'A':'B'), Rate, chnlIdx, txPower);
1429 if ( (MGN_6M <= Rate && Rate <= MGN_54M) && ! IS_CCK_RATE(Rate))
1431 txPower += pHalData->OFDM_5G_Diff[RFPath][TX_1S];
1432 //DBG_871X("+PowerDiff 5G (RF-%c): (OFDM-1T) = (%d)\n", ((RFPath==0)?'A':'B'), pHalData->OFDM_5G_Diff[RFPath][TX_1S]);
1436 if (BandWidth == CHANNEL_WIDTH_20)
1438 if ( (MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1439 txPower += pHalData->BW20_5G_Diff[RFPath][TX_1S];
1440 if ( (MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1441 txPower += pHalData->BW20_5G_Diff[RFPath][TX_2S];
1442 if ( (MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1443 txPower += pHalData->BW20_5G_Diff[RFPath][TX_3S];
1444 if ( (MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1445 txPower += pHalData->BW20_5G_Diff[RFPath][TX_4S];
1447 //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'),
1448 // pHalData->BW20_5G_Diff[RFPath][TX_1S], pHalData->BW20_5G_Diff[RFPath][TX_2S],
1449 // pHalData->BW20_5G_Diff[RFPath][TX_3S], pHalData->BW20_5G_Diff[RFPath][TX_4S]);
1452 else if (BandWidth == CHANNEL_WIDTH_40)
1454 if ( (MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1455 txPower += pHalData->BW40_5G_Diff[RFPath][TX_1S];
1456 if ( (MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1457 txPower += pHalData->BW40_5G_Diff[RFPath][TX_2S];
1458 if ( (MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1459 txPower += pHalData->BW40_5G_Diff[RFPath][TX_3S];
1460 if ( (MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1461 txPower += pHalData->BW40_5G_Diff[RFPath][TX_4S];
1463 //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'),
1464 // pHalData->BW40_5G_Diff[RFPath][TX_1S], pHalData->BW40_5G_Diff[RFPath][TX_2S],
1465 // pHalData->BW40_5G_Diff[RFPath][TX_3S], pHalData->BW40_5G_Diff[RFPath][TX_4S]);
1468 else if (BandWidth== CHANNEL_WIDTH_80)
1470 // <20121220, Kordan> Get the index of array "Index5G_BW80_Base".
1471 u8 channel5G_80M[CHANNEL_MAX_NUMBER_5G_80M] = {42, 58, 106, 122, 138, 155, 171};
1472 for (i = 0; i < sizeof(channel5G_80M)/sizeof(u8); ++i)
1473 if ( channel5G_80M[i] == Channel)
1476 txPower = pHalData->Index5G_BW80_Base[RFPath][chnlIdx];
1478 if ( (MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1479 txPower += + pHalData->BW80_5G_Diff[RFPath][TX_1S];
1480 if ( (MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1481 txPower += pHalData->BW80_5G_Diff[RFPath][TX_2S];
1482 if ( (MGN_MCS16 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT3SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1483 txPower += pHalData->BW80_5G_Diff[RFPath][TX_3S];
1484 if ( (MGN_MCS23 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
1485 txPower += pHalData->BW80_5G_Diff[RFPath][TX_4S];
1487 //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'),
1488 // pHalData->BW80_5G_Diff[RFPath][TX_1S], pHalData->BW80_5G_Diff[RFPath][TX_2S],
1489 // pHalData->BW80_5G_Diff[RFPath][TX_3S], pHalData->BW80_5G_Diff[RFPath][TX_4S]);
1497 PHY_GetTxPowerTrackingOffset(
1503 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1504 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
1507 if( pDM_Odm->RFCalibrateInfo.TxPowerTrackControl == _FALSE)
1510 if ((Rate == MGN_1M) ||(Rate == MGN_2M)||(Rate == MGN_5_5M)||(Rate == MGN_11M))
1512 offset = pDM_Odm->Remnant_CCKSwingIdx;
1513 //DBG_871X("+Remnant_CCKSwingIdx = 0x%x\n", RFPath, Rate, pDM_Odm->Remnant_CCKSwingIdx);
1517 offset = pDM_Odm->Remnant_OFDMSwingIdx[RFPath];
1518 //DBG_871X("+Remanant_OFDMSwingIdx[RFPath %u][Rate 0x%x] = 0x%x\n", RFPath, Rate, pDM_Odm->Remnant_OFDMSwingIdx[RFPath]);
1526 PHY_GetRateIndexOfTxPowerByRate(
1533 case MGN_1M: index = 0; break;
1534 case MGN_2M: index = 1; break;
1535 case MGN_5_5M: index = 2; break;
1536 case MGN_11M: index = 3; break;
1537 case MGN_6M: index = 4; break;
1538 case MGN_9M: index = 5; break;
1539 case MGN_12M: index = 6; break;
1540 case MGN_18M: index = 7; break;
1541 case MGN_24M: index = 8; break;
1542 case MGN_36M: index = 9; break;
1543 case MGN_48M: index = 10; break;
1544 case MGN_54M: index = 11; break;
1545 case MGN_MCS0: index = 12; break;
1546 case MGN_MCS1: index = 13; break;
1547 case MGN_MCS2: index = 14; break;
1548 case MGN_MCS3: index = 15; break;
1549 case MGN_MCS4: index = 16; break;
1550 case MGN_MCS5: index = 17; break;
1551 case MGN_MCS6: index = 18; break;
1552 case MGN_MCS7: index = 19; break;
1553 case MGN_MCS8: index = 20; break;
1554 case MGN_MCS9: index = 21; break;
1555 case MGN_MCS10: index = 22; break;
1556 case MGN_MCS11: index = 23; break;
1557 case MGN_MCS12: index = 24; break;
1558 case MGN_MCS13: index = 25; break;
1559 case MGN_MCS14: index = 26; break;
1560 case MGN_MCS15: index = 27; break;
1561 case MGN_MCS16: index = 28; break;
1562 case MGN_MCS17: index = 29; break;
1563 case MGN_MCS18: index = 30; break;
1564 case MGN_MCS19: index = 31; break;
1565 case MGN_MCS20: index = 32; break;
1566 case MGN_MCS21: index = 33; break;
1567 case MGN_MCS22: index = 34; break;
1568 case MGN_MCS23: index = 35; break;
1569 case MGN_MCS24: index = 36; break;
1570 case MGN_MCS25: index = 37; break;
1571 case MGN_MCS26: index = 38; break;
1572 case MGN_MCS27: index = 39; break;
1573 case MGN_MCS28: index = 40; break;
1574 case MGN_MCS29: index = 41; break;
1575 case MGN_MCS30: index = 42; break;
1576 case MGN_MCS31: index = 43; break;
1577 case MGN_VHT1SS_MCS0: index = 44; break;
1578 case MGN_VHT1SS_MCS1: index = 45; break;
1579 case MGN_VHT1SS_MCS2: index = 46; break;
1580 case MGN_VHT1SS_MCS3: index = 47; break;
1581 case MGN_VHT1SS_MCS4: index = 48; break;
1582 case MGN_VHT1SS_MCS5: index = 49; break;
1583 case MGN_VHT1SS_MCS6: index = 50; break;
1584 case MGN_VHT1SS_MCS7: index = 51; break;
1585 case MGN_VHT1SS_MCS8: index = 52; break;
1586 case MGN_VHT1SS_MCS9: index = 53; break;
1587 case MGN_VHT2SS_MCS0: index = 54; break;
1588 case MGN_VHT2SS_MCS1: index = 55; break;
1589 case MGN_VHT2SS_MCS2: index = 56; break;
1590 case MGN_VHT2SS_MCS3: index = 57; break;
1591 case MGN_VHT2SS_MCS4: index = 58; break;
1592 case MGN_VHT2SS_MCS5: index = 59; break;
1593 case MGN_VHT2SS_MCS6: index = 60; break;
1594 case MGN_VHT2SS_MCS7: index = 61; break;
1595 case MGN_VHT2SS_MCS8: index = 62; break;
1596 case MGN_VHT2SS_MCS9: index = 63; break;
1597 case MGN_VHT3SS_MCS0: index = 64; break;
1598 case MGN_VHT3SS_MCS1: index = 65; break;
1599 case MGN_VHT3SS_MCS2: index = 66; break;
1600 case MGN_VHT3SS_MCS3: index = 67; break;
1601 case MGN_VHT3SS_MCS4: index = 68; break;
1602 case MGN_VHT3SS_MCS5: index = 69; break;
1603 case MGN_VHT3SS_MCS6: index = 70; break;
1604 case MGN_VHT3SS_MCS7: index = 71; break;
1605 case MGN_VHT3SS_MCS8: index = 72; break;
1606 case MGN_VHT3SS_MCS9: index = 73; break;
1607 case MGN_VHT4SS_MCS0: index = 74; break;
1608 case MGN_VHT4SS_MCS1: index = 75; break;
1609 case MGN_VHT4SS_MCS2: index = 76; break;
1610 case MGN_VHT4SS_MCS3: index = 77; break;
1611 case MGN_VHT4SS_MCS4: index = 78; break;
1612 case MGN_VHT4SS_MCS5: index = 79; break;
1613 case MGN_VHT4SS_MCS6: index = 80; break;
1614 case MGN_VHT4SS_MCS7: index = 81; break;
1615 case MGN_VHT4SS_MCS8: index = 82; break;
1616 case MGN_VHT4SS_MCS9: index = 83; break;
1618 DBG_871X("Invalid rate 0x%x in %s\n", Rate, __FUNCTION__ );
1626 PHY_GetTxPowerByRate(
1627 IN PADAPTER pAdapter,
1634 HAL_DATA_TYPE *pHalData = GET_HAL_DATA( pAdapter );
1635 s8 value = 0, limit = 0;
1636 u8 rateIndex = PHY_GetRateIndexOfTxPowerByRate( Rate );
1638 if ( ( pAdapter->registrypriv.RegEnableTxPowerByRate == 2 && pHalData->EEPROMRegulatory == 2 ) ||
1639 pAdapter->registrypriv.RegEnableTxPowerByRate == 0 )
1642 if ( Band != BAND_ON_2_4G && Band != BAND_ON_5G )
1644 DBG_871X("Invalid band %d in %s\n", Band, __FUNCTION__ );
1647 if ( RFPath > ODM_RF_PATH_D )
1649 DBG_871X("Invalid RfPath %d in %s\n", RFPath, __FUNCTION__ );
1652 if ( TxNum >= RF_MAX_TX_NUM )
1654 DBG_871X("Invalid TxNum %d in %s\n", TxNum, __FUNCTION__ );
1657 if ( rateIndex >= TX_PWR_BY_RATE_NUM_RATE )
1659 DBG_871X("Invalid RateIndex %d in %s\n", rateIndex, __FUNCTION__ );
1663 value = pHalData->TxPwrByRateOffset[Band][RFPath][TxNum][rateIndex];
1670 PHY_SetTxPowerByRate(
1671 IN PADAPTER pAdapter,
1679 HAL_DATA_TYPE *pHalData = GET_HAL_DATA( pAdapter );
1680 u8 rateIndex = PHY_GetRateIndexOfTxPowerByRate( Rate );
1682 if ( Band != BAND_ON_2_4G && Band != BAND_ON_5G )
1684 DBG_871X("Invalid band %d in %s\n", Band, __FUNCTION__ );
1687 if ( RFPath > ODM_RF_PATH_D )
1689 DBG_871X("Invalid RfPath %d in %s\n", RFPath, __FUNCTION__ );
1692 if ( TxNum >= RF_MAX_TX_NUM )
1694 DBG_871X( "Invalid TxNum %d in %s\n", TxNum, __FUNCTION__ );
1697 if ( rateIndex >= TX_PWR_BY_RATE_NUM_RATE )
1699 DBG_871X("Invalid RateIndex %d in %s\n", rateIndex, __FUNCTION__ );
1703 pHalData->TxPwrByRateOffset[Band][RFPath][TxNum][rateIndex] = Value;
1707 PHY_SetTxPowerLevelByPath(
1708 IN PADAPTER Adapter,
1713 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter);
1714 BOOLEAN bIsIn24G = (pHalData->CurrentBandType == BAND_ON_2_4G );
1716 //if ( pMgntInfo->RegNByteAccess == 0 )
1719 PHY_SetTxPowerIndexByRateSection( Adapter, path, channel, CCK );
1721 PHY_SetTxPowerIndexByRateSection( Adapter, path, channel, OFDM );
1722 PHY_SetTxPowerIndexByRateSection( Adapter, path, channel, HT_MCS0_MCS7 );
1724 if ( IS_HARDWARE_TYPE_JAGUAR( Adapter ) || IS_HARDWARE_TYPE_8813A( Adapter ) )
1725 PHY_SetTxPowerIndexByRateSection( Adapter, path, channel, VHT_1SSMCS0_1SSMCS9 );
1727 if ( pHalData->NumTotalRFPath >= 2 )
1729 PHY_SetTxPowerIndexByRateSection( Adapter, path, channel, HT_MCS8_MCS15 );
1731 if ( IS_HARDWARE_TYPE_JAGUAR( Adapter ) || IS_HARDWARE_TYPE_8813A( Adapter ) )
1732 PHY_SetTxPowerIndexByRateSection( Adapter, path, channel, VHT_2SSMCS0_2SSMCS9 );
1734 if ( IS_HARDWARE_TYPE_8813A( Adapter ) )
1736 PHY_SetTxPowerIndexByRateSection( Adapter, path, channel, HT_MCS16_MCS23 );
1737 PHY_SetTxPowerIndexByRateSection( Adapter, path, channel, VHT_3SSMCS0_3SSMCS9 );
1744 PHY_SetTxPowerIndexByRateArray(
1745 IN PADAPTER pAdapter,
1747 IN CHANNEL_WIDTH BandWidth,
1756 for (i = 0; i < RateArraySize; ++i)
1758 powerIndex = PHY_GetTxPowerIndex(pAdapter, RFPath, Rates[i], BandWidth, Channel);
1759 PHY_SetTxPowerIndex(pAdapter, powerIndex, RFPath, Rates[i]);
1764 phy_GetWorldWideLimit(
1768 s8 min = LimitTable[0];
1771 for (i = 0; i < MAX_REGULATION_NUM; ++i) {
1772 if (LimitTable[i] < min)
1773 min = LimitTable[i];
1780 phy_GetChannelIndexOfTxPowerLimit(
1785 s8 channelIndex = -1;
1786 u8 channel5G[CHANNEL_MAX_NUMBER_5G] =
1787 {36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,100,102,104,106,108,110,112,
1788 114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,149,151,
1789 153,155,157,159,161,163,165,167,168,169,171,173,175,177};
1791 if ( Band == BAND_ON_2_4G )
1793 channelIndex = Channel - 1;
1795 else if ( Band == BAND_ON_5G )
1797 for ( i = 0; i < sizeof(channel5G)/sizeof(u8); ++i )
1799 if ( channel5G[i] == Channel )
1805 DBG_871X("Invalid Band %d in %s", Band, __FUNCTION__ );
1808 if ( channelIndex == -1 )
1809 DBG_871X("Invalid Channel %d of Band %d in %s", Channel, Band, __FUNCTION__ );
1811 return channelIndex;
1815 PHY_GetTxPowerLimit(
1816 IN PADAPTER Adapter,
1817 IN u32 RegPwrTblSel,
1819 IN CHANNEL_WIDTH Bandwidth,
1825 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
1826 s16 band = -1, regulation = -1, bandwidth = -1,
1827 rateSection = -1, channel = -1;
1828 s8 powerLimit = MAX_POWER_INDEX;
1830 if ( ( Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory != 1 ) ||
1831 Adapter->registrypriv.RegEnableTxPowerLimit == 0 )
1832 return MAX_POWER_INDEX;
1834 switch( Adapter->registrypriv.RegPwrTblSel )
1837 regulation = TXPWR_LMT_ETSI;
1840 regulation = TXPWR_LMT_MKK;
1843 regulation = TXPWR_LMT_FCC;
1847 regulation = TXPWR_LMT_WW;
1851 regulation = ( Band == BAND_ON_2_4G ) ? pHalData->Regulation2_4G
1852 : pHalData->Regulation5G;
1856 //DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", Adapter->registrypriv.RegPwrTblSel, regulation );
1859 if ( Band == BAND_ON_2_4G ) band = 0;
1860 else if ( Band == BAND_ON_5G ) band = 1;
1862 if ( Bandwidth == CHANNEL_WIDTH_20 ) bandwidth = 0;
1863 else if ( Bandwidth == CHANNEL_WIDTH_40 ) bandwidth = 1;
1864 else if ( Bandwidth == CHANNEL_WIDTH_80 ) bandwidth = 2;
1865 else if ( Bandwidth == CHANNEL_WIDTH_160 ) bandwidth = 3;
1869 case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M:
1873 case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M:
1874 case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M:
1878 case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3:
1879 case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7:
1883 case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11:
1884 case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15:
1888 case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19:
1889 case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23:
1893 case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27:
1894 case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31:
1898 case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2:
1899 case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5:
1900 case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8:
1901 case MGN_VHT1SS_MCS9:
1905 case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2:
1906 case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5:
1907 case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8:
1908 case MGN_VHT2SS_MCS9:
1912 case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2:
1913 case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5:
1914 case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8:
1915 case MGN_VHT3SS_MCS9:
1919 case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2:
1920 case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5:
1921 case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8:
1922 case MGN_VHT4SS_MCS9:
1927 DBG_871X("Wrong rate 0x%x\n", DataRate );
1931 if ( Band == BAND_ON_5G && rateSection == 0 )
1932 DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate );
1934 // workaround for wrong index combination to obtain tx power limit,
1935 // OFDM only exists in BW 20M
1936 if ( rateSection == 1 )
1939 // workaround for wrong index combination to obtain tx power limit,
1940 // CCK table will only be given in BW 20M
1941 if ( rateSection == 0 )
1944 // workaround for wrong indxe combination to obtain tx power limit,
1945 // HT on 80M will reference to HT on 40M
1946 if ( ( rateSection == 2 || rateSection == 3 ) && Band == BAND_ON_5G && bandwidth == 2 ) {
1950 if ( Band == BAND_ON_2_4G )
1951 channel = phy_GetChannelIndexOfTxPowerLimit( BAND_ON_2_4G, Channel );
1952 else if ( Band == BAND_ON_5G )
1953 channel = phy_GetChannelIndexOfTxPowerLimit( BAND_ON_5G, Channel );
1954 else if ( Band == BAND_ON_BOTH )
1956 // BAND_ON_BOTH don't care temporarily
1959 if ( band == -1 || regulation == -1 || bandwidth == -1 ||
1960 rateSection == -1 || channel == -1 )
1962 //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",
1963 // band, regulation, bandwidth, RfPath, rateSection, channelGroup );
1965 return MAX_POWER_INDEX;
1968 if ( Band == BAND_ON_2_4G ) {
1969 s8 limits[10] = {0}; u8 i = 0;
1970 for (i = 0; i < MAX_REGULATION_NUM; ++i)
1971 limits[i] = pHalData->TxPwrLimit_2_4G[i][bandwidth][rateSection][channel][RfPath];
1973 powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) :
1974 pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channel][RfPath];
1976 } else if ( Band == BAND_ON_5G ) {
1977 s8 limits[10] = {0}; u8 i = 0;
1978 for (i = 0; i < MAX_REGULATION_NUM; ++i)
1979 limits[i] = pHalData->TxPwrLimit_5G[i][bandwidth][rateSection][channel][RfPath];
1981 powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) :
1982 pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channel][RfPath];
1984 DBG_871X("No power limit table of the specified band\n" );
1986 // combine 5G VHT & HT rate
1987 // 5G 20M and 40M HT and VHT can cross reference
1989 if ( Band == BAND_ON_5G && powerLimit == MAX_POWER_INDEX ) {
1990 if ( bandwidth == 0 || bandwidth == 1 ) {
1991 RT_TRACE( COMP_INIT, DBG_LOUD, ( "No power limit table of the specified band %d, bandwidth %d, ratesection %d, rf path %d\n",
1992 band, bandwidth, rateSection, RfPath ) );
1993 if ( rateSection == 2 )
1994 powerLimit = pHalData->TxPwrLimit_5G[regulation]
1995 [bandwidth][4][channelGroup][RfPath];
1996 else if ( rateSection == 4 )
1997 powerLimit = pHalData->TxPwrLimit_5G[regulation]
1998 [bandwidth][2][channelGroup][RfPath];
1999 else if ( rateSection == 3 )
2000 powerLimit = pHalData->TxPwrLimit_5G[regulation]
2001 [bandwidth][5][channelGroup][RfPath];
2002 else if ( rateSection == 5 )
2003 powerLimit = pHalData->TxPwrLimit_5G[regulation]
2004 [bandwidth][3][channelGroup][RfPath];
2008 //DBG_871X("TxPwrLmt[Regulation %d][Band %d][BW %d][RFPath %d][Rate 0x%x][Chnl %d] = %d\n",
2009 // regulation, pHalData->CurrentBandType, Bandwidth, RfPath, DataRate, Channel, powerLimit);
2014 phy_CrossReferenceHTAndVHTTxPowerLimit(
2015 IN PADAPTER pAdapter
2018 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
2019 u8 regulation, bw, channel, rateSection;
2022 for ( regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation )
2024 for ( bw = 0; bw < MAX_5G_BANDWITH_NUM; ++bw )
2026 for ( channel = 0; channel < CHANNEL_MAX_NUMBER_5G; ++channel )
2028 for ( rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection )
2030 tempPwrLmt = pHalData->TxPwrLimit_5G[regulation][bw][rateSection][channel][ODM_RF_PATH_A];
2031 if ( tempPwrLmt == MAX_POWER_INDEX )
2033 u8 baseSection = 2, refSection = 6;
2034 if ( bw == 0 || bw == 1 ) { // 5G 20M 40M VHT and HT can cross reference
2035 //DBG_871X("No power limit table of the specified band %d, bandwidth %d, ratesection %d, channel %d, rf path %d\n",
2036 // 1, bw, rateSection, channel, ODM_RF_PATH_A );
2037 if ( rateSection >= 2 && rateSection <= 9 ) {
2038 if ( rateSection == 2 )
2043 else if ( rateSection == 3 )
2048 else if ( rateSection == 4 )
2053 else if ( rateSection == 5 )
2058 else if ( rateSection == 6 )
2063 else if ( rateSection == 7 )
2068 else if ( rateSection == 8 )
2073 else if ( rateSection == 9 )
2078 pHalData->TxPwrLimit_5G[regulation][bw][baseSection][channel][ODM_RF_PATH_A] =
2079 pHalData->TxPwrLimit_5G[regulation][bw][refSection][channel][ODM_RF_PATH_A];
2082 //DBG_871X("use other value %d", tempPwrLmt );
2092 PHY_ConvertTxPowerLimitToPowerIndex(
2096 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
2097 u8 BW40PwrBasedBm2_4G = 0x2E, BW40PwrBasedBm5G = 0x2E;
2098 u8 regulation, bw, channel, rateSection;
2101 s8 tempValue = 0, tempPwrLmt = 0;
2104 //DBG_871X("=====> PHY_ConvertTxPowerLimitToPowerIndex()\n" );
2106 phy_CrossReferenceHTAndVHTTxPowerLimit( Adapter );
2108 for ( regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation )
2110 for ( bw = 0; bw < MAX_2_4G_BANDWITH_NUM; ++bw )
2112 for ( channel = 0; channel < CHANNEL_MAX_NUMBER_2G; ++channel )
2114 for ( rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection )
2116 tempPwrLmt = pHalData->TxPwrLimit_2_4G[regulation][bw][rateSection][channel][ODM_RF_PATH_A];
2118 for ( rfPath = ODM_RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath )
2120 if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE )
2122 if ( rateSection == 5 ) // HT 4T
2123 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_4TX, HT_MCS24_MCS31 );
2124 else if ( rateSection == 4 ) // HT 3T
2125 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_3TX, HT_MCS16_MCS23 );
2126 else if ( rateSection == 3 ) // HT 2T
2127 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_2TX, HT_MCS8_MCS15 );
2128 else if ( rateSection == 2 ) // HT 1T
2129 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_1TX, HT_MCS0_MCS7 );
2130 else if ( rateSection == 1 ) // OFDM
2131 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_1TX, OFDM );
2132 else if ( rateSection == 0 ) // CCK
2133 BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_1TX, CCK );
2136 BW40PwrBasedBm2_4G = Adapter->registrypriv.RegPowerBase * 2;
2138 if ( tempPwrLmt != MAX_POWER_INDEX ) {
2139 tempValue = tempPwrLmt - BW40PwrBasedBm2_4G;
2140 pHalData->TxPwrLimit_2_4G[regulation][bw][rateSection][channel][rfPath] = tempValue;
2148 if ( IS_HARDWARE_TYPE_JAGUAR( Adapter ) || IS_HARDWARE_TYPE_8813A( Adapter ) )
2150 for ( regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation )
2152 for ( bw = 0; bw < MAX_5G_BANDWITH_NUM; ++bw )
2154 for ( channel = 0; channel < CHANNEL_MAX_NUMBER_5G; ++channel )
2156 for ( rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection )
2158 tempPwrLmt = pHalData->TxPwrLimit_5G[regulation][bw][rateSection][channel][ODM_RF_PATH_A];
2160 for ( rfPath = ODM_RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath )
2162 if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE )
2164 if ( rateSection == 9 ) // VHT 4SS
2165 BW40PwrBasedBm5G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_4TX, VHT_4SSMCS0_4SSMCS9);
2166 else if ( rateSection == 8 ) // VHT 3SS
2167 BW40PwrBasedBm5G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_3TX, VHT_3SSMCS0_3SSMCS9 );
2168 else if ( rateSection == 7 ) // VHT 2SS
2169 BW40PwrBasedBm5G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_2TX, VHT_2SSMCS0_2SSMCS9 );
2170 else if ( rateSection == 6 ) // VHT 1SS
2171 BW40PwrBasedBm5G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_1TX, VHT_1SSMCS0_1SSMCS9 );
2172 else if ( rateSection == 5 ) // HT 4T
2173 BW40PwrBasedBm5G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_4TX, HT_MCS24_MCS31 );
2174 else if ( rateSection == 4 ) // HT 3T
2175 BW40PwrBasedBm5G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_3TX, HT_MCS16_MCS23 );
2176 else if ( rateSection == 3 ) // HT 2T
2177 BW40PwrBasedBm5G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_2TX, HT_MCS8_MCS15 );
2178 else if ( rateSection == 2 ) // HT 1T
2179 BW40PwrBasedBm5G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_1TX, HT_MCS0_MCS7 );
2180 else if ( rateSection == 1 ) // OFDM
2181 BW40PwrBasedBm5G = PHY_GetTxPowerByRateBase( Adapter, BAND_ON_2_4G, rfPath, RF_1TX, OFDM );
2184 BW40PwrBasedBm5G = Adapter->registrypriv.RegPowerBase * 2;
2186 if ( tempPwrLmt != MAX_POWER_INDEX ) {
2187 tempValue = tempPwrLmt - BW40PwrBasedBm5G;
2188 pHalData->TxPwrLimit_5G[regulation][bw][rateSection][channel][rfPath] = tempValue;
2196 //DBG_871X("<===== PHY_ConvertTxPowerLimitToPowerIndex()\n" );
2200 PHY_InitTxPowerLimit(
2204 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
2207 //DBG_871X("=====> PHY_InitTxPowerLimit()!\n" );
2209 for ( i = 0; i < MAX_REGULATION_NUM; ++i )
2211 for ( j = 0; j < MAX_2_4G_BANDWITH_NUM; ++j )
2212 for ( k = 0; k < MAX_RATE_SECTION_NUM; ++k )
2213 for ( m = 0; m < CHANNEL_MAX_NUMBER_2G; ++m )
2214 for ( l = 0; l < MAX_RF_PATH_NUM; ++l )
2215 pHalData->TxPwrLimit_2_4G[i][j][k][m][l] = MAX_POWER_INDEX;
2218 for ( i = 0; i < MAX_REGULATION_NUM; ++i )
2220 for ( j = 0; j < MAX_5G_BANDWITH_NUM; ++j )
2221 for ( k = 0; k < MAX_RATE_SECTION_NUM; ++k )
2222 for ( m = 0; m < CHANNEL_MAX_NUMBER_5G; ++m )
2223 for ( l = 0; l < MAX_RF_PATH_NUM; ++l )
2224 pHalData->TxPwrLimit_5G[i][j][k][m][l] = MAX_POWER_INDEX;
2227 //DBG_871X("<===== PHY_InitTxPowerLimit()!\n" );
2231 PHY_SetTxPowerLimit(
2232 IN PADAPTER Adapter,
2242 HAL_DATA_TYPE *pHalData = GET_HAL_DATA( Adapter );
2243 u8 regulation=0, bandwidth=0, rateSection=0,
2245 s8 powerLimit = 0, prevPowerLimit, channelIndex;
2247 //DBG_871X( "Index of power limit table [band %s][regulation %s][bw %s][rate section %s][rf path %s][chnl %s][val %s]\n",
2248 // Band, Regulation, Bandwidth, RateSection, RfPath, Channel, PowerLimit );
2250 if ( !GetU1ByteIntegerFromStringInDecimal( (s8 *)Channel, &channel ) ||
2251 !GetU1ByteIntegerFromStringInDecimal( (s8 *)PowerLimit, &powerLimit ) )
2253 DBG_871X("Illegal index of power limit table [chnl %s][val %s]\n", Channel, PowerLimit );
2256 powerLimit = powerLimit > MAX_POWER_INDEX ? MAX_POWER_INDEX : powerLimit;
2258 if ( eqNByte( Regulation, (u8 *)("FCC"), 3 ) ) regulation = 0;
2259 else if ( eqNByte( Regulation, (u8 *)("MKK"), 3 ) ) regulation = 1;
2260 else if ( eqNByte( Regulation, (u8 *)("ETSI"), 4 ) ) regulation = 2;
2261 else if ( eqNByte( Regulation, (u8 *)("WW13"), 4 ) ) regulation = 3;
2263 if ( eqNByte( RateSection, (u8 *)("CCK"), 3 ) && eqNByte( RfPath, (u8 *)("1T"), 2 ) )
2265 else if ( eqNByte( RateSection, (u8 *)("OFDM"), 4 ) && eqNByte( RfPath, (u8 *)("1T"), 2 ) )
2267 else if ( eqNByte( RateSection, (u8 *)("HT"), 2 ) && eqNByte( RfPath, (u8 *)("1T"), 2 ) )
2269 else if ( eqNByte( RateSection, (u8 *)("HT"), 2 ) && eqNByte( RfPath, (u8 *)("2T"), 2 ) )
2271 else if ( eqNByte( RateSection, (u8 *)("HT"), 2 ) && eqNByte( RfPath, (u8 *)("3T"), 2 ) )
2273 else if ( eqNByte( RateSection, (u8 *)("HT"), 2 ) && eqNByte( RfPath, (u8 *)("4T"), 2 ) )
2275 else if ( eqNByte( RateSection, (u8 *)("VHT"), 3 ) && eqNByte( RfPath, (u8 *)("1T"), 2 ) )
2277 else if ( eqNByte( RateSection, (u8 *)("VHT"), 3 ) && eqNByte( RfPath, (u8 *)("2T"), 2 ) )
2279 else if ( eqNByte( RateSection, (u8 *)("VHT"), 3 ) && eqNByte( RfPath, (u8 *)("3T"), 2 ) )
2281 else if ( eqNByte( RateSection, (u8 *)("VHT"), 3 ) && eqNByte( RfPath, (u8 *)("4T"), 2 ) )
2285 DBG_871X("Wrong rate section!\n");
2290 if ( eqNByte( Bandwidth, (u8 *)("20M"), 3 ) ) bandwidth = 0;
2291 else if ( eqNByte( Bandwidth, (u8 *)("40M"), 3 ) ) bandwidth = 1;
2292 else if ( eqNByte( Bandwidth, (u8 *)("80M"), 3 ) ) bandwidth = 2;
2293 else if ( eqNByte( Bandwidth, (u8 *)("160M"), 4 ) ) bandwidth = 3;
2295 if ( eqNByte( Band, (u8 *)("2.4G"), 4 ) )
2297 channelIndex = phy_GetChannelIndexOfTxPowerLimit( BAND_ON_2_4G, channel );
2299 if ( channelIndex == -1 )
2302 prevPowerLimit = pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A];
2304 if ( powerLimit < prevPowerLimit )
2305 pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] = powerLimit;
2307 //DBG_871X( "2.4G Band value : [regulation %d][bw %d][rate_section %d][chnl %d][val %d]\n",
2308 // regulation, bandwidth, rateSection, channelIndex, pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] );
2310 else if ( eqNByte( Band, (u8 *)("5G"), 2 ) )
2312 channelIndex = phy_GetChannelIndexOfTxPowerLimit( BAND_ON_5G, channel );
2314 if ( channelIndex == -1 )
2317 prevPowerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A];
2319 if ( powerLimit < prevPowerLimit )
2320 pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] = powerLimit;
2322 //DBG_871X( "5G Band value : [regulation %d][bw %d][rate_section %d][chnl %d][val %d]\n",
2323 // regulation, bandwidth, rateSection, channel, pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] );
2327 DBG_871X("Cannot recognize the band info in %s\n", Band );
2333 PHY_GetTxPowerIndex(
2334 IN PADAPTER pAdapter,
2337 IN CHANNEL_WIDTH BandWidth,
2343 if (IS_HARDWARE_TYPE_8813A(pAdapter)) {
2344 //#if (RTL8813A_SUPPORT==1)
2345 // txPower = PHY_GetTxPowerIndex_8813A( pAdapter, PowerIndex, RFPath, Rate );
2348 else if (IS_HARDWARE_TYPE_JAGUAR(pAdapter)) {
2349 #if ((RTL8812A_SUPPORT==1) || (RTL8821A_SUPPORT == 1))
2350 txPower = PHY_GetTxPowerIndex_8812A(pAdapter, RFPath, Rate, BandWidth, Channel);
2353 else if (IS_HARDWARE_TYPE_8723B(pAdapter)) {
2354 #if (RTL8723B_SUPPORT==1)
2355 txPower = PHY_GetTxPowerIndex_8723B(pAdapter, RFPath, Rate, BandWidth, Channel);
2358 else if (IS_HARDWARE_TYPE_8192E(pAdapter)) {
2359 #if (RTL8192E_SUPPORT==1)
2360 txPower = PHY_GetTxPowerIndex_8192E(pAdapter, RFPath, Rate, BandWidth, Channel);
2363 else if (IS_HARDWARE_TYPE_8188E(pAdapter)) {
2364 #if (RTL8188E_SUPPORT==1)
2365 txPower = PHY_GetTxPowerIndex_8188E(pAdapter, RFPath, Rate, BandWidth, Channel);
2373 PHY_SetTxPowerIndex(
2374 IN PADAPTER pAdapter,
2380 if (IS_HARDWARE_TYPE_8813A(pAdapter)) {
2381 //#if (RTL8813A_SUPPORT==1)
2382 // PHY_SetTxPowerIndex_8813A( pAdapter, PowerIndex, RFPath, Rate );
2385 else if (IS_HARDWARE_TYPE_JAGUAR(pAdapter)) {
2386 #if ((RTL8812A_SUPPORT==1) || (RTL8821A_SUPPORT == 1))
2387 PHY_SetTxPowerIndex_8812A( pAdapter, PowerIndex, RFPath, Rate );
2390 else if (IS_HARDWARE_TYPE_8723B(pAdapter)) {
2391 #if (RTL8723B_SUPPORT==1)
2392 PHY_SetTxPowerIndex_8723B( pAdapter, PowerIndex, RFPath, Rate );
2395 else if (IS_HARDWARE_TYPE_8192E(pAdapter)) {
2396 #if (RTL8192E_SUPPORT==1)
2397 PHY_SetTxPowerIndex_8192E( pAdapter, PowerIndex, RFPath, Rate );
2400 else if (IS_HARDWARE_TYPE_8188E(pAdapter)) {
2401 #if (RTL8188E_SUPPORT==1)
2402 PHY_SetTxPowerIndex_8188E( pAdapter, PowerIndex, RFPath, Rate );
2408 Hal_ChannelPlanToRegulation(
2409 IN PADAPTER Adapter,
2413 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
2414 pHalData->Regulation2_4G = TXPWR_LMT_WW;
2415 pHalData->Regulation5G = TXPWR_LMT_WW;
2419 case RT_CHANNEL_DOMAIN_WORLD_NULL:
2420 pHalData->Regulation2_4G = TXPWR_LMT_WW;
2422 case RT_CHANNEL_DOMAIN_ETSI1_NULL:
2423 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2425 case RT_CHANNEL_DOMAIN_FCC1_NULL:
2426 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2428 case RT_CHANNEL_DOMAIN_MKK1_NULL:
2429 pHalData->Regulation2_4G = TXPWR_LMT_MKK;
2431 case RT_CHANNEL_DOMAIN_ETSI2_NULL:
2432 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2434 case RT_CHANNEL_DOMAIN_FCC1_FCC1:
2435 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2436 pHalData->Regulation5G = TXPWR_LMT_FCC;
2438 case RT_CHANNEL_DOMAIN_WORLD_ETSI1:
2439 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2440 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2442 case RT_CHANNEL_DOMAIN_MKK1_MKK1:
2443 pHalData->Regulation2_4G = TXPWR_LMT_MKK;
2444 pHalData->Regulation5G = TXPWR_LMT_MKK;
2446 case RT_CHANNEL_DOMAIN_WORLD_KCC1:
2447 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2448 pHalData->Regulation5G = TXPWR_LMT_MKK;
2450 case RT_CHANNEL_DOMAIN_WORLD_FCC2:
2451 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2452 pHalData->Regulation5G = TXPWR_LMT_FCC;
2454 case RT_CHANNEL_DOMAIN_WORLD_FCC3:
2455 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2456 pHalData->Regulation5G = TXPWR_LMT_FCC;
2458 case RT_CHANNEL_DOMAIN_WORLD_FCC4:
2459 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2460 pHalData->Regulation5G = TXPWR_LMT_FCC;
2462 case RT_CHANNEL_DOMAIN_WORLD_FCC5:
2463 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2464 pHalData->Regulation5G = TXPWR_LMT_FCC;
2466 case RT_CHANNEL_DOMAIN_WORLD_FCC6:
2467 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2468 pHalData->Regulation5G = TXPWR_LMT_FCC;
2470 case RT_CHANNEL_DOMAIN_FCC1_FCC7:
2471 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2472 pHalData->Regulation5G = TXPWR_LMT_FCC;
2474 case RT_CHANNEL_DOMAIN_WORLD_ETSI2:
2475 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2476 pHalData->Regulation5G = TXPWR_LMT_FCC;
2478 case RT_CHANNEL_DOMAIN_WORLD_ETSI3:
2479 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2480 pHalData->Regulation5G = TXPWR_LMT_FCC;
2482 case RT_CHANNEL_DOMAIN_MKK1_MKK2:
2483 pHalData->Regulation2_4G = TXPWR_LMT_MKK;
2484 pHalData->Regulation5G = TXPWR_LMT_FCC;
2486 case RT_CHANNEL_DOMAIN_MKK1_MKK3:
2487 pHalData->Regulation2_4G = TXPWR_LMT_MKK;
2488 pHalData->Regulation5G = TXPWR_LMT_FCC;
2490 case RT_CHANNEL_DOMAIN_FCC1_NCC1:
2491 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2492 pHalData->Regulation5G = TXPWR_LMT_FCC;
2494 case RT_CHANNEL_DOMAIN_FCC1_NCC2:
2495 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2496 pHalData->Regulation5G = TXPWR_LMT_FCC;
2498 case RT_CHANNEL_DOMAIN_GLOBAL_NULL:
2499 pHalData->Regulation2_4G = TXPWR_LMT_WW;
2500 pHalData->Regulation5G = TXPWR_LMT_WW;
2502 case RT_CHANNEL_DOMAIN_ETSI1_ETSI4:
2503 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2504 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2506 case RT_CHANNEL_DOMAIN_FCC1_FCC2:
2507 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2508 pHalData->Regulation5G = TXPWR_LMT_FCC;
2510 case RT_CHANNEL_DOMAIN_FCC1_NCC3:
2511 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2512 pHalData->Regulation5G = TXPWR_LMT_FCC;
2514 case RT_CHANNEL_DOMAIN_WORLD_ETSI5:
2515 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2516 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2518 case RT_CHANNEL_DOMAIN_FCC1_FCC8:
2519 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2520 pHalData->Regulation5G = TXPWR_LMT_FCC;
2522 case RT_CHANNEL_DOMAIN_WORLD_ETSI6:
2523 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2524 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2526 case RT_CHANNEL_DOMAIN_WORLD_ETSI7:
2527 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2528 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2530 case RT_CHANNEL_DOMAIN_WORLD_ETSI8:
2531 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2532 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2534 case RT_CHANNEL_DOMAIN_WORLD_ETSI9:
2535 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2536 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2538 case RT_CHANNEL_DOMAIN_WORLD_ETSI10:
2539 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2540 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2542 case RT_CHANNEL_DOMAIN_WORLD_ETSI11:
2543 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2544 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2546 case RT_CHANNEL_DOMAIN_FCC1_NCC4:
2547 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2548 pHalData->Regulation5G = TXPWR_LMT_FCC;
2550 case RT_CHANNEL_DOMAIN_WORLD_ETSI12:
2551 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2552 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2554 case RT_CHANNEL_DOMAIN_FCC1_FCC9:
2555 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2556 pHalData->Regulation5G = TXPWR_LMT_FCC;
2558 case RT_CHANNEL_DOMAIN_WORLD_ETSI13:
2559 pHalData->Regulation2_4G = TXPWR_LMT_ETSI;
2560 pHalData->Regulation5G = TXPWR_LMT_ETSI;
2562 case RT_CHANNEL_DOMAIN_FCC1_FCC10:
2563 pHalData->Regulation2_4G = TXPWR_LMT_FCC;
2564 pHalData->Regulation5G = TXPWR_LMT_FCC;
2566 case RT_CHANNEL_DOMAIN_REALTEK_DEFINE: //Realtek Reserve
2567 pHalData->Regulation2_4G = TXPWR_LMT_WW;
2568 pHalData->Regulation5G = TXPWR_LMT_WW;
2575 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
2577 extern char *rtw_phy_file_path;
2578 char file_path[PATH_LENGTH_MAX];
2580 #define GetLineFromBuffer(buffer) strsep(&buffer, "\n")
2583 phy_ConfigMACWithParaFile(
2584 IN PADAPTER Adapter,
2588 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter);
2589 int rlen = 0, rtStatus = _FAIL;
2590 char *szLine, *ptmp;
2591 u32 u4bRegOffset, u4bRegValue, u4bMove;
2593 if(!(Adapter->registrypriv.load_phy_file & LOAD_MAC_PARA_FILE))
2596 _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
2598 if ((pHalData->mac_reg_len == 0) && (pHalData->mac_reg == NULL))
2600 rtw_merge_string(file_path, PATH_LENGTH_MAX, rtw_phy_file_path, pFileName);
2602 if (rtw_is_file_readable(file_path) == _TRUE)
2604 rlen = rtw_retrive_from_file(file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
2607 rtStatus = _SUCCESS;
2608 pHalData->mac_reg = rtw_zmalloc(rlen);
2609 if(pHalData->mac_reg) {
2610 _rtw_memcpy(pHalData->mac_reg, pHalData->para_file_buf, rlen);
2611 pHalData->mac_reg_len = rlen;
2614 DBG_871X("%s mac_reg alloc fail !\n",__FUNCTION__);
2621 if ((pHalData->mac_reg_len != 0) && (pHalData->mac_reg != NULL)) {
2622 _rtw_memcpy(pHalData->para_file_buf, pHalData->mac_reg, pHalData->mac_reg_len);
2623 rtStatus = _SUCCESS;
2626 DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__);
2630 if (rtStatus == _SUCCESS)
2632 ptmp = pHalData->para_file_buf;
2633 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
2635 if(!IsCommentString(szLine))
2637 // Get 1st hex value as register offset
2638 if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
2640 if(u4bRegOffset == 0xffff)
2645 // Get 2nd hex value as register value.
2647 if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
2649 rtw_write8(Adapter, u4bRegOffset, (u8)u4bRegValue);
2657 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName);
2664 phy_ConfigBBWithParaFile(
2665 IN PADAPTER Adapter,
2670 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
2671 int rlen = 0, rtStatus = _FAIL;
2672 char *szLine, *ptmp;
2673 u32 u4bRegOffset, u4bRegValue, u4bMove;
2675 u32 *pBufLen = NULL;
2677 if(!(Adapter->registrypriv.load_phy_file & LOAD_BB_PARA_FILE))
2682 case CONFIG_BB_PHY_REG:
2683 pBuf = pHalData->bb_phy_reg;
2684 pBufLen = &pHalData->bb_phy_reg_len;
2686 case CONFIG_BB_AGC_TAB:
2687 pBuf = pHalData->bb_agc_tab;
2688 pBufLen = &pHalData->bb_agc_tab_len;
2691 DBG_871X("Unknown ConfigType!! %d\r\n", ConfigType);
2695 _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
2697 if ((*pBufLen == 0) && (pBuf == NULL))
2699 rtw_merge_string(file_path, PATH_LENGTH_MAX, rtw_phy_file_path, pFileName);
2701 if (rtw_is_file_readable(file_path) == _TRUE)
2703 rlen = rtw_retrive_from_file(file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
2706 rtStatus = _SUCCESS;
2707 pBuf = rtw_zmalloc(rlen);
2709 _rtw_memcpy(pBuf, pHalData->para_file_buf, rlen);
2714 case CONFIG_BB_PHY_REG:
2715 pHalData->bb_phy_reg = pBuf;
2717 case CONFIG_BB_AGC_TAB:
2718 pHalData->bb_agc_tab = pBuf;
2721 DBG_871X("Unknown ConfigType!! %d\r\n", ConfigType);
2722 rtw_mfree(pBuf, rlen);
2727 DBG_871X("%s(): ConfigType %d alloc fail !\n",__FUNCTION__,ConfigType);
2734 if ((*pBufLen != 0) && (pBuf != NULL)) {
2735 _rtw_memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
2736 rtStatus = _SUCCESS;
2739 DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__);
2743 if (rtStatus == _SUCCESS)
2745 ptmp = pHalData->para_file_buf;
2746 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
2748 if(!IsCommentString(szLine))
2750 // Get 1st hex value as register offset.
2751 if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
2753 if(u4bRegOffset == 0xffff)
2757 else if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe)
2759 #ifdef CONFIG_LONG_DELAY_ISSUE
2765 else if (u4bRegOffset == 0xfd)
2769 else if (u4bRegOffset == 0xfc)
2773 else if (u4bRegOffset == 0xfb)
2777 else if (u4bRegOffset == 0xfa)
2781 else if (u4bRegOffset == 0xf9)
2786 // Get 2nd hex value as register value.
2788 if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
2790 //DBG_871X("[BB-ADDR]%03lX=%08lX\n", u4bRegOffset, u4bRegValue);
2791 PHY_SetBBReg(Adapter, u4bRegOffset, bMaskDWord, u4bRegValue);
2793 if (u4bRegOffset == 0xa24)
2794 pHalData->odmpriv.RFCalibrateInfo.RegA24 = u4bRegValue;
2796 // Add 1us delay between BB/RF register setting.
2805 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName);
2812 phy_DecryptBBPgParaFile(
2820 char *BufOfLines, *ptmp;
2822 //DBG_871X("=====>phy_DecryptBBPgParaFile()\n");
2823 // 32 the ascii code of the first visable char, 126 the last one
2824 for ( i = 0; i < 95; ++i )
2825 map[i] = ( u8 ) ( 94 - i );
2829 for (BufOfLines = GetLineFromBuffer(ptmp); BufOfLines != NULL; BufOfLines = GetLineFromBuffer(ptmp))
2831 //DBG_871X("Encrypted Line: %s\n", BufOfLines);
2833 for ( j = 0; j < strlen(BufOfLines); ++j )
2835 currentChar = BufOfLines[j];
2837 if ( currentChar == '\0' )
2840 currentChar -= (u8) ( ( ( ( i + j ) * 3 ) % 128 ) );
2842 BufOfLines[j] = map[currentChar - 32] + 32;
2844 //DBG_871X("Decrypted Line: %s\n", BufOfLines );
2845 if (strlen(BufOfLines) != 0)
2847 BufOfLines[strlen(BufOfLines)] = '\n';
2852 phy_ParseBBPgParaFile(
2857 int rtStatus = _SUCCESS;
2858 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
2859 char *szLine, *ptmp;
2860 u32 u4bRegOffset, u4bRegMask, u4bRegValue;
2862 BOOLEAN firstLine = _TRUE;
2864 u8 band = 0, rf_path = 0;
2866 //DBG_871X("=====>phy_ParseBBPgParaFile()\n");
2868 if ( Adapter->registrypriv.RegDecryptCustomFile == 1 )
2869 phy_DecryptBBPgParaFile( Adapter, buffer);
2872 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
2874 if(!IsCommentString(szLine))
2876 if( isAllSpaceOrTab( szLine, sizeof( szLine ) ) )
2879 // Get header info (relative value or exact value)
2882 if ( eqNByte( szLine, (u8 *)("#[v1]"), 5 ) )
2885 pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0';
2886 //DBG_871X("This is a new format PHY_REG_PG.txt \n");
2888 else if ( eqNByte( szLine, (u8 *)("#[v0]"), 5 ))
2890 pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0';
2891 //DBG_871X("This is a old format PHY_REG_PG.txt ok\n");
2895 DBG_871X("The format in PHY_REG_PG are invalid %s\n", szLine);
2899 if ( eqNByte( szLine + 5, (u8 *)("[Exact]#"), 8 ) )
2901 pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE;
2902 //DBG_871X("The values in PHY_REG_PG are exact values ok\n");
2906 else if ( eqNByte( szLine + 5, (pu1Byte)("[Relative]#"), 11 ) )
2908 pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_RELATIVE_VALUE;
2909 //DBG_871X("The values in PHY_REG_PG are relative values ok\n");
2915 DBG_871X("The values in PHY_REG_PG are invalid %s\n", szLine);
2920 if ( pHalData->odmpriv.PhyRegPgVersion == 0 )
2922 // Get 1st hex value as register offset.
2923 if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
2926 if(u4bRegOffset == 0xffff)
2931 // Get 2nd hex value as register mask.
2932 if ( GetHexValueFromString(szLine, &u4bRegMask, &u4bMove) )
2937 if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE )
2939 // Get 3rd hex value as register value.
2940 if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
2942 PHY_StoreTxPowerByRate(Adapter, 0, 0, 1, u4bRegOffset, u4bRegMask, u4bRegValue);
2943 //DBG_871X("[ADDR] %03X=%08X Mask=%08x\n", u4bRegOffset, u4bRegValue, u4bRegMask);
2950 else if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE )
2952 u32 combineValue = 0;
2953 u8 integer = 0, fraction = 0;
2955 if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) )
2961 if ( fraction == 5 ) integer += 1;
2962 combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) );
2963 //DBG_871X(" %d", integer );
2965 if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) )
2971 if ( fraction == 5 ) integer += 1;
2973 combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) );
2974 //DBG_871X(" %d", integer );
2976 if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) )
2982 if ( fraction == 5 ) integer += 1;
2984 combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) );
2985 //DBG_871X(" %d", integer );
2987 if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) )
2993 if ( fraction == 5 ) integer += 1;
2995 combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) );
2996 //DBG_871X(" %d", integer );
2997 PHY_StoreTxPowerByRate(Adapter, 0, 0, 1, u4bRegOffset, u4bRegMask, combineValue);
2999 //DBG_871X("[ADDR] 0x%3x = 0x%4x\n", u4bRegOffset, combineValue );
3003 else if ( pHalData->odmpriv.PhyRegPgVersion > 0 )
3005 u32 index = 0, cnt = 0;
3007 if ( eqNByte( szLine, "0xffff", 6 ) )
3010 if( !eqNByte( "#[END]#", szLine, 7 ) )
3012 // load the table label info
3013 if ( szLine[0] == '#' )
3016 if ( eqNByte( szLine, "#[2.4G]" , 7 ) )
3018 band = BAND_ON_2_4G;
3021 else if ( eqNByte( szLine, "#[5G]", 5) )
3028 DBG_871X("Invalid band %s in PHY_REG_PG.txt \n", szLine );
3032 rf_path= szLine[index] - 'A';
3033 //DBG_871X(" Table label Band %d, RfPath %d\n", band, rf_path );
3035 else // load rows of tables
3037 if ( szLine[1] == '1' )
3039 else if ( szLine[1] == '2' )
3041 else if ( szLine[1] == '3' )
3043 else if ( szLine[1] == '4' )
3047 DBG_871X("Invalid row in PHY_REG_PG.txt %c\n", szLine[1] );
3051 while ( szLine[index] != ']' )
3055 // Get 2nd hex value as register offset.
3057 if ( GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove) )
3062 // Get 2nd hex value as register mask.
3063 if ( GetHexValueFromString(szLine, &u4bRegMask, &u4bMove) )
3068 if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE )
3070 // Get 3rd hex value as register value.
3071 if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
3073 PHY_StoreTxPowerByRate(Adapter, band, rf_path, tx_num, u4bRegOffset, u4bRegMask, u4bRegValue);
3074 //DBG_871X("[ADDR] %03X (tx_num %d) =%08X Mask=%08x\n", u4bRegOffset, tx_num, u4bRegValue, u4bRegMask);
3081 else if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE )
3083 u32 combineValue = 0;
3084 u8 integer = 0, fraction = 0;
3086 if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) )
3092 if ( fraction == 5 ) integer += 1;
3093 combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) );
3094 //DBG_871X(" %d", integer );
3096 if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) )
3102 if ( fraction == 5 ) integer += 1;
3104 combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) );
3105 //DBG_871X(" %d", integer );
3107 if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) )
3113 if ( fraction == 5 ) integer += 1;
3115 combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) );
3116 //DBG_871X(" %d", integer );
3118 if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) )
3124 if ( fraction == 5 ) integer += 1;
3126 combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) );
3127 //DBG_871X(" %d", integer );
3128 PHY_StoreTxPowerByRate(Adapter, band, rf_path, tx_num, u4bRegOffset, u4bRegMask, combineValue);
3130 //DBG_871X("[ADDR] 0x%3x (tx_num %d) = 0x%4x\n", u4bRegOffset, tx_num, combineValue );
3137 //DBG_871X("<=====phy_ParseBBPgParaFile()\n");
3142 phy_ConfigBBWithPgParaFile(
3143 IN PADAPTER Adapter,
3146 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
3147 int rlen = 0, rtStatus = _FAIL;
3149 if(!(Adapter->registrypriv.load_phy_file & LOAD_BB_PG_PARA_FILE))
3152 _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
3154 if ((pHalData->bb_phy_reg_pg_len == 0) && (pHalData->bb_phy_reg_pg == NULL))
3156 rtw_merge_string(file_path, PATH_LENGTH_MAX, rtw_phy_file_path, pFileName);
3158 if (rtw_is_file_readable(file_path) == _TRUE)
3160 rlen = rtw_retrive_from_file(file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
3163 rtStatus = _SUCCESS;
3164 pHalData->bb_phy_reg_pg = rtw_zmalloc(rlen);
3165 if(pHalData->bb_phy_reg_pg) {
3166 _rtw_memcpy(pHalData->bb_phy_reg_pg, pHalData->para_file_buf, rlen);
3167 pHalData->bb_phy_reg_pg_len = rlen;
3170 DBG_871X("%s bb_phy_reg_pg alloc fail !\n",__FUNCTION__);
3177 if ((pHalData->bb_phy_reg_pg_len != 0) && (pHalData->bb_phy_reg_pg != NULL)) {
3178 _rtw_memcpy(pHalData->para_file_buf, pHalData->bb_phy_reg_pg, pHalData->bb_phy_reg_pg_len);
3179 rtStatus = _SUCCESS;
3182 DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__);
3186 if(rtStatus == _SUCCESS)
3188 //DBG_871X("phy_ConfigBBWithPgParaFile(): read %s ok\n", pFileName);
3189 phy_ParseBBPgParaFile(Adapter, pHalData->para_file_buf);
3193 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName);
3199 #if (MP_DRIVER == 1 )
3202 phy_ConfigBBWithMpParaFile(
3203 IN PADAPTER Adapter,
3207 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
3208 int rlen = 0, rtStatus = _FAIL;
3209 char *szLine, *ptmp;
3210 u32 u4bRegOffset, u4bRegValue, u4bMove;
3212 if(!(Adapter->registrypriv.load_phy_file & LOAD_BB_MP_PARA_FILE))
3215 _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
3217 if ((pHalData->bb_phy_reg_mp_len == 0) && (pHalData->bb_phy_reg_mp == NULL))
3219 rtw_merge_string(file_path, PATH_LENGTH_MAX, rtw_phy_file_path, pFileName);
3221 if (rtw_is_file_readable(file_path) == _TRUE)
3223 rlen = rtw_retrive_from_file(file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
3226 rtStatus = _SUCCESS;
3227 pHalData->bb_phy_reg_mp = rtw_zmalloc(rlen);
3228 if(pHalData->bb_phy_reg_mp) {
3229 _rtw_memcpy(pHalData->bb_phy_reg_mp, pHalData->para_file_buf, rlen);
3230 pHalData->bb_phy_reg_mp_len = rlen;
3233 DBG_871X("%s bb_phy_reg_mp alloc fail !\n",__FUNCTION__);
3240 if ((pHalData->bb_phy_reg_mp_len != 0) && (pHalData->bb_phy_reg_mp != NULL)) {
3241 _rtw_memcpy(pHalData->para_file_buf, pHalData->bb_phy_reg_mp, pHalData->bb_phy_reg_mp_len);
3242 rtStatus = _SUCCESS;
3245 DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__);
3249 if(rtStatus == _SUCCESS)
3251 //DBG_871X("phy_ConfigBBWithMpParaFile(): read %s ok\n", pFileName);
3253 ptmp = pHalData->para_file_buf;
3254 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
3256 if(!IsCommentString(szLine))
3258 // Get 1st hex value as register offset.
3259 if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
3261 if(u4bRegOffset == 0xffff)
3265 else if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe)
3267 #ifdef CONFIG_LONG_DELAY_ISSUE
3273 else if (u4bRegOffset == 0xfd)
3277 else if (u4bRegOffset == 0xfc)
3281 else if (u4bRegOffset == 0xfb)
3285 else if (u4bRegOffset == 0xfa)
3289 else if (u4bRegOffset == 0xf9)
3294 // Get 2nd hex value as register value.
3296 if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
3298 //DBG_871X("[ADDR]%03lX=%08lX\n", u4bRegOffset, u4bRegValue);
3299 PHY_SetBBReg(Adapter, u4bRegOffset, bMaskDWord, u4bRegValue);
3301 // Add 1us delay between BB/RF register setting.
3310 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName);
3319 PHY_ConfigRFWithParaFile(
3320 IN PADAPTER Adapter,
3325 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
3326 int rlen = 0, rtStatus = _FAIL;
3327 char *szLine, *ptmp;
3328 u32 u4bRegOffset, u4bRegValue, u4bMove;
3331 u32 *pBufLen = NULL;
3333 if(!(Adapter->registrypriv.load_phy_file & LOAD_RF_PARA_FILE))
3339 pBuf = pHalData->rf_radio_a;
3340 pBufLen = &pHalData->rf_radio_a_len;
3343 pBuf = pHalData->rf_radio_b;
3344 pBufLen = &pHalData->rf_radio_b_len;
3347 DBG_871X("Unknown RF path!! %d\r\n", eRFPath);
3351 _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
3353 if ((*pBufLen == 0) && (pBuf == NULL))
3355 rtw_merge_string(file_path, PATH_LENGTH_MAX, rtw_phy_file_path, pFileName);
3357 if (rtw_is_file_readable(file_path) == _TRUE)
3359 rlen = rtw_retrive_from_file(file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
3362 rtStatus = _SUCCESS;
3363 pBuf = rtw_zmalloc(rlen);
3365 _rtw_memcpy(pBuf, pHalData->para_file_buf, rlen);
3371 pHalData->rf_radio_a = pBuf;
3374 pHalData->rf_radio_b = pBuf;
3377 DBG_871X("Unknown eRFPath!! %d\r\n", eRFPath);
3378 rtw_mfree(pBuf, rlen);
3383 DBG_871X("%s(): eRFPath=%d alloc fail !\n",__FUNCTION__,eRFPath);
3390 if ((*pBufLen != 0) && (pBuf != NULL)) {
3391 _rtw_memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
3392 rtStatus = _SUCCESS;
3395 DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__);
3399 if(rtStatus == _SUCCESS)
3401 //DBG_871X("%s(): read %s successfully\n", __FUNCTION__, pFileName);
3403 ptmp = pHalData->para_file_buf;
3404 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
3406 if(!IsCommentString(szLine))
3408 // Get 1st hex value as register offset.
3409 if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove))
3411 if(u4bRegOffset == 0xfe || u4bRegOffset == 0xffe)
3412 { // Deay specific ms. Only RF configuration require delay.
3413 #ifdef CONFIG_LONG_DELAY_ISSUE
3419 else if (u4bRegOffset == 0xfd)
3423 rtw_udelay_os(MAX_STALL_TIME);
3425 else if (u4bRegOffset == 0xfc)
3429 rtw_udelay_os(MAX_STALL_TIME);
3431 else if (u4bRegOffset == 0xfb)
3435 else if (u4bRegOffset == 0xfa)
3439 else if (u4bRegOffset == 0xf9)
3443 else if(u4bRegOffset == 0xffff)
3448 // Get 2nd hex value as register value.
3450 if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove))
3452 PHY_SetRFReg(Adapter, eRFPath, u4bRegOffset, bRFRegOffsetMask, u4bRegValue);
3454 // Temp add, for frequency lock, if no delay, that may cause
3455 // frequency shift, ex: 2412MHz => 2417MHz
3456 // If frequency shift, the following action may works.
3457 // Fractional-N table in radio_a.txt
3458 //0x2a 0x00001 // channel 1
3459 //0x2b 0x00808 frequency divider.
3470 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName);
3477 initDeltaSwingIndexTables(
3487 #define STR_EQUAL_5G(_band, _path, _sign, _rate, _chnl) \
3488 ((strcmp(Band, _band) == 0) && (strcmp(Path, _path) == 0) && (strcmp(Sign, _sign) == 0) &&\
3489 (strcmp(Rate, _rate) == 0) && (strcmp(Channel, _chnl) == 0)\
3491 #define STR_EQUAL_2G(_band, _path, _sign, _rate) \
3492 ((strcmp(Band, _band) == 0) && (strcmp(Path, _path) == 0) && (strcmp(Sign, _sign) == 0) &&\
3493 (strcmp(Rate, _rate) == 0)\
3496 #define STORE_SWING_TABLE(_array, _iteratedIdx) \
3497 for(token = strsep(&Data, delim); token != NULL; token = strsep(&Data, delim))\
3499 sscanf(token, "%d", &idx);\
3500 _array[_iteratedIdx++] = (u8)idx;\
3503 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
3504 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
3505 PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
3511 //DBG_871X("===>initDeltaSwingIndexTables(): Band: %s;\nPath: %s;\nSign: %s;\nChannel: %s;\nRate: %s;\n, Data: %s;\n",
3512 // Band, Path, Sign, Channel, Rate, Data);
3514 if ( STR_EQUAL_2G("2G", "A", "+", "CCK") )
3516 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P, j);
3518 else if ( STR_EQUAL_2G("2G", "A", "-", "CCK") )
3520 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, j);
3522 else if ( STR_EQUAL_2G("2G", "B", "+", "CCK") )
3524 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, j);
3526 else if ( STR_EQUAL_2G("2G", "B", "-", "CCK") )
3528 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, j);
3530 else if ( STR_EQUAL_2G("2G", "A", "+", "ALL") )
3532 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P, j);
3534 else if ( STR_EQUAL_2G("2G", "A", "-", "ALL") )
3536 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N, j);
3538 else if ( STR_EQUAL_2G("2G", "B", "+", "ALL") )
3540 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P, j);
3542 else if ( STR_EQUAL_2G("2G", "B", "-", "ALL") )
3544 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N, j);
3546 else if ( STR_EQUAL_5G("5G", "A", "+", "ALL", "0") )
3548 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[0], j);
3550 else if ( STR_EQUAL_5G("5G", "A", "-", "ALL", "0") )
3552 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[0], j);
3554 else if ( STR_EQUAL_5G("5G", "B", "+", "ALL", "0") )
3556 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[0], j);
3558 else if ( STR_EQUAL_5G("5G", "B", "-", "ALL", "0") )
3560 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[0], j);
3562 else if ( STR_EQUAL_5G("5G", "A", "+", "ALL", "1") )
3564 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[1], j);
3566 else if ( STR_EQUAL_5G("5G", "A", "-", "ALL", "1") )
3568 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[1], j);
3570 else if ( STR_EQUAL_5G("5G", "B", "+", "ALL", "1") )
3572 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[1], j);
3574 else if ( STR_EQUAL_5G("5G", "B", "-", "ALL", "1") )
3576 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[1], j);
3578 else if ( STR_EQUAL_5G("5G", "A", "+", "ALL", "2") )
3580 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[2], j);
3582 else if ( STR_EQUAL_5G("5G", "A", "-", "ALL", "2") )
3584 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[2], j);
3586 else if ( STR_EQUAL_5G("5G", "B", "+", "ALL", "2") )
3588 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[2], j);
3590 else if ( STR_EQUAL_5G("5G", "B", "-", "ALL", "2") )
3592 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[2], j);
3594 else if ( STR_EQUAL_5G("5G", "A", "+", "ALL", "3") )
3596 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[3], j);
3598 else if ( STR_EQUAL_5G("5G", "A", "-", "ALL", "3") )
3600 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[3], j);
3602 else if ( STR_EQUAL_5G("5G", "B", "+", "ALL", "3") )
3604 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[3], j);
3606 else if ( STR_EQUAL_5G("5G", "B", "-", "ALL", "3") )
3608 STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[3], j);
3612 DBG_871X("===>initDeltaSwingIndexTables(): The input is invalid!!\n");
3617 PHY_ConfigRFWithTxPwrTrackParaFile(
3618 IN PADAPTER Adapter,
3622 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
3623 PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
3624 PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
3625 int rlen = 0, rtStatus = _FAIL;
3626 char *szLine, *ptmp;
3630 if(!(Adapter->registrypriv.load_phy_file & LOAD_RF_TXPWR_TRACK_PARA_FILE))
3633 _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
3635 if ((pHalData->rf_tx_pwr_track_len == 0) && (pHalData->rf_tx_pwr_track == NULL))
3637 rtw_merge_string(file_path, PATH_LENGTH_MAX, rtw_phy_file_path, pFileName);
3639 if (rtw_is_file_readable(file_path) == _TRUE)
3641 rlen = rtw_retrive_from_file(file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
3644 rtStatus = _SUCCESS;
3645 pHalData->rf_tx_pwr_track = rtw_zmalloc(rlen);
3646 if(pHalData->rf_tx_pwr_track) {
3647 _rtw_memcpy(pHalData->rf_tx_pwr_track, pHalData->para_file_buf, rlen);
3648 pHalData->rf_tx_pwr_track_len = rlen;
3651 DBG_871X("%s rf_tx_pwr_track alloc fail !\n",__FUNCTION__);
3658 if ((pHalData->rf_tx_pwr_track_len != 0) && (pHalData->rf_tx_pwr_track != NULL)) {
3659 _rtw_memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_track, pHalData->rf_tx_pwr_track_len);
3660 rtStatus = _SUCCESS;
3663 DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__);
3667 if(rtStatus == _SUCCESS)
3669 //DBG_871X("%s(): read %s successfully\n", __FUNCTION__, pFileName);
3671 ptmp = pHalData->para_file_buf;
3672 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
3674 if ( ! IsCommentString(szLine) )
3676 char band[5]="", path[5]="", sign[5] = "";
3677 char chnl[5]="", rate[10]="";
3678 char data[300]=""; // 100 is too small
3680 if (strlen(szLine) < 10 || szLine[0] != '[')
3683 strncpy(band, szLine+1, 2);
3684 strncpy(path, szLine+5, 1);
3685 strncpy(sign, szLine+8, 1);
3687 i = 10; // szLine+10
3688 if ( ! ParseQualifiedString(szLine, &i, rate, '[', ']') ) {
3689 //DBG_871X("Fail to parse rate!\n");
3691 if ( ! ParseQualifiedString(szLine, &i, chnl, '[', ']') ) {
3692 //DBG_871X("Fail to parse channel group!\n");
3694 while ( szLine[i] != '{' && i < strlen(szLine))
3696 if ( ! ParseQualifiedString(szLine, &i, data, '{', '}') ) {
3697 //DBG_871X("Fail to parse data!\n");
3700 initDeltaSwingIndexTables(Adapter, band, path, sign, chnl, rate, data);
3706 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName);
3709 for (i = 0; i < DELTA_SWINGIDX_SIZE; ++i)
3711 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P[i]);
3712 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N[i]);
3713 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P[i]);
3714 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N[i]);
3715 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P[i]);
3716 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N[i]);
3717 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P[i]);
3718 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N[i]);
3720 for (j = 0; j < 3; ++j)
3722 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[%d][%d] = %d\n", j, i, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[j][i]);
3723 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[%d][%d] = %d\n", j, i, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[j][i]);
3724 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[%d][%d] = %d\n", j, i, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[j][i]);
3725 DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[%d][%d] = %d\n", j, i, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[j][i]);
3733 phy_ParsePowerLimitTableFile(
3738 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
3739 u32 i = 0, forCnt = 0;
3740 u8 loadingStage = 0, limitValue = 0, fraction = 0;
3741 char *szLine, *ptmp;
3742 int rtStatus = _SUCCESS;
3743 char band[10], bandwidth[10], rateSection[10],
3744 regulation[TXPWR_LMT_MAX_REGULATION_NUM][10], rfPath[10],colNumBuf[10];
3747 DBG_871X("===>phy_ParsePowerLimitTableFile()\n" );
3749 if ( Adapter->registrypriv.RegDecryptCustomFile == 1 )
3750 phy_DecryptBBPgParaFile( Adapter, buffer);
3753 for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp))
3756 if ( IsCommentString( szLine ) ) {
3760 if( loadingStage == 0 ) {
3761 for ( forCnt = 0; forCnt < TXPWR_LMT_MAX_REGULATION_NUM; ++forCnt )
3762 _rtw_memset( ( PVOID ) regulation[forCnt], 0, 10 );
3763 _rtw_memset( ( PVOID ) band, 0, 10 );
3764 _rtw_memset( ( PVOID ) bandwidth, 0, 10 );
3765 _rtw_memset( ( PVOID ) rateSection, 0, 10 );
3766 _rtw_memset( ( PVOID ) rfPath, 0, 10 );
3767 _rtw_memset( ( PVOID ) colNumBuf, 0, 10 );
3769 if ( szLine[0] != '#' || szLine[1] != '#' )
3774 while ( szLine[i] == ' ' || szLine[i] == '\t' )
3777 szLine[--i] = ' '; // return the space in front of the regulation info
3779 // Parse the label of the table
3780 if ( ! ParseQualifiedString( szLine, &i, band, ' ', ',' ) ) {
3781 DBG_871X( "Fail to parse band!\n");
3784 if ( ! ParseQualifiedString( szLine, &i, bandwidth, ' ', ',' ) ) {
3785 DBG_871X("Fail to parse bandwidth!\n");
3788 if ( ! ParseQualifiedString( szLine, &i, rfPath, ' ', ',' ) ) {
3789 DBG_871X("Fail to parse rf path!\n");
3792 if ( ! ParseQualifiedString( szLine, &i, rateSection, ' ', ',' ) ) {
3793 DBG_871X("Fail to parse rate!\n");
3799 else if ( loadingStage == 1 )
3801 if ( szLine[0] != '#' || szLine[1] != '#' )
3806 while ( szLine[i] == ' ' || szLine[i] == '\t' )
3809 if ( !eqNByte( (u8 *)(szLine + i), (u8 *)("START"), 5 ) ) {
3810 DBG_871X("Lost \"## START\" label\n");
3816 else if ( loadingStage == 2 )
3818 if ( szLine[0] != '#' || szLine[1] != '#' )
3823 while ( szLine[i] == ' ' || szLine[i] == '\t' )
3826 if ( ! ParseQualifiedString( szLine, &i, colNumBuf, '#', '#' ) ) {
3827 DBG_871X("Fail to parse column number!\n");
3831 if ( !GetU1ByteIntegerFromStringInDecimal( colNumBuf, &colNum ) )
3834 if ( colNum > TXPWR_LMT_MAX_REGULATION_NUM ) {
3835 DBG_871X("unvalid col number %d (greater than max %d)\n",
3836 colNum, TXPWR_LMT_MAX_REGULATION_NUM );
3840 for ( forCnt = 0; forCnt < colNum; ++forCnt )
3842 u8 regulation_name_cnt = 0;
3845 while ( szLine[i] == ' ' || szLine[i] == '\t' )
3848 while ( szLine[i] != ' ' && szLine[i] != '\t' && szLine[i] != '\0' )
3849 regulation[forCnt][regulation_name_cnt++] = szLine[i++];
3850 //DBG_871X("regulation %s!\n", regulation[forCnt]);
3852 if ( regulation_name_cnt == 0 ) {
3853 DBG_871X("unvalid number of regulation!\n");
3860 else if ( loadingStage == 3 )
3862 char channel[10] = {0}, powerLimit[10] = {0};
3866 if ( szLine[0] == '#' && szLine[1] == '#' ) {
3868 while ( szLine[i] == ' ' || szLine[i] == '\t' )
3871 if ( eqNByte( (u8 *)(szLine + i), (u8 *)("END"), 3 ) ) {
3876 DBG_871X("Wrong format\n");
3877 DBG_871X("<===== phy_ParsePowerLimitTableFile()\n");
3882 if ( ( szLine[0] != 'c' && szLine[0] != 'C' ) ||
3883 ( szLine[1] != 'h' && szLine[1] != 'H' ) ) {
3884 DBG_871X("Meet wrong channel => power limt pair\n");
3887 i = 2;// move to the location behind 'h'
3889 // load the channel number
3891 while ( szLine[i] >= '0' && szLine[i] <= '9' ) {
3892 channel[cnt] = szLine[i];
3896 //DBG_871X("chnl %s!\n", channel);
3898 for ( forCnt = 0; forCnt < colNum; ++forCnt )
3900 // skip the space between channel number and the power limit value
3901 while ( szLine[i] == ' ' || szLine[i] == '\t' )
3904 // load the power limit value
3907 _rtw_memset( ( PVOID ) powerLimit, 0, 10 );
3908 while ( ( szLine[i] >= '0' && szLine[i] <= '9' ) || szLine[i] == '.' )
3910 if ( szLine[i] == '.' ){
3911 if ( ( szLine[i+1] >= '0' && szLine[i+1] <= '9' ) ) {
3912 fraction = szLine[i+1];
3916 DBG_871X("Wrong fraction in TXPWR_LMT.txt\n");
3923 powerLimit[cnt] = szLine[i];
3928 if ( powerLimit[0] == '\0' ) {
3929 powerLimit[0] = '6';
3930 powerLimit[1] = '3';
3934 if ( !GetU1ByteIntegerFromStringInDecimal( powerLimit, &limitValue ) )
3939 if ( fraction == '5' )
3942 // the value is greater or equal to 100
3943 if ( limitValue >= 100 ) {
3944 powerLimit[cnt++] = limitValue/100 + '0';
3947 if ( limitValue >= 10 ) {
3948 powerLimit[cnt++] = limitValue/10 + '0';
3952 powerLimit[cnt++] = '0';
3955 powerLimit[cnt++] = limitValue + '0';
3957 // the value is greater or equal to 10
3958 else if ( limitValue >= 10 ) {
3959 powerLimit[cnt++] = limitValue/10 + '0';
3961 powerLimit[cnt++] = limitValue + '0';
3963 // the value is less than 10
3965 powerLimit[cnt++] = limitValue + '0';
3967 powerLimit[cnt] = '\0';
3970 //DBG_871X("ch%s => %s\n", channel, powerLimit);
3972 // store the power limit value
3973 PHY_SetTxPowerLimit( Adapter, (u8 *)regulation[forCnt], (u8 *)band,
3974 (u8 *)bandwidth, (u8 *)rateSection, (u8 *)rfPath, (u8 *)channel, (u8 *)powerLimit );
3980 DBG_871X("Abnormal loading stage in phy_ParsePowerLimitTableFile()!\n");
3986 DBG_871X("<===phy_ParsePowerLimitTableFile()\n");
3991 PHY_ConfigRFWithPowerLimitTableParaFile(
3992 IN PADAPTER Adapter,
3996 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
3997 int rlen = 0, rtStatus = _FAIL;
3999 if(!(Adapter->registrypriv.load_phy_file & LOAD_RF_TXPWR_LMT_PARA_FILE))
4002 _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
4004 if ((pHalData->rf_tx_pwr_lmt_len == 0) && (pHalData->rf_tx_pwr_lmt == NULL))
4006 rtw_merge_string(file_path, PATH_LENGTH_MAX, rtw_phy_file_path, pFileName);
4008 if (rtw_is_file_readable(file_path) == _TRUE)
4010 rlen = rtw_retrive_from_file(file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
4013 rtStatus = _SUCCESS;
4014 pHalData->rf_tx_pwr_lmt = rtw_zmalloc(rlen);
4015 if(pHalData->rf_tx_pwr_lmt) {
4016 _rtw_memcpy(pHalData->rf_tx_pwr_lmt, pHalData->para_file_buf, rlen);
4017 pHalData->rf_tx_pwr_lmt_len = rlen;
4020 DBG_871X("%s rf_tx_pwr_lmt alloc fail !\n",__FUNCTION__);
4027 if ((pHalData->rf_tx_pwr_lmt_len != 0) && (pHalData->rf_tx_pwr_lmt != NULL)) {
4028 _rtw_memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_lmt, pHalData->rf_tx_pwr_lmt_len);
4029 rtStatus = _SUCCESS;
4032 DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__);
4036 if(rtStatus == _SUCCESS)
4038 //DBG_871X("%s(): read %s ok\n", __FUNCTION__, pFileName);
4039 rtStatus = phy_ParsePowerLimitTableFile( Adapter, pHalData->para_file_buf );
4043 DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName);