~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/staging/rtl8192e/r8192E_dm.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
//
26
26
// Indicate different AP vendor for IOT issue.
27
27
//
28
 
#ifdef  RTL8190P
29
 
static const u32 edca_setting_DL[HT_IOT_PEER_MAX] =
30
 
{ 0x5e4322,     0x5e4322,       0x5e4322,       0x604322,       0xa44f,         0x5e4322,       0x5e4322};
31
 
static const u32 edca_setting_UL[HT_IOT_PEER_MAX] =
32
 
{ 0x5e4322,     0xa44f,         0x5e4322,       0x604322,       0x5e4322,       0x5e4322,       0x5e4322};
33
 
#else
34
 
#ifdef RTL8192E
35
28
static const u32 edca_setting_DL[HT_IOT_PEER_MAX] =
36
29
{ 0x5e4322,     0x5e4322,       0x5e4322,       0x604322,       0xa44f,         0x5e4322,       0x5e4322};
37
30
static const u32 edca_setting_UL[HT_IOT_PEER_MAX] =
38
31
{ 0x5e4322,     0xa44f,         0x5e4322,       0x604322,       0x5e4322,       0x5e4322,       0x5e4322};
39
 
#else
40
 
static const u32 edca_setting_DL[HT_IOT_PEER_MAX] =
41
 
{ 0x5e4322,     0x5e4322,       0x5e4322,       0x604322,       0xa44f,         0x5ea44f,       0x5e4322};
42
 
static const u32 edca_setting_UL[HT_IOT_PEER_MAX] =
43
 
{ 0x5e4322,     0xa44f,         0x5e4322,       0x604322,       0x5ea44f,       0x5ea44f,       0x5e4322};
44
 
#endif
45
 
#endif
46
32
 
47
33
#define RTK_UL_EDCA 0xa44f
48
34
#define RTK_DL_EDCA 0x5e4322
52
38
// For Dynamic Rx Path Selection by Signal Strength
53
39
DRxPathSel      DM_RxPathSelTable;
54
40
 
55
 
 
56
 
/*--------------------Define export function prototype-----------------------*/
57
 
extern  void    init_hal_dm(struct net_device *dev);
58
 
extern  void deinit_hal_dm(struct net_device *dev);
59
 
 
60
 
extern void hal_dm_watchdog(struct net_device *dev);
61
 
 
62
 
 
63
 
extern  void    init_rate_adaptive(struct net_device *dev);
64
 
extern  void    dm_txpower_trackingcallback(struct work_struct *work);
65
 
 
66
 
extern  void    dm_cck_txpower_adjust(struct net_device *dev,bool  binch14);
67
 
extern  void    dm_restore_dynamic_mechanism_state(struct net_device *dev);
68
 
extern  void    dm_backup_dynamic_mechanism_state(struct net_device *dev);
69
 
extern  void    dm_change_dynamic_initgain_thresh(struct net_device *dev,
70
 
                                                                u32             dm_type,
71
 
                                                                u32             dm_value);
72
 
extern  void    DM_ChangeFsyncSetting(struct net_device *dev,
73
 
                                                                                                s32             DM_Type,
74
 
                                                                                                s32             DM_Value);
75
 
extern  void dm_force_tx_fw_info(struct net_device *dev,
76
 
                                                                                u32             force_type,
77
 
                                                                                u32             force_value);
78
 
extern  void    dm_init_edca_turbo(struct net_device *dev);
79
 
extern  void    dm_rf_operation_test_callback(unsigned long data);
80
 
extern  void    dm_rf_pathcheck_workitemcallback(struct work_struct *work);
81
 
extern  void dm_fsync_timer_callback(unsigned long data);
82
 
extern  void dm_check_fsync(struct net_device *dev);
83
 
extern  void dm_initialize_txpower_tracking(struct net_device *dev);
84
 
 
85
 
#ifdef RTL8192E
86
 
extern  void    dm_gpio_change_rf_callback(struct work_struct *work);
87
 
#endif
88
 
 
 
41
void dm_gpio_change_rf_callback(struct work_struct *work);
89
42
 
90
43
// DM --> Rate Adaptive
91
 
static  void    dm_check_rate_adaptive(struct net_device *dev);
 
44
static void dm_check_rate_adaptive(struct r8192_priv *priv);
92
45
 
93
46
// DM --> Bandwidth switch
94
 
static  void    dm_init_bandwidth_autoswitch(struct net_device *dev);
95
 
static  void    dm_bandwidth_autoswitch(        struct net_device *dev);
 
47
static void dm_init_bandwidth_autoswitch(struct r8192_priv *priv);
 
48
static void dm_bandwidth_autoswitch(struct r8192_priv *priv);
96
49
 
97
50
// DM --> TX power control
98
 
static  void    dm_check_txpower_tracking(struct net_device *dev);
99
 
 
100
 
// DM --> BB init gain restore
101
 
#ifndef RTL8192U
102
 
static  void    dm_bb_initialgain_restore(struct net_device *dev);
103
 
 
104
 
// DM --> BB init gain backup
105
 
static  void    dm_bb_initialgain_backup(struct net_device *dev);
106
 
#endif
 
51
static void dm_check_txpower_tracking(struct r8192_priv *priv);
107
52
 
108
53
// DM --> Dynamic Init Gain by RSSI
109
 
static  void    dm_dig_init(struct net_device *dev);
110
 
static  void    dm_ctrl_initgain_byrssi(struct net_device *dev);
111
 
static  void    dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev);
112
 
static  void    dm_ctrl_initgain_byrssi_by_driverrssi(  struct net_device *dev);
113
 
static  void    dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct net_device *dev);
114
 
static  void    dm_initial_gain(struct net_device *dev);
115
 
static  void    dm_pd_th(struct net_device *dev);
116
 
static  void    dm_cs_ratio(struct net_device *dev);
 
54
static void dm_dig_init(struct r8192_priv *priv);
 
55
static void dm_ctrl_initgain_byrssi(struct r8192_priv *priv);
 
56
static void dm_ctrl_initgain_byrssi_highpwr(struct r8192_priv *priv);
 
57
static void dm_ctrl_initgain_byrssi_by_driverrssi(struct r8192_priv *priv);
 
58
static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct r8192_priv *priv);
 
59
static void dm_initial_gain(struct r8192_priv *priv);
 
60
static void dm_pd_th(struct r8192_priv *priv);
 
61
static void dm_cs_ratio(struct r8192_priv *priv);
117
62
 
118
 
static  void dm_init_ctstoself(struct net_device *dev);
 
63
static void dm_init_ctstoself(struct r8192_priv *priv);
119
64
// DM --> EDCA turboe mode control
120
 
static  void    dm_check_edca_turbo(struct net_device *dev);
 
65
static void dm_check_edca_turbo(struct r8192_priv *priv);
 
66
static void dm_init_edca_turbo(struct r8192_priv *priv);
121
67
 
122
68
// DM --> HW RF control
123
 
static  void    dm_check_rfctrl_gpio(struct net_device *dev);
124
 
 
125
 
// DM --> Check PBC
126
 
static  void dm_check_pbc_gpio(struct net_device *dev);
 
69
static void dm_check_rfctrl_gpio(struct r8192_priv *priv);
127
70
 
128
71
// DM --> Check current RX RF path state
129
 
static  void    dm_check_rx_path_selection(struct net_device *dev);
130
 
static  void dm_init_rxpath_selection(struct net_device *dev);
131
 
static  void dm_rxpath_sel_byrssi(struct net_device *dev);
 
72
static void dm_check_rx_path_selection(struct r8192_priv *priv);
 
73
static void dm_init_rxpath_selection(struct r8192_priv *priv);
 
74
static void dm_rxpath_sel_byrssi(struct r8192_priv *priv);
132
75
 
133
76
// DM --> Fsync for broadcom ap
134
 
static void dm_init_fsync(struct net_device *dev);
135
 
static void dm_deInit_fsync(struct net_device *dev);
 
77
static void dm_init_fsync(struct r8192_priv *priv);
 
78
static void dm_deInit_fsync(struct r8192_priv *priv);
136
79
 
137
 
static  void    dm_check_txrateandretrycount(struct net_device *dev);
 
80
static void dm_check_txrateandretrycount(struct r8192_priv *priv);
 
81
static void dm_check_fsync(struct r8192_priv *priv);
138
82
 
139
83
 
140
84
/*---------------------Define of Tx Power Control For Near/Far Range --------*/   //Add by Jacken 2008/02/18
141
 
static  void    dm_init_dynamic_txpower(struct net_device *dev);
142
 
static  void    dm_dynamic_txpower(struct net_device *dev);
 
85
static void dm_init_dynamic_txpower(struct r8192_priv *priv);
 
86
static void dm_dynamic_txpower(struct r8192_priv *priv);
143
87
 
144
88
// DM --> For rate adaptive and DIG, we must send RSSI to firmware
145
 
static  void dm_send_rssi_tofw(struct net_device *dev);
146
 
static  void    dm_ctstoself(struct net_device *dev);
 
89
static void dm_send_rssi_tofw(struct r8192_priv *priv);
 
90
static void dm_ctstoself(struct r8192_priv *priv);
 
91
 
 
92
static void dm_fsync_timer_callback(unsigned long data);
147
93
 
148
94
/*
149
95
 * Prepare SW resource for HW dynamic mechanism.
150
96
 * This function is only invoked at driver intialization once.
151
97
 */
152
 
void init_hal_dm(struct net_device *dev)
 
98
void init_hal_dm(struct r8192_priv *priv)
153
99
{
154
 
        struct r8192_priv *priv = ieee80211_priv(dev);
155
 
 
156
100
        // Undecorated Smoothed Signal Strength, it can utilized to dynamic mechanism.
157
101
        priv->undecorated_smoothed_pwdb = -1;
158
102
 
159
103
        //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code.
160
 
        dm_init_dynamic_txpower(dev);
161
 
        init_rate_adaptive(dev);
 
104
        dm_init_dynamic_txpower(priv);
 
105
        init_rate_adaptive(priv);
162
106
        //dm_initialize_txpower_tracking(dev);
163
 
        dm_dig_init(dev);
164
 
        dm_init_edca_turbo(dev);
165
 
        dm_init_bandwidth_autoswitch(dev);
166
 
        dm_init_fsync(dev);
167
 
        dm_init_rxpath_selection(dev);
168
 
        dm_init_ctstoself(dev);
169
 
#ifdef RTL8192E
 
107
        dm_dig_init(priv);
 
108
        dm_init_edca_turbo(priv);
 
109
        dm_init_bandwidth_autoswitch(priv);
 
110
        dm_init_fsync(priv);
 
111
        dm_init_rxpath_selection(priv);
 
112
        dm_init_ctstoself(priv);
170
113
        INIT_DELAYED_WORK(&priv->gpio_change_rf_wq,  dm_gpio_change_rf_callback);
171
 
#endif
172
 
 
173
 
}
174
 
 
175
 
void deinit_hal_dm(struct net_device *dev)
176
 
{
177
 
 
178
 
        dm_deInit_fsync(dev);
179
 
 
180
 
}
181
 
 
182
 
 
183
 
#ifdef USB_RX_AGGREGATION_SUPPORT
184
 
void dm_CheckRxAggregation(struct net_device *dev) {
185
 
        struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
186
 
        PRT_HIGH_THROUGHPUT     pHTInfo = priv->ieee80211->pHTInfo;
187
 
        static unsigned long    lastTxOkCnt = 0;
188
 
        static unsigned long    lastRxOkCnt = 0;
189
 
        unsigned long           curTxOkCnt = 0;
190
 
        unsigned long           curRxOkCnt = 0;
191
 
 
192
 
/*
193
 
        if (pHalData->bForcedUsbRxAggr) {
194
 
                if (pHalData->ForcedUsbRxAggrInfo == 0) {
195
 
                        if (pHalData->bCurrentRxAggrEnable) {
196
 
                                Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, FALSE);
197
 
                        }
198
 
                } else {
199
 
                        if (!pHalData->bCurrentRxAggrEnable || (pHalData->ForcedUsbRxAggrInfo != pHalData->LastUsbRxAggrInfoSetting)) {
200
 
                                Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, TRUE);
201
 
                        }
202
 
                }
203
 
                return;
204
 
        }
205
 
 
206
 
*/
207
 
        curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt;
208
 
        curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt;
209
 
 
210
 
        if((curTxOkCnt + curRxOkCnt) < 15000000) {
211
 
                return;
212
 
        }
213
 
 
214
 
        if(curTxOkCnt > 4*curRxOkCnt) {
215
 
                if (priv->bCurrentRxAggrEnable) {
216
 
                        write_nic_dword(dev, 0x1a8, 0);
217
 
                        priv->bCurrentRxAggrEnable = false;
218
 
                }
219
 
        }else{
220
 
                if (!priv->bCurrentRxAggrEnable && !pHTInfo->bCurrentRT2RTAggregation) {
221
 
                        u32 ulValue;
222
 
                        ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) |
223
 
                                (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout);
224
 
                        /*
225
 
                         * If usb rx firmware aggregation is enabled,
226
 
                         * when anyone of three threshold conditions above is reached,
227
 
                         * firmware will send aggregated packet to driver.
228
 
                         */
229
 
                        write_nic_dword(dev, 0x1a8, ulValue);
230
 
                        priv->bCurrentRxAggrEnable = true;
231
 
                }
232
 
        }
233
 
 
234
 
        lastTxOkCnt = priv->stats.txbytesunicast;
235
 
        lastRxOkCnt = priv->stats.rxbytesunicast;
236
 
}
237
 
#endif
238
 
 
239
 
 
240
 
// call the script file to enable
241
 
void dm_check_ac_dc_power(struct net_device *dev)
242
 
{
243
 
        struct r8192_priv *priv = ieee80211_priv(dev);
244
 
        static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh";
245
 
        char *argv[] = {ac_dc_check_script_path,DRV_NAME,NULL};
246
 
        static char *envp[] = {"HOME=/",
247
 
                        "TERM=linux",
248
 
                        "PATH=/usr/bin:/bin",
249
 
                         NULL};
250
 
 
251
 
        if(priv->ResetProgress == RESET_TYPE_SILENT)
252
 
        {
253
 
                RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n");
254
 
                return;
255
 
        }
256
 
 
257
 
        if(priv->ieee80211->state != IEEE80211_LINKED) {
258
 
                return;
259
 
        }
260
 
        call_usermodehelper(ac_dc_check_script_path,argv,envp,1);
261
 
}
262
 
 
263
 
void hal_dm_watchdog(struct net_device *dev)
264
 
{
265
 
        dm_check_ac_dc_power(dev);
 
114
 
 
115
}
 
116
 
 
117
void deinit_hal_dm(struct r8192_priv *priv)
 
118
{
 
119
        dm_deInit_fsync(priv);
 
120
}
 
121
 
 
122
void hal_dm_watchdog(struct r8192_priv *priv)
 
123
{
266
124
 
267
125
        /*Add by amy 2008/05/15 ,porting from windows code.*/
268
 
        dm_check_rate_adaptive(dev);
269
 
        dm_dynamic_txpower(dev);
270
 
        dm_check_txrateandretrycount(dev);
271
 
 
272
 
        dm_check_txpower_tracking(dev);
273
 
 
274
 
        dm_ctrl_initgain_byrssi(dev);
275
 
        dm_check_edca_turbo(dev);
276
 
        dm_bandwidth_autoswitch(dev);
277
 
 
278
 
        dm_check_rfctrl_gpio(dev);
279
 
        dm_check_rx_path_selection(dev);
280
 
        dm_check_fsync(dev);
 
126
        dm_check_rate_adaptive(priv);
 
127
        dm_dynamic_txpower(priv);
 
128
        dm_check_txrateandretrycount(priv);
 
129
 
 
130
        dm_check_txpower_tracking(priv);
 
131
 
 
132
        dm_ctrl_initgain_byrssi(priv);
 
133
        dm_check_edca_turbo(priv);
 
134
        dm_bandwidth_autoswitch(priv);
 
135
 
 
136
        dm_check_rfctrl_gpio(priv);
 
137
        dm_check_rx_path_selection(priv);
 
138
        dm_check_fsync(priv);
281
139
 
282
140
        // Add by amy 2008-05-15 porting from windows code.
283
 
        dm_check_pbc_gpio(dev);
284
 
        dm_send_rssi_tofw(dev);
285
 
        dm_ctstoself(dev);
286
 
 
287
 
#ifdef USB_RX_AGGREGATION_SUPPORT
288
 
        dm_CheckRxAggregation(dev);
289
 
#endif
 
141
        dm_send_rssi_tofw(priv);
 
142
        dm_ctstoself(priv);
290
143
}
291
144
 
292
145
 
296
149
  *     01/16/2008      MHC             RF_Type is assigned in ReadAdapterInfo(). We must call
297
150
  *                                             the function after making sure RF_Type.
298
151
  */
299
 
void init_rate_adaptive(struct net_device * dev)
 
152
void init_rate_adaptive(struct r8192_priv *priv)
300
153
{
301
 
 
302
 
        struct r8192_priv *priv = ieee80211_priv(dev);
303
 
        prate_adaptive                  pra = (prate_adaptive)&priv->rate_adaptive;
 
154
        prate_adaptive pra = &priv->rate_adaptive;
304
155
 
305
156
        pra->ratr_state = DM_RATR_STA_MAX;
306
157
        pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High;
342
193
}
343
194
 
344
195
 
345
 
static void dm_check_rate_adaptive(struct net_device * dev)
 
196
static void dm_check_rate_adaptive(struct r8192_priv *priv)
346
197
{
347
 
        struct r8192_priv *priv = ieee80211_priv(dev);
348
198
        PRT_HIGH_THROUGHPUT     pHTInfo = priv->ieee80211->pHTInfo;
349
199
        prate_adaptive                  pra = (prate_adaptive)&priv->rate_adaptive;
350
200
        u32                                             currentRATR, targetRATR = 0;
421
271
                                        (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M);
422
272
                }
423
273
 
424
 
                //DbgPrint("[DM] Thresh H/L=%d/%d\n\r", RATR.HighRSSIThreshForRA, RATR.LowRSSIThreshForRA);
425
274
                if(priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA)
426
275
                {
427
 
                        //DbgPrint("[DM] RSSI=%d STA=HIGH\n\r", pHalData->UndecoratedSmoothedPWDB);
428
276
                        pra->ratr_state = DM_RATR_STA_HIGH;
429
277
                        targetRATR = pra->upper_rssi_threshold_ratr;
430
278
                }else if(priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA)
431
279
                {
432
 
                        //DbgPrint("[DM] RSSI=%d STA=Middle\n\r", pHalData->UndecoratedSmoothedPWDB);
433
280
                        pra->ratr_state = DM_RATR_STA_MIDDLE;
434
281
                        targetRATR = pra->middle_rssi_threshold_ratr;
435
282
                }else
436
283
                {
437
 
                        //DbgPrint("[DM] RSSI=%d STA=LOW\n\r", pHalData->UndecoratedSmoothedPWDB);
438
284
                        pra->ratr_state = DM_RATR_STA_LOW;
439
285
                        targetRATR = pra->low_rssi_threshold_ratr;
440
286
                }
448
294
                                if( (priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) ||
449
295
                                        ping_rssi_state )
450
296
                                {
451
 
                                        //DbgPrint("TestRSSI = %d, set RATR to 0x%x \n", pHalData->UndecoratedSmoothedPWDB, pRA->TestRSSIRATR);
452
297
                                        pra->ratr_state = DM_RATR_STA_LOW;
453
298
                                        targetRATR = pra->ping_rssi_ratr;
454
299
                                        ping_rssi_state = 1;
455
300
                                }
456
 
                                //else
457
 
                                //      DbgPrint("TestRSSI is between the range. \n");
458
301
                        }
459
302
                        else
460
303
                        {
461
 
                                //DbgPrint("TestRSSI Recover to 0x%x \n", targetRATR);
462
304
                                ping_rssi_state = 0;
463
305
                        }
464
306
                }
465
307
 
466
 
                // 2008.04.01
467
 
#if 1
468
308
                // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
469
 
                if(priv->ieee80211->GetHalfNmodeSupportByAPsHandler(dev))
 
309
                if(priv->ieee80211->GetHalfNmodeSupportByAPsHandler(priv->ieee80211))
470
310
                        targetRATR &=  0xf00fffff;
471
 
#endif
472
311
 
473
312
                //
474
313
                // Check whether updating of RATR0 is required
475
314
                //
476
 
                currentRATR = read_nic_dword(dev, RATR0);
 
315
                currentRATR = read_nic_dword(priv, RATR0);
477
316
                if( targetRATR !=  currentRATR )
478
317
                {
479
318
                        u32 ratr_value;
483
322
                        {
484
323
                                ratr_value &= ~(RATE_ALL_OFDM_2SS);
485
324
                        }
486
 
                        write_nic_dword(dev, RATR0, ratr_value);
487
 
                        write_nic_byte(dev, UFWP, 1);
 
325
                        write_nic_dword(priv, RATR0, ratr_value);
 
326
                        write_nic_byte(priv, UFWP, 1);
488
327
 
489
328
                        pra->last_ratr = targetRATR;
490
329
                }
498
337
}
499
338
 
500
339
 
501
 
static void dm_init_bandwidth_autoswitch(struct net_device * dev)
 
340
static void dm_init_bandwidth_autoswitch(struct r8192_priv *priv)
502
341
{
503
 
        struct r8192_priv *priv = ieee80211_priv(dev);
504
 
 
505
342
        priv->ieee80211->bandwidth_auto_switch.threshold_20Mhzto40Mhz = BW_AUTO_SWITCH_LOW_HIGH;
506
343
        priv->ieee80211->bandwidth_auto_switch.threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW;
507
344
        priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = false;
510
347
}
511
348
 
512
349
 
513
 
static void dm_bandwidth_autoswitch(struct net_device * dev)
 
350
static void dm_bandwidth_autoswitch(struct r8192_priv *priv)
514
351
{
515
 
        struct r8192_priv *priv = ieee80211_priv(dev);
516
 
 
517
352
        if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||!priv->ieee80211->bandwidth_auto_switch.bautoswitch_enable){
518
353
                return;
519
354
        }else{
529
364
}
530
365
 
531
366
//OFDM default at 0db, index=6.
532
 
#ifndef RTL8190P
533
367
static const u32 OFDMSwingTable[OFDM_Table_Length] = {
534
368
        0x7f8001fe,     // 0, +6db
535
369
        0x71c001c7,     // 1, +5db
580
414
        {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},       // 10, -10db
581
415
        {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}        // 11, -11db
582
416
};
583
 
#endif
 
417
 
584
418
#define         Pw_Track_Flag                           0x11d
585
419
#define         Tssi_Mea_Value                          0x13c
586
420
#define         Tssi_Report_Value1                      0x134
587
421
#define         Tssi_Report_Value2                      0x13e
588
422
#define         FW_Busy_Flag                            0x13f
589
 
static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev)
590
 
        {
591
 
        struct r8192_priv *priv = ieee80211_priv(dev);
 
423
static void dm_TXPowerTrackingCallback_TSSI(struct r8192_priv *priv)
 
424
{
592
425
        bool                                            bHighpowerstate, viviflag = FALSE;
593
426
        DCMD_TXCMD_T                    tx_cmd;
594
427
        u8                                      powerlevelOFDM24G;
597
430
        u32                                             Value;
598
431
        u8                                              Pwr_Flag;
599
432
        u16                                     Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0;
600
 
#ifdef RTL8192U
601
 
        RT_STATUS                               rtStatus = RT_STATUS_SUCCESS;
602
 
#endif
603
433
//      bool rtStatus = true;
604
434
        u32                                             delta=0;
605
435
        RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__FUNCTION__);
606
 
//      write_nic_byte(dev, 0x1ba, 0);
607
 
        write_nic_byte(dev, Pw_Track_Flag, 0);
608
 
        write_nic_byte(dev, FW_Busy_Flag, 0);
 
436
//      write_nic_byte(priv, 0x1ba, 0);
 
437
        write_nic_byte(priv, Pw_Track_Flag, 0);
 
438
        write_nic_byte(priv, FW_Busy_Flag, 0);
609
439
        priv->ieee80211->bdynamic_txpower_enable = false;
610
440
        bHighpowerstate = priv->bDynamicTxHighPower;
611
441
 
621
451
        tx_cmd.Op               = TXCMD_SET_TX_PWR_TRACKING;
622
452
        tx_cmd.Length   = 4;
623
453
        tx_cmd.Value            = Value;
624
 
#ifdef RTL8192U
625
 
        rtStatus = SendTxCommandPacket(dev, &tx_cmd, 12);
626
 
        if (rtStatus == RT_STATUS_FAILURE)
627
 
        {
628
 
                RT_TRACE(COMP_POWER_TRACKING, "Set configuration with tx cmd queue fail!\n");
629
 
        }
630
 
#else
631
 
        cmpk_message_handle_tx(dev, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T));
632
 
#endif
 
454
        cmpk_message_handle_tx(priv, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T));
633
455
        mdelay(1);
634
 
        //DbgPrint("hi, vivi, strange\n");
 
456
 
635
457
        for(i = 0;i <= 30; i++)
636
458
        {
637
 
                Pwr_Flag = read_nic_byte(dev, Pw_Track_Flag);
 
459
                Pwr_Flag = read_nic_byte(priv, Pw_Track_Flag);
638
460
 
639
461
                if (Pwr_Flag == 0)
640
462
                {
642
464
                        continue;
643
465
                }
644
466
 
645
 
                Avg_TSSI_Meas = read_nic_word(dev, Tssi_Mea_Value);
 
467
                Avg_TSSI_Meas = read_nic_word(priv, Tssi_Mea_Value);
646
468
 
647
469
                if(Avg_TSSI_Meas == 0)
648
470
                {
649
 
                        write_nic_byte(dev, Pw_Track_Flag, 0);
650
 
                        write_nic_byte(dev, FW_Busy_Flag, 0);
 
471
                        write_nic_byte(priv, Pw_Track_Flag, 0);
 
472
                        write_nic_byte(priv, FW_Busy_Flag, 0);
651
473
                        return;
652
474
                }
653
475
 
654
476
                for(k = 0;k < 5; k++)
655
477
                {
656
478
                        if(k !=4)
657
 
                                tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value1+k);
 
479
                                tmp_report[k] = read_nic_byte(priv, Tssi_Report_Value1+k);
658
480
                        else
659
 
                                tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value2);
 
481
                                tmp_report[k] = read_nic_byte(priv, Tssi_Report_Value2);
660
482
 
661
483
                        RT_TRACE(COMP_POWER_TRACKING, "TSSI_report_value = %d\n", tmp_report[k]);
662
484
                }
672
494
                }
673
495
                if(viviflag ==TRUE)
674
496
                {
675
 
                        write_nic_byte(dev, Pw_Track_Flag, 0);
 
497
                        write_nic_byte(priv, Pw_Track_Flag, 0);
676
498
                        viviflag = FALSE;
677
499
                        RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n");
678
500
                        for(k = 0;k < 5; k++)
700
522
                if(delta <= E_FOR_TX_POWER_TRACK)
701
523
                {
702
524
                        priv->ieee80211->bdynamic_txpower_enable = TRUE;
703
 
                        write_nic_byte(dev, Pw_Track_Flag, 0);
704
 
                        write_nic_byte(dev, FW_Busy_Flag, 0);
 
525
                        write_nic_byte(priv, Pw_Track_Flag, 0);
 
526
                        write_nic_byte(priv, FW_Busy_Flag, 0);
705
527
                        RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n");
706
528
                        RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex);
707
529
                        RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real);
708
 
#ifdef RTL8190P
709
 
                        RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex);
710
 
                        RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real);
711
 
#endif
712
530
                        RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference);
713
531
                        RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation);
714
532
                        return;
726
544
                                        if(priv->rfa_txpowertrackingindex_real > 4)
727
545
                                        {
728
546
                                                priv->rfa_txpowertrackingindex_real--;
729
 
                                                rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
 
547
                                                rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
730
548
                                        }
731
549
 
732
550
                                        priv->rfc_txpowertrackingindex--;
733
551
                                        if(priv->rfc_txpowertrackingindex_real > 4)
734
552
                                        {
735
553
                                                priv->rfc_txpowertrackingindex_real--;
736
 
                                                rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
 
554
                                                rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
737
555
                                        }
738
556
                                                }
739
557
                                                else
740
558
                                                {
741
 
                                                                rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
742
 
                                                                rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
 
559
                                                                rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
 
560
                                                                rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
743
561
                                }
744
562
                        }
745
563
                        else
750
568
                                                        if(priv->rfc_txpowertrackingindex_real > 4)
751
569
                                                        {
752
570
                                                                priv->rfc_txpowertrackingindex_real--;
753
 
                                                                rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
 
571
                                                                rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
754
572
                                                        }
755
573
                                                }
756
574
                                                else
757
 
                                                        rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
 
575
                                                        rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
758
576
                                }
759
577
                        }
760
578
                        else
765
583
                                {
766
584
                                        priv->rfa_txpowertrackingindex++;
767
585
                                        priv->rfa_txpowertrackingindex_real++;
768
 
                                        rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
 
586
                                        rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
769
587
                                        priv->rfc_txpowertrackingindex++;
770
588
                                        priv->rfc_txpowertrackingindex_real++;
771
 
                                        rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
 
589
                                        rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
772
590
                                }
773
591
                                        else
774
592
                                        {
775
 
                                                rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
776
 
                                                rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
 
593
                                                rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
 
594
                                                rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
777
595
                        }
778
596
                                }
779
597
                                else
782
600
                                        {
783
601
                                                        priv->rfc_txpowertrackingindex++;
784
602
                                                        priv->rfc_txpowertrackingindex_real++;
785
 
                                                        rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
 
603
                                                        rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
786
604
                                        }
787
605
                                        else
788
 
                                                        rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
 
606
                                                        rtl8192_setBBreg(priv, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
789
607
                                }
790
608
                        }
791
609
                        if (RF_Type == RF_2T4R)
812
630
                                if(priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14)
813
631
                                {
814
632
                                        priv->bcck_in_ch14 = TRUE;
815
 
                                        dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
 
633
                                        dm_cck_txpower_adjust(priv, priv->bcck_in_ch14);
816
634
                                }
817
635
                                else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14)
818
636
                                {
819
637
                                        priv->bcck_in_ch14 = FALSE;
820
 
                                        dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
 
638
                                        dm_cck_txpower_adjust(priv, priv->bcck_in_ch14);
821
639
                                }
822
640
                                else
823
 
                                        dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
 
641
                                        dm_cck_txpower_adjust(priv, priv->bcck_in_ch14);
824
642
                        }
825
643
                RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex);
826
644
                RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real);
827
 
#ifdef RTL8190P
828
 
                RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex);
829
 
                RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real);
830
 
#endif
831
645
                RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference);
832
646
                RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation);
833
647
 
834
648
                if (priv->CCKPresentAttentuation_difference <= -12||priv->CCKPresentAttentuation_difference >= 24)
835
649
                {
836
650
                        priv->ieee80211->bdynamic_txpower_enable = TRUE;
837
 
                        write_nic_byte(dev, Pw_Track_Flag, 0);
838
 
                        write_nic_byte(dev, FW_Busy_Flag, 0);
 
651
                        write_nic_byte(priv, Pw_Track_Flag, 0);
 
652
                        write_nic_byte(priv, FW_Busy_Flag, 0);
839
653
                        RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n");
840
654
                        return;
841
655
                }
842
656
 
843
657
 
844
658
        }
845
 
                write_nic_byte(dev, Pw_Track_Flag, 0);
 
659
                write_nic_byte(priv, Pw_Track_Flag, 0);
846
660
                Avg_TSSI_Meas_from_driver = 0;
847
661
                for(k = 0;k < 5; k++)
848
662
                        tmp_report[k] = 0;
849
663
                break;
850
664
        }
851
 
        write_nic_byte(dev, FW_Busy_Flag, 0);
 
665
        write_nic_byte(priv, FW_Busy_Flag, 0);
852
666
}
853
667
                priv->ieee80211->bdynamic_txpower_enable = TRUE;
854
 
                write_nic_byte(dev, Pw_Track_Flag, 0);
 
668
                write_nic_byte(priv, Pw_Track_Flag, 0);
855
669
}
856
 
#ifndef RTL8190P
857
 
static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev)
 
670
 
 
671
static void dm_TXPowerTrackingCallback_ThermalMeter(struct r8192_priv *priv)
858
672
{
859
673
#define ThermalMeterVal 9
860
 
        struct r8192_priv *priv = ieee80211_priv(dev);
861
674
        u32 tmpRegA, TempCCk;
862
675
        u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval;
863
676
        int i =0, CCKSwingNeedUpdate=0;
865
678
        if(!priv->btxpower_trackingInit)
866
679
        {
867
680
                //Query OFDM default setting
868
 
                tmpRegA= rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord);
 
681
                tmpRegA = rtl8192_QueryBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord);
869
682
                for(i=0; i<OFDM_Table_Length; i++)      //find the index
870
683
                {
871
684
                        if(tmpRegA == OFDMSwingTable[i])
877
690
                }
878
691
 
879
692
                //Query CCK default setting From 0xa22
880
 
                TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2);
 
693
                TempCCk = rtl8192_QueryBBReg(priv, rCCK0_TxFilter1, bMaskByte2);
881
694
                for(i=0 ; i<CCK_Table_length ; i++)
882
695
                {
883
696
                        if(TempCCk == (u32)CCKSwingTable_Ch1_Ch13[i][0])
894
707
        }
895
708
 
896
709
        // read and filter out unreasonable value
897
 
        tmpRegA = rtl8192_phy_QueryRFReg(dev, RF90_PATH_A, 0x12, 0x078);        // 0x12: RF Reg[10:7]
898
 
        RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d \n", tmpRegA);
 
710
        tmpRegA = rtl8192_phy_QueryRFReg(priv, RF90_PATH_A, 0x12, 0x078);       // 0x12: RF Reg[10:7]
 
711
        RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d\n", tmpRegA);
899
712
        if(tmpRegA < 3 || tmpRegA > 13)
900
713
                return;
901
714
        if(tmpRegA >= 12)       // if over 12, TP will be bad when high temperature
902
715
                tmpRegA = 12;
903
 
        RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d \n", tmpRegA);
 
716
        RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d\n", tmpRegA);
904
717
        priv->ThermalMeter[0] = ThermalMeterVal;        //We use fixed value by Bryant's suggestion
905
718
        priv->ThermalMeter[1] = ThermalMeterVal;        //We use fixed value by Bryant's suggestion
906
719
 
925
738
                        tmpOFDMindex = tmpCCK20Mindex = 6 - tmpval;
926
739
                tmpCCK40Mindex = 0;
927
740
        }
928
 
        //DbgPrint("%ddb, tmpOFDMindex = %d, tmpCCK20Mindex = %d, tmpCCK40Mindex = %d",
929
 
                //((u1Byte)tmpRegA - pHalData->ThermalMeter[0]),
930
 
                //tmpOFDMindex, tmpCCK20Mindex, tmpCCK40Mindex);
 
741
 
931
742
        if(priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)       //40M
932
743
                tmpCCKindex = tmpCCK40Mindex;
933
744
        else
958
769
 
959
770
        if(CCKSwingNeedUpdate)
960
771
        {
961
 
                //DbgPrint("Update CCK Swing, CCK_index = %d\n", pHalData->CCK_index);
962
 
                dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
 
772
                dm_cck_txpower_adjust(priv, priv->bcck_in_ch14);
963
773
        }
964
774
        if(priv->OFDM_index != tmpOFDMindex)
965
775
        {
966
776
                priv->OFDM_index = tmpOFDMindex;
967
 
                rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index]);
 
777
                rtl8192_setBBreg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index]);
968
778
                RT_TRACE(COMP_POWER_TRACKING, "Update OFDMSwing[%d] = 0x%x\n",
969
779
                        priv->OFDM_index, OFDMSwingTable[priv->OFDM_index]);
970
780
        }
971
781
        priv->txpower_count = 0;
972
782
}
973
 
#endif
 
783
 
974
784
void dm_txpower_trackingcallback(struct work_struct *work)
975
785
{
976
786
        struct delayed_work *dwork = container_of(work,struct delayed_work,work);
977
 
       struct r8192_priv *priv = container_of(dwork,struct r8192_priv,txpower_tracking_wq);
978
 
       struct net_device *dev = priv->ieee80211->dev;
 
787
        struct r8192_priv *priv = container_of(dwork,struct r8192_priv,txpower_tracking_wq);
979
788
 
980
 
#ifdef RTL8190P
981
 
        dm_TXPowerTrackingCallback_TSSI(dev);
982
 
#else
983
 
        //if(priv->bDcut == TRUE)
984
789
        if(priv->IC_Cut >= IC_VersionCut_D)
985
 
                dm_TXPowerTrackingCallback_TSSI(dev);
 
790
                dm_TXPowerTrackingCallback_TSSI(priv);
986
791
        else
987
 
                dm_TXPowerTrackingCallback_ThermalMeter(dev);
988
 
#endif
 
792
                dm_TXPowerTrackingCallback_ThermalMeter(priv);
989
793
}
990
794
 
991
795
 
992
 
static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev)
 
796
static const txbbgain_struct rtl8192_txbbgain_table[] = {
 
797
        { 12,   0x7f8001fe },
 
798
        { 11,   0x788001e2 },
 
799
        { 10,   0x71c001c7 },
 
800
        { 9,    0x6b8001ae },
 
801
        { 8,    0x65400195 },
 
802
        { 7,    0x5fc0017f },
 
803
        { 6,    0x5a400169 },
 
804
        { 5,    0x55400155 },
 
805
        { 4,    0x50800142 },
 
806
        { 3,    0x4c000130 },
 
807
        { 2,    0x47c0011f },
 
808
        { 1,    0x43c0010f },
 
809
        { 0,    0x40000100 },
 
810
        { -1,   0x3c8000f2 },
 
811
        { -2,   0x390000e4 },
 
812
        { -3,   0x35c000d7 },
 
813
        { -4,   0x32c000cb },
 
814
        { -5,   0x300000c0 },
 
815
        { -6,   0x2d4000b5 },
 
816
        { -7,   0x2ac000ab },
 
817
        { -8,   0x288000a2 },
 
818
        { -9,   0x26000098 },
 
819
        { -10,  0x24000090 },
 
820
        { -11,  0x22000088 },
 
821
        { -12,  0x20000080 },
 
822
        { -13,  0x1a00006c },
 
823
        { -14,  0x1c800072 },
 
824
        { -15,  0x18000060 },
 
825
        { -16,  0x19800066 },
 
826
        { -17,  0x15800056 },
 
827
        { -18,  0x26c0005b },
 
828
        { -19,  0x14400051 },
 
829
        { -20,  0x24400051 },
 
830
        { -21,  0x1300004c },
 
831
        { -22,  0x12000048 },
 
832
        { -23,  0x11000044 },
 
833
        { -24,  0x10000040 },
 
834
};
 
835
 
 
836
/*
 
837
 * ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
 
838
 * This Table is for CH1~CH13
 
839
 */
 
840
static const ccktxbbgain_struct rtl8192_cck_txbbgain_table[] = {
 
841
        {{ 0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04 }},
 
842
        {{ 0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04 }},
 
843
        {{ 0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03 }},
 
844
        {{ 0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03 }},
 
845
        {{ 0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03 }},
 
846
        {{ 0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03 }},
 
847
        {{ 0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03 }},
 
848
        {{ 0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03 }},
 
849
        {{ 0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02 }},
 
850
        {{ 0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02 }},
 
851
        {{ 0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02 }},
 
852
        {{ 0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02 }},
 
853
        {{ 0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02 }},
 
854
        {{ 0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02 }},
 
855
        {{ 0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02 }},
 
856
        {{ 0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02 }},
 
857
        {{ 0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01 }},
 
858
        {{ 0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02 }},
 
859
        {{ 0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01 }},
 
860
        {{ 0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01 }},
 
861
        {{ 0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01 }},
 
862
        {{ 0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01 }},
 
863
        {{ 0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01 }},
 
864
};
 
865
 
 
866
/*
 
867
 * ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
 
868
 * This Table is for CH14
 
869
 */
 
870
static const ccktxbbgain_struct rtl8192_cck_txbbgain_ch14_table[] = {
 
871
        {{ 0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00 }},
 
872
        {{ 0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00 }},
 
873
        {{ 0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00 }},
 
874
        {{ 0x2d, 0x2d, 0x27, 0x17, 0x00, 0x00, 0x00, 0x00 }},
 
875
        {{ 0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00 }},
 
876
        {{ 0x28, 0x28, 0x22, 0x14, 0x00, 0x00, 0x00, 0x00 }},
 
877
        {{ 0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00 }},
 
878
        {{ 0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00 }},
 
879
        {{ 0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00 }},
 
880
        {{ 0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00 }},
 
881
        {{ 0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00 }},
 
882
        {{ 0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00 }},
 
883
        {{ 0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00 }},
 
884
        {{ 0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00 }},
 
885
        {{ 0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00 }},
 
886
        {{ 0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00 }},
 
887
        {{ 0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00 }},
 
888
        {{ 0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00 }},
 
889
        {{ 0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00 }},
 
890
        {{ 0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00 }},
 
891
        {{ 0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00 }},
 
892
        {{ 0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00 }},
 
893
        {{ 0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00 }},
 
894
};
 
895
 
 
896
static void dm_InitializeTXPowerTracking_TSSI(struct r8192_priv *priv)
993
897
{
994
 
 
995
 
        struct r8192_priv *priv = ieee80211_priv(dev);
996
 
 
997
 
        //Initial the Tx BB index and mapping value
998
 
        priv->txbbgain_table[0].txbb_iq_amplifygain =                   12;
999
 
        priv->txbbgain_table[0].txbbgain_value=0x7f8001fe;
1000
 
        priv->txbbgain_table[1].txbb_iq_amplifygain =                   11;
1001
 
        priv->txbbgain_table[1].txbbgain_value=0x788001e2;
1002
 
        priv->txbbgain_table[2].txbb_iq_amplifygain =                   10;
1003
 
        priv->txbbgain_table[2].txbbgain_value=0x71c001c7;
1004
 
        priv->txbbgain_table[3].txbb_iq_amplifygain =                   9;
1005
 
        priv->txbbgain_table[3].txbbgain_value=0x6b8001ae;
1006
 
        priv->txbbgain_table[4].txbb_iq_amplifygain =                  8;
1007
 
        priv->txbbgain_table[4].txbbgain_value=0x65400195;
1008
 
        priv->txbbgain_table[5].txbb_iq_amplifygain =                  7;
1009
 
        priv->txbbgain_table[5].txbbgain_value=0x5fc0017f;
1010
 
        priv->txbbgain_table[6].txbb_iq_amplifygain =                  6;
1011
 
        priv->txbbgain_table[6].txbbgain_value=0x5a400169;
1012
 
        priv->txbbgain_table[7].txbb_iq_amplifygain =                  5;
1013
 
        priv->txbbgain_table[7].txbbgain_value=0x55400155;
1014
 
        priv->txbbgain_table[8].txbb_iq_amplifygain =                  4;
1015
 
        priv->txbbgain_table[8].txbbgain_value=0x50800142;
1016
 
        priv->txbbgain_table[9].txbb_iq_amplifygain =                  3;
1017
 
        priv->txbbgain_table[9].txbbgain_value=0x4c000130;
1018
 
        priv->txbbgain_table[10].txbb_iq_amplifygain =                 2;
1019
 
        priv->txbbgain_table[10].txbbgain_value=0x47c0011f;
1020
 
        priv->txbbgain_table[11].txbb_iq_amplifygain =                 1;
1021
 
        priv->txbbgain_table[11].txbbgain_value=0x43c0010f;
1022
 
        priv->txbbgain_table[12].txbb_iq_amplifygain =                 0;
1023
 
        priv->txbbgain_table[12].txbbgain_value=0x40000100;
1024
 
        priv->txbbgain_table[13].txbb_iq_amplifygain =                 -1;
1025
 
        priv->txbbgain_table[13].txbbgain_value=0x3c8000f2;
1026
 
        priv->txbbgain_table[14].txbb_iq_amplifygain =               -2;
1027
 
        priv->txbbgain_table[14].txbbgain_value=0x390000e4;
1028
 
        priv->txbbgain_table[15].txbb_iq_amplifygain =               -3;
1029
 
        priv->txbbgain_table[15].txbbgain_value=0x35c000d7;
1030
 
        priv->txbbgain_table[16].txbb_iq_amplifygain =               -4;
1031
 
        priv->txbbgain_table[16].txbbgain_value=0x32c000cb;
1032
 
        priv->txbbgain_table[17].txbb_iq_amplifygain =               -5;
1033
 
        priv->txbbgain_table[17].txbbgain_value=0x300000c0;
1034
 
        priv->txbbgain_table[18].txbb_iq_amplifygain =                      -6;
1035
 
        priv->txbbgain_table[18].txbbgain_value=0x2d4000b5;
1036
 
        priv->txbbgain_table[19].txbb_iq_amplifygain =               -7;
1037
 
        priv->txbbgain_table[19].txbbgain_value=0x2ac000ab;
1038
 
        priv->txbbgain_table[20].txbb_iq_amplifygain =               -8;
1039
 
        priv->txbbgain_table[20].txbbgain_value=0x288000a2;
1040
 
        priv->txbbgain_table[21].txbb_iq_amplifygain =               -9;
1041
 
        priv->txbbgain_table[21].txbbgain_value=0x26000098;
1042
 
        priv->txbbgain_table[22].txbb_iq_amplifygain =               -10;
1043
 
        priv->txbbgain_table[22].txbbgain_value=0x24000090;
1044
 
        priv->txbbgain_table[23].txbb_iq_amplifygain =               -11;
1045
 
        priv->txbbgain_table[23].txbbgain_value=0x22000088;
1046
 
        priv->txbbgain_table[24].txbb_iq_amplifygain =               -12;
1047
 
        priv->txbbgain_table[24].txbbgain_value=0x20000080;
1048
 
        priv->txbbgain_table[25].txbb_iq_amplifygain =               -13;
1049
 
        priv->txbbgain_table[25].txbbgain_value=0x1a00006c;
1050
 
        priv->txbbgain_table[26].txbb_iq_amplifygain =               -14;
1051
 
        priv->txbbgain_table[26].txbbgain_value=0x1c800072;
1052
 
        priv->txbbgain_table[27].txbb_iq_amplifygain =               -15;
1053
 
        priv->txbbgain_table[27].txbbgain_value=0x18000060;
1054
 
        priv->txbbgain_table[28].txbb_iq_amplifygain =               -16;
1055
 
        priv->txbbgain_table[28].txbbgain_value=0x19800066;
1056
 
        priv->txbbgain_table[29].txbb_iq_amplifygain =               -17;
1057
 
        priv->txbbgain_table[29].txbbgain_value=0x15800056;
1058
 
        priv->txbbgain_table[30].txbb_iq_amplifygain =               -18;
1059
 
        priv->txbbgain_table[30].txbbgain_value=0x26c0005b;
1060
 
        priv->txbbgain_table[31].txbb_iq_amplifygain =               -19;
1061
 
        priv->txbbgain_table[31].txbbgain_value=0x14400051;
1062
 
        priv->txbbgain_table[32].txbb_iq_amplifygain =               -20;
1063
 
        priv->txbbgain_table[32].txbbgain_value=0x24400051;
1064
 
        priv->txbbgain_table[33].txbb_iq_amplifygain =               -21;
1065
 
        priv->txbbgain_table[33].txbbgain_value=0x1300004c;
1066
 
        priv->txbbgain_table[34].txbb_iq_amplifygain =               -22;
1067
 
        priv->txbbgain_table[34].txbbgain_value=0x12000048;
1068
 
        priv->txbbgain_table[35].txbb_iq_amplifygain =               -23;
1069
 
        priv->txbbgain_table[35].txbbgain_value=0x11000044;
1070
 
        priv->txbbgain_table[36].txbb_iq_amplifygain =               -24;
1071
 
        priv->txbbgain_table[36].txbbgain_value=0x10000040;
1072
 
 
1073
 
        //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
1074
 
        //This Table is for CH1~CH13
1075
 
        priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36;
1076
 
        priv->cck_txbbgain_table[0].ccktxbb_valuearray[1] = 0x35;
1077
 
        priv->cck_txbbgain_table[0].ccktxbb_valuearray[2] = 0x2e;
1078
 
        priv->cck_txbbgain_table[0].ccktxbb_valuearray[3] = 0x25;
1079
 
        priv->cck_txbbgain_table[0].ccktxbb_valuearray[4] = 0x1c;
1080
 
        priv->cck_txbbgain_table[0].ccktxbb_valuearray[5] = 0x12;
1081
 
        priv->cck_txbbgain_table[0].ccktxbb_valuearray[6] = 0x09;
1082
 
        priv->cck_txbbgain_table[0].ccktxbb_valuearray[7] = 0x04;
1083
 
 
1084
 
        priv->cck_txbbgain_table[1].ccktxbb_valuearray[0] = 0x33;
1085
 
        priv->cck_txbbgain_table[1].ccktxbb_valuearray[1] = 0x32;
1086
 
        priv->cck_txbbgain_table[1].ccktxbb_valuearray[2] = 0x2b;
1087
 
        priv->cck_txbbgain_table[1].ccktxbb_valuearray[3] = 0x23;
1088
 
        priv->cck_txbbgain_table[1].ccktxbb_valuearray[4] = 0x1a;
1089
 
        priv->cck_txbbgain_table[1].ccktxbb_valuearray[5] = 0x11;
1090
 
        priv->cck_txbbgain_table[1].ccktxbb_valuearray[6] = 0x08;
1091
 
        priv->cck_txbbgain_table[1].ccktxbb_valuearray[7] = 0x04;
1092
 
 
1093
 
        priv->cck_txbbgain_table[2].ccktxbb_valuearray[0] = 0x30;
1094
 
        priv->cck_txbbgain_table[2].ccktxbb_valuearray[1] = 0x2f;
1095
 
        priv->cck_txbbgain_table[2].ccktxbb_valuearray[2] = 0x29;
1096
 
        priv->cck_txbbgain_table[2].ccktxbb_valuearray[3] = 0x21;
1097
 
        priv->cck_txbbgain_table[2].ccktxbb_valuearray[4] = 0x19;
1098
 
        priv->cck_txbbgain_table[2].ccktxbb_valuearray[5] = 0x10;
1099
 
        priv->cck_txbbgain_table[2].ccktxbb_valuearray[6] = 0x08;
1100
 
        priv->cck_txbbgain_table[2].ccktxbb_valuearray[7] = 0x03;
1101
 
 
1102
 
        priv->cck_txbbgain_table[3].ccktxbb_valuearray[0] = 0x2d;
1103
 
        priv->cck_txbbgain_table[3].ccktxbb_valuearray[1] = 0x2d;
1104
 
        priv->cck_txbbgain_table[3].ccktxbb_valuearray[2] = 0x27;
1105
 
        priv->cck_txbbgain_table[3].ccktxbb_valuearray[3] = 0x1f;
1106
 
        priv->cck_txbbgain_table[3].ccktxbb_valuearray[4] = 0x18;
1107
 
        priv->cck_txbbgain_table[3].ccktxbb_valuearray[5] = 0x0f;
1108
 
        priv->cck_txbbgain_table[3].ccktxbb_valuearray[6] = 0x08;
1109
 
        priv->cck_txbbgain_table[3].ccktxbb_valuearray[7] = 0x03;
1110
 
 
1111
 
        priv->cck_txbbgain_table[4].ccktxbb_valuearray[0] = 0x2b;
1112
 
        priv->cck_txbbgain_table[4].ccktxbb_valuearray[1] = 0x2a;
1113
 
        priv->cck_txbbgain_table[4].ccktxbb_valuearray[2] = 0x25;
1114
 
        priv->cck_txbbgain_table[4].ccktxbb_valuearray[3] = 0x1e;
1115
 
        priv->cck_txbbgain_table[4].ccktxbb_valuearray[4] = 0x16;
1116
 
        priv->cck_txbbgain_table[4].ccktxbb_valuearray[5] = 0x0e;
1117
 
        priv->cck_txbbgain_table[4].ccktxbb_valuearray[6] = 0x07;
1118
 
        priv->cck_txbbgain_table[4].ccktxbb_valuearray[7] = 0x03;
1119
 
 
1120
 
        priv->cck_txbbgain_table[5].ccktxbb_valuearray[0] = 0x28;
1121
 
        priv->cck_txbbgain_table[5].ccktxbb_valuearray[1] = 0x28;
1122
 
        priv->cck_txbbgain_table[5].ccktxbb_valuearray[2] = 0x22;
1123
 
        priv->cck_txbbgain_table[5].ccktxbb_valuearray[3] = 0x1c;
1124
 
        priv->cck_txbbgain_table[5].ccktxbb_valuearray[4] = 0x15;
1125
 
        priv->cck_txbbgain_table[5].ccktxbb_valuearray[5] = 0x0d;
1126
 
        priv->cck_txbbgain_table[5].ccktxbb_valuearray[6] = 0x07;
1127
 
        priv->cck_txbbgain_table[5].ccktxbb_valuearray[7] = 0x03;
1128
 
 
1129
 
        priv->cck_txbbgain_table[6].ccktxbb_valuearray[0] = 0x26;
1130
 
        priv->cck_txbbgain_table[6].ccktxbb_valuearray[1] = 0x25;
1131
 
        priv->cck_txbbgain_table[6].ccktxbb_valuearray[2] = 0x21;
1132
 
        priv->cck_txbbgain_table[6].ccktxbb_valuearray[3] = 0x1b;
1133
 
        priv->cck_txbbgain_table[6].ccktxbb_valuearray[4] = 0x14;
1134
 
        priv->cck_txbbgain_table[6].ccktxbb_valuearray[5] = 0x0d;
1135
 
        priv->cck_txbbgain_table[6].ccktxbb_valuearray[6] = 0x06;
1136
 
        priv->cck_txbbgain_table[6].ccktxbb_valuearray[7] = 0x03;
1137
 
 
1138
 
        priv->cck_txbbgain_table[7].ccktxbb_valuearray[0] = 0x24;
1139
 
        priv->cck_txbbgain_table[7].ccktxbb_valuearray[1] = 0x23;
1140
 
        priv->cck_txbbgain_table[7].ccktxbb_valuearray[2] = 0x1f;
1141
 
        priv->cck_txbbgain_table[7].ccktxbb_valuearray[3] = 0x19;
1142
 
        priv->cck_txbbgain_table[7].ccktxbb_valuearray[4] = 0x13;
1143
 
        priv->cck_txbbgain_table[7].ccktxbb_valuearray[5] = 0x0c;
1144
 
        priv->cck_txbbgain_table[7].ccktxbb_valuearray[6] = 0x06;
1145
 
        priv->cck_txbbgain_table[7].ccktxbb_valuearray[7] = 0x03;
1146
 
 
1147
 
        priv->cck_txbbgain_table[8].ccktxbb_valuearray[0] = 0x22;
1148
 
        priv->cck_txbbgain_table[8].ccktxbb_valuearray[1] = 0x21;
1149
 
        priv->cck_txbbgain_table[8].ccktxbb_valuearray[2] = 0x1d;
1150
 
        priv->cck_txbbgain_table[8].ccktxbb_valuearray[3] = 0x18;
1151
 
        priv->cck_txbbgain_table[8].ccktxbb_valuearray[4] = 0x11;
1152
 
        priv->cck_txbbgain_table[8].ccktxbb_valuearray[5] = 0x0b;
1153
 
        priv->cck_txbbgain_table[8].ccktxbb_valuearray[6] = 0x06;
1154
 
        priv->cck_txbbgain_table[8].ccktxbb_valuearray[7] = 0x02;
1155
 
 
1156
 
        priv->cck_txbbgain_table[9].ccktxbb_valuearray[0] = 0x20;
1157
 
        priv->cck_txbbgain_table[9].ccktxbb_valuearray[1] = 0x20;
1158
 
        priv->cck_txbbgain_table[9].ccktxbb_valuearray[2] = 0x1b;
1159
 
        priv->cck_txbbgain_table[9].ccktxbb_valuearray[3] = 0x16;
1160
 
        priv->cck_txbbgain_table[9].ccktxbb_valuearray[4] = 0x11;
1161
 
        priv->cck_txbbgain_table[9].ccktxbb_valuearray[5] = 0x08;
1162
 
        priv->cck_txbbgain_table[9].ccktxbb_valuearray[6] = 0x05;
1163
 
        priv->cck_txbbgain_table[9].ccktxbb_valuearray[7] = 0x02;
1164
 
 
1165
 
        priv->cck_txbbgain_table[10].ccktxbb_valuearray[0] = 0x1f;
1166
 
        priv->cck_txbbgain_table[10].ccktxbb_valuearray[1] = 0x1e;
1167
 
        priv->cck_txbbgain_table[10].ccktxbb_valuearray[2] = 0x1a;
1168
 
        priv->cck_txbbgain_table[10].ccktxbb_valuearray[3] = 0x15;
1169
 
        priv->cck_txbbgain_table[10].ccktxbb_valuearray[4] = 0x10;
1170
 
        priv->cck_txbbgain_table[10].ccktxbb_valuearray[5] = 0x0a;
1171
 
        priv->cck_txbbgain_table[10].ccktxbb_valuearray[6] = 0x05;
1172
 
        priv->cck_txbbgain_table[10].ccktxbb_valuearray[7] = 0x02;
1173
 
 
1174
 
        priv->cck_txbbgain_table[11].ccktxbb_valuearray[0] = 0x1d;
1175
 
        priv->cck_txbbgain_table[11].ccktxbb_valuearray[1] = 0x1c;
1176
 
        priv->cck_txbbgain_table[11].ccktxbb_valuearray[2] = 0x18;
1177
 
        priv->cck_txbbgain_table[11].ccktxbb_valuearray[3] = 0x14;
1178
 
        priv->cck_txbbgain_table[11].ccktxbb_valuearray[4] = 0x0f;
1179
 
        priv->cck_txbbgain_table[11].ccktxbb_valuearray[5] = 0x0a;
1180
 
        priv->cck_txbbgain_table[11].ccktxbb_valuearray[6] = 0x05;
1181
 
        priv->cck_txbbgain_table[11].ccktxbb_valuearray[7] = 0x02;
1182
 
 
1183
 
        priv->cck_txbbgain_table[12].ccktxbb_valuearray[0] = 0x1b;
1184
 
        priv->cck_txbbgain_table[12].ccktxbb_valuearray[1] = 0x1a;
1185
 
        priv->cck_txbbgain_table[12].ccktxbb_valuearray[2] = 0x17;
1186
 
        priv->cck_txbbgain_table[12].ccktxbb_valuearray[3] = 0x13;
1187
 
        priv->cck_txbbgain_table[12].ccktxbb_valuearray[4] = 0x0e;
1188
 
        priv->cck_txbbgain_table[12].ccktxbb_valuearray[5] = 0x09;
1189
 
        priv->cck_txbbgain_table[12].ccktxbb_valuearray[6] = 0x04;
1190
 
        priv->cck_txbbgain_table[12].ccktxbb_valuearray[7] = 0x02;
1191
 
 
1192
 
        priv->cck_txbbgain_table[13].ccktxbb_valuearray[0] = 0x1a;
1193
 
        priv->cck_txbbgain_table[13].ccktxbb_valuearray[1] = 0x19;
1194
 
        priv->cck_txbbgain_table[13].ccktxbb_valuearray[2] = 0x16;
1195
 
        priv->cck_txbbgain_table[13].ccktxbb_valuearray[3] = 0x12;
1196
 
        priv->cck_txbbgain_table[13].ccktxbb_valuearray[4] = 0x0d;
1197
 
        priv->cck_txbbgain_table[13].ccktxbb_valuearray[5] = 0x09;
1198
 
        priv->cck_txbbgain_table[13].ccktxbb_valuearray[6] = 0x04;
1199
 
        priv->cck_txbbgain_table[13].ccktxbb_valuearray[7] = 0x02;
1200
 
 
1201
 
        priv->cck_txbbgain_table[14].ccktxbb_valuearray[0] = 0x18;
1202
 
        priv->cck_txbbgain_table[14].ccktxbb_valuearray[1] = 0x17;
1203
 
        priv->cck_txbbgain_table[14].ccktxbb_valuearray[2] = 0x15;
1204
 
        priv->cck_txbbgain_table[14].ccktxbb_valuearray[3] = 0x11;
1205
 
        priv->cck_txbbgain_table[14].ccktxbb_valuearray[4] = 0x0c;
1206
 
        priv->cck_txbbgain_table[14].ccktxbb_valuearray[5] = 0x08;
1207
 
        priv->cck_txbbgain_table[14].ccktxbb_valuearray[6] = 0x04;
1208
 
        priv->cck_txbbgain_table[14].ccktxbb_valuearray[7] = 0x02;
1209
 
 
1210
 
        priv->cck_txbbgain_table[15].ccktxbb_valuearray[0] = 0x17;
1211
 
        priv->cck_txbbgain_table[15].ccktxbb_valuearray[1] = 0x16;
1212
 
        priv->cck_txbbgain_table[15].ccktxbb_valuearray[2] = 0x13;
1213
 
        priv->cck_txbbgain_table[15].ccktxbb_valuearray[3] = 0x10;
1214
 
        priv->cck_txbbgain_table[15].ccktxbb_valuearray[4] = 0x0c;
1215
 
        priv->cck_txbbgain_table[15].ccktxbb_valuearray[5] = 0x08;
1216
 
        priv->cck_txbbgain_table[15].ccktxbb_valuearray[6] = 0x04;
1217
 
        priv->cck_txbbgain_table[15].ccktxbb_valuearray[7] = 0x02;
1218
 
 
1219
 
        priv->cck_txbbgain_table[16].ccktxbb_valuearray[0] = 0x16;
1220
 
        priv->cck_txbbgain_table[16].ccktxbb_valuearray[1] = 0x15;
1221
 
        priv->cck_txbbgain_table[16].ccktxbb_valuearray[2] = 0x12;
1222
 
        priv->cck_txbbgain_table[16].ccktxbb_valuearray[3] = 0x0f;
1223
 
        priv->cck_txbbgain_table[16].ccktxbb_valuearray[4] = 0x0b;
1224
 
        priv->cck_txbbgain_table[16].ccktxbb_valuearray[5] = 0x07;
1225
 
        priv->cck_txbbgain_table[16].ccktxbb_valuearray[6] = 0x04;
1226
 
        priv->cck_txbbgain_table[16].ccktxbb_valuearray[7] = 0x01;
1227
 
 
1228
 
        priv->cck_txbbgain_table[17].ccktxbb_valuearray[0] = 0x14;
1229
 
        priv->cck_txbbgain_table[17].ccktxbb_valuearray[1] = 0x14;
1230
 
        priv->cck_txbbgain_table[17].ccktxbb_valuearray[2] = 0x11;
1231
 
        priv->cck_txbbgain_table[17].ccktxbb_valuearray[3] = 0x0e;
1232
 
        priv->cck_txbbgain_table[17].ccktxbb_valuearray[4] = 0x0b;
1233
 
        priv->cck_txbbgain_table[17].ccktxbb_valuearray[5] = 0x07;
1234
 
        priv->cck_txbbgain_table[17].ccktxbb_valuearray[6] = 0x03;
1235
 
        priv->cck_txbbgain_table[17].ccktxbb_valuearray[7] = 0x02;
1236
 
 
1237
 
        priv->cck_txbbgain_table[18].ccktxbb_valuearray[0] = 0x13;
1238
 
        priv->cck_txbbgain_table[18].ccktxbb_valuearray[1] = 0x13;
1239
 
        priv->cck_txbbgain_table[18].ccktxbb_valuearray[2] = 0x10;
1240
 
        priv->cck_txbbgain_table[18].ccktxbb_valuearray[3] = 0x0d;
1241
 
        priv->cck_txbbgain_table[18].ccktxbb_valuearray[4] = 0x0a;
1242
 
        priv->cck_txbbgain_table[18].ccktxbb_valuearray[5] = 0x06;
1243
 
        priv->cck_txbbgain_table[18].ccktxbb_valuearray[6] = 0x03;
1244
 
        priv->cck_txbbgain_table[18].ccktxbb_valuearray[7] = 0x01;
1245
 
 
1246
 
        priv->cck_txbbgain_table[19].ccktxbb_valuearray[0] = 0x12;
1247
 
        priv->cck_txbbgain_table[19].ccktxbb_valuearray[1] = 0x12;
1248
 
        priv->cck_txbbgain_table[19].ccktxbb_valuearray[2] = 0x0f;
1249
 
        priv->cck_txbbgain_table[19].ccktxbb_valuearray[3] = 0x0c;
1250
 
        priv->cck_txbbgain_table[19].ccktxbb_valuearray[4] = 0x09;
1251
 
        priv->cck_txbbgain_table[19].ccktxbb_valuearray[5] = 0x06;
1252
 
        priv->cck_txbbgain_table[19].ccktxbb_valuearray[6] = 0x03;
1253
 
        priv->cck_txbbgain_table[19].ccktxbb_valuearray[7] = 0x01;
1254
 
 
1255
 
        priv->cck_txbbgain_table[20].ccktxbb_valuearray[0] = 0x11;
1256
 
        priv->cck_txbbgain_table[20].ccktxbb_valuearray[1] = 0x11;
1257
 
        priv->cck_txbbgain_table[20].ccktxbb_valuearray[2] = 0x0f;
1258
 
        priv->cck_txbbgain_table[20].ccktxbb_valuearray[3] = 0x0c;
1259
 
        priv->cck_txbbgain_table[20].ccktxbb_valuearray[4] = 0x09;
1260
 
        priv->cck_txbbgain_table[20].ccktxbb_valuearray[5] = 0x06;
1261
 
        priv->cck_txbbgain_table[20].ccktxbb_valuearray[6] = 0x03;
1262
 
        priv->cck_txbbgain_table[20].ccktxbb_valuearray[7] = 0x01;
1263
 
 
1264
 
        priv->cck_txbbgain_table[21].ccktxbb_valuearray[0] = 0x10;
1265
 
        priv->cck_txbbgain_table[21].ccktxbb_valuearray[1] = 0x10;
1266
 
        priv->cck_txbbgain_table[21].ccktxbb_valuearray[2] = 0x0e;
1267
 
        priv->cck_txbbgain_table[21].ccktxbb_valuearray[3] = 0x0b;
1268
 
        priv->cck_txbbgain_table[21].ccktxbb_valuearray[4] = 0x08;
1269
 
        priv->cck_txbbgain_table[21].ccktxbb_valuearray[5] = 0x05;
1270
 
        priv->cck_txbbgain_table[21].ccktxbb_valuearray[6] = 0x03;
1271
 
        priv->cck_txbbgain_table[21].ccktxbb_valuearray[7] = 0x01;
1272
 
 
1273
 
        priv->cck_txbbgain_table[22].ccktxbb_valuearray[0] = 0x0f;
1274
 
        priv->cck_txbbgain_table[22].ccktxbb_valuearray[1] = 0x0f;
1275
 
        priv->cck_txbbgain_table[22].ccktxbb_valuearray[2] = 0x0d;
1276
 
        priv->cck_txbbgain_table[22].ccktxbb_valuearray[3] = 0x0b;
1277
 
        priv->cck_txbbgain_table[22].ccktxbb_valuearray[4] = 0x08;
1278
 
        priv->cck_txbbgain_table[22].ccktxbb_valuearray[5] = 0x05;
1279
 
        priv->cck_txbbgain_table[22].ccktxbb_valuearray[6] = 0x03;
1280
 
        priv->cck_txbbgain_table[22].ccktxbb_valuearray[7] = 0x01;
1281
 
 
1282
 
        //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
1283
 
        //This Table is for CH14
1284
 
        priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[0] = 0x36;
1285
 
        priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[1] = 0x35;
1286
 
        priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[2] = 0x2e;
1287
 
        priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[3] = 0x1b;
1288
 
        priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[4] = 0x00;
1289
 
        priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[5] = 0x00;
1290
 
        priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[6] = 0x00;
1291
 
        priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[7] = 0x00;
1292
 
 
1293
 
        priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[0] = 0x33;
1294
 
        priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[1] = 0x32;
1295
 
        priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[2] = 0x2b;
1296
 
        priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[3] = 0x19;
1297
 
        priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[4] = 0x00;
1298
 
        priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[5] = 0x00;
1299
 
        priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[6] = 0x00;
1300
 
        priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[7] = 0x00;
1301
 
 
1302
 
        priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[0] = 0x30;
1303
 
        priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[1] = 0x2f;
1304
 
        priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[2] = 0x29;
1305
 
        priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[3] = 0x18;
1306
 
        priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[4] = 0x00;
1307
 
        priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[5] = 0x00;
1308
 
        priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[6] = 0x00;
1309
 
        priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[7] = 0x00;
1310
 
 
1311
 
        priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[0] = 0x2d;
1312
 
        priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[1] = 0x2d;
1313
 
        priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[2] = 0x27;
1314
 
        priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[3] = 0x17;
1315
 
        priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[4] = 0x00;
1316
 
        priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[5] = 0x00;
1317
 
        priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[6] = 0x00;
1318
 
        priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[7] = 0x00;
1319
 
 
1320
 
        priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[0] = 0x2b;
1321
 
        priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[1] = 0x2a;
1322
 
        priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[2] = 0x25;
1323
 
        priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[3] = 0x15;
1324
 
        priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[4] = 0x00;
1325
 
        priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[5] = 0x00;
1326
 
        priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[6] = 0x00;
1327
 
        priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[7] = 0x00;
1328
 
 
1329
 
        priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[0] = 0x28;
1330
 
        priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[1] = 0x28;
1331
 
        priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[2] = 0x22;
1332
 
        priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[3] = 0x14;
1333
 
        priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[4] = 0x00;
1334
 
        priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[5] = 0x00;
1335
 
        priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[6] = 0x00;
1336
 
        priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[7] = 0x00;
1337
 
 
1338
 
        priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[0] = 0x26;
1339
 
        priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[1] = 0x25;
1340
 
        priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[2] = 0x21;
1341
 
        priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[3] = 0x13;
1342
 
        priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[4] = 0x00;
1343
 
        priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[5] = 0x00;
1344
 
        priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[6] = 0x00;
1345
 
        priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[7] = 0x00;
1346
 
 
1347
 
        priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[0] = 0x24;
1348
 
        priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[1] = 0x23;
1349
 
        priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[2] = 0x1f;
1350
 
        priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[3] = 0x12;
1351
 
        priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[4] = 0x00;
1352
 
        priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[5] = 0x00;
1353
 
        priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[6] = 0x00;
1354
 
        priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[7] = 0x00;
1355
 
 
1356
 
        priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[0] = 0x22;
1357
 
        priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[1] = 0x21;
1358
 
        priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[2] = 0x1d;
1359
 
        priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[3] = 0x11;
1360
 
        priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[4] = 0x00;
1361
 
        priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[5] = 0x00;
1362
 
        priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[6] = 0x00;
1363
 
        priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[7] = 0x00;
1364
 
 
1365
 
        priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[0] = 0x20;
1366
 
        priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[1] = 0x20;
1367
 
        priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[2] = 0x1b;
1368
 
        priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[3] = 0x10;
1369
 
        priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[4] = 0x00;
1370
 
        priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[5] = 0x00;
1371
 
        priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[6] = 0x00;
1372
 
        priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[7] = 0x00;
1373
 
 
1374
 
        priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[0] = 0x1f;
1375
 
        priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[1] = 0x1e;
1376
 
        priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[2] = 0x1a;
1377
 
        priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[3] = 0x0f;
1378
 
        priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[4] = 0x00;
1379
 
        priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[5] = 0x00;
1380
 
        priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[6] = 0x00;
1381
 
        priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[7] = 0x00;
1382
 
 
1383
 
        priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[0] = 0x1d;
1384
 
        priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[1] = 0x1c;
1385
 
        priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[2] = 0x18;
1386
 
        priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[3] = 0x0e;
1387
 
        priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[4] = 0x00;
1388
 
        priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[5] = 0x00;
1389
 
        priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[6] = 0x00;
1390
 
        priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[7] = 0x00;
1391
 
 
1392
 
        priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[0] = 0x1b;
1393
 
        priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[1] = 0x1a;
1394
 
        priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[2] = 0x17;
1395
 
        priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[3] = 0x0e;
1396
 
        priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[4] = 0x00;
1397
 
        priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[5] = 0x00;
1398
 
        priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[6] = 0x00;
1399
 
        priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[7] = 0x00;
1400
 
 
1401
 
        priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[0] = 0x1a;
1402
 
        priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[1] = 0x19;
1403
 
        priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[2] = 0x16;
1404
 
        priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[3] = 0x0d;
1405
 
        priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[4] = 0x00;
1406
 
        priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[5] = 0x00;
1407
 
        priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[6] = 0x00;
1408
 
        priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[7] = 0x00;
1409
 
 
1410
 
        priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[0] = 0x18;
1411
 
        priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[1] = 0x17;
1412
 
        priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[2] = 0x15;
1413
 
        priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[3] = 0x0c;
1414
 
        priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[4] = 0x00;
1415
 
        priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[5] = 0x00;
1416
 
        priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[6] = 0x00;
1417
 
        priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[7] = 0x00;
1418
 
 
1419
 
        priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[0] = 0x17;
1420
 
        priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[1] = 0x16;
1421
 
        priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[2] = 0x13;
1422
 
        priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[3] = 0x0b;
1423
 
        priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[4] = 0x00;
1424
 
        priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[5] = 0x00;
1425
 
        priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[6] = 0x00;
1426
 
        priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[7] = 0x00;
1427
 
 
1428
 
        priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[0] = 0x16;
1429
 
        priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[1] = 0x15;
1430
 
        priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[2] = 0x12;
1431
 
        priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[3] = 0x0b;
1432
 
        priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[4] = 0x00;
1433
 
        priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[5] = 0x00;
1434
 
        priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[6] = 0x00;
1435
 
        priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[7] = 0x00;
1436
 
 
1437
 
        priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[0] = 0x14;
1438
 
        priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[1] = 0x14;
1439
 
        priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[2] = 0x11;
1440
 
        priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[3] = 0x0a;
1441
 
        priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[4] = 0x00;
1442
 
        priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[5] = 0x00;
1443
 
        priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[6] = 0x00;
1444
 
        priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[7] = 0x00;
1445
 
 
1446
 
        priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[0] = 0x13;
1447
 
        priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[1] = 0x13;
1448
 
        priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[2] = 0x10;
1449
 
        priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[3] = 0x0a;
1450
 
        priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[4] = 0x00;
1451
 
        priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[5] = 0x00;
1452
 
        priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[6] = 0x00;
1453
 
        priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[7] = 0x00;
1454
 
 
1455
 
        priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[0] = 0x12;
1456
 
        priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[1] = 0x12;
1457
 
        priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[2] = 0x0f;
1458
 
        priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[3] = 0x09;
1459
 
        priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[4] = 0x00;
1460
 
        priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[5] = 0x00;
1461
 
        priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[6] = 0x00;
1462
 
        priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[7] = 0x00;
1463
 
 
1464
 
        priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[0] = 0x11;
1465
 
        priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[1] = 0x11;
1466
 
        priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[2] = 0x0f;
1467
 
        priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[3] = 0x09;
1468
 
        priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[4] = 0x00;
1469
 
        priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[5] = 0x00;
1470
 
        priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[6] = 0x00;
1471
 
        priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[7] = 0x00;
1472
 
 
1473
 
        priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[0] = 0x10;
1474
 
        priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[1] = 0x10;
1475
 
        priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[2] = 0x0e;
1476
 
        priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[3] = 0x08;
1477
 
        priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[4] = 0x00;
1478
 
        priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[5] = 0x00;
1479
 
        priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[6] = 0x00;
1480
 
        priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[7] = 0x00;
1481
 
 
1482
 
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[0] = 0x0f;
1483
 
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[1] = 0x0f;
1484
 
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[2] = 0x0d;
1485
 
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[3] = 0x08;
1486
 
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[4] = 0x00;
1487
 
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[5] = 0x00;
1488
 
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[6] = 0x00;
1489
 
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[7] = 0x00;
 
898
        priv->txbbgain_table = rtl8192_txbbgain_table;
 
899
        priv->cck_txbbgain_table = rtl8192_cck_txbbgain_table;
 
900
        priv->cck_txbbgain_ch14_table = rtl8192_cck_txbbgain_ch14_table;
1490
901
 
1491
902
        priv->btxpower_tracking = TRUE;
1492
903
        priv->txpower_count       = 0;
1493
904
        priv->btxpower_trackingInit = FALSE;
1494
905
 
1495
906
}
1496
 
#ifndef RTL8190P
1497
 
static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev)
 
907
 
 
908
static void dm_InitializeTXPowerTracking_ThermalMeter(struct r8192_priv *priv)
1498
909
{
1499
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1500
 
 
1501
910
        // Tx Power tracking by Theremal Meter require Firmware R/W 3-wire. This mechanism
1502
911
        // can be enabled only when Firmware R/W 3-wire is enabled. Otherwise, frequent r/w
1503
912
        // 3-wire by driver cause RF goes into wrong state.
1508
917
        priv->txpower_count       = 0;
1509
918
        priv->btxpower_trackingInit = FALSE;
1510
919
}
1511
 
#endif
1512
920
 
1513
 
void dm_initialize_txpower_tracking(struct net_device *dev)
 
921
void dm_initialize_txpower_tracking(struct r8192_priv *priv)
1514
922
{
1515
 
#ifndef RTL8190P
1516
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1517
 
#endif
1518
 
#ifdef RTL8190P
1519
 
        dm_InitializeTXPowerTracking_TSSI(dev);
1520
 
#else
1521
923
        if(priv->IC_Cut >= IC_VersionCut_D)
1522
 
                dm_InitializeTXPowerTracking_TSSI(dev);
 
924
                dm_InitializeTXPowerTracking_TSSI(priv);
1523
925
        else
1524
 
                dm_InitializeTXPowerTracking_ThermalMeter(dev);
1525
 
#endif
 
926
                dm_InitializeTXPowerTracking_ThermalMeter(priv);
1526
927
}
1527
928
 
1528
929
 
1529
 
static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev)
 
930
static void dm_CheckTXPowerTracking_TSSI(struct r8192_priv *priv)
1530
931
{
1531
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1532
932
        static u32 tx_power_track_counter = 0;
1533
933
        RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__FUNCTION__);
1534
 
        if(read_nic_byte(dev, 0x11e) ==1)
 
934
        if(read_nic_byte(priv, 0x11e) ==1)
1535
935
                return;
1536
936
        if(!priv->btxpower_tracking)
1537
937
                return;
1543
943
        }
1544
944
}
1545
945
 
1546
 
#ifndef RTL8190P
1547
 
static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev)
 
946
static void dm_CheckTXPowerTracking_ThermalMeter(struct r8192_priv *priv)
1548
947
{
1549
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1550
948
        static u8       TM_Trigger=0;
1551
949
 
1552
 
        //DbgPrint("dm_CheckTXPowerTracking() \n");
1553
950
        if(!priv->btxpower_tracking)
1554
951
                return;
1555
952
        else
1565
962
        {
1566
963
                //Attention!! You have to wirte all 12bits data to RF, or it may cause RF to crash
1567
964
                //actually write reg0x02 bit1=0, then bit1=1.
1568
 
                //DbgPrint("Trigger ThermalMeter, write RF reg0x2 = 0x4d to 0x4f\n");
1569
 
                rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d);
1570
 
                rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f);
1571
 
                rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d);
1572
 
                rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f);
 
965
                rtl8192_phy_SetRFReg(priv, RF90_PATH_A, 0x02, bMask12Bits, 0x4d);
 
966
                rtl8192_phy_SetRFReg(priv, RF90_PATH_A, 0x02, bMask12Bits, 0x4f);
 
967
                rtl8192_phy_SetRFReg(priv, RF90_PATH_A, 0x02, bMask12Bits, 0x4d);
 
968
                rtl8192_phy_SetRFReg(priv, RF90_PATH_A, 0x02, bMask12Bits, 0x4f);
1573
969
                TM_Trigger = 1;
1574
970
                return;
1575
971
        }
1576
972
        else {
1577
 
                //DbgPrint("Schedule TxPowerTrackingWorkItem\n");
1578
 
                        queue_delayed_work(priv->priv_wq,&priv->txpower_tracking_wq,0);
 
973
                queue_delayed_work(priv->priv_wq,&priv->txpower_tracking_wq,0);
1579
974
                TM_Trigger = 0;
1580
975
        }
1581
976
}
1582
 
#endif
1583
977
 
1584
 
static void dm_check_txpower_tracking(struct net_device *dev)
 
978
static void dm_check_txpower_tracking(struct r8192_priv *priv)
1585
979
{
1586
 
#ifndef RTL8190P
1587
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1588
 
        //static u32 tx_power_track_counter = 0;
1589
 
#endif
1590
 
#ifdef  RTL8190P
1591
 
        dm_CheckTXPowerTracking_TSSI(dev);
1592
 
#else
1593
 
        //if(priv->bDcut == TRUE)
1594
980
        if(priv->IC_Cut >= IC_VersionCut_D)
1595
 
                dm_CheckTXPowerTracking_TSSI(dev);
 
981
                dm_CheckTXPowerTracking_TSSI(priv);
1596
982
        else
1597
 
                dm_CheckTXPowerTracking_ThermalMeter(dev);
1598
 
#endif
1599
 
 
 
983
                dm_CheckTXPowerTracking_ThermalMeter(priv);
1600
984
}
1601
985
 
1602
986
 
1603
 
static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool  bInCH14)
 
987
static void dm_CCKTxPowerAdjust_TSSI(struct r8192_priv *priv, bool bInCH14)
1604
988
{
1605
989
        u32 TempVal;
1606
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1607
990
        //Write 0xa22 0xa23
1608
991
        TempVal = 0;
1609
992
        if(!bInCH14){
1611
994
                TempVal =       (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] +
1612
995
                                        (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ;
1613
996
 
1614
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal);
 
997
                rtl8192_setBBreg(priv, rCCK0_TxFilter1, bMaskHWord, TempVal);
1615
998
                //Write 0xa24 ~ 0xa27
1616
999
                TempVal = 0;
1617
1000
                TempVal =       (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] +
1618
1001
                                        (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) +
1619
1002
                                        (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+
1620
1003
                                        (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24));
1621
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal);
 
1004
                rtl8192_setBBreg(priv, rCCK0_TxFilter2, bMaskDWord, TempVal);
1622
1005
                //Write 0xa28  0xa29
1623
1006
                TempVal = 0;
1624
1007
                TempVal =       (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] +
1625
1008
                                        (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ;
1626
1009
 
1627
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal);
 
1010
                rtl8192_setBBreg(priv, rCCK0_DebugPort, bMaskLWord, TempVal);
1628
1011
        }
1629
1012
        else
1630
1013
        {
1631
1014
                TempVal =       (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] +
1632
1015
                                        (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ;
1633
1016
 
1634
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal);
 
1017
                rtl8192_setBBreg(priv, rCCK0_TxFilter1, bMaskHWord, TempVal);
1635
1018
                //Write 0xa24 ~ 0xa27
1636
1019
                TempVal = 0;
1637
1020
                TempVal =       (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] +
1638
1021
                                        (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) +
1639
1022
                                        (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+
1640
1023
                                        (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24));
1641
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal);
 
1024
                rtl8192_setBBreg(priv, rCCK0_TxFilter2, bMaskDWord, TempVal);
1642
1025
                //Write 0xa28  0xa29
1643
1026
                TempVal = 0;
1644
1027
                TempVal =       (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] +
1645
1028
                                        (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ;
1646
1029
 
1647
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal);
 
1030
                rtl8192_setBBreg(priv, rCCK0_DebugPort, bMaskLWord, TempVal);
1648
1031
        }
1649
1032
 
1650
1033
 
1651
1034
}
1652
 
#ifndef RTL8190P
1653
 
static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,    bool  bInCH14)
 
1035
 
 
1036
static void dm_CCKTxPowerAdjust_ThermalMeter(struct r8192_priv *priv,
 
1037
                                             bool bInCH14)
1654
1038
{
1655
1039
        u32 TempVal;
1656
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1657
1040
 
1658
1041
        TempVal = 0;
1659
1042
        if(!bInCH14)
1661
1044
                //Write 0xa22 0xa23
1662
1045
                TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] +
1663
1046
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ;
1664
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
 
1047
                rtl8192_setBBreg(priv, rCCK0_TxFilter1, bMaskHWord, TempVal);
1665
1048
                RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
1666
1049
                        rCCK0_TxFilter1, TempVal);
1667
1050
                //Write 0xa24 ~ 0xa27
1670
1053
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) +
1671
1054
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+
1672
1055
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24);
1673
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
 
1056
                rtl8192_setBBreg(priv, rCCK0_TxFilter2, bMaskDWord, TempVal);
1674
1057
                RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
1675
1058
                        rCCK0_TxFilter2, TempVal);
1676
1059
                //Write 0xa28  0xa29
1678
1061
                TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
1679
1062
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ;
1680
1063
 
1681
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
 
1064
                rtl8192_setBBreg(priv, rCCK0_DebugPort, bMaskLWord, TempVal);
1682
1065
                RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
1683
1066
                        rCCK0_DebugPort, TempVal);
1684
1067
        }
1689
1072
                TempVal =       CCKSwingTable_Ch14[priv->CCK_index][0] +
1690
1073
                                        (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ;
1691
1074
 
1692
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
 
1075
                rtl8192_setBBreg(priv, rCCK0_TxFilter1, bMaskHWord, TempVal);
1693
1076
                RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
1694
1077
                        rCCK0_TxFilter1, TempVal);
1695
1078
                //Write 0xa24 ~ 0xa27
1698
1081
                                        (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) +
1699
1082
                                        (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+
1700
1083
                                        (CCKSwingTable_Ch14[priv->CCK_index][5]<<24);
1701
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
 
1084
                rtl8192_setBBreg(priv, rCCK0_TxFilter2, bMaskDWord, TempVal);
1702
1085
                RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
1703
1086
                        rCCK0_TxFilter2, TempVal);
1704
1087
                //Write 0xa28  0xa29
1706
1089
                TempVal =       CCKSwingTable_Ch14[priv->CCK_index][6] +
1707
1090
                                        (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ;
1708
1091
 
1709
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
 
1092
                rtl8192_setBBreg(priv, rCCK0_DebugPort, bMaskLWord, TempVal);
1710
1093
                RT_TRACE(COMP_POWER_TRACKING,"CCK chnl 14, reg 0x%x = 0x%x\n",
1711
1094
                        rCCK0_DebugPort, TempVal);
1712
1095
        }
1713
1096
}
1714
 
#endif
1715
 
 
1716
 
 
1717
 
void dm_cck_txpower_adjust(struct net_device *dev, bool binch14)
 
1097
 
 
1098
void dm_cck_txpower_adjust(struct r8192_priv *priv, bool binch14)
1718
1099
{
1719
 
#ifndef RTL8190P
1720
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1721
 
#endif
1722
 
#ifdef RTL8190P
1723
 
        dm_CCKTxPowerAdjust_TSSI(dev, binch14);
1724
 
#else
1725
1100
        if(priv->IC_Cut >= IC_VersionCut_D)
1726
 
                dm_CCKTxPowerAdjust_TSSI(dev, binch14);
 
1101
                dm_CCKTxPowerAdjust_TSSI(priv, binch14);
1727
1102
        else
1728
 
                dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14);
1729
 
#endif
1730
 
}
1731
 
 
1732
 
 
1733
 
#ifndef  RTL8192U
1734
 
static void dm_txpower_reset_recovery(
1735
 
        struct net_device *dev
1736
 
)
1737
 
{
1738
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1739
 
 
1740
 
        RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n");
1741
 
        rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value);
1742
 
        RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value);
1743
 
        RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",priv->rfa_txpowertrackingindex);
1744
 
        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);
1745
 
        RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n",priv->CCKPresentAttentuation);
1746
 
        dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
1747
 
 
1748
 
        rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value);
1749
 
        RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value);
1750
 
        RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",priv->rfc_txpowertrackingindex);
1751
 
        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);
1752
 
 
1753
 
}
1754
 
 
1755
 
void dm_restore_dynamic_mechanism_state(struct net_device *dev)
1756
 
{
1757
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1758
 
        u32     reg_ratr = priv->rate_adaptive.last_ratr;
1759
 
 
1760
 
        if(!priv->up)
1761
 
        {
1762
 
                RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n");
1763
 
                return;
1764
 
        }
1765
 
 
1766
 
        //
1767
 
        // Restore previous state for rate adaptive
1768
 
        //
1769
 
        if(priv->rate_adaptive.rate_adaptive_disabled)
1770
 
                return;
1771
 
        // TODO: Only 11n mode is implemented currently,
1772
 
        if( !(priv->ieee80211->mode==WIRELESS_MODE_N_24G ||
1773
 
                 priv->ieee80211->mode==WIRELESS_MODE_N_5G))
1774
 
                 return;
1775
 
        {
1776
 
                        /* 2007/11/15 MH Copy from 8190PCI. */
1777
 
                        u32 ratr_value;
1778
 
                        ratr_value = reg_ratr;
1779
 
                        if(priv->rf_type == RF_1T2R)    // 1T2R, Spatial Stream 2 should be disabled
1780
 
                        {
1781
 
                                ratr_value &=~ (RATE_ALL_OFDM_2SS);
1782
 
                                //DbgPrint("HW_VAR_TATR_0 from 0x%x ==> 0x%x\n", ((pu4Byte)(val))[0], ratr_value);
1783
 
                        }
1784
 
                        //DbgPrint("set HW_VAR_TATR_0 = 0x%x\n", ratr_value);
1785
 
                        //cosa PlatformEFIOWrite4Byte(Adapter, RATR0, ((pu4Byte)(val))[0]);
1786
 
                        write_nic_dword(dev, RATR0, ratr_value);
1787
 
                        write_nic_byte(dev, UFWP, 1);
1788
 
        }
1789
 
        //Resore TX Power Tracking Index
1790
 
        if(priv->btxpower_trackingInit && priv->btxpower_tracking){
1791
 
                dm_txpower_reset_recovery(dev);
1792
 
        }
1793
 
 
1794
 
        //
1795
 
        //Restore BB Initial Gain
1796
 
        //
1797
 
        dm_bb_initialgain_restore(dev);
1798
 
 
1799
 
}
1800
 
 
1801
 
static void dm_bb_initialgain_restore(struct net_device *dev)
1802
 
{
1803
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1804
 
        u32 bit_mask = 0x7f; //Bit0~ Bit6
1805
 
 
1806
 
        if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
1807
 
                return;
1808
 
 
1809
 
        //Disable Initial Gain
1810
 
        //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);
1811
 
        rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8);   // Only clear byte 1 and rewrite.
1812
 
        rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask, (u32)priv->initgain_backup.xaagccore1);
1813
 
        rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask, (u32)priv->initgain_backup.xbagccore1);
1814
 
        rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask, (u32)priv->initgain_backup.xcagccore1);
1815
 
        rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask, (u32)priv->initgain_backup.xdagccore1);
1816
 
        bit_mask  = bMaskByte2;
1817
 
        rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca);
1818
 
 
1819
 
        RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
1820
 
        RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
1821
 
        RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
1822
 
        RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
1823
 
        RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca);
1824
 
        //Enable Initial Gain
1825
 
        //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x100);
1826
 
        rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1);   // Only clear byte 1 and rewrite.
1827
 
 
1828
 
}
1829
 
 
1830
 
 
1831
 
void dm_backup_dynamic_mechanism_state(struct net_device *dev)
1832
 
{
1833
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1834
 
 
1835
 
        // Fsync to avoid reset
1836
 
        priv->bswitch_fsync  = false;
1837
 
        priv->bfsync_processing = false;
1838
 
        //Backup BB InitialGain
1839
 
        dm_bb_initialgain_backup(dev);
1840
 
 
1841
 
}
1842
 
 
1843
 
 
1844
 
static void dm_bb_initialgain_backup(struct net_device *dev)
1845
 
{
1846
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1847
 
        u32 bit_mask = bMaskByte0; //Bit0~ Bit6
1848
 
 
1849
 
        if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
1850
 
                return;
1851
 
 
1852
 
        //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);
1853
 
        rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8);   // Only clear byte 1 and rewrite.
1854
 
        priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bit_mask);
1855
 
        priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, bit_mask);
1856
 
        priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, bit_mask);
1857
 
        priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, bit_mask);
1858
 
        bit_mask  = bMaskByte2;
1859
 
        priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask);
1860
 
 
1861
 
        RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
1862
 
        RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
1863
 
        RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
1864
 
        RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
1865
 
        RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca);
1866
 
 
1867
 
}
1868
 
 
1869
 
#endif
1870
 
 
1871
 
void dm_change_dynamic_initgain_thresh(struct net_device *dev, u32 dm_type, u32 dm_value)
1872
 
{
1873
 
        if (dm_type == DIG_TYPE_THRESH_HIGH)
1874
 
        {
1875
 
                dm_digtable.rssi_high_thresh = dm_value;
1876
 
        }
1877
 
        else if (dm_type == DIG_TYPE_THRESH_LOW)
1878
 
        {
1879
 
                dm_digtable.rssi_low_thresh = dm_value;
1880
 
        }
1881
 
        else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)
1882
 
        {
1883
 
                dm_digtable.rssi_high_power_highthresh = dm_value;
1884
 
        }
1885
 
        else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)
1886
 
        {
1887
 
                dm_digtable.rssi_high_power_highthresh = dm_value;
1888
 
        }
1889
 
        else if (dm_type == DIG_TYPE_ENABLE)
1890
 
        {
1891
 
                dm_digtable.dig_state           = DM_STA_DIG_MAX;
1892
 
                dm_digtable.dig_enable_flag     = true;
1893
 
        }
1894
 
        else if (dm_type == DIG_TYPE_DISABLE)
1895
 
        {
1896
 
                dm_digtable.dig_state           = DM_STA_DIG_MAX;
1897
 
                dm_digtable.dig_enable_flag     = false;
1898
 
        }
1899
 
        else if (dm_type == DIG_TYPE_DBG_MODE)
1900
 
        {
1901
 
                if(dm_value >= DM_DBG_MAX)
1902
 
                        dm_value = DM_DBG_OFF;
1903
 
                dm_digtable.dbg_mode            = (u8)dm_value;
1904
 
        }
1905
 
        else if (dm_type == DIG_TYPE_RSSI)
1906
 
        {
1907
 
                if(dm_value > 100)
1908
 
                        dm_value = 30;
1909
 
                dm_digtable.rssi_val                    = (long)dm_value;
1910
 
        }
1911
 
        else if (dm_type == DIG_TYPE_ALGORITHM)
1912
 
        {
1913
 
                if (dm_value >= DIG_ALGO_MAX)
1914
 
                        dm_value = DIG_ALGO_BY_FALSE_ALARM;
1915
 
                if(dm_digtable.dig_algorithm != (u8)dm_value)
1916
 
                        dm_digtable.dig_algorithm_switch = 1;
1917
 
                dm_digtable.dig_algorithm       = (u8)dm_value;
1918
 
        }
1919
 
        else if (dm_type == DIG_TYPE_BACKOFF)
1920
 
        {
1921
 
                if(dm_value > 30)
1922
 
                        dm_value = 30;
1923
 
                dm_digtable.backoff_val         = (u8)dm_value;
1924
 
        }
1925
 
        else if(dm_type == DIG_TYPE_RX_GAIN_MIN)
1926
 
        {
1927
 
                if(dm_value == 0)
1928
 
                        dm_value = 0x1;
1929
 
                dm_digtable.rx_gain_range_min = (u8)dm_value;
1930
 
        }
1931
 
        else if(dm_type == DIG_TYPE_RX_GAIN_MAX)
1932
 
        {
1933
 
                if(dm_value > 0x50)
1934
 
                        dm_value = 0x50;
1935
 
                dm_digtable.rx_gain_range_max = (u8)dm_value;
1936
 
        }
1937
 
}
1938
 
 
 
1103
                dm_CCKTxPowerAdjust_ThermalMeter(priv, binch14);
 
1104
}
1939
1105
 
1940
1106
/* Set DIG scheme init value. */
1941
 
static void dm_dig_init(struct net_device *dev)
 
1107
static void dm_dig_init(struct r8192_priv *priv)
1942
1108
{
1943
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1944
1109
        /* 2007/10/05 MH Disable DIG scheme now. Not tested. */
1945
1110
        dm_digtable.dig_enable_flag     = true;
1946
1111
        dm_digtable.dig_algorithm = DIG_ALGO_BY_RSSI;
1974
1139
 * gain according to different threshold. BB team provide the
1975
1140
 * suggested solution.
1976
1141
 */
1977
 
static void dm_ctrl_initgain_byrssi(struct net_device *dev)
 
1142
static void dm_ctrl_initgain_byrssi(struct r8192_priv *priv)
1978
1143
{
1979
 
 
1980
1144
        if (dm_digtable.dig_enable_flag == false)
1981
1145
                return;
1982
1146
 
1983
1147
        if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
1984
 
                dm_ctrl_initgain_byrssi_by_fwfalse_alarm(dev);
 
1148
                dm_ctrl_initgain_byrssi_by_fwfalse_alarm(priv);
1985
1149
        else if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
1986
 
                dm_ctrl_initgain_byrssi_by_driverrssi(dev);
 
1150
                dm_ctrl_initgain_byrssi_by_driverrssi(priv);
1987
1151
}
1988
1152
 
1989
1153
 
1990
 
static void dm_ctrl_initgain_byrssi_by_driverrssi(
1991
 
        struct net_device *dev)
 
1154
static void dm_ctrl_initgain_byrssi_by_driverrssi(struct r8192_priv *priv)
1992
1155
{
1993
 
        struct r8192_priv *priv = ieee80211_priv(dev);
1994
1156
        u8 i;
1995
1157
        static u8       fw_dig=0;
1996
1158
 
1997
1159
        if (dm_digtable.dig_enable_flag == false)
1998
1160
                return;
1999
1161
 
2000
 
        //DbgPrint("Dig by Sw Rssi \n");
2001
1162
        if(dm_digtable.dig_algorithm_switch)    // if swithed algorithm, we have to disable FW Dig.
2002
1163
                fw_dig = 0;
2003
1164
        if(fw_dig <= 3) // execute several times to make sure the FW Dig is disabled
2004
1165
        {// FW DIG Off
2005
1166
                for(i=0; i<3; i++)
2006
 
                        rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8);   // Only clear byte 1 and rewrite.
 
1167
                        rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x8);  // Only clear byte 1 and rewrite.
2007
1168
                fw_dig++;
2008
1169
                dm_digtable.dig_state = DM_STA_DIG_OFF; //fw dig off.
2009
1170
        }
2013
1174
        else
2014
1175
                dm_digtable.cur_connect_state = DIG_DISCONNECT;
2015
1176
 
2016
 
        //DbgPrint("DM_DigTable.PreConnectState = %d, DM_DigTable.CurConnectState = %d \n",
2017
 
                //DM_DigTable.PreConnectState, DM_DigTable.CurConnectState);
2018
 
 
2019
1177
        if(dm_digtable.dbg_mode == DM_DBG_OFF)
2020
1178
                dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb;
2021
 
        //DbgPrint("DM_DigTable.Rssi_val = %d \n", DM_DigTable.Rssi_val);
2022
 
        dm_initial_gain(dev);
2023
 
        dm_pd_th(dev);
2024
 
        dm_cs_ratio(dev);
 
1179
 
 
1180
        dm_initial_gain(priv);
 
1181
        dm_pd_th(priv);
 
1182
        dm_cs_ratio(priv);
2025
1183
        if(dm_digtable.dig_algorithm_switch)
2026
1184
                dm_digtable.dig_algorithm_switch = 0;
2027
1185
        dm_digtable.pre_connect_state = dm_digtable.cur_connect_state;
2028
1186
 
2029
1187
}
2030
1188
 
2031
 
static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
2032
 
        struct net_device *dev)
 
1189
static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct r8192_priv *priv)
2033
1190
{
2034
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2035
1191
        static u32 reset_cnt = 0;
2036
1192
        u8 i;
2037
1193
 
2043
1199
                dm_digtable.dig_state = DM_STA_DIG_MAX;
2044
1200
                // Fw DIG On.
2045
1201
                for(i=0; i<3; i++)
2046
 
                        rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1);   // Only clear byte 1 and rewrite.
 
1202
                        rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x1);  // Only clear byte 1 and rewrite.
2047
1203
                dm_digtable.dig_algorithm_switch = 0;
2048
1204
        }
2049
1205
 
2056
1212
        {
2057
1213
                return;
2058
1214
        }
2059
 
        //DbgPrint("Dig by Fw False Alarm\n");
2060
 
        //if (DM_DigTable.Dig_State == DM_STA_DIG_OFF)
2061
 
        /*DbgPrint("DIG Check\n\r RSSI=%d LOW=%d HIGH=%d STATE=%d",
2062
 
        pHalData->UndecoratedSmoothedPWDB, DM_DigTable.RssiLowThresh,
2063
 
        DM_DigTable.RssiHighThresh, DM_DigTable.Dig_State);*/
 
1215
 
2064
1216
        /* 1. When RSSI decrease, We have to judge if it is smaller than a threshold
2065
1217
                  and then execute below step. */
2066
1218
        if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh))
2082
1234
                dm_digtable.dig_state = DM_STA_DIG_OFF;
2083
1235
 
2084
1236
                // 1.1 DIG Off.
2085
 
                rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8);   // Only clear byte 1 and rewrite.
 
1237
                rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x8);  // Only clear byte 1 and rewrite.
2086
1238
 
2087
1239
                // 1.2 Set initial gain.
2088
 
                write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x17);
2089
 
                write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x17);
2090
 
                write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x17);
2091
 
                write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x17);
 
1240
                write_nic_byte(priv, rOFDM0_XAAGCCore1, 0x17);
 
1241
                write_nic_byte(priv, rOFDM0_XBAGCCore1, 0x17);
 
1242
                write_nic_byte(priv, rOFDM0_XCAGCCore1, 0x17);
 
1243
                write_nic_byte(priv, rOFDM0_XDAGCCore1, 0x17);
2092
1244
 
2093
1245
                // 1.3 Lower PD_TH for OFDM.
2094
1246
                if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
2095
1247
                {
2096
1248
                        /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
2097
1249
                        // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2098
 
                        #ifdef RTL8190P
2099
 
                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x40);
2100
 
                        #else
2101
 
                                write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00);
2102
 
                                #endif
2103
 
                        /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2104
 
                                write_nic_byte(pAdapter, rOFDM0_RxDetector1, 0x40);
2105
 
                        */
2106
 
                        //else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
2107
 
 
2108
 
 
2109
 
                        //else
2110
 
                                //PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x40);
 
1250
                        write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x00);
2111
1251
                }
2112
1252
                else
2113
 
                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
 
1253
                        write_nic_byte(priv, rOFDM0_RxDetector1, 0x42);
2114
1254
 
2115
1255
                // 1.4 Lower CS ratio for CCK.
2116
 
                write_nic_byte(dev, 0xa0a, 0x08);
 
1256
                write_nic_byte(priv, 0xa0a, 0x08);
2117
1257
 
2118
1258
                // 1.5 Higher EDCCA.
2119
1259
                //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x325);
2130
1270
                if (dm_digtable.dig_state == DM_STA_DIG_ON &&
2131
1271
                        (priv->reset_count == reset_cnt))
2132
1272
                {
2133
 
                        dm_ctrl_initgain_byrssi_highpwr(dev);
 
1273
                        dm_ctrl_initgain_byrssi_highpwr(priv);
2134
1274
                        return;
2135
1275
                }
2136
1276
                else
2142
1282
                }
2143
1283
 
2144
1284
                dm_digtable.dig_state = DM_STA_DIG_ON;
2145
 
                //DbgPrint("DIG ON\n\r");
2146
1285
 
2147
1286
                // 2.1 Set initial gain.
2148
1287
                // 2008/02/26 MH SD3-Jerry suggest to prevent dirty environment.
2149
1288
                if (reset_flag == 1)
2150
1289
                {
2151
 
                        write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x2c);
2152
 
                        write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x2c);
2153
 
                        write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x2c);
2154
 
                        write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x2c);
 
1290
                        write_nic_byte(priv, rOFDM0_XAAGCCore1, 0x2c);
 
1291
                        write_nic_byte(priv, rOFDM0_XBAGCCore1, 0x2c);
 
1292
                        write_nic_byte(priv, rOFDM0_XCAGCCore1, 0x2c);
 
1293
                        write_nic_byte(priv, rOFDM0_XDAGCCore1, 0x2c);
2155
1294
                }
2156
1295
                else
2157
1296
                {
2158
 
                write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20);
2159
 
                write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20);
2160
 
                write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20);
2161
 
                write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20);
 
1297
                        write_nic_byte(priv, rOFDM0_XAAGCCore1, 0x20);
 
1298
                        write_nic_byte(priv, rOFDM0_XBAGCCore1, 0x20);
 
1299
                        write_nic_byte(priv, rOFDM0_XCAGCCore1, 0x20);
 
1300
                        write_nic_byte(priv, rOFDM0_XDAGCCore1, 0x20);
2162
1301
                }
2163
1302
 
2164
1303
                // 2.2 Higher PD_TH for OFDM.
2166
1305
                {
2167
1306
                        /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
2168
1307
                        // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2169
 
                        #ifdef RTL8190P
2170
 
                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2171
 
                        #else
2172
 
                                write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
2173
 
                                #endif
2174
 
                        /*
2175
 
                        else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2176
 
                                write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2177
 
                        */
2178
 
                        //else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
2179
 
 
2180
 
                        //else
2181
 
                                //PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x42);
 
1308
                        write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x20);
2182
1309
                }
2183
1310
                else
2184
 
                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x44);
 
1311
                        write_nic_byte(priv, rOFDM0_RxDetector1, 0x44);
2185
1312
 
2186
1313
                // 2.3 Higher CS ratio for CCK.
2187
 
                write_nic_byte(dev, 0xa0a, 0xcd);
 
1314
                write_nic_byte(priv, 0xa0a, 0xcd);
2188
1315
 
2189
1316
                // 2.4 Lower EDCCA.
2190
1317
                /* 2008/01/11 MH 90/92 series are the same. */
2191
1318
                //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x346);
2192
1319
 
2193
1320
                // 2.5 DIG On.
2194
 
                rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1);   // Only clear byte 1 and rewrite.
 
1321
                rtl8192_setBBreg(priv, UFWP, bMaskByte1, 0x1);  // Only clear byte 1 and rewrite.
2195
1322
 
2196
1323
        }
2197
1324
 
2198
 
        dm_ctrl_initgain_byrssi_highpwr(dev);
 
1325
        dm_ctrl_initgain_byrssi_highpwr(priv);
2199
1326
 
2200
1327
}
2201
1328
 
2202
 
static void dm_ctrl_initgain_byrssi_highpwr(
2203
 
        struct net_device * dev)
 
1329
static void dm_ctrl_initgain_byrssi_highpwr(struct r8192_priv *priv)
2204
1330
{
2205
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2206
1331
        static u32 reset_cnt_highpwr = 0;
2207
1332
 
2208
1333
        // For smooth, we can not change high power DIG state in the range.
2226
1351
                // 3.1 Higher PD_TH for OFDM for high power state.
2227
1352
                if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
2228
1353
                {
2229
 
                        #ifdef RTL8190P
2230
 
                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
2231
 
                        #else
2232
 
                                write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10);
2233
 
                                #endif
2234
 
 
2235
 
                        /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2236
 
                                write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
2237
 
                        */
2238
 
 
 
1354
                        write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x10);
2239
1355
                }
2240
1356
                else
2241
 
                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x43);
 
1357
                        write_nic_byte(priv, rOFDM0_RxDetector1, 0x43);
2242
1358
        }
2243
1359
        else
2244
1360
        {
2254
1370
                        // 3.2 Recover PD_TH for OFDM for normal power region.
2255
1371
                        if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
2256
1372
                        {
2257
 
                                #ifdef RTL8190P
2258
 
                                write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2259
 
                                #else
2260
 
                                        write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
2261
 
                                        #endif
2262
 
                                /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2263
 
                                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2264
 
                                */
2265
 
 
 
1373
                                write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x20);
2266
1374
                        }
2267
1375
                        else
2268
 
                                write_nic_byte(dev, rOFDM0_RxDetector1, 0x44);
 
1376
                                write_nic_byte(priv, rOFDM0_RxDetector1, 0x44);
2269
1377
                }
2270
1378
        }
2271
1379
 
2274
1382
}
2275
1383
 
2276
1384
 
2277
 
static void dm_initial_gain(
2278
 
        struct net_device * dev)
 
1385
static void dm_initial_gain(struct r8192_priv *priv)
2279
1386
{
2280
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2281
1387
        u8                                      initial_gain=0;
2282
1388
        static u8                               initialized=0, force_write=0;
2283
1389
        static u32                      reset_cnt=0;
2312
1418
                dm_digtable.cur_ig_value = priv->DefaultInitialGain[0];
2313
1419
                dm_digtable.pre_ig_value = 0;
2314
1420
        }
2315
 
        //DbgPrint("DM_DigTable.CurIGValue = 0x%x, DM_DigTable.PreIGValue = 0x%x\n", DM_DigTable.CurIGValue, DM_DigTable.PreIGValue);
2316
1421
 
2317
1422
        // if silent reset happened, we should rewrite the values back
2318
1423
        if(priv->reset_count != reset_cnt)
2321
1426
                reset_cnt = priv->reset_count;
2322
1427
        }
2323
1428
 
2324
 
        if(dm_digtable.pre_ig_value != read_nic_byte(dev, rOFDM0_XAAGCCore1))
 
1429
        if(dm_digtable.pre_ig_value != read_nic_byte(priv, rOFDM0_XAAGCCore1))
2325
1430
                force_write = 1;
2326
1431
 
2327
1432
        {
2329
1434
                        || !initialized || force_write)
2330
1435
                {
2331
1436
                        initial_gain = (u8)dm_digtable.cur_ig_value;
2332
 
                        //DbgPrint("Write initial gain = 0x%x\n", initial_gain);
2333
1437
                        // Set initial gain.
2334
 
                        write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain);
2335
 
                        write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain);
2336
 
                        write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain);
2337
 
                        write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain);
 
1438
                        write_nic_byte(priv, rOFDM0_XAAGCCore1, initial_gain);
 
1439
                        write_nic_byte(priv, rOFDM0_XBAGCCore1, initial_gain);
 
1440
                        write_nic_byte(priv, rOFDM0_XCAGCCore1, initial_gain);
 
1441
                        write_nic_byte(priv, rOFDM0_XDAGCCore1, initial_gain);
2338
1442
                        dm_digtable.pre_ig_value = dm_digtable.cur_ig_value;
2339
1443
                        initialized = 1;
2340
1444
                        force_write = 0;
2342
1446
        }
2343
1447
}
2344
1448
 
2345
 
static void dm_pd_th(
2346
 
        struct net_device * dev)
 
1449
static void dm_pd_th(struct r8192_priv *priv)
2347
1450
{
2348
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2349
1451
        static u8                               initialized=0, force_write=0;
2350
1452
        static u32                      reset_cnt = 0;
2351
1453
 
2390
1492
                if((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) ||
2391
1493
                        (initialized<=3) || force_write)
2392
1494
                {
2393
 
                        //DbgPrint("Write PD_TH state = %d\n", DM_DigTable.CurPD_THState);
2394
1495
                        if(dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER)
2395
1496
                        {
2396
1497
                                // Lower PD_TH for OFDM.
2398
1499
                                {
2399
1500
                                        /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
2400
1501
                                        // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2401
 
                                        #ifdef RTL8190P
2402
 
                                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x40);
2403
 
                                        #else
2404
 
                                                write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00);
2405
 
                                                #endif
2406
 
                                        /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2407
 
                                                write_nic_byte(dev, rOFDM0_RxDetector1, 0x40);
2408
 
                                        */
 
1502
                                        write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x00);
2409
1503
                                }
2410
1504
                                else
2411
 
                                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
 
1505
                                        write_nic_byte(priv, rOFDM0_RxDetector1, 0x42);
2412
1506
                        }
2413
1507
                        else if(dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER)
2414
1508
                        {
2417
1511
                                {
2418
1512
                                        /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
2419
1513
                                        // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
2420
 
                                        #ifdef RTL8190P
2421
 
                                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2422
 
                                        #else
2423
 
                                                write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
2424
 
                                                #endif
2425
 
                                        /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2426
 
                                                write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
2427
 
                                        */
 
1514
                                        write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x20);
2428
1515
                                }
2429
1516
                                else
2430
 
                                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x44);
 
1517
                                        write_nic_byte(priv, rOFDM0_RxDetector1, 0x44);
2431
1518
                        }
2432
1519
                        else if(dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER)
2433
1520
                        {
2434
1521
                                // Higher PD_TH for OFDM for high power state.
2435
1522
                                if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
2436
1523
                                {
2437
 
                                        #ifdef RTL8190P
2438
 
                                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
2439
 
                                        #else
2440
 
                                                write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10);
2441
 
                                                #endif
2442
 
                                        /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
2443
 
                                                write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
2444
 
                                        */
 
1524
                                        write_nic_byte(priv, (rOFDM0_XATxAFE+3), 0x10);
2445
1525
                                }
2446
1526
                                else
2447
 
                                        write_nic_byte(dev, rOFDM0_RxDetector1, 0x43);
 
1527
                                        write_nic_byte(priv, rOFDM0_RxDetector1, 0x43);
2448
1528
                        }
2449
1529
                        dm_digtable.prepd_thstate = dm_digtable.curpd_thstate;
2450
1530
                        if(initialized <= 3)
2454
1534
        }
2455
1535
}
2456
1536
 
2457
 
static  void dm_cs_ratio(
2458
 
        struct net_device * dev)
 
1537
static void dm_cs_ratio(struct r8192_priv *priv)
2459
1538
{
2460
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2461
1539
        static u8                               initialized=0,force_write=0;
2462
1540
        static u32                      reset_cnt = 0;
2463
1541
 
2499
1577
        if((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) ||
2500
1578
                !initialized || force_write)
2501
1579
        {
2502
 
                //DbgPrint("Write CS_ratio state = %d\n", DM_DigTable.CurCS_ratioState);
2503
1580
                if(dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER)
2504
1581
                {
2505
1582
                        // Lower CS ratio for CCK.
2506
 
                        write_nic_byte(dev, 0xa0a, 0x08);
 
1583
                        write_nic_byte(priv, 0xa0a, 0x08);
2507
1584
                }
2508
1585
                else if(dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER)
2509
1586
                {
2510
1587
                        // Higher CS ratio for CCK.
2511
 
                        write_nic_byte(dev, 0xa0a, 0xcd);
 
1588
                        write_nic_byte(priv, 0xa0a, 0xcd);
2512
1589
                }
2513
1590
                dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state;
2514
1591
                initialized = 1;
2516
1593
        }
2517
1594
}
2518
1595
 
2519
 
void dm_init_edca_turbo(struct net_device *dev)
 
1596
void dm_init_edca_turbo(struct r8192_priv *priv)
2520
1597
{
2521
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2522
1598
 
2523
1599
        priv->bcurrent_turbo_EDCA = false;
2524
1600
        priv->ieee80211->bis_any_nonbepkts = false;
2525
1601
        priv->bis_cur_rdlstate = false;
2526
1602
}
2527
1603
 
2528
 
#if 1
2529
 
static void dm_check_edca_turbo(
2530
 
        struct net_device * dev)
 
1604
static void dm_check_edca_turbo(struct r8192_priv *priv)
2531
1605
{
2532
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2533
1606
        PRT_HIGH_THROUGHPUT     pHTInfo = priv->ieee80211->pHTInfo;
2534
1607
        //PSTA_QOS                      pStaQos = pMgntInfo->pStaQos;
2535
1608
 
2543
1616
        // Do not be Turbo if it's under WiFi config and Qos Enabled, because the EDCA parameters
2544
1617
        // should follow the settings from QAP. By Bruce, 2007-12-07.
2545
1618
        //
2546
 
        #if 1
2547
1619
        if(priv->ieee80211->state != IEEE80211_LINKED)
2548
1620
                goto dm_CheckEdcaTurbo_EXIT;
2549
 
        #endif
2550
1621
        // We do not turn on EDCA turbo mode for some AP that has IOT issue
2551
1622
        if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO)
2552
1623
                goto dm_CheckEdcaTurbo_EXIT;
2553
1624
 
2554
 
//      printk("========>%s():bis_any_nonbepkts is %d\n",__FUNCTION__,priv->bis_any_nonbepkts);
2555
1625
        // Check the status for current condition.
2556
1626
        if(!priv->ieee80211->bis_any_nonbepkts)
2557
1627
        {
2560
1630
                // For RT-AP, we needs to turn it on when Rx>Tx
2561
1631
                if(curRxOkCnt > 4*curTxOkCnt)
2562
1632
                {
2563
 
                        //printk("%s():curRxOkCnt > 4*curTxOkCnt\n");
2564
1633
                        if(!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
2565
1634
                        {
2566
 
                                write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]);
 
1635
                                write_nic_dword(priv, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]);
2567
1636
                                priv->bis_cur_rdlstate = true;
2568
1637
                        }
2569
1638
                }
2570
1639
                else
2571
1640
                {
2572
 
 
2573
 
                        //printk("%s():curRxOkCnt < 4*curTxOkCnt\n");
2574
1641
                        if(priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
2575
1642
                        {
2576
 
                                write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]);
 
1643
                                write_nic_dword(priv, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]);
2577
1644
                                priv->bis_cur_rdlstate = false;
2578
1645
                        }
2579
1646
 
2597
1664
                                u8 mode = priv->ieee80211->mode;
2598
1665
 
2599
1666
                        // For Each time updating EDCA parameter, reset EDCA turbo mode status.
2600
 
                                dm_init_edca_turbo(dev);
 
1667
                                dm_init_edca_turbo(priv);
2601
1668
                                u1bAIFS = qos_parameters->aifs[0] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime;
2602
1669
                                u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[0]))<< AC_PARAM_TXOP_LIMIT_OFFSET)|
2603
1670
                                        (((u32)(qos_parameters->cw_max[0]))<< AC_PARAM_ECW_MAX_OFFSET)|
2605
1672
                                        ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET));
2606
1673
                                printk("===>u4bAcParam:%x, ", u4bAcParam);
2607
1674
                        //write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam);
2608
 
                                write_nic_dword(dev, EDCAPARA_BE,  u4bAcParam);
 
1675
                                write_nic_dword(priv, EDCAPARA_BE,  u4bAcParam);
2609
1676
 
2610
1677
                        // Check ACM bit.
2611
1678
                        // If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13.
2613
1680
                        // TODO:  Modified this part and try to set acm control in only 1 IO processing!!
2614
1681
 
2615
1682
                                        PACI_AIFSN      pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]);
2616
 
                                        u8              AcmCtrl = read_nic_byte( dev, AcmHwCtrl );
 
1683
                                        u8              AcmCtrl = read_nic_byte(priv, AcmHwCtrl );
2617
1684
                                        if( pAciAifsn->f.ACM )
2618
1685
                                        { // ACM bit is 1.
2619
1686
                                                AcmCtrl |= AcmHw_BeqEn;
2624
1691
                                        }
2625
1692
 
2626
1693
                                        RT_TRACE( COMP_QOS,"SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl ) ;
2627
 
                                        write_nic_byte(dev, AcmHwCtrl, AcmCtrl );
 
1694
                                        write_nic_byte(priv, AcmHwCtrl, AcmCtrl );
2628
1695
                                }
2629
1696
                        }
2630
1697
                        priv->bcurrent_turbo_EDCA = false;
2638
1705
        lastTxOkCnt = priv->stats.txbytesunicast;
2639
1706
        lastRxOkCnt = priv->stats.rxbytesunicast;
2640
1707
}
2641
 
#endif
2642
1708
 
2643
 
static void dm_init_ctstoself(struct net_device * dev)
 
1709
static void dm_init_ctstoself(struct r8192_priv *priv)
2644
1710
{
2645
 
        struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
2646
 
 
2647
1711
        priv->ieee80211->bCTSToSelfEnable = TRUE;
2648
1712
        priv->ieee80211->CTSToSelfTH = CTSToSelfTHVal;
2649
1713
}
2650
1714
 
2651
 
static void dm_ctstoself(struct net_device *dev)
 
1715
static void dm_ctstoself(struct r8192_priv *priv)
2652
1716
{
2653
 
        struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
2654
1717
        PRT_HIGH_THROUGHPUT     pHTInfo = priv->ieee80211->pHTInfo;
2655
1718
        static unsigned long                            lastTxOkCnt = 0;
2656
1719
        static unsigned long                            lastRxOkCnt = 0;
2675
1738
                if(curRxOkCnt > 4*curTxOkCnt)   //downlink, disable CTS to self
2676
1739
                {
2677
1740
                        pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF;
2678
 
                        //DbgPrint("dm_CTSToSelf() ==> CTS to self disabled -- downlink\n");
2679
1741
                }
2680
1742
                else    //uplink
2681
1743
                {
2682
 
                #if 1
2683
1744
                        pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
2684
 
                #else
2685
 
                        if(priv->undecorated_smoothed_pwdb < priv->ieee80211->CTSToSelfTH)      // disable CTS to self
2686
 
                        {
2687
 
                                pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF;
2688
 
                                //DbgPrint("dm_CTSToSelf() ==> CTS to self disabled\n");
2689
 
                        }
2690
 
                        else if(priv->undecorated_smoothed_pwdb >= (priv->ieee80211->CTSToSelfTH+5))    // enable CTS to self
2691
 
                        {
2692
 
                                pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
2693
 
                                //DbgPrint("dm_CTSToSelf() ==> CTS to self enabled\n");
2694
 
                        }
2695
 
                #endif
2696
1745
                }
2697
1746
 
2698
1747
                lastTxOkCnt = priv->stats.txbytesunicast;
2703
1752
 
2704
1753
 
2705
1754
/* Copy 8187B template for 9xseries */
2706
 
#if 1
2707
 
static void dm_check_rfctrl_gpio(struct net_device * dev)
 
1755
static void dm_check_rfctrl_gpio(struct r8192_priv *priv)
2708
1756
{
2709
 
#ifdef RTL8192E
2710
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2711
 
#endif
2712
1757
 
2713
1758
        // Walk around for DTM test, we will not enable HW - radio on/off because r/w
2714
1759
        // page 1 register before Lextra bus is enabled cause system fails when resuming
2715
1760
        // from S4. 20080218, Emily
2716
1761
 
2717
1762
        // Stop to execute workitem to prevent S3/S4 bug.
2718
 
#ifdef RTL8190P
2719
 
        return;
2720
 
#endif
2721
 
#ifdef RTL8192U
2722
 
        return;
2723
 
#endif
2724
 
#ifdef RTL8192E
2725
 
                queue_delayed_work(priv->priv_wq,&priv->gpio_change_rf_wq,0);
2726
 
#endif
2727
 
 
2728
 
}
2729
 
 
2730
 
#endif
2731
 
/* Check if PBC button is pressed. */
2732
 
static  void    dm_check_pbc_gpio(struct net_device *dev)
2733
 
{
2734
 
#ifdef RTL8192U
2735
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2736
 
        u8 tmp1byte;
2737
 
 
2738
 
 
2739
 
        tmp1byte = read_nic_byte(dev,GPI);
2740
 
        if(tmp1byte == 0xff)
2741
 
                return;
2742
 
 
2743
 
        if (tmp1byte&BIT6 || tmp1byte&BIT0)
2744
 
        {
2745
 
                // Here we only set bPbcPressed to TRUE
2746
 
                // After trigger PBC, the variable will be set to FALSE
2747
 
                RT_TRACE(COMP_IO, "CheckPbcGPIO - PBC is pressed\n");
2748
 
                priv->bpbc_pressed = true;
2749
 
        }
2750
 
#endif
2751
 
 
2752
 
}
2753
 
 
2754
 
#ifdef RTL8192E
 
1763
        queue_delayed_work(priv->priv_wq,&priv->gpio_change_rf_wq,0);
 
1764
}
2755
1765
 
2756
1766
/* PCI will not support workitem call back HW radio on-off control. */
2757
1767
void dm_gpio_change_rf_callback(struct work_struct *work)
2758
1768
{
2759
1769
        struct delayed_work *dwork = container_of(work,struct delayed_work,work);
2760
1770
        struct r8192_priv *priv = container_of(dwork,struct r8192_priv,gpio_change_rf_wq);
2761
 
        struct net_device *dev = priv->ieee80211->dev;
2762
1771
        u8 tmp1byte;
2763
1772
        RT_RF_POWER_STATE       eRfPowerStateToSet;
2764
1773
        bool bActuallySet = false;
2768
1777
        } else {
2769
1778
                // 0x108 GPIO input register is read only
2770
1779
                //set 0x108 B1= 1: RF-ON; 0: RF-OFF.
2771
 
                tmp1byte = read_nic_byte(dev,GPI);
 
1780
                tmp1byte = read_nic_byte(priv, GPI);
2772
1781
 
2773
1782
                eRfPowerStateToSet = (tmp1byte&BIT1) ?  eRfOn : eRfOff;
2774
1783
 
2785
1794
 
2786
1795
                if (bActuallySet) {
2787
1796
                        priv->bHwRfOffAction = 1;
2788
 
                        MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW);
 
1797
                        MgntActSet_RF_State(priv, eRfPowerStateToSet, RF_CHANGE_BY_HW);
2789
1798
                        //DrvIFIndicateCurrentPhyStatus(pAdapter);
2790
1799
                } else {
2791
1800
                        msleep(2000);
2793
1802
        }
2794
1803
}
2795
1804
 
2796
 
#endif
2797
 
 
2798
1805
/* Check if Current RF RX path is enabled */
2799
1806
void dm_rf_pathcheck_workitemcallback(struct work_struct *work)
2800
1807
{
2801
1808
        struct delayed_work *dwork = container_of(work,struct delayed_work,work);
2802
1809
        struct r8192_priv *priv = container_of(dwork,struct r8192_priv,rfpath_check_wq);
2803
 
        struct net_device *dev =priv->ieee80211->dev;
2804
 
        //bool bactually_set = false;
2805
1810
        u8 rfpath = 0, i;
2806
1811
 
2807
1812
 
2808
1813
        /* 2008/01/30 MH After discussing with SD3 Jerry, 0xc04/0xd04 register will
2809
1814
           always be the same. We only read 0xc04 now. */
2810
 
        rfpath = read_nic_byte(dev, 0xc04);
 
1815
        rfpath = read_nic_byte(priv, 0xc04);
2811
1816
 
2812
1817
        // Check Bit 0-3, it means if RF A-D is enabled.
2813
1818
        for (i = 0; i < RF90_PATH_MAX; i++)
2820
1825
        if(!DM_RxPathSelTable.Enable)
2821
1826
                return;
2822
1827
 
2823
 
        dm_rxpath_sel_byrssi(dev);
 
1828
        dm_rxpath_sel_byrssi(priv);
2824
1829
}
2825
1830
 
2826
 
static void dm_init_rxpath_selection(struct net_device * dev)
 
1831
static void dm_init_rxpath_selection(struct r8192_priv *priv)
2827
1832
{
2828
1833
        u8 i;
2829
 
        struct r8192_priv *priv = ieee80211_priv(dev);
 
1834
 
2830
1835
        DM_RxPathSelTable.Enable = 1;   //default enabled
2831
1836
        DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low;
2832
1837
        DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH;
2844
1849
        }
2845
1850
}
2846
1851
 
2847
 
static void dm_rxpath_sel_byrssi(struct net_device * dev)
 
1852
static void dm_rxpath_sel_byrssi(struct r8192_priv *priv)
2848
1853
{
2849
 
        struct r8192_priv *priv = ieee80211_priv(dev);
2850
1854
        u8                              i, max_rssi_index=0, min_rssi_index=0, sec_rssi_index=0, rf_num=0;
2851
1855
        u8                              tmp_max_rssi=0, tmp_min_rssi=0, tmp_sec_rssi=0;
2852
1856
        u8                              cck_default_Rx=0x2;     //RF-C
2863
1867
 
2864
1868
        if(!cck_Rx_Path_initialized)
2865
1869
        {
2866
 
                DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(dev, 0xa07)&0xf);
 
1870
                DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(priv, 0xa07)&0xf);
2867
1871
                cck_Rx_Path_initialized = 1;
2868
1872
        }
2869
1873
 
2870
1874
        DM_RxPathSelTable.disabledRF = 0xf;
2871
 
        DM_RxPathSelTable.disabledRF &=~ (read_nic_byte(dev, 0xc04));
 
1875
        DM_RxPathSelTable.disabledRF &=~ (read_nic_byte(priv, 0xc04));
2872
1876
 
2873
1877
        if(priv->ieee80211->mode == WIRELESS_MODE_B)
2874
1878
        {
2875
1879
                DM_RxPathSelTable.cck_method = CCK_Rx_Version_2;        //pure B mode, fixed cck version2
2876
 
                //DbgPrint("Pure B mode, use cck rx version2 \n");
2877
1880
        }
2878
1881
 
2879
1882
        //decide max/sec/min rssi index
3067
2070
                        //record the enabled rssi threshold
3068
2071
                        DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5;
3069
2072
                        //disable the BB Rx path, OFDM
3070
 
                        rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<<min_rssi_index, 0x0);  // 0xc04[3:0]
3071
 
                        rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x1<<min_rssi_index, 0x0);  // 0xd04[3:0]
 
2073
                        rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0x1<<min_rssi_index, 0x0); // 0xc04[3:0]
 
2074
                        rtl8192_setBBreg(priv, rOFDM1_TRxPathEnable, 0x1<<min_rssi_index, 0x0); // 0xd04[3:0]
3072
2075
                        disabled_rf_cnt++;
3073
2076
                }
3074
2077
                if(DM_RxPathSelTable.cck_method == CCK_Rx_Version_1)
3083
2086
        if(update_cck_rx_path)
3084
2087
        {
3085
2088
                DM_RxPathSelTable.cck_Rx_path = (cck_default_Rx<<2)|(cck_optional_Rx);
3086
 
                rtl8192_setBBreg(dev, rCCK0_AFESetting, 0x0f000000, DM_RxPathSelTable.cck_Rx_path);
 
2089
                rtl8192_setBBreg(priv, rCCK0_AFESetting, 0x0f000000, DM_RxPathSelTable.cck_Rx_path);
3087
2090
        }
3088
2091
 
3089
2092
        if(DM_RxPathSelTable.disabledRF)
3095
2098
                                if(tmp_max_rssi >= DM_RxPathSelTable.rf_enable_rssi_th[i])
3096
2099
                                {
3097
2100
                                        //enable the BB Rx path
3098
 
                                        //DbgPrint("RF-%d is enabled. \n", 0x1<<i);
3099
 
                                        rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<<i, 0x1);       // 0xc04[3:0]
3100
 
                                        rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x1<<i, 0x1);       // 0xd04[3:0]
 
2101
                                        rtl8192_setBBreg(priv, rOFDM0_TRxPathEnable, 0x1<<i, 0x1);      // 0xc04[3:0]
 
2102
                                        rtl8192_setBBreg(priv, rOFDM1_TRxPathEnable, 0x1<<i, 0x1);      // 0xd04[3:0]
3101
2103
                                        DM_RxPathSelTable.rf_enable_rssi_th[i] = 100;
3102
2104
                                        disabled_rf_cnt--;
3103
2105
                                }
3109
2111
/*
3110
2112
 * Call a workitem to check current RXRF path and Rx Path selection by RSSI.
3111
2113
 */
3112
 
static void dm_check_rx_path_selection(struct net_device *dev)
 
2114
static void dm_check_rx_path_selection(struct r8192_priv *priv)
3113
2115
{
3114
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3115
2116
        queue_delayed_work(priv->priv_wq,&priv->rfpath_check_wq,0);
3116
2117
}
3117
2118
 
3118
 
static void dm_init_fsync (struct net_device *dev)
 
2119
static void dm_init_fsync(struct r8192_priv *priv)
3119
2120
{
3120
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3121
 
 
3122
2121
        priv->ieee80211->fsync_time_interval = 500;
3123
2122
        priv->ieee80211->fsync_rate_bitmap = 0x0f000800;
3124
2123
        priv->ieee80211->fsync_rssi_threshold = 30;
3125
 
#ifdef RTL8190P
3126
 
        priv->ieee80211->bfsync_enable = true;
3127
 
#else
3128
2124
        priv->ieee80211->bfsync_enable = false;
3129
 
#endif
3130
2125
        priv->ieee80211->fsync_multiple_timeinterval = 3;
3131
2126
        priv->ieee80211->fsync_firstdiff_ratethreshold= 100;
3132
2127
        priv->ieee80211->fsync_seconddiff_ratethreshold= 200;
3134
2129
        priv->framesyncMonitor = 1;     // current default 0xc38 monitor on
3135
2130
 
3136
2131
        init_timer(&priv->fsync_timer);
3137
 
        priv->fsync_timer.data = (unsigned long)dev;
 
2132
        priv->fsync_timer.data = (unsigned long)priv;
3138
2133
        priv->fsync_timer.function = dm_fsync_timer_callback;
3139
2134
}
3140
2135
 
3141
2136
 
3142
 
static void dm_deInit_fsync(struct net_device *dev)
 
2137
static void dm_deInit_fsync(struct r8192_priv *priv)
3143
2138
{
3144
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3145
2139
        del_timer_sync(&priv->fsync_timer);
3146
2140
}
3147
2141
 
3148
 
void dm_fsync_timer_callback(unsigned long data)
 
2142
static void dm_fsync_timer_callback(unsigned long data)
3149
2143
{
3150
 
        struct net_device *dev = (struct net_device *)data;
3151
 
        struct r8192_priv *priv = ieee80211_priv((struct net_device *)data);
 
2144
        struct r8192_priv *priv = (struct r8192_priv *)data;
3152
2145
        u32 rate_index, rate_count = 0, rate_count_diff=0;
3153
2146
        bool            bSwitchFromCountDiff = false;
3154
2147
        bool            bDoubleTimeInterval = false;
3209
2202
                        priv->bswitch_fsync = !priv->bswitch_fsync;
3210
2203
                        if(priv->bswitch_fsync)
3211
2204
                        {
3212
 
                        #ifdef RTL8190P
3213
 
                                write_nic_byte(dev,0xC36, 0x00);
3214
 
                        #else
3215
 
                                write_nic_byte(dev,0xC36, 0x1c);
3216
 
                        #endif
3217
 
                                write_nic_byte(dev, 0xC3e, 0x90);
 
2205
                                write_nic_byte(priv,0xC36, 0x1c);
 
2206
                                write_nic_byte(priv, 0xC3e, 0x90);
3218
2207
                        }
3219
2208
                        else
3220
2209
                        {
3221
 
                        #ifdef RTL8190P
3222
 
                                write_nic_byte(dev, 0xC36, 0x40);
3223
 
                        #else
3224
 
                                write_nic_byte(dev, 0xC36, 0x5c);
3225
 
                        #endif
3226
 
                                write_nic_byte(dev, 0xC3e, 0x96);
 
2210
                                write_nic_byte(priv, 0xC36, 0x5c);
 
2211
                                write_nic_byte(priv, 0xC3e, 0x96);
3227
2212
                        }
3228
2213
                }
3229
2214
                else if(priv->undecorated_smoothed_pwdb <= priv->ieee80211->fsync_rssi_threshold)
3231
2216
                        if(priv->bswitch_fsync)
3232
2217
                        {
3233
2218
                                priv->bswitch_fsync  = false;
3234
 
                        #ifdef RTL8190P
3235
 
                                write_nic_byte(dev, 0xC36, 0x40);
3236
 
                        #else
3237
 
                                write_nic_byte(dev, 0xC36, 0x5c);
3238
 
                        #endif
3239
 
                                write_nic_byte(dev, 0xC3e, 0x96);
 
2219
                                write_nic_byte(priv, 0xC36, 0x5c);
 
2220
                                write_nic_byte(priv, 0xC3e, 0x96);
3240
2221
                        }
3241
2222
                }
3242
2223
                if(bDoubleTimeInterval){
3258
2239
                if(priv->bswitch_fsync)
3259
2240
                {
3260
2241
                        priv->bswitch_fsync  = false;
3261
 
                #ifdef RTL8190P
3262
 
                        write_nic_byte(dev, 0xC36, 0x40);
3263
 
                #else
3264
 
                        write_nic_byte(dev, 0xC36, 0x5c);
3265
 
                #endif
3266
 
                        write_nic_byte(dev, 0xC3e, 0x96);
 
2242
                        write_nic_byte(priv, 0xC36, 0x5c);
 
2243
                        write_nic_byte(priv, 0xC3e, 0x96);
3267
2244
                }
3268
2245
                priv->ContiuneDiffCount = 0;
3269
 
        #ifdef RTL8190P
3270
 
                write_nic_dword(dev, rOFDM0_RxDetector2, 0x164052cd);
3271
 
        #else
3272
 
                write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
3273
 
        #endif
 
2246
                write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c52cd);
3274
2247
        }
3275
2248
        RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount);
3276
2249
        RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync);
3277
2250
}
3278
2251
 
3279
 
static void dm_StartHWFsync(struct net_device *dev)
 
2252
static void dm_StartHWFsync(struct r8192_priv *priv)
3280
2253
{
3281
2254
        RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__);
3282
 
        write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf);
3283
 
        write_nic_byte(dev, 0xc3b, 0x41);
 
2255
        write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c12cf);
 
2256
        write_nic_byte(priv, 0xc3b, 0x41);
3284
2257
}
3285
2258
 
3286
 
static void dm_EndSWFsync(struct net_device *dev)
 
2259
static void dm_EndSWFsync(struct r8192_priv *priv)
3287
2260
{
3288
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3289
 
 
3290
2261
        RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__);
3291
2262
        del_timer_sync(&(priv->fsync_timer));
3292
2263
 
3295
2266
        {
3296
2267
                priv->bswitch_fsync  = false;
3297
2268
 
3298
 
                #ifdef RTL8190P
3299
 
                        write_nic_byte(dev, 0xC36, 0x40);
3300
 
                #else
3301
 
                write_nic_byte(dev, 0xC36, 0x5c);
3302
 
#endif
 
2269
                write_nic_byte(priv, 0xC36, 0x40);
3303
2270
 
3304
 
                write_nic_byte(dev, 0xC3e, 0x96);
 
2271
                write_nic_byte(priv, 0xC3e, 0x96);
3305
2272
        }
3306
2273
 
3307
2274
        priv->ContiuneDiffCount = 0;
3308
 
#ifndef RTL8190P
3309
 
        write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
3310
 
#endif
3311
2275
 
 
2276
        write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c52cd);
3312
2277
}
3313
2278
 
3314
 
static void dm_StartSWFsync(struct net_device *dev)
 
2279
static void dm_StartSWFsync(struct r8192_priv *priv)
3315
2280
{
3316
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3317
2281
        u32                     rateIndex;
3318
2282
        u32                     rateBitmap;
3319
2283
 
3346
2310
        priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval);
3347
2311
        add_timer(&priv->fsync_timer);
3348
2312
 
3349
 
#ifndef RTL8190P
3350
 
        write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd);
3351
 
#endif
3352
 
 
 
2313
        write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c12cd);
3353
2314
}
3354
2315
 
3355
 
static void dm_EndHWFsync(struct net_device *dev)
 
2316
static void dm_EndHWFsync(struct r8192_priv *priv)
3356
2317
{
3357
2318
        RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__);
3358
 
        write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
3359
 
        write_nic_byte(dev, 0xc3b, 0x49);
3360
 
 
 
2319
        write_nic_dword(priv, rOFDM0_RxDetector2, 0x465c52cd);
 
2320
        write_nic_byte(priv, 0xc3b, 0x49);
3361
2321
}
3362
2322
 
3363
 
void dm_check_fsync(struct net_device *dev)
 
2323
static void dm_check_fsync(struct r8192_priv *priv)
3364
2324
{
3365
2325
#define RegC38_Default                          0
3366
2326
#define RegC38_NonFsync_Other_AP        1
3367
2327
#define RegC38_Fsync_AP_BCM             2
3368
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3369
2328
        //u32                   framesyncC34;
3370
2329
        static u8               reg_c38_State=RegC38_Default;
3371
2330
        static u32      reset_cnt=0;
3381
2340
                        switch(priv->ieee80211->fsync_state)
3382
2341
                        {
3383
2342
                                case Default_Fsync:
3384
 
                                        dm_StartHWFsync(dev);
 
2343
                                        dm_StartHWFsync(priv);
3385
2344
                                        priv->ieee80211->fsync_state = HW_Fsync;
3386
2345
                                        break;
3387
2346
                                case SW_Fsync:
3388
 
                                        dm_EndSWFsync(dev);
3389
 
                                        dm_StartHWFsync(dev);
 
2347
                                        dm_EndSWFsync(priv);
 
2348
                                        dm_StartHWFsync(priv);
3390
2349
                                        priv->ieee80211->fsync_state = HW_Fsync;
3391
2350
                                        break;
3392
2351
                                case HW_Fsync:
3399
2358
                        switch(priv->ieee80211->fsync_state)
3400
2359
                        {
3401
2360
                                case Default_Fsync:
3402
 
                                        dm_StartSWFsync(dev);
 
2361
                                        dm_StartSWFsync(priv);
3403
2362
                                        priv->ieee80211->fsync_state = SW_Fsync;
3404
2363
                                        break;
3405
2364
                                case HW_Fsync:
3406
 
                                        dm_EndHWFsync(dev);
3407
 
                                        dm_StartSWFsync(dev);
 
2365
                                        dm_EndHWFsync(priv);
 
2366
                                        dm_StartSWFsync(priv);
3408
2367
                                        priv->ieee80211->fsync_state = SW_Fsync;
3409
2368
                                        break;
3410
2369
                                case SW_Fsync:
3417
2376
                {
3418
2377
                        if(reg_c38_State != RegC38_Fsync_AP_BCM)
3419
2378
                        {       //For broadcom AP we write different default value
3420
 
                                #ifdef RTL8190P
3421
 
                                        write_nic_byte(dev, rOFDM0_RxDetector3, 0x15);
3422
 
                                #else
3423
 
                                        write_nic_byte(dev, rOFDM0_RxDetector3, 0x95);
3424
 
                                #endif
 
2379
                                write_nic_byte(priv, rOFDM0_RxDetector3, 0x95);
3425
2380
 
3426
2381
                                reg_c38_State = RegC38_Fsync_AP_BCM;
3427
2382
                        }
3432
2387
                switch(priv->ieee80211->fsync_state)
3433
2388
                {
3434
2389
                        case HW_Fsync:
3435
 
                                dm_EndHWFsync(dev);
 
2390
                                dm_EndHWFsync(priv);
3436
2391
                                priv->ieee80211->fsync_state = Default_Fsync;
3437
2392
                                break;
3438
2393
                        case SW_Fsync:
3439
 
                                dm_EndSWFsync(dev);
 
2394
                                dm_EndSWFsync(priv);
3440
2395
                                priv->ieee80211->fsync_state = Default_Fsync;
3441
2396
                                break;
3442
2397
                        case Default_Fsync:
3452
2407
                                {
3453
2408
                                        if(reg_c38_State != RegC38_NonFsync_Other_AP)
3454
2409
                                        {
3455
 
                                                #ifdef RTL8190P
3456
 
                                                        write_nic_byte(dev, rOFDM0_RxDetector3, 0x10);
3457
 
                                                #else
3458
 
                                                        write_nic_byte(dev, rOFDM0_RxDetector3, 0x90);
3459
 
                                                #endif
 
2410
                                                write_nic_byte(priv, rOFDM0_RxDetector3, 0x90);
3460
2411
 
3461
2412
                                                reg_c38_State = RegC38_NonFsync_Other_AP;
3462
 
                                        #if 0//cosa
3463
 
                                                if (Adapter->HardwareType == HARDWARE_TYPE_RTL8190P)
3464
 
                                                        DbgPrint("Fsync is idle, rssi<=35, write 0xc38 = 0x%x \n", 0x10);
3465
 
                                                else
3466
 
                                                        DbgPrint("Fsync is idle, rssi<=35, write 0xc38 = 0x%x \n", 0x90);
3467
 
                                        #endif
3468
2413
                                        }
3469
2414
                                }
3470
2415
                                else if(priv->undecorated_smoothed_pwdb >= (RegC38_TH+5))
3471
2416
                                {
3472
2417
                                        if(reg_c38_State)
3473
2418
                                        {
3474
 
                                                write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
 
2419
                                                write_nic_byte(priv, rOFDM0_RxDetector3, priv->framesync);
3475
2420
                                                reg_c38_State = RegC38_Default;
3476
 
                                                //DbgPrint("Fsync is idle, rssi>=40, write 0xc38 = 0x%x \n", pHalData->framesync);
3477
2421
                                        }
3478
2422
                                }
3479
2423
                        }
3481
2425
                        {
3482
2426
                                if(reg_c38_State)
3483
2427
                                {
3484
 
                                        write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
 
2428
                                        write_nic_byte(priv, rOFDM0_RxDetector3, priv->framesync);
3485
2429
                                        reg_c38_State = RegC38_Default;
3486
 
                                        //DbgPrint("Fsync is idle, not connected, write 0xc38 = 0x%x \n", pHalData->framesync);
3487
2430
                                }
3488
2431
                        }
3489
2432
                }
3492
2435
        {
3493
2436
                if(priv->reset_count != reset_cnt)
3494
2437
                {       //After silent reset, the reg_c38_State will be returned to default value
3495
 
                        write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
 
2438
                        write_nic_byte(priv, rOFDM0_RxDetector3, priv->framesync);
3496
2439
                        reg_c38_State = RegC38_Default;
3497
2440
                        reset_cnt = priv->reset_count;
3498
 
                        //DbgPrint("reg_c38_State = 0 for silent reset. \n");
3499
2441
                }
3500
2442
        }
3501
2443
        else
3502
2444
        {
3503
2445
                if(reg_c38_State)
3504
2446
                {
3505
 
                        write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
 
2447
                        write_nic_byte(priv, rOFDM0_RxDetector3, priv->framesync);
3506
2448
                        reg_c38_State = RegC38_Default;
3507
 
                        //DbgPrint("framesync no monitor, write 0xc38 = 0x%x \n", pHalData->framesync);
3508
2449
                }
3509
2450
        }
3510
2451
}
3513
2454
 * Detect Signal strength to control TX Registry
3514
2455
 * Tx Power Control For Near/Far Range
3515
2456
 */
3516
 
static void dm_init_dynamic_txpower(struct net_device *dev)
 
2457
static void dm_init_dynamic_txpower(struct r8192_priv *priv)
3517
2458
{
3518
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3519
 
 
3520
2459
        //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code.
3521
2460
        priv->ieee80211->bdynamic_txpower_enable = true;    //Default to enable Tx Power Control
3522
2461
        priv->bLastDTPFlag_High = false;
3525
2464
        priv->bDynamicTxLowPower = false;
3526
2465
}
3527
2466
 
3528
 
static void dm_dynamic_txpower(struct net_device *dev)
 
2467
static void dm_dynamic_txpower(struct r8192_priv *priv)
3529
2468
{
3530
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3531
2469
        unsigned int txhipower_threshhold=0;
3532
2470
        unsigned int txlowpower_threshold=0;
3533
2471
        if(priv->ieee80211->bdynamic_txpower_enable != true)
3536
2474
                priv->bDynamicTxLowPower = false;
3537
2475
                return;
3538
2476
        }
3539
 
        //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);
3540
2477
        if((priv->ieee80211->current_network.atheros_cap_exist ) && (priv->ieee80211->mode == IEEE_G)){
3541
2478
                txhipower_threshhold = TX_POWER_ATHEROAP_THRESH_HIGH;
3542
2479
                txlowpower_threshold = TX_POWER_ATHEROAP_THRESH_LOW;
3547
2484
                txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW;
3548
2485
        }
3549
2486
 
3550
 
//      printk("=======>%s(): txhipower_threshhold is %d,txlowpower_threshold is %d\n",__FUNCTION__,txhipower_threshhold,txlowpower_threshold);
3551
 
 
3552
 
        RT_TRACE(COMP_TXAGC,"priv->undecorated_smoothed_pwdb = %ld \n" , priv->undecorated_smoothed_pwdb);
 
2487
        RT_TRACE(COMP_TXAGC, "priv->undecorated_smoothed_pwdb = %ld\n" , priv->undecorated_smoothed_pwdb);
3553
2488
 
3554
2489
        if(priv->ieee80211->state == IEEE80211_LINKED)
3555
2490
        {
3586
2521
        if( (priv->bDynamicTxHighPower != priv->bLastDTPFlag_High ) ||
3587
2522
                (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low ) )
3588
2523
        {
3589
 
                RT_TRACE(COMP_TXAGC,"SetTxPowerLevel8190()  channel = %d \n" , priv->ieee80211->current_network.channel);
3590
 
 
3591
 
 
3592
 
                rtl8192_phy_setTxPower(dev,priv->ieee80211->current_network.channel);
 
2524
                RT_TRACE(COMP_TXAGC, "SetTxPowerLevel8190() channel = %d\n", priv->ieee80211->current_network.channel);
 
2525
 
 
2526
 
 
2527
                rtl8192_phy_setTxPower(priv, priv->ieee80211->current_network.channel);
3593
2528
 
3594
2529
        }
3595
2530
        priv->bLastDTPFlag_High = priv->bDynamicTxHighPower;
3598
2533
}
3599
2534
 
3600
2535
//added by vivi, for read tx rate and retrycount
3601
 
static void dm_check_txrateandretrycount(struct net_device * dev)
 
2536
static void dm_check_txrateandretrycount(struct r8192_priv *priv)
3602
2537
{
3603
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3604
2538
        struct ieee80211_device* ieee = priv->ieee80211;
3605
 
        //for 11n tx rate
3606
 
//      priv->stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);
3607
 
        ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);
3608
 
        //printk("=============>tx_rate_reg:%x\n", ieee->softmac_stats.CurrentShowTxate);
 
2539
 
3609
2540
        //for initial tx rate
3610
 
//      priv->stats.last_packet_rate = read_nic_byte(dev, Initial_Tx_Rate_Reg);
3611
 
        ieee->softmac_stats.last_packet_rate = read_nic_byte(dev ,Initial_Tx_Rate_Reg);
 
2541
        ieee->softmac_stats.last_packet_rate = read_nic_byte(priv ,Initial_Tx_Rate_Reg);
3612
2542
        //for tx tx retry count
3613
 
//      priv->stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);
3614
 
        ieee->softmac_stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);
 
2543
        ieee->softmac_stats.txretrycount = read_nic_dword(priv, Tx_Retry_Count_Reg);
3615
2544
}
3616
2545
 
3617
 
static void dm_send_rssi_tofw(struct net_device *dev)
 
2546
static void dm_send_rssi_tofw(struct r8192_priv *priv)
3618
2547
{
3619
 
        DCMD_TXCMD_T                    tx_cmd;
3620
 
        struct r8192_priv *priv = ieee80211_priv(dev);
3621
 
 
3622
2548
        // If we test chariot, we should stop the TX command ?
3623
2549
        // Because 92E will always silent reset when we send tx command. We use register
3624
2550
        // 0x1e0(byte) to botify driver.
3625
 
        write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb);
 
2551
        write_nic_byte(priv, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb);
3626
2552
        return;
3627
 
#if 1
3628
 
        tx_cmd.Op               = TXCMD_SET_RX_RSSI;
3629
 
        tx_cmd.Length   = 4;
3630
 
        tx_cmd.Value            = priv->undecorated_smoothed_pwdb;
3631
 
 
3632
 
        cmpk_message_handle_tx(dev, (u8*)&tx_cmd,
3633
 
                                                                DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T));
3634
 
#endif
3635
2553
}
3636
2554