8723BU: Update 8723BU wifi driver to version v4.3.16_14189.20150519_BTCOEX2015119...
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bu / hal / OUTSRC / phydm_DynamicTxPower.c
1 /******************************************************************************\r
2  *\r
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.\r
4  *                                        \r
5  * This program is free software; you can redistribute it and/or modify it\r
6  * under the terms of version 2 of the GNU General Public License as\r
7  * published by the Free Software Foundation.\r
8  *\r
9  * This program is distributed in the hope that it will be useful, but WITHOUT\r
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
12  * more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License along with\r
15  * this program; if not, write to the Free Software Foundation, Inc.,\r
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA\r
17  *\r
18  *\r
19  ******************************************************************************/\r
20 \r
21 //============================================================\r
22 // include files\r
23 //============================================================\r
24 #include "Mp_Precomp.h"
25 #include "phydm_precomp.h"\r
26 \r
27 VOID \r
28 odm_DynamicTxPowerInit(
29         IN              PVOID                                   pDM_VOID        \r
30         )
31 {
32         PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;\r
33 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)\r
34         PADAPTER        Adapter = pDM_Odm->Adapter;
35         PMGNT_INFO                      pMgntInfo = &Adapter->MgntInfo;
36         HAL_DATA_TYPE           *pHalData = GET_HAL_DATA(Adapter);
37
38         #if DEV_BUS_TYPE==RT_USB_INTERFACE                                      
39         if(RT_GetInterfaceSelection(Adapter) == INTF_SEL1_USB_High_Power)
40         {
41                 odm_DynamicTxPowerSavePowerIndex(pDM_Odm);
42                 pMgntInfo->bDynamicTxPowerEnable = TRUE;
43         }               
44         else    
45         #else
46         //so 92c pci do not need dynamic tx power? vivi check it later
47         if(IS_HARDWARE_TYPE_8192D(Adapter))
48                 pMgntInfo->bDynamicTxPowerEnable = TRUE;
49         else
50                 pMgntInfo->bDynamicTxPowerEnable = FALSE;
51         #endif
52         
53
54         pHalData->LastDTPLvl = TxHighPwrLevel_Normal;
55         pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
56
57 \r
58 #endif
59         
60 }
61
62 VOID
63 odm_DynamicTxPowerSavePowerIndex(
64         IN              PVOID                                   pDM_VOID        \r
65         )
66 {       
67         PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;
68 #if (DM_ODM_SUPPORT_TYPE & (ODM_CE|ODM_WIN))
69         u1Byte          index;
70         u4Byte          Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};\r
71         
72 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)    
73         PADAPTER        Adapter = pDM_Odm->Adapter;
74         HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(Adapter);      
75         for(index = 0; index< 6; index++)
76                 pHalData->PowerIndex_backup[index] = PlatformEFIORead1Byte(Adapter, Power_Index_REG[index]);
77         
78         \r
79 #endif
80 #endif
81 }
82
83 VOID
84 odm_DynamicTxPowerRestorePowerIndex(
85         IN              PVOID                                   pDM_VOID\r
86         )
87 {
88         PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;\r
89 #if (DM_ODM_SUPPORT_TYPE & (ODM_CE|ODM_WIN))
90         u1Byte                  index;
91         PADAPTER                Adapter = pDM_Odm->Adapter;\r
92         HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(Adapter);
93         u4Byte                  Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
94 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
95         for(index = 0; index< 6; index++)
96                 PlatformEFIOWrite1Byte(Adapter, Power_Index_REG[index], pHalData->PowerIndex_backup[index]);
97
98 \r
99 #endif
100 #endif
101 }
102
103 VOID
104 odm_DynamicTxPowerWritePowerIndex(
105         IN              PVOID                                   pDM_VOID, \r
106         IN      u1Byte          Value)
107 {
108         PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;\r
109         u1Byte                  index;\r
110         u4Byte                  Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
111         
112         for(index = 0; index< 6; index++)
113                 //PlatformEFIOWrite1Byte(Adapter, Power_Index_REG[index], Value);
114                 ODM_Write1Byte(pDM_Odm, Power_Index_REG[index], Value);
115
116 }
117
118
119 VOID 
120 odm_DynamicTxPower(
121         IN              PVOID                                   pDM_VOID\r
122         )
123 {
124         // 
125         // For AP/ADSL use prtl8192cd_priv
126         // For CE/NIC use PADAPTER
127         //
128         //PADAPTER              pAdapter = pDM_Odm->Adapter;
129 //      prtl8192cd_priv priv            = pDM_Odm->priv;
130         PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;\r
131         if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR))
132                 return;
133         //
134         // 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate
135         // at the same time. In the stage2/3, we need to prive universal interface and merge all
136         // HW dynamic mechanism.
137         //
138         switch  (pDM_Odm->SupportPlatform)
139         {
140                 case    ODM_WIN:
141                 case    ODM_CE:
142                         odm_DynamicTxPowerNIC(pDM_Odm);
143                         break;  
144                 case    ODM_AP:
145                         odm_DynamicTxPowerAP(pDM_Odm);
146                         break;          
147
148                 case    ODM_ADSL:
149                         //odm_DIGAP(pDM_Odm);
150                         break;  
151         }
152
153         
154 }
155
156
157 VOID 
158 odm_DynamicTxPowerNIC(
159         IN              PVOID                                   pDM_VOID\r
160         )
161 {       
162         PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;\r
163         
164         if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR))\r
165                 return;
166         
167 #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
168
169         if(pDM_Odm->SupportICType == ODM_RTL8192C)      
170         {
171                 odm_DynamicTxPower_92C(pDM_Odm);
172         }
173         else if(pDM_Odm->SupportICType == ODM_RTL8192D)
174         {
175                 odm_DynamicTxPower_92D(pDM_Odm);
176         }
177         else if (pDM_Odm->SupportICType == ODM_RTL8821)
178         {
179 #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
180                 PADAPTER                Adapter  =  pDM_Odm->Adapter;
181                 PMGNT_INFO              pMgntInfo = GetDefaultMgntInfo(Adapter);
182
183                 if (pMgntInfo->RegRspPwr == 1)
184                 {
185                         if(pDM_Odm->RSSI_Min > 60)
186                         {
187                                 ODM_SetMACReg(pDM_Odm, ODM_REG_RESP_TX_11AC, BIT20|BIT19|BIT18, 1); // Resp TXAGC offset = -3dB
188
189                         }
190                         else if(pDM_Odm->RSSI_Min < 55)
191                         {
192                                 ODM_SetMACReg(pDM_Odm, ODM_REG_RESP_TX_11AC, BIT20|BIT19|BIT18, 0); // Resp TXAGC offset = 0dB
193                         }
194                 }
195 #endif
196         }
197 #endif  
198 }
199
200 VOID 
201 odm_DynamicTxPowerAP(
202         IN              PVOID                                   pDM_VOID\r
203
204         )
205 {       \r
206         PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;\r
207 #if (DM_ODM_SUPPORT_TYPE == ODM_AP)
208
209 //#if ((RTL8192C_SUPPORT==1) || (RTL8192D_SUPPORT==1) || (RTL8188E_SUPPORT==1) || (RTL8812E_SUPPORT==1))
210
211
212         prtl8192cd_priv priv            = pDM_Odm->priv;
213         s4Byte i;
214         s2Byte pwr_thd = TX_POWER_NEAR_FIELD_THRESH_AP;
215
216         if(!priv->pshare->rf_ft_var.tx_pwr_ctrl)
217                 return;
218         
219 #if ((RTL8812E_SUPPORT==1) || (RTL8881A_SUPPORT==1) || (RTL8814A_SUPPORT==1))
220         if (pDM_Odm->SupportICType & (ODM_RTL8812 | ODM_RTL8881A | ODM_RTL8814A))
221                 pwr_thd = TX_POWER_NEAR_FIELD_THRESH_8812;
222 #endif
223
224 #if defined(CONFIG_RTL_92D_SUPPORT) || defined(CONFIG_RTL_92C_SUPPORT)
225         if(CHIP_VER_92X_SERIES(priv))
226         {
227 #ifdef HIGH_POWER_EXT_PA
228         if(pDM_Odm->ExtPA)
229                 tx_power_control(priv);
230 #endif          
231         }
232 #endif  
233         /*
234          *      Check if station is near by to use lower tx power
235          */
236
237         if ((priv->up_time % 3) == 0 )  {
238                 int disable_pwr_ctrl = ((pDM_Odm->FalseAlmCnt.Cnt_all > 1000 ) || ((pDM_Odm->FalseAlmCnt.Cnt_all > 300 ) && ((RTL_R8(0xc50) & 0x7f) >= 0x32))) ? 1 : 0;
239                         
240                 for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++){
241                         PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
242                         if(IS_STA_VALID(pstat) ) {
243                                         if(disable_pwr_ctrl)
244                                                 pstat->hp_level = 0;
245                                          else if ((pstat->hp_level == 0) && (pstat->rssi > pwr_thd))
246                                         pstat->hp_level = 1;
247                                                 else if ((pstat->hp_level == 1) && (pstat->rssi < (pwr_thd-8)))
248                                         pstat->hp_level = 0;
249                         }
250                 }
251
252 #if defined(CONFIG_WLAN_HAL_8192EE)
253                 if (GET_CHIP_VER(priv) == VERSION_8192E) {
254                         if( !disable_pwr_ctrl && (pDM_Odm->RSSI_Min != 0xff) ) {
255                                 if(pDM_Odm->RSSI_Min > pwr_thd)
256                                         RRSR_power_control_11n(priv,  1 );
257                                 else if(pDM_Odm->RSSI_Min < (pwr_thd-8))
258                                         RRSR_power_control_11n(priv,  0 );
259                         } else {
260                                         RRSR_power_control_11n(priv,  0 );
261                         }
262                 }
263 #endif                  
264
265 #ifdef CONFIG_WLAN_HAL_8814AE
266                 if (GET_CHIP_VER(priv) == VERSION_8814A) {
267                         if (!disable_pwr_ctrl && (pDM_Odm->RSSI_Min != 0xff)) {\r
268                                 if (pDM_Odm->RSSI_Min > pwr_thd)\r
269                                         RRSR_power_control_14(priv,  1);\r
270                                 else if (pDM_Odm->RSSI_Min < (pwr_thd-8))\r
271                                         RRSR_power_control_14(priv,  0);\r
272                         } else {
273                                         RRSR_power_control_14(priv,  0);\r
274                         }
275                 }
276 #endif          
277
278         }
279 //#endif        
280
281 #endif  
282 }
283
284
285 VOID 
286 odm_DynamicTxPower_92C(
287         IN              PVOID                                   pDM_VOID\r
288         )
289 {\r
290         PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;\r
291 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
292         PADAPTER Adapter = pDM_Odm->Adapter;
293         PMGNT_INFO                      pMgntInfo = &Adapter->MgntInfo;
294         HAL_DATA_TYPE           *pHalData = GET_HAL_DATA(Adapter);
295         s4Byte                          UndecoratedSmoothedPWDB;
296
297         // 2012/01/12 MH According to Luke's suggestion, only high power will support the feature.
298         if (pDM_Odm->ExtPA == FALSE)
299                 return;
300
301         // STA not connected and AP not connected
302         if((!pMgntInfo->bMediaConnect) &&       
303                 (pHalData->EntryMinUndecoratedSmoothedPWDB == 0))
304         {
305                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("Not connected to any \n"));
306                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
307
308                 //the LastDTPlvl should reset when disconnect, 
309                 //otherwise the tx power level wouldn't change when disconnect and connect again.
310                 // Maddest 20091220.
311                  pHalData->LastDTPLvl=TxHighPwrLevel_Normal;
312                 return;
313         }
314
315 #if (INTEL_PROXIMITY_SUPPORT == 1)
316         // Intel set fixed tx power 
317         if(pMgntInfo->IntelProximityModeInfo.PowerOutput > 0)
318         {
319                 switch(pMgntInfo->IntelProximityModeInfo.PowerOutput){
320                         case 1:
321                                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_100;
322                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_100\n"));
323                                 break;
324                         case 2:
325                                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_70;
326                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_70\n"));
327                                 break;
328                         case 3:
329                                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_50;
330                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_50\n"));
331                                 break;
332                         case 4:
333                                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_35;
334                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_35\n"));
335                                 break;
336                         case 5:
337                                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_15;
338                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_15\n"));
339                                 break;
340                         default:
341                                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_100;
342                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_100\n"));
343                                 break;
344                 }               
345         }
346         else
347 #endif          
348         { 
349                 if(     (pMgntInfo->bDynamicTxPowerEnable != TRUE) ||
350                         pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_HIGH_POWER)
351                 {
352                         pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
353                 }
354                 else
355                 {
356                         if(pMgntInfo->bMediaConnect)    // Default port
357                         {
358                                 if(ACTING_AS_AP(Adapter) || ACTING_AS_IBSS(Adapter))
359                                 {
360                                         UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
361                                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
362                                 }
363                                 else
364                                 {
365                                         UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB;
366                                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
367                                 }
368                         }
369                         else // associated entry pwdb
370                         {       
371                                 UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
372                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
373                         }
374                                 
375                         if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2)
376                         {
377                                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2;
378                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n"));
379                         }
380                         else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) &&
381                                 (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) )
382                         {
383                                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
384                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
385                         }
386                         else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5))
387                         {
388                                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
389                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n"));
390                         }
391                 }
392         }
393         if( pHalData->DynamicTxHighPowerLvl != pHalData->LastDTPLvl )
394         {
395                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("PHY_SetTxPowerLevel8192C() Channel = %d \n" , pHalData->CurrentChannel));
396                 PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
397                 if(     (pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Normal) &&
398                         (pHalData->LastDTPLvl == TxHighPwrLevel_Level1 || pHalData->LastDTPLvl == TxHighPwrLevel_Level2)) //TxHighPwrLevel_Normal
399                         odm_DynamicTxPowerRestorePowerIndex(pDM_Odm);
400                 else if(pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1)
401                         odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x14);
402                 else if(pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2)
403                         odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x10);
404         }
405         pHalData->LastDTPLvl = pHalData->DynamicTxHighPowerLvl;
406
407         
408
409
410 #endif  // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)\r
411
412 }
413
414
415 VOID 
416 odm_DynamicTxPower_92D(
417         IN              PVOID                                   pDM_VOID\r
418         )
419 {
420 #if (RTL8192D_SUPPORT==1)
421         PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;\r
422 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)\r
423         PADAPTER Adapter = pDM_Odm->Adapter;
424         PMGNT_INFO                      pMgntInfo = &Adapter->MgntInfo;
425         HAL_DATA_TYPE           *pHalData = GET_HAL_DATA(Adapter);
426         s4Byte                          UndecoratedSmoothedPWDB;
427
428         PADAPTER        BuddyAdapter = Adapter->BuddyAdapter;
429         BOOLEAN         bGetValueFromBuddyAdapter = dm_DualMacGetParameterFromBuddyAdapter(Adapter);
430         u1Byte          HighPowerLvlBackForMac0 = TxHighPwrLevel_Level1;
431
432         // 2012/01/12 MH According to Luke's suggestion, only high power will support the feature.
433         if (pDM_Odm->ExtPA == FALSE)
434                 return;
435
436         // If dynamic high power is disabled.
437         if( (pMgntInfo->bDynamicTxPowerEnable != TRUE) ||
438                 pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_HIGH_POWER)
439         {
440                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
441                 return;
442         }
443
444         // STA not connected and AP not connected
445         if((!pMgntInfo->bMediaConnect) &&       
446                 (pHalData->EntryMinUndecoratedSmoothedPWDB == 0))
447         {
448                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("Not connected to any \n"));
449                 pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
450
451                 //the LastDTPlvl should reset when disconnect, 
452                 //otherwise the tx power level wouldn't change when disconnect and connect again.
453                 // Maddest 20091220.
454                  pHalData->LastDTPLvl=TxHighPwrLevel_Normal;
455                 return;
456         }
457         
458         if(pMgntInfo->bMediaConnect)    // Default port
459         {
460                 if(ACTING_AS_AP(Adapter) || pMgntInfo->mIbss)
461                 {
462                         UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
463                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
464                 }
465                 else
466                 {
467                         UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB;
468                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
469                 }
470         }
471         else // associated entry pwdb
472         {       
473                 UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
474                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
475         }
476         
477         if(IS_HARDWARE_TYPE_8192D(Adapter) && GET_HAL_DATA(Adapter)->CurrentBandType == 1){
478                 if(UndecoratedSmoothedPWDB >= 0x33)
479                 {
480                         pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2;
481                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n"));
482                 }
483                 else if((UndecoratedSmoothedPWDB <0x33) &&
484                         (UndecoratedSmoothedPWDB >= 0x2b) )
485                 {
486                         pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
487                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
488                 }
489                 else if(UndecoratedSmoothedPWDB < 0x2b)
490                 {
491                         pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
492                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Normal\n"));
493                 }
494
495         }
496         else
497         
498         {
499                 if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2)
500                 {
501                         pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
502                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n"));
503                 }
504                 else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) &&
505                         (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) )
506                 {
507                         pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
508                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
509                 }
510                 else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5))
511                 {
512                         pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
513                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n"));
514                 }
515
516         }
517
518 //sherry  delete flag 20110517
519         if(bGetValueFromBuddyAdapter)
520         {
521                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 1 \n"));
522                 if(Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP)
523                 {
524                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() change value \n"));
525                         HighPowerLvlBackForMac0 = pHalData->DynamicTxHighPowerLvl;
526                         pHalData->DynamicTxHighPowerLvl = Adapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP;
527                         PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
528                         pHalData->DynamicTxHighPowerLvl = HighPowerLvlBackForMac0;
529                         Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = FALSE;
530                 }                                               
531         }
532
533         if( (pHalData->DynamicTxHighPowerLvl != pHalData->LastDTPLvl) )
534         {
535                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("PHY_SetTxPowerLevel8192S() Channel = %d \n" , pHalData->CurrentChannel));
536                         if(Adapter->DualMacSmartConcurrent == TRUE)
537                         {
538                                 if(BuddyAdapter == NULL)
539                                 {
540                                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter == NULL case \n"));
541                                         if(!Adapter->bSlaveOfDMSP)
542                                         {
543                                                 PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
544                                         }
545                                 }
546                                 else
547                                 {
548                                         if(pHalData->MacPhyMode92D == DUALMAC_SINGLEPHY)
549                                         {
550                                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMSP \n"));
551                                                 if(Adapter->bSlaveOfDMSP)
552                                                 {
553                                                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() bslave case  \n"));
554                                                         BuddyAdapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = TRUE;
555                                                         BuddyAdapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP = pHalData->DynamicTxHighPowerLvl;
556                                                 }
557                                                 else
558                                                 {
559                                                         ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() master case  \n"));                                  
560                                                         if(!bGetValueFromBuddyAdapter)
561                                                         {
562                                                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 0 \n"));
563                                                                 PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
564                                                         }
565                                                 }
566                                         }
567                                         else
568                                         {
569                                                 ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMDP\n"));
570                                                 PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
571                                         }
572                                 }
573                         }
574                         else
575                         {
576                                 PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
577                         }
578
579                 }
580         pHalData->LastDTPLvl = pHalData->DynamicTxHighPowerLvl;
581
582 \r
583 #endif  // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)\r
584 #endif
585 }
586 \r