2 Copyright-c Realtek Semiconductor Corp. All rights reserved.
12 ---------- --------------- -------------------------------
13 2008-05-14 amy create version 0 porting from windows code.
17 #include "r8192E_dm.h"
18 #include "r8192E_hw.h"
19 #include "r819xE_phy.h"
20 #include "r819xE_phyreg.h"
21 #include "r8190_rtl8256.h"
22 /*---------------------------Define Local Constant---------------------------*/
24 // Indicate different AP vendor for IOT issue.
27 static u32 edca_setting_DL
[HT_IOT_PEER_MAX
] =
28 { 0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5e4322};
29 static u32 edca_setting_UL
[HT_IOT_PEER_MAX
] =
30 { 0x5e4322, 0xa44f, 0x5e4322, 0x604322, 0x5e4322, 0x5e4322};
33 static u32 edca_setting_DL
[HT_IOT_PEER_MAX
] =
34 { 0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5e4322};
35 static u32 edca_setting_UL
[HT_IOT_PEER_MAX
] =
36 { 0x5e4322, 0xa44f, 0x5e4322, 0x604322, 0x5e4322, 0x5e4322};
38 static u32 edca_setting_DL
[HT_IOT_PEER_MAX
] =
39 { 0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5ea44f};
40 static u32 edca_setting_UL
[HT_IOT_PEER_MAX
] =
41 { 0x5e4322, 0xa44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f};
45 #define RTK_UL_EDCA 0xa44f
46 #define RTK_DL_EDCA 0x5e4322
47 /*---------------------------Define Local Constant---------------------------*/
50 /*------------------------Define global variable-----------------------------*/
53 // Store current shoftware write register content for MAC PHY.
54 u8 dm_shadow
[16][256] = {{0}};
55 // For Dynamic Rx Path Selection by Signal Strength
56 DRxPathSel DM_RxPathSelTable
;
57 /*------------------------Define global variable-----------------------------*/
60 /*------------------------Define local variable------------------------------*/
61 /*------------------------Define local variable------------------------------*/
64 /*--------------------Define export function prototype-----------------------*/
65 extern void init_hal_dm(struct net_device
*dev
);
66 extern void deinit_hal_dm(struct net_device
*dev
);
68 extern void hal_dm_watchdog(struct net_device
*dev
);
71 extern void init_rate_adaptive(struct net_device
*dev
);
72 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
73 extern void dm_txpower_trackingcallback(struct work_struct
*work
);
75 extern void dm_txpower_trackingcallback(struct net_device
*dev
);
78 extern void dm_cck_txpower_adjust(struct net_device
*dev
,bool binch14
);
79 extern void dm_restore_dynamic_mechanism_state(struct net_device
*dev
);
80 extern void dm_backup_dynamic_mechanism_state(struct net_device
*dev
);
81 extern void dm_change_dynamic_initgain_thresh(struct net_device
*dev
,
84 extern void DM_ChangeFsyncSetting(struct net_device
*dev
,
87 extern void dm_force_tx_fw_info(struct net_device
*dev
,
90 extern void dm_init_edca_turbo(struct net_device
*dev
);
91 extern void dm_rf_operation_test_callback(unsigned long data
);
92 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
93 extern void dm_rf_pathcheck_workitemcallback(struct work_struct
*work
);
95 extern void dm_rf_pathcheck_workitemcallback(struct net_device
*dev
);
97 extern void dm_fsync_timer_callback(unsigned long data
);
99 extern bool dm_check_lbus_status(struct net_device
*dev
);
101 extern void dm_check_fsync(struct net_device
*dev
);
102 extern void dm_shadow_init(struct net_device
*dev
);
103 extern void dm_initialize_txpower_tracking(struct net_device
*dev
);
106 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
107 extern void dm_gpio_change_rf_callback(struct work_struct
*work
);
109 extern void dm_gpio_change_rf_callback(struct net_device
*dev
);
115 /*--------------------Define export function prototype-----------------------*/
118 /*---------------------Define local function prototype-----------------------*/
119 // DM --> Rate Adaptive
120 static void dm_check_rate_adaptive(struct net_device
*dev
);
122 // DM --> Bandwidth switch
123 static void dm_init_bandwidth_autoswitch(struct net_device
*dev
);
124 static void dm_bandwidth_autoswitch( struct net_device
*dev
);
126 // DM --> TX power control
127 //static void dm_initialize_txpower_tracking(struct net_device *dev);
129 static void dm_check_txpower_tracking(struct net_device
*dev
);
133 //static void dm_txpower_reset_recovery(struct net_device *dev);
136 // DM --> BB init gain restore
138 static void dm_bb_initialgain_restore(struct net_device
*dev
);
141 // DM --> BB init gain backup
142 static void dm_bb_initialgain_backup(struct net_device
*dev
);
145 // DM --> Dynamic Init Gain by RSSI
146 static void dm_dig_init(struct net_device
*dev
);
147 static void dm_ctrl_initgain_byrssi(struct net_device
*dev
);
148 static void dm_ctrl_initgain_byrssi_highpwr(struct net_device
*dev
);
149 static void dm_ctrl_initgain_byrssi_by_driverrssi( struct net_device
*dev
);
150 static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct net_device
*dev
);
151 static void dm_initial_gain(struct net_device
*dev
);
152 static void dm_pd_th(struct net_device
*dev
);
153 static void dm_cs_ratio(struct net_device
*dev
);
155 static void dm_init_ctstoself(struct net_device
*dev
);
156 // DM --> EDCA turboe mode control
157 static void dm_check_edca_turbo(struct net_device
*dev
);
159 // DM --> HW RF control
160 static void dm_check_rfctrl_gpio(struct net_device
*dev
);
163 //static void dm_gpio_change_rf(struct net_device *dev);
166 static void dm_check_pbc_gpio(struct net_device
*dev
);
169 // DM --> Check current RX RF path state
170 static void dm_check_rx_path_selection(struct net_device
*dev
);
171 static void dm_init_rxpath_selection(struct net_device
*dev
);
172 static void dm_rxpath_sel_byrssi(struct net_device
*dev
);
175 // DM --> Fsync for broadcom ap
176 static void dm_init_fsync(struct net_device
*dev
);
177 static void dm_deInit_fsync(struct net_device
*dev
);
179 //Added by vivi, 20080522
180 static void dm_check_txrateandretrycount(struct net_device
*dev
);
182 /*---------------------Define local function prototype-----------------------*/
184 /*---------------------Define of Tx Power Control For Near/Far Range --------*/ //Add by Jacken 2008/02/18
185 static void dm_init_dynamic_txpower(struct net_device
*dev
);
186 static void dm_dynamic_txpower(struct net_device
*dev
);
189 // DM --> For rate adaptive and DIG, we must send RSSI to firmware
190 static void dm_send_rssi_tofw(struct net_device
*dev
);
191 static void dm_ctstoself(struct net_device
*dev
);
192 /*---------------------------Define function prototype------------------------*/
193 //================================================================================
194 // HW Dynamic mechanism interface.
195 //================================================================================
199 // Prepare SW resource for HW dynamic mechanism.
202 // This function is only invoked at driver intialization once.
205 void init_hal_dm(struct net_device
*dev
)
207 struct r8192_priv
*priv
= ieee80211_priv(dev
);
209 // Undecorated Smoothed Signal Strength, it can utilized to dynamic mechanism.
210 priv
->undecorated_smoothed_pwdb
= -1;
212 //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code.
213 dm_init_dynamic_txpower(dev
);
214 init_rate_adaptive(dev
);
215 //dm_initialize_txpower_tracking(dev);
217 dm_init_edca_turbo(dev
);
218 dm_init_bandwidth_autoswitch(dev
);
220 dm_init_rxpath_selection(dev
);
221 dm_init_ctstoself(dev
);
223 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
224 INIT_DELAYED_WORK(&priv
->gpio_change_rf_wq
, dm_gpio_change_rf_callback
);
226 INIT_WORK(&priv
->gpio_change_rf_wq
, (void(*)(void*)) dm_gpio_change_rf_callback
,dev
);
232 void deinit_hal_dm(struct net_device
*dev
)
235 dm_deInit_fsync(dev
);
240 #ifdef USB_RX_AGGREGATION_SUPPORT
241 void dm_CheckRxAggregation(struct net_device
*dev
) {
242 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)dev
);
243 PRT_HIGH_THROUGHPUT pHTInfo
= priv
->ieee80211
->pHTInfo
;
244 static unsigned long lastTxOkCnt
= 0;
245 static unsigned long lastRxOkCnt
= 0;
246 unsigned long curTxOkCnt
= 0;
247 unsigned long curRxOkCnt
= 0;
250 if (pHalData->bForcedUsbRxAggr) {
251 if (pHalData->ForcedUsbRxAggrInfo == 0) {
252 if (pHalData->bCurrentRxAggrEnable) {
253 Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, FALSE);
256 if (!pHalData->bCurrentRxAggrEnable || (pHalData->ForcedUsbRxAggrInfo != pHalData->LastUsbRxAggrInfoSetting)) {
257 Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, TRUE);
264 curTxOkCnt
= priv
->stats
.txbytesunicast
- lastTxOkCnt
;
265 curRxOkCnt
= priv
->stats
.rxbytesunicast
- lastRxOkCnt
;
267 if((curTxOkCnt
+ curRxOkCnt
) < 15000000) {
271 if(curTxOkCnt
> 4*curRxOkCnt
) {
272 if (priv
->bCurrentRxAggrEnable
) {
273 write_nic_dword(dev
, 0x1a8, 0);
274 priv
->bCurrentRxAggrEnable
= false;
277 if (!priv
->bCurrentRxAggrEnable
&& !pHTInfo
->bCurrentRT2RTAggregation
) {
279 ulValue
= (pHTInfo
->UsbRxFwAggrEn
<<24) | (pHTInfo
->UsbRxFwAggrPageNum
<<16) |
280 (pHTInfo
->UsbRxFwAggrPacketNum
<<8) | (pHTInfo
->UsbRxFwAggrTimeout
);
282 * If usb rx firmware aggregation is enabled,
283 * when anyone of three threshold conditions above is reached,
284 * firmware will send aggregated packet to driver.
286 write_nic_dword(dev
, 0x1a8, ulValue
);
287 priv
->bCurrentRxAggrEnable
= true;
291 lastTxOkCnt
= priv
->stats
.txbytesunicast
;
292 lastRxOkCnt
= priv
->stats
.rxbytesunicast
;
293 } // dm_CheckEdcaTurbo
298 void hal_dm_watchdog(struct net_device
*dev
)
300 //struct r8192_priv *priv = ieee80211_priv(dev);
302 //static u8 previous_bssid[6] ={0};
304 /*Add by amy 2008/05/15 ,porting from windows code.*/
305 dm_check_rate_adaptive(dev
);
306 dm_dynamic_txpower(dev
);
307 dm_check_txrateandretrycount(dev
);
309 dm_check_txpower_tracking(dev
);
311 dm_ctrl_initgain_byrssi(dev
);
312 dm_check_edca_turbo(dev
);
313 dm_bandwidth_autoswitch(dev
);
315 dm_check_rfctrl_gpio(dev
);
316 dm_check_rx_path_selection(dev
);
319 // Add by amy 2008-05-15 porting from windows code.
320 dm_check_pbc_gpio(dev
);
321 dm_send_rssi_tofw(dev
);
324 #ifdef USB_RX_AGGREGATION_SUPPORT
325 dm_CheckRxAggregation(dev
);
331 * Decide Rate Adaptive Set according to distance (signal strength)
332 * 01/11/2008 MHC Modify input arguments and RATR table level.
333 * 01/16/2008 MHC RF_Type is assigned in ReadAdapterInfo(). We must call
334 * the function after making sure RF_Type.
336 void init_rate_adaptive(struct net_device
* dev
)
339 struct r8192_priv
*priv
= ieee80211_priv(dev
);
340 prate_adaptive pra
= (prate_adaptive
)&priv
->rate_adaptive
;
342 pra
->ratr_state
= DM_RATR_STA_MAX
;
343 pra
->high2low_rssi_thresh_for_ra
= RateAdaptiveTH_High
;
344 pra
->low2high_rssi_thresh_for_ra20M
= RateAdaptiveTH_Low_20M
+5;
345 pra
->low2high_rssi_thresh_for_ra40M
= RateAdaptiveTH_Low_40M
+5;
347 pra
->high_rssi_thresh_for_ra
= RateAdaptiveTH_High
+5;
348 pra
->low_rssi_thresh_for_ra20M
= RateAdaptiveTH_Low_20M
;
349 pra
->low_rssi_thresh_for_ra40M
= RateAdaptiveTH_Low_40M
;
351 if(priv
->CustomerID
== RT_CID_819x_Netcore
)
352 pra
->ping_rssi_enable
= 1;
354 pra
->ping_rssi_enable
= 0;
355 pra
->ping_rssi_thresh_for_ra
= 15;
358 if (priv
->rf_type
== RF_2T4R
)
360 // 07/10/08 MH Modify for RA smooth scheme.
361 /* 2008/01/11 MH Modify 2T RATR table for different RSSI. 080515 porting by amy from windows code.*/
362 pra
->upper_rssi_threshold_ratr
= 0x8f0f0000;
363 pra
->middle_rssi_threshold_ratr
= 0x8f0ff000;
364 pra
->low_rssi_threshold_ratr
= 0x8f0ff001;
365 pra
->low_rssi_threshold_ratr_40M
= 0x8f0ff005;
366 pra
->low_rssi_threshold_ratr_20M
= 0x8f0ff001;
367 pra
->ping_rssi_ratr
= 0x0000000d;//cosa add for test
369 else if (priv
->rf_type
== RF_1T2R
)
371 pra
->upper_rssi_threshold_ratr
= 0x000f0000;
372 pra
->middle_rssi_threshold_ratr
= 0x000ff000;
373 pra
->low_rssi_threshold_ratr
= 0x000ff001;
374 pra
->low_rssi_threshold_ratr_40M
= 0x000ff005;
375 pra
->low_rssi_threshold_ratr_20M
= 0x000ff001;
376 pra
->ping_rssi_ratr
= 0x0000000d;//cosa add for test
379 } // InitRateAdaptive
382 /*-----------------------------------------------------------------------------
383 * Function: dm_check_rate_adaptive()
395 * 05/26/08 amy Create version 0 proting from windows code.
397 *---------------------------------------------------------------------------*/
398 static void dm_check_rate_adaptive(struct net_device
* dev
)
400 struct r8192_priv
*priv
= ieee80211_priv(dev
);
401 PRT_HIGH_THROUGHPUT pHTInfo
= priv
->ieee80211
->pHTInfo
;
402 prate_adaptive pra
= (prate_adaptive
)&priv
->rate_adaptive
;
403 u32 currentRATR
, targetRATR
= 0;
404 u32 LowRSSIThreshForRA
= 0, HighRSSIThreshForRA
= 0;
405 bool bshort_gi_enabled
= false;
406 static u8 ping_rssi_state
=0;
411 RT_TRACE(COMP_RATE
, "<---- dm_check_rate_adaptive(): driver is going to unload\n");
415 if(pra
->rate_adaptive_disabled
)//this variable is set by ioctl.
418 // TODO: Only 11n mode is implemented currently,
419 if( !(priv
->ieee80211
->mode
== WIRELESS_MODE_N_24G
||
420 priv
->ieee80211
->mode
== WIRELESS_MODE_N_5G
))
423 if( priv
->ieee80211
->state
== IEEE80211_LINKED
)
425 // RT_TRACE(COMP_RATE, "dm_CheckRateAdaptive(): \t");
428 // Check whether Short GI is enabled
430 bshort_gi_enabled
= (pHTInfo
->bCurTxBW40MHz
&& pHTInfo
->bCurShortGI40MHz
) ||
431 (!pHTInfo
->bCurTxBW40MHz
&& pHTInfo
->bCurShortGI20MHz
);
434 pra
->upper_rssi_threshold_ratr
=
435 (pra
->upper_rssi_threshold_ratr
& (~BIT31
)) | ((bshort_gi_enabled
)? BIT31
:0) ;
437 pra
->middle_rssi_threshold_ratr
=
438 (pra
->middle_rssi_threshold_ratr
& (~BIT31
)) | ((bshort_gi_enabled
)? BIT31
:0) ;
440 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)
442 pra
->low_rssi_threshold_ratr
=
443 (pra
->low_rssi_threshold_ratr_40M
& (~BIT31
)) | ((bshort_gi_enabled
)? BIT31
:0) ;
447 pra
->low_rssi_threshold_ratr
=
448 (pra
->low_rssi_threshold_ratr_20M
& (~BIT31
)) | ((bshort_gi_enabled
)? BIT31
:0) ;
451 pra
->ping_rssi_ratr
=
452 (pra
->ping_rssi_ratr
& (~BIT31
)) | ((bshort_gi_enabled
)? BIT31
:0) ;
454 /* 2007/10/08 MH We support RA smooth scheme now. When it is the first
455 time to link with AP. We will not change upper/lower threshold. If
456 STA stay in high or low level, we must change two different threshold
457 to prevent jumping frequently. */
458 if (pra
->ratr_state
== DM_RATR_STA_HIGH
)
460 HighRSSIThreshForRA
= pra
->high2low_rssi_thresh_for_ra
;
461 LowRSSIThreshForRA
= (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)?
462 (pra
->low_rssi_thresh_for_ra40M
):(pra
->low_rssi_thresh_for_ra20M
);
464 else if (pra
->ratr_state
== DM_RATR_STA_LOW
)
466 HighRSSIThreshForRA
= pra
->high_rssi_thresh_for_ra
;
467 LowRSSIThreshForRA
= (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)?
468 (pra
->low2high_rssi_thresh_for_ra40M
):(pra
->low2high_rssi_thresh_for_ra20M
);
472 HighRSSIThreshForRA
= pra
->high_rssi_thresh_for_ra
;
473 LowRSSIThreshForRA
= (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)?
474 (pra
->low_rssi_thresh_for_ra40M
):(pra
->low_rssi_thresh_for_ra20M
);
477 //DbgPrint("[DM] THresh H/L=%d/%d\n\r", RATR.HighRSSIThreshForRA, RATR.LowRSSIThreshForRA);
478 if(priv
->undecorated_smoothed_pwdb
>= (long)HighRSSIThreshForRA
)
480 //DbgPrint("[DM] RSSI=%d STA=HIGH\n\r", pHalData->UndecoratedSmoothedPWDB);
481 pra
->ratr_state
= DM_RATR_STA_HIGH
;
482 targetRATR
= pra
->upper_rssi_threshold_ratr
;
483 }else if(priv
->undecorated_smoothed_pwdb
>= (long)LowRSSIThreshForRA
)
485 //DbgPrint("[DM] RSSI=%d STA=Middle\n\r", pHalData->UndecoratedSmoothedPWDB);
486 pra
->ratr_state
= DM_RATR_STA_MIDDLE
;
487 targetRATR
= pra
->middle_rssi_threshold_ratr
;
490 //DbgPrint("[DM] RSSI=%d STA=LOW\n\r", pHalData->UndecoratedSmoothedPWDB);
491 pra
->ratr_state
= DM_RATR_STA_LOW
;
492 targetRATR
= pra
->low_rssi_threshold_ratr
;
496 if(pra
->ping_rssi_enable
)
498 //pHalData->UndecoratedSmoothedPWDB = 19;
499 if(priv
->undecorated_smoothed_pwdb
< (long)(pra
->ping_rssi_thresh_for_ra
+5))
501 if( (priv
->undecorated_smoothed_pwdb
< (long)pra
->ping_rssi_thresh_for_ra
) ||
504 //DbgPrint("TestRSSI = %d, set RATR to 0x%x \n", pHalData->UndecoratedSmoothedPWDB, pRA->TestRSSIRATR);
505 pra
->ratr_state
= DM_RATR_STA_LOW
;
506 targetRATR
= pra
->ping_rssi_ratr
;
510 // DbgPrint("TestRSSI is between the range. \n");
514 //DbgPrint("TestRSSI Recover to 0x%x \n", targetRATR);
521 // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
522 if(priv
->ieee80211
->GetHalfNmodeSupportByAPsHandler(dev
))
523 targetRATR
&= 0xf00fffff;
527 // Check whether updating of RATR0 is required
529 currentRATR
= read_nic_dword(dev
, RATR0
);
530 if( targetRATR
!= currentRATR
)
533 ratr_value
= targetRATR
;
534 RT_TRACE(COMP_RATE
,"currentRATR = %x, targetRATR = %x\n", currentRATR
, targetRATR
);
535 if(priv
->rf_type
== RF_1T2R
)
537 ratr_value
&= ~(RATE_ALL_OFDM_2SS
);
539 write_nic_dword(dev
, RATR0
, ratr_value
);
540 write_nic_byte(dev
, UFWP
, 1);
542 pra
->last_ratr
= targetRATR
;
548 pra
->ratr_state
= DM_RATR_STA_MAX
;
551 } // dm_CheckRateAdaptive
554 static void dm_init_bandwidth_autoswitch(struct net_device
* dev
)
556 struct r8192_priv
*priv
= ieee80211_priv(dev
);
558 priv
->ieee80211
->bandwidth_auto_switch
.threshold_20Mhzto40Mhz
= BW_AUTO_SWITCH_LOW_HIGH
;
559 priv
->ieee80211
->bandwidth_auto_switch
.threshold_40Mhzto20Mhz
= BW_AUTO_SWITCH_HIGH_LOW
;
560 priv
->ieee80211
->bandwidth_auto_switch
.bforced_tx20Mhz
= false;
561 priv
->ieee80211
->bandwidth_auto_switch
.bautoswitch_enable
= false;
563 } // dm_init_bandwidth_autoswitch
566 static void dm_bandwidth_autoswitch(struct net_device
* dev
)
568 struct r8192_priv
*priv
= ieee80211_priv(dev
);
570 if(priv
->CurrentChannelBW
== HT_CHANNEL_WIDTH_20
||!priv
->ieee80211
->bandwidth_auto_switch
.bautoswitch_enable
){
573 if(priv
->ieee80211
->bandwidth_auto_switch
.bforced_tx20Mhz
== false){//If send packets in 40 Mhz in 20/40
574 if(priv
->undecorated_smoothed_pwdb
<= priv
->ieee80211
->bandwidth_auto_switch
.threshold_40Mhzto20Mhz
)
575 priv
->ieee80211
->bandwidth_auto_switch
.bforced_tx20Mhz
= true;
576 }else{//in force send packets in 20 Mhz in 20/40
577 if(priv
->undecorated_smoothed_pwdb
>= priv
->ieee80211
->bandwidth_auto_switch
.threshold_20Mhzto40Mhz
)
578 priv
->ieee80211
->bandwidth_auto_switch
.bforced_tx20Mhz
= false;
582 } // dm_BandwidthAutoSwitch
584 //OFDM default at 0db, index=6.
586 static u32 OFDMSwingTable
[OFDM_Table_Length
] = {
587 0x7f8001fe, // 0, +6db
588 0x71c001c7, // 1, +5db
589 0x65400195, // 2, +4db
590 0x5a400169, // 3, +3db
591 0x50800142, // 4, +2db
592 0x47c0011f, // 5, +1db
593 0x40000100, // 6, +0db ===> default, upper for higher temprature, lower for low temprature
594 0x390000e4, // 7, -1db
595 0x32c000cb, // 8, -2db
596 0x2d4000b5, // 9, -3db
597 0x288000a2, // 10, -4db
598 0x24000090, // 11, -5db
599 0x20000080, // 12, -6db
600 0x1c800072, // 13, -7db
601 0x19800066, // 14, -8db
602 0x26c0005b, // 15, -9db
603 0x24400051, // 16, -10db
604 0x12000048, // 17, -11db
605 0x10000040 // 18, -12db
607 static u8 CCKSwingTable_Ch1_Ch13
[CCK_Table_length
][8] = {
608 {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, // 0, +0db ===> CCK40M default
609 {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, // 1, -1db
610 {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, // 2, -2db
611 {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, // 3, -3db
612 {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, // 4, -4db
613 {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, // 5, -5db
614 {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, // 6, -6db ===> CCK20M default
615 {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, // 7, -7db
616 {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, // 8, -8db
617 {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, // 9, -9db
618 {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 10, -10db
619 {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01} // 11, -11db
622 static u8 CCKSwingTable_Ch14
[CCK_Table_length
][8] = {
623 {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, // 0, +0db ===> CCK40M default
624 {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, // 1, -1db
625 {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, // 2, -2db
626 {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, // 3, -3db
627 {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, // 4, -4db
628 {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, // 5, -5db
629 {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 6, -6db ===> CCK20M default
630 {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, // 7, -7db
631 {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 8, -8db
632 {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 9, -9db
633 {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 10, -10db
634 {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} // 11, -11db
637 #define Pw_Track_Flag 0x11d
638 #define Tssi_Mea_Value 0x13c
639 #define Tssi_Report_Value1 0x134
640 #define Tssi_Report_Value2 0x13e
641 #define FW_Busy_Flag 0x13f
642 static void dm_TXPowerTrackingCallback_TSSI(struct net_device
* dev
)
644 struct r8192_priv
*priv
= ieee80211_priv(dev
);
645 bool bHighpowerstate
, viviflag
= FALSE
;
647 u8 powerlevelOFDM24G
;
648 int i
=0, j
= 0, k
= 0;
649 u8 RF_Type
, tmp_report
[5]={0, 0, 0, 0, 0};
652 u16 Avg_TSSI_Meas
, TSSI_13dBm
, Avg_TSSI_Meas_from_driver
=0;
654 RT_STATUS rtStatus
= RT_STATUS_SUCCESS
;
656 // bool rtStatus = true;
658 RT_TRACE(COMP_POWER_TRACKING
,"%s()\n",__FUNCTION__
);
659 // write_nic_byte(dev, 0x1ba, 0);
660 write_nic_byte(dev
, Pw_Track_Flag
, 0);
661 write_nic_byte(dev
, FW_Busy_Flag
, 0);
662 priv
->ieee80211
->bdynamic_txpower_enable
= false;
663 bHighpowerstate
= priv
->bDynamicTxHighPower
;
665 powerlevelOFDM24G
= (u8
)(priv
->Pwr_Track
>>24);
666 RF_Type
= priv
->rf_type
;
667 Value
= (RF_Type
<<8) | powerlevelOFDM24G
;
669 RT_TRACE(COMP_POWER_TRACKING
, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G
);
671 for(j
= 0; j
<=30; j
++)
674 tx_cmd
.Op
= TXCMD_SET_TX_PWR_TRACKING
;
676 tx_cmd
.Value
= Value
;
678 rtStatus
= SendTxCommandPacket(dev
, &tx_cmd
, 12);
679 if (rtStatus
== RT_STATUS_FAILURE
)
681 RT_TRACE(COMP_POWER_TRACKING
, "Set configuration with tx cmd queue fail!\n");
684 cmpk_message_handle_tx(dev
, (u8
*)&tx_cmd
, DESC_PACKET_TYPE_INIT
, sizeof(DCMD_TXCMD_T
));
687 //DbgPrint("hi, vivi, strange\n");
688 for(i
= 0;i
<= 30; i
++)
690 Pwr_Flag
= read_nic_byte(dev
, Pw_Track_Flag
);
698 Avg_TSSI_Meas
= read_nic_word(dev
, Tssi_Mea_Value
);
700 if(Avg_TSSI_Meas
== 0)
702 write_nic_byte(dev
, Pw_Track_Flag
, 0);
703 write_nic_byte(dev
, FW_Busy_Flag
, 0);
707 for(k
= 0;k
< 5; k
++)
710 tmp_report
[k
] = read_nic_byte(dev
, Tssi_Report_Value1
+k
);
712 tmp_report
[k
] = read_nic_byte(dev
, Tssi_Report_Value2
);
714 RT_TRACE(COMP_POWER_TRACKING
, "TSSI_report_value = %d\n", tmp_report
[k
]);
717 //check if the report value is right
718 for(k
= 0;k
< 5; k
++)
720 if(tmp_report
[k
] <= 20)
728 write_nic_byte(dev
, Pw_Track_Flag
, 0);
730 RT_TRACE(COMP_POWER_TRACKING
, "we filted this data\n");
731 for(k
= 0;k
< 5; k
++)
736 for(k
= 0;k
< 5; k
++)
738 Avg_TSSI_Meas_from_driver
+= tmp_report
[k
];
741 Avg_TSSI_Meas_from_driver
= Avg_TSSI_Meas_from_driver
*100/5;
742 RT_TRACE(COMP_POWER_TRACKING
, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver
);
743 TSSI_13dBm
= priv
->TSSI_13dBm
;
744 RT_TRACE(COMP_POWER_TRACKING
, "TSSI_13dBm = %d\n", TSSI_13dBm
);
746 //if(abs(Avg_TSSI_Meas_from_driver - TSSI_13dBm) <= E_FOR_TX_POWER_TRACK)
747 // For MacOS-compatible
748 if(Avg_TSSI_Meas_from_driver
> TSSI_13dBm
)
749 delta
= Avg_TSSI_Meas_from_driver
- TSSI_13dBm
;
751 delta
= TSSI_13dBm
- Avg_TSSI_Meas_from_driver
;
753 if(delta
<= E_FOR_TX_POWER_TRACK
)
755 priv
->ieee80211
->bdynamic_txpower_enable
= TRUE
;
756 write_nic_byte(dev
, Pw_Track_Flag
, 0);
757 write_nic_byte(dev
, FW_Busy_Flag
, 0);
758 RT_TRACE(COMP_POWER_TRACKING
, "tx power track is done\n");
759 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfa_txpowertrackingindex = %d\n", priv
->rfa_txpowertrackingindex
);
760 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfa_txpowertrackingindex_real = %d\n", priv
->rfa_txpowertrackingindex_real
);
762 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfc_txpowertrackingindex = %d\n", priv
->rfc_txpowertrackingindex
);
763 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfc_txpowertrackingindex_real = %d\n", priv
->rfc_txpowertrackingindex_real
);
765 RT_TRACE(COMP_POWER_TRACKING
, "priv->CCKPresentAttentuation_difference = %d\n", priv
->CCKPresentAttentuation_difference
);
766 RT_TRACE(COMP_POWER_TRACKING
, "priv->CCKPresentAttentuation = %d\n", priv
->CCKPresentAttentuation
);
771 if(Avg_TSSI_Meas_from_driver
< TSSI_13dBm
- E_FOR_TX_POWER_TRACK
)
773 if (RF_Type
== RF_2T4R
)
776 if((priv
->rfa_txpowertrackingindex
> 0) &&(priv
->rfc_txpowertrackingindex
> 0))
778 priv
->rfa_txpowertrackingindex
--;
779 if(priv
->rfa_txpowertrackingindex_real
> 4)
781 priv
->rfa_txpowertrackingindex_real
--;
782 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfa_txpowertrackingindex_real
].txbbgain_value
);
785 priv
->rfc_txpowertrackingindex
--;
786 if(priv
->rfc_txpowertrackingindex_real
> 4)
788 priv
->rfc_txpowertrackingindex_real
--;
789 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfc_txpowertrackingindex_real
].txbbgain_value
);
794 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[4].txbbgain_value
);
795 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[4].txbbgain_value
);
800 if(priv
->rfc_txpowertrackingindex
> 0)
802 priv
->rfc_txpowertrackingindex
--;
803 if(priv
->rfc_txpowertrackingindex_real
> 4)
805 priv
->rfc_txpowertrackingindex_real
--;
806 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfc_txpowertrackingindex_real
].txbbgain_value
);
810 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[4].txbbgain_value
);
815 if (RF_Type
== RF_2T4R
)
817 if((priv
->rfa_txpowertrackingindex
< TxBBGainTableLength
- 1) &&(priv
->rfc_txpowertrackingindex
< TxBBGainTableLength
- 1))
819 priv
->rfa_txpowertrackingindex
++;
820 priv
->rfa_txpowertrackingindex_real
++;
821 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfa_txpowertrackingindex_real
].txbbgain_value
);
822 priv
->rfc_txpowertrackingindex
++;
823 priv
->rfc_txpowertrackingindex_real
++;
824 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfc_txpowertrackingindex_real
].txbbgain_value
);
828 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[TxBBGainTableLength
- 1].txbbgain_value
);
829 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[TxBBGainTableLength
- 1].txbbgain_value
);
834 if(priv
->rfc_txpowertrackingindex
< (TxBBGainTableLength
- 1))
836 priv
->rfc_txpowertrackingindex
++;
837 priv
->rfc_txpowertrackingindex_real
++;
838 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfc_txpowertrackingindex_real
].txbbgain_value
);
841 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[TxBBGainTableLength
- 1].txbbgain_value
);
844 if (RF_Type
== RF_2T4R
)
845 priv
->CCKPresentAttentuation_difference
846 = priv
->rfa_txpowertrackingindex
- priv
->rfa_txpowertracking_default
;
848 priv
->CCKPresentAttentuation_difference
849 = priv
->rfc_txpowertrackingindex
- priv
->rfc_txpowertracking_default
;
851 if(priv
->CurrentChannelBW
== HT_CHANNEL_WIDTH_20
)
852 priv
->CCKPresentAttentuation
853 = priv
->CCKPresentAttentuation_20Mdefault
+ priv
->CCKPresentAttentuation_difference
;
855 priv
->CCKPresentAttentuation
856 = priv
->CCKPresentAttentuation_40Mdefault
+ priv
->CCKPresentAttentuation_difference
;
858 if(priv
->CCKPresentAttentuation
> (CCKTxBBGainTableLength
-1))
859 priv
->CCKPresentAttentuation
= CCKTxBBGainTableLength
-1;
860 if(priv
->CCKPresentAttentuation
< 0)
861 priv
->CCKPresentAttentuation
= 0;
865 if(priv
->ieee80211
->current_network
.channel
== 14 && !priv
->bcck_in_ch14
)
867 priv
->bcck_in_ch14
= TRUE
;
868 dm_cck_txpower_adjust(dev
,priv
->bcck_in_ch14
);
870 else if(priv
->ieee80211
->current_network
.channel
!= 14 && priv
->bcck_in_ch14
)
872 priv
->bcck_in_ch14
= FALSE
;
873 dm_cck_txpower_adjust(dev
,priv
->bcck_in_ch14
);
876 dm_cck_txpower_adjust(dev
,priv
->bcck_in_ch14
);
878 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfa_txpowertrackingindex = %d\n", priv
->rfa_txpowertrackingindex
);
879 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfa_txpowertrackingindex_real = %d\n", priv
->rfa_txpowertrackingindex_real
);
881 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfc_txpowertrackingindex = %d\n", priv
->rfc_txpowertrackingindex
);
882 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfc_txpowertrackingindex_real = %d\n", priv
->rfc_txpowertrackingindex_real
);
884 RT_TRACE(COMP_POWER_TRACKING
, "priv->CCKPresentAttentuation_difference = %d\n", priv
->CCKPresentAttentuation_difference
);
885 RT_TRACE(COMP_POWER_TRACKING
, "priv->CCKPresentAttentuation = %d\n", priv
->CCKPresentAttentuation
);
887 if (priv
->CCKPresentAttentuation_difference
<= -12||priv
->CCKPresentAttentuation_difference
>= 24)
889 priv
->ieee80211
->bdynamic_txpower_enable
= TRUE
;
890 write_nic_byte(dev
, Pw_Track_Flag
, 0);
891 write_nic_byte(dev
, FW_Busy_Flag
, 0);
892 RT_TRACE(COMP_POWER_TRACKING
, "tx power track--->limited\n");
898 write_nic_byte(dev
, Pw_Track_Flag
, 0);
899 Avg_TSSI_Meas_from_driver
= 0;
900 for(k
= 0;k
< 5; k
++)
904 write_nic_byte(dev
, FW_Busy_Flag
, 0);
906 priv
->ieee80211
->bdynamic_txpower_enable
= TRUE
;
907 write_nic_byte(dev
, Pw_Track_Flag
, 0);
910 static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device
* dev
)
912 #define ThermalMeterVal 9
913 struct r8192_priv
*priv
= ieee80211_priv(dev
);
914 u32 tmpRegA
, TempCCk
;
915 u8 tmpOFDMindex
, tmpCCKindex
, tmpCCK20Mindex
, tmpCCK40Mindex
, tmpval
;
916 int i
=0, CCKSwingNeedUpdate
=0;
918 if(!priv
->btxpower_trackingInit
)
920 //Query OFDM default setting
921 tmpRegA
= rtl8192_QueryBBReg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
);
922 for(i
=0; i
<OFDM_Table_Length
; i
++) //find the index
924 if(tmpRegA
== OFDMSwingTable
[i
])
926 priv
->OFDM_index
= (u8
)i
;
927 RT_TRACE(COMP_POWER_TRACKING
, "Initial reg0x%x = 0x%x, OFDM_index=0x%x\n",
928 rOFDM0_XATxIQImbalance
, tmpRegA
, priv
->OFDM_index
);
932 //Query CCK default setting From 0xa22
933 TempCCk
= rtl8192_QueryBBReg(dev
, rCCK0_TxFilter1
, bMaskByte2
);
934 for(i
=0 ; i
<CCK_Table_length
; i
++)
936 if(TempCCk
== (u32
)CCKSwingTable_Ch1_Ch13
[i
][0])
938 priv
->CCK_index
=(u8
) i
;
939 RT_TRACE(COMP_POWER_TRACKING
, "Initial reg0x%x = 0x%x, CCK_index=0x%x\n",
940 rCCK0_TxFilter1
, TempCCk
, priv
->CCK_index
);
944 priv
->btxpower_trackingInit
= TRUE
;
945 //pHalData->TXPowercount = 0;
949 //==========================
950 // this is only for test, should be masked
954 //UINT32 start_rf, end_rf;
957 //UINT32 reg_addr_end;
959 //start_rf = RF90_PATH_A;
960 //end_rf = RF90_PATH_B;//RF90_PATH_MAX;
962 //reg_addr_end = 0x2F;
964 for (curr_addr
= 0; curr_addr
< 0x2d; curr_addr
++)
966 reg_value
= PHY_QueryRFReg( Adapter
, (RF90_RADIO_PATH_E
)RF90_PATH_A
,
967 curr_addr
, bMaskDWord
);
970 pHalData
->TXPowercount
= 0;
974 //==========================
976 // read and filter out unreasonable value
977 tmpRegA
= rtl8192_phy_QueryRFReg(dev
, RF90_PATH_A
, 0x12, 0x078); // 0x12: RF Reg[10:7]
978 RT_TRACE(COMP_POWER_TRACKING
, "Readback ThermalMeterA = %d \n", tmpRegA
);
979 if(tmpRegA
< 3 || tmpRegA
> 13)
981 if(tmpRegA
>= 12) // if over 12, TP will be bad when high temprature
983 RT_TRACE(COMP_POWER_TRACKING
, "Valid ThermalMeterA = %d \n", tmpRegA
);
984 priv
->ThermalMeter
[0] = ThermalMeterVal
; //We use fixed value by Bryant's suggestion
985 priv
->ThermalMeter
[1] = ThermalMeterVal
; //We use fixed value by Bryant's suggestion
987 //Get current RF-A temprature index
988 if(priv
->ThermalMeter
[0] >= (u8
)tmpRegA
) //lower temprature
990 tmpOFDMindex
= tmpCCK20Mindex
= 6+(priv
->ThermalMeter
[0]-(u8
)tmpRegA
);
991 tmpCCK40Mindex
= tmpCCK20Mindex
- 6;
992 if(tmpOFDMindex
>= OFDM_Table_Length
)
993 tmpOFDMindex
= OFDM_Table_Length
-1;
994 if(tmpCCK20Mindex
>= CCK_Table_length
)
995 tmpCCK20Mindex
= CCK_Table_length
-1;
996 if(tmpCCK40Mindex
>= CCK_Table_length
)
997 tmpCCK40Mindex
= CCK_Table_length
-1;
1001 tmpval
= ((u8
)tmpRegA
- priv
->ThermalMeter
[0]);
1002 if(tmpval
>= 6) // higher temprature
1003 tmpOFDMindex
= tmpCCK20Mindex
= 0; // max to +6dB
1005 tmpOFDMindex
= tmpCCK20Mindex
= 6 - tmpval
;
1008 //DbgPrint("%ddb, tmpOFDMindex = %d, tmpCCK20Mindex = %d, tmpCCK40Mindex = %d",
1009 //((u1Byte)tmpRegA - pHalData->ThermalMeter[0]),
1010 //tmpOFDMindex, tmpCCK20Mindex, tmpCCK40Mindex);
1011 if(priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) //40M
1012 tmpCCKindex
= tmpCCK40Mindex
;
1014 tmpCCKindex
= tmpCCK20Mindex
;
1016 //record for bandwidth swith
1017 priv
->Record_CCK_20Mindex
= tmpCCK20Mindex
;
1018 priv
->Record_CCK_40Mindex
= tmpCCK40Mindex
;
1019 RT_TRACE(COMP_POWER_TRACKING
, "Record_CCK_20Mindex / Record_CCK_40Mindex = %d / %d.\n",
1020 priv
->Record_CCK_20Mindex
, priv
->Record_CCK_40Mindex
);
1022 if(priv
->ieee80211
->current_network
.channel
== 14 && !priv
->bcck_in_ch14
)
1024 priv
->bcck_in_ch14
= TRUE
;
1025 CCKSwingNeedUpdate
= 1;
1027 else if(priv
->ieee80211
->current_network
.channel
!= 14 && priv
->bcck_in_ch14
)
1029 priv
->bcck_in_ch14
= FALSE
;
1030 CCKSwingNeedUpdate
= 1;
1033 if(priv
->CCK_index
!= tmpCCKindex
)
1035 priv
->CCK_index
= tmpCCKindex
;
1036 CCKSwingNeedUpdate
= 1;
1039 if(CCKSwingNeedUpdate
)
1041 //DbgPrint("Update CCK Swing, CCK_index = %d\n", pHalData->CCK_index);
1042 dm_cck_txpower_adjust(dev
, priv
->bcck_in_ch14
);
1044 if(priv
->OFDM_index
!= tmpOFDMindex
)
1046 priv
->OFDM_index
= tmpOFDMindex
;
1047 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, OFDMSwingTable
[priv
->OFDM_index
]);
1048 RT_TRACE(COMP_POWER_TRACKING
, "Update OFDMSwing[%d] = 0x%x\n",
1049 priv
->OFDM_index
, OFDMSwingTable
[priv
->OFDM_index
]);
1051 priv
->txpower_count
= 0;
1054 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
1055 void dm_txpower_trackingcallback(struct work_struct
*work
)
1057 struct delayed_work
*dwork
= container_of(work
,struct delayed_work
,work
);
1058 struct r8192_priv
*priv
= container_of(dwork
,struct r8192_priv
,txpower_tracking_wq
);
1059 struct net_device
*dev
= priv
->ieee80211
->dev
;
1061 extern void dm_txpower_trackingcallback(struct net_device
*dev
)
1064 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1069 dm_TXPowerTrackingCallback_TSSI(dev
);
1071 //if(priv->bDcut == TRUE)
1072 if(priv
->IC_Cut
>= IC_VersionCut_D
)
1073 dm_TXPowerTrackingCallback_TSSI(dev
);
1075 dm_TXPowerTrackingCallback_ThermalMeter(dev
);
1080 static void dm_InitializeTXPowerTracking_TSSI(struct net_device
*dev
)
1083 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1085 //Initial the Tx BB index and mapping value
1086 priv
->txbbgain_table
[0].txbb_iq_amplifygain
= 12;
1087 priv
->txbbgain_table
[0].txbbgain_value
=0x7f8001fe;
1088 priv
->txbbgain_table
[1].txbb_iq_amplifygain
= 11;
1089 priv
->txbbgain_table
[1].txbbgain_value
=0x788001e2;
1090 priv
->txbbgain_table
[2].txbb_iq_amplifygain
= 10;
1091 priv
->txbbgain_table
[2].txbbgain_value
=0x71c001c7;
1092 priv
->txbbgain_table
[3].txbb_iq_amplifygain
= 9;
1093 priv
->txbbgain_table
[3].txbbgain_value
=0x6b8001ae;
1094 priv
->txbbgain_table
[4].txbb_iq_amplifygain
= 8;
1095 priv
->txbbgain_table
[4].txbbgain_value
=0x65400195;
1096 priv
->txbbgain_table
[5].txbb_iq_amplifygain
= 7;
1097 priv
->txbbgain_table
[5].txbbgain_value
=0x5fc0017f;
1098 priv
->txbbgain_table
[6].txbb_iq_amplifygain
= 6;
1099 priv
->txbbgain_table
[6].txbbgain_value
=0x5a400169;
1100 priv
->txbbgain_table
[7].txbb_iq_amplifygain
= 5;
1101 priv
->txbbgain_table
[7].txbbgain_value
=0x55400155;
1102 priv
->txbbgain_table
[8].txbb_iq_amplifygain
= 4;
1103 priv
->txbbgain_table
[8].txbbgain_value
=0x50800142;
1104 priv
->txbbgain_table
[9].txbb_iq_amplifygain
= 3;
1105 priv
->txbbgain_table
[9].txbbgain_value
=0x4c000130;
1106 priv
->txbbgain_table
[10].txbb_iq_amplifygain
= 2;
1107 priv
->txbbgain_table
[10].txbbgain_value
=0x47c0011f;
1108 priv
->txbbgain_table
[11].txbb_iq_amplifygain
= 1;
1109 priv
->txbbgain_table
[11].txbbgain_value
=0x43c0010f;
1110 priv
->txbbgain_table
[12].txbb_iq_amplifygain
= 0;
1111 priv
->txbbgain_table
[12].txbbgain_value
=0x40000100;
1112 priv
->txbbgain_table
[13].txbb_iq_amplifygain
= -1;
1113 priv
->txbbgain_table
[13].txbbgain_value
=0x3c8000f2;
1114 priv
->txbbgain_table
[14].txbb_iq_amplifygain
= -2;
1115 priv
->txbbgain_table
[14].txbbgain_value
=0x390000e4;
1116 priv
->txbbgain_table
[15].txbb_iq_amplifygain
= -3;
1117 priv
->txbbgain_table
[15].txbbgain_value
=0x35c000d7;
1118 priv
->txbbgain_table
[16].txbb_iq_amplifygain
= -4;
1119 priv
->txbbgain_table
[16].txbbgain_value
=0x32c000cb;
1120 priv
->txbbgain_table
[17].txbb_iq_amplifygain
= -5;
1121 priv
->txbbgain_table
[17].txbbgain_value
=0x300000c0;
1122 priv
->txbbgain_table
[18].txbb_iq_amplifygain
= -6;
1123 priv
->txbbgain_table
[18].txbbgain_value
=0x2d4000b5;
1124 priv
->txbbgain_table
[19].txbb_iq_amplifygain
= -7;
1125 priv
->txbbgain_table
[19].txbbgain_value
=0x2ac000ab;
1126 priv
->txbbgain_table
[20].txbb_iq_amplifygain
= -8;
1127 priv
->txbbgain_table
[20].txbbgain_value
=0x288000a2;
1128 priv
->txbbgain_table
[21].txbb_iq_amplifygain
= -9;
1129 priv
->txbbgain_table
[21].txbbgain_value
=0x26000098;
1130 priv
->txbbgain_table
[22].txbb_iq_amplifygain
= -10;
1131 priv
->txbbgain_table
[22].txbbgain_value
=0x24000090;
1132 priv
->txbbgain_table
[23].txbb_iq_amplifygain
= -11;
1133 priv
->txbbgain_table
[23].txbbgain_value
=0x22000088;
1134 priv
->txbbgain_table
[24].txbb_iq_amplifygain
= -12;
1135 priv
->txbbgain_table
[24].txbbgain_value
=0x20000080;
1136 priv
->txbbgain_table
[25].txbb_iq_amplifygain
= -13;
1137 priv
->txbbgain_table
[25].txbbgain_value
=0x1a00006c;
1138 priv
->txbbgain_table
[26].txbb_iq_amplifygain
= -14;
1139 priv
->txbbgain_table
[26].txbbgain_value
=0x1c800072;
1140 priv
->txbbgain_table
[27].txbb_iq_amplifygain
= -15;
1141 priv
->txbbgain_table
[27].txbbgain_value
=0x18000060;
1142 priv
->txbbgain_table
[28].txbb_iq_amplifygain
= -16;
1143 priv
->txbbgain_table
[28].txbbgain_value
=0x19800066;
1144 priv
->txbbgain_table
[29].txbb_iq_amplifygain
= -17;
1145 priv
->txbbgain_table
[29].txbbgain_value
=0x15800056;
1146 priv
->txbbgain_table
[30].txbb_iq_amplifygain
= -18;
1147 priv
->txbbgain_table
[30].txbbgain_value
=0x26c0005b;
1148 priv
->txbbgain_table
[31].txbb_iq_amplifygain
= -19;
1149 priv
->txbbgain_table
[31].txbbgain_value
=0x14400051;
1150 priv
->txbbgain_table
[32].txbb_iq_amplifygain
= -20;
1151 priv
->txbbgain_table
[32].txbbgain_value
=0x24400051;
1152 priv
->txbbgain_table
[33].txbb_iq_amplifygain
= -21;
1153 priv
->txbbgain_table
[33].txbbgain_value
=0x1300004c;
1154 priv
->txbbgain_table
[34].txbb_iq_amplifygain
= -22;
1155 priv
->txbbgain_table
[34].txbbgain_value
=0x12000048;
1156 priv
->txbbgain_table
[35].txbb_iq_amplifygain
= -23;
1157 priv
->txbbgain_table
[35].txbbgain_value
=0x11000044;
1158 priv
->txbbgain_table
[36].txbb_iq_amplifygain
= -24;
1159 priv
->txbbgain_table
[36].txbbgain_value
=0x10000040;
1161 //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
1162 //This Table is for CH1~CH13
1163 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[0] = 0x36;
1164 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[1] = 0x35;
1165 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[2] = 0x2e;
1166 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[3] = 0x25;
1167 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[4] = 0x1c;
1168 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[5] = 0x12;
1169 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[6] = 0x09;
1170 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[7] = 0x04;
1172 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[0] = 0x33;
1173 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[1] = 0x32;
1174 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[2] = 0x2b;
1175 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[3] = 0x23;
1176 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[4] = 0x1a;
1177 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[5] = 0x11;
1178 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[6] = 0x08;
1179 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[7] = 0x04;
1181 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[0] = 0x30;
1182 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[1] = 0x2f;
1183 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[2] = 0x29;
1184 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[3] = 0x21;
1185 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[4] = 0x19;
1186 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[5] = 0x10;
1187 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[6] = 0x08;
1188 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[7] = 0x03;
1190 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[0] = 0x2d;
1191 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[1] = 0x2d;
1192 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[2] = 0x27;
1193 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[3] = 0x1f;
1194 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[4] = 0x18;
1195 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[5] = 0x0f;
1196 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[6] = 0x08;
1197 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[7] = 0x03;
1199 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[0] = 0x2b;
1200 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[1] = 0x2a;
1201 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[2] = 0x25;
1202 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[3] = 0x1e;
1203 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[4] = 0x16;
1204 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[5] = 0x0e;
1205 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[6] = 0x07;
1206 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[7] = 0x03;
1208 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[0] = 0x28;
1209 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[1] = 0x28;
1210 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[2] = 0x22;
1211 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[3] = 0x1c;
1212 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[4] = 0x15;
1213 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[5] = 0x0d;
1214 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[6] = 0x07;
1215 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[7] = 0x03;
1217 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[0] = 0x26;
1218 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[1] = 0x25;
1219 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[2] = 0x21;
1220 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[3] = 0x1b;
1221 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[4] = 0x14;
1222 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[5] = 0x0d;
1223 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[6] = 0x06;
1224 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[7] = 0x03;
1226 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[0] = 0x24;
1227 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[1] = 0x23;
1228 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[2] = 0x1f;
1229 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[3] = 0x19;
1230 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[4] = 0x13;
1231 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[5] = 0x0c;
1232 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[6] = 0x06;
1233 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[7] = 0x03;
1235 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[0] = 0x22;
1236 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[1] = 0x21;
1237 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[2] = 0x1d;
1238 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[3] = 0x18;
1239 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[4] = 0x11;
1240 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[5] = 0x0b;
1241 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[6] = 0x06;
1242 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[7] = 0x02;
1244 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[0] = 0x20;
1245 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[1] = 0x20;
1246 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[2] = 0x1b;
1247 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[3] = 0x16;
1248 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[4] = 0x11;
1249 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[5] = 0x08;
1250 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[6] = 0x05;
1251 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[7] = 0x02;
1253 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[0] = 0x1f;
1254 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[1] = 0x1e;
1255 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[2] = 0x1a;
1256 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[3] = 0x15;
1257 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[4] = 0x10;
1258 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[5] = 0x0a;
1259 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[6] = 0x05;
1260 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[7] = 0x02;
1262 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[0] = 0x1d;
1263 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[1] = 0x1c;
1264 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[2] = 0x18;
1265 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[3] = 0x14;
1266 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[4] = 0x0f;
1267 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[5] = 0x0a;
1268 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[6] = 0x05;
1269 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[7] = 0x02;
1271 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[0] = 0x1b;
1272 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[1] = 0x1a;
1273 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[2] = 0x17;
1274 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[3] = 0x13;
1275 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[4] = 0x0e;
1276 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[5] = 0x09;
1277 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[6] = 0x04;
1278 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[7] = 0x02;
1280 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[0] = 0x1a;
1281 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[1] = 0x19;
1282 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[2] = 0x16;
1283 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[3] = 0x12;
1284 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[4] = 0x0d;
1285 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[5] = 0x09;
1286 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[6] = 0x04;
1287 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[7] = 0x02;
1289 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[0] = 0x18;
1290 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[1] = 0x17;
1291 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[2] = 0x15;
1292 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[3] = 0x11;
1293 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[4] = 0x0c;
1294 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[5] = 0x08;
1295 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[6] = 0x04;
1296 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[7] = 0x02;
1298 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[0] = 0x17;
1299 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[1] = 0x16;
1300 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[2] = 0x13;
1301 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[3] = 0x10;
1302 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[4] = 0x0c;
1303 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[5] = 0x08;
1304 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[6] = 0x04;
1305 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[7] = 0x02;
1307 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[0] = 0x16;
1308 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[1] = 0x15;
1309 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[2] = 0x12;
1310 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[3] = 0x0f;
1311 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[4] = 0x0b;
1312 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[5] = 0x07;
1313 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[6] = 0x04;
1314 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[7] = 0x01;
1316 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[0] = 0x14;
1317 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[1] = 0x14;
1318 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[2] = 0x11;
1319 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[3] = 0x0e;
1320 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[4] = 0x0b;
1321 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[5] = 0x07;
1322 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[6] = 0x03;
1323 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[7] = 0x02;
1325 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[0] = 0x13;
1326 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[1] = 0x13;
1327 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[2] = 0x10;
1328 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[3] = 0x0d;
1329 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[4] = 0x0a;
1330 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[5] = 0x06;
1331 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[6] = 0x03;
1332 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[7] = 0x01;
1334 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[0] = 0x12;
1335 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[1] = 0x12;
1336 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[2] = 0x0f;
1337 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[3] = 0x0c;
1338 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[4] = 0x09;
1339 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[5] = 0x06;
1340 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[6] = 0x03;
1341 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[7] = 0x01;
1343 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[0] = 0x11;
1344 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[1] = 0x11;
1345 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[2] = 0x0f;
1346 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[3] = 0x0c;
1347 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[4] = 0x09;
1348 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[5] = 0x06;
1349 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[6] = 0x03;
1350 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[7] = 0x01;
1352 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[0] = 0x10;
1353 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[1] = 0x10;
1354 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[2] = 0x0e;
1355 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[3] = 0x0b;
1356 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[4] = 0x08;
1357 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[5] = 0x05;
1358 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[6] = 0x03;
1359 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[7] = 0x01;
1361 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[0] = 0x0f;
1362 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[1] = 0x0f;
1363 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[2] = 0x0d;
1364 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[3] = 0x0b;
1365 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[4] = 0x08;
1366 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[5] = 0x05;
1367 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[6] = 0x03;
1368 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[7] = 0x01;
1370 //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
1371 //This Table is for CH14
1372 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[0] = 0x36;
1373 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[1] = 0x35;
1374 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[2] = 0x2e;
1375 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[3] = 0x1b;
1376 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[4] = 0x00;
1377 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[5] = 0x00;
1378 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[6] = 0x00;
1379 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[7] = 0x00;
1381 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[0] = 0x33;
1382 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[1] = 0x32;
1383 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[2] = 0x2b;
1384 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[3] = 0x19;
1385 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[4] = 0x00;
1386 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[5] = 0x00;
1387 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[6] = 0x00;
1388 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[7] = 0x00;
1390 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[0] = 0x30;
1391 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[1] = 0x2f;
1392 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[2] = 0x29;
1393 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[3] = 0x18;
1394 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[4] = 0x00;
1395 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[5] = 0x00;
1396 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[6] = 0x00;
1397 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[7] = 0x00;
1399 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[0] = 0x2d;
1400 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[1] = 0x2d;
1401 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[2] = 0x27;
1402 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[3] = 0x17;
1403 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[4] = 0x00;
1404 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[5] = 0x00;
1405 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[6] = 0x00;
1406 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[7] = 0x00;
1408 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[0] = 0x2b;
1409 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[1] = 0x2a;
1410 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[2] = 0x25;
1411 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[3] = 0x15;
1412 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[4] = 0x00;
1413 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[5] = 0x00;
1414 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[6] = 0x00;
1415 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[7] = 0x00;
1417 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[0] = 0x28;
1418 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[1] = 0x28;
1419 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[2] = 0x22;
1420 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[3] = 0x14;
1421 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[4] = 0x00;
1422 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[5] = 0x00;
1423 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[6] = 0x00;
1424 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[7] = 0x00;
1426 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[0] = 0x26;
1427 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[1] = 0x25;
1428 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[2] = 0x21;
1429 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[3] = 0x13;
1430 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[4] = 0x00;
1431 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[5] = 0x00;
1432 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[6] = 0x00;
1433 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[7] = 0x00;
1435 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[0] = 0x24;
1436 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[1] = 0x23;
1437 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[2] = 0x1f;
1438 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[3] = 0x12;
1439 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[4] = 0x00;
1440 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[5] = 0x00;
1441 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[6] = 0x00;
1442 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[7] = 0x00;
1444 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[0] = 0x22;
1445 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[1] = 0x21;
1446 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[2] = 0x1d;
1447 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[3] = 0x11;
1448 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[4] = 0x00;
1449 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[5] = 0x00;
1450 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[6] = 0x00;
1451 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[7] = 0x00;
1453 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[0] = 0x20;
1454 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[1] = 0x20;
1455 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[2] = 0x1b;
1456 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[3] = 0x10;
1457 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[4] = 0x00;
1458 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[5] = 0x00;
1459 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[6] = 0x00;
1460 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[7] = 0x00;
1462 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[0] = 0x1f;
1463 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[1] = 0x1e;
1464 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[2] = 0x1a;
1465 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[3] = 0x0f;
1466 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[4] = 0x00;
1467 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[5] = 0x00;
1468 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[6] = 0x00;
1469 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[7] = 0x00;
1471 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[0] = 0x1d;
1472 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[1] = 0x1c;
1473 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[2] = 0x18;
1474 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[3] = 0x0e;
1475 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[4] = 0x00;
1476 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[5] = 0x00;
1477 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[6] = 0x00;
1478 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[7] = 0x00;
1480 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[0] = 0x1b;
1481 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[1] = 0x1a;
1482 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[2] = 0x17;
1483 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[3] = 0x0e;
1484 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[4] = 0x00;
1485 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[5] = 0x00;
1486 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[6] = 0x00;
1487 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[7] = 0x00;
1489 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[0] = 0x1a;
1490 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[1] = 0x19;
1491 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[2] = 0x16;
1492 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[3] = 0x0d;
1493 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[4] = 0x00;
1494 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[5] = 0x00;
1495 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[6] = 0x00;
1496 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[7] = 0x00;
1498 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[0] = 0x18;
1499 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[1] = 0x17;
1500 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[2] = 0x15;
1501 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[3] = 0x0c;
1502 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[4] = 0x00;
1503 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[5] = 0x00;
1504 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[6] = 0x00;
1505 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[7] = 0x00;
1507 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[0] = 0x17;
1508 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[1] = 0x16;
1509 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[2] = 0x13;
1510 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[3] = 0x0b;
1511 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[4] = 0x00;
1512 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[5] = 0x00;
1513 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[6] = 0x00;
1514 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[7] = 0x00;
1516 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[0] = 0x16;
1517 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[1] = 0x15;
1518 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[2] = 0x12;
1519 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[3] = 0x0b;
1520 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[4] = 0x00;
1521 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[5] = 0x00;
1522 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[6] = 0x00;
1523 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[7] = 0x00;
1525 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[0] = 0x14;
1526 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[1] = 0x14;
1527 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[2] = 0x11;
1528 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[3] = 0x0a;
1529 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[4] = 0x00;
1530 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[5] = 0x00;
1531 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[6] = 0x00;
1532 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[7] = 0x00;
1534 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[0] = 0x13;
1535 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[1] = 0x13;
1536 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[2] = 0x10;
1537 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[3] = 0x0a;
1538 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[4] = 0x00;
1539 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[5] = 0x00;
1540 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[6] = 0x00;
1541 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[7] = 0x00;
1543 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[0] = 0x12;
1544 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[1] = 0x12;
1545 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[2] = 0x0f;
1546 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[3] = 0x09;
1547 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[4] = 0x00;
1548 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[5] = 0x00;
1549 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[6] = 0x00;
1550 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[7] = 0x00;
1552 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[0] = 0x11;
1553 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[1] = 0x11;
1554 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[2] = 0x0f;
1555 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[3] = 0x09;
1556 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[4] = 0x00;
1557 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[5] = 0x00;
1558 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[6] = 0x00;
1559 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[7] = 0x00;
1561 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[0] = 0x10;
1562 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[1] = 0x10;
1563 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[2] = 0x0e;
1564 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[3] = 0x08;
1565 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[4] = 0x00;
1566 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[5] = 0x00;
1567 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[6] = 0x00;
1568 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[7] = 0x00;
1570 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[0] = 0x0f;
1571 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[1] = 0x0f;
1572 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[2] = 0x0d;
1573 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[3] = 0x08;
1574 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[4] = 0x00;
1575 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[5] = 0x00;
1576 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[6] = 0x00;
1577 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[7] = 0x00;
1579 priv
->btxpower_tracking
= TRUE
;
1580 priv
->txpower_count
= 0;
1581 priv
->btxpower_trackingInit
= FALSE
;
1585 static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device
*dev
)
1587 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1589 // Tx Power tracking by Theremal Meter require Firmware R/W 3-wire. This mechanism
1590 // can be enabled only when Firmware R/W 3-wire is enabled. Otherwise, frequent r/w
1591 // 3-wire by driver cause RF goes into wrong state.
1592 if(priv
->ieee80211
->FwRWRF
)
1593 priv
->btxpower_tracking
= TRUE
;
1595 priv
->btxpower_tracking
= FALSE
;
1596 priv
->txpower_count
= 0;
1597 priv
->btxpower_trackingInit
= FALSE
;
1601 void dm_initialize_txpower_tracking(struct net_device
*dev
)
1604 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1607 dm_InitializeTXPowerTracking_TSSI(dev
);
1609 //if(priv->bDcut == TRUE)
1610 if(priv
->IC_Cut
>= IC_VersionCut_D
)
1611 dm_InitializeTXPowerTracking_TSSI(dev
);
1613 dm_InitializeTXPowerTracking_ThermalMeter(dev
);
1615 } // dm_InitializeTXPowerTracking
1618 static void dm_CheckTXPowerTracking_TSSI(struct net_device
*dev
)
1620 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1621 static u32 tx_power_track_counter
= 0;
1622 RT_TRACE(COMP_POWER_TRACKING
,"%s()\n",__FUNCTION__
);
1623 if(read_nic_byte(dev
, 0x11e) ==1)
1625 if(!priv
->btxpower_tracking
)
1627 tx_power_track_counter
++;
1630 if(tx_power_track_counter
> 90)
1632 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1633 queue_delayed_work(priv
->priv_wq
,&priv
->txpower_tracking_wq
,0);
1635 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
1636 schedule_task(&priv
->txpower_tracking_wq
);
1638 queue_work(priv
->priv_wq
,&priv
->txpower_tracking_wq
);
1641 tx_power_track_counter
=0;
1647 static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device
*dev
)
1649 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1650 static u8 TM_Trigger
=0;
1656 tmpRegA
= PHY_QueryRFReg(Adapter
, RF90_PATH_A
, 0x12, 0x078); // 0x12: RF Reg[10:7]
1657 PHY_SetRFReg(Adapter
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4d);
1659 PHY_SetRFReg(Adapter
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4f);
1662 DbgPrint("Trigger and readback ThermalMeter, write RF reg0x2 = 0x4d to 0x4f for 50 times\n");
1664 //DbgPrint("dm_CheckTXPowerTracking() \n");
1665 if(!priv
->btxpower_tracking
)
1669 if(priv
->txpower_count
<= 2)
1671 priv
->txpower_count
++;
1678 //Attention!! You have to wirte all 12bits data to RF, or it may cause RF to crash
1679 //actually write reg0x02 bit1=0, then bit1=1.
1680 //DbgPrint("Trigger ThermalMeter, write RF reg0x2 = 0x4d to 0x4f\n");
1681 rtl8192_phy_SetRFReg(dev
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4d);
1682 rtl8192_phy_SetRFReg(dev
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4f);
1683 rtl8192_phy_SetRFReg(dev
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4d);
1684 rtl8192_phy_SetRFReg(dev
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4f);
1690 //DbgPrint("Schedule TxPowerTrackingWorkItem\n");
1691 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1692 queue_delayed_work(priv
->priv_wq
,&priv
->txpower_tracking_wq
,0);
1694 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
1695 schedule_task(&priv
->txpower_tracking_wq
);
1697 queue_work(priv
->priv_wq
,&priv
->txpower_tracking_wq
);
1706 static void dm_check_txpower_tracking(struct net_device
*dev
)
1709 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1710 //static u32 tx_power_track_counter = 0;
1713 dm_CheckTXPowerTracking_TSSI(dev
);
1715 //if(priv->bDcut == TRUE)
1716 if(priv
->IC_Cut
>= IC_VersionCut_D
)
1717 dm_CheckTXPowerTracking_TSSI(dev
);
1719 dm_CheckTXPowerTracking_ThermalMeter(dev
);
1722 } // dm_CheckTXPowerTracking
1725 static void dm_CCKTxPowerAdjust_TSSI(struct net_device
*dev
, bool bInCH14
)
1728 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1733 TempVal
= (u32
)(priv
->cck_txbbgain_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[0] +
1734 (priv
->cck_txbbgain_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[1]<<8)) ;
1736 rtl8192_setBBreg(dev
, rCCK0_TxFilter1
,bMaskHWord
, TempVal
);
1737 //Write 0xa24 ~ 0xa27
1739 TempVal
= (u32
)(priv
->cck_txbbgain_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[2] +
1740 (priv
->cck_txbbgain_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[3]<<8) +
1741 (priv
->cck_txbbgain_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[4]<<16 )+
1742 (priv
->cck_txbbgain_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[5]<<24));
1743 rtl8192_setBBreg(dev
, rCCK0_TxFilter2
,bMaskDWord
, TempVal
);
1746 TempVal
= (u32
)(priv
->cck_txbbgain_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[6] +
1747 (priv
->cck_txbbgain_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[7]<<8)) ;
1749 rtl8192_setBBreg(dev
, rCCK0_DebugPort
,bMaskLWord
, TempVal
);
1753 TempVal
= (u32
)(priv
->cck_txbbgain_ch14_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[0] +
1754 (priv
->cck_txbbgain_ch14_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[1]<<8)) ;
1756 rtl8192_setBBreg(dev
, rCCK0_TxFilter1
,bMaskHWord
, TempVal
);
1757 //Write 0xa24 ~ 0xa27
1759 TempVal
= (u32
)(priv
->cck_txbbgain_ch14_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[2] +
1760 (priv
->cck_txbbgain_ch14_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[3]<<8) +
1761 (priv
->cck_txbbgain_ch14_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[4]<<16 )+
1762 (priv
->cck_txbbgain_ch14_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[5]<<24));
1763 rtl8192_setBBreg(dev
, rCCK0_TxFilter2
,bMaskDWord
, TempVal
);
1766 TempVal
= (u32
)(priv
->cck_txbbgain_ch14_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[6] +
1767 (priv
->cck_txbbgain_ch14_table
[(u8
)(priv
->CCKPresentAttentuation
)].ccktxbb_valuearray
[7]<<8)) ;
1769 rtl8192_setBBreg(dev
, rCCK0_DebugPort
,bMaskLWord
, TempVal
);
1775 static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device
*dev
, bool bInCH14
)
1778 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1784 TempVal
= CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][0] +
1785 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][1]<<8) ;
1786 rtl8192_setBBreg(dev
, rCCK0_TxFilter1
, bMaskHWord
, TempVal
);
1787 RT_TRACE(COMP_POWER_TRACKING
, "CCK not chnl 14, reg 0x%x = 0x%x\n",
1788 rCCK0_TxFilter1
, TempVal
);
1789 //Write 0xa24 ~ 0xa27
1791 TempVal
= CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][2] +
1792 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][3]<<8) +
1793 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][4]<<16 )+
1794 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][5]<<24);
1795 rtl8192_setBBreg(dev
, rCCK0_TxFilter2
, bMaskDWord
, TempVal
);
1796 RT_TRACE(COMP_POWER_TRACKING
, "CCK not chnl 14, reg 0x%x = 0x%x\n",
1797 rCCK0_TxFilter2
, TempVal
);
1800 TempVal
= CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][6] +
1801 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][7]<<8) ;
1803 rtl8192_setBBreg(dev
, rCCK0_DebugPort
, bMaskLWord
, TempVal
);
1804 RT_TRACE(COMP_POWER_TRACKING
, "CCK not chnl 14, reg 0x%x = 0x%x\n",
1805 rCCK0_DebugPort
, TempVal
);
1809 // priv->CCKTxPowerAdjustCntNotCh14++; //cosa add for debug.
1811 TempVal
= CCKSwingTable_Ch14
[priv
->CCK_index
][0] +
1812 (CCKSwingTable_Ch14
[priv
->CCK_index
][1]<<8) ;
1814 rtl8192_setBBreg(dev
, rCCK0_TxFilter1
, bMaskHWord
, TempVal
);
1815 RT_TRACE(COMP_POWER_TRACKING
, "CCK chnl 14, reg 0x%x = 0x%x\n",
1816 rCCK0_TxFilter1
, TempVal
);
1817 //Write 0xa24 ~ 0xa27
1819 TempVal
= CCKSwingTable_Ch14
[priv
->CCK_index
][2] +
1820 (CCKSwingTable_Ch14
[priv
->CCK_index
][3]<<8) +
1821 (CCKSwingTable_Ch14
[priv
->CCK_index
][4]<<16 )+
1822 (CCKSwingTable_Ch14
[priv
->CCK_index
][5]<<24);
1823 rtl8192_setBBreg(dev
, rCCK0_TxFilter2
, bMaskDWord
, TempVal
);
1824 RT_TRACE(COMP_POWER_TRACKING
, "CCK chnl 14, reg 0x%x = 0x%x\n",
1825 rCCK0_TxFilter2
, TempVal
);
1828 TempVal
= CCKSwingTable_Ch14
[priv
->CCK_index
][6] +
1829 (CCKSwingTable_Ch14
[priv
->CCK_index
][7]<<8) ;
1831 rtl8192_setBBreg(dev
, rCCK0_DebugPort
, bMaskLWord
, TempVal
);
1832 RT_TRACE(COMP_POWER_TRACKING
,"CCK chnl 14, reg 0x%x = 0x%x\n",
1833 rCCK0_DebugPort
, TempVal
);
1839 void dm_cck_txpower_adjust(struct net_device
*dev
, bool binch14
)
1840 { // dm_CCKTxPowerAdjust
1842 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1845 dm_CCKTxPowerAdjust_TSSI(dev
, binch14
);
1847 //if(priv->bDcut == TRUE)
1848 if(priv
->IC_Cut
>= IC_VersionCut_D
)
1849 dm_CCKTxPowerAdjust_TSSI(dev
, binch14
);
1851 dm_CCKTxPowerAdjust_ThermalMeter(dev
, binch14
);
1857 static void dm_txpower_reset_recovery(
1858 struct net_device
*dev
1861 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1863 RT_TRACE(COMP_POWER_TRACKING
, "Start Reset Recovery ==>\n");
1864 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfa_txpowertrackingindex
].txbbgain_value
);
1865 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: Fill in 0xc80 is %08x\n",priv
->txbbgain_table
[priv
->rfa_txpowertrackingindex
].txbbgain_value
);
1866 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",priv
->rfa_txpowertrackingindex
);
1867 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n",priv
->txbbgain_table
[priv
->rfa_txpowertrackingindex
].txbb_iq_amplifygain
);
1868 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: CCK Attenuation is %d dB\n",priv
->CCKPresentAttentuation
);
1869 dm_cck_txpower_adjust(dev
,priv
->bcck_in_ch14
);
1871 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfc_txpowertrackingindex
].txbbgain_value
);
1872 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: Fill in 0xc90 is %08x\n",priv
->txbbgain_table
[priv
->rfc_txpowertrackingindex
].txbbgain_value
);
1873 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",priv
->rfc_txpowertrackingindex
);
1874 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n",priv
->txbbgain_table
[priv
->rfc_txpowertrackingindex
].txbb_iq_amplifygain
);
1876 } // dm_TXPowerResetRecovery
1878 void dm_restore_dynamic_mechanism_state(struct net_device
*dev
)
1880 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1881 u32 reg_ratr
= priv
->rate_adaptive
.last_ratr
;
1885 RT_TRACE(COMP_RATE
, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n");
1890 // Restore previous state for rate adaptive
1892 if(priv
->rate_adaptive
.rate_adaptive_disabled
)
1894 // TODO: Only 11n mode is implemented currently,
1895 if( !(priv
->ieee80211
->mode
==WIRELESS_MODE_N_24G
||
1896 priv
->ieee80211
->mode
==WIRELESS_MODE_N_5G
))
1899 /* 2007/11/15 MH Copy from 8190PCI. */
1901 ratr_value
= reg_ratr
;
1902 if(priv
->rf_type
== RF_1T2R
) // 1T2R, Spatial Stream 2 should be disabled
1904 ratr_value
&=~ (RATE_ALL_OFDM_2SS
);
1905 //DbgPrint("HW_VAR_TATR_0 from 0x%x ==> 0x%x\n", ((pu4Byte)(val))[0], ratr_value);
1907 //DbgPrint("set HW_VAR_TATR_0 = 0x%x\n", ratr_value);
1908 //cosa PlatformEFIOWrite4Byte(Adapter, RATR0, ((pu4Byte)(val))[0]);
1909 write_nic_dword(dev
, RATR0
, ratr_value
);
1910 write_nic_byte(dev
, UFWP
, 1);
1911 #if 0 // Disable old code.
1914 index
= (u1Byte
)((((pu4Byte
)(val
))[0]) >> 28);
1915 input_value
= (((pu4Byte
)(val
))[0]) & 0x0fffffff;
1916 // TODO: Correct it. Emily 2007.01.11
1917 PlatformEFIOWrite4Byte(Adapter
, RATR0
+index
*4, input_value
);
1920 //Resore TX Power Tracking Index
1921 if(priv
->btxpower_trackingInit
&& priv
->btxpower_tracking
){
1922 dm_txpower_reset_recovery(dev
);
1926 //Restore BB Initial Gain
1928 dm_bb_initialgain_restore(dev
);
1930 } // DM_RestoreDynamicMechanismState
1932 static void dm_bb_initialgain_restore(struct net_device
*dev
)
1934 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1935 u32 bit_mask
= 0x7f; //Bit0~ Bit6
1937 if(dm_digtable
.dig_algorithm
== DIG_ALGO_BY_RSSI
)
1940 //Disable Initial Gain
1941 //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);
1942 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x8); // Only clear byte 1 and rewrite.
1943 rtl8192_setBBreg(dev
, rOFDM0_XAAGCCore1
, bit_mask
, (u32
)priv
->initgain_backup
.xaagccore1
);
1944 rtl8192_setBBreg(dev
, rOFDM0_XBAGCCore1
, bit_mask
, (u32
)priv
->initgain_backup
.xbagccore1
);
1945 rtl8192_setBBreg(dev
, rOFDM0_XCAGCCore1
, bit_mask
, (u32
)priv
->initgain_backup
.xcagccore1
);
1946 rtl8192_setBBreg(dev
, rOFDM0_XDAGCCore1
, bit_mask
, (u32
)priv
->initgain_backup
.xdagccore1
);
1947 bit_mask
= bMaskByte2
;
1948 rtl8192_setBBreg(dev
, rCCK0_CCA
, bit_mask
, (u32
)priv
->initgain_backup
.cca
);
1950 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xc50 is %x\n",priv
->initgain_backup
.xaagccore1
);
1951 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xc58 is %x\n",priv
->initgain_backup
.xbagccore1
);
1952 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xc60 is %x\n",priv
->initgain_backup
.xcagccore1
);
1953 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xc68 is %x\n",priv
->initgain_backup
.xdagccore1
);
1954 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xa0a is %x\n",priv
->initgain_backup
.cca
);
1955 //Enable Initial Gain
1956 //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x100);
1957 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x1); // Only clear byte 1 and rewrite.
1959 } // dm_BBInitialGainRestore
1962 void dm_backup_dynamic_mechanism_state(struct net_device
*dev
)
1964 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1966 // Fsync to avoid reset
1967 priv
->bswitch_fsync
= false;
1968 priv
->bfsync_processing
= false;
1969 //Backup BB InitialGain
1970 dm_bb_initialgain_backup(dev
);
1972 } // DM_BackupDynamicMechanismState
1975 static void dm_bb_initialgain_backup(struct net_device
*dev
)
1977 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1978 u32 bit_mask
= bMaskByte0
; //Bit0~ Bit6
1980 if(dm_digtable
.dig_algorithm
== DIG_ALGO_BY_RSSI
)
1983 //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);
1984 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x8); // Only clear byte 1 and rewrite.
1985 priv
->initgain_backup
.xaagccore1
= (u8
)rtl8192_QueryBBReg(dev
, rOFDM0_XAAGCCore1
, bit_mask
);
1986 priv
->initgain_backup
.xbagccore1
= (u8
)rtl8192_QueryBBReg(dev
, rOFDM0_XBAGCCore1
, bit_mask
);
1987 priv
->initgain_backup
.xcagccore1
= (u8
)rtl8192_QueryBBReg(dev
, rOFDM0_XCAGCCore1
, bit_mask
);
1988 priv
->initgain_backup
.xdagccore1
= (u8
)rtl8192_QueryBBReg(dev
, rOFDM0_XDAGCCore1
, bit_mask
);
1989 bit_mask
= bMaskByte2
;
1990 priv
->initgain_backup
.cca
= (u8
)rtl8192_QueryBBReg(dev
, rCCK0_CCA
, bit_mask
);
1992 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xc50 is %x\n",priv
->initgain_backup
.xaagccore1
);
1993 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xc58 is %x\n",priv
->initgain_backup
.xbagccore1
);
1994 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xc60 is %x\n",priv
->initgain_backup
.xcagccore1
);
1995 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xc68 is %x\n",priv
->initgain_backup
.xdagccore1
);
1996 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xa0a is %x\n",priv
->initgain_backup
.cca
);
1998 } // dm_BBInitialGainBakcup
2001 /*-----------------------------------------------------------------------------
2002 * Function: dm_change_dynamic_initgain_thresh()
2014 * 05/29/2008 amy Create Version 0 porting from windows code.
2016 *---------------------------------------------------------------------------*/
2017 void dm_change_dynamic_initgain_thresh(struct net_device
*dev
, u32 dm_type
, u32 dm_value
)
2019 if (dm_type
== DIG_TYPE_THRESH_HIGH
)
2021 dm_digtable
.rssi_high_thresh
= dm_value
;
2023 else if (dm_type
== DIG_TYPE_THRESH_LOW
)
2025 dm_digtable
.rssi_low_thresh
= dm_value
;
2027 else if (dm_type
== DIG_TYPE_THRESH_HIGHPWR_HIGH
)
2029 dm_digtable
.rssi_high_power_highthresh
= dm_value
;
2031 else if (dm_type
== DIG_TYPE_THRESH_HIGHPWR_HIGH
)
2033 dm_digtable
.rssi_high_power_highthresh
= dm_value
;
2035 else if (dm_type
== DIG_TYPE_ENABLE
)
2037 dm_digtable
.dig_state
= DM_STA_DIG_MAX
;
2038 dm_digtable
.dig_enable_flag
= true;
2040 else if (dm_type
== DIG_TYPE_DISABLE
)
2042 dm_digtable
.dig_state
= DM_STA_DIG_MAX
;
2043 dm_digtable
.dig_enable_flag
= false;
2045 else if (dm_type
== DIG_TYPE_DBG_MODE
)
2047 if(dm_value
>= DM_DBG_MAX
)
2048 dm_value
= DM_DBG_OFF
;
2049 dm_digtable
.dbg_mode
= (u8
)dm_value
;
2051 else if (dm_type
== DIG_TYPE_RSSI
)
2055 dm_digtable
.rssi_val
= (long)dm_value
;
2057 else if (dm_type
== DIG_TYPE_ALGORITHM
)
2059 if (dm_value
>= DIG_ALGO_MAX
)
2060 dm_value
= DIG_ALGO_BY_FALSE_ALARM
;
2061 if(dm_digtable
.dig_algorithm
!= (u8
)dm_value
)
2062 dm_digtable
.dig_algorithm_switch
= 1;
2063 dm_digtable
.dig_algorithm
= (u8
)dm_value
;
2065 else if (dm_type
== DIG_TYPE_BACKOFF
)
2069 dm_digtable
.backoff_val
= (u8
)dm_value
;
2071 else if(dm_type
== DIG_TYPE_RX_GAIN_MIN
)
2075 dm_digtable
.rx_gain_range_min
= (u8
)dm_value
;
2077 else if(dm_type
== DIG_TYPE_RX_GAIN_MAX
)
2081 dm_digtable
.rx_gain_range_max
= (u8
)dm_value
;
2083 } /* DM_ChangeDynamicInitGainThresh */
2085 static void dm_change_fsync_setting(struct net_device
*dev
, s32 DM_Type
, s32 DM_Value
)
2087 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2089 if (DM_Type
== 0) // monitor 0xc38 register
2093 priv
->framesyncMonitor
= (u8
)DM_Value
;
2094 //DbgPrint("pHalData->framesyncMonitor = %d", pHalData->framesyncMonitor);
2098 static void dm_change_rxpath_selection_setting(struct net_device
*dev
, s32 DM_Type
, s32 DM_Value
)
2100 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2101 prate_adaptive pRA
= (prate_adaptive
)&(priv
->rate_adaptive
);
2108 DM_RxPathSelTable
.Enable
= (u8
)DM_Value
;
2110 else if(DM_Type
== 1)
2114 DM_RxPathSelTable
.DbgMode
= (u8
)DM_Value
;
2116 else if(DM_Type
== 2)
2120 DM_RxPathSelTable
.SS_TH_low
= (u8
)DM_Value
;
2122 else if(DM_Type
== 3)
2126 DM_RxPathSelTable
.diff_TH
= (u8
)DM_Value
;
2128 else if(DM_Type
== 4)
2130 if(DM_Value
>= CCK_Rx_Version_MAX
)
2131 DM_Value
= CCK_Rx_Version_1
;
2132 DM_RxPathSelTable
.cck_method
= (u8
)DM_Value
;
2134 else if(DM_Type
== 10)
2138 DM_RxPathSelTable
.rf_rssi
[0] = (u8
)DM_Value
;
2140 else if(DM_Type
== 11)
2144 DM_RxPathSelTable
.rf_rssi
[1] = (u8
)DM_Value
;
2146 else if(DM_Type
== 12)
2150 DM_RxPathSelTable
.rf_rssi
[2] = (u8
)DM_Value
;
2152 else if(DM_Type
== 13)
2156 DM_RxPathSelTable
.rf_rssi
[3] = (u8
)DM_Value
;
2158 else if(DM_Type
== 20)
2162 pRA
->ping_rssi_enable
= (u8
)DM_Value
;
2164 else if(DM_Type
== 21)
2168 pRA
->ping_rssi_thresh_for_ra
= DM_Value
;
2173 void dm_force_tx_fw_info(struct net_device
*dev
, u32 force_type
, u32 force_value
)
2175 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2177 if (force_type
== 0) // don't force TxSC
2179 //DbgPrint("Set Force SubCarrier Off\n");
2180 priv
->tx_fwinfo_force_subcarriermode
= 0;
2182 else if(force_type
== 1) //force
2184 //DbgPrint("Set Force SubCarrier On\n");
2185 priv
->tx_fwinfo_force_subcarriermode
= 1;
2188 priv
->tx_fwinfo_force_subcarrierval
= (u8
)force_value
;
2193 /*-----------------------------------------------------------------------------
2194 * Function: dm_dig_init()
2196 * Overview: Set DIG scheme init value.
2206 * 05/15/2008 amy Create Version 0 porting from windows code.
2208 *---------------------------------------------------------------------------*/
2209 static void dm_dig_init(struct net_device
*dev
)
2211 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2212 /* 2007/10/05 MH Disable DIG scheme now. Not tested. */
2213 dm_digtable
.dig_enable_flag
= true;
2214 dm_digtable
.dig_algorithm
= DIG_ALGO_BY_RSSI
;
2215 dm_digtable
.dbg_mode
= DM_DBG_OFF
; //off=by real rssi value, on=by DM_DigTable.Rssi_val for new dig
2216 dm_digtable
.dig_algorithm_switch
= 0;
2218 /* 2007/10/04 MH Define init gain threshol. */
2219 dm_digtable
.dig_state
= DM_STA_DIG_MAX
;
2220 dm_digtable
.dig_highpwr_state
= DM_STA_DIG_MAX
;
2221 dm_digtable
.initialgain_lowerbound_state
= false;
2223 dm_digtable
.rssi_low_thresh
= DM_DIG_THRESH_LOW
;
2224 dm_digtable
.rssi_high_thresh
= DM_DIG_THRESH_HIGH
;
2226 dm_digtable
.rssi_high_power_lowthresh
= DM_DIG_HIGH_PWR_THRESH_LOW
;
2227 dm_digtable
.rssi_high_power_highthresh
= DM_DIG_HIGH_PWR_THRESH_HIGH
;
2229 dm_digtable
.rssi_val
= 50; //for new dig debug rssi value
2230 dm_digtable
.backoff_val
= DM_DIG_BACKOFF
;
2231 dm_digtable
.rx_gain_range_max
= DM_DIG_MAX
;
2232 if(priv
->CustomerID
== RT_CID_819x_Netcore
)
2233 dm_digtable
.rx_gain_range_min
= DM_DIG_MIN_Netcore
;
2235 dm_digtable
.rx_gain_range_min
= DM_DIG_MIN
;
2240 /*-----------------------------------------------------------------------------
2241 * Function: dm_ctrl_initgain_byrssi()
2243 * Overview: Driver must monitor RSSI and notify firmware to change initial
2244 * gain according to different threshold. BB team provide the
2245 * suggested solution.
2247 * Input: struct net_device *dev
2255 * 05/27/2008 amy Create Version 0 porting from windows code.
2256 *---------------------------------------------------------------------------*/
2257 static void dm_ctrl_initgain_byrssi(struct net_device
*dev
)
2260 if (dm_digtable
.dig_enable_flag
== false)
2263 if(dm_digtable
.dig_algorithm
== DIG_ALGO_BY_FALSE_ALARM
)
2264 dm_ctrl_initgain_byrssi_by_fwfalse_alarm(dev
);
2265 else if(dm_digtable
.dig_algorithm
== DIG_ALGO_BY_RSSI
)
2266 dm_ctrl_initgain_byrssi_by_driverrssi(dev
);
2272 static void dm_ctrl_initgain_byrssi_by_driverrssi(
2273 struct net_device
*dev
)
2275 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2279 if (dm_digtable
.dig_enable_flag
== false)
2282 //DbgPrint("Dig by Sw Rssi \n");
2283 if(dm_digtable
.dig_algorithm_switch
) // if swithed algorithm, we have to disable FW Dig.
2285 if(fw_dig
<= 3) // execute several times to make sure the FW Dig is disabled
2288 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x8); // Only clear byte 1 and rewrite.
2290 dm_digtable
.dig_state
= DM_STA_DIG_OFF
; //fw dig off.
2293 if(priv
->ieee80211
->state
== IEEE80211_LINKED
)
2294 dm_digtable
.cur_connect_state
= DIG_CONNECT
;
2296 dm_digtable
.cur_connect_state
= DIG_DISCONNECT
;
2298 //DbgPrint("DM_DigTable.PreConnectState = %d, DM_DigTable.CurConnectState = %d \n",
2299 //DM_DigTable.PreConnectState, DM_DigTable.CurConnectState);
2301 if(dm_digtable
.dbg_mode
== DM_DBG_OFF
)
2302 dm_digtable
.rssi_val
= priv
->undecorated_smoothed_pwdb
;
2303 //DbgPrint("DM_DigTable.Rssi_val = %d \n", DM_DigTable.Rssi_val);
2304 dm_initial_gain(dev
);
2307 if(dm_digtable
.dig_algorithm_switch
)
2308 dm_digtable
.dig_algorithm_switch
= 0;
2309 dm_digtable
.pre_connect_state
= dm_digtable
.cur_connect_state
;
2311 } /* dm_CtrlInitGainByRssi */
2313 static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
2314 struct net_device
*dev
)
2316 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2317 static u32 reset_cnt
= 0;
2320 if (dm_digtable
.dig_enable_flag
== false)
2323 if(dm_digtable
.dig_algorithm_switch
)
2325 dm_digtable
.dig_state
= DM_STA_DIG_MAX
;
2328 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x1); // Only clear byte 1 and rewrite.
2329 dm_digtable
.dig_algorithm_switch
= 0;
2332 if (priv
->ieee80211
->state
!= IEEE80211_LINKED
)
2335 // For smooth, we can not change DIG state.
2336 if ((priv
->undecorated_smoothed_pwdb
> dm_digtable
.rssi_low_thresh
) &&
2337 (priv
->undecorated_smoothed_pwdb
< dm_digtable
.rssi_high_thresh
))
2341 //DbgPrint("Dig by Fw False Alarm\n");
2342 //if (DM_DigTable.Dig_State == DM_STA_DIG_OFF)
2343 /*DbgPrint("DIG Check\n\r RSSI=%d LOW=%d HIGH=%d STATE=%d",
2344 pHalData->UndecoratedSmoothedPWDB, DM_DigTable.RssiLowThresh,
2345 DM_DigTable.RssiHighThresh, DM_DigTable.Dig_State);*/
2346 /* 1. When RSSI decrease, We have to judge if it is smaller than a treshold
2347 and then execute below step. */
2348 if ((priv
->undecorated_smoothed_pwdb
<= dm_digtable
.rssi_low_thresh
))
2350 /* 2008/02/05 MH When we execute silent reset, the DIG PHY parameters
2351 will be reset to init value. We must prevent the condition. */
2352 if (dm_digtable
.dig_state
== DM_STA_DIG_OFF
&&
2353 (priv
->reset_count
== reset_cnt
))
2359 reset_cnt
= priv
->reset_count
;
2362 // If DIG is off, DIG high power state must reset.
2363 dm_digtable
.dig_highpwr_state
= DM_STA_DIG_MAX
;
2364 dm_digtable
.dig_state
= DM_STA_DIG_OFF
;
2367 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x8); // Only clear byte 1 and rewrite.
2369 // 1.2 Set initial gain.
2370 write_nic_byte(dev
, rOFDM0_XAAGCCore1
, 0x17);
2371 write_nic_byte(dev
, rOFDM0_XBAGCCore1
, 0x17);
2372 write_nic_byte(dev
, rOFDM0_XCAGCCore1
, 0x17);
2373 write_nic_byte(dev
, rOFDM0_XDAGCCore1
, 0x17);
2375 // 1.3 Lower PD_TH for OFDM.
2376 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)
2378 /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
2379 // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2381 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x40);
2383 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x00);
2385 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2386 write_nic_byte(pAdapter, rOFDM0_RxDetector1, 0x40);
2388 //else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
2392 //PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x40);
2395 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x42);
2397 // 1.4 Lower CS ratio for CCK.
2398 write_nic_byte(dev
, 0xa0a, 0x08);
2400 // 1.5 Higher EDCCA.
2401 //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x325);
2406 /* 2. When RSSI increase, We have to judge if it is larger than a treshold
2407 and then execute below step. */
2408 if ((priv
->undecorated_smoothed_pwdb
>= dm_digtable
.rssi_high_thresh
) )
2412 if (dm_digtable
.dig_state
== DM_STA_DIG_ON
&&
2413 (priv
->reset_count
== reset_cnt
))
2415 dm_ctrl_initgain_byrssi_highpwr(dev
);
2420 if (priv
->reset_count
!= reset_cnt
)
2423 reset_cnt
= priv
->reset_count
;
2426 dm_digtable
.dig_state
= DM_STA_DIG_ON
;
2427 //DbgPrint("DIG ON\n\r");
2429 // 2.1 Set initial gain.
2430 // 2008/02/26 MH SD3-Jerry suggest to prevent dirty environment.
2431 if (reset_flag
== 1)
2433 write_nic_byte(dev
, rOFDM0_XAAGCCore1
, 0x2c);
2434 write_nic_byte(dev
, rOFDM0_XBAGCCore1
, 0x2c);
2435 write_nic_byte(dev
, rOFDM0_XCAGCCore1
, 0x2c);
2436 write_nic_byte(dev
, rOFDM0_XDAGCCore1
, 0x2c);
2440 write_nic_byte(dev
, rOFDM0_XAAGCCore1
, 0x20);
2441 write_nic_byte(dev
, rOFDM0_XBAGCCore1
, 0x20);
2442 write_nic_byte(dev
, rOFDM0_XCAGCCore1
, 0x20);
2443 write_nic_byte(dev
, rOFDM0_XDAGCCore1
, 0x20);
2446 // 2.2 Higher PD_TH for OFDM.
2447 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)
2449 /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
2450 // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2452 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x42);
2454 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x20);
2457 else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2458 write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2460 //else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
2463 //PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x42);
2466 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x44);
2468 // 2.3 Higher CS ratio for CCK.
2469 write_nic_byte(dev
, 0xa0a, 0xcd);
2472 /* 2008/01/11 MH 90/92 series are the same. */
2473 //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x346);
2476 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x1); // Only clear byte 1 and rewrite.
2480 dm_ctrl_initgain_byrssi_highpwr(dev
);
2482 } /* dm_CtrlInitGainByRssi */
2485 /*-----------------------------------------------------------------------------
2486 * Function: dm_ctrl_initgain_byrssi_highpwr()
2498 * 05/28/2008 amy Create Version 0 porting from windows code.
2500 *---------------------------------------------------------------------------*/
2501 static void dm_ctrl_initgain_byrssi_highpwr(
2502 struct net_device
* dev
)
2504 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2505 static u32 reset_cnt_highpwr
= 0;
2507 // For smooth, we can not change high power DIG state in the range.
2508 if ((priv
->undecorated_smoothed_pwdb
> dm_digtable
.rssi_high_power_lowthresh
) &&
2509 (priv
->undecorated_smoothed_pwdb
< dm_digtable
.rssi_high_power_highthresh
))
2514 /* 3. When RSSI >75% or <70%, it is a high power issue. We have to judge if
2515 it is larger than a treshold and then execute below step. */
2516 // 2008/02/05 MH SD3-Jerry Modify PD_TH for high power issue.
2517 if (priv
->undecorated_smoothed_pwdb
>= dm_digtable
.rssi_high_power_highthresh
)
2519 if (dm_digtable
.dig_highpwr_state
== DM_STA_DIG_ON
&&
2520 (priv
->reset_count
== reset_cnt_highpwr
))
2523 dm_digtable
.dig_highpwr_state
= DM_STA_DIG_ON
;
2525 // 3.1 Higher PD_TH for OFDM for high power state.
2526 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)
2529 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x41);
2531 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x10);
2534 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2535 write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
2540 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x43);
2544 if (dm_digtable
.dig_highpwr_state
== DM_STA_DIG_OFF
&&
2545 (priv
->reset_count
== reset_cnt_highpwr
))
2548 dm_digtable
.dig_highpwr_state
= DM_STA_DIG_OFF
;
2550 if (priv
->undecorated_smoothed_pwdb
< dm_digtable
.rssi_high_power_lowthresh
&&
2551 priv
->undecorated_smoothed_pwdb
>= dm_digtable
.rssi_high_thresh
)
2553 // 3.2 Recover PD_TH for OFDM for normal power region.
2554 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)
2557 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x42);
2559 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x20);
2561 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2562 write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2567 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x44);
2571 reset_cnt_highpwr
= priv
->reset_count
;
2573 } /* dm_CtrlInitGainByRssiHighPwr */
2576 static void dm_initial_gain(
2577 struct net_device
* dev
)
2579 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2581 static u8 initialized
=0, force_write
=0;
2582 static u32 reset_cnt
=0;
2584 if(dm_digtable
.dig_algorithm_switch
)
2590 if(dm_digtable
.pre_connect_state
== dm_digtable
.cur_connect_state
)
2592 if(dm_digtable
.cur_connect_state
== DIG_CONNECT
)
2594 if((dm_digtable
.rssi_val
+10-dm_digtable
.backoff_val
) > dm_digtable
.rx_gain_range_max
)
2595 dm_digtable
.cur_ig_value
= dm_digtable
.rx_gain_range_max
;
2596 else if((dm_digtable
.rssi_val
+10-dm_digtable
.backoff_val
) < dm_digtable
.rx_gain_range_min
)
2597 dm_digtable
.cur_ig_value
= dm_digtable
.rx_gain_range_min
;
2599 dm_digtable
.cur_ig_value
= dm_digtable
.rssi_val
+10-dm_digtable
.backoff_val
;
2601 else //current state is disconnected
2603 if(dm_digtable
.cur_ig_value
== 0)
2604 dm_digtable
.cur_ig_value
= priv
->DefaultInitialGain
[0];
2606 dm_digtable
.cur_ig_value
= dm_digtable
.pre_ig_value
;
2609 else // disconnected -> connected or connected -> disconnected
2611 dm_digtable
.cur_ig_value
= priv
->DefaultInitialGain
[0];
2612 dm_digtable
.pre_ig_value
= 0;
2614 //DbgPrint("DM_DigTable.CurIGValue = 0x%x, DM_DigTable.PreIGValue = 0x%x\n", DM_DigTable.CurIGValue, DM_DigTable.PreIGValue);
2616 // if silent reset happened, we should rewrite the values back
2617 if(priv
->reset_count
!= reset_cnt
)
2620 reset_cnt
= priv
->reset_count
;
2623 if(dm_digtable
.pre_ig_value
!= read_nic_byte(dev
, rOFDM0_XAAGCCore1
))
2627 if((dm_digtable
.pre_ig_value
!= dm_digtable
.cur_ig_value
)
2628 || !initialized
|| force_write
)
2630 initial_gain
= (u8
)dm_digtable
.cur_ig_value
;
2631 //DbgPrint("Write initial gain = 0x%x\n", initial_gain);
2632 // Set initial gain.
2633 write_nic_byte(dev
, rOFDM0_XAAGCCore1
, initial_gain
);
2634 write_nic_byte(dev
, rOFDM0_XBAGCCore1
, initial_gain
);
2635 write_nic_byte(dev
, rOFDM0_XCAGCCore1
, initial_gain
);
2636 write_nic_byte(dev
, rOFDM0_XDAGCCore1
, initial_gain
);
2637 dm_digtable
.pre_ig_value
= dm_digtable
.cur_ig_value
;
2644 static void dm_pd_th(
2645 struct net_device
* dev
)
2647 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2648 static u8 initialized
=0, force_write
=0;
2649 static u32 reset_cnt
= 0;
2651 if(dm_digtable
.dig_algorithm_switch
)
2657 if(dm_digtable
.pre_connect_state
== dm_digtable
.cur_connect_state
)
2659 if(dm_digtable
.cur_connect_state
== DIG_CONNECT
)
2661 if (dm_digtable
.rssi_val
>= dm_digtable
.rssi_high_power_highthresh
)
2662 dm_digtable
.curpd_thstate
= DIG_PD_AT_HIGH_POWER
;
2663 else if ((dm_digtable
.rssi_val
<= dm_digtable
.rssi_low_thresh
))
2664 dm_digtable
.curpd_thstate
= DIG_PD_AT_LOW_POWER
;
2665 else if ((dm_digtable
.rssi_val
>= dm_digtable
.rssi_high_thresh
) &&
2666 (dm_digtable
.rssi_val
< dm_digtable
.rssi_high_power_lowthresh
))
2667 dm_digtable
.curpd_thstate
= DIG_PD_AT_NORMAL_POWER
;
2669 dm_digtable
.curpd_thstate
= dm_digtable
.prepd_thstate
;
2673 dm_digtable
.curpd_thstate
= DIG_PD_AT_LOW_POWER
;
2676 else // disconnected -> connected or connected -> disconnected
2678 dm_digtable
.curpd_thstate
= DIG_PD_AT_LOW_POWER
;
2681 // if silent reset happened, we should rewrite the values back
2682 if(priv
->reset_count
!= reset_cnt
)
2685 reset_cnt
= priv
->reset_count
;
2689 if((dm_digtable
.prepd_thstate
!= dm_digtable
.curpd_thstate
) ||
2690 (initialized
<=3) || force_write
)
2692 //DbgPrint("Write PD_TH state = %d\n", DM_DigTable.CurPD_THState);
2693 if(dm_digtable
.curpd_thstate
== DIG_PD_AT_LOW_POWER
)
2695 // Lower PD_TH for OFDM.
2696 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)
2698 /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
2699 // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2701 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x40);
2703 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x00);
2705 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2706 write_nic_byte(dev, rOFDM0_RxDetector1, 0x40);
2710 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x42);
2712 else if(dm_digtable
.curpd_thstate
== DIG_PD_AT_NORMAL_POWER
)
2714 // Higher PD_TH for OFDM.
2715 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)
2717 /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
2718 // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2720 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x42);
2722 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x20);
2724 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2725 write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2729 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x44);
2731 else if(dm_digtable
.curpd_thstate
== DIG_PD_AT_HIGH_POWER
)
2733 // Higher PD_TH for OFDM for high power state.
2734 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
)
2737 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x41);
2739 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x10);
2741 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2742 write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
2746 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x43);
2748 dm_digtable
.prepd_thstate
= dm_digtable
.curpd_thstate
;
2749 if(initialized
<= 3)
2756 static void dm_cs_ratio(
2757 struct net_device
* dev
)
2759 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2760 static u8 initialized
=0,force_write
=0;
2761 static u32 reset_cnt
= 0;
2763 if(dm_digtable
.dig_algorithm_switch
)
2769 if(dm_digtable
.pre_connect_state
== dm_digtable
.cur_connect_state
)
2771 if(dm_digtable
.cur_connect_state
== DIG_CONNECT
)
2773 if ((dm_digtable
.rssi_val
<= dm_digtable
.rssi_low_thresh
))
2774 dm_digtable
.curcs_ratio_state
= DIG_CS_RATIO_LOWER
;
2775 else if ((dm_digtable
.rssi_val
>= dm_digtable
.rssi_high_thresh
) )
2776 dm_digtable
.curcs_ratio_state
= DIG_CS_RATIO_HIGHER
;
2778 dm_digtable
.curcs_ratio_state
= dm_digtable
.precs_ratio_state
;
2782 dm_digtable
.curcs_ratio_state
= DIG_CS_RATIO_LOWER
;
2785 else // disconnected -> connected or connected -> disconnected
2787 dm_digtable
.curcs_ratio_state
= DIG_CS_RATIO_LOWER
;
2790 // if silent reset happened, we should rewrite the values back
2791 if(priv
->reset_count
!= reset_cnt
)
2794 reset_cnt
= priv
->reset_count
;
2799 if((dm_digtable
.precs_ratio_state
!= dm_digtable
.curcs_ratio_state
) ||
2800 !initialized
|| force_write
)
2802 //DbgPrint("Write CS_ratio state = %d\n", DM_DigTable.CurCS_ratioState);
2803 if(dm_digtable
.curcs_ratio_state
== DIG_CS_RATIO_LOWER
)
2805 // Lower CS ratio for CCK.
2806 write_nic_byte(dev
, 0xa0a, 0x08);
2808 else if(dm_digtable
.curcs_ratio_state
== DIG_CS_RATIO_HIGHER
)
2810 // Higher CS ratio for CCK.
2811 write_nic_byte(dev
, 0xa0a, 0xcd);
2813 dm_digtable
.precs_ratio_state
= dm_digtable
.curcs_ratio_state
;
2820 void dm_init_edca_turbo(struct net_device
*dev
)
2822 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2824 priv
->bcurrent_turbo_EDCA
= false;
2825 priv
->ieee80211
->bis_any_nonbepkts
= false;
2826 priv
->bis_cur_rdlstate
= false;
2827 } // dm_init_edca_turbo
2830 static void dm_check_edca_turbo(
2831 struct net_device
* dev
)
2833 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2834 PRT_HIGH_THROUGHPUT pHTInfo
= priv
->ieee80211
->pHTInfo
;
2835 //PSTA_QOS pStaQos = pMgntInfo->pStaQos;
2837 // Keep past Tx/Rx packet count for RT-to-RT EDCA turbo.
2838 static unsigned long lastTxOkCnt
= 0;
2839 static unsigned long lastRxOkCnt
= 0;
2840 unsigned long curTxOkCnt
= 0;
2841 unsigned long curRxOkCnt
= 0;
2844 // Do not be Turbo if it's under WiFi config and Qos Enabled, because the EDCA parameters
2845 // should follow the settings from QAP. By Bruce, 2007-12-07.
2848 if(priv
->ieee80211
->state
!= IEEE80211_LINKED
)
2849 goto dm_CheckEdcaTurbo_EXIT
;
2851 // We do not turn on EDCA turbo mode for some AP that has IOT issue
2852 if(priv
->ieee80211
->pHTInfo
->IOTAction
& HT_IOT_ACT_DISABLE_EDCA_TURBO
)
2853 goto dm_CheckEdcaTurbo_EXIT
;
2855 // printk("========>%s():bis_any_nonbepkts is %d\n",__FUNCTION__,priv->bis_any_nonbepkts);
2856 // Check the status for current condition.
2857 if(!priv
->ieee80211
->bis_any_nonbepkts
)
2859 curTxOkCnt
= priv
->stats
.txbytesunicast
- lastTxOkCnt
;
2860 curRxOkCnt
= priv
->stats
.rxbytesunicast
- lastRxOkCnt
;
2861 // For RT-AP, we needs to turn it on when Rx>Tx
2862 if(curRxOkCnt
> 4*curTxOkCnt
)
2864 //printk("%s():curRxOkCnt > 4*curTxOkCnt\n");
2865 if(!priv
->bis_cur_rdlstate
|| !priv
->bcurrent_turbo_EDCA
)
2867 write_nic_dword(dev
, EDCAPARA_BE
, edca_setting_DL
[pHTInfo
->IOTPeer
]);
2868 priv
->bis_cur_rdlstate
= true;
2874 //printk("%s():curRxOkCnt < 4*curTxOkCnt\n");
2875 if(priv
->bis_cur_rdlstate
|| !priv
->bcurrent_turbo_EDCA
)
2877 write_nic_dword(dev
, EDCAPARA_BE
, edca_setting_UL
[pHTInfo
->IOTPeer
]);
2878 priv
->bis_cur_rdlstate
= false;
2883 priv
->bcurrent_turbo_EDCA
= true;
2888 // Turn Off EDCA turbo here.
2889 // Restore original EDCA according to the declaration of AP.
2891 if(priv
->bcurrent_turbo_EDCA
)
2897 struct ieee80211_qos_parameters
*qos_parameters
= &priv
->ieee80211
->current_network
.qos_data
.parameters
;
2898 u8 mode
= priv
->ieee80211
->mode
;
2900 // For Each time updating EDCA parameter, reset EDCA turbo mode status.
2901 dm_init_edca_turbo(dev
);
2902 u1bAIFS
= qos_parameters
->aifs
[0] * ((mode
&(IEEE_G
|IEEE_N_24G
)) ?9:20) + aSifsTime
;
2903 u4bAcParam
= ((((u32
)(qos_parameters
->tx_op_limit
[0]))<< AC_PARAM_TXOP_LIMIT_OFFSET
)|
2904 (((u32
)(qos_parameters
->cw_max
[0]))<< AC_PARAM_ECW_MAX_OFFSET
)|
2905 (((u32
)(qos_parameters
->cw_min
[0]))<< AC_PARAM_ECW_MIN_OFFSET
)|
2906 ((u32
)u1bAIFS
<< AC_PARAM_AIFS_OFFSET
));
2907 printk("===>u4bAcParam:%x, ", u4bAcParam
);
2908 //write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam);
2909 write_nic_dword(dev
, EDCAPARA_BE
, u4bAcParam
);
2912 // If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13.
2914 // TODO: Modified this part and try to set acm control in only 1 IO processing!!
2916 PACI_AIFSN pAciAifsn
= (PACI_AIFSN
)&(qos_parameters
->aifs
[0]);
2917 u8 AcmCtrl
= read_nic_byte( dev
, AcmHwCtrl
);
2918 if( pAciAifsn
->f
.ACM
)
2920 AcmCtrl
|= AcmHw_BeqEn
;
2924 AcmCtrl
&= (~AcmHw_BeqEn
);
2927 RT_TRACE( COMP_QOS
,"SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl
) ;
2928 write_nic_byte(dev
, AcmHwCtrl
, AcmCtrl
);
2931 priv
->bcurrent_turbo_EDCA
= false;
2936 dm_CheckEdcaTurbo_EXIT
:
2937 // Set variables for next time.
2938 priv
->ieee80211
->bis_any_nonbepkts
= false;
2939 lastTxOkCnt
= priv
->stats
.txbytesunicast
;
2940 lastRxOkCnt
= priv
->stats
.rxbytesunicast
;
2941 } // dm_CheckEdcaTurbo
2944 static void DM_CTSToSelfSetting(struct net_device
*dev
, u32 DM_Type
, u32 DM_Value
)
2946 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)dev
);
2948 if (DM_Type
== 0) // CTS to self disable/enable
2952 priv
->ieee80211
->bCTSToSelfEnable
= (bool)DM_Value
;
2953 //DbgPrint("pMgntInfo->bCTSToSelfEnable = %d\n", pMgntInfo->bCTSToSelfEnable);
2955 else if(DM_Type
== 1) //CTS to self Th
2959 priv
->ieee80211
->CTSToSelfTH
= (u8
)DM_Value
;
2960 //DbgPrint("pMgntInfo->CTSToSelfTH = %d\n", pMgntInfo->CTSToSelfTH);
2964 static void dm_init_ctstoself(struct net_device
* dev
)
2966 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)dev
);
2968 priv
->ieee80211
->bCTSToSelfEnable
= TRUE
;
2969 priv
->ieee80211
->CTSToSelfTH
= CTSToSelfTHVal
;
2972 static void dm_ctstoself(struct net_device
*dev
)
2974 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)dev
);
2975 PRT_HIGH_THROUGHPUT pHTInfo
= priv
->ieee80211
->pHTInfo
;
2976 static unsigned long lastTxOkCnt
= 0;
2977 static unsigned long lastRxOkCnt
= 0;
2978 unsigned long curTxOkCnt
= 0;
2979 unsigned long curRxOkCnt
= 0;
2981 if(priv
->ieee80211
->bCTSToSelfEnable
!= TRUE
)
2983 pHTInfo
->IOTAction
&= ~HT_IOT_ACT_FORCED_CTS2SELF
;
2988 2. Linksys350/Linksys300N
2989 3. <50 disable, >55 enable
2992 if(pHTInfo
->IOTPeer
== HT_IOT_PEER_BROADCOM
)
2994 curTxOkCnt
= priv
->stats
.txbytesunicast
- lastTxOkCnt
;
2995 curRxOkCnt
= priv
->stats
.rxbytesunicast
- lastRxOkCnt
;
2996 if(curRxOkCnt
> 4*curTxOkCnt
) //downlink, disable CTS to self
2998 pHTInfo
->IOTAction
&= ~HT_IOT_ACT_FORCED_CTS2SELF
;
2999 //DbgPrint("dm_CTSToSelf() ==> CTS to self disabled -- downlink\n");
3004 pHTInfo
->IOTAction
|= HT_IOT_ACT_FORCED_CTS2SELF
;
3006 if(priv
->undecorated_smoothed_pwdb
< priv
->ieee80211
->CTSToSelfTH
) // disable CTS to self
3008 pHTInfo
->IOTAction
&= ~HT_IOT_ACT_FORCED_CTS2SELF
;
3009 //DbgPrint("dm_CTSToSelf() ==> CTS to self disabled\n");
3011 else if(priv
->undecorated_smoothed_pwdb
>= (priv
->ieee80211
->CTSToSelfTH
+5)) // enable CTS to self
3013 pHTInfo
->IOTAction
|= HT_IOT_ACT_FORCED_CTS2SELF
;
3014 //DbgPrint("dm_CTSToSelf() ==> CTS to self enabled\n");
3019 lastTxOkCnt
= priv
->stats
.txbytesunicast
;
3020 lastRxOkCnt
= priv
->stats
.rxbytesunicast
;
3026 /*-----------------------------------------------------------------------------
3027 * Function: dm_rf_operation_test_callback()
3029 * Overview: Only for RF operation test now.
3039 * 05/29/2008 amy Create Version 0 porting from windows code.
3041 *---------------------------------------------------------------------------*/
3042 void dm_rf_operation_test_callback(unsigned long dev
)
3044 // struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
3048 for(erfpath
=0; erfpath
<4; erfpath
++)
3050 //DbgPrint("Set RF-%d\n\r", eRFPath);
3051 //PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3d7);
3056 //PlatformSetPeriodicTimer(Adapter, &pHalData->RfTest1Timer, 500);
3062 //PlatformSetPeriodicTimer(Adapter, &pHalData->RfTest1Timer, 500);
3067 PHY_SetRFReg(Adapter
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4d);
3069 PHY_SetRFReg(Adapter
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4f);
3071 PHY_SetRFReg(Adapter
, RF90_PATH_C
, 0x02, bMask12Bits
, 0x4d);
3073 PHY_SetRFReg(Adapter
, RF90_PATH_C
, 0x02, bMask12Bits
, 0x4f);
3078 PHY_QueryRFReg(Adapter
, RF90_PATH_A
, 0x02, bMask12Bits
);
3080 PHY_QueryRFReg(Adapter
, RF90_PATH_A
, 0x02, bMask12Bits
);
3082 PHY_QueryRFReg(Adapter
, RF90_PATH_A
, 0x12, bMask12Bits
);
3084 PHY_QueryRFReg(Adapter
, RF90_PATH_A
, 0x12, bMask12Bits
);
3086 PHY_QueryRFReg(Adapter
, RF90_PATH_A
, 0x21, bMask12Bits
);
3088 PHY_QueryRFReg(Adapter
, RF90_PATH_A
, 0x21, bMask12Bits
);
3095 } /* DM_RfOperationTestCallBack */
3098 /*-----------------------------------------------------------------------------
3099 * Function: dm_check_rfctrl_gpio()
3101 * Overview: Copy 8187B template for 9xseries.
3111 * 05/28/2008 amy Create Version 0 porting from windows code.
3113 *---------------------------------------------------------------------------*/
3115 static void dm_check_rfctrl_gpio(struct net_device
* dev
)
3118 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3121 // Walk around for DTM test, we will not enable HW - radio on/off because r/w
3122 // page 1 register before Lextra bus is enabled cause system fails when resuming
3123 // from S4. 20080218, Emily
3125 // Stop to execute workitem to prevent S3/S4 bug.
3133 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
3134 queue_delayed_work(priv
->priv_wq
,&priv
->gpio_change_rf_wq
,0);
3136 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
3137 schedule_task(&priv
->gpio_change_rf_wq
);
3139 queue_work(priv
->priv_wq
,&priv
->gpio_change_rf_wq
);
3144 } /* dm_CheckRfCtrlGPIO */
3147 /*-----------------------------------------------------------------------------
3148 * Function: dm_check_pbc_gpio()
3150 * Overview: Check if PBC button is pressed.
3160 * 05/28/2008 amy Create Version 0 porting from windows code.
3162 *---------------------------------------------------------------------------*/
3163 static void dm_check_pbc_gpio(struct net_device
*dev
)
3166 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3170 tmp1byte
= read_nic_byte(dev
,GPI
);
3171 if(tmp1byte
== 0xff)
3174 if (tmp1byte
&BIT6
|| tmp1byte
&BIT0
)
3176 // Here we only set bPbcPressed to TRUE
3177 // After trigger PBC, the variable will be set to FALSE
3178 RT_TRACE(COMP_IO
, "CheckPbcGPIO - PBC is pressed\n");
3179 priv
->bpbc_pressed
= true;
3187 /*-----------------------------------------------------------------------------
3188 * Function: dm_GPIOChangeRF
3189 * Overview: PCI will not support workitem call back HW radio on-off control.
3199 * 02/21/2008 MHC Create Version 0.
3201 *---------------------------------------------------------------------------*/
3202 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
3203 void dm_gpio_change_rf_callback(struct work_struct
*work
)
3205 struct delayed_work
*dwork
= container_of(work
,struct delayed_work
,work
);
3206 struct r8192_priv
*priv
= container_of(dwork
,struct r8192_priv
,gpio_change_rf_wq
);
3207 struct net_device
*dev
= priv
->ieee80211
->dev
;
3209 extern void dm_gpio_change_rf_callback(struct net_device
*dev
)
3211 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3214 RT_RF_POWER_STATE eRfPowerStateToSet
;
3215 bool bActuallySet
= false;
3221 RT_TRACE((COMP_INIT
| COMP_POWER
| COMP_RF
),"dm_gpio_change_rf_callback(): Callback function breaks out!!\n");
3225 // 0x108 GPIO input register is read only
3226 //set 0x108 B1= 1: RF-ON; 0: RF-OFF.
3227 tmp1byte
= read_nic_byte(dev
,GPI
);
3229 eRfPowerStateToSet
= (tmp1byte
&BIT1
) ? eRfOn
: eRfOff
;
3231 if( (priv
->bHwRadioOff
== true) && (eRfPowerStateToSet
== eRfOn
))
3233 RT_TRACE(COMP_RF
, "gpiochangeRF - HW Radio ON\n");
3235 priv
->bHwRadioOff
= false;
3236 bActuallySet
= true;
3238 else if ( (priv
->bHwRadioOff
== false) && (eRfPowerStateToSet
== eRfOff
))
3240 RT_TRACE(COMP_RF
, "gpiochangeRF - HW Radio OFF\n");
3241 priv
->bHwRadioOff
= true;
3242 bActuallySet
= true;
3247 priv
->bHwRfOffAction
= 1;
3248 MgntActSet_RF_State(dev
, eRfPowerStateToSet
, RF_CHANGE_BY_HW
);
3249 //DrvIFIndicateCurrentPhyStatus(pAdapter);
3259 } /* dm_GPIOChangeRF */
3262 /*-----------------------------------------------------------------------------
3263 * Function: DM_RFPathCheckWorkItemCallBack()
3265 * Overview: Check if Current RF RX path is enabled
3275 * 01/30/2008 MHC Create Version 0.
3277 *---------------------------------------------------------------------------*/
3278 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
3279 void dm_rf_pathcheck_workitemcallback(struct work_struct
*work
)
3281 struct delayed_work
*dwork
= container_of(work
,struct delayed_work
,work
);
3282 struct r8192_priv
*priv
= container_of(dwork
,struct r8192_priv
,rfpath_check_wq
);
3283 struct net_device
*dev
=priv
->ieee80211
->dev
;
3285 extern void dm_rf_pathcheck_workitemcallback(struct net_device
*dev
)
3287 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3289 //bool bactually_set = false;
3293 /* 2008/01/30 MH After discussing with SD3 Jerry, 0xc04/0xd04 register will
3294 always be the same. We only read 0xc04 now. */
3295 rfpath
= read_nic_byte(dev
, 0xc04);
3297 // Check Bit 0-3, it means if RF A-D is enabled.
3298 for (i
= 0; i
< RF90_PATH_MAX
; i
++)
3300 if (rfpath
& (0x01<<i
))
3301 priv
->brfpath_rxenable
[i
] = 1;
3303 priv
->brfpath_rxenable
[i
] = 0;
3305 if(!DM_RxPathSelTable
.Enable
)
3308 dm_rxpath_sel_byrssi(dev
);
3309 } /* DM_RFPathCheckWorkItemCallBack */
3311 static void dm_init_rxpath_selection(struct net_device
* dev
)
3314 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3315 DM_RxPathSelTable
.Enable
= 1; //default enabled
3316 DM_RxPathSelTable
.SS_TH_low
= RxPathSelection_SS_TH_low
;
3317 DM_RxPathSelTable
.diff_TH
= RxPathSelection_diff_TH
;
3318 if(priv
->CustomerID
== RT_CID_819x_Netcore
)
3319 DM_RxPathSelTable
.cck_method
= CCK_Rx_Version_2
;
3321 DM_RxPathSelTable
.cck_method
= CCK_Rx_Version_1
;
3322 DM_RxPathSelTable
.DbgMode
= DM_DBG_OFF
;
3323 DM_RxPathSelTable
.disabledRF
= 0;
3326 DM_RxPathSelTable
.rf_rssi
[i
] = 50;
3327 DM_RxPathSelTable
.cck_pwdb_sta
[i
] = -64;
3328 DM_RxPathSelTable
.rf_enable_rssi_th
[i
] = 100;
3332 static void dm_rxpath_sel_byrssi(struct net_device
* dev
)
3334 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3335 u8 i
, max_rssi_index
=0, min_rssi_index
=0, sec_rssi_index
=0, rf_num
=0;
3336 u8 tmp_max_rssi
=0, tmp_min_rssi
=0, tmp_sec_rssi
=0;
3337 u8 cck_default_Rx
=0x2; //RF-C
3338 u8 cck_optional_Rx
=0x3;//RF-D
3339 long tmp_cck_max_pwdb
=0, tmp_cck_min_pwdb
=0, tmp_cck_sec_pwdb
=0;
3340 u8 cck_rx_ver2_max_index
=0, cck_rx_ver2_min_index
=0, cck_rx_ver2_sec_index
=0;
3343 static u8 disabled_rf_cnt
=0, cck_Rx_Path_initialized
=0;
3344 u8 update_cck_rx_path
;
3346 if(priv
->rf_type
!= RF_2T4R
)
3349 if(!cck_Rx_Path_initialized
)
3351 DM_RxPathSelTable
.cck_Rx_path
= (read_nic_byte(dev
, 0xa07)&0xf);
3352 cck_Rx_Path_initialized
= 1;
3355 DM_RxPathSelTable
.disabledRF
= 0xf;
3356 DM_RxPathSelTable
.disabledRF
&=~ (read_nic_byte(dev
, 0xc04));
3358 if(priv
->ieee80211
->mode
== WIRELESS_MODE_B
)
3360 DM_RxPathSelTable
.cck_method
= CCK_Rx_Version_2
; //pure B mode, fixed cck version2
3361 //DbgPrint("Pure B mode, use cck rx version2 \n");
3364 //decide max/sec/min rssi index
3365 for (i
=0; i
<RF90_PATH_MAX
; i
++)
3367 if(!DM_RxPathSelTable
.DbgMode
)
3368 DM_RxPathSelTable
.rf_rssi
[i
] = priv
->stats
.rx_rssi_percentage
[i
];
3370 if(priv
->brfpath_rxenable
[i
])
3373 cur_rf_rssi
= DM_RxPathSelTable
.rf_rssi
[i
];
3375 if(rf_num
== 1) // find first enabled rf path and the rssi values
3376 { //initialize, set all rssi index to the same one
3377 max_rssi_index
= min_rssi_index
= sec_rssi_index
= i
;
3378 tmp_max_rssi
= tmp_min_rssi
= tmp_sec_rssi
= cur_rf_rssi
;
3380 else if(rf_num
== 2)
3381 { // we pick up the max index first, and let sec and min to be the same one
3382 if(cur_rf_rssi
>= tmp_max_rssi
)
3384 tmp_max_rssi
= cur_rf_rssi
;
3389 tmp_sec_rssi
= tmp_min_rssi
= cur_rf_rssi
;
3390 sec_rssi_index
= min_rssi_index
= i
;
3395 if(cur_rf_rssi
> tmp_max_rssi
)
3397 tmp_sec_rssi
= tmp_max_rssi
;
3398 sec_rssi_index
= max_rssi_index
;
3399 tmp_max_rssi
= cur_rf_rssi
;
3402 else if(cur_rf_rssi
== tmp_max_rssi
)
3403 { // let sec and min point to the different index
3404 tmp_sec_rssi
= cur_rf_rssi
;
3407 else if((cur_rf_rssi
< tmp_max_rssi
) &&(cur_rf_rssi
> tmp_sec_rssi
))
3409 tmp_sec_rssi
= cur_rf_rssi
;
3412 else if(cur_rf_rssi
== tmp_sec_rssi
)
3414 if(tmp_sec_rssi
== tmp_min_rssi
)
3415 { // let sec and min point to the different index
3416 tmp_sec_rssi
= cur_rf_rssi
;
3421 // This case we don't need to set any index
3424 else if((cur_rf_rssi
< tmp_sec_rssi
) && (cur_rf_rssi
> tmp_min_rssi
))
3426 // This case we don't need to set any index
3428 else if(cur_rf_rssi
== tmp_min_rssi
)
3430 if(tmp_sec_rssi
== tmp_min_rssi
)
3431 { // let sec and min point to the different index
3432 tmp_min_rssi
= cur_rf_rssi
;
3437 // This case we don't need to set any index
3440 else if(cur_rf_rssi
< tmp_min_rssi
)
3442 tmp_min_rssi
= cur_rf_rssi
;
3450 // decide max/sec/min cck pwdb index
3451 if(DM_RxPathSelTable
.cck_method
== CCK_Rx_Version_2
)
3453 for (i
=0; i
<RF90_PATH_MAX
; i
++)
3455 if(priv
->brfpath_rxenable
[i
])
3458 cur_cck_pwdb
= DM_RxPathSelTable
.cck_pwdb_sta
[i
];
3460 if(rf_num
== 1) // find first enabled rf path and the rssi values
3461 { //initialize, set all rssi index to the same one
3462 cck_rx_ver2_max_index
= cck_rx_ver2_min_index
= cck_rx_ver2_sec_index
= i
;
3463 tmp_cck_max_pwdb
= tmp_cck_min_pwdb
= tmp_cck_sec_pwdb
= cur_cck_pwdb
;
3465 else if(rf_num
== 2)
3466 { // we pick up the max index first, and let sec and min to be the same one
3467 if(cur_cck_pwdb
>= tmp_cck_max_pwdb
)
3469 tmp_cck_max_pwdb
= cur_cck_pwdb
;
3470 cck_rx_ver2_max_index
= i
;
3474 tmp_cck_sec_pwdb
= tmp_cck_min_pwdb
= cur_cck_pwdb
;
3475 cck_rx_ver2_sec_index
= cck_rx_ver2_min_index
= i
;
3480 if(cur_cck_pwdb
> tmp_cck_max_pwdb
)
3482 tmp_cck_sec_pwdb
= tmp_cck_max_pwdb
;
3483 cck_rx_ver2_sec_index
= cck_rx_ver2_max_index
;
3484 tmp_cck_max_pwdb
= cur_cck_pwdb
;
3485 cck_rx_ver2_max_index
= i
;
3487 else if(cur_cck_pwdb
== tmp_cck_max_pwdb
)
3488 { // let sec and min point to the different index
3489 tmp_cck_sec_pwdb
= cur_cck_pwdb
;
3490 cck_rx_ver2_sec_index
= i
;
3492 else if((cur_cck_pwdb
< tmp_cck_max_pwdb
) &&(cur_cck_pwdb
> tmp_cck_sec_pwdb
))
3494 tmp_cck_sec_pwdb
= cur_cck_pwdb
;
3495 cck_rx_ver2_sec_index
= i
;
3497 else if(cur_cck_pwdb
== tmp_cck_sec_pwdb
)
3499 if(tmp_cck_sec_pwdb
== tmp_cck_min_pwdb
)
3500 { // let sec and min point to the different index
3501 tmp_cck_sec_pwdb
= cur_cck_pwdb
;
3502 cck_rx_ver2_sec_index
= i
;
3506 // This case we don't need to set any index
3509 else if((cur_cck_pwdb
< tmp_cck_sec_pwdb
) && (cur_cck_pwdb
> tmp_cck_min_pwdb
))
3511 // This case we don't need to set any index
3513 else if(cur_cck_pwdb
== tmp_cck_min_pwdb
)
3515 if(tmp_cck_sec_pwdb
== tmp_cck_min_pwdb
)
3516 { // let sec and min point to the different index
3517 tmp_cck_min_pwdb
= cur_cck_pwdb
;
3518 cck_rx_ver2_min_index
= i
;
3522 // This case we don't need to set any index
3525 else if(cur_cck_pwdb
< tmp_cck_min_pwdb
)
3527 tmp_cck_min_pwdb
= cur_cck_pwdb
;
3528 cck_rx_ver2_min_index
= i
;
3538 // reg0xA07[3:2]=cck default rx path, reg0xa07[1:0]=cck optional rx path.
3539 update_cck_rx_path
= 0;
3540 if(DM_RxPathSelTable
.cck_method
== CCK_Rx_Version_2
)
3542 cck_default_Rx
= cck_rx_ver2_max_index
;
3543 cck_optional_Rx
= cck_rx_ver2_sec_index
;
3544 if(tmp_cck_max_pwdb
!= -64)
3545 update_cck_rx_path
= 1;
3548 if(tmp_min_rssi
< DM_RxPathSelTable
.SS_TH_low
&& disabled_rf_cnt
< 2)
3550 if((tmp_max_rssi
- tmp_min_rssi
) >= DM_RxPathSelTable
.diff_TH
)
3552 //record the enabled rssi threshold
3553 DM_RxPathSelTable
.rf_enable_rssi_th
[min_rssi_index
] = tmp_max_rssi
+5;
3554 //disable the BB Rx path, OFDM
3555 rtl8192_setBBreg(dev
, rOFDM0_TRxPathEnable
, 0x1<<min_rssi_index
, 0x0); // 0xc04[3:0]
3556 rtl8192_setBBreg(dev
, rOFDM1_TRxPathEnable
, 0x1<<min_rssi_index
, 0x0); // 0xd04[3:0]
3559 if(DM_RxPathSelTable
.cck_method
== CCK_Rx_Version_1
)
3561 cck_default_Rx
= max_rssi_index
;
3562 cck_optional_Rx
= sec_rssi_index
;
3564 update_cck_rx_path
= 1;
3568 if(update_cck_rx_path
)
3570 DM_RxPathSelTable
.cck_Rx_path
= (cck_default_Rx
<<2)|(cck_optional_Rx
);
3571 rtl8192_setBBreg(dev
, rCCK0_AFESetting
, 0x0f000000, DM_RxPathSelTable
.cck_Rx_path
);
3574 if(DM_RxPathSelTable
.disabledRF
)
3578 if((DM_RxPathSelTable
.disabledRF
>>i
) & 0x1) //disabled rf
3580 if(tmp_max_rssi
>= DM_RxPathSelTable
.rf_enable_rssi_th
[i
])
3582 //enable the BB Rx path
3583 //DbgPrint("RF-%d is enabled. \n", 0x1<<i);
3584 rtl8192_setBBreg(dev
, rOFDM0_TRxPathEnable
, 0x1<<i
, 0x1); // 0xc04[3:0]
3585 rtl8192_setBBreg(dev
, rOFDM1_TRxPathEnable
, 0x1<<i
, 0x1); // 0xd04[3:0]
3586 DM_RxPathSelTable
.rf_enable_rssi_th
[i
] = 100;
3594 /*-----------------------------------------------------------------------------
3595 * Function: dm_check_rx_path_selection()
3597 * Overview: Call a workitem to check current RXRF path and Rx Path selection by RSSI.
3607 * 05/28/2008 amy Create Version 0 porting from windows code.
3609 *---------------------------------------------------------------------------*/
3610 static void dm_check_rx_path_selection(struct net_device
*dev
)
3612 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3613 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
3614 queue_delayed_work(priv
->priv_wq
,&priv
->rfpath_check_wq
,0);
3616 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
3617 schedule_task(&priv
->rfpath_check_wq
);
3619 queue_work(priv
->priv_wq
,&priv
->rfpath_check_wq
);
3622 } /* dm_CheckRxRFPath */
3625 static void dm_init_fsync (struct net_device
*dev
)
3627 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3629 priv
->ieee80211
->fsync_time_interval
= 500;
3630 priv
->ieee80211
->fsync_rate_bitmap
= 0x0f000800;
3631 priv
->ieee80211
->fsync_rssi_threshold
= 30;
3633 priv
->ieee80211
->bfsync_enable
= true;
3635 priv
->ieee80211
->bfsync_enable
= false;
3637 priv
->ieee80211
->fsync_multiple_timeinterval
= 3;
3638 priv
->ieee80211
->fsync_firstdiff_ratethreshold
= 100;
3639 priv
->ieee80211
->fsync_seconddiff_ratethreshold
= 200;
3640 priv
->ieee80211
->fsync_state
= Default_Fsync
;
3641 priv
->framesyncMonitor
= 1; // current default 0xc38 monitor on
3643 init_timer(&priv
->fsync_timer
);
3644 priv
->fsync_timer
.data
= (unsigned long)dev
;
3645 priv
->fsync_timer
.function
= dm_fsync_timer_callback
;
3649 static void dm_deInit_fsync(struct net_device
*dev
)
3651 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3652 del_timer_sync(&priv
->fsync_timer
);
3655 void dm_fsync_timer_callback(unsigned long data
)
3657 struct net_device
*dev
= (struct net_device
*)data
;
3658 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)data
);
3659 u32 rate_index
, rate_count
= 0, rate_count_diff
=0;
3660 bool bSwitchFromCountDiff
= false;
3661 bool bDoubleTimeInterval
= false;
3663 if( priv
->ieee80211
->state
== IEEE80211_LINKED
&&
3664 priv
->ieee80211
->bfsync_enable
&&
3665 (priv
->ieee80211
->pHTInfo
->IOTAction
& HT_IOT_ACT_CDD_FSYNC
))
3667 // Count rate 54, MCS [7], [12, 13, 14, 15]
3669 for(rate_index
= 0; rate_index
<= 27; rate_index
++)
3671 rate_bitmap
= 1 << rate_index
;
3672 if(priv
->ieee80211
->fsync_rate_bitmap
& rate_bitmap
)
3673 rate_count
+= priv
->stats
.received_rate_histogram
[1][rate_index
];
3676 if(rate_count
< priv
->rate_record
)
3677 rate_count_diff
= 0xffffffff - rate_count
+ priv
->rate_record
;
3679 rate_count_diff
= rate_count
- priv
->rate_record
;
3680 if(rate_count_diff
< priv
->rateCountDiffRecord
)
3683 u32 DiffNum
= priv
->rateCountDiffRecord
- rate_count_diff
;
3685 if(DiffNum
>= priv
->ieee80211
->fsync_seconddiff_ratethreshold
)
3686 priv
->ContiuneDiffCount
++;
3688 priv
->ContiuneDiffCount
= 0;
3690 // Contiune count over
3691 if(priv
->ContiuneDiffCount
>=2)
3693 bSwitchFromCountDiff
= true;
3694 priv
->ContiuneDiffCount
= 0;
3699 // Stop contiune count
3700 priv
->ContiuneDiffCount
= 0;
3703 //If Count diff <= FsyncRateCountThreshold
3704 if(rate_count_diff
<= priv
->ieee80211
->fsync_firstdiff_ratethreshold
)
3706 bSwitchFromCountDiff
= true;
3707 priv
->ContiuneDiffCount
= 0;
3709 priv
->rate_record
= rate_count
;
3710 priv
->rateCountDiffRecord
= rate_count_diff
;
3711 RT_TRACE(COMP_HALDM
, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv
->rate_record
, rate_count
, rate_count_diff
, priv
->bswitch_fsync
);
3712 // if we never receive those mcs rate and rssi > 30 % then switch fsyn
3713 if(priv
->undecorated_smoothed_pwdb
> priv
->ieee80211
->fsync_rssi_threshold
&& bSwitchFromCountDiff
)
3715 bDoubleTimeInterval
= true;
3716 priv
->bswitch_fsync
= !priv
->bswitch_fsync
;
3717 if(priv
->bswitch_fsync
)
3720 write_nic_byte(dev
,0xC36, 0x00);
3722 write_nic_byte(dev
,0xC36, 0x1c);
3724 write_nic_byte(dev
, 0xC3e, 0x90);
3729 write_nic_byte(dev
, 0xC36, 0x40);
3731 write_nic_byte(dev
, 0xC36, 0x5c);
3733 write_nic_byte(dev
, 0xC3e, 0x96);
3736 else if(priv
->undecorated_smoothed_pwdb
<= priv
->ieee80211
->fsync_rssi_threshold
)
3738 if(priv
->bswitch_fsync
)
3740 priv
->bswitch_fsync
= false;
3742 write_nic_byte(dev
, 0xC36, 0x40);
3744 write_nic_byte(dev
, 0xC36, 0x5c);
3746 write_nic_byte(dev
, 0xC3e, 0x96);
3749 if(bDoubleTimeInterval
){
3750 if(timer_pending(&priv
->fsync_timer
))
3751 del_timer_sync(&priv
->fsync_timer
);
3752 priv
->fsync_timer
.expires
= jiffies
+ MSECS(priv
->ieee80211
->fsync_time_interval
*priv
->ieee80211
->fsync_multiple_timeinterval
);
3753 add_timer(&priv
->fsync_timer
);
3756 if(timer_pending(&priv
->fsync_timer
))
3757 del_timer_sync(&priv
->fsync_timer
);
3758 priv
->fsync_timer
.expires
= jiffies
+ MSECS(priv
->ieee80211
->fsync_time_interval
);
3759 add_timer(&priv
->fsync_timer
);
3764 // Let Register return to default value;
3765 if(priv
->bswitch_fsync
)
3767 priv
->bswitch_fsync
= false;
3769 write_nic_byte(dev
, 0xC36, 0x40);
3771 write_nic_byte(dev
, 0xC36, 0x5c);
3773 write_nic_byte(dev
, 0xC3e, 0x96);
3775 priv
->ContiuneDiffCount
= 0;
3777 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x164052cd);
3779 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c52cd);
3782 RT_TRACE(COMP_HALDM
, "ContiuneDiffCount %d\n", priv
->ContiuneDiffCount
);
3783 RT_TRACE(COMP_HALDM
, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv
->rate_record
, rate_count
, rate_count_diff
, priv
->bswitch_fsync
);
3786 static void dm_StartHWFsync(struct net_device
*dev
)
3788 RT_TRACE(COMP_HALDM
, "%s\n", __FUNCTION__
);
3789 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c12cf);
3790 write_nic_byte(dev
, 0xc3b, 0x41);
3793 static void dm_EndSWFsync(struct net_device
*dev
)
3795 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3797 RT_TRACE(COMP_HALDM
, "%s\n", __FUNCTION__
);
3798 del_timer_sync(&(priv
->fsync_timer
));
3800 // Let Register return to default value;
3801 if(priv
->bswitch_fsync
)
3803 priv
->bswitch_fsync
= false;
3806 write_nic_byte(dev
, 0xC36, 0x40);
3808 write_nic_byte(dev
, 0xC36, 0x5c);
3811 write_nic_byte(dev
, 0xC3e, 0x96);
3814 priv
->ContiuneDiffCount
= 0;
3816 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c52cd);
3821 static void dm_StartSWFsync(struct net_device
*dev
)
3823 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3827 RT_TRACE(COMP_HALDM
,"%s\n", __FUNCTION__
);
3828 // Initial rate record to zero, start to record.
3829 priv
->rate_record
= 0;
3830 // Initial contiune diff count to zero, start to record.
3831 priv
->ContiuneDiffCount
= 0;
3832 priv
->rateCountDiffRecord
= 0;
3833 priv
->bswitch_fsync
= false;
3835 if(priv
->ieee80211
->mode
== WIRELESS_MODE_N_24G
)
3837 priv
->ieee80211
->fsync_firstdiff_ratethreshold
= 600;
3838 priv
->ieee80211
->fsync_seconddiff_ratethreshold
= 0xffff;
3842 priv
->ieee80211
->fsync_firstdiff_ratethreshold
= 200;
3843 priv
->ieee80211
->fsync_seconddiff_ratethreshold
= 200;
3845 for(rateIndex
= 0; rateIndex
<= 27; rateIndex
++)
3847 rateBitmap
= 1 << rateIndex
;
3848 if(priv
->ieee80211
->fsync_rate_bitmap
& rateBitmap
)
3849 priv
->rate_record
+= priv
->stats
.received_rate_histogram
[1][rateIndex
];
3851 if(timer_pending(&priv
->fsync_timer
))
3852 del_timer_sync(&priv
->fsync_timer
);
3853 priv
->fsync_timer
.expires
= jiffies
+ MSECS(priv
->ieee80211
->fsync_time_interval
);
3854 add_timer(&priv
->fsync_timer
);
3857 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c12cd);
3862 static void dm_EndHWFsync(struct net_device
*dev
)
3864 RT_TRACE(COMP_HALDM
,"%s\n", __FUNCTION__
);
3865 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c52cd);
3866 write_nic_byte(dev
, 0xc3b, 0x49);
3870 void dm_check_fsync(struct net_device
*dev
)
3872 #define RegC38_Default 0
3873 #define RegC38_NonFsync_Other_AP 1
3874 #define RegC38_Fsync_AP_BCM 2
3875 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3877 static u8 reg_c38_State
=RegC38_Default
;
3878 static u32 reset_cnt
=0;
3880 RT_TRACE(COMP_HALDM
, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv
->ieee80211
->fsync_rssi_threshold
, priv
->ieee80211
->fsync_time_interval
, priv
->ieee80211
->fsync_multiple_timeinterval
);
3881 RT_TRACE(COMP_HALDM
, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv
->ieee80211
->fsync_rate_bitmap
, priv
->ieee80211
->fsync_firstdiff_ratethreshold
, priv
->ieee80211
->fsync_seconddiff_ratethreshold
);
3883 if( priv
->ieee80211
->state
== IEEE80211_LINKED
&&
3884 (priv
->ieee80211
->pHTInfo
->IOTAction
& HT_IOT_ACT_CDD_FSYNC
))
3886 if(priv
->ieee80211
->bfsync_enable
== 0)
3888 switch(priv
->ieee80211
->fsync_state
)
3891 dm_StartHWFsync(dev
);
3892 priv
->ieee80211
->fsync_state
= HW_Fsync
;
3896 dm_StartHWFsync(dev
);
3897 priv
->ieee80211
->fsync_state
= HW_Fsync
;
3906 switch(priv
->ieee80211
->fsync_state
)
3909 dm_StartSWFsync(dev
);
3910 priv
->ieee80211
->fsync_state
= SW_Fsync
;
3914 dm_StartSWFsync(dev
);
3915 priv
->ieee80211
->fsync_state
= SW_Fsync
;
3923 if(priv
->framesyncMonitor
)
3925 if(reg_c38_State
!= RegC38_Fsync_AP_BCM
)
3926 { //For broadcom AP we write different default value
3928 write_nic_byte(dev
, rOFDM0_RxDetector3
, 0x15);
3930 write_nic_byte(dev
, rOFDM0_RxDetector3
, 0x95);
3933 reg_c38_State
= RegC38_Fsync_AP_BCM
;
3939 switch(priv
->ieee80211
->fsync_state
)
3943 priv
->ieee80211
->fsync_state
= Default_Fsync
;
3947 priv
->ieee80211
->fsync_state
= Default_Fsync
;
3954 if(priv
->framesyncMonitor
)
3956 if(priv
->ieee80211
->state
== IEEE80211_LINKED
)
3958 if(priv
->undecorated_smoothed_pwdb
<= RegC38_TH
)
3960 if(reg_c38_State
!= RegC38_NonFsync_Other_AP
)
3963 write_nic_byte(dev
, rOFDM0_RxDetector3
, 0x10);
3965 write_nic_byte(dev
, rOFDM0_RxDetector3
, 0x90);
3968 reg_c38_State
= RegC38_NonFsync_Other_AP
;
3970 if (Adapter
->HardwareType
== HARDWARE_TYPE_RTL8190P
)
3971 DbgPrint("Fsync is idle, rssi<=35, write 0xc38 = 0x%x \n", 0x10);
3973 DbgPrint("Fsync is idle, rssi<=35, write 0xc38 = 0x%x \n", 0x90);
3977 else if(priv
->undecorated_smoothed_pwdb
>= (RegC38_TH
+5))
3981 write_nic_byte(dev
, rOFDM0_RxDetector3
, priv
->framesync
);
3982 reg_c38_State
= RegC38_Default
;
3983 //DbgPrint("Fsync is idle, rssi>=40, write 0xc38 = 0x%x \n", pHalData->framesync);
3991 write_nic_byte(dev
, rOFDM0_RxDetector3
, priv
->framesync
);
3992 reg_c38_State
= RegC38_Default
;
3993 //DbgPrint("Fsync is idle, not connected, write 0xc38 = 0x%x \n", pHalData->framesync);
3998 if(priv
->framesyncMonitor
)
4000 if(priv
->reset_count
!= reset_cnt
)
4001 { //After silent reset, the reg_c38_State will be returned to default value
4002 write_nic_byte(dev
, rOFDM0_RxDetector3
, priv
->framesync
);
4003 reg_c38_State
= RegC38_Default
;
4004 reset_cnt
= priv
->reset_count
;
4005 //DbgPrint("reg_c38_State = 0 for silent reset. \n");
4012 write_nic_byte(dev
, rOFDM0_RxDetector3
, priv
->framesync
);
4013 reg_c38_State
= RegC38_Default
;
4014 //DbgPrint("framesync no monitor, write 0xc38 = 0x%x \n", pHalData->framesync);
4020 /*-----------------------------------------------------------------------------
4021 * Function: DM_CheckLBusStatus()
4023 * Overview: For 9x series, we must make sure LBUS is active for IO.
4033 * 02/22/2008 MHC Create Version 0.
4035 *---------------------------------------------------------------------------*/
4036 extern s1Byte
DM_CheckLBusStatus(IN PADAPTER Adapter
)
4038 PMGNT_INFO pMgntInfo
=&Adapter
->MgntInfo
;
4040 #if (HAL_CODE_BASE & RTL819X)
4042 #if (HAL_CODE_BASE == RTL8192)
4044 #if( DEV_BUS_TYPE==PCI_INTERFACE)
4045 //return (pMgntInfo->bLbusEnable); // For debug only
4049 #if( DEV_BUS_TYPE==USB_INTERFACE)
4053 #endif // #if (HAL_CODE_BASE == RTL8192)
4055 #if (HAL_CODE_BASE == RTL8190)
4057 #endif // #if (HAL_CODE_BASE == RTL8190)
4059 #endif // #if (HAL_CODE_BASE & RTL819X)
4060 } /* DM_CheckLBusStatus */
4064 /*-----------------------------------------------------------------------------
4065 * Function: dm_shadow_init()
4067 * Overview: Store all NIC MAC/BB register content.
4077 * 05/29/2008 amy Create Version 0 porting from windows code.
4079 *---------------------------------------------------------------------------*/
4080 void dm_shadow_init(struct net_device
*dev
)
4085 for (page
= 0; page
< 5; page
++)
4086 for (offset
= 0; offset
< 256; offset
++)
4088 dm_shadow
[page
][offset
] = read_nic_byte(dev
, offset
+page
*256);
4089 //DbgPrint("P-%d/O-%02x=%02x\r\n", page, offset, DM_Shadow[page][offset]);
4092 for (page
= 8; page
< 11; page
++)
4093 for (offset
= 0; offset
< 256; offset
++)
4094 dm_shadow
[page
][offset
] = read_nic_byte(dev
, offset
+page
*256);
4096 for (page
= 12; page
< 15; page
++)
4097 for (offset
= 0; offset
< 256; offset
++)
4098 dm_shadow
[page
][offset
] = read_nic_byte(dev
, offset
+page
*256);
4100 } /* dm_shadow_init */
4102 /*---------------------------Define function prototype------------------------*/
4103 /*-----------------------------------------------------------------------------
4104 * Function: DM_DynamicTxPower()
4106 * Overview: Detect Signal strength to control TX Registry
4107 Tx Power Control For Near/Far Range
4117 * 03/06/2008 Jacken Create Version 0.
4119 *---------------------------------------------------------------------------*/
4120 static void dm_init_dynamic_txpower(struct net_device
*dev
)
4122 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4124 //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code.
4125 priv
->ieee80211
->bdynamic_txpower_enable
= true; //Default to enable Tx Power Control
4126 priv
->bLastDTPFlag_High
= false;
4127 priv
->bLastDTPFlag_Low
= false;
4128 priv
->bDynamicTxHighPower
= false;
4129 priv
->bDynamicTxLowPower
= false;
4132 static void dm_dynamic_txpower(struct net_device
*dev
)
4134 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4135 unsigned int txhipower_threshhold
=0;
4136 unsigned int txlowpower_threshold
=0;
4137 if(priv
->ieee80211
->bdynamic_txpower_enable
!= true)
4139 priv
->bDynamicTxHighPower
= false;
4140 priv
->bDynamicTxLowPower
= false;
4143 //printk("priv->ieee80211->current_network.unknown_cap_exist is %d ,priv->ieee80211->current_network.broadcom_cap_exist is %d\n",priv->ieee80211->current_network.unknown_cap_exist,priv->ieee80211->current_network.broadcom_cap_exist);
4144 if((priv
->ieee80211
->current_network
.atheros_cap_exist
) && (priv
->ieee80211
->mode
== IEEE_G
)){
4145 txhipower_threshhold
= TX_POWER_ATHEROAP_THRESH_HIGH
;
4146 txlowpower_threshold
= TX_POWER_ATHEROAP_THRESH_LOW
;
4150 txhipower_threshhold
= TX_POWER_NEAR_FIELD_THRESH_HIGH
;
4151 txlowpower_threshold
= TX_POWER_NEAR_FIELD_THRESH_LOW
;
4154 // printk("=======>%s(): txhipower_threshhold is %d,txlowpower_threshold is %d\n",__FUNCTION__,txhipower_threshhold,txlowpower_threshold);
4156 RT_TRACE(COMP_TXAGC
,"priv->undecorated_smoothed_pwdb = %ld \n" , priv
->undecorated_smoothed_pwdb
);
4158 if(priv
->ieee80211
->state
== IEEE80211_LINKED
)
4160 if(priv
->undecorated_smoothed_pwdb
>= txhipower_threshhold
)
4162 priv
->bDynamicTxHighPower
= true;
4163 priv
->bDynamicTxLowPower
= false;
4167 // high power state check
4168 if(priv
->undecorated_smoothed_pwdb
< txlowpower_threshold
&& priv
->bDynamicTxHighPower
== true)
4170 priv
->bDynamicTxHighPower
= false;
4172 // low power state check
4173 if(priv
->undecorated_smoothed_pwdb
< 35)
4175 priv
->bDynamicTxLowPower
= true;
4177 else if(priv
->undecorated_smoothed_pwdb
>= 40)
4179 priv
->bDynamicTxLowPower
= false;
4185 //pHalData->bTXPowerCtrlforNearFarRange = !pHalData->bTXPowerCtrlforNearFarRange;
4186 priv
->bDynamicTxHighPower
= false;
4187 priv
->bDynamicTxLowPower
= false;
4190 if( (priv
->bDynamicTxHighPower
!= priv
->bLastDTPFlag_High
) ||
4191 (priv
->bDynamicTxLowPower
!= priv
->bLastDTPFlag_Low
) )
4193 RT_TRACE(COMP_TXAGC
,"SetTxPowerLevel8190() channel = %d \n" , priv
->ieee80211
->current_network
.channel
);
4196 rtl8192_phy_setTxPower(dev
,priv
->ieee80211
->current_network
.channel
);
4199 priv
->bLastDTPFlag_High
= priv
->bDynamicTxHighPower
;
4200 priv
->bLastDTPFlag_Low
= priv
->bDynamicTxLowPower
;
4202 } /* dm_dynamic_txpower */
4204 //added by vivi, for read tx rate and retrycount
4205 static void dm_check_txrateandretrycount(struct net_device
* dev
)
4207 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4208 struct ieee80211_device
* ieee
= priv
->ieee80211
;
4210 // priv->stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);
4211 ieee
->softmac_stats
.CurrentShowTxate
= read_nic_byte(dev
, Current_Tx_Rate_Reg
);
4212 //printk("=============>tx_rate_reg:%x\n", ieee->softmac_stats.CurrentShowTxate);
4213 //for initial tx rate
4214 // priv->stats.last_packet_rate = read_nic_byte(dev, Initial_Tx_Rate_Reg);
4215 ieee
->softmac_stats
.last_packet_rate
= read_nic_byte(dev
,Initial_Tx_Rate_Reg
);
4216 //for tx tx retry count
4217 // priv->stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);
4218 ieee
->softmac_stats
.txretrycount
= read_nic_dword(dev
, Tx_Retry_Count_Reg
);
4221 static void dm_send_rssi_tofw(struct net_device
*dev
)
4223 DCMD_TXCMD_T tx_cmd
;
4224 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4226 // If we test chariot, we should stop the TX command ?
4227 // Because 92E will always silent reset when we send tx command. We use register
4228 // 0x1e0(byte) to botify driver.
4229 write_nic_byte(dev
, DRIVER_RSSI
, (u8
)priv
->undecorated_smoothed_pwdb
);
4232 tx_cmd
.Op
= TXCMD_SET_RX_RSSI
;
4234 tx_cmd
.Value
= priv
->undecorated_smoothed_pwdb
;
4236 cmpk_message_handle_tx(dev
, (u8
*)&tx_cmd
,
4237 DESC_PACKET_TYPE_INIT
, sizeof(DCMD_TXCMD_T
));
4241 /*---------------------------Define function prototype------------------------*/