2 Copyright-c Realtek Semiconductor Corp. All rights reserved.
12 ---------- --------------- -------------------------------
13 2008-05-14 amy create version 0 porting from windows code.
17 #include "r8192U_dm.h"
18 #include "r8192U_hw.h"
19 #include "r819xU_phy.h"
20 #include "r819xU_phyreg.h"
21 #include "r8190_rtl8256.h"
22 #include "r819xU_cmdpkt.h"
23 /*---------------------------Define Local Constant---------------------------*/
24 /* Indicate different AP vendor for IOT issue. */
25 static u32 edca_setting_DL
[HT_IOT_PEER_MAX
] = {
26 0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0x00a44f, 0x5ea44f
28 static u32 edca_setting_UL
[HT_IOT_PEER_MAX
] = {
29 0x5e4322, 0x00a44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f
32 #define RTK_UL_EDCA 0xa44f
33 #define RTK_DL_EDCA 0x5e4322
34 /*---------------------------Define Local Constant---------------------------*/
37 /*------------------------Define global variable-----------------------------*/
38 /* Debug variable ? */
39 struct dig dm_digtable
;
40 /* Store current software write register content for MAC PHY. */
41 u8 dm_shadow
[16][256] = { {0} };
42 /* For Dynamic Rx Path Selection by Signal Strength */
43 struct dynamic_rx_path_sel DM_RxPathSelTable
;
45 /*------------------------Define global variable-----------------------------*/
48 /*------------------------Define local variable------------------------------*/
49 /*------------------------Define local variable------------------------------*/
52 /*--------------------Define export function prototype-----------------------*/
53 extern void dm_check_fsync(struct net_device
*dev
);
55 /*--------------------Define export function prototype-----------------------*/
58 /*---------------------Define local function prototype-----------------------*/
59 /* DM --> Rate Adaptive */
60 static void dm_check_rate_adaptive(struct net_device
*dev
);
62 /* DM --> Bandwidth switch */
63 static void dm_init_bandwidth_autoswitch(struct net_device
*dev
);
64 static void dm_bandwidth_autoswitch(struct net_device
*dev
);
66 /* DM --> TX power control */
67 /*static void dm_initialize_txpower_tracking(struct net_device *dev);*/
69 static void dm_check_txpower_tracking(struct net_device
*dev
);
71 /*static void dm_txpower_reset_recovery(struct net_device *dev);*/
73 /* DM --> Dynamic Init Gain by RSSI */
74 static void dm_dig_init(struct net_device
*dev
);
75 static void dm_ctrl_initgain_byrssi(struct net_device
*dev
);
76 static void dm_ctrl_initgain_byrssi_highpwr(struct net_device
*dev
);
77 static void dm_ctrl_initgain_byrssi_by_driverrssi(struct net_device
*dev
);
78 static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct net_device
*dev
);
79 static void dm_initial_gain(struct net_device
*dev
);
80 static void dm_pd_th(struct net_device
*dev
);
81 static void dm_cs_ratio(struct net_device
*dev
);
83 static void dm_init_ctstoself(struct net_device
*dev
);
84 /* DM --> EDCA turbo mode control */
85 static void dm_check_edca_turbo(struct net_device
*dev
);
87 /*static void dm_gpio_change_rf(struct net_device *dev);*/
88 /* DM --> Check PBC */
89 static void dm_check_pbc_gpio(struct net_device
*dev
);
91 /* DM --> Check current RX RF path state */
92 static void dm_check_rx_path_selection(struct net_device
*dev
);
93 static void dm_init_rxpath_selection(struct net_device
*dev
);
94 static void dm_rxpath_sel_byrssi(struct net_device
*dev
);
96 /* DM --> Fsync for broadcom ap */
97 static void dm_init_fsync(struct net_device
*dev
);
98 static void dm_deInit_fsync(struct net_device
*dev
);
100 /* Added by vivi, 20080522 */
101 static void dm_check_txrateandretrycount(struct net_device
*dev
);
103 /*---------------------Define local function prototype-----------------------*/
105 /*---------------------Define of Tx Power Control For Near/Far Range --------*/ /*Add by Jacken 2008/02/18 */
106 static void dm_init_dynamic_txpower(struct net_device
*dev
);
107 static void dm_dynamic_txpower(struct net_device
*dev
);
109 /* DM --> For rate adaptive and DIG, we must send RSSI to firmware */
110 static void dm_send_rssi_tofw(struct net_device
*dev
);
111 static void dm_ctstoself(struct net_device
*dev
);
112 /*---------------------------Define function prototype------------------------*/
114 * ================================================================================
115 * HW Dynamic mechanism interface.
116 * ================================================================================
120 * Prepare SW resource for HW dynamic mechanism.
123 * This function is only invoked at driver initialization once.
125 void init_hal_dm(struct net_device
*dev
)
127 struct r8192_priv
*priv
= ieee80211_priv(dev
);
129 /* Undecorated Smoothed Signal Strength, it can utilized to dynamic mechanism. */
130 priv
->undecorated_smoothed_pwdb
= -1;
132 /* Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code. */
133 dm_init_dynamic_txpower(dev
);
134 init_rate_adaptive(dev
);
135 /*dm_initialize_txpower_tracking(dev);*/
137 dm_init_edca_turbo(dev
);
138 dm_init_bandwidth_autoswitch(dev
);
140 dm_init_rxpath_selection(dev
);
141 dm_init_ctstoself(dev
);
145 void deinit_hal_dm(struct net_device
*dev
)
147 dm_deInit_fsync(dev
);
150 #ifdef USB_RX_AGGREGATION_SUPPORT
151 void dm_CheckRxAggregation(struct net_device
*dev
)
153 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)dev
);
154 PRT_HIGH_THROUGHPUT pHTInfo
= priv
->ieee80211
->pHTInfo
;
155 static unsigned long lastTxOkCnt
;
156 static unsigned long lastRxOkCnt
;
157 unsigned long curTxOkCnt
= 0;
158 unsigned long curRxOkCnt
= 0;
161 if (pHalData->bForcedUsbRxAggr) {
162 if (pHalData->ForcedUsbRxAggrInfo == 0) {
163 if (pHalData->bCurrentRxAggrEnable) {
164 Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, FALSE);
167 if (!pHalData->bCurrentRxAggrEnable || (pHalData->ForcedUsbRxAggrInfo != pHalData->LastUsbRxAggrInfoSetting)) {
168 Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, TRUE);
175 curTxOkCnt
= priv
->stats
.txbytesunicast
- lastTxOkCnt
;
176 curRxOkCnt
= priv
->stats
.rxbytesunicast
- lastRxOkCnt
;
178 if ((curTxOkCnt
+ curRxOkCnt
) < 15000000)
181 if (curTxOkCnt
> 4*curRxOkCnt
) {
182 if (priv
->bCurrentRxAggrEnable
) {
183 write_nic_dword(dev
, 0x1a8, 0);
184 priv
->bCurrentRxAggrEnable
= false;
187 if (!priv
->bCurrentRxAggrEnable
&& !pHTInfo
->bCurrentRT2RTAggregation
) {
190 ulValue
= (pHTInfo
->UsbRxFwAggrEn
<<24) | (pHTInfo
->UsbRxFwAggrPageNum
<<16) |
191 (pHTInfo
->UsbRxFwAggrPacketNum
<<8) | (pHTInfo
->UsbRxFwAggrTimeout
);
193 * If usb rx firmware aggregation is enabled,
194 * when anyone of three threshold conditions above is reached,
195 * firmware will send aggregated packet to driver.
197 write_nic_dword(dev
, 0x1a8, ulValue
);
198 priv
->bCurrentRxAggrEnable
= true;
202 lastTxOkCnt
= priv
->stats
.txbytesunicast
;
203 lastRxOkCnt
= priv
->stats
.rxbytesunicast
;
204 } /* dm_CheckEdcaTurbo */
207 void hal_dm_watchdog(struct net_device
*dev
)
209 /*struct r8192_priv *priv = ieee80211_priv(dev);*/
211 /*static u8 previous_bssid[6] ={0};*/
213 /*Add by amy 2008/05/15 ,porting from windows code.*/
214 dm_check_rate_adaptive(dev
);
215 dm_dynamic_txpower(dev
);
216 dm_check_txrateandretrycount(dev
);
217 dm_check_txpower_tracking(dev
);
218 dm_ctrl_initgain_byrssi(dev
);
219 dm_check_edca_turbo(dev
);
220 dm_bandwidth_autoswitch(dev
);
221 dm_check_rx_path_selection(dev
);
224 /* Add by amy 2008-05-15 porting from windows code. */
225 dm_check_pbc_gpio(dev
);
226 dm_send_rssi_tofw(dev
);
228 #ifdef USB_RX_AGGREGATION_SUPPORT
229 dm_CheckRxAggregation(dev
);
231 } /* HalDmWatchDog */
234 * Decide Rate Adaptive Set according to distance (signal strength)
235 * 01/11/2008 MHC Modify input arguments and RATR table level.
236 * 01/16/2008 MHC RF_Type is assigned in ReadAdapterInfo(). We must call
237 * the function after making sure RF_Type.
239 void init_rate_adaptive(struct net_device
*dev
)
241 struct r8192_priv
*priv
= ieee80211_priv(dev
);
242 prate_adaptive pra
= (prate_adaptive
)&priv
->rate_adaptive
;
244 pra
->ratr_state
= DM_RATR_STA_MAX
;
245 pra
->high2low_rssi_thresh_for_ra
= RateAdaptiveTH_High
;
246 pra
->low2high_rssi_thresh_for_ra20M
= RateAdaptiveTH_Low_20M
+5;
247 pra
->low2high_rssi_thresh_for_ra40M
= RateAdaptiveTH_Low_40M
+5;
249 pra
->high_rssi_thresh_for_ra
= RateAdaptiveTH_High
+5;
250 pra
->low_rssi_thresh_for_ra20M
= RateAdaptiveTH_Low_20M
;
251 pra
->low_rssi_thresh_for_ra40M
= RateAdaptiveTH_Low_40M
;
253 if (priv
->CustomerID
== RT_CID_819x_Netcore
)
254 pra
->ping_rssi_enable
= 1;
256 pra
->ping_rssi_enable
= 0;
257 pra
->ping_rssi_thresh_for_ra
= 15;
259 if (priv
->rf_type
== RF_2T4R
) {
261 * 07/10/08 MH Modify for RA smooth scheme.
262 * 2008/01/11 MH Modify 2T RATR table for different RSSI. 080515 porting by amy from windows code.
264 pra
->upper_rssi_threshold_ratr
= 0x8f0f0000;
265 pra
->middle_rssi_threshold_ratr
= 0x8f0ff000;
266 pra
->low_rssi_threshold_ratr
= 0x8f0ff001;
267 pra
->low_rssi_threshold_ratr_40M
= 0x8f0ff005;
268 pra
->low_rssi_threshold_ratr_20M
= 0x8f0ff001;
269 pra
->ping_rssi_ratr
= 0x0000000d;/* cosa add for test */
270 } else if (priv
->rf_type
== RF_1T2R
) {
271 pra
->upper_rssi_threshold_ratr
= 0x000f0000;
272 pra
->middle_rssi_threshold_ratr
= 0x000ff000;
273 pra
->low_rssi_threshold_ratr
= 0x000ff001;
274 pra
->low_rssi_threshold_ratr_40M
= 0x000ff005;
275 pra
->low_rssi_threshold_ratr_20M
= 0x000ff001;
276 pra
->ping_rssi_ratr
= 0x0000000d;/* cosa add for test */
279 } /* InitRateAdaptive */
281 /*-----------------------------------------------------------------------------
282 * Function: dm_check_rate_adaptive()
294 * 05/26/08 amy Create version 0 porting from windows code.
296 *---------------------------------------------------------------------------*/
297 static void dm_check_rate_adaptive(struct net_device
*dev
)
299 struct r8192_priv
*priv
= ieee80211_priv(dev
);
300 PRT_HIGH_THROUGHPUT pHTInfo
= priv
->ieee80211
->pHTInfo
;
301 prate_adaptive pra
= (prate_adaptive
)&priv
->rate_adaptive
;
302 u32 currentRATR
, targetRATR
= 0;
303 u32 LowRSSIThreshForRA
= 0, HighRSSIThreshForRA
= 0;
304 bool bshort_gi_enabled
= false;
305 static u8 ping_rssi_state
;
308 RT_TRACE(COMP_RATE
, "<---- dm_check_rate_adaptive(): driver is going to unload\n");
312 if (pra
->rate_adaptive_disabled
) /* this variable is set by ioctl. */
315 /* TODO: Only 11n mode is implemented currently, */
316 if (!(priv
->ieee80211
->mode
== WIRELESS_MODE_N_24G
||
317 priv
->ieee80211
->mode
== WIRELESS_MODE_N_5G
))
320 if (priv
->ieee80211
->state
== IEEE80211_LINKED
) {
321 /*RT_TRACE(COMP_RATE, "dm_CheckRateAdaptive(): \t");*/
323 /* Check whether Short GI is enabled */
324 bshort_gi_enabled
= (pHTInfo
->bCurTxBW40MHz
&& pHTInfo
->bCurShortGI40MHz
) ||
325 (!pHTInfo
->bCurTxBW40MHz
&& pHTInfo
->bCurShortGI20MHz
);
327 pra
->upper_rssi_threshold_ratr
=
328 (pra
->upper_rssi_threshold_ratr
& (~BIT(31))) |
329 ((bshort_gi_enabled
) ? BIT(31) : 0);
331 pra
->middle_rssi_threshold_ratr
=
332 (pra
->middle_rssi_threshold_ratr
& (~BIT(31))) |
333 ((bshort_gi_enabled
) ? BIT(31) : 0);
335 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) {
336 pra
->low_rssi_threshold_ratr
=
337 (pra
->low_rssi_threshold_ratr_40M
& (~BIT(31))) |
338 ((bshort_gi_enabled
) ? BIT(31) : 0);
340 pra
->low_rssi_threshold_ratr
=
341 (pra
->low_rssi_threshold_ratr_20M
& (~BIT(31))) |
342 ((bshort_gi_enabled
) ? BIT(31) : 0);
344 /* cosa add for test */
345 pra
->ping_rssi_ratr
=
346 (pra
->ping_rssi_ratr
& (~BIT(31))) |
347 ((bshort_gi_enabled
) ? BIT(31) : 0);
349 /* 2007/10/08 MH We support RA smooth scheme now. When it is the first
350 time to link with AP. We will not change upper/lower threshold. If
351 STA stay in high or low level, we must change two different threshold
352 to prevent jumping frequently. */
353 if (pra
->ratr_state
== DM_RATR_STA_HIGH
) {
354 HighRSSIThreshForRA
= pra
->high2low_rssi_thresh_for_ra
;
355 LowRSSIThreshForRA
= (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) ?
356 (pra
->low_rssi_thresh_for_ra40M
):(pra
->low_rssi_thresh_for_ra20M
);
357 } else if (pra
->ratr_state
== DM_RATR_STA_LOW
) {
358 HighRSSIThreshForRA
= pra
->high_rssi_thresh_for_ra
;
359 LowRSSIThreshForRA
= (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) ?
360 (pra
->low2high_rssi_thresh_for_ra40M
):(pra
->low2high_rssi_thresh_for_ra20M
);
362 HighRSSIThreshForRA
= pra
->high_rssi_thresh_for_ra
;
363 LowRSSIThreshForRA
= (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) ?
364 (pra
->low_rssi_thresh_for_ra40M
):(pra
->low_rssi_thresh_for_ra20M
);
367 /*DbgPrint("[DM] THresh H/L=%d/%d\n\r", RATR.HighRSSIThreshForRA, RATR.LowRSSIThreshForRA);*/
368 if (priv
->undecorated_smoothed_pwdb
>= (long)HighRSSIThreshForRA
) {
369 /*DbgPrint("[DM] RSSI=%d STA=HIGH\n\r", pHalData->UndecoratedSmoothedPWDB);*/
370 pra
->ratr_state
= DM_RATR_STA_HIGH
;
371 targetRATR
= pra
->upper_rssi_threshold_ratr
;
372 } else if (priv
->undecorated_smoothed_pwdb
>= (long)LowRSSIThreshForRA
) {
373 /*DbgPrint("[DM] RSSI=%d STA=Middle\n\r", pHalData->UndecoratedSmoothedPWDB);*/
374 pra
->ratr_state
= DM_RATR_STA_MIDDLE
;
375 targetRATR
= pra
->middle_rssi_threshold_ratr
;
377 /*DbgPrint("[DM] RSSI=%d STA=LOW\n\r", pHalData->UndecoratedSmoothedPWDB);*/
378 pra
->ratr_state
= DM_RATR_STA_LOW
;
379 targetRATR
= pra
->low_rssi_threshold_ratr
;
382 /* cosa add for test */
383 if (pra
->ping_rssi_enable
) {
384 /*pHalData->UndecoratedSmoothedPWDB = 19;*/
385 if (priv
->undecorated_smoothed_pwdb
< (long)(pra
->ping_rssi_thresh_for_ra
+5)) {
386 if ((priv
->undecorated_smoothed_pwdb
< (long)pra
->ping_rssi_thresh_for_ra
) ||
388 /*DbgPrint("TestRSSI = %d, set RATR to 0x%x\n", pHalData->UndecoratedSmoothedPWDB, pRA->TestRSSIRATR);*/
389 pra
->ratr_state
= DM_RATR_STA_LOW
;
390 targetRATR
= pra
->ping_rssi_ratr
;
394 DbgPrint("TestRSSI is between the range.\n");*/
396 /*DbgPrint("TestRSSI Recover to 0x%x\n", targetRATR);*/
403 * For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
405 if (priv
->ieee80211
->GetHalfNmodeSupportByAPsHandler(dev
))
406 targetRATR
&= 0xf00fffff;
408 /* Check whether updating of RATR0 is required */
409 read_nic_dword(dev
, RATR0
, ¤tRATR
);
410 if (targetRATR
!= currentRATR
) {
413 ratr_value
= targetRATR
;
414 RT_TRACE(COMP_RATE
, "currentRATR = %x, targetRATR = %x\n", currentRATR
, targetRATR
);
415 if (priv
->rf_type
== RF_1T2R
)
416 ratr_value
&= ~(RATE_ALL_OFDM_2SS
);
417 write_nic_dword(dev
, RATR0
, ratr_value
);
418 write_nic_byte(dev
, UFWP
, 1);
420 pra
->last_ratr
= targetRATR
;
424 pra
->ratr_state
= DM_RATR_STA_MAX
;
427 } /* dm_CheckRateAdaptive */
429 static void dm_init_bandwidth_autoswitch(struct net_device
*dev
)
431 struct r8192_priv
*priv
= ieee80211_priv(dev
);
433 priv
->ieee80211
->bandwidth_auto_switch
.threshold_20Mhzto40Mhz
= BW_AUTO_SWITCH_LOW_HIGH
;
434 priv
->ieee80211
->bandwidth_auto_switch
.threshold_40Mhzto20Mhz
= BW_AUTO_SWITCH_HIGH_LOW
;
435 priv
->ieee80211
->bandwidth_auto_switch
.bforced_tx20Mhz
= false;
436 priv
->ieee80211
->bandwidth_auto_switch
.bautoswitch_enable
= false;
438 } /* dm_init_bandwidth_autoswitch */
440 static void dm_bandwidth_autoswitch(struct net_device
*dev
)
442 struct r8192_priv
*priv
= ieee80211_priv(dev
);
444 if (priv
->CurrentChannelBW
== HT_CHANNEL_WIDTH_20
|| !priv
->ieee80211
->bandwidth_auto_switch
.bautoswitch_enable
)
446 if (!priv
->ieee80211
->bandwidth_auto_switch
.bforced_tx20Mhz
) { /* If send packets in 40 Mhz in 20/40 */
447 if (priv
->undecorated_smoothed_pwdb
<= priv
->ieee80211
->bandwidth_auto_switch
.threshold_40Mhzto20Mhz
)
448 priv
->ieee80211
->bandwidth_auto_switch
.bforced_tx20Mhz
= true;
449 } else { /* in force send packets in 20 Mhz in 20/40 */
450 if (priv
->undecorated_smoothed_pwdb
>= priv
->ieee80211
->bandwidth_auto_switch
.threshold_20Mhzto40Mhz
)
451 priv
->ieee80211
->bandwidth_auto_switch
.bforced_tx20Mhz
= false;
453 } /* dm_BandwidthAutoSwitch */
455 /* OFDM default at 0db, index=6. */
456 static u32 OFDMSwingTable
[OFDM_Table_Length
] = {
457 0x7f8001fe, /* 0, +6db */
458 0x71c001c7, /* 1, +5db */
459 0x65400195, /* 2, +4db */
460 0x5a400169, /* 3, +3db */
461 0x50800142, /* 4, +2db */
462 0x47c0011f, /* 5, +1db */
463 0x40000100, /* 6, +0db ===> default, upper for higher temperature, lower for low temperature */
464 0x390000e4, /* 7, -1db */
465 0x32c000cb, /* 8, -2db */
466 0x2d4000b5, /* 9, -3db */
467 0x288000a2, /* 10, -4db */
468 0x24000090, /* 11, -5db */
469 0x20000080, /* 12, -6db */
470 0x1c800072, /* 13, -7db */
471 0x19800066, /* 14, -8db */
472 0x26c0005b, /* 15, -9db */
473 0x24400051, /* 16, -10db */
474 0x12000048, /* 17, -11db */
475 0x10000040 /* 18, -12db */
478 static u8 CCKSwingTable_Ch1_Ch13
[CCK_Table_length
][8] = {
479 {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /* 0, +0db ===> CCK40M default */
480 {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 1, -1db */
481 {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 2, -2db */
482 {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 3, -3db */
483 {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 4, -4db */
484 {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 5, -5db */
485 {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 6, -6db ===> CCK20M default */
486 {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 7, -7db */
487 {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 8, -8db */
488 {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 9, -9db */
489 {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 10, -10db */
490 {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01} /* 11, -11db */
493 static u8 CCKSwingTable_Ch14
[CCK_Table_length
][8] = {
494 {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /* 0, +0db ===> CCK40M default */
495 {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 1, -1db */
496 {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 2, -2db */
497 {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 3, -3db */
498 {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 4, -4db */
499 {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 5, -5db */
500 {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 6, -6db ===> CCK20M default */
501 {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 7, -7db */
502 {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 8, -8db */
503 {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 9, -9db */
504 {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 10, -10db */
505 {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} /* 11, -11db */
508 static void dm_TXPowerTrackingCallback_TSSI(struct net_device
*dev
)
510 struct r8192_priv
*priv
= ieee80211_priv(dev
);
511 bool bHighpowerstate
, viviflag
= false;
513 u8 powerlevelOFDM24G
;
514 int i
= 0, j
= 0, k
= 0;
515 u8 RF_Type
, tmp_report
[5] = {0, 0, 0, 0, 0};
518 u16 Avg_TSSI_Meas
, TSSI_13dBm
, Avg_TSSI_Meas_from_driver
= 0;
519 /*RT_STATUS rtStatus = RT_STATUS_SUCCESS;*/
520 bool rtStatus
= true;
523 write_nic_byte(dev
, 0x1ba, 0);
525 priv
->ieee80211
->bdynamic_txpower_enable
= false;
526 bHighpowerstate
= priv
->bDynamicTxHighPower
;
528 powerlevelOFDM24G
= (u8
)(priv
->Pwr_Track
>>24);
529 RF_Type
= priv
->rf_type
;
530 Value
= (RF_Type
<<8) | powerlevelOFDM24G
;
532 RT_TRACE(COMP_POWER_TRACKING
, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G
);
534 for (j
= 0; j
<= 30; j
++) { /* fill tx_cmd */
535 tx_cmd
.Op
= TXCMD_SET_TX_PWR_TRACKING
;
537 tx_cmd
.Value
= Value
;
538 rtStatus
= SendTxCommandPacket(dev
, &tx_cmd
, 12);
539 if (rtStatus
== RT_STATUS_FAILURE
)
540 RT_TRACE(COMP_POWER_TRACKING
, "Set configuration with tx cmd queue fail!\n");
542 /*DbgPrint("hi, vivi, strange\n");*/
543 for (i
= 0; i
<= 30; i
++) {
544 read_nic_byte(dev
, 0x1ba, &Pwr_Flag
);
550 read_nic_word(dev
, 0x13c, &Avg_TSSI_Meas
);
551 if (Avg_TSSI_Meas
== 0) {
552 write_nic_byte(dev
, 0x1ba, 0);
556 for (k
= 0; k
< 5; k
++) {
558 read_nic_byte(dev
, 0x134+k
, &tmp_report
[k
]);
560 read_nic_byte(dev
, 0x13e, &tmp_report
[k
]);
561 RT_TRACE(COMP_POWER_TRACKING
, "TSSI_report_value = %d\n", tmp_report
[k
]);
564 /* check if the report value is right */
565 for (k
= 0; k
< 5; k
++) {
566 if (tmp_report
[k
] <= 20) {
572 write_nic_byte(dev
, 0x1ba, 0);
574 RT_TRACE(COMP_POWER_TRACKING
, "we filtered the data\n");
575 for (k
= 0; k
< 5; k
++)
580 for (k
= 0; k
< 5; k
++)
581 Avg_TSSI_Meas_from_driver
+= tmp_report
[k
];
583 Avg_TSSI_Meas_from_driver
= Avg_TSSI_Meas_from_driver
*100/5;
584 RT_TRACE(COMP_POWER_TRACKING
, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver
);
585 TSSI_13dBm
= priv
->TSSI_13dBm
;
586 RT_TRACE(COMP_POWER_TRACKING
, "TSSI_13dBm = %d\n", TSSI_13dBm
);
588 /*if (abs(Avg_TSSI_Meas_from_driver - TSSI_13dBm) <= E_FOR_TX_POWER_TRACK)*/
589 /* For MacOS-compatible */
590 if (Avg_TSSI_Meas_from_driver
> TSSI_13dBm
)
591 delta
= Avg_TSSI_Meas_from_driver
- TSSI_13dBm
;
593 delta
= TSSI_13dBm
- Avg_TSSI_Meas_from_driver
;
595 if (delta
<= E_FOR_TX_POWER_TRACK
) {
596 priv
->ieee80211
->bdynamic_txpower_enable
= true;
597 write_nic_byte(dev
, 0x1ba, 0);
598 RT_TRACE(COMP_POWER_TRACKING
, "tx power track is done\n");
599 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfa_txpowertrackingindex = %d\n", priv
->rfa_txpowertrackingindex
);
600 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfa_txpowertrackingindex_real = %d\n", priv
->rfa_txpowertrackingindex_real
);
601 RT_TRACE(COMP_POWER_TRACKING
, "priv->cck_present_attentuation_difference = %d\n", priv
->cck_present_attentuation_difference
);
602 RT_TRACE(COMP_POWER_TRACKING
, "priv->cck_present_attentuation = %d\n", priv
->cck_present_attentuation
);
605 if (Avg_TSSI_Meas_from_driver
< TSSI_13dBm
- E_FOR_TX_POWER_TRACK
) {
606 if (priv
->rfa_txpowertrackingindex
> 0) {
607 priv
->rfa_txpowertrackingindex
--;
608 if (priv
->rfa_txpowertrackingindex_real
> 4) {
609 priv
->rfa_txpowertrackingindex_real
--;
610 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfa_txpowertrackingindex_real
].txbbgain_value
);
614 if (priv
->rfa_txpowertrackingindex
< 36) {
615 priv
->rfa_txpowertrackingindex
++;
616 priv
->rfa_txpowertrackingindex_real
++;
617 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfa_txpowertrackingindex_real
].txbbgain_value
);
621 priv
->cck_present_attentuation_difference
622 = priv
->rfa_txpowertrackingindex
- priv
->rfa_txpowertracking_default
;
624 if (priv
->CurrentChannelBW
== HT_CHANNEL_WIDTH_20
)
625 priv
->cck_present_attentuation
626 = priv
->cck_present_attentuation_20Mdefault
+ priv
->cck_present_attentuation_difference
;
628 priv
->cck_present_attentuation
629 = priv
->cck_present_attentuation_40Mdefault
+ priv
->cck_present_attentuation_difference
;
631 if (priv
->cck_present_attentuation
> -1 && priv
->cck_present_attentuation
< 23) {
632 if (priv
->ieee80211
->current_network
.channel
== 14 && !priv
->bcck_in_ch14
) {
633 priv
->bcck_in_ch14
= true;
634 dm_cck_txpower_adjust(dev
, priv
->bcck_in_ch14
);
635 } else if (priv
->ieee80211
->current_network
.channel
!= 14 && priv
->bcck_in_ch14
) {
636 priv
->bcck_in_ch14
= false;
637 dm_cck_txpower_adjust(dev
, priv
->bcck_in_ch14
);
639 dm_cck_txpower_adjust(dev
, priv
->bcck_in_ch14
);
641 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfa_txpowertrackingindex = %d\n", priv
->rfa_txpowertrackingindex
);
642 RT_TRACE(COMP_POWER_TRACKING
, "priv->rfa_txpowertrackingindex_real = %d\n", priv
->rfa_txpowertrackingindex_real
);
643 RT_TRACE(COMP_POWER_TRACKING
, "priv->cck_present_attentuation_difference = %d\n", priv
->cck_present_attentuation_difference
);
644 RT_TRACE(COMP_POWER_TRACKING
, "priv->cck_present_attentuation = %d\n", priv
->cck_present_attentuation
);
646 if (priv
->cck_present_attentuation_difference
<= -12 || priv
->cck_present_attentuation_difference
>= 24) {
647 priv
->ieee80211
->bdynamic_txpower_enable
= true;
648 write_nic_byte(dev
, 0x1ba, 0);
649 RT_TRACE(COMP_POWER_TRACKING
, "tx power track--->limited\n");
653 write_nic_byte(dev
, 0x1ba, 0);
654 Avg_TSSI_Meas_from_driver
= 0;
655 for (k
= 0; k
< 5; k
++)
660 priv
->ieee80211
->bdynamic_txpower_enable
= true;
661 write_nic_byte(dev
, 0x1ba, 0);
664 static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device
*dev
)
666 #define ThermalMeterVal 9
667 struct r8192_priv
*priv
= ieee80211_priv(dev
);
668 u32 tmpRegA
, TempCCk
;
669 u8 tmpOFDMindex
, tmpCCKindex
, tmpCCK20Mindex
, tmpCCK40Mindex
, tmpval
;
670 int i
= 0, CCKSwingNeedUpdate
= 0;
672 if (!priv
->btxpower_trackingInit
) {
673 /* Query OFDM default setting */
674 tmpRegA
= rtl8192_QueryBBReg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
);
675 for (i
= 0; i
< OFDM_Table_Length
; i
++) { /* find the index */
676 if (tmpRegA
== OFDMSwingTable
[i
]) {
677 priv
->OFDM_index
= (u8
)i
;
678 RT_TRACE(COMP_POWER_TRACKING
, "Initial reg0x%x = 0x%x, OFDM_index=0x%x\n",
679 rOFDM0_XATxIQImbalance
, tmpRegA
, priv
->OFDM_index
);
683 /* Query CCK default setting From 0xa22 */
684 TempCCk
= rtl8192_QueryBBReg(dev
, rCCK0_TxFilter1
, bMaskByte2
);
685 for (i
= 0; i
< CCK_Table_length
; i
++) {
686 if (TempCCk
== (u32
)CCKSwingTable_Ch1_Ch13
[i
][0]) {
687 priv
->CCK_index
= (u8
) i
;
688 RT_TRACE(COMP_POWER_TRACKING
, "Initial reg0x%x = 0x%x, CCK_index=0x%x\n",
689 rCCK0_TxFilter1
, TempCCk
, priv
->CCK_index
);
693 priv
->btxpower_trackingInit
= true;
694 /*pHalData->TXPowercount = 0;*/
699 * ==========================
700 * this is only for test, should be masked
701 * ==========================
704 /* read and filter out unreasonable value */
705 tmpRegA
= rtl8192_phy_QueryRFReg(dev
, RF90_PATH_A
, 0x12, 0x078); /* 0x12: RF Reg[10:7] */
706 RT_TRACE(COMP_POWER_TRACKING
, "Readback ThermalMeterA = %d\n", tmpRegA
);
707 if (tmpRegA
< 3 || tmpRegA
> 13)
709 if (tmpRegA
>= 12) /* if over 12, TP will be bad when high temperature */
711 RT_TRACE(COMP_POWER_TRACKING
, "Valid ThermalMeterA = %d\n", tmpRegA
);
712 priv
->ThermalMeter
[0] = ThermalMeterVal
; /* We use fixed value by Bryant's suggestion */
713 priv
->ThermalMeter
[1] = ThermalMeterVal
; /* We use fixed value by Bryant's suggestion */
715 /* Get current RF-A temperature index */
716 if (priv
->ThermalMeter
[0] >= (u8
)tmpRegA
) { /* lower temperature */
717 tmpOFDMindex
= tmpCCK20Mindex
= 6+(priv
->ThermalMeter
[0]-(u8
)tmpRegA
);
718 tmpCCK40Mindex
= tmpCCK20Mindex
- 6;
719 if (tmpOFDMindex
>= OFDM_Table_Length
)
720 tmpOFDMindex
= OFDM_Table_Length
-1;
721 if (tmpCCK20Mindex
>= CCK_Table_length
)
722 tmpCCK20Mindex
= CCK_Table_length
-1;
723 if (tmpCCK40Mindex
>= CCK_Table_length
)
724 tmpCCK40Mindex
= CCK_Table_length
-1;
726 tmpval
= (u8
)tmpRegA
- priv
->ThermalMeter
[0];
728 if (tmpval
>= 6) /* higher temperature */
729 tmpOFDMindex
= tmpCCK20Mindex
= 0; /* max to +6dB */
731 tmpOFDMindex
= tmpCCK20Mindex
= 6 - tmpval
;
734 /*DbgPrint("%ddb, tmpOFDMindex = %d, tmpCCK20Mindex = %d, tmpCCK40Mindex = %d",
735 ((u1Byte)tmpRegA - pHalData->ThermalMeter[0]),
736 tmpOFDMindex, tmpCCK20Mindex, tmpCCK40Mindex);*/
737 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) /* 40M */
738 tmpCCKindex
= tmpCCK40Mindex
;
740 tmpCCKindex
= tmpCCK20Mindex
;
742 if (priv
->ieee80211
->current_network
.channel
== 14 && !priv
->bcck_in_ch14
) {
743 priv
->bcck_in_ch14
= true;
744 CCKSwingNeedUpdate
= 1;
745 } else if (priv
->ieee80211
->current_network
.channel
!= 14 && priv
->bcck_in_ch14
) {
746 priv
->bcck_in_ch14
= false;
747 CCKSwingNeedUpdate
= 1;
750 if (priv
->CCK_index
!= tmpCCKindex
) {
751 priv
->CCK_index
= tmpCCKindex
;
752 CCKSwingNeedUpdate
= 1;
755 if (CCKSwingNeedUpdate
) {
756 /*DbgPrint("Update CCK Swing, CCK_index = %d\n", pHalData->CCK_index);*/
757 dm_cck_txpower_adjust(dev
, priv
->bcck_in_ch14
);
759 if (priv
->OFDM_index
!= tmpOFDMindex
) {
760 priv
->OFDM_index
= tmpOFDMindex
;
761 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, OFDMSwingTable
[priv
->OFDM_index
]);
762 RT_TRACE(COMP_POWER_TRACKING
, "Update OFDMSwing[%d] = 0x%x\n",
763 priv
->OFDM_index
, OFDMSwingTable
[priv
->OFDM_index
]);
765 priv
->txpower_count
= 0;
768 void dm_txpower_trackingcallback(struct work_struct
*work
)
770 struct delayed_work
*dwork
= container_of(work
, struct delayed_work
, work
);
771 struct r8192_priv
*priv
= container_of(dwork
, struct r8192_priv
, txpower_tracking_wq
);
772 struct net_device
*dev
= priv
->ieee80211
->dev
;
775 dm_TXPowerTrackingCallback_TSSI(dev
);
777 dm_TXPowerTrackingCallback_ThermalMeter(dev
);
780 static void dm_InitializeTXPowerTracking_TSSI(struct net_device
*dev
)
782 struct r8192_priv
*priv
= ieee80211_priv(dev
);
784 /* Initial the Tx BB index and mapping value */
785 priv
->txbbgain_table
[0].txbb_iq_amplifygain
= 12;
786 priv
->txbbgain_table
[0].txbbgain_value
= 0x7f8001fe;
787 priv
->txbbgain_table
[1].txbb_iq_amplifygain
= 11;
788 priv
->txbbgain_table
[1].txbbgain_value
= 0x788001e2;
789 priv
->txbbgain_table
[2].txbb_iq_amplifygain
= 10;
790 priv
->txbbgain_table
[2].txbbgain_value
= 0x71c001c7;
791 priv
->txbbgain_table
[3].txbb_iq_amplifygain
= 9;
792 priv
->txbbgain_table
[3].txbbgain_value
= 0x6b8001ae;
793 priv
->txbbgain_table
[4].txbb_iq_amplifygain
= 8;
794 priv
->txbbgain_table
[4].txbbgain_value
= 0x65400195;
795 priv
->txbbgain_table
[5].txbb_iq_amplifygain
= 7;
796 priv
->txbbgain_table
[5].txbbgain_value
= 0x5fc0017f;
797 priv
->txbbgain_table
[6].txbb_iq_amplifygain
= 6;
798 priv
->txbbgain_table
[6].txbbgain_value
= 0x5a400169;
799 priv
->txbbgain_table
[7].txbb_iq_amplifygain
= 5;
800 priv
->txbbgain_table
[7].txbbgain_value
= 0x55400155;
801 priv
->txbbgain_table
[8].txbb_iq_amplifygain
= 4;
802 priv
->txbbgain_table
[8].txbbgain_value
= 0x50800142;
803 priv
->txbbgain_table
[9].txbb_iq_amplifygain
= 3;
804 priv
->txbbgain_table
[9].txbbgain_value
= 0x4c000130;
805 priv
->txbbgain_table
[10].txbb_iq_amplifygain
= 2;
806 priv
->txbbgain_table
[10].txbbgain_value
= 0x47c0011f;
807 priv
->txbbgain_table
[11].txbb_iq_amplifygain
= 1;
808 priv
->txbbgain_table
[11].txbbgain_value
= 0x43c0010f;
809 priv
->txbbgain_table
[12].txbb_iq_amplifygain
= 0;
810 priv
->txbbgain_table
[12].txbbgain_value
= 0x40000100;
811 priv
->txbbgain_table
[13].txbb_iq_amplifygain
= -1;
812 priv
->txbbgain_table
[13].txbbgain_value
= 0x3c8000f2;
813 priv
->txbbgain_table
[14].txbb_iq_amplifygain
= -2;
814 priv
->txbbgain_table
[14].txbbgain_value
= 0x390000e4;
815 priv
->txbbgain_table
[15].txbb_iq_amplifygain
= -3;
816 priv
->txbbgain_table
[15].txbbgain_value
= 0x35c000d7;
817 priv
->txbbgain_table
[16].txbb_iq_amplifygain
= -4;
818 priv
->txbbgain_table
[16].txbbgain_value
= 0x32c000cb;
819 priv
->txbbgain_table
[17].txbb_iq_amplifygain
= -5;
820 priv
->txbbgain_table
[17].txbbgain_value
= 0x300000c0;
821 priv
->txbbgain_table
[18].txbb_iq_amplifygain
= -6;
822 priv
->txbbgain_table
[18].txbbgain_value
= 0x2d4000b5;
823 priv
->txbbgain_table
[19].txbb_iq_amplifygain
= -7;
824 priv
->txbbgain_table
[19].txbbgain_value
= 0x2ac000ab;
825 priv
->txbbgain_table
[20].txbb_iq_amplifygain
= -8;
826 priv
->txbbgain_table
[20].txbbgain_value
= 0x288000a2;
827 priv
->txbbgain_table
[21].txbb_iq_amplifygain
= -9;
828 priv
->txbbgain_table
[21].txbbgain_value
= 0x26000098;
829 priv
->txbbgain_table
[22].txbb_iq_amplifygain
= -10;
830 priv
->txbbgain_table
[22].txbbgain_value
= 0x24000090;
831 priv
->txbbgain_table
[23].txbb_iq_amplifygain
= -11;
832 priv
->txbbgain_table
[23].txbbgain_value
= 0x22000088;
833 priv
->txbbgain_table
[24].txbb_iq_amplifygain
= -12;
834 priv
->txbbgain_table
[24].txbbgain_value
= 0x20000080;
835 priv
->txbbgain_table
[25].txbb_iq_amplifygain
= -13;
836 priv
->txbbgain_table
[25].txbbgain_value
= 0x1a00006c;
837 priv
->txbbgain_table
[26].txbb_iq_amplifygain
= -14;
838 priv
->txbbgain_table
[26].txbbgain_value
= 0x1c800072;
839 priv
->txbbgain_table
[27].txbb_iq_amplifygain
= -15;
840 priv
->txbbgain_table
[27].txbbgain_value
= 0x18000060;
841 priv
->txbbgain_table
[28].txbb_iq_amplifygain
= -16;
842 priv
->txbbgain_table
[28].txbbgain_value
= 0x19800066;
843 priv
->txbbgain_table
[29].txbb_iq_amplifygain
= -17;
844 priv
->txbbgain_table
[29].txbbgain_value
= 0x15800056;
845 priv
->txbbgain_table
[30].txbb_iq_amplifygain
= -18;
846 priv
->txbbgain_table
[30].txbbgain_value
= 0x26c0005b;
847 priv
->txbbgain_table
[31].txbb_iq_amplifygain
= -19;
848 priv
->txbbgain_table
[31].txbbgain_value
= 0x14400051;
849 priv
->txbbgain_table
[32].txbb_iq_amplifygain
= -20;
850 priv
->txbbgain_table
[32].txbbgain_value
= 0x24400051;
851 priv
->txbbgain_table
[33].txbb_iq_amplifygain
= -21;
852 priv
->txbbgain_table
[33].txbbgain_value
= 0x1300004c;
853 priv
->txbbgain_table
[34].txbb_iq_amplifygain
= -22;
854 priv
->txbbgain_table
[34].txbbgain_value
= 0x12000048;
855 priv
->txbbgain_table
[35].txbb_iq_amplifygain
= -23;
856 priv
->txbbgain_table
[35].txbbgain_value
= 0x11000044;
857 priv
->txbbgain_table
[36].txbb_iq_amplifygain
= -24;
858 priv
->txbbgain_table
[36].txbbgain_value
= 0x10000040;
861 * ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
862 * This Table is for CH1~CH13
864 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[0] = 0x36;
865 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[1] = 0x35;
866 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[2] = 0x2e;
867 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[3] = 0x25;
868 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[4] = 0x1c;
869 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[5] = 0x12;
870 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[6] = 0x09;
871 priv
->cck_txbbgain_table
[0].ccktxbb_valuearray
[7] = 0x04;
873 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[0] = 0x33;
874 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[1] = 0x32;
875 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[2] = 0x2b;
876 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[3] = 0x23;
877 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[4] = 0x1a;
878 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[5] = 0x11;
879 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[6] = 0x08;
880 priv
->cck_txbbgain_table
[1].ccktxbb_valuearray
[7] = 0x04;
882 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[0] = 0x30;
883 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[1] = 0x2f;
884 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[2] = 0x29;
885 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[3] = 0x21;
886 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[4] = 0x19;
887 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[5] = 0x10;
888 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[6] = 0x08;
889 priv
->cck_txbbgain_table
[2].ccktxbb_valuearray
[7] = 0x03;
891 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[0] = 0x2d;
892 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[1] = 0x2d;
893 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[2] = 0x27;
894 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[3] = 0x1f;
895 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[4] = 0x18;
896 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[5] = 0x0f;
897 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[6] = 0x08;
898 priv
->cck_txbbgain_table
[3].ccktxbb_valuearray
[7] = 0x03;
900 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[0] = 0x2b;
901 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[1] = 0x2a;
902 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[2] = 0x25;
903 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[3] = 0x1e;
904 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[4] = 0x16;
905 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[5] = 0x0e;
906 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[6] = 0x07;
907 priv
->cck_txbbgain_table
[4].ccktxbb_valuearray
[7] = 0x03;
909 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[0] = 0x28;
910 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[1] = 0x28;
911 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[2] = 0x22;
912 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[3] = 0x1c;
913 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[4] = 0x15;
914 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[5] = 0x0d;
915 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[6] = 0x07;
916 priv
->cck_txbbgain_table
[5].ccktxbb_valuearray
[7] = 0x03;
918 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[0] = 0x26;
919 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[1] = 0x25;
920 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[2] = 0x21;
921 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[3] = 0x1b;
922 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[4] = 0x14;
923 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[5] = 0x0d;
924 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[6] = 0x06;
925 priv
->cck_txbbgain_table
[6].ccktxbb_valuearray
[7] = 0x03;
927 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[0] = 0x24;
928 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[1] = 0x23;
929 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[2] = 0x1f;
930 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[3] = 0x19;
931 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[4] = 0x13;
932 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[5] = 0x0c;
933 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[6] = 0x06;
934 priv
->cck_txbbgain_table
[7].ccktxbb_valuearray
[7] = 0x03;
936 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[0] = 0x22;
937 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[1] = 0x21;
938 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[2] = 0x1d;
939 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[3] = 0x18;
940 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[4] = 0x11;
941 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[5] = 0x0b;
942 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[6] = 0x06;
943 priv
->cck_txbbgain_table
[8].ccktxbb_valuearray
[7] = 0x02;
945 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[0] = 0x20;
946 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[1] = 0x20;
947 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[2] = 0x1b;
948 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[3] = 0x16;
949 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[4] = 0x11;
950 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[5] = 0x08;
951 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[6] = 0x05;
952 priv
->cck_txbbgain_table
[9].ccktxbb_valuearray
[7] = 0x02;
954 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[0] = 0x1f;
955 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[1] = 0x1e;
956 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[2] = 0x1a;
957 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[3] = 0x15;
958 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[4] = 0x10;
959 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[5] = 0x0a;
960 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[6] = 0x05;
961 priv
->cck_txbbgain_table
[10].ccktxbb_valuearray
[7] = 0x02;
963 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[0] = 0x1d;
964 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[1] = 0x1c;
965 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[2] = 0x18;
966 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[3] = 0x14;
967 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[4] = 0x0f;
968 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[5] = 0x0a;
969 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[6] = 0x05;
970 priv
->cck_txbbgain_table
[11].ccktxbb_valuearray
[7] = 0x02;
972 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[0] = 0x1b;
973 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[1] = 0x1a;
974 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[2] = 0x17;
975 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[3] = 0x13;
976 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[4] = 0x0e;
977 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[5] = 0x09;
978 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[6] = 0x04;
979 priv
->cck_txbbgain_table
[12].ccktxbb_valuearray
[7] = 0x02;
981 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[0] = 0x1a;
982 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[1] = 0x19;
983 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[2] = 0x16;
984 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[3] = 0x12;
985 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[4] = 0x0d;
986 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[5] = 0x09;
987 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[6] = 0x04;
988 priv
->cck_txbbgain_table
[13].ccktxbb_valuearray
[7] = 0x02;
990 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[0] = 0x18;
991 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[1] = 0x17;
992 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[2] = 0x15;
993 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[3] = 0x11;
994 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[4] = 0x0c;
995 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[5] = 0x08;
996 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[6] = 0x04;
997 priv
->cck_txbbgain_table
[14].ccktxbb_valuearray
[7] = 0x02;
999 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[0] = 0x17;
1000 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[1] = 0x16;
1001 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[2] = 0x13;
1002 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[3] = 0x10;
1003 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[4] = 0x0c;
1004 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[5] = 0x08;
1005 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[6] = 0x04;
1006 priv
->cck_txbbgain_table
[15].ccktxbb_valuearray
[7] = 0x02;
1008 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[0] = 0x16;
1009 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[1] = 0x15;
1010 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[2] = 0x12;
1011 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[3] = 0x0f;
1012 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[4] = 0x0b;
1013 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[5] = 0x07;
1014 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[6] = 0x04;
1015 priv
->cck_txbbgain_table
[16].ccktxbb_valuearray
[7] = 0x01;
1017 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[0] = 0x14;
1018 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[1] = 0x14;
1019 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[2] = 0x11;
1020 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[3] = 0x0e;
1021 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[4] = 0x0b;
1022 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[5] = 0x07;
1023 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[6] = 0x03;
1024 priv
->cck_txbbgain_table
[17].ccktxbb_valuearray
[7] = 0x02;
1026 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[0] = 0x13;
1027 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[1] = 0x13;
1028 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[2] = 0x10;
1029 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[3] = 0x0d;
1030 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[4] = 0x0a;
1031 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[5] = 0x06;
1032 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[6] = 0x03;
1033 priv
->cck_txbbgain_table
[18].ccktxbb_valuearray
[7] = 0x01;
1035 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[0] = 0x12;
1036 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[1] = 0x12;
1037 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[2] = 0x0f;
1038 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[3] = 0x0c;
1039 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[4] = 0x09;
1040 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[5] = 0x06;
1041 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[6] = 0x03;
1042 priv
->cck_txbbgain_table
[19].ccktxbb_valuearray
[7] = 0x01;
1044 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[0] = 0x11;
1045 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[1] = 0x11;
1046 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[2] = 0x0f;
1047 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[3] = 0x0c;
1048 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[4] = 0x09;
1049 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[5] = 0x06;
1050 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[6] = 0x03;
1051 priv
->cck_txbbgain_table
[20].ccktxbb_valuearray
[7] = 0x01;
1053 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[0] = 0x10;
1054 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[1] = 0x10;
1055 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[2] = 0x0e;
1056 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[3] = 0x0b;
1057 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[4] = 0x08;
1058 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[5] = 0x05;
1059 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[6] = 0x03;
1060 priv
->cck_txbbgain_table
[21].ccktxbb_valuearray
[7] = 0x01;
1062 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[0] = 0x0f;
1063 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[1] = 0x0f;
1064 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[2] = 0x0d;
1065 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[3] = 0x0b;
1066 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[4] = 0x08;
1067 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[5] = 0x05;
1068 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[6] = 0x03;
1069 priv
->cck_txbbgain_table
[22].ccktxbb_valuearray
[7] = 0x01;
1072 * ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
1073 * This Table is for CH14
1075 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[0] = 0x36;
1076 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[1] = 0x35;
1077 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[2] = 0x2e;
1078 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[3] = 0x1b;
1079 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[4] = 0x00;
1080 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[5] = 0x00;
1081 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[6] = 0x00;
1082 priv
->cck_txbbgain_ch14_table
[0].ccktxbb_valuearray
[7] = 0x00;
1084 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[0] = 0x33;
1085 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[1] = 0x32;
1086 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[2] = 0x2b;
1087 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[3] = 0x19;
1088 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[4] = 0x00;
1089 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[5] = 0x00;
1090 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[6] = 0x00;
1091 priv
->cck_txbbgain_ch14_table
[1].ccktxbb_valuearray
[7] = 0x00;
1093 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[0] = 0x30;
1094 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[1] = 0x2f;
1095 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[2] = 0x29;
1096 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[3] = 0x18;
1097 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[4] = 0x00;
1098 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[5] = 0x00;
1099 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[6] = 0x00;
1100 priv
->cck_txbbgain_ch14_table
[2].ccktxbb_valuearray
[7] = 0x00;
1102 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[0] = 0x2d;
1103 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[1] = 0x2d;
1104 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[2] = 0x27;
1105 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[3] = 0x17;
1106 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[4] = 0x00;
1107 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[5] = 0x00;
1108 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[6] = 0x00;
1109 priv
->cck_txbbgain_ch14_table
[3].ccktxbb_valuearray
[7] = 0x00;
1111 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[0] = 0x2b;
1112 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[1] = 0x2a;
1113 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[2] = 0x25;
1114 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[3] = 0x15;
1115 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[4] = 0x00;
1116 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[5] = 0x00;
1117 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[6] = 0x00;
1118 priv
->cck_txbbgain_ch14_table
[4].ccktxbb_valuearray
[7] = 0x00;
1120 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[0] = 0x28;
1121 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[1] = 0x28;
1122 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[2] = 0x22;
1123 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[3] = 0x14;
1124 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[4] = 0x00;
1125 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[5] = 0x00;
1126 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[6] = 0x00;
1127 priv
->cck_txbbgain_ch14_table
[5].ccktxbb_valuearray
[7] = 0x00;
1129 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[0] = 0x26;
1130 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[1] = 0x25;
1131 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[2] = 0x21;
1132 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[3] = 0x13;
1133 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[4] = 0x00;
1134 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[5] = 0x00;
1135 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[6] = 0x00;
1136 priv
->cck_txbbgain_ch14_table
[6].ccktxbb_valuearray
[7] = 0x00;
1138 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[0] = 0x24;
1139 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[1] = 0x23;
1140 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[2] = 0x1f;
1141 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[3] = 0x12;
1142 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[4] = 0x00;
1143 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[5] = 0x00;
1144 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[6] = 0x00;
1145 priv
->cck_txbbgain_ch14_table
[7].ccktxbb_valuearray
[7] = 0x00;
1147 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[0] = 0x22;
1148 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[1] = 0x21;
1149 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[2] = 0x1d;
1150 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[3] = 0x11;
1151 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[4] = 0x00;
1152 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[5] = 0x00;
1153 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[6] = 0x00;
1154 priv
->cck_txbbgain_ch14_table
[8].ccktxbb_valuearray
[7] = 0x00;
1156 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[0] = 0x20;
1157 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[1] = 0x20;
1158 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[2] = 0x1b;
1159 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[3] = 0x10;
1160 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[4] = 0x00;
1161 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[5] = 0x00;
1162 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[6] = 0x00;
1163 priv
->cck_txbbgain_ch14_table
[9].ccktxbb_valuearray
[7] = 0x00;
1165 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[0] = 0x1f;
1166 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[1] = 0x1e;
1167 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[2] = 0x1a;
1168 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[3] = 0x0f;
1169 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[4] = 0x00;
1170 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[5] = 0x00;
1171 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[6] = 0x00;
1172 priv
->cck_txbbgain_ch14_table
[10].ccktxbb_valuearray
[7] = 0x00;
1174 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[0] = 0x1d;
1175 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[1] = 0x1c;
1176 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[2] = 0x18;
1177 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[3] = 0x0e;
1178 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[4] = 0x00;
1179 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[5] = 0x00;
1180 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[6] = 0x00;
1181 priv
->cck_txbbgain_ch14_table
[11].ccktxbb_valuearray
[7] = 0x00;
1183 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[0] = 0x1b;
1184 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[1] = 0x1a;
1185 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[2] = 0x17;
1186 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[3] = 0x0e;
1187 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[4] = 0x00;
1188 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[5] = 0x00;
1189 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[6] = 0x00;
1190 priv
->cck_txbbgain_ch14_table
[12].ccktxbb_valuearray
[7] = 0x00;
1192 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[0] = 0x1a;
1193 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[1] = 0x19;
1194 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[2] = 0x16;
1195 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[3] = 0x0d;
1196 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[4] = 0x00;
1197 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[5] = 0x00;
1198 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[6] = 0x00;
1199 priv
->cck_txbbgain_ch14_table
[13].ccktxbb_valuearray
[7] = 0x00;
1201 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[0] = 0x18;
1202 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[1] = 0x17;
1203 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[2] = 0x15;
1204 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[3] = 0x0c;
1205 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[4] = 0x00;
1206 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[5] = 0x00;
1207 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[6] = 0x00;
1208 priv
->cck_txbbgain_ch14_table
[14].ccktxbb_valuearray
[7] = 0x00;
1210 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[0] = 0x17;
1211 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[1] = 0x16;
1212 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[2] = 0x13;
1213 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[3] = 0x0b;
1214 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[4] = 0x00;
1215 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[5] = 0x00;
1216 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[6] = 0x00;
1217 priv
->cck_txbbgain_ch14_table
[15].ccktxbb_valuearray
[7] = 0x00;
1219 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[0] = 0x16;
1220 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[1] = 0x15;
1221 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[2] = 0x12;
1222 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[3] = 0x0b;
1223 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[4] = 0x00;
1224 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[5] = 0x00;
1225 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[6] = 0x00;
1226 priv
->cck_txbbgain_ch14_table
[16].ccktxbb_valuearray
[7] = 0x00;
1228 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[0] = 0x14;
1229 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[1] = 0x14;
1230 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[2] = 0x11;
1231 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[3] = 0x0a;
1232 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[4] = 0x00;
1233 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[5] = 0x00;
1234 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[6] = 0x00;
1235 priv
->cck_txbbgain_ch14_table
[17].ccktxbb_valuearray
[7] = 0x00;
1237 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[0] = 0x13;
1238 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[1] = 0x13;
1239 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[2] = 0x10;
1240 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[3] = 0x0a;
1241 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[4] = 0x00;
1242 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[5] = 0x00;
1243 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[6] = 0x00;
1244 priv
->cck_txbbgain_ch14_table
[18].ccktxbb_valuearray
[7] = 0x00;
1246 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[0] = 0x12;
1247 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[1] = 0x12;
1248 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[2] = 0x0f;
1249 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[3] = 0x09;
1250 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[4] = 0x00;
1251 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[5] = 0x00;
1252 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[6] = 0x00;
1253 priv
->cck_txbbgain_ch14_table
[19].ccktxbb_valuearray
[7] = 0x00;
1255 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[0] = 0x11;
1256 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[1] = 0x11;
1257 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[2] = 0x0f;
1258 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[3] = 0x09;
1259 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[4] = 0x00;
1260 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[5] = 0x00;
1261 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[6] = 0x00;
1262 priv
->cck_txbbgain_ch14_table
[20].ccktxbb_valuearray
[7] = 0x00;
1264 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[0] = 0x10;
1265 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[1] = 0x10;
1266 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[2] = 0x0e;
1267 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[3] = 0x08;
1268 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[4] = 0x00;
1269 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[5] = 0x00;
1270 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[6] = 0x00;
1271 priv
->cck_txbbgain_ch14_table
[21].ccktxbb_valuearray
[7] = 0x00;
1273 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[0] = 0x0f;
1274 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[1] = 0x0f;
1275 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[2] = 0x0d;
1276 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[3] = 0x08;
1277 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[4] = 0x00;
1278 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[5] = 0x00;
1279 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[6] = 0x00;
1280 priv
->cck_txbbgain_ch14_table
[22].ccktxbb_valuearray
[7] = 0x00;
1282 priv
->btxpower_tracking
= true;
1283 priv
->txpower_count
= 0;
1284 priv
->btxpower_trackingInit
= false;
1288 static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device
*dev
)
1290 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1293 * Tx Power tracking by Thermal Meter requires Firmware R/W 3-wire. This mechanism
1294 * can be enabled only when Firmware R/W 3-wire is enabled. Otherwise, frequent r/w
1295 * 3-wire by driver causes RF to go into a wrong state.
1297 if (priv
->ieee80211
->FwRWRF
)
1298 priv
->btxpower_tracking
= true;
1300 priv
->btxpower_tracking
= false;
1301 priv
->txpower_count
= 0;
1302 priv
->btxpower_trackingInit
= false;
1305 void dm_initialize_txpower_tracking(struct net_device
*dev
)
1307 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1310 dm_InitializeTXPowerTracking_TSSI(dev
);
1312 dm_InitializeTXPowerTracking_ThermalMeter(dev
);
1313 } /* dm_InitializeTXPowerTracking */
1315 static void dm_CheckTXPowerTracking_TSSI(struct net_device
*dev
)
1317 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1318 static u32 tx_power_track_counter
;
1320 if (!priv
->btxpower_tracking
)
1322 if ((tx_power_track_counter
% 30 == 0) && (tx_power_track_counter
!= 0))
1323 queue_delayed_work(priv
->priv_wq
, &priv
->txpower_tracking_wq
, 0);
1324 tx_power_track_counter
++;
1327 static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device
*dev
)
1329 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1330 static u8 TM_Trigger
;
1331 /*DbgPrint("dm_CheckTXPowerTracking()\n");*/
1332 if (!priv
->btxpower_tracking
)
1334 if (priv
->txpower_count
<= 2) {
1335 priv
->txpower_count
++;
1341 * Attention!! You have to write all 12bits of data to RF, or it may cause RF to crash
1342 * actually write reg0x02 bit1=0, then bit1=1.
1343 * DbgPrint("Trigger ThermalMeter, write RF reg0x2 = 0x4d to 0x4f\n");
1345 rtl8192_phy_SetRFReg(dev
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4d);
1346 rtl8192_phy_SetRFReg(dev
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4f);
1347 rtl8192_phy_SetRFReg(dev
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4d);
1348 rtl8192_phy_SetRFReg(dev
, RF90_PATH_A
, 0x02, bMask12Bits
, 0x4f);
1352 /*DbgPrint("Schedule TxPowerTrackingWorkItem\n");*/
1353 queue_delayed_work(priv
->priv_wq
, &priv
->txpower_tracking_wq
, 0);
1357 static void dm_check_txpower_tracking(struct net_device
*dev
)
1359 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1360 /*static u32 tx_power_track_counter = 0;*/
1363 dm_CheckTXPowerTracking_TSSI(dev
);
1366 dm_CheckTXPowerTracking_TSSI(dev
);
1368 dm_CheckTXPowerTracking_ThermalMeter(dev
);
1371 } /* dm_CheckTXPowerTracking */
1373 static void dm_CCKTxPowerAdjust_TSSI(struct net_device
*dev
, bool bInCH14
)
1376 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1378 /* Write 0xa22 0xa23 */
1381 /* Write 0xa22 0xa23 */
1382 TempVal
= priv
->cck_txbbgain_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[0] +
1383 (priv
->cck_txbbgain_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[1]<<8);
1385 rtl8192_setBBreg(dev
, rCCK0_TxFilter1
, bMaskHWord
, TempVal
);
1386 /* Write 0xa24 ~ 0xa27 */
1387 TempVal
= priv
->cck_txbbgain_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[2] +
1388 (priv
->cck_txbbgain_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[3]<<8) +
1389 (priv
->cck_txbbgain_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[4]<<16)+
1390 (priv
->cck_txbbgain_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[5]<<24);
1391 rtl8192_setBBreg(dev
, rCCK0_TxFilter2
, bMaskDWord
, TempVal
);
1392 /* Write 0xa28 0xa29 */
1393 TempVal
= priv
->cck_txbbgain_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[6] +
1394 (priv
->cck_txbbgain_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[7]<<8);
1396 rtl8192_setBBreg(dev
, rCCK0_DebugPort
, bMaskLWord
, TempVal
);
1398 TempVal
= priv
->cck_txbbgain_ch14_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[0] +
1399 (priv
->cck_txbbgain_ch14_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[1]<<8);
1401 rtl8192_setBBreg(dev
, rCCK0_TxFilter1
, bMaskHWord
, TempVal
);
1402 /* Write 0xa24 ~ 0xa27 */
1403 TempVal
= priv
->cck_txbbgain_ch14_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[2] +
1404 (priv
->cck_txbbgain_ch14_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[3]<<8) +
1405 (priv
->cck_txbbgain_ch14_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[4]<<16)+
1406 (priv
->cck_txbbgain_ch14_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[5]<<24);
1407 rtl8192_setBBreg(dev
, rCCK0_TxFilter2
, bMaskDWord
, TempVal
);
1408 /* Write 0xa28 0xa29 */
1409 TempVal
= priv
->cck_txbbgain_ch14_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[6] +
1410 (priv
->cck_txbbgain_ch14_table
[priv
->cck_present_attentuation
].ccktxbb_valuearray
[7]<<8);
1412 rtl8192_setBBreg(dev
, rCCK0_DebugPort
, bMaskLWord
, TempVal
);
1416 static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device
*dev
, bool bInCH14
)
1419 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1423 /* Write 0xa22 0xa23 */
1424 TempVal
= CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][0] +
1425 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][1]<<8);
1426 rtl8192_setBBreg(dev
, rCCK0_TxFilter1
, bMaskHWord
, TempVal
);
1427 RT_TRACE(COMP_POWER_TRACKING
, "CCK not chnl 14, reg 0x%x = 0x%x\n",
1428 rCCK0_TxFilter1
, TempVal
);
1429 /* Write 0xa24 ~ 0xa27 */
1430 TempVal
= CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][2] +
1431 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][3]<<8) +
1432 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][4]<<16)+
1433 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][5]<<24);
1434 rtl8192_setBBreg(dev
, rCCK0_TxFilter2
, bMaskDWord
, TempVal
);
1435 RT_TRACE(COMP_POWER_TRACKING
, "CCK not chnl 14, reg 0x%x = 0x%x\n",
1436 rCCK0_TxFilter2
, TempVal
);
1437 /* Write 0xa28 0xa29 */
1438 TempVal
= CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][6] +
1439 (CCKSwingTable_Ch1_Ch13
[priv
->CCK_index
][7]<<8);
1441 rtl8192_setBBreg(dev
, rCCK0_DebugPort
, bMaskLWord
, TempVal
);
1442 RT_TRACE(COMP_POWER_TRACKING
, "CCK not chnl 14, reg 0x%x = 0x%x\n",
1443 rCCK0_DebugPort
, TempVal
);
1445 /*priv->CCKTxPowerAdjustCntNotCh14++; cosa add for debug.*/
1446 /* Write 0xa22 0xa23 */
1447 TempVal
= CCKSwingTable_Ch14
[priv
->CCK_index
][0] +
1448 (CCKSwingTable_Ch14
[priv
->CCK_index
][1]<<8);
1450 rtl8192_setBBreg(dev
, rCCK0_TxFilter1
, bMaskHWord
, TempVal
);
1451 RT_TRACE(COMP_POWER_TRACKING
, "CCK chnl 14, reg 0x%x = 0x%x\n",
1452 rCCK0_TxFilter1
, TempVal
);
1453 /* Write 0xa24 ~ 0xa27 */
1454 TempVal
= CCKSwingTable_Ch14
[priv
->CCK_index
][2] +
1455 (CCKSwingTable_Ch14
[priv
->CCK_index
][3]<<8) +
1456 (CCKSwingTable_Ch14
[priv
->CCK_index
][4]<<16)+
1457 (CCKSwingTable_Ch14
[priv
->CCK_index
][5]<<24);
1458 rtl8192_setBBreg(dev
, rCCK0_TxFilter2
, bMaskDWord
, TempVal
);
1459 RT_TRACE(COMP_POWER_TRACKING
, "CCK chnl 14, reg 0x%x = 0x%x\n",
1460 rCCK0_TxFilter2
, TempVal
);
1461 /* Write 0xa28 0xa29 */
1462 TempVal
= CCKSwingTable_Ch14
[priv
->CCK_index
][6] +
1463 (CCKSwingTable_Ch14
[priv
->CCK_index
][7]<<8);
1465 rtl8192_setBBreg(dev
, rCCK0_DebugPort
, bMaskLWord
, TempVal
);
1466 RT_TRACE(COMP_POWER_TRACKING
, "CCK chnl 14, reg 0x%x = 0x%x\n",
1467 rCCK0_DebugPort
, TempVal
);
1471 void dm_cck_txpower_adjust(struct net_device
*dev
, bool binch14
)
1472 { /* dm_CCKTxPowerAdjust */
1473 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1476 dm_CCKTxPowerAdjust_TSSI(dev
, binch14
);
1478 dm_CCKTxPowerAdjust_ThermalMeter(dev
, binch14
);
1482 static void dm_txpower_reset_recovery(
1483 struct net_device
*dev
1486 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1488 RT_TRACE(COMP_POWER_TRACKING
, "Start Reset Recovery ==>\n");
1489 rtl8192_setBBreg(dev
, rOFDM0_XATxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfa_txpowertrackingindex
].txbbgain_value
);
1490 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: Fill in 0xc80 is %08x\n", priv
->txbbgain_table
[priv
->rfa_txpowertrackingindex
].txbbgain_value
);
1491 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n", priv
->rfa_txpowertrackingindex
);
1492 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
);
1493 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: CCK Attenuation is %d dB\n", priv
->cck_present_attentuation
);
1494 dm_cck_txpower_adjust(dev
, priv
->bcck_in_ch14
);
1496 rtl8192_setBBreg(dev
, rOFDM0_XCTxIQImbalance
, bMaskDWord
, priv
->txbbgain_table
[priv
->rfc_txpowertrackingindex
].txbbgain_value
);
1497 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: Fill in 0xc90 is %08x\n", priv
->txbbgain_table
[priv
->rfc_txpowertrackingindex
].txbbgain_value
);
1498 RT_TRACE(COMP_POWER_TRACKING
, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n", priv
->rfc_txpowertrackingindex
);
1499 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
);
1501 } /* dm_TXPowerResetRecovery */
1503 void dm_restore_dynamic_mechanism_state(struct net_device
*dev
)
1505 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1506 u32 reg_ratr
= priv
->rate_adaptive
.last_ratr
;
1509 RT_TRACE(COMP_RATE
, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n");
1513 /* Restore previous state for rate adaptive */
1514 if (priv
->rate_adaptive
.rate_adaptive_disabled
)
1516 /* TODO: Only 11n mode is implemented currently, */
1517 if (!(priv
->ieee80211
->mode
== WIRELESS_MODE_N_24G
||
1518 priv
->ieee80211
->mode
== WIRELESS_MODE_N_5G
))
1522 /* 2007/11/15 MH Copy from 8190PCI. */
1525 ratr_value
= reg_ratr
;
1526 if (priv
->rf_type
== RF_1T2R
) { /* 1T2R, Spatial Stream 2 should be disabled */
1527 ratr_value
&= ~(RATE_ALL_OFDM_2SS
);
1528 /*DbgPrint("HW_VAR_TATR_0 from 0x%x ==> 0x%x\n", ((pu4Byte)(val))[0], ratr_value);*/
1530 /*DbgPrint("set HW_VAR_TATR_0 = 0x%x\n", ratr_value);*/
1531 /*cosa PlatformEFIOWrite4Byte(Adapter, RATR0, ((pu4Byte)(val))[0]);*/
1532 write_nic_dword(dev
, RATR0
, ratr_value
);
1533 write_nic_byte(dev
, UFWP
, 1);
1535 /* Restore TX Power Tracking Index */
1536 if (priv
->btxpower_trackingInit
&& priv
->btxpower_tracking
)
1537 dm_txpower_reset_recovery(dev
);
1539 /* Restore BB Initial Gain */
1540 dm_bb_initialgain_restore(dev
);
1542 } /* DM_RestoreDynamicMechanismState */
1544 static void dm_bb_initialgain_restore(struct net_device
*dev
)
1546 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1547 u32 bit_mask
= 0x7f; /* Bit0~ Bit6 */
1549 if (dm_digtable
.dig_algorithm
== DIG_ALGO_BY_RSSI
)
1552 /* Disable Initial Gain */
1553 /*PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);*/
1554 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x8); /* Only clear byte 1 and rewrite. */
1555 rtl8192_setBBreg(dev
, rOFDM0_XAAGCCore1
, bit_mask
, (u32
)priv
->initgain_backup
.xaagccore1
);
1556 rtl8192_setBBreg(dev
, rOFDM0_XBAGCCore1
, bit_mask
, (u32
)priv
->initgain_backup
.xbagccore1
);
1557 rtl8192_setBBreg(dev
, rOFDM0_XCAGCCore1
, bit_mask
, (u32
)priv
->initgain_backup
.xcagccore1
);
1558 rtl8192_setBBreg(dev
, rOFDM0_XDAGCCore1
, bit_mask
, (u32
)priv
->initgain_backup
.xdagccore1
);
1559 bit_mask
= bMaskByte2
;
1560 rtl8192_setBBreg(dev
, rCCK0_CCA
, bit_mask
, (u32
)priv
->initgain_backup
.cca
);
1562 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xc50 is %x\n", priv
->initgain_backup
.xaagccore1
);
1563 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xc58 is %x\n", priv
->initgain_backup
.xbagccore1
);
1564 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xc60 is %x\n", priv
->initgain_backup
.xcagccore1
);
1565 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xc68 is %x\n", priv
->initgain_backup
.xdagccore1
);
1566 RT_TRACE(COMP_DIG
, "dm_BBInitialGainRestore 0xa0a is %x\n", priv
->initgain_backup
.cca
);
1567 /* Enable Initial Gain */
1568 /*PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x100);*/
1569 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x1); /* Only clear byte 1 and rewrite. */
1571 } /* dm_BBInitialGainRestore */
1573 void dm_backup_dynamic_mechanism_state(struct net_device
*dev
)
1575 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1577 /* Fsync to avoid reset */
1578 priv
->bswitch_fsync
= false;
1579 priv
->bfsync_processing
= false;
1580 /* Backup BB InitialGain */
1581 dm_bb_initialgain_backup(dev
);
1583 } /* DM_BackupDynamicMechanismState */
1585 static void dm_bb_initialgain_backup(struct net_device
*dev
)
1587 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1588 u32 bit_mask
= bMaskByte0
; /* Bit0~ Bit6 */
1590 if (dm_digtable
.dig_algorithm
== DIG_ALGO_BY_RSSI
)
1593 /*PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);*/
1594 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x8); /* Only clear byte 1 and rewrite. */
1595 priv
->initgain_backup
.xaagccore1
= (u8
)rtl8192_QueryBBReg(dev
, rOFDM0_XAAGCCore1
, bit_mask
);
1596 priv
->initgain_backup
.xbagccore1
= (u8
)rtl8192_QueryBBReg(dev
, rOFDM0_XBAGCCore1
, bit_mask
);
1597 priv
->initgain_backup
.xcagccore1
= (u8
)rtl8192_QueryBBReg(dev
, rOFDM0_XCAGCCore1
, bit_mask
);
1598 priv
->initgain_backup
.xdagccore1
= (u8
)rtl8192_QueryBBReg(dev
, rOFDM0_XDAGCCore1
, bit_mask
);
1599 bit_mask
= bMaskByte2
;
1600 priv
->initgain_backup
.cca
= (u8
)rtl8192_QueryBBReg(dev
, rCCK0_CCA
, bit_mask
);
1602 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xc50 is %x\n", priv
->initgain_backup
.xaagccore1
);
1603 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xc58 is %x\n", priv
->initgain_backup
.xbagccore1
);
1604 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xc60 is %x\n", priv
->initgain_backup
.xcagccore1
);
1605 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xc68 is %x\n", priv
->initgain_backup
.xdagccore1
);
1606 RT_TRACE(COMP_DIG
, "BBInitialGainBackup 0xa0a is %x\n", priv
->initgain_backup
.cca
);
1608 } /* dm_BBInitialGainBakcup */
1611 /*-----------------------------------------------------------------------------
1612 * Function: dm_change_dynamic_initgain_thresh()
1624 * 05/29/2008 amy Create Version 0 porting from windows code.
1626 *---------------------------------------------------------------------------*/
1628 void dm_change_dynamic_initgain_thresh(struct net_device
*dev
, u32 dm_type
,
1631 if (dm_type
== DIG_TYPE_THRESH_HIGH
) {
1632 dm_digtable
.rssi_high_thresh
= dm_value
;
1633 } else if (dm_type
== DIG_TYPE_THRESH_LOW
) {
1634 dm_digtable
.rssi_low_thresh
= dm_value
;
1635 } else if (dm_type
== DIG_TYPE_THRESH_HIGHPWR_HIGH
) {
1636 dm_digtable
.rssi_high_power_highthresh
= dm_value
;
1637 } else if (dm_type
== DIG_TYPE_THRESH_HIGHPWR_LOW
) {
1638 dm_digtable
.rssi_high_power_lowthresh
= dm_value
;
1639 } else if (dm_type
== DIG_TYPE_ENABLE
) {
1640 dm_digtable
.dig_state
= DM_STA_DIG_MAX
;
1641 dm_digtable
.dig_enable_flag
= true;
1642 } else if (dm_type
== DIG_TYPE_DISABLE
) {
1643 dm_digtable
.dig_state
= DM_STA_DIG_MAX
;
1644 dm_digtable
.dig_enable_flag
= false;
1645 } else if (dm_type
== DIG_TYPE_DBG_MODE
) {
1646 if (dm_value
>= DM_DBG_MAX
)
1647 dm_value
= DM_DBG_OFF
;
1648 dm_digtable
.dbg_mode
= (u8
)dm_value
;
1649 } else if (dm_type
== DIG_TYPE_RSSI
) {
1652 dm_digtable
.rssi_val
= (long)dm_value
;
1653 } else if (dm_type
== DIG_TYPE_ALGORITHM
) {
1654 if (dm_value
>= DIG_ALGO_MAX
)
1655 dm_value
= DIG_ALGO_BY_FALSE_ALARM
;
1656 if (dm_digtable
.dig_algorithm
!= (u8
)dm_value
)
1657 dm_digtable
.dig_algorithm_switch
= 1;
1658 dm_digtable
.dig_algorithm
= (u8
)dm_value
;
1659 } else if (dm_type
== DIG_TYPE_BACKOFF
) {
1662 dm_digtable
.backoff_val
= (u8
)dm_value
;
1663 } else if (dm_type
== DIG_TYPE_RX_GAIN_MIN
) {
1666 dm_digtable
.rx_gain_range_min
= (u8
)dm_value
;
1667 } else if (dm_type
== DIG_TYPE_RX_GAIN_MAX
) {
1668 if (dm_value
> 0x50)
1670 dm_digtable
.rx_gain_range_max
= (u8
)dm_value
;
1672 } /* DM_ChangeDynamicInitGainThresh */
1674 /*-----------------------------------------------------------------------------
1675 * Function: dm_dig_init()
1677 * Overview: Set DIG scheme init value.
1687 * 05/15/2008 amy Create Version 0 porting from windows code.
1689 *---------------------------------------------------------------------------*/
1690 static void dm_dig_init(struct net_device
*dev
)
1692 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1693 /* 2007/10/05 MH Disable DIG scheme now. Not tested. */
1694 dm_digtable
.dig_enable_flag
= true;
1695 dm_digtable
.dig_algorithm
= DIG_ALGO_BY_RSSI
;
1696 dm_digtable
.dbg_mode
= DM_DBG_OFF
; /* off=by real rssi value, on=by DM_DigTable.Rssi_val for new dig */
1697 dm_digtable
.dig_algorithm_switch
= 0;
1699 /* 2007/10/04 MH Define init gain threshold. */
1700 dm_digtable
.dig_state
= DM_STA_DIG_MAX
;
1701 dm_digtable
.dig_highpwr_state
= DM_STA_DIG_MAX
;
1702 dm_digtable
.initialgain_lowerbound_state
= false;
1704 dm_digtable
.rssi_low_thresh
= DM_DIG_THRESH_LOW
;
1705 dm_digtable
.rssi_high_thresh
= DM_DIG_THRESH_HIGH
;
1707 dm_digtable
.rssi_high_power_lowthresh
= DM_DIG_HIGH_PWR_THRESH_LOW
;
1708 dm_digtable
.rssi_high_power_highthresh
= DM_DIG_HIGH_PWR_THRESH_HIGH
;
1710 dm_digtable
.rssi_val
= 50; /* for new dig debug rssi value */
1711 dm_digtable
.backoff_val
= DM_DIG_BACKOFF
;
1712 dm_digtable
.rx_gain_range_max
= DM_DIG_MAX
;
1713 if (priv
->CustomerID
== RT_CID_819x_Netcore
)
1714 dm_digtable
.rx_gain_range_min
= DM_DIG_MIN_Netcore
;
1716 dm_digtable
.rx_gain_range_min
= DM_DIG_MIN
;
1720 /*-----------------------------------------------------------------------------
1721 * Function: dm_ctrl_initgain_byrssi()
1723 * Overview: Driver must monitor RSSI and notify firmware to change initial
1724 * gain according to different threshold. BB team provide the
1725 * suggested solution.
1727 * Input: struct net_device *dev
1735 * 05/27/2008 amy Create Version 0 porting from windows code.
1736 *---------------------------------------------------------------------------*/
1737 static void dm_ctrl_initgain_byrssi(struct net_device
*dev
)
1739 if (!dm_digtable
.dig_enable_flag
)
1742 if (dm_digtable
.dig_algorithm
== DIG_ALGO_BY_FALSE_ALARM
)
1743 dm_ctrl_initgain_byrssi_by_fwfalse_alarm(dev
);
1744 else if (dm_digtable
.dig_algorithm
== DIG_ALGO_BY_RSSI
)
1745 dm_ctrl_initgain_byrssi_by_driverrssi(dev
);
1751 static void dm_ctrl_initgain_byrssi_by_driverrssi(
1752 struct net_device
*dev
)
1754 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1758 if (!dm_digtable
.dig_enable_flag
)
1761 /*DbgPrint("Dig by Sw Rssi\n");*/
1762 if (dm_digtable
.dig_algorithm_switch
) /* if switched algorithm, we have to disable FW Dig. */
1765 if (fw_dig
<= 3) { /* execute several times to make sure the FW Dig is disabled */
1767 for (i
= 0; i
< 3; i
++)
1768 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x8); /* Only clear byte 1 and rewrite. */
1770 dm_digtable
.dig_state
= DM_STA_DIG_OFF
; /* fw dig off. */
1773 if (priv
->ieee80211
->state
== IEEE80211_LINKED
)
1774 dm_digtable
.cur_connect_state
= DIG_CONNECT
;
1776 dm_digtable
.cur_connect_state
= DIG_DISCONNECT
;
1778 /*DbgPrint("DM_DigTable.PreConnectState = %d, DM_DigTable.CurConnectState = %d\n",
1779 DM_DigTable.PreConnectState, DM_DigTable.CurConnectState);*/
1781 if (dm_digtable
.dbg_mode
== DM_DBG_OFF
)
1782 dm_digtable
.rssi_val
= priv
->undecorated_smoothed_pwdb
;
1783 /*DbgPrint("DM_DigTable.Rssi_val = %d\n", DM_DigTable.Rssi_val);*/
1784 dm_initial_gain(dev
);
1787 if (dm_digtable
.dig_algorithm_switch
)
1788 dm_digtable
.dig_algorithm_switch
= 0;
1789 dm_digtable
.pre_connect_state
= dm_digtable
.cur_connect_state
;
1791 } /* dm_CtrlInitGainByRssi */
1793 static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
1794 struct net_device
*dev
)
1796 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1797 static u32 reset_cnt
;
1800 if (!dm_digtable
.dig_enable_flag
)
1803 if (dm_digtable
.dig_algorithm_switch
) {
1804 dm_digtable
.dig_state
= DM_STA_DIG_MAX
;
1806 for (i
= 0; i
< 3; i
++)
1807 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x1); /* Only clear byte 1 and rewrite.*/
1808 dm_digtable
.dig_algorithm_switch
= 0;
1811 if (priv
->ieee80211
->state
!= IEEE80211_LINKED
)
1814 /* For smooth, we can not change DIG state. */
1815 if ((priv
->undecorated_smoothed_pwdb
> dm_digtable
.rssi_low_thresh
) &&
1816 (priv
->undecorated_smoothed_pwdb
< dm_digtable
.rssi_high_thresh
))
1819 /*DbgPrint("Dig by Fw False Alarm\n");*/
1820 /*if (DM_DigTable.Dig_State == DM_STA_DIG_OFF)*/
1821 /*DbgPrint("DIG Check\n\r RSSI=%d LOW=%d HIGH=%d STATE=%d",
1822 pHalData->UndecoratedSmoothedPWDB, DM_DigTable.RssiLowThresh,
1823 DM_DigTable.RssiHighThresh, DM_DigTable.Dig_State);*/
1824 /* 1. When RSSI decrease, We have to judge if it is smaller than a threshold
1825 and then execute the step below. */
1826 if (priv
->undecorated_smoothed_pwdb
<= dm_digtable
.rssi_low_thresh
) {
1827 /* 2008/02/05 MH When we execute silent reset, the DIG PHY parameters
1828 will be reset to init value. We must prevent the condition. */
1829 if (dm_digtable
.dig_state
== DM_STA_DIG_OFF
&&
1830 (priv
->reset_count
== reset_cnt
)) {
1833 reset_cnt
= priv
->reset_count
;
1835 /* If DIG is off, DIG high power state must reset. */
1836 dm_digtable
.dig_highpwr_state
= DM_STA_DIG_MAX
;
1837 dm_digtable
.dig_state
= DM_STA_DIG_OFF
;
1840 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x8); /* Only clear byte 1 and rewrite. */
1842 /* 1.2 Set initial gain. */
1843 write_nic_byte(dev
, rOFDM0_XAAGCCore1
, 0x17);
1844 write_nic_byte(dev
, rOFDM0_XBAGCCore1
, 0x17);
1845 write_nic_byte(dev
, rOFDM0_XCAGCCore1
, 0x17);
1846 write_nic_byte(dev
, rOFDM0_XDAGCCore1
, 0x17);
1848 /* 1.3 Lower PD_TH for OFDM. */
1849 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) {
1851 * 2008/01/11 MH 40MHZ 90/92 register are not the same.
1852 * 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
1854 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x00);
1855 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
1856 write_nic_byte(pAdapter, rOFDM0_RxDetector1, 0x40);
1857 else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
1859 PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x40);
1862 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x42);
1864 /* 1.4 Lower CS ratio for CCK. */
1865 write_nic_byte(dev
, 0xa0a, 0x08);
1867 /* 1.5 Higher EDCCA. */
1868 /*PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x325);*/
1873 /* 2. When RSSI increase, We have to judge if it is larger than a threshold
1874 and then execute the step below. */
1875 if (priv
->undecorated_smoothed_pwdb
>= dm_digtable
.rssi_high_thresh
) {
1878 if (dm_digtable
.dig_state
== DM_STA_DIG_ON
&&
1879 (priv
->reset_count
== reset_cnt
)) {
1880 dm_ctrl_initgain_byrssi_highpwr(dev
);
1883 if (priv
->reset_count
!= reset_cnt
)
1886 reset_cnt
= priv
->reset_count
;
1888 dm_digtable
.dig_state
= DM_STA_DIG_ON
;
1889 /*DbgPrint("DIG ON\n\r");*/
1892 * 2.1 Set initial gain.
1893 * 2008/02/26 MH SD3-Jerry suggest to prevent dirty environment.
1895 if (reset_flag
== 1) {
1896 write_nic_byte(dev
, rOFDM0_XAAGCCore1
, 0x2c);
1897 write_nic_byte(dev
, rOFDM0_XBAGCCore1
, 0x2c);
1898 write_nic_byte(dev
, rOFDM0_XCAGCCore1
, 0x2c);
1899 write_nic_byte(dev
, rOFDM0_XDAGCCore1
, 0x2c);
1901 write_nic_byte(dev
, rOFDM0_XAAGCCore1
, 0x20);
1902 write_nic_byte(dev
, rOFDM0_XBAGCCore1
, 0x20);
1903 write_nic_byte(dev
, rOFDM0_XCAGCCore1
, 0x20);
1904 write_nic_byte(dev
, rOFDM0_XDAGCCore1
, 0x20);
1907 /* 2.2 Higher PD_TH for OFDM. */
1908 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) {
1910 * 2008/01/11 MH 40MHZ 90/92 register are not the same.
1911 * 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
1913 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x20);
1915 else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
1916 write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
1917 else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
1919 PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x42);
1922 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x44);
1924 /* 2.3 Higher CS ratio for CCK. */
1925 write_nic_byte(dev
, 0xa0a, 0xcd);
1929 * 2008/01/11 MH 90/92 series are the same.
1931 /*PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x346);*/
1934 rtl8192_setBBreg(dev
, UFWP
, bMaskByte1
, 0x1); /* Only clear byte 1 and rewrite. */
1938 dm_ctrl_initgain_byrssi_highpwr(dev
);
1940 } /* dm_CtrlInitGainByRssi */
1942 /*-----------------------------------------------------------------------------
1943 * Function: dm_ctrl_initgain_byrssi_highpwr()
1955 * 05/28/2008 amy Create Version 0 porting from windows code.
1957 *---------------------------------------------------------------------------*/
1958 static void dm_ctrl_initgain_byrssi_highpwr(
1959 struct net_device
*dev
)
1961 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1962 static u32 reset_cnt_highpwr
;
1964 /* For smooth, we can not change high power DIG state in the range. */
1965 if ((priv
->undecorated_smoothed_pwdb
> dm_digtable
.rssi_high_power_lowthresh
) &&
1966 (priv
->undecorated_smoothed_pwdb
< dm_digtable
.rssi_high_power_highthresh
))
1970 * 3. When RSSI >75% or <70%, it is a high power issue. We have to judge if
1971 * it is larger than a threshold and then execute the step below.
1973 * 2008/02/05 MH SD3-Jerry Modify PD_TH for high power issue.
1975 if (priv
->undecorated_smoothed_pwdb
>= dm_digtable
.rssi_high_power_highthresh
) {
1976 if (dm_digtable
.dig_highpwr_state
== DM_STA_DIG_ON
&&
1977 (priv
->reset_count
== reset_cnt_highpwr
))
1979 dm_digtable
.dig_highpwr_state
= DM_STA_DIG_ON
;
1981 /* 3.1 Higher PD_TH for OFDM for high power state. */
1982 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) {
1983 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x10);
1985 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
1986 write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
1990 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x43);
1992 if (dm_digtable
.dig_highpwr_state
== DM_STA_DIG_OFF
&&
1993 (priv
->reset_count
== reset_cnt_highpwr
))
1995 dm_digtable
.dig_highpwr_state
= DM_STA_DIG_OFF
;
1997 if (priv
->undecorated_smoothed_pwdb
< dm_digtable
.rssi_high_power_lowthresh
&&
1998 priv
->undecorated_smoothed_pwdb
>= dm_digtable
.rssi_high_thresh
) {
1999 /* 3.2 Recover PD_TH for OFDM for normal power region. */
2000 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) {
2001 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x20);
2002 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2003 write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2007 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x44);
2011 reset_cnt_highpwr
= priv
->reset_count
;
2013 } /* dm_CtrlInitGainByRssiHighPwr */
2015 static void dm_initial_gain(
2016 struct net_device
*dev
)
2018 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2019 u8 initial_gain
= 0;
2020 static u8 initialized
, force_write
;
2021 static u32 reset_cnt
;
2024 if (dm_digtable
.dig_algorithm_switch
) {
2029 if (dm_digtable
.pre_connect_state
== dm_digtable
.cur_connect_state
) {
2030 if (dm_digtable
.cur_connect_state
== DIG_CONNECT
) {
2031 if ((dm_digtable
.rssi_val
+10-dm_digtable
.backoff_val
) > dm_digtable
.rx_gain_range_max
)
2032 dm_digtable
.cur_ig_value
= dm_digtable
.rx_gain_range_max
;
2033 else if ((dm_digtable
.rssi_val
+10-dm_digtable
.backoff_val
) < dm_digtable
.rx_gain_range_min
)
2034 dm_digtable
.cur_ig_value
= dm_digtable
.rx_gain_range_min
;
2036 dm_digtable
.cur_ig_value
= dm_digtable
.rssi_val
+10-dm_digtable
.backoff_val
;
2037 } else { /* current state is disconnected */
2038 if (dm_digtable
.cur_ig_value
== 0)
2039 dm_digtable
.cur_ig_value
= priv
->DefaultInitialGain
[0];
2041 dm_digtable
.cur_ig_value
= dm_digtable
.pre_ig_value
;
2043 } else { /* disconnected -> connected or connected -> disconnected */
2044 dm_digtable
.cur_ig_value
= priv
->DefaultInitialGain
[0];
2045 dm_digtable
.pre_ig_value
= 0;
2047 /*DbgPrint("DM_DigTable.CurIGValue = 0x%x, DM_DigTable.PreIGValue = 0x%x\n", DM_DigTable.CurIGValue, DM_DigTable.PreIGValue);*/
2049 /* if silent reset happened, we should rewrite the values back */
2050 if (priv
->reset_count
!= reset_cnt
) {
2052 reset_cnt
= priv
->reset_count
;
2055 read_nic_byte(dev
, rOFDM0_XAAGCCore1
, &tmp
);
2056 if (dm_digtable
.pre_ig_value
!= tmp
)
2060 if ((dm_digtable
.pre_ig_value
!= dm_digtable
.cur_ig_value
)
2061 || !initialized
|| force_write
) {
2062 initial_gain
= (u8
)dm_digtable
.cur_ig_value
;
2063 /*DbgPrint("Write initial gain = 0x%x\n", initial_gain);*/
2064 /* Set initial gain. */
2065 write_nic_byte(dev
, rOFDM0_XAAGCCore1
, initial_gain
);
2066 write_nic_byte(dev
, rOFDM0_XBAGCCore1
, initial_gain
);
2067 write_nic_byte(dev
, rOFDM0_XCAGCCore1
, initial_gain
);
2068 write_nic_byte(dev
, rOFDM0_XDAGCCore1
, initial_gain
);
2069 dm_digtable
.pre_ig_value
= dm_digtable
.cur_ig_value
;
2076 static void dm_pd_th(
2077 struct net_device
*dev
)
2079 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2080 static u8 initialized
, force_write
;
2081 static u32 reset_cnt
;
2083 if (dm_digtable
.dig_algorithm_switch
) {
2088 if (dm_digtable
.pre_connect_state
== dm_digtable
.cur_connect_state
) {
2089 if (dm_digtable
.cur_connect_state
== DIG_CONNECT
) {
2090 if (dm_digtable
.rssi_val
>= dm_digtable
.rssi_high_power_highthresh
)
2091 dm_digtable
.curpd_thstate
= DIG_PD_AT_HIGH_POWER
;
2092 else if (dm_digtable
.rssi_val
<= dm_digtable
.rssi_low_thresh
)
2093 dm_digtable
.curpd_thstate
= DIG_PD_AT_LOW_POWER
;
2094 else if ((dm_digtable
.rssi_val
>= dm_digtable
.rssi_high_thresh
) &&
2095 (dm_digtable
.rssi_val
< dm_digtable
.rssi_high_power_lowthresh
))
2096 dm_digtable
.curpd_thstate
= DIG_PD_AT_NORMAL_POWER
;
2098 dm_digtable
.curpd_thstate
= dm_digtable
.prepd_thstate
;
2100 dm_digtable
.curpd_thstate
= DIG_PD_AT_LOW_POWER
;
2102 } else { /* disconnected -> connected or connected -> disconnected */
2103 dm_digtable
.curpd_thstate
= DIG_PD_AT_LOW_POWER
;
2106 /* if silent reset happened, we should rewrite the values back */
2107 if (priv
->reset_count
!= reset_cnt
) {
2109 reset_cnt
= priv
->reset_count
;
2113 if ((dm_digtable
.prepd_thstate
!= dm_digtable
.curpd_thstate
) ||
2114 (initialized
<= 3) || force_write
) {
2115 /*DbgPrint("Write PD_TH state = %d\n", DM_DigTable.CurPD_THState);*/
2116 if (dm_digtable
.curpd_thstate
== DIG_PD_AT_LOW_POWER
) {
2117 /* Lower PD_TH for OFDM. */
2118 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) {
2120 * 2008/01/11 MH 40MHZ 90/92 register are not the same.
2121 * 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2123 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x00);
2124 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2125 write_nic_byte(dev, rOFDM0_RxDetector1, 0x40);
2128 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x42);
2129 } else if (dm_digtable
.curpd_thstate
== DIG_PD_AT_NORMAL_POWER
) {
2130 /* Higher PD_TH for OFDM. */
2131 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) {
2133 * 2008/01/11 MH 40MHZ 90/92 register are not the same.
2134 * 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2136 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x20);
2137 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2138 write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2141 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x44);
2142 } else if (dm_digtable
.curpd_thstate
== DIG_PD_AT_HIGH_POWER
) {
2143 /* Higher PD_TH for OFDM for high power state. */
2144 if (priv
->CurrentChannelBW
!= HT_CHANNEL_WIDTH_20
) {
2145 write_nic_byte(dev
, (rOFDM0_XATxAFE
+3), 0x10);
2146 /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2147 write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
2150 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x43);
2152 dm_digtable
.prepd_thstate
= dm_digtable
.curpd_thstate
;
2153 if (initialized
<= 3)
2160 static void dm_cs_ratio(
2161 struct net_device
*dev
)
2163 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2164 static u8 initialized
, force_write
;
2165 static u32 reset_cnt
;
2167 if (dm_digtable
.dig_algorithm_switch
) {
2172 if (dm_digtable
.pre_connect_state
== dm_digtable
.cur_connect_state
) {
2173 if (dm_digtable
.cur_connect_state
== DIG_CONNECT
) {
2174 if (dm_digtable
.rssi_val
<= dm_digtable
.rssi_low_thresh
)
2175 dm_digtable
.curcs_ratio_state
= DIG_CS_RATIO_LOWER
;
2176 else if (dm_digtable
.rssi_val
>= dm_digtable
.rssi_high_thresh
)
2177 dm_digtable
.curcs_ratio_state
= DIG_CS_RATIO_HIGHER
;
2179 dm_digtable
.curcs_ratio_state
= dm_digtable
.precs_ratio_state
;
2181 dm_digtable
.curcs_ratio_state
= DIG_CS_RATIO_LOWER
;
2183 } else /* disconnected -> connected or connected -> disconnected */
2184 dm_digtable
.curcs_ratio_state
= DIG_CS_RATIO_LOWER
;
2186 /* if silent reset happened, we should rewrite the values back */
2187 if (priv
->reset_count
!= reset_cnt
) {
2189 reset_cnt
= priv
->reset_count
;
2193 if ((dm_digtable
.precs_ratio_state
!= dm_digtable
.curcs_ratio_state
) ||
2194 !initialized
|| force_write
) {
2195 /*DbgPrint("Write CS_ratio state = %d\n", DM_DigTable.CurCS_ratioState);*/
2196 if (dm_digtable
.curcs_ratio_state
== DIG_CS_RATIO_LOWER
) {
2197 /* Lower CS ratio for CCK. */
2198 write_nic_byte(dev
, 0xa0a, 0x08);
2199 } else if (dm_digtable
.curcs_ratio_state
== DIG_CS_RATIO_HIGHER
) {
2200 /* Higher CS ratio for CCK. */
2201 write_nic_byte(dev
, 0xa0a, 0xcd);
2203 dm_digtable
.precs_ratio_state
= dm_digtable
.curcs_ratio_state
;
2210 void dm_init_edca_turbo(struct net_device
*dev
)
2212 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2214 priv
->bcurrent_turbo_EDCA
= false;
2215 priv
->ieee80211
->bis_any_nonbepkts
= false;
2216 priv
->bis_cur_rdlstate
= false;
2217 } /* dm_init_edca_turbo */
2219 static void dm_check_edca_turbo(
2220 struct net_device
*dev
)
2222 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2223 PRT_HIGH_THROUGHPUT pHTInfo
= priv
->ieee80211
->pHTInfo
;
2224 /*PSTA_QOS pStaQos = pMgntInfo->pStaQos;*/
2226 /* Keep past Tx/Rx packet count for RT-to-RT EDCA turbo. */
2227 static unsigned long lastTxOkCnt
;
2228 static unsigned long lastRxOkCnt
;
2229 unsigned long curTxOkCnt
= 0;
2230 unsigned long curRxOkCnt
= 0;
2233 * Do not be Turbo if it's under WiFi config and Qos Enabled, because the EDCA parameters
2234 * should follow the settings from QAP. By Bruce, 2007-12-07.
2236 if (priv
->ieee80211
->state
!= IEEE80211_LINKED
)
2237 goto dm_CheckEdcaTurbo_EXIT
;
2238 /* We do not turn on EDCA turbo mode for some AP that has IOT issue */
2239 if (priv
->ieee80211
->pHTInfo
->IOTAction
& HT_IOT_ACT_DISABLE_EDCA_TURBO
)
2240 goto dm_CheckEdcaTurbo_EXIT
;
2242 /*printk("========>%s():bis_any_nonbepkts is %d\n", __func__, priv->bis_any_nonbepkts);*/
2243 /* Check the status for current condition. */
2244 if (!priv
->ieee80211
->bis_any_nonbepkts
) {
2245 curTxOkCnt
= priv
->stats
.txbytesunicast
- lastTxOkCnt
;
2246 curRxOkCnt
= priv
->stats
.rxbytesunicast
- lastRxOkCnt
;
2247 /* For RT-AP, we needs to turn it on when Rx>Tx */
2248 if (curRxOkCnt
> 4*curTxOkCnt
) {
2249 /*printk("%s():curRxOkCnt > 4*curTxOkCnt\n");*/
2250 if (!priv
->bis_cur_rdlstate
|| !priv
->bcurrent_turbo_EDCA
) {
2251 write_nic_dword(dev
, EDCAPARA_BE
, edca_setting_DL
[pHTInfo
->IOTPeer
]);
2252 priv
->bis_cur_rdlstate
= true;
2255 /*printk("%s():curRxOkCnt < 4*curTxOkCnt\n");*/
2256 if (priv
->bis_cur_rdlstate
|| !priv
->bcurrent_turbo_EDCA
) {
2257 write_nic_dword(dev
, EDCAPARA_BE
, edca_setting_UL
[pHTInfo
->IOTPeer
]);
2258 priv
->bis_cur_rdlstate
= false;
2263 priv
->bcurrent_turbo_EDCA
= true;
2266 * Turn Off EDCA turbo here.
2267 * Restore original EDCA according to the declaration of AP.
2269 if (priv
->bcurrent_turbo_EDCA
) {
2273 struct ieee80211_qos_parameters
*qos_parameters
= &priv
->ieee80211
->current_network
.qos_data
.parameters
;
2274 u8 mode
= priv
->ieee80211
->mode
;
2276 /* For Each time updating EDCA parameter, reset EDCA turbo mode status. */
2277 dm_init_edca_turbo(dev
);
2278 u1bAIFS
= qos_parameters
->aifs
[0] * ((mode
&(IEEE_G
|IEEE_N_24G
)) ? 9 : 20) + aSifsTime
;
2279 u4bAcParam
= (((u32
)(qos_parameters
->tx_op_limit
[0])) << AC_PARAM_TXOP_LIMIT_OFFSET
)|
2280 (((u32
)(qos_parameters
->cw_max
[0])) << AC_PARAM_ECW_MAX_OFFSET
)|
2281 (((u32
)(qos_parameters
->cw_min
[0])) << AC_PARAM_ECW_MIN_OFFSET
)|
2282 ((u32
)u1bAIFS
<< AC_PARAM_AIFS_OFFSET
);
2283 /*write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam);*/
2284 write_nic_dword(dev
, EDCAPARA_BE
, u4bAcParam
);
2288 * If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13.
2291 /* TODO: Modified this part and try to set acm control in only 1 IO processing!! */
2293 PACI_AIFSN pAciAifsn
= (PACI_AIFSN
)&(qos_parameters
->aifs
[0]);
2296 read_nic_byte(dev
, AcmHwCtrl
, &AcmCtrl
);
2298 if (pAciAifsn
->f
.ACM
) { /* ACM bit is 1. */
2299 AcmCtrl
|= AcmHw_BeqEn
;
2300 } else { /* ACM bit is 0. */
2301 AcmCtrl
&= (~AcmHw_BeqEn
);
2304 RT_TRACE(COMP_QOS
, "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl
);
2305 write_nic_byte(dev
, AcmHwCtrl
, AcmCtrl
);
2308 priv
->bcurrent_turbo_EDCA
= false;
2312 dm_CheckEdcaTurbo_EXIT
:
2313 /* Set variables for next time. */
2314 priv
->ieee80211
->bis_any_nonbepkts
= false;
2315 lastTxOkCnt
= priv
->stats
.txbytesunicast
;
2316 lastRxOkCnt
= priv
->stats
.rxbytesunicast
;
2317 } /* dm_CheckEdcaTurbo */
2319 static void dm_init_ctstoself(struct net_device
*dev
)
2321 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)dev
);
2323 priv
->ieee80211
->bCTSToSelfEnable
= true;
2324 priv
->ieee80211
->CTSToSelfTH
= CTSToSelfTHVal
;
2327 static void dm_ctstoself(struct net_device
*dev
)
2329 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)dev
);
2330 PRT_HIGH_THROUGHPUT pHTInfo
= priv
->ieee80211
->pHTInfo
;
2331 static unsigned long lastTxOkCnt
;
2332 static unsigned long lastRxOkCnt
;
2333 unsigned long curTxOkCnt
= 0;
2334 unsigned long curRxOkCnt
= 0;
2336 if (priv
->ieee80211
->bCTSToSelfEnable
!= true) {
2337 pHTInfo
->IOTAction
&= ~HT_IOT_ACT_FORCED_CTS2SELF
;
2342 2. Linksys350/Linksys300N
2343 3. <50 disable, >55 enable
2346 if (pHTInfo
->IOTPeer
== HT_IOT_PEER_BROADCOM
) {
2347 curTxOkCnt
= priv
->stats
.txbytesunicast
- lastTxOkCnt
;
2348 curRxOkCnt
= priv
->stats
.rxbytesunicast
- lastRxOkCnt
;
2349 if (curRxOkCnt
> 4*curTxOkCnt
) { /* downlink, disable CTS to self */
2350 pHTInfo
->IOTAction
&= ~HT_IOT_ACT_FORCED_CTS2SELF
;
2351 /*DbgPrint("dm_CTSToSelf() ==> CTS to self disabled -- downlink\n");*/
2352 } else { /* uplink */
2353 pHTInfo
->IOTAction
|= HT_IOT_ACT_FORCED_CTS2SELF
;
2356 lastTxOkCnt
= priv
->stats
.txbytesunicast
;
2357 lastRxOkCnt
= priv
->stats
.rxbytesunicast
;
2361 /*-----------------------------------------------------------------------------
2362 * Function: dm_check_pbc_gpio()
2364 * Overview: Check if PBC button is pressed.
2374 * 05/28/2008 amy Create Version 0 porting from windows code.
2376 *---------------------------------------------------------------------------*/
2377 static void dm_check_pbc_gpio(struct net_device
*dev
)
2379 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2382 read_nic_byte(dev
, GPI
, &tmp1byte
);
2383 if (tmp1byte
== 0xff)
2386 if (tmp1byte
& BIT(6) || tmp1byte
& BIT(0)) {
2388 * Here we only set bPbcPressed to TRUE
2389 * After trigger PBC, the variable will be set to FALSE
2391 RT_TRACE(COMP_IO
, "CheckPbcGPIO - PBC is pressed\n");
2392 priv
->bpbc_pressed
= true;
2397 /*-----------------------------------------------------------------------------
2398 * Function: DM_RFPathCheckWorkItemCallBack()
2400 * Overview: Check if Current RF RX path is enabled
2410 * 01/30/2008 MHC Create Version 0.
2412 *---------------------------------------------------------------------------*/
2413 void dm_rf_pathcheck_workitemcallback(struct work_struct
*work
)
2415 struct delayed_work
*dwork
= container_of(work
, struct delayed_work
, work
);
2416 struct r8192_priv
*priv
= container_of(dwork
, struct r8192_priv
, rfpath_check_wq
);
2417 struct net_device
*dev
= priv
->ieee80211
->dev
;
2418 /*bool bactually_set = false;*/
2421 /* 2008/01/30 MH After discussing with SD3 Jerry, 0xc04/0xd04 register will
2422 always be the same. We only read 0xc04 now. */
2423 read_nic_byte(dev
, 0xc04, &rfpath
);
2425 /* Check Bit 0-3, it means if RF A-D is enabled. */
2426 for (i
= 0; i
< RF90_PATH_MAX
; i
++) {
2427 if (rfpath
& (0x01<<i
))
2428 priv
->brfpath_rxenable
[i
] = true;
2430 priv
->brfpath_rxenable
[i
] = false;
2432 if (!DM_RxPathSelTable
.Enable
)
2435 dm_rxpath_sel_byrssi(dev
);
2436 } /* DM_RFPathCheckWorkItemCallBack */
2438 static void dm_init_rxpath_selection(struct net_device
*dev
)
2441 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2443 DM_RxPathSelTable
.Enable
= 1; /* default enabled */
2444 DM_RxPathSelTable
.SS_TH_low
= RxPathSelection_SS_TH_low
;
2445 DM_RxPathSelTable
.diff_TH
= RxPathSelection_diff_TH
;
2446 if (priv
->CustomerID
== RT_CID_819x_Netcore
)
2447 DM_RxPathSelTable
.cck_method
= CCK_Rx_Version_2
;
2449 DM_RxPathSelTable
.cck_method
= CCK_Rx_Version_1
;
2450 DM_RxPathSelTable
.DbgMode
= DM_DBG_OFF
;
2451 DM_RxPathSelTable
.disabledRF
= 0;
2452 for (i
= 0; i
< 4; i
++) {
2453 DM_RxPathSelTable
.rf_rssi
[i
] = 50;
2454 DM_RxPathSelTable
.cck_pwdb_sta
[i
] = -64;
2455 DM_RxPathSelTable
.rf_enable_rssi_th
[i
] = 100;
2459 static void dm_rxpath_sel_byrssi(struct net_device
*dev
)
2461 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2462 u8 i
, max_rssi_index
= 0, min_rssi_index
= 0, sec_rssi_index
= 0, rf_num
= 0;
2463 u8 tmp_max_rssi
= 0, tmp_min_rssi
= 0, tmp_sec_rssi
= 0;
2464 u8 cck_default_Rx
= 0x2; /* RF-C */
2465 u8 cck_optional_Rx
= 0x3; /* RF-D */
2466 long tmp_cck_max_pwdb
= 0, tmp_cck_min_pwdb
= 0, tmp_cck_sec_pwdb
= 0;
2467 u8 cck_rx_ver2_max_index
= 0, cck_rx_ver2_min_index
= 0, cck_rx_ver2_sec_index
= 0;
2470 static u8 disabled_rf_cnt
, cck_Rx_Path_initialized
;
2471 u8 update_cck_rx_path
;
2473 if (priv
->rf_type
!= RF_2T4R
)
2476 if (!cck_Rx_Path_initialized
) {
2477 read_nic_byte(dev
, 0xa07, &DM_RxPathSelTable
.cck_Rx_path
);
2478 DM_RxPathSelTable
.cck_Rx_path
&= 0xf;
2479 cck_Rx_Path_initialized
= 1;
2482 read_nic_byte(dev
, 0xc04, &DM_RxPathSelTable
.disabledRF
);
2483 DM_RxPathSelTable
.disabledRF
= ~DM_RxPathSelTable
.disabledRF
& 0xf;
2485 if (priv
->ieee80211
->mode
== WIRELESS_MODE_B
) {
2486 DM_RxPathSelTable
.cck_method
= CCK_Rx_Version_2
; /* pure B mode, fixed cck version2 */
2487 /*DbgPrint("Pure B mode, use cck rx version2\n");*/
2490 /* decide max/sec/min rssi index */
2491 for (i
= 0; i
< RF90_PATH_MAX
; i
++) {
2492 if (!DM_RxPathSelTable
.DbgMode
)
2493 DM_RxPathSelTable
.rf_rssi
[i
] = priv
->stats
.rx_rssi_percentage
[i
];
2495 if (priv
->brfpath_rxenable
[i
]) {
2497 cur_rf_rssi
= DM_RxPathSelTable
.rf_rssi
[i
];
2499 if (rf_num
== 1) { /* find first enabled rf path and the rssi values */
2500 /* initialize, set all rssi index to the same one */
2501 max_rssi_index
= min_rssi_index
= sec_rssi_index
= i
;
2502 tmp_max_rssi
= tmp_min_rssi
= tmp_sec_rssi
= cur_rf_rssi
;
2503 } else if (rf_num
== 2) { /* we pick up the max index first, and let sec and min to be the same one */
2504 if (cur_rf_rssi
>= tmp_max_rssi
) {
2505 tmp_max_rssi
= cur_rf_rssi
;
2508 tmp_sec_rssi
= tmp_min_rssi
= cur_rf_rssi
;
2509 sec_rssi_index
= min_rssi_index
= i
;
2512 if (cur_rf_rssi
> tmp_max_rssi
) {
2513 tmp_sec_rssi
= tmp_max_rssi
;
2514 sec_rssi_index
= max_rssi_index
;
2515 tmp_max_rssi
= cur_rf_rssi
;
2517 } else if (cur_rf_rssi
== tmp_max_rssi
) { /* let sec and min point to the different index */
2518 tmp_sec_rssi
= cur_rf_rssi
;
2520 } else if ((cur_rf_rssi
< tmp_max_rssi
) && (cur_rf_rssi
> tmp_sec_rssi
)) {
2521 tmp_sec_rssi
= cur_rf_rssi
;
2523 } else if (cur_rf_rssi
== tmp_sec_rssi
) {
2524 if (tmp_sec_rssi
== tmp_min_rssi
) {
2525 /* let sec and min point to the different index */
2526 tmp_sec_rssi
= cur_rf_rssi
;
2529 /* This case we don't need to set any index */
2531 } else if ((cur_rf_rssi
< tmp_sec_rssi
) && (cur_rf_rssi
> tmp_min_rssi
)) {
2532 /* This case we don't need to set any index */
2533 } else if (cur_rf_rssi
== tmp_min_rssi
) {
2534 if (tmp_sec_rssi
== tmp_min_rssi
) {
2535 /* let sec and min point to the different index */
2536 tmp_min_rssi
= cur_rf_rssi
;
2539 /* This case we don't need to set any index */
2541 } else if (cur_rf_rssi
< tmp_min_rssi
) {
2542 tmp_min_rssi
= cur_rf_rssi
;
2550 /* decide max/sec/min cck pwdb index */
2551 if (DM_RxPathSelTable
.cck_method
== CCK_Rx_Version_2
) {
2552 for (i
= 0; i
< RF90_PATH_MAX
; i
++) {
2553 if (priv
->brfpath_rxenable
[i
]) {
2555 cur_cck_pwdb
= DM_RxPathSelTable
.cck_pwdb_sta
[i
];
2557 if (rf_num
== 1) { /* find first enabled rf path and the rssi values */
2558 /* initialize, set all rssi index to the same one */
2559 cck_rx_ver2_max_index
= cck_rx_ver2_min_index
= cck_rx_ver2_sec_index
= i
;
2560 tmp_cck_max_pwdb
= tmp_cck_min_pwdb
= tmp_cck_sec_pwdb
= cur_cck_pwdb
;
2561 } else if (rf_num
== 2) { /* we pick up the max index first, and let sec and min to be the same one */
2562 if (cur_cck_pwdb
>= tmp_cck_max_pwdb
) {
2563 tmp_cck_max_pwdb
= cur_cck_pwdb
;
2564 cck_rx_ver2_max_index
= i
;
2566 tmp_cck_sec_pwdb
= tmp_cck_min_pwdb
= cur_cck_pwdb
;
2567 cck_rx_ver2_sec_index
= cck_rx_ver2_min_index
= i
;
2570 if (cur_cck_pwdb
> tmp_cck_max_pwdb
) {
2571 tmp_cck_sec_pwdb
= tmp_cck_max_pwdb
;
2572 cck_rx_ver2_sec_index
= cck_rx_ver2_max_index
;
2573 tmp_cck_max_pwdb
= cur_cck_pwdb
;
2574 cck_rx_ver2_max_index
= i
;
2575 } else if (cur_cck_pwdb
== tmp_cck_max_pwdb
) {
2576 /* let sec and min point to the different index */
2577 tmp_cck_sec_pwdb
= cur_cck_pwdb
;
2578 cck_rx_ver2_sec_index
= i
;
2579 } else if ((cur_cck_pwdb
< tmp_cck_max_pwdb
) && (cur_cck_pwdb
> tmp_cck_sec_pwdb
)) {
2580 tmp_cck_sec_pwdb
= cur_cck_pwdb
;
2581 cck_rx_ver2_sec_index
= i
;
2582 } else if (cur_cck_pwdb
== tmp_cck_sec_pwdb
&& tmp_cck_sec_pwdb
== tmp_cck_min_pwdb
) {
2583 /* let sec and min point to the different index */
2584 tmp_cck_sec_pwdb
= cur_cck_pwdb
;
2585 cck_rx_ver2_sec_index
= i
;
2586 /* otherwise we don't need to set any index */
2587 } else if ((cur_cck_pwdb
< tmp_cck_sec_pwdb
) && (cur_cck_pwdb
> tmp_cck_min_pwdb
)) {
2588 /* This case we don't need to set any index */
2589 } else if (cur_cck_pwdb
== tmp_cck_min_pwdb
&& tmp_cck_sec_pwdb
== tmp_cck_min_pwdb
) {
2590 /* let sec and min point to the different index */
2591 tmp_cck_min_pwdb
= cur_cck_pwdb
;
2592 cck_rx_ver2_min_index
= i
;
2593 /* otherwise we don't need to set any index */
2594 } else if (cur_cck_pwdb
< tmp_cck_min_pwdb
) {
2595 tmp_cck_min_pwdb
= cur_cck_pwdb
;
2596 cck_rx_ver2_min_index
= i
;
2606 * reg0xA07[3:2]=cck default rx path, reg0xa07[1:0]=cck optional rx path.
2608 update_cck_rx_path
= 0;
2609 if (DM_RxPathSelTable
.cck_method
== CCK_Rx_Version_2
) {
2610 cck_default_Rx
= cck_rx_ver2_max_index
;
2611 cck_optional_Rx
= cck_rx_ver2_sec_index
;
2612 if (tmp_cck_max_pwdb
!= -64)
2613 update_cck_rx_path
= 1;
2616 if (tmp_min_rssi
< DM_RxPathSelTable
.SS_TH_low
&& disabled_rf_cnt
< 2) {
2617 if ((tmp_max_rssi
- tmp_min_rssi
) >= DM_RxPathSelTable
.diff_TH
) {
2618 /* record the enabled rssi threshold */
2619 DM_RxPathSelTable
.rf_enable_rssi_th
[min_rssi_index
] = tmp_max_rssi
+5;
2620 /* disable the BB Rx path, OFDM */
2621 rtl8192_setBBreg(dev
, rOFDM0_TRxPathEnable
, 0x1<<min_rssi_index
, 0x0); /* 0xc04[3:0] */
2622 rtl8192_setBBreg(dev
, rOFDM1_TRxPathEnable
, 0x1<<min_rssi_index
, 0x0); /* 0xd04[3:0] */
2625 if (DM_RxPathSelTable
.cck_method
== CCK_Rx_Version_1
) {
2626 cck_default_Rx
= max_rssi_index
;
2627 cck_optional_Rx
= sec_rssi_index
;
2629 update_cck_rx_path
= 1;
2633 if (update_cck_rx_path
) {
2634 DM_RxPathSelTable
.cck_Rx_path
= (cck_default_Rx
<<2)|(cck_optional_Rx
);
2635 rtl8192_setBBreg(dev
, rCCK0_AFESetting
, 0x0f000000, DM_RxPathSelTable
.cck_Rx_path
);
2638 if (DM_RxPathSelTable
.disabledRF
) {
2639 for (i
= 0; i
< 4; i
++) {
2640 if ((DM_RxPathSelTable
.disabledRF
>>i
) & 0x1) { /* disabled rf */
2641 if (tmp_max_rssi
>= DM_RxPathSelTable
.rf_enable_rssi_th
[i
]) {
2642 /* enable the BB Rx path */
2643 /*DbgPrint("RF-%d is enabled.\n", 0x1<<i);*/
2644 rtl8192_setBBreg(dev
, rOFDM0_TRxPathEnable
, 0x1<<i
, 0x1); /* 0xc04[3:0] */
2645 rtl8192_setBBreg(dev
, rOFDM1_TRxPathEnable
, 0x1<<i
, 0x1); /* 0xd04[3:0] */
2646 DM_RxPathSelTable
.rf_enable_rssi_th
[i
] = 100;
2654 /*-----------------------------------------------------------------------------
2655 * Function: dm_check_rx_path_selection()
2657 * Overview: Call a workitem to check current RXRF path and Rx Path selection by RSSI.
2667 * 05/28/2008 amy Create Version 0 porting from windows code.
2669 *---------------------------------------------------------------------------*/
2670 static void dm_check_rx_path_selection(struct net_device
*dev
)
2672 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2674 queue_delayed_work(priv
->priv_wq
, &priv
->rfpath_check_wq
, 0);
2675 } /* dm_CheckRxRFPath */
2677 static void dm_init_fsync(struct net_device
*dev
)
2679 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2681 priv
->ieee80211
->fsync_time_interval
= 500;
2682 priv
->ieee80211
->fsync_rate_bitmap
= 0x0f000800;
2683 priv
->ieee80211
->fsync_rssi_threshold
= 30;
2684 priv
->ieee80211
->bfsync_enable
= false;
2685 priv
->ieee80211
->fsync_multiple_timeinterval
= 3;
2686 priv
->ieee80211
->fsync_firstdiff_ratethreshold
= 100;
2687 priv
->ieee80211
->fsync_seconddiff_ratethreshold
= 200;
2688 priv
->ieee80211
->fsync_state
= Default_Fsync
;
2689 priv
->framesyncMonitor
= 1; /* current default 0xc38 monitor on */
2690 setup_timer(&priv
->fsync_timer
, dm_fsync_timer_callback
,
2691 (unsigned long)dev
);
2694 static void dm_deInit_fsync(struct net_device
*dev
)
2696 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2698 del_timer_sync(&priv
->fsync_timer
);
2701 void dm_fsync_timer_callback(unsigned long data
)
2703 struct net_device
*dev
= (struct net_device
*)data
;
2704 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)data
);
2705 u32 rate_index
, rate_count
= 0, rate_count_diff
= 0;
2706 bool bSwitchFromCountDiff
= false;
2707 bool bDoubleTimeInterval
= false;
2709 if (priv
->ieee80211
->state
== IEEE80211_LINKED
&&
2710 priv
->ieee80211
->bfsync_enable
&&
2711 (priv
->ieee80211
->pHTInfo
->IOTAction
& HT_IOT_ACT_CDD_FSYNC
)) {
2712 /* Count rate 54, MCS [7], [12, 13, 14, 15] */
2715 for (rate_index
= 0; rate_index
<= 27; rate_index
++) {
2716 rate_bitmap
= 1 << rate_index
;
2717 if (priv
->ieee80211
->fsync_rate_bitmap
& rate_bitmap
)
2718 rate_count
+= priv
->stats
.received_rate_histogram
[1][rate_index
];
2721 if (rate_count
< priv
->rate_record
)
2722 rate_count_diff
= 0xffffffff - rate_count
+ priv
->rate_record
;
2724 rate_count_diff
= rate_count
- priv
->rate_record
;
2725 if (rate_count_diff
< priv
->rateCountDiffRecord
) {
2726 u32 DiffNum
= priv
->rateCountDiffRecord
- rate_count_diff
;
2727 /* Continue count */
2728 if (DiffNum
>= priv
->ieee80211
->fsync_seconddiff_ratethreshold
)
2729 priv
->ContinueDiffCount
++;
2731 priv
->ContinueDiffCount
= 0;
2733 /* Continue count over */
2734 if (priv
->ContinueDiffCount
>= 2) {
2735 bSwitchFromCountDiff
= true;
2736 priv
->ContinueDiffCount
= 0;
2739 /* Stop the continued count */
2740 priv
->ContinueDiffCount
= 0;
2743 /* If Count diff <= FsyncRateCountThreshold */
2744 if (rate_count_diff
<= priv
->ieee80211
->fsync_firstdiff_ratethreshold
) {
2745 bSwitchFromCountDiff
= true;
2746 priv
->ContinueDiffCount
= 0;
2748 priv
->rate_record
= rate_count
;
2749 priv
->rateCountDiffRecord
= rate_count_diff
;
2750 RT_TRACE(COMP_HALDM
, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv
->rate_record
, rate_count
, rate_count_diff
, priv
->bswitch_fsync
);
2751 /* if we never receive those mcs rate and rssi > 30 % then switch fsyn */
2752 if (priv
->undecorated_smoothed_pwdb
> priv
->ieee80211
->fsync_rssi_threshold
&& bSwitchFromCountDiff
) {
2753 bDoubleTimeInterval
= true;
2754 priv
->bswitch_fsync
= !priv
->bswitch_fsync
;
2755 if (priv
->bswitch_fsync
) {
2756 write_nic_byte(dev
, 0xC36, 0x1c);
2757 write_nic_byte(dev
, 0xC3e, 0x90);
2759 write_nic_byte(dev
, 0xC36, 0x5c);
2760 write_nic_byte(dev
, 0xC3e, 0x96);
2762 } else if (priv
->undecorated_smoothed_pwdb
<= priv
->ieee80211
->fsync_rssi_threshold
) {
2763 if (priv
->bswitch_fsync
) {
2764 priv
->bswitch_fsync
= false;
2765 write_nic_byte(dev
, 0xC36, 0x5c);
2766 write_nic_byte(dev
, 0xC3e, 0x96);
2769 if (bDoubleTimeInterval
) {
2770 if (timer_pending(&priv
->fsync_timer
))
2771 del_timer_sync(&priv
->fsync_timer
);
2772 priv
->fsync_timer
.expires
= jiffies
+ MSECS(priv
->ieee80211
->fsync_time_interval
*priv
->ieee80211
->fsync_multiple_timeinterval
);
2773 add_timer(&priv
->fsync_timer
);
2775 if (timer_pending(&priv
->fsync_timer
))
2776 del_timer_sync(&priv
->fsync_timer
);
2777 priv
->fsync_timer
.expires
= jiffies
+ MSECS(priv
->ieee80211
->fsync_time_interval
);
2778 add_timer(&priv
->fsync_timer
);
2781 /* Let Register return to default value; */
2782 if (priv
->bswitch_fsync
) {
2783 priv
->bswitch_fsync
= false;
2784 write_nic_byte(dev
, 0xC36, 0x5c);
2785 write_nic_byte(dev
, 0xC3e, 0x96);
2787 priv
->ContinueDiffCount
= 0;
2788 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c52cd);
2790 RT_TRACE(COMP_HALDM
, "ContinueDiffCount %d\n", priv
->ContinueDiffCount
);
2791 RT_TRACE(COMP_HALDM
, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv
->rate_record
, rate_count
, rate_count_diff
, priv
->bswitch_fsync
);
2794 static void dm_StartHWFsync(struct net_device
*dev
)
2796 RT_TRACE(COMP_HALDM
, "%s\n", __func__
);
2797 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c12cf);
2798 write_nic_byte(dev
, 0xc3b, 0x41);
2801 static void dm_EndSWFsync(struct net_device
*dev
)
2803 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2805 RT_TRACE(COMP_HALDM
, "%s\n", __func__
);
2806 del_timer_sync(&(priv
->fsync_timer
));
2808 /* Let Register return to default value; */
2809 if (priv
->bswitch_fsync
) {
2810 priv
->bswitch_fsync
= false;
2812 write_nic_byte(dev
, 0xC36, 0x5c);
2814 write_nic_byte(dev
, 0xC3e, 0x96);
2817 priv
->ContinueDiffCount
= 0;
2818 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c52cd);
2822 static void dm_StartSWFsync(struct net_device
*dev
)
2824 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2828 RT_TRACE(COMP_HALDM
, "%s\n", __func__
);
2829 /* Initial rate record to zero, start to record. */
2830 priv
->rate_record
= 0;
2831 /* Initialize continue diff count to zero, start to record. */
2832 priv
->ContinueDiffCount
= 0;
2833 priv
->rateCountDiffRecord
= 0;
2834 priv
->bswitch_fsync
= false;
2836 if (priv
->ieee80211
->mode
== WIRELESS_MODE_N_24G
) {
2837 priv
->ieee80211
->fsync_firstdiff_ratethreshold
= 600;
2838 priv
->ieee80211
->fsync_seconddiff_ratethreshold
= 0xffff;
2840 priv
->ieee80211
->fsync_firstdiff_ratethreshold
= 200;
2841 priv
->ieee80211
->fsync_seconddiff_ratethreshold
= 200;
2843 for (rateIndex
= 0; rateIndex
<= 27; rateIndex
++) {
2844 rateBitmap
= 1 << rateIndex
;
2845 if (priv
->ieee80211
->fsync_rate_bitmap
& rateBitmap
)
2846 priv
->rate_record
+= priv
->stats
.received_rate_histogram
[1][rateIndex
];
2848 if (timer_pending(&priv
->fsync_timer
))
2849 del_timer_sync(&priv
->fsync_timer
);
2850 priv
->fsync_timer
.expires
= jiffies
+ MSECS(priv
->ieee80211
->fsync_time_interval
);
2851 add_timer(&priv
->fsync_timer
);
2853 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c12cd);
2857 static void dm_EndHWFsync(struct net_device
*dev
)
2859 RT_TRACE(COMP_HALDM
, "%s\n", __func__
);
2860 write_nic_dword(dev
, rOFDM0_RxDetector2
, 0x465c52cd);
2861 write_nic_byte(dev
, 0xc3b, 0x49);
2865 void dm_check_fsync(struct net_device
*dev
)
2867 #define RegC38_Default 0
2868 #define RegC38_NonFsync_Other_AP 1
2869 #define RegC38_Fsync_AP_BCM 2
2870 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2871 /*u32 framesyncC34;*/
2872 static u8 reg_c38_State
= RegC38_Default
;
2873 static u32 reset_cnt
;
2875 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
);
2876 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
);
2878 if (priv
->ieee80211
->state
== IEEE80211_LINKED
&&
2879 (priv
->ieee80211
->pHTInfo
->IOTAction
& HT_IOT_ACT_CDD_FSYNC
)) {
2880 if (priv
->ieee80211
->bfsync_enable
== 0) {
2881 switch (priv
->ieee80211
->fsync_state
) {
2883 dm_StartHWFsync(dev
);
2884 priv
->ieee80211
->fsync_state
= HW_Fsync
;
2888 dm_StartHWFsync(dev
);
2889 priv
->ieee80211
->fsync_state
= HW_Fsync
;
2896 switch (priv
->ieee80211
->fsync_state
) {
2898 dm_StartSWFsync(dev
);
2899 priv
->ieee80211
->fsync_state
= SW_Fsync
;
2903 dm_StartSWFsync(dev
);
2904 priv
->ieee80211
->fsync_state
= SW_Fsync
;
2911 if (priv
->framesyncMonitor
) {
2912 if (reg_c38_State
!= RegC38_Fsync_AP_BCM
) {
2913 /* For broadcom AP we write different default value */
2914 write_nic_byte(dev
, rOFDM0_RxDetector3
, 0x95);
2916 reg_c38_State
= RegC38_Fsync_AP_BCM
;
2920 switch (priv
->ieee80211
->fsync_state
) {
2923 priv
->ieee80211
->fsync_state
= Default_Fsync
;
2927 priv
->ieee80211
->fsync_state
= Default_Fsync
;
2934 if (priv
->framesyncMonitor
) {
2935 if (priv
->ieee80211
->state
== IEEE80211_LINKED
) {
2936 if (priv
->undecorated_smoothed_pwdb
<= RegC38_TH
) {
2937 if (reg_c38_State
!= RegC38_NonFsync_Other_AP
) {
2938 write_nic_byte(dev
, rOFDM0_RxDetector3
, 0x90);
2940 reg_c38_State
= RegC38_NonFsync_Other_AP
;
2942 } else if (priv
->undecorated_smoothed_pwdb
>= (RegC38_TH
+5)) {
2943 if (reg_c38_State
) {
2944 write_nic_byte(dev
, rOFDM0_RxDetector3
, priv
->framesync
);
2945 reg_c38_State
= RegC38_Default
;
2946 /*DbgPrint("Fsync is idle, rssi>=40, write 0xc38 = 0x%x\n", pHalData->framesync);*/
2950 if (reg_c38_State
) {
2951 write_nic_byte(dev
, rOFDM0_RxDetector3
, priv
->framesync
);
2952 reg_c38_State
= RegC38_Default
;
2953 /*DbgPrint("Fsync is idle, not connected, write 0xc38 = 0x%x\n", pHalData->framesync);*/
2958 if (priv
->framesyncMonitor
) {
2959 if (priv
->reset_count
!= reset_cnt
) { /* After silent reset, the reg_c38_State will be returned to default value */
2960 write_nic_byte(dev
, rOFDM0_RxDetector3
, priv
->framesync
);
2961 reg_c38_State
= RegC38_Default
;
2962 reset_cnt
= priv
->reset_count
;
2963 /*DbgPrint("reg_c38_State = 0 for silent reset.\n");*/
2966 if (reg_c38_State
) {
2967 write_nic_byte(dev
, rOFDM0_RxDetector3
, priv
->framesync
);
2968 reg_c38_State
= RegC38_Default
;
2969 /*DbgPrint("framesync no monitor, write 0xc38 = 0x%x\n", pHalData->framesync);*/
2974 /*-----------------------------------------------------------------------------
2975 * Function: dm_shadow_init()
2977 * Overview: Store all NIC MAC/BB register content.
2987 * 05/29/2008 amy Create Version 0 porting from windows code.
2989 *---------------------------------------------------------------------------*/
2990 void dm_shadow_init(struct net_device
*dev
)
2995 for (page
= 0; page
< 5; page
++)
2996 for (offset
= 0; offset
< 256; offset
++) {
2997 read_nic_byte(dev
, offset
+page
*256, &dm_shadow
[page
][offset
]);
2998 /*DbgPrint("P-%d/O-%02x=%02x\r\n", page, offset, DM_Shadow[page][offset]);*/
3001 for (page
= 8; page
< 11; page
++)
3002 for (offset
= 0; offset
< 256; offset
++)
3003 read_nic_byte(dev
, offset
+page
*256, &dm_shadow
[page
][offset
]);
3005 for (page
= 12; page
< 15; page
++)
3006 for (offset
= 0; offset
< 256; offset
++)
3007 read_nic_byte(dev
, offset
+page
*256, &dm_shadow
[page
][offset
]);
3009 } /* dm_shadow_init */
3011 /*---------------------------Define function prototype------------------------*/
3012 /*-----------------------------------------------------------------------------
3013 * Function: DM_DynamicTxPower()
3015 * Overview: Detect Signal strength to control TX Registry
3016 Tx Power Control For Near/Far Range
3026 * 03/06/2008 Jacken Create Version 0.
3028 *---------------------------------------------------------------------------*/
3029 static void dm_init_dynamic_txpower(struct net_device
*dev
)
3031 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3033 /* Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code. */
3034 priv
->ieee80211
->bdynamic_txpower_enable
= true; /* Default to enable Tx Power Control */
3035 priv
->bLastDTPFlag_High
= false;
3036 priv
->bLastDTPFlag_Low
= false;
3037 priv
->bDynamicTxHighPower
= false;
3038 priv
->bDynamicTxLowPower
= false;
3041 static void dm_dynamic_txpower(struct net_device
*dev
)
3043 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3044 unsigned int txhipower_threshhold
= 0;
3045 unsigned int txlowpower_threshold
= 0;
3047 if (priv
->ieee80211
->bdynamic_txpower_enable
!= true) {
3048 priv
->bDynamicTxHighPower
= false;
3049 priv
->bDynamicTxLowPower
= false;
3052 /*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);*/
3053 if ((priv
->ieee80211
->current_network
.atheros_cap_exist
) && (priv
->ieee80211
->mode
== IEEE_G
)) {
3054 txhipower_threshhold
= TX_POWER_ATHEROAP_THRESH_HIGH
;
3055 txlowpower_threshold
= TX_POWER_ATHEROAP_THRESH_LOW
;
3057 txhipower_threshhold
= TX_POWER_NEAR_FIELD_THRESH_HIGH
;
3058 txlowpower_threshold
= TX_POWER_NEAR_FIELD_THRESH_LOW
;
3061 /*printk("=======>%s(): txhipower_threshhold is %d, txlowpower_threshold is %d\n", __func__, txhipower_threshhold, txlowpower_threshold);*/
3062 RT_TRACE(COMP_TXAGC
, "priv->undecorated_smoothed_pwdb = %ld\n", priv
->undecorated_smoothed_pwdb
);
3064 if (priv
->ieee80211
->state
== IEEE80211_LINKED
) {
3065 if (priv
->undecorated_smoothed_pwdb
>= txhipower_threshhold
) {
3066 priv
->bDynamicTxHighPower
= true;
3067 priv
->bDynamicTxLowPower
= false;
3069 /* high power state check */
3070 if (priv
->undecorated_smoothed_pwdb
< txlowpower_threshold
&& priv
->bDynamicTxHighPower
)
3071 priv
->bDynamicTxHighPower
= false;
3073 /* low power state check */
3074 if (priv
->undecorated_smoothed_pwdb
< 35)
3075 priv
->bDynamicTxLowPower
= true;
3076 else if (priv
->undecorated_smoothed_pwdb
>= 40)
3077 priv
->bDynamicTxLowPower
= false;
3080 /*pHalData->bTXPowerCtrlforNearFarRange = !pHalData->bTXPowerCtrlforNearFarRange;*/
3081 priv
->bDynamicTxHighPower
= false;
3082 priv
->bDynamicTxLowPower
= false;
3085 if ((priv
->bDynamicTxHighPower
!= priv
->bLastDTPFlag_High
) ||
3086 (priv
->bDynamicTxLowPower
!= priv
->bLastDTPFlag_Low
)) {
3087 RT_TRACE(COMP_TXAGC
, "SetTxPowerLevel8190() channel = %d\n", priv
->ieee80211
->current_network
.channel
);
3089 #if defined(RTL8190P) || defined(RTL8192E)
3090 SetTxPowerLevel8190(Adapter
, pHalData
->CurrentChannel
);
3093 rtl8192_phy_setTxPower(dev
, priv
->ieee80211
->current_network
.channel
);
3094 /*pHalData->bStartTxCtrlByTPCNFR = FALSE; Clear th flag of Set TX Power from Sitesurvey*/
3096 priv
->bLastDTPFlag_High
= priv
->bDynamicTxHighPower
;
3097 priv
->bLastDTPFlag_Low
= priv
->bDynamicTxLowPower
;
3099 } /* dm_dynamic_txpower */
3101 /* added by vivi, for read tx rate and retrycount */
3102 static void dm_check_txrateandretrycount(struct net_device
*dev
)
3104 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3105 struct ieee80211_device
*ieee
= priv
->ieee80211
;
3106 /* for 11n tx rate */
3107 /*priv->stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);*/
3108 read_nic_byte(dev
, Current_Tx_Rate_Reg
, &ieee
->softmac_stats
.CurrentShowTxate
);
3109 /*printk("=============>tx_rate_reg:%x\n", ieee->softmac_stats.CurrentShowTxate);*/
3110 /* for initial tx rate */
3111 /*priv->stats.last_packet_rate = read_nic_byte(dev, Initial_Tx_Rate_Reg);*/
3112 read_nic_byte(dev
, Initial_Tx_Rate_Reg
, &ieee
->softmac_stats
.last_packet_rate
);
3113 /* for tx tx retry count */
3114 /*priv->stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);*/
3115 read_nic_dword(dev
, Tx_Retry_Count_Reg
, &ieee
->softmac_stats
.txretrycount
);
3118 static void dm_send_rssi_tofw(struct net_device
*dev
)
3120 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3123 * If we test chariot, we should stop the TX command ?
3124 * Because 92E will always silent reset when we send tx command. We use register
3125 * 0x1e0(byte) to notify driver.
3127 write_nic_byte(dev
, DRIVER_RSSI
, (u8
)priv
->undecorated_smoothed_pwdb
);
3130 /*---------------------------Define function prototype------------------------*/