1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2012 Realtek Corporation.*/
4 /**************************************************************
6 **************************************************************/
7 #include "halbt_precomp.h"
8 /**************************************************************
9 * Global variables, these are static variables
10 **************************************************************/
11 static struct coex_dm_8192e_2ant glcoex_dm_8192e_2ant
;
12 static struct coex_dm_8192e_2ant
*coex_dm
= &glcoex_dm_8192e_2ant
;
13 static struct coex_sta_8192e_2ant glcoex_sta_8192e_2ant
;
14 static struct coex_sta_8192e_2ant
*coex_sta
= &glcoex_sta_8192e_2ant
;
16 static const char *const glbt_info_src_8192e_2ant
[] = {
19 "BT Info[bt auto report]",
22 static u32 glcoex_ver_date_8192e_2ant
= 20130902;
23 static u32 glcoex_ver_8192e_2ant
= 0x34;
25 /**************************************************************
26 * local function proto type if needed
27 **************************************************************/
28 /**************************************************************
29 * local function start with btc8192e2ant_
30 **************************************************************/
31 static u8
btc8192e2ant_bt_rssi_state(struct btc_coexist
*btcoexist
,
32 u8 level_num
, u8 rssi_thresh
,
35 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
37 u8 bt_rssi_state
= coex_sta
->pre_bt_rssi_state
;
39 bt_rssi
= coex_sta
->bt_rssi
;
42 if ((coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
43 (coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
45 (rssi_thresh
+ BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT
))
46 bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
48 bt_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
50 if (bt_rssi
< rssi_thresh
)
51 bt_rssi_state
= BTC_RSSI_STATE_LOW
;
53 bt_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
55 } else if (level_num
== 3) {
56 if (rssi_thresh
> rssi_thresh1
) {
57 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
58 "[BTCoex], BT Rssi thresh error!!\n");
59 return coex_sta
->pre_bt_rssi_state
;
62 if ((coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
63 (coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
65 (rssi_thresh
+ BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT
))
66 bt_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
68 bt_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
69 } else if ((coex_sta
->pre_bt_rssi_state
==
70 BTC_RSSI_STATE_MEDIUM
) ||
71 (coex_sta
->pre_bt_rssi_state
==
72 BTC_RSSI_STATE_STAY_MEDIUM
)) {
73 if (bt_rssi
>= (rssi_thresh1
+
74 BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT
))
75 bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
76 else if (bt_rssi
< rssi_thresh
)
77 bt_rssi_state
= BTC_RSSI_STATE_LOW
;
79 bt_rssi_state
= BTC_RSSI_STATE_STAY_MEDIUM
;
81 if (bt_rssi
< rssi_thresh1
)
82 bt_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
84 bt_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
88 coex_sta
->pre_bt_rssi_state
= bt_rssi_state
;
93 static u8
btc8192e2ant_wifi_rssi_state(struct btc_coexist
*btcoexist
,
94 u8 index
, u8 level_num
, u8 rssi_thresh
,
97 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
99 u8 wifi_rssi_state
= coex_sta
->pre_wifi_rssi_state
[index
];
101 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_WIFI_RSSI
, &wifi_rssi
);
103 if (level_num
== 2) {
104 if ((coex_sta
->pre_wifi_rssi_state
[index
] ==
105 BTC_RSSI_STATE_LOW
) ||
106 (coex_sta
->pre_wifi_rssi_state
[index
] ==
107 BTC_RSSI_STATE_STAY_LOW
)) {
109 (rssi_thresh
+ BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT
))
110 wifi_rssi_state
= BTC_RSSI_STATE_HIGH
;
112 wifi_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
114 if (wifi_rssi
< rssi_thresh
)
115 wifi_rssi_state
= BTC_RSSI_STATE_LOW
;
117 wifi_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
119 } else if (level_num
== 3) {
120 if (rssi_thresh
> rssi_thresh1
) {
121 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
122 "[BTCoex], wifi RSSI thresh error!!\n");
123 return coex_sta
->pre_wifi_rssi_state
[index
];
126 if ((coex_sta
->pre_wifi_rssi_state
[index
] ==
127 BTC_RSSI_STATE_LOW
) ||
128 (coex_sta
->pre_wifi_rssi_state
[index
] ==
129 BTC_RSSI_STATE_STAY_LOW
)) {
131 (rssi_thresh
+ BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT
))
132 wifi_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
134 wifi_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
135 } else if ((coex_sta
->pre_wifi_rssi_state
[index
] ==
136 BTC_RSSI_STATE_MEDIUM
) ||
137 (coex_sta
->pre_wifi_rssi_state
[index
] ==
138 BTC_RSSI_STATE_STAY_MEDIUM
)) {
139 if (wifi_rssi
>= (rssi_thresh1
+
140 BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT
))
141 wifi_rssi_state
= BTC_RSSI_STATE_HIGH
;
142 else if (wifi_rssi
< rssi_thresh
)
143 wifi_rssi_state
= BTC_RSSI_STATE_LOW
;
145 wifi_rssi_state
= BTC_RSSI_STATE_STAY_MEDIUM
;
147 if (wifi_rssi
< rssi_thresh1
)
148 wifi_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
150 wifi_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
154 coex_sta
->pre_wifi_rssi_state
[index
] = wifi_rssi_state
;
156 return wifi_rssi_state
;
159 static void btc8192e2ant_monitor_bt_enable_disable(struct btc_coexist
162 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
163 static bool pre_bt_disabled
;
164 static u32 bt_disable_cnt
;
165 bool bt_active
= true, bt_disabled
= false;
167 /* This function check if bt is disabled */
169 if (coex_sta
->high_priority_tx
== 0 &&
170 coex_sta
->high_priority_rx
== 0 &&
171 coex_sta
->low_priority_tx
== 0 &&
172 coex_sta
->low_priority_rx
== 0)
175 if (coex_sta
->high_priority_tx
== 0xffff &&
176 coex_sta
->high_priority_rx
== 0xffff &&
177 coex_sta
->low_priority_tx
== 0xffff &&
178 coex_sta
->low_priority_rx
== 0xffff)
184 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_DISABLE
,
186 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
187 "[BTCoex], BT is enabled !!\n");
190 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
191 "[BTCoex], bt all counters = 0, %d times!!\n",
193 if (bt_disable_cnt
>= 2) {
195 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_DISABLE
,
197 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
198 "[BTCoex], BT is disabled !!\n");
201 if (pre_bt_disabled
!= bt_disabled
) {
202 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
203 "[BTCoex], BT is from %s to %s!!\n",
204 (pre_bt_disabled
? "disabled" : "enabled"),
205 (bt_disabled
? "disabled" : "enabled"));
206 pre_bt_disabled
= bt_disabled
;
210 static u32
btc8192e2ant_decide_ra_mask(struct btc_coexist
*btcoexist
,
211 u8 ss_type
, u32 ra_mask_type
)
213 u32 dis_ra_mask
= 0x0;
215 switch (ra_mask_type
) {
216 case 0: /* normal mode */
218 dis_ra_mask
= 0x0; /* enable 2ss */
220 dis_ra_mask
= 0xfff00000; /* disable 2ss */
222 case 1: /* disable cck 1/2 */
224 dis_ra_mask
= 0x00000003; /* enable 2ss */
226 dis_ra_mask
= 0xfff00003; /* disable 2ss */
228 case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */
230 dis_ra_mask
= 0x0001f1f7; /* enable 2ss */
232 dis_ra_mask
= 0xfff1f1f7; /* disable 2ss */
241 static void btc8192e2ant_update_ra_mask(struct btc_coexist
*btcoexist
,
242 bool force_exec
, u32 dis_rate_mask
)
244 coex_dm
->cur_ra_mask
= dis_rate_mask
;
246 if (force_exec
|| (coex_dm
->pre_ra_mask
!= coex_dm
->cur_ra_mask
))
247 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_UPDATE_RAMASK
,
248 &coex_dm
->cur_ra_mask
);
249 coex_dm
->pre_ra_mask
= coex_dm
->cur_ra_mask
;
252 static void btc8192e2ant_auto_rate_fallback_retry(struct btc_coexist
*btcoexist
,
253 bool force_exec
, u8 type
)
255 bool wifi_under_b_mode
= false;
257 coex_dm
->cur_arfr_type
= type
;
259 if (force_exec
|| (coex_dm
->pre_arfr_type
!= coex_dm
->cur_arfr_type
)) {
260 switch (coex_dm
->cur_arfr_type
) {
261 case 0: /* normal mode */
262 btcoexist
->btc_write_4byte(btcoexist
, 0x430,
263 coex_dm
->backup_arfr_cnt1
);
264 btcoexist
->btc_write_4byte(btcoexist
, 0x434,
265 coex_dm
->backup_arfr_cnt2
);
268 btcoexist
->btc_get(btcoexist
,
269 BTC_GET_BL_WIFI_UNDER_B_MODE
,
271 if (wifi_under_b_mode
) {
272 btcoexist
->btc_write_4byte(btcoexist
, 0x430,
274 btcoexist
->btc_write_4byte(btcoexist
, 0x434,
277 btcoexist
->btc_write_4byte(btcoexist
, 0x430,
279 btcoexist
->btc_write_4byte(btcoexist
, 0x434,
288 coex_dm
->pre_arfr_type
= coex_dm
->cur_arfr_type
;
291 static void btc8192e2ant_retry_limit(struct btc_coexist
*btcoexist
,
292 bool force_exec
, u8 type
)
294 coex_dm
->cur_retry_limit_type
= type
;
296 if (force_exec
|| (coex_dm
->pre_retry_limit_type
!=
297 coex_dm
->cur_retry_limit_type
)) {
298 switch (coex_dm
->cur_retry_limit_type
) {
299 case 0: /* normal mode */
300 btcoexist
->btc_write_2byte(btcoexist
, 0x42a,
301 coex_dm
->backup_retry_limit
);
303 case 1: /* retry limit = 8 */
304 btcoexist
->btc_write_2byte(btcoexist
, 0x42a, 0x0808);
311 coex_dm
->pre_retry_limit_type
= coex_dm
->cur_retry_limit_type
;
314 static void btc8192e2ant_ampdu_maxtime(struct btc_coexist
*btcoexist
,
315 bool force_exec
, u8 type
)
317 coex_dm
->cur_ampdu_time_type
= type
;
319 if (force_exec
|| (coex_dm
->pre_ampdu_time_type
!=
320 coex_dm
->cur_ampdu_time_type
)) {
321 switch (coex_dm
->cur_ampdu_time_type
) {
322 case 0: /* normal mode */
323 btcoexist
->btc_write_1byte(btcoexist
, 0x456,
324 coex_dm
->backup_ampdu_maxtime
);
326 case 1: /* AMPDU time = 0x38 * 32us */
327 btcoexist
->btc_write_1byte(btcoexist
, 0x456, 0x38);
334 coex_dm
->pre_ampdu_time_type
= coex_dm
->cur_ampdu_time_type
;
337 static void btc8192e2ant_limited_tx(struct btc_coexist
*btcoexist
,
338 bool force_exec
, u8 ra_mask_type
,
339 u8 arfr_type
, u8 retry_limit_type
,
342 u32 dis_ra_mask
= 0x0;
344 coex_dm
->cur_ra_mask_type
= ra_mask_type
;
346 btc8192e2ant_decide_ra_mask(btcoexist
, coex_dm
->cur_ss_type
,
348 btc8192e2ant_update_ra_mask(btcoexist
, force_exec
, dis_ra_mask
);
349 btc8192e2ant_auto_rate_fallback_retry(btcoexist
, force_exec
, arfr_type
);
350 btc8192e2ant_retry_limit(btcoexist
, force_exec
, retry_limit_type
);
351 btc8192e2ant_ampdu_maxtime(btcoexist
, force_exec
, ampdu_time_type
);
354 static void btc8192e2ant_limited_rx(struct btc_coexist
*btcoexist
,
355 bool force_exec
, bool rej_ap_agg_pkt
,
356 bool bt_ctrl_agg_buf_size
,
359 bool reject_rx_agg
= rej_ap_agg_pkt
;
360 bool bt_ctrl_rx_agg_size
= bt_ctrl_agg_buf_size
;
361 u8 rx_agg_size
= agg_buf_size
;
363 /*********************************************
364 * Rx Aggregation related setting
365 *********************************************/
366 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_TO_REJ_AP_AGG_PKT
,
368 /* decide BT control aggregation buf size or not */
369 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_CTRL_AGG_SIZE
,
370 &bt_ctrl_rx_agg_size
);
371 /* aggregation buf size, only work
372 * when BT control Rx aggregation size.
374 btcoexist
->btc_set(btcoexist
, BTC_SET_U1_AGG_BUF_SIZE
, &rx_agg_size
);
375 /* real update aggregation setting */
376 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_AGGREGATE_CTRL
, NULL
);
379 static void btc8192e2ant_monitor_bt_ctr(struct btc_coexist
*btcoexist
)
381 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
382 u32 reg_hp_txrx
, reg_lp_txrx
, u32tmp
;
383 u32 reg_hp_tx
= 0, reg_hp_rx
= 0, reg_lp_tx
= 0, reg_lp_rx
= 0;
388 u32tmp
= btcoexist
->btc_read_4byte(btcoexist
, reg_hp_txrx
);
389 reg_hp_tx
= u32tmp
& MASKLWORD
;
390 reg_hp_rx
= (u32tmp
& MASKHWORD
) >> 16;
392 u32tmp
= btcoexist
->btc_read_4byte(btcoexist
, reg_lp_txrx
);
393 reg_lp_tx
= u32tmp
& MASKLWORD
;
394 reg_lp_rx
= (u32tmp
& MASKHWORD
) >> 16;
396 coex_sta
->high_priority_tx
= reg_hp_tx
;
397 coex_sta
->high_priority_rx
= reg_hp_rx
;
398 coex_sta
->low_priority_tx
= reg_lp_tx
;
399 coex_sta
->low_priority_rx
= reg_lp_rx
;
401 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
402 "[BTCoex] High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
403 reg_hp_txrx
, reg_hp_tx
, reg_hp_tx
, reg_hp_rx
, reg_hp_rx
);
404 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
405 "[BTCoex] Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
406 reg_lp_txrx
, reg_lp_tx
, reg_lp_tx
, reg_lp_rx
, reg_lp_rx
);
409 btcoexist
->btc_write_1byte(btcoexist
, 0x76e, 0xc);
412 static void btc8192e2ant_query_bt_info(struct btc_coexist
*btcoexist
)
414 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
415 u8 h2c_parameter
[1] = {0};
417 coex_sta
->c2h_bt_info_req_sent
= true;
419 h2c_parameter
[0] |= BIT0
; /* trigger */
421 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
422 "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n",
425 btcoexist
->btc_fill_h2c(btcoexist
, 0x61, 1, h2c_parameter
);
429 bool btc8192e2ant_is_wifi_status_changed(struct btc_coexist
*btcoexist
)
431 static bool pre_wifi_busy
= false, pre_under_4way
= false,
432 pre_bt_hs_on
= false;
433 bool wifi_busy
= false, under_4way
= false, bt_hs_on
= false;
434 bool wifi_connected
= false;
436 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
438 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
439 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
440 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_4_WAY_PROGRESS
,
443 if (wifi_connected
) {
444 if (wifi_busy
!= pre_wifi_busy
) {
445 pre_wifi_busy
= wifi_busy
;
448 if (under_4way
!= pre_under_4way
) {
449 pre_under_4way
= under_4way
;
452 if (bt_hs_on
!= pre_bt_hs_on
) {
453 pre_bt_hs_on
= bt_hs_on
;
461 static void btc8192e2ant_update_bt_link_info(struct btc_coexist
*btcoexist
)
463 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
464 bool bt_hs_on
= false;
466 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
468 bt_link_info
->bt_link_exist
= coex_sta
->bt_link_exist
;
469 bt_link_info
->sco_exist
= coex_sta
->sco_exist
;
470 bt_link_info
->a2dp_exist
= coex_sta
->a2dp_exist
;
471 bt_link_info
->pan_exist
= coex_sta
->pan_exist
;
472 bt_link_info
->hid_exist
= coex_sta
->hid_exist
;
474 /* work around for HS mode. */
476 bt_link_info
->pan_exist
= true;
477 bt_link_info
->bt_link_exist
= true;
480 /* check if Sco only */
481 if (bt_link_info
->sco_exist
&&
482 !bt_link_info
->a2dp_exist
&&
483 !bt_link_info
->pan_exist
&&
484 !bt_link_info
->hid_exist
)
485 bt_link_info
->sco_only
= true;
487 bt_link_info
->sco_only
= false;
489 /* check if A2dp only */
490 if (!bt_link_info
->sco_exist
&&
491 bt_link_info
->a2dp_exist
&&
492 !bt_link_info
->pan_exist
&&
493 !bt_link_info
->hid_exist
)
494 bt_link_info
->a2dp_only
= true;
496 bt_link_info
->a2dp_only
= false;
498 /* check if Pan only */
499 if (!bt_link_info
->sco_exist
&&
500 !bt_link_info
->a2dp_exist
&&
501 bt_link_info
->pan_exist
&&
502 !bt_link_info
->hid_exist
)
503 bt_link_info
->pan_only
= true;
505 bt_link_info
->pan_only
= false;
507 /* check if Hid only */
508 if (!bt_link_info
->sco_exist
&&
509 !bt_link_info
->a2dp_exist
&&
510 !bt_link_info
->pan_exist
&&
511 bt_link_info
->hid_exist
)
512 bt_link_info
->hid_only
= true;
514 bt_link_info
->hid_only
= false;
517 static u8
btc8192e2ant_action_algorithm(struct btc_coexist
*btcoexist
)
519 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
520 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
521 struct btc_stack_info
*stack_info
= &btcoexist
->stack_info
;
522 bool bt_hs_on
= false;
523 u8 algorithm
= BT_8192E_2ANT_COEX_ALGO_UNDEFINED
;
524 u8 num_of_diff_profile
= 0;
526 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
528 if (!bt_link_info
->bt_link_exist
) {
529 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
530 "No BT link exists!!!\n");
534 if (bt_link_info
->sco_exist
)
535 num_of_diff_profile
++;
536 if (bt_link_info
->hid_exist
)
537 num_of_diff_profile
++;
538 if (bt_link_info
->pan_exist
)
539 num_of_diff_profile
++;
540 if (bt_link_info
->a2dp_exist
)
541 num_of_diff_profile
++;
543 if (num_of_diff_profile
== 1) {
544 if (bt_link_info
->sco_exist
) {
545 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
547 algorithm
= BT_8192E_2ANT_COEX_ALGO_SCO
;
549 if (bt_link_info
->hid_exist
) {
550 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
552 algorithm
= BT_8192E_2ANT_COEX_ALGO_HID
;
553 } else if (bt_link_info
->a2dp_exist
) {
554 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
556 algorithm
= BT_8192E_2ANT_COEX_ALGO_A2DP
;
557 } else if (bt_link_info
->pan_exist
) {
559 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
563 BT_8192E_2ANT_COEX_ALGO_PANHS
;
565 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
569 BT_8192E_2ANT_COEX_ALGO_PANEDR
;
573 } else if (num_of_diff_profile
== 2) {
574 if (bt_link_info
->sco_exist
) {
575 if (bt_link_info
->hid_exist
) {
576 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
578 algorithm
= BT_8192E_2ANT_COEX_ALGO_SCO
;
579 } else if (bt_link_info
->a2dp_exist
) {
580 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
581 "SCO + A2DP ==> SCO\n");
582 algorithm
= BT_8192E_2ANT_COEX_ALGO_PANEDR_HID
;
583 } else if (bt_link_info
->pan_exist
) {
585 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
588 algorithm
= BT_8192E_2ANT_COEX_ALGO_SCO
;
590 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
594 BT_8192E_2ANT_COEX_ALGO_SCO_PAN
;
598 if (bt_link_info
->hid_exist
&&
599 bt_link_info
->a2dp_exist
) {
600 if (stack_info
->num_of_hid
>= 2) {
601 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
605 BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR
;
607 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
611 BT_8192E_2ANT_COEX_ALGO_HID_A2DP
;
613 } else if (bt_link_info
->hid_exist
&&
614 bt_link_info
->pan_exist
) {
616 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
619 algorithm
= BT_8192E_2ANT_COEX_ALGO_HID
;
621 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
625 BT_8192E_2ANT_COEX_ALGO_PANEDR_HID
;
627 } else if (bt_link_info
->pan_exist
&&
628 bt_link_info
->a2dp_exist
) {
630 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
634 BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS
;
636 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
638 "A2DP + PAN(EDR)\n");
640 BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP
;
644 } else if (num_of_diff_profile
== 3) {
645 if (bt_link_info
->sco_exist
) {
646 if (bt_link_info
->hid_exist
&&
647 bt_link_info
->a2dp_exist
) {
648 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
649 "SCO + HID + A2DP ==> HID\n");
650 algorithm
= BT_8192E_2ANT_COEX_ALGO_PANEDR_HID
;
651 } else if (bt_link_info
->hid_exist
&&
652 bt_link_info
->pan_exist
) {
654 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
656 "SCO + HID + PAN(HS)\n");
657 algorithm
= BT_8192E_2ANT_COEX_ALGO_SCO
;
659 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
661 "SCO + HID + PAN(EDR)\n");
663 BT_8192E_2ANT_COEX_ALGO_SCO_PAN
;
665 } else if (bt_link_info
->pan_exist
&&
666 bt_link_info
->a2dp_exist
) {
668 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
670 "SCO + A2DP + PAN(HS)\n");
671 algorithm
= BT_8192E_2ANT_COEX_ALGO_SCO
;
673 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
675 "SCO + A2DP + PAN(EDR)\n");
677 BT_8192E_2ANT_COEX_ALGO_PANEDR_HID
;
681 if (bt_link_info
->hid_exist
&&
682 bt_link_info
->pan_exist
&&
683 bt_link_info
->a2dp_exist
) {
685 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
687 "HID + A2DP + PAN(HS)\n");
689 BT_8192E_2ANT_COEX_ALGO_HID_A2DP
;
691 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
693 "HID + A2DP + PAN(EDR)\n");
695 BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR
;
699 } else if (num_of_diff_profile
>= 3) {
700 if (bt_link_info
->sco_exist
) {
701 if (bt_link_info
->hid_exist
&&
702 bt_link_info
->pan_exist
&&
703 bt_link_info
->a2dp_exist
) {
705 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
707 "ErrorSCO+HID+A2DP+PAN(HS)\n");
710 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
712 "SCO+HID+A2DP+PAN(EDR)\n");
714 BT_8192E_2ANT_COEX_ALGO_PANEDR_HID
;
723 static void btc8192e2ant_set_fw_dac_swing_level(struct btc_coexist
*btcoexist
,
726 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
727 u8 h2c_parameter
[1] = {0};
729 /* There are several type of dacswing
730 * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
732 h2c_parameter
[0] = dac_swing_lvl
;
734 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
735 "[BTCoex], Set Dac Swing Level = 0x%x\n", dac_swing_lvl
);
736 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
737 "[BTCoex], FW write 0x64 = 0x%x\n", h2c_parameter
[0]);
739 btcoexist
->btc_fill_h2c(btcoexist
, 0x64, 1, h2c_parameter
);
742 static void btc8192e2ant_set_fw_dec_bt_pwr(struct btc_coexist
*btcoexist
,
745 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
746 u8 h2c_parameter
[1] = {0};
748 h2c_parameter
[0] = dec_bt_pwr_lvl
;
750 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
751 "[BTCoex] decrease Bt Power level = %d, FW write 0x62 = 0x%x\n",
752 dec_bt_pwr_lvl
, h2c_parameter
[0]);
754 btcoexist
->btc_fill_h2c(btcoexist
, 0x62, 1, h2c_parameter
);
757 static void btc8192e2ant_dec_bt_pwr(struct btc_coexist
*btcoexist
,
758 bool force_exec
, u8 dec_bt_pwr_lvl
)
760 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
762 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
763 "[BTCoex], %s Dec BT power level = %d\n",
764 force_exec
? "force to" : "", dec_bt_pwr_lvl
);
765 coex_dm
->cur_dec_bt_pwr
= dec_bt_pwr_lvl
;
768 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
769 "[BTCoex], preBtDecPwrLvl=%d, curBtDecPwrLvl=%d\n",
770 coex_dm
->pre_dec_bt_pwr
, coex_dm
->cur_dec_bt_pwr
);
772 btc8192e2ant_set_fw_dec_bt_pwr(btcoexist
, coex_dm
->cur_dec_bt_pwr
);
774 coex_dm
->pre_dec_bt_pwr
= coex_dm
->cur_dec_bt_pwr
;
777 static void btc8192e2ant_set_bt_auto_report(struct btc_coexist
*btcoexist
,
778 bool enable_auto_report
)
780 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
781 u8 h2c_parameter
[1] = {0};
783 h2c_parameter
[0] = 0;
785 if (enable_auto_report
)
786 h2c_parameter
[0] |= BIT0
;
788 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
789 "[BTCoex], BT FW auto report : %s, FW write 0x68 = 0x%x\n",
790 (enable_auto_report
? "Enabled!!" : "Disabled!!"),
793 btcoexist
->btc_fill_h2c(btcoexist
, 0x68, 1, h2c_parameter
);
796 static void btc8192e2ant_bt_auto_report(struct btc_coexist
*btcoexist
,
798 bool enable_auto_report
)
800 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
802 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
803 "[BTCoex], %s BT Auto report = %s\n",
804 (force_exec
? "force to" : ""),
805 ((enable_auto_report
) ? "Enabled" : "Disabled"));
806 coex_dm
->cur_bt_auto_report
= enable_auto_report
;
809 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
810 "[BTCoex] bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
811 coex_dm
->pre_bt_auto_report
,
812 coex_dm
->cur_bt_auto_report
);
814 if (coex_dm
->pre_bt_auto_report
== coex_dm
->cur_bt_auto_report
)
817 btc8192e2ant_set_bt_auto_report(btcoexist
,
818 coex_dm
->cur_bt_auto_report
);
820 coex_dm
->pre_bt_auto_report
= coex_dm
->cur_bt_auto_report
;
823 static void btc8192e2ant_fw_dac_swing_lvl(struct btc_coexist
*btcoexist
,
824 bool force_exec
, u8 fw_dac_swing_lvl
)
826 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
828 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
829 "[BTCoex], %s set FW Dac Swing level = %d\n",
830 (force_exec
? "force to" : ""), fw_dac_swing_lvl
);
831 coex_dm
->cur_fw_dac_swing_lvl
= fw_dac_swing_lvl
;
834 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
835 "[BTCoex] preFwDacSwingLvl=%d, curFwDacSwingLvl=%d\n",
836 coex_dm
->pre_fw_dac_swing_lvl
,
837 coex_dm
->cur_fw_dac_swing_lvl
);
839 if (coex_dm
->pre_fw_dac_swing_lvl
==
840 coex_dm
->cur_fw_dac_swing_lvl
)
844 btc8192e2ant_set_fw_dac_swing_level(btcoexist
,
845 coex_dm
->cur_fw_dac_swing_lvl
);
847 coex_dm
->pre_fw_dac_swing_lvl
= coex_dm
->cur_fw_dac_swing_lvl
;
850 static void btc8192e2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist
*btcoexist
,
851 bool rx_rf_shrink_on
)
853 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
855 if (rx_rf_shrink_on
) {
856 /* Shrink RF Rx LPF corner */
857 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
858 "[BTCoex], Shrink RF Rx LPF corner!!\n");
859 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1e,
862 /* Resume RF Rx LPF corner
863 * After initialized, we can use coex_dm->btRf0x1eBackup
865 if (btcoexist
->initialized
) {
866 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
867 "[BTCoex], Resume RF Rx LPF corner!!\n");
868 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1e,
870 coex_dm
->bt_rf0x1e_backup
);
875 static void btc8192e2ant_rf_shrink(struct btc_coexist
*btcoexist
,
876 bool force_exec
, bool rx_rf_shrink_on
)
878 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
880 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
881 "[BTCoex], %s turn Rx RF Shrink = %s\n",
882 (force_exec
? "force to" : ""),
883 ((rx_rf_shrink_on
) ? "ON" : "OFF"));
884 coex_dm
->cur_rf_rx_lpf_shrink
= rx_rf_shrink_on
;
887 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
888 "[BTCoex]bPreRfRxLpfShrink=%d,bCurRfRxLpfShrink=%d\n",
889 coex_dm
->pre_rf_rx_lpf_shrink
,
890 coex_dm
->cur_rf_rx_lpf_shrink
);
892 if (coex_dm
->pre_rf_rx_lpf_shrink
==
893 coex_dm
->cur_rf_rx_lpf_shrink
)
896 btc8192e2ant_set_sw_rf_rx_lpf_corner(btcoexist
,
897 coex_dm
->cur_rf_rx_lpf_shrink
);
899 coex_dm
->pre_rf_rx_lpf_shrink
= coex_dm
->cur_rf_rx_lpf_shrink
;
902 static void btc8192e2ant_set_dac_swing_reg(struct btc_coexist
*btcoexist
,
905 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
908 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
909 "[BTCoex], Write SwDacSwing = 0x%x\n", level
);
910 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x883, 0x3e, val
);
913 static void btc8192e2ant_set_sw_full_swing(struct btc_coexist
*btcoexist
,
914 bool sw_dac_swing_on
,
915 u32 sw_dac_swing_lvl
)
918 btc8192e2ant_set_dac_swing_reg(btcoexist
, sw_dac_swing_lvl
);
920 btc8192e2ant_set_dac_swing_reg(btcoexist
, 0x18);
923 static void btc8192e2ant_dac_swing(struct btc_coexist
*btcoexist
,
924 bool force_exec
, bool dac_swing_on
,
927 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
929 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
930 "[BTCoex], %s turn DacSwing=%s, dac_swing_lvl = 0x%x\n",
931 (force_exec
? "force to" : ""),
932 ((dac_swing_on
) ? "ON" : "OFF"), dac_swing_lvl
);
933 coex_dm
->cur_dac_swing_on
= dac_swing_on
;
934 coex_dm
->cur_dac_swing_lvl
= dac_swing_lvl
;
937 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
938 "[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl = 0x%x, ",
939 coex_dm
->pre_dac_swing_on
,
940 coex_dm
->pre_dac_swing_lvl
);
941 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
942 "bCurDacSwingOn=%d, curDacSwingLvl = 0x%x\n",
943 coex_dm
->cur_dac_swing_on
,
944 coex_dm
->cur_dac_swing_lvl
);
946 if ((coex_dm
->pre_dac_swing_on
== coex_dm
->cur_dac_swing_on
) &&
947 (coex_dm
->pre_dac_swing_lvl
== coex_dm
->cur_dac_swing_lvl
))
951 btc8192e2ant_set_sw_full_swing(btcoexist
, dac_swing_on
, dac_swing_lvl
);
953 coex_dm
->pre_dac_swing_on
= coex_dm
->cur_dac_swing_on
;
954 coex_dm
->pre_dac_swing_lvl
= coex_dm
->cur_dac_swing_lvl
;
957 static void btc8192e2ant_set_agc_table(struct btc_coexist
*btcoexist
,
960 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
962 /* BB AGC Gain Table */
964 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
965 "[BTCoex], BB Agc Table On!\n");
966 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x0a1A0001);
967 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x091B0001);
968 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x081C0001);
969 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x071D0001);
970 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x061E0001);
971 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x051F0001);
973 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
974 "[BTCoex], BB Agc Table Off!\n");
975 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xaa1A0001);
976 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa91B0001);
977 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa81C0001);
978 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa71D0001);
979 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa61E0001);
980 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa51F0001);
984 static void btc8192e2ant_agc_table(struct btc_coexist
*btcoexist
,
985 bool force_exec
, bool agc_table_en
)
987 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
989 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
990 "[BTCoex], %s %s Agc Table\n",
991 (force_exec
? "force to" : ""),
992 ((agc_table_en
) ? "Enable" : "Disable"));
993 coex_dm
->cur_agc_table_en
= agc_table_en
;
996 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
997 "[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
998 coex_dm
->pre_agc_table_en
,
999 coex_dm
->cur_agc_table_en
);
1001 if (coex_dm
->pre_agc_table_en
== coex_dm
->cur_agc_table_en
)
1004 btc8192e2ant_set_agc_table(btcoexist
, agc_table_en
);
1006 coex_dm
->pre_agc_table_en
= coex_dm
->cur_agc_table_en
;
1009 static void btc8192e2ant_set_coex_table(struct btc_coexist
*btcoexist
,
1010 u32 val0x6c0
, u32 val0x6c4
,
1011 u32 val0x6c8
, u8 val0x6cc
)
1013 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1015 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1016 "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0
);
1017 btcoexist
->btc_write_4byte(btcoexist
, 0x6c0, val0x6c0
);
1019 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1020 "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4
);
1021 btcoexist
->btc_write_4byte(btcoexist
, 0x6c4, val0x6c4
);
1023 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1024 "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8
);
1025 btcoexist
->btc_write_4byte(btcoexist
, 0x6c8, val0x6c8
);
1027 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1028 "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc
);
1029 btcoexist
->btc_write_1byte(btcoexist
, 0x6cc, val0x6cc
);
1032 static void btc8192e2ant_coex_table(struct btc_coexist
*btcoexist
,
1033 bool force_exec
, u32 val0x6c0
, u32 val0x6c4
,
1034 u32 val0x6c8
, u8 val0x6cc
)
1036 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1038 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1039 "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, ",
1040 (force_exec
? "force to" : ""), val0x6c0
);
1041 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1042 "0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n",
1043 val0x6c4
, val0x6c8
, val0x6cc
);
1044 coex_dm
->cur_val0x6c0
= val0x6c0
;
1045 coex_dm
->cur_val0x6c4
= val0x6c4
;
1046 coex_dm
->cur_val0x6c8
= val0x6c8
;
1047 coex_dm
->cur_val0x6cc
= val0x6cc
;
1050 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1051 "[BTCoex], preVal0x6c0 = 0x%x, preVal0x6c4 = 0x%x, ",
1052 coex_dm
->pre_val0x6c0
, coex_dm
->pre_val0x6c4
);
1053 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1054 "preVal0x6c8 = 0x%x, preVal0x6cc = 0x%x !!\n",
1055 coex_dm
->pre_val0x6c8
, coex_dm
->pre_val0x6cc
);
1056 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1057 "[BTCoex], curVal0x6c0 = 0x%x, curVal0x6c4 = 0x%x\n",
1058 coex_dm
->cur_val0x6c0
, coex_dm
->cur_val0x6c4
);
1059 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1060 "curVal0x6c8 = 0x%x, curVal0x6cc = 0x%x !!\n",
1061 coex_dm
->cur_val0x6c8
, coex_dm
->cur_val0x6cc
);
1063 if ((coex_dm
->pre_val0x6c0
== coex_dm
->cur_val0x6c0
) &&
1064 (coex_dm
->pre_val0x6c4
== coex_dm
->cur_val0x6c4
) &&
1065 (coex_dm
->pre_val0x6c8
== coex_dm
->cur_val0x6c8
) &&
1066 (coex_dm
->pre_val0x6cc
== coex_dm
->cur_val0x6cc
))
1069 btc8192e2ant_set_coex_table(btcoexist
, val0x6c0
, val0x6c4
, val0x6c8
,
1072 coex_dm
->pre_val0x6c0
= coex_dm
->cur_val0x6c0
;
1073 coex_dm
->pre_val0x6c4
= coex_dm
->cur_val0x6c4
;
1074 coex_dm
->pre_val0x6c8
= coex_dm
->cur_val0x6c8
;
1075 coex_dm
->pre_val0x6cc
= coex_dm
->cur_val0x6cc
;
1078 static void btc8192e2ant_coex_table_with_type(struct btc_coexist
*btcoexist
,
1079 bool force_exec
, u8 type
)
1083 btc8192e2ant_coex_table(btcoexist
, force_exec
, 0x55555555,
1084 0x5a5a5a5a, 0xffffff, 0x3);
1087 btc8192e2ant_coex_table(btcoexist
, force_exec
, 0x5a5a5a5a,
1088 0x5a5a5a5a, 0xffffff, 0x3);
1091 btc8192e2ant_coex_table(btcoexist
, force_exec
, 0x55555555,
1092 0x5ffb5ffb, 0xffffff, 0x3);
1095 btc8192e2ant_coex_table(btcoexist
, force_exec
, 0xdfffdfff,
1096 0x5fdb5fdb, 0xffffff, 0x3);
1099 btc8192e2ant_coex_table(btcoexist
, force_exec
, 0xdfffdfff,
1100 0x5ffb5ffb, 0xffffff, 0x3);
1107 static void btc8192e2ant_set_fw_ignore_wlan_act(struct btc_coexist
*btcoexist
,
1110 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1111 u8 h2c_parameter
[1] = {0};
1114 h2c_parameter
[0] |= BIT0
; /* function enable */
1116 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1117 "[BTCoex]set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n",
1120 btcoexist
->btc_fill_h2c(btcoexist
, 0x63, 1, h2c_parameter
);
1123 static void btc8192e2ant_ignore_wlan_act(struct btc_coexist
*btcoexist
,
1124 bool force_exec
, bool enable
)
1126 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1128 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1129 "[BTCoex], %s turn Ignore WlanAct %s\n",
1130 (force_exec
? "force to" : ""), (enable
? "ON" : "OFF"));
1131 coex_dm
->cur_ignore_wlan_act
= enable
;
1134 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1135 "[BTCoex], bPreIgnoreWlanAct = %d ",
1136 coex_dm
->pre_ignore_wlan_act
);
1137 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1138 "bCurIgnoreWlanAct = %d!!\n",
1139 coex_dm
->cur_ignore_wlan_act
);
1141 if (coex_dm
->pre_ignore_wlan_act
==
1142 coex_dm
->cur_ignore_wlan_act
)
1145 btc8192e2ant_set_fw_ignore_wlan_act(btcoexist
, enable
);
1147 coex_dm
->pre_ignore_wlan_act
= coex_dm
->cur_ignore_wlan_act
;
1150 static void btc8192e2ant_set_fw_ps_tdma(struct btc_coexist
*btcoexist
, u8 byte1
,
1151 u8 byte2
, u8 byte3
, u8 byte4
, u8 byte5
)
1153 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1155 u8 h2c_parameter
[5] = {0};
1157 h2c_parameter
[0] = byte1
;
1158 h2c_parameter
[1] = byte2
;
1159 h2c_parameter
[2] = byte3
;
1160 h2c_parameter
[3] = byte4
;
1161 h2c_parameter
[4] = byte5
;
1163 coex_dm
->ps_tdma_para
[0] = byte1
;
1164 coex_dm
->ps_tdma_para
[1] = byte2
;
1165 coex_dm
->ps_tdma_para
[2] = byte3
;
1166 coex_dm
->ps_tdma_para
[3] = byte4
;
1167 coex_dm
->ps_tdma_para
[4] = byte5
;
1169 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1170 "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n",
1172 h2c_parameter
[1] << 24 | h2c_parameter
[2] << 16 |
1173 h2c_parameter
[3] << 8 | h2c_parameter
[4]);
1175 btcoexist
->btc_fill_h2c(btcoexist
, 0x60, 5, h2c_parameter
);
1178 static void btc8192e2ant_sw_mechanism1(struct btc_coexist
*btcoexist
,
1179 bool shrink_rx_lpf
, bool low_penalty_ra
,
1180 bool limited_dig
, bool btlan_constrain
)
1182 btc8192e2ant_rf_shrink(btcoexist
, NORMAL_EXEC
, shrink_rx_lpf
);
1185 static void btc8192e2ant_sw_mechanism2(struct btc_coexist
*btcoexist
,
1186 bool agc_table_shift
, bool adc_backoff
,
1187 bool sw_dac_swing
, u32 dac_swing_lvl
)
1189 btc8192e2ant_agc_table(btcoexist
, NORMAL_EXEC
, agc_table_shift
);
1190 btc8192e2ant_dac_swing(btcoexist
, NORMAL_EXEC
, sw_dac_swing
,
1194 static void btc8192e2ant_ps_tdma(struct btc_coexist
*btcoexist
,
1195 bool force_exec
, bool turn_on
, u8 type
)
1197 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1199 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1200 "[BTCoex], %s turn %s PS TDMA, type=%d\n",
1201 (force_exec
? "force to" : ""),
1202 (turn_on
? "ON" : "OFF"), type
);
1203 coex_dm
->cur_ps_tdma_on
= turn_on
;
1204 coex_dm
->cur_ps_tdma
= type
;
1207 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1208 "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
1209 coex_dm
->pre_ps_tdma_on
, coex_dm
->cur_ps_tdma_on
);
1210 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1211 "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
1212 coex_dm
->pre_ps_tdma
, coex_dm
->cur_ps_tdma
);
1214 if ((coex_dm
->pre_ps_tdma_on
== coex_dm
->cur_ps_tdma_on
) &&
1215 (coex_dm
->pre_ps_tdma
== coex_dm
->cur_ps_tdma
))
1222 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1226 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x12,
1230 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1c,
1234 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x10,
1238 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1242 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x12,
1246 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1c,
1250 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xa3, 0x10,
1254 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1258 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x12,
1262 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1c,
1266 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x10,
1270 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1274 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x12,
1278 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1c,
1282 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x12,
1286 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0x61, 0x20,
1290 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x5,
1294 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x25,
1298 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x25,
1302 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x15,
1306 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1311 /* disable PS tdma */
1315 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0x8, 0x0, 0x0,
1317 btcoexist
->btc_write_1byte(btcoexist
, 0x92c, 0x4);
1320 btc8192e2ant_set_fw_ps_tdma(btcoexist
, 0x0, 0x0, 0x0,
1323 btcoexist
->btc_write_1byte(btcoexist
, 0x92c, 0x20);
1328 /* update pre state */
1329 coex_dm
->pre_ps_tdma_on
= coex_dm
->cur_ps_tdma_on
;
1330 coex_dm
->pre_ps_tdma
= coex_dm
->cur_ps_tdma
;
1333 static void btc8192e2ant_set_switch_ss_type(struct btc_coexist
*btcoexist
,
1336 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1337 u8 mimops
= BTC_MIMO_PS_DYNAMIC
;
1338 u32 dis_ra_mask
= 0x0;
1340 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1341 "[BTCoex], REAL set SS Type = %d\n", ss_type
);
1343 dis_ra_mask
= btc8192e2ant_decide_ra_mask(btcoexist
, ss_type
,
1344 coex_dm
->cur_ra_mask_type
);
1345 btc8192e2ant_update_ra_mask(btcoexist
, FORCE_EXEC
, dis_ra_mask
);
1348 btc8192e2ant_ps_tdma(btcoexist
, FORCE_EXEC
, false, 1);
1349 /* switch ofdm path */
1350 btcoexist
->btc_write_1byte(btcoexist
, 0xc04, 0x11);
1351 btcoexist
->btc_write_1byte(btcoexist
, 0xd04, 0x1);
1352 btcoexist
->btc_write_4byte(btcoexist
, 0x90c, 0x81111111);
1353 /* switch cck patch */
1354 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0xe77, 0x4, 0x1);
1355 btcoexist
->btc_write_1byte(btcoexist
, 0xa07, 0x81);
1356 mimops
= BTC_MIMO_PS_STATIC
;
1357 } else if (ss_type
== 2) {
1358 btc8192e2ant_ps_tdma(btcoexist
, FORCE_EXEC
, false, 0);
1359 btcoexist
->btc_write_1byte(btcoexist
, 0xc04, 0x33);
1360 btcoexist
->btc_write_1byte(btcoexist
, 0xd04, 0x3);
1361 btcoexist
->btc_write_4byte(btcoexist
, 0x90c, 0x81121313);
1362 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0xe77, 0x4, 0x0);
1363 btcoexist
->btc_write_1byte(btcoexist
, 0xa07, 0x41);
1364 mimops
= BTC_MIMO_PS_DYNAMIC
;
1366 /* set rx 1ss or 2ss */
1367 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_SEND_MIMO_PS
, &mimops
);
1370 static void btc8192e2ant_switch_ss_type(struct btc_coexist
*btcoexist
,
1371 bool force_exec
, u8 new_ss_type
)
1373 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1375 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1376 "[BTCoex], %s Switch SS Type = %d\n",
1377 (force_exec
? "force to" : ""), new_ss_type
);
1378 coex_dm
->cur_ss_type
= new_ss_type
;
1381 if (coex_dm
->pre_ss_type
== coex_dm
->cur_ss_type
)
1384 btc8192e2ant_set_switch_ss_type(btcoexist
, coex_dm
->cur_ss_type
);
1386 coex_dm
->pre_ss_type
= coex_dm
->cur_ss_type
;
1389 static void btc8192e2ant_coex_all_off(struct btc_coexist
*btcoexist
)
1392 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1393 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1394 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1397 btc8192e2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1398 btc8192e2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1401 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
1404 static void btc8192e2ant_init_coex_dm(struct btc_coexist
*btcoexist
)
1406 /* force to reset coex mechanism */
1408 btc8192e2ant_ps_tdma(btcoexist
, FORCE_EXEC
, false, 1);
1409 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, FORCE_EXEC
, 6);
1410 btc8192e2ant_dec_bt_pwr(btcoexist
, FORCE_EXEC
, 0);
1412 btc8192e2ant_coex_table_with_type(btcoexist
, FORCE_EXEC
, 0);
1413 btc8192e2ant_switch_ss_type(btcoexist
, FORCE_EXEC
, 2);
1415 btc8192e2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1416 btc8192e2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1419 static void btc8192e2ant_action_bt_inquiry(struct btc_coexist
*btcoexist
)
1421 bool low_pwr_disable
= true;
1423 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_DISABLE_LOW_POWER
,
1426 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
1428 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 2);
1429 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 3);
1430 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1431 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1433 btc8192e2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1434 btc8192e2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1437 static bool btc8192e2ant_is_common_action(struct btc_coexist
*btcoexist
)
1439 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1440 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
1441 bool common
= false, wifi_connected
= false, wifi_busy
= false;
1442 bool bt_hs_on
= false, low_pwr_disable
= false;
1444 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
1445 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
1447 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
1449 if (bt_link_info
->sco_exist
|| bt_link_info
->hid_exist
)
1450 btc8192e2ant_limited_tx(btcoexist
, NORMAL_EXEC
, 1, 0, 0, 0);
1452 btc8192e2ant_limited_tx(btcoexist
, NORMAL_EXEC
, 0, 0, 0, 0);
1454 if (!wifi_connected
) {
1455 low_pwr_disable
= false;
1456 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_DISABLE_LOW_POWER
,
1459 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1460 "[BTCoex], Wifi non-connected idle!!\n");
1462 if ((BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE
==
1463 coex_dm
->bt_status
) ||
1464 (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE
==
1465 coex_dm
->bt_status
)) {
1466 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 2);
1467 btc8192e2ant_coex_table_with_type(btcoexist
,
1469 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 0);
1471 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
1472 btc8192e2ant_coex_table_with_type(btcoexist
,
1474 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1477 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1478 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1480 btc8192e2ant_sw_mechanism1(btcoexist
, false, false, false,
1482 btc8192e2ant_sw_mechanism2(btcoexist
, false, false, false,
1487 if (BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE
==
1488 coex_dm
->bt_status
) {
1489 low_pwr_disable
= false;
1490 btcoexist
->btc_set(btcoexist
,
1491 BTC_SET_ACT_DISABLE_LOW_POWER
,
1494 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1495 "Wifi connected + BT non connected-idle!!\n");
1497 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 2);
1498 btc8192e2ant_coex_table_with_type(btcoexist
,
1500 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 0);
1501 btc8192e2ant_fw_dac_swing_lvl(btcoexist
,
1503 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1505 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
1507 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
1511 } else if (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE
==
1512 coex_dm
->bt_status
) {
1513 low_pwr_disable
= true;
1514 btcoexist
->btc_set(btcoexist
,
1515 BTC_SET_ACT_DISABLE_LOW_POWER
,
1520 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1521 "Wifi connected + BT connected-idle!!\n");
1523 btc8192e2ant_switch_ss_type(btcoexist
,
1525 btc8192e2ant_coex_table_with_type(btcoexist
,
1527 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1529 btc8192e2ant_fw_dac_swing_lvl(btcoexist
,
1531 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1533 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
1535 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
1540 low_pwr_disable
= true;
1541 btcoexist
->btc_set(btcoexist
,
1542 BTC_SET_ACT_DISABLE_LOW_POWER
,
1546 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1547 "Wifi Connected-Busy + BT Busy!!\n");
1550 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1551 "Wifi Connected-Idle + BT Busy!!\n");
1553 btc8192e2ant_switch_ss_type(btcoexist
,
1555 btc8192e2ant_coex_table_with_type(btcoexist
,
1558 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1560 btc8192e2ant_fw_dac_swing_lvl(btcoexist
,
1562 btc8192e2ant_dec_bt_pwr(btcoexist
,
1564 btc8192e2ant_sw_mechanism1(btcoexist
, false,
1565 false, false, false);
1566 btc8192e2ant_sw_mechanism2(btcoexist
, false,
1567 false, false, 0x18);
1575 static void btc8192e2ant_tdma_duration_adjust(struct btc_coexist
*btcoexist
,
1576 bool sco_hid
, bool tx_pause
,
1579 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1580 static int up
, dn
, m
, n
, wait_cnt
;
1583 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1584 "[BTCoex], TdmaDurationAdjust()\n");
1586 if (!coex_dm
->auto_tdma_adjust
) {
1587 coex_dm
->auto_tdma_adjust
= true;
1588 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1589 "[BTCoex], first run TdmaDurationAdjust()!!\n");
1592 if (max_interval
== 1) {
1593 btc8192e2ant_ps_tdma(btcoexist
,
1596 coex_dm
->tdma_adj_type
= 13;
1597 } else if (max_interval
== 2) {
1598 btc8192e2ant_ps_tdma(btcoexist
,
1601 coex_dm
->tdma_adj_type
= 14;
1603 btc8192e2ant_ps_tdma(btcoexist
,
1606 coex_dm
->tdma_adj_type
= 15;
1609 if (max_interval
== 1) {
1610 btc8192e2ant_ps_tdma(btcoexist
,
1613 coex_dm
->tdma_adj_type
= 9;
1614 } else if (max_interval
== 2) {
1615 btc8192e2ant_ps_tdma(btcoexist
,
1618 coex_dm
->tdma_adj_type
= 10;
1620 btc8192e2ant_ps_tdma(btcoexist
,
1623 coex_dm
->tdma_adj_type
= 11;
1628 if (max_interval
== 1) {
1629 btc8192e2ant_ps_tdma(btcoexist
,
1632 coex_dm
->tdma_adj_type
= 5;
1633 } else if (max_interval
== 2) {
1634 btc8192e2ant_ps_tdma(btcoexist
,
1637 coex_dm
->tdma_adj_type
= 6;
1639 btc8192e2ant_ps_tdma(btcoexist
,
1642 coex_dm
->tdma_adj_type
= 7;
1645 if (max_interval
== 1) {
1646 btc8192e2ant_ps_tdma(btcoexist
,
1649 coex_dm
->tdma_adj_type
= 1;
1650 } else if (max_interval
== 2) {
1651 btc8192e2ant_ps_tdma(btcoexist
,
1654 coex_dm
->tdma_adj_type
= 2;
1656 btc8192e2ant_ps_tdma(btcoexist
,
1659 coex_dm
->tdma_adj_type
= 3;
1670 /* accquire the BT TRx retry count from BT_Info byte2 */
1671 retry_cnt
= coex_sta
->bt_retry_cnt
;
1672 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1673 "[BTCoex], retry_cnt = %d\n", retry_cnt
);
1674 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1675 "[BTCoex], up=%d, dn=%d, m=%d, n=%d, wait_cnt=%d\n",
1676 up
, dn
, m
, n
, wait_cnt
);
1678 /* no retry in the last 2-second duration */
1679 if (retry_cnt
== 0) {
1691 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1692 "[BTCoex]Increase wifi duration!!\n");
1694 } else if (retry_cnt
<= 3) {
1714 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1715 "Reduce wifi duration for retry<3\n");
1730 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1731 "Decrease wifi duration for retryCounter>3!!\n");
1734 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1735 "[BTCoex], max Interval = %d\n", max_interval
);
1738 /* if current PsTdma not match with
1739 * the recorded one (when scan, dhcp...),
1740 * then we have to adjust it back to the previous record one.
1742 if (coex_dm
->cur_ps_tdma
!= coex_dm
->tdma_adj_type
) {
1743 bool scan
= false, link
= false, roam
= false;
1745 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1746 "[BTCoex], PsTdma type mismatch!!!, ");
1747 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1748 "curPsTdma=%d, recordPsTdma=%d\n",
1749 coex_dm
->cur_ps_tdma
, coex_dm
->tdma_adj_type
);
1751 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_SCAN
, &scan
);
1752 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_LINK
, &link
);
1753 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_ROAM
, &roam
);
1755 if (!scan
&& !link
&& !roam
)
1756 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1757 true, coex_dm
->tdma_adj_type
);
1759 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1760 "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n");
1764 /* SCO only or SCO+PAN(HS) */
1765 static void btc8192e2ant_action_sco(struct btc_coexist
*btcoexist
)
1767 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
1770 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
1772 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
1773 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
1775 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1777 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 4);
1779 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
1781 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
1782 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
1783 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1784 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 13);
1785 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
1786 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
1787 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
1788 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 9);
1789 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
1790 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
1791 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
1792 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 9);
1795 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
1798 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
1799 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
1800 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
1801 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
1803 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
1806 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
1808 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
1812 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
1813 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
1814 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
1816 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
1819 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
1821 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
1827 static void btc8192e2ant_action_sco_pan(struct btc_coexist
*btcoexist
)
1829 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
1832 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
1834 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
1835 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
1837 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1839 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 4);
1841 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
1843 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
1844 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
1845 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1846 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 14);
1847 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
1848 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
1849 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
1850 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 10);
1851 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
1852 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
1853 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
1854 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 10);
1857 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
1860 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
1861 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
1862 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
1863 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
1865 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
1868 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
1870 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
1874 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
1875 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
1876 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
1878 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
1881 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
1883 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
1889 static void btc8192e2ant_action_hid(struct btc_coexist
*btcoexist
)
1891 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
1894 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
1895 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
1897 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
1898 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
1900 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1902 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
1904 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 3);
1906 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
1907 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
1908 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1909 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 13);
1910 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
1911 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
1912 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
1913 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 9);
1914 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
1915 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
1916 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
1917 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 9);
1921 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
1922 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
1923 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
1924 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
1926 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
1929 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
1931 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
1935 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
1936 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
1937 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
1939 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
1942 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
1944 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
1950 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
1951 static void btc8192e2ant_action_a2dp(struct btc_coexist
*btcoexist
)
1953 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1954 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
1956 bool long_dist
= false;
1958 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
1959 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
1961 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
||
1962 bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
) &&
1963 (wifi_rssi_state
== BTC_RSSI_STATE_LOW
||
1964 wifi_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
1965 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1966 "[BTCoex], A2dp, wifi/bt rssi both LOW!!\n");
1970 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 2);
1971 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, true,
1974 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
1975 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false,
1979 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1982 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
1984 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 2);
1987 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 17);
1988 coex_dm
->auto_tdma_adjust
= false;
1989 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1991 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
1992 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
1993 btc8192e2ant_tdma_duration_adjust(btcoexist
, false,
1995 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1996 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
1997 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
1998 btc8192e2ant_tdma_duration_adjust(btcoexist
, false,
2000 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2001 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2002 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2003 btc8192e2ant_tdma_duration_adjust(btcoexist
, false,
2005 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
2010 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2011 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2012 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2013 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2014 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2016 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2019 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2021 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2025 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2026 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2027 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2029 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2032 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2034 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2040 static void btc8192e2ant_action_a2dp_pan_hs(struct btc_coexist
*btcoexist
)
2042 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
2045 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2046 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
2048 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
2049 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2051 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2052 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 2);
2054 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
2055 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
2056 btc8192e2ant_tdma_duration_adjust(btcoexist
, false, true, 2);
2057 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
2058 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
2059 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
2060 btc8192e2ant_tdma_duration_adjust(btcoexist
, false, false, 2);
2061 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2062 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2063 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2064 btc8192e2ant_tdma_duration_adjust(btcoexist
, false, false, 2);
2065 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
2069 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2070 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2071 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2072 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2073 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2075 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2078 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2080 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2084 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2085 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2086 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2088 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2091 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2093 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2099 static void btc8192e2ant_action_pan_edr(struct btc_coexist
*btcoexist
)
2101 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
2104 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2105 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
2107 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
2108 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2110 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2112 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 2);
2114 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
2115 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
2116 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
2117 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 5);
2118 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
2119 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
2120 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2121 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 1);
2122 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2123 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2124 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
2125 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 1);
2129 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2130 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2131 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2132 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2133 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2135 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2138 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2140 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2144 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2145 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2146 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2148 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2151 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2153 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2160 static void btc8192e2ant_action_pan_hs(struct btc_coexist
*btcoexist
)
2162 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
2165 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2166 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
2168 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
2169 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2171 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2173 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 2);
2175 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
2176 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
2177 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
2178 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
2179 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
2180 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2181 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2182 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2183 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
2185 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
2187 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2188 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2189 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2190 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2191 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2193 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2196 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2198 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2202 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2203 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2204 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2206 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2209 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2211 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2218 static void btc8192e2ant_action_pan_edr_a2dp(struct btc_coexist
*btcoexist
)
2220 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
2223 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2224 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
2226 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
2227 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2229 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2231 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 2);
2233 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2235 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
2236 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
2237 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
2238 btc8192e2ant_tdma_duration_adjust(btcoexist
, false, true, 3);
2239 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
2240 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
2241 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2242 btc8192e2ant_tdma_duration_adjust(btcoexist
, false, false, 3);
2243 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2244 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2245 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
2246 btc8192e2ant_tdma_duration_adjust(btcoexist
, false, false, 3);
2250 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2251 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2252 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2253 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2255 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2258 btc8192e2ant_sw_mechanism1(btcoexist
, true, false,
2260 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2264 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2265 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2266 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2268 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2271 btc8192e2ant_sw_mechanism1(btcoexist
, false, false,
2273 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2279 static void btc8192e2ant_action_pan_edr_hid(struct btc_coexist
*btcoexist
)
2281 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
2284 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2285 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
2287 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2289 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
2290 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2292 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2294 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 3);
2296 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
2297 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
2298 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
2299 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 14);
2300 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
2301 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
2302 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2303 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 10);
2304 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2305 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2306 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
2307 btc8192e2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2312 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2313 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2314 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2315 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
2317 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2320 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
2322 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2326 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2327 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2328 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
2330 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2333 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
2335 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2341 /* HID+A2DP+PAN(EDR) */
2342 static void btc8192e2ant_action_hid_a2dp_pan_edr(struct btc_coexist
*btcoexist
)
2344 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
2347 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2348 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
2350 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
2351 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2353 btc8192e2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2355 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2357 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 3);
2359 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
2360 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
2361 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
2362 btc8192e2ant_tdma_duration_adjust(btcoexist
, true, true, 3);
2363 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
2364 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
2365 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2366 btc8192e2ant_tdma_duration_adjust(btcoexist
, true, false, 3);
2367 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2368 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2369 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
2370 btc8192e2ant_tdma_duration_adjust(btcoexist
, true, false, 3);
2374 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2375 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2376 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2377 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
2379 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2382 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
2384 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2388 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2389 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2390 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
2392 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2395 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
2397 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2403 static void btc8192e2ant_action_hid_a2dp(struct btc_coexist
*btcoexist
)
2405 u8 wifi_rssi_state
, bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
2408 wifi_rssi_state
= btc8192e2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2409 bt_rssi_state
= btc8192e2ant_bt_rssi_state(btcoexist
, 3, 34, 42);
2411 btc8192e2ant_switch_ss_type(btcoexist
, NORMAL_EXEC
, 1);
2412 btc8192e2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2414 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2416 btc8192e2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 3);
2418 if ((bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
2419 (bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
2420 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
2421 btc8192e2ant_tdma_duration_adjust(btcoexist
, true, true, 2);
2422 } else if ((bt_rssi_state
== BTC_RSSI_STATE_MEDIUM
) ||
2423 (bt_rssi_state
== BTC_RSSI_STATE_STAY_MEDIUM
)) {
2424 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2425 btc8192e2ant_tdma_duration_adjust(btcoexist
, true, false, 2);
2426 } else if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2427 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2428 btc8192e2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 4);
2429 btc8192e2ant_tdma_duration_adjust(btcoexist
, true, false, 2);
2433 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2434 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2435 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2436 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
2438 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2441 btc8192e2ant_sw_mechanism1(btcoexist
, true, true,
2443 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2447 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2448 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2449 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
2451 btc8192e2ant_sw_mechanism2(btcoexist
, true, false,
2454 btc8192e2ant_sw_mechanism1(btcoexist
, false, true,
2456 btc8192e2ant_sw_mechanism2(btcoexist
, false, false,
2462 static void btc8192e2ant_run_coexist_mechanism(struct btc_coexist
*btcoexist
)
2464 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2467 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2468 "[BTCoex], RunCoexistMechanism()===>\n");
2470 if (btcoexist
->manual_control
) {
2471 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2472 "[BTCoex], return for Manual CTRL <===\n");
2476 if (coex_sta
->under_ips
) {
2477 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2478 "[BTCoex], wifi is under IPS !!!\n");
2482 algorithm
= btc8192e2ant_action_algorithm(btcoexist
);
2483 if (coex_sta
->c2h_bt_inquiry_page
&&
2484 (BT_8192E_2ANT_COEX_ALGO_PANHS
!= algorithm
)) {
2485 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2486 "[BTCoex], BT is under inquiry/page scan !!\n");
2487 btc8192e2ant_action_bt_inquiry(btcoexist
);
2491 coex_dm
->cur_algorithm
= algorithm
;
2492 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2493 "[BTCoex], Algorithm = %d\n", coex_dm
->cur_algorithm
);
2495 if (btc8192e2ant_is_common_action(btcoexist
)) {
2496 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2497 "[BTCoex], Action 2-Ant common\n");
2498 coex_dm
->auto_tdma_adjust
= false;
2500 if (coex_dm
->cur_algorithm
!= coex_dm
->pre_algorithm
) {
2501 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2502 "[BTCoex] preAlgorithm=%d, curAlgorithm=%d\n",
2503 coex_dm
->pre_algorithm
,
2504 coex_dm
->cur_algorithm
);
2505 coex_dm
->auto_tdma_adjust
= false;
2507 switch (coex_dm
->cur_algorithm
) {
2508 case BT_8192E_2ANT_COEX_ALGO_SCO
:
2509 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2510 "Action 2-Ant, algorithm = SCO\n");
2511 btc8192e2ant_action_sco(btcoexist
);
2513 case BT_8192E_2ANT_COEX_ALGO_SCO_PAN
:
2514 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2515 "Action 2-Ant, algorithm = SCO+PAN(EDR)\n");
2516 btc8192e2ant_action_sco_pan(btcoexist
);
2518 case BT_8192E_2ANT_COEX_ALGO_HID
:
2519 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2520 "Action 2-Ant, algorithm = HID\n");
2521 btc8192e2ant_action_hid(btcoexist
);
2523 case BT_8192E_2ANT_COEX_ALGO_A2DP
:
2524 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2525 "Action 2-Ant, algorithm = A2DP\n");
2526 btc8192e2ant_action_a2dp(btcoexist
);
2528 case BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS
:
2529 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2530 "Action 2-Ant, algorithm = A2DP+PAN(HS)\n");
2531 btc8192e2ant_action_a2dp_pan_hs(btcoexist
);
2533 case BT_8192E_2ANT_COEX_ALGO_PANEDR
:
2534 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2535 "Action 2-Ant, algorithm = PAN(EDR)\n");
2536 btc8192e2ant_action_pan_edr(btcoexist
);
2538 case BT_8192E_2ANT_COEX_ALGO_PANHS
:
2539 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2540 "Action 2-Ant, algorithm = HS mode\n");
2541 btc8192e2ant_action_pan_hs(btcoexist
);
2543 case BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP
:
2544 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2545 "Action 2-Ant, algorithm = PAN+A2DP\n");
2546 btc8192e2ant_action_pan_edr_a2dp(btcoexist
);
2548 case BT_8192E_2ANT_COEX_ALGO_PANEDR_HID
:
2549 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2550 "Action 2-Ant, algorithm = PAN(EDR)+HID\n");
2551 btc8192e2ant_action_pan_edr_hid(btcoexist
);
2553 case BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR
:
2554 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2555 "Action 2-Ant, algorithm = HID+A2DP+PAN\n");
2556 btc8192e2ant_action_hid_a2dp_pan_edr(btcoexist
);
2558 case BT_8192E_2ANT_COEX_ALGO_HID_A2DP
:
2559 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2560 "Action 2-Ant, algorithm = HID+A2DP\n");
2561 btc8192e2ant_action_hid_a2dp(btcoexist
);
2564 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2565 "Action 2-Ant, algorithm = unknown!!\n");
2566 /* btc8192e2ant_coex_all_off(btcoexist); */
2569 coex_dm
->pre_algorithm
= coex_dm
->cur_algorithm
;
2573 static void btc8192e2ant_init_hwconfig(struct btc_coexist
*btcoexist
,
2576 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2580 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2581 "[BTCoex], 2Ant Init HW Config!!\n");
2584 /* backup rf 0x1e value */
2585 coex_dm
->bt_rf0x1e_backup
=
2586 btcoexist
->btc_get_rf_reg(btcoexist
, BTC_RF_A
,
2589 coex_dm
->backup_arfr_cnt1
= btcoexist
->btc_read_4byte(btcoexist
,
2591 coex_dm
->backup_arfr_cnt2
= btcoexist
->btc_read_4byte(btcoexist
,
2593 coex_dm
->backup_retry_limit
= btcoexist
->btc_read_2byte(
2596 coex_dm
->backup_ampdu_maxtime
= btcoexist
->btc_read_1byte(
2601 /* antenna sw ctrl to bt */
2602 btcoexist
->btc_write_1byte(btcoexist
, 0x4f, 0x6);
2603 btcoexist
->btc_write_1byte(btcoexist
, 0x944, 0x24);
2604 btcoexist
->btc_write_4byte(btcoexist
, 0x930, 0x700700);
2605 btcoexist
->btc_write_1byte(btcoexist
, 0x92c, 0x20);
2606 if (btcoexist
->chip_interface
== BTC_INTF_USB
)
2607 btcoexist
->btc_write_4byte(btcoexist
, 0x64, 0x30430004);
2609 btcoexist
->btc_write_4byte(btcoexist
, 0x64, 0x30030004);
2611 btc8192e2ant_coex_table_with_type(btcoexist
, FORCE_EXEC
, 0);
2613 /* antenna switch control parameter */
2614 btcoexist
->btc_write_4byte(btcoexist
, 0x858, 0x55555555);
2616 /* coex parameters */
2617 btcoexist
->btc_write_1byte(btcoexist
, 0x778, 0x3);
2618 /* 0x790[5:0] = 0x5 */
2619 u8tmp
= btcoexist
->btc_read_1byte(btcoexist
, 0x790);
2622 btcoexist
->btc_write_1byte(btcoexist
, 0x790, u8tmp
);
2624 /* enable counter statistics */
2625 btcoexist
->btc_write_1byte(btcoexist
, 0x76e, 0x4);
2628 btcoexist
->btc_write_1byte(btcoexist
, 0x40, 0x20);
2629 /* enable mailbox interface */
2630 u16tmp
= btcoexist
->btc_read_2byte(btcoexist
, 0x40);
2632 btcoexist
->btc_write_2byte(btcoexist
, 0x40, u16tmp
);
2634 /* enable PTA I2C mailbox */
2635 u8tmp
= btcoexist
->btc_read_1byte(btcoexist
, 0x101);
2637 btcoexist
->btc_write_1byte(btcoexist
, 0x101, u8tmp
);
2639 /* enable bt clock when wifi is disabled. */
2640 u8tmp
= btcoexist
->btc_read_1byte(btcoexist
, 0x93);
2642 btcoexist
->btc_write_1byte(btcoexist
, 0x93, u8tmp
);
2643 /* enable bt clock when suspend. */
2644 u8tmp
= btcoexist
->btc_read_1byte(btcoexist
, 0x7);
2646 btcoexist
->btc_write_1byte(btcoexist
, 0x7, u8tmp
);
2649 /************************************************************
2650 * extern function start with ex_btc8192e2ant_
2651 ************************************************************/
2653 void ex_btc8192e2ant_init_hwconfig(struct btc_coexist
*btcoexist
)
2655 btc8192e2ant_init_hwconfig(btcoexist
, true);
2658 void ex_btc8192e2ant_init_coex_dm(struct btc_coexist
*btcoexist
)
2660 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2662 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2663 "[BTCoex], Coex Mechanism Init!!\n");
2664 btc8192e2ant_init_coex_dm(btcoexist
);
2667 void ex_btc8192e2ant_display_coex_info(struct btc_coexist
*btcoexist
,
2670 struct btc_board_info
*board_info
= &btcoexist
->board_info
;
2671 struct btc_stack_info
*stack_info
= &btcoexist
->stack_info
;
2672 u8 u8tmp
[4], i
, bt_info_ext
, ps_tdma_case
= 0;
2675 bool roam
= false, scan
= false, link
= false, wifi_under_5g
= false;
2676 bool bt_hs_on
= false, wifi_busy
= false;
2677 int wifi_rssi
= 0, bt_hs_rssi
= 0;
2678 u32 wifi_bw
, wifi_traffic_dir
;
2679 u8 wifi_dot11_chnl
, wifi_hs_chnl
;
2680 u32 fw_ver
= 0, bt_patch_ver
= 0;
2682 seq_puts(m
, "\n ============[BT Coexist info]============");
2684 if (btcoexist
->manual_control
) {
2685 seq_puts(m
, "\n ===========[Under Manual Control]===========");
2686 seq_puts(m
, "\n ==========================================");
2689 seq_printf(m
, "\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:",
2690 board_info
->pg_ant_num
, board_info
->btdm_ant_num
);
2692 seq_printf(m
, "\n %-35s = %s / %d", "BT stack/ hci ext ver",
2693 ((stack_info
->profile_notified
) ? "Yes" : "No"),
2694 stack_info
->hci_version
);
2696 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_BT_PATCH_VER
, &bt_patch_ver
);
2697 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_FW_VER
, &fw_ver
);
2698 seq_printf(m
, "\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)",
2699 "CoexVer/ FwVer/ PatchVer",
2700 glcoex_ver_date_8192e_2ant
, glcoex_ver_8192e_2ant
,
2701 fw_ver
, bt_patch_ver
, bt_patch_ver
);
2703 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
2704 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_WIFI_DOT11_CHNL
,
2706 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_WIFI_HS_CHNL
, &wifi_hs_chnl
);
2707 seq_printf(m
, "\n %-35s = %d / %d(%d)",
2708 "Dot11 channel / HsMode(HsChnl)",
2709 wifi_dot11_chnl
, bt_hs_on
, wifi_hs_chnl
);
2711 seq_printf(m
, "\n %-35s = %3ph ",
2712 "H2C Wifi inform bt chnl Info", coex_dm
->wifi_chnl_info
);
2714 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_WIFI_RSSI
, &wifi_rssi
);
2715 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_HS_RSSI
, &bt_hs_rssi
);
2716 seq_printf(m
, "\n %-35s = %d/ %d",
2717 "Wifi rssi/ HS rssi", wifi_rssi
, bt_hs_rssi
);
2719 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_SCAN
, &scan
);
2720 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_LINK
, &link
);
2721 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_ROAM
, &roam
);
2722 seq_printf(m
, "\n %-35s = %d/ %d/ %d ",
2723 "Wifi link/ roam/ scan", link
, roam
, scan
);
2725 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_UNDER_5G
, &wifi_under_5g
);
2726 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2727 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
2728 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION
,
2730 seq_printf(m
, "\n %-35s = %s / %s/ %s ",
2731 "Wifi status", (wifi_under_5g
? "5G" : "2.4G"),
2732 ((BTC_WIFI_BW_LEGACY
== wifi_bw
) ? "Legacy" :
2733 (((BTC_WIFI_BW_HT40
== wifi_bw
) ? "HT40" : "HT20"))),
2734 ((!wifi_busy
) ? "idle" :
2735 ((BTC_WIFI_TRAFFIC_TX
== wifi_traffic_dir
) ?
2736 "uplink" : "downlink")));
2738 seq_printf(m
, "\n %-35s = [%s/ %d/ %d] ",
2739 "BT [status/ rssi/ retryCnt]",
2740 ((btcoexist
->bt_info
.bt_disabled
) ? ("disabled") :
2741 ((coex_sta
->c2h_bt_inquiry_page
) ?
2742 ("inquiry/page scan") :
2743 ((BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE
==
2744 coex_dm
->bt_status
) ? "non-connected idle" :
2745 ((BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE
==
2746 coex_dm
->bt_status
) ? "connected-idle" : "busy")))),
2747 coex_sta
->bt_rssi
, coex_sta
->bt_retry_cnt
);
2749 seq_printf(m
, "\n %-35s = %d / %d / %d / %d",
2750 "SCO/HID/PAN/A2DP", stack_info
->sco_exist
,
2751 stack_info
->hid_exist
, stack_info
->pan_exist
,
2752 stack_info
->a2dp_exist
);
2753 btcoexist
->btc_disp_dbg_msg(btcoexist
, BTC_DBG_DISP_BT_LINK_INFO
, m
);
2755 bt_info_ext
= coex_sta
->bt_info_ext
;
2756 seq_printf(m
, "\n %-35s = %s",
2757 "BT Info A2DP rate",
2758 (bt_info_ext
&BIT0
) ? "Basic rate" : "EDR rate");
2760 for (i
= 0; i
< BT_INFO_SRC_8192E_2ANT_MAX
; i
++) {
2761 if (coex_sta
->bt_info_c2h_cnt
[i
]) {
2762 seq_printf(m
, "\n %-35s = %7ph(%d)",
2763 glbt_info_src_8192e_2ant
[i
],
2764 coex_sta
->bt_info_c2h
[i
],
2765 coex_sta
->bt_info_c2h_cnt
[i
]);
2769 seq_printf(m
, "\n %-35s = %s/%s",
2770 "PS state, IPS/LPS",
2771 ((coex_sta
->under_ips
? "IPS ON" : "IPS OFF")),
2772 ((coex_sta
->under_lps
? "LPS ON" : "LPS OFF")));
2773 btcoexist
->btc_disp_dbg_msg(btcoexist
, BTC_DBG_DISP_FW_PWR_MODE_CMD
, m
);
2775 seq_printf(m
, "\n %-35s = 0x%x ", "SS Type",
2776 coex_dm
->cur_ss_type
);
2779 seq_printf(m
, "\n %-35s",
2780 "============[Sw mechanism]============");
2781 seq_printf(m
, "\n %-35s = %d/ %d/ %d ",
2782 "SM1[ShRf/ LpRA/ LimDig]", coex_dm
->cur_rf_rx_lpf_shrink
,
2783 coex_dm
->cur_low_penalty_ra
, coex_dm
->limited_dig
);
2784 seq_printf(m
, "\n %-35s = %d/ %d/ %d(0x%x) ",
2785 "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]",
2786 coex_dm
->cur_agc_table_en
, coex_dm
->cur_adc_back_off
,
2787 coex_dm
->cur_dac_swing_on
, coex_dm
->cur_dac_swing_lvl
);
2789 seq_printf(m
, "\n %-35s = 0x%x ", "Rate Mask",
2790 btcoexist
->bt_info
.ra_mask
);
2793 seq_printf(m
, "\n %-35s",
2794 "============[Fw mechanism]============");
2796 ps_tdma_case
= coex_dm
->cur_ps_tdma
;
2798 "\n %-35s = %5ph case-%d (auto:%d)",
2799 "PS TDMA", coex_dm
->ps_tdma_para
,
2800 ps_tdma_case
, coex_dm
->auto_tdma_adjust
);
2802 seq_printf(m
, "\n %-35s = %d/ %d ",
2803 "DecBtPwr/ IgnWlanAct",
2804 coex_dm
->cur_dec_bt_pwr
, coex_dm
->cur_ignore_wlan_act
);
2807 seq_printf(m
, "\n %-35s",
2808 "============[Hw setting]============");
2810 seq_printf(m
, "\n %-35s = 0x%x",
2811 "RF-A, 0x1e initVal", coex_dm
->bt_rf0x1e_backup
);
2813 seq_printf(m
, "\n %-35s = 0x%x/0x%x/0x%x/0x%x",
2814 "backup ARFR1/ARFR2/RL/AMaxTime", coex_dm
->backup_arfr_cnt1
,
2815 coex_dm
->backup_arfr_cnt2
, coex_dm
->backup_retry_limit
,
2816 coex_dm
->backup_ampdu_maxtime
);
2818 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x430);
2819 u32tmp
[1] = btcoexist
->btc_read_4byte(btcoexist
, 0x434);
2820 u16tmp
[0] = btcoexist
->btc_read_2byte(btcoexist
, 0x42a);
2821 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x456);
2822 seq_printf(m
, "\n %-35s = 0x%x/0x%x/0x%x/0x%x",
2823 "0x430/0x434/0x42a/0x456",
2824 u32tmp
[0], u32tmp
[1], u16tmp
[0], u8tmp
[0]);
2826 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0xc04);
2827 u32tmp
[1] = btcoexist
->btc_read_4byte(btcoexist
, 0xd04);
2828 u32tmp
[2] = btcoexist
->btc_read_4byte(btcoexist
, 0x90c);
2829 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x/ 0x%x",
2830 "0xc04/ 0xd04/ 0x90c", u32tmp
[0], u32tmp
[1], u32tmp
[2]);
2832 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x778);
2833 seq_printf(m
, "\n %-35s = 0x%x", "0x778", u8tmp
[0]);
2835 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x92c);
2836 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x930);
2837 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x",
2838 "0x92c/ 0x930", (u8tmp
[0]), u32tmp
[0]);
2840 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x40);
2841 u8tmp
[1] = btcoexist
->btc_read_1byte(btcoexist
, 0x4f);
2842 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x",
2843 "0x40/ 0x4f", u8tmp
[0], u8tmp
[1]);
2845 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x550);
2846 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x522);
2847 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x",
2848 "0x550(bcn ctrl)/0x522", u32tmp
[0], u8tmp
[0]);
2850 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0xc50);
2851 seq_printf(m
, "\n %-35s = 0x%x", "0xc50(dig)",
2854 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x6c0);
2855 u32tmp
[1] = btcoexist
->btc_read_4byte(btcoexist
, 0x6c4);
2856 u32tmp
[2] = btcoexist
->btc_read_4byte(btcoexist
, 0x6c8);
2857 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x6cc);
2859 "\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
2860 "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)",
2861 u32tmp
[0], u32tmp
[1], u32tmp
[2], u8tmp
[0]);
2863 seq_printf(m
, "\n %-35s = %d/ %d",
2864 "0x770(hp rx[31:16]/tx[15:0])",
2865 coex_sta
->high_priority_rx
, coex_sta
->high_priority_tx
);
2866 seq_printf(m
, "\n %-35s = %d/ %d",
2867 "0x774(lp rx[31:16]/tx[15:0])",
2868 coex_sta
->low_priority_rx
, coex_sta
->low_priority_tx
);
2869 if (btcoexist
->auto_report_2ant
)
2870 btc8192e2ant_monitor_bt_ctr(btcoexist
);
2871 btcoexist
->btc_disp_dbg_msg(btcoexist
, BTC_DBG_DISP_COEX_STATISTICS
, m
);
2874 void ex_btc8192e2ant_ips_notify(struct btc_coexist
*btcoexist
, u8 type
)
2876 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2878 if (BTC_IPS_ENTER
== type
) {
2879 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2880 "[BTCoex], IPS ENTER notify\n");
2881 coex_sta
->under_ips
= true;
2882 btc8192e2ant_coex_all_off(btcoexist
);
2883 } else if (BTC_IPS_LEAVE
== type
) {
2884 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2885 "[BTCoex], IPS LEAVE notify\n");
2886 coex_sta
->under_ips
= false;
2890 void ex_btc8192e2ant_lps_notify(struct btc_coexist
*btcoexist
, u8 type
)
2892 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2894 if (BTC_LPS_ENABLE
== type
) {
2895 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2896 "[BTCoex], LPS ENABLE notify\n");
2897 coex_sta
->under_lps
= true;
2898 } else if (BTC_LPS_DISABLE
== type
) {
2899 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2900 "[BTCoex], LPS DISABLE notify\n");
2901 coex_sta
->under_lps
= false;
2905 void ex_btc8192e2ant_scan_notify(struct btc_coexist
*btcoexist
, u8 type
)
2907 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2909 if (BTC_SCAN_START
== type
)
2910 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2911 "[BTCoex], SCAN START notify\n");
2912 else if (BTC_SCAN_FINISH
== type
)
2913 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2914 "[BTCoex], SCAN FINISH notify\n");
2917 void ex_btc8192e2ant_connect_notify(struct btc_coexist
*btcoexist
, u8 type
)
2919 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2921 if (BTC_ASSOCIATE_START
== type
)
2922 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2923 "[BTCoex], CONNECT START notify\n");
2924 else if (BTC_ASSOCIATE_FINISH
== type
)
2925 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2926 "[BTCoex], CONNECT FINISH notify\n");
2929 void ex_btc8192e2ant_media_status_notify(struct btc_coexist
*btcoexist
,
2932 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2933 u8 h2c_parameter
[3] = {0};
2935 u8 wifi_center_chnl
;
2937 if (btcoexist
->manual_control
||
2938 btcoexist
->stop_coex_dm
||
2939 btcoexist
->bt_info
.bt_disabled
)
2942 if (BTC_MEDIA_CONNECT
== type
)
2943 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2944 "[BTCoex], MEDIA connect notify\n");
2946 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2947 "[BTCoex], MEDIA disconnect notify\n");
2949 /* only 2.4G we need to inform bt the chnl mask */
2950 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_WIFI_CENTRAL_CHNL
,
2952 if ((BTC_MEDIA_CONNECT
== type
) &&
2953 (wifi_center_chnl
<= 14)) {
2954 h2c_parameter
[0] = 0x1;
2955 h2c_parameter
[1] = wifi_center_chnl
;
2956 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2957 if (BTC_WIFI_BW_HT40
== wifi_bw
)
2958 h2c_parameter
[2] = 0x30;
2960 h2c_parameter
[2] = 0x20;
2963 coex_dm
->wifi_chnl_info
[0] = h2c_parameter
[0];
2964 coex_dm
->wifi_chnl_info
[1] = h2c_parameter
[1];
2965 coex_dm
->wifi_chnl_info
[2] = h2c_parameter
[2];
2967 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2968 "[BTCoex], FW write 0x66 = 0x%x\n",
2969 h2c_parameter
[0] << 16 | h2c_parameter
[1] << 8 |
2972 btcoexist
->btc_fill_h2c(btcoexist
, 0x66, 3, h2c_parameter
);
2975 void ex_btc8192e2ant_special_packet_notify(struct btc_coexist
*btcoexist
,
2978 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2980 if (type
== BTC_PACKET_DHCP
)
2981 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2982 "[BTCoex], DHCP Packet notify\n");
2985 void ex_btc8192e2ant_bt_info_notify(struct btc_coexist
*btcoexist
,
2986 u8
*tmp_buf
, u8 length
)
2988 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
2990 u8 i
, rsp_source
= 0;
2991 bool bt_busy
= false, limited_dig
= false;
2992 bool wifi_connected
= false;
2994 coex_sta
->c2h_bt_info_req_sent
= false;
2996 rsp_source
= tmp_buf
[0] & 0xf;
2997 if (rsp_source
>= BT_INFO_SRC_8192E_2ANT_MAX
)
2998 rsp_source
= BT_INFO_SRC_8192E_2ANT_WIFI_FW
;
2999 coex_sta
->bt_info_c2h_cnt
[rsp_source
]++;
3001 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3002 "[BTCoex], Bt info[%d], length=%d, hex data = [",
3003 rsp_source
, length
);
3004 for (i
= 0; i
< length
; i
++) {
3005 coex_sta
->bt_info_c2h
[rsp_source
][i
] = tmp_buf
[i
];
3007 bt_info
= tmp_buf
[i
];
3009 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3010 "0x%02x]\n", tmp_buf
[i
]);
3012 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3013 "0x%02x, ", tmp_buf
[i
]);
3016 if (BT_INFO_SRC_8192E_2ANT_WIFI_FW
!= rsp_source
) {
3018 coex_sta
->bt_retry_cnt
=
3019 coex_sta
->bt_info_c2h
[rsp_source
][2] & 0xf;
3022 coex_sta
->bt_info_c2h
[rsp_source
][3] * 2 + 10;
3024 coex_sta
->bt_info_ext
=
3025 coex_sta
->bt_info_c2h
[rsp_source
][4];
3027 /* Here we need to resend some wifi info to BT
3028 * because bt is reset and loss of the info.
3030 if ((coex_sta
->bt_info_ext
& BIT1
)) {
3031 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3032 "bit1, send wifi BW&Chnl to BT!!\n");
3033 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
3036 ex_btc8192e2ant_media_status_notify(
3040 ex_btc8192e2ant_media_status_notify(
3042 BTC_MEDIA_DISCONNECT
);
3045 if ((coex_sta
->bt_info_ext
& BIT3
)) {
3046 if (!btcoexist
->manual_control
&&
3047 !btcoexist
->stop_coex_dm
) {
3048 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3049 "bit3, BT NOT ignore Wlan active!\n");
3050 btc8192e2ant_ignore_wlan_act(btcoexist
,
3055 /* BT already NOT ignore Wlan active,
3060 if (!btcoexist
->auto_report_2ant
) {
3061 if (!(coex_sta
->bt_info_ext
& BIT4
))
3062 btc8192e2ant_bt_auto_report(btcoexist
,
3068 /* check BIT2 first ==> check if bt is under inquiry or page scan */
3069 if (bt_info
& BT_INFO_8192E_2ANT_B_INQ_PAGE
)
3070 coex_sta
->c2h_bt_inquiry_page
= true;
3072 coex_sta
->c2h_bt_inquiry_page
= false;
3074 /* set link exist status */
3075 if (!(bt_info
&BT_INFO_8192E_2ANT_B_CONNECTION
)) {
3076 coex_sta
->bt_link_exist
= false;
3077 coex_sta
->pan_exist
= false;
3078 coex_sta
->a2dp_exist
= false;
3079 coex_sta
->hid_exist
= false;
3080 coex_sta
->sco_exist
= false;
3081 } else {/* connection exists */
3082 coex_sta
->bt_link_exist
= true;
3083 if (bt_info
& BT_INFO_8192E_2ANT_B_FTP
)
3084 coex_sta
->pan_exist
= true;
3086 coex_sta
->pan_exist
= false;
3087 if (bt_info
& BT_INFO_8192E_2ANT_B_A2DP
)
3088 coex_sta
->a2dp_exist
= true;
3090 coex_sta
->a2dp_exist
= false;
3091 if (bt_info
& BT_INFO_8192E_2ANT_B_HID
)
3092 coex_sta
->hid_exist
= true;
3094 coex_sta
->hid_exist
= false;
3095 if (bt_info
& BT_INFO_8192E_2ANT_B_SCO_ESCO
)
3096 coex_sta
->sco_exist
= true;
3098 coex_sta
->sco_exist
= false;
3101 btc8192e2ant_update_bt_link_info(btcoexist
);
3103 if (!(bt_info
& BT_INFO_8192E_2ANT_B_CONNECTION
)) {
3104 coex_dm
->bt_status
= BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE
;
3105 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3106 "[BTCoex], BT Non-Connected idle!!!\n");
3107 } else if (bt_info
== BT_INFO_8192E_2ANT_B_CONNECTION
) {
3108 coex_dm
->bt_status
= BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE
;
3109 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3110 "[BTCoex], bt_infoNotify(), BT Connected-idle!!!\n");
3111 } else if ((bt_info
& BT_INFO_8192E_2ANT_B_SCO_ESCO
) ||
3112 (bt_info
& BT_INFO_8192E_2ANT_B_SCO_BUSY
)) {
3113 coex_dm
->bt_status
= BT_8192E_2ANT_BT_STATUS_SCO_BUSY
;
3114 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3115 "[BTCoex], bt_infoNotify(), BT SCO busy!!!\n");
3116 } else if (bt_info
& BT_INFO_8192E_2ANT_B_ACL_BUSY
) {
3117 coex_dm
->bt_status
= BT_8192E_2ANT_BT_STATUS_ACL_BUSY
;
3118 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3119 "[BTCoex], bt_infoNotify(), BT ACL busy!!!\n");
3121 coex_dm
->bt_status
= BT_8192E_2ANT_BT_STATUS_MAX
;
3122 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3123 "[BTCoex]bt_infoNotify(), BT Non-Defined state!!!\n");
3126 if ((BT_8192E_2ANT_BT_STATUS_ACL_BUSY
== coex_dm
->bt_status
) ||
3127 (BT_8192E_2ANT_BT_STATUS_SCO_BUSY
== coex_dm
->bt_status
) ||
3128 (BT_8192E_2ANT_BT_STATUS_ACL_SCO_BUSY
== coex_dm
->bt_status
)) {
3133 limited_dig
= false;
3136 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_TRAFFIC_BUSY
, &bt_busy
);
3138 coex_dm
->limited_dig
= limited_dig
;
3139 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_LIMITED_DIG
, &limited_dig
);
3141 btc8192e2ant_run_coexist_mechanism(btcoexist
);
3144 void ex_btc8192e2ant_halt_notify(struct btc_coexist
*btcoexist
)
3146 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3148 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
, "[BTCoex], Halt notify\n");
3150 btc8192e2ant_ignore_wlan_act(btcoexist
, FORCE_EXEC
, true);
3151 ex_btc8192e2ant_media_status_notify(btcoexist
, BTC_MEDIA_DISCONNECT
);
3154 void ex_btc8192e2ant_periodical(struct btc_coexist
*btcoexist
)
3156 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3157 static u8 dis_ver_info_cnt
;
3158 u32 fw_ver
= 0, bt_patch_ver
= 0;
3159 struct btc_board_info
*board_info
= &btcoexist
->board_info
;
3160 struct btc_stack_info
*stack_info
= &btcoexist
->stack_info
;
3162 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3163 "=======================Periodical=======================\n");
3164 if (dis_ver_info_cnt
<= 5) {
3165 dis_ver_info_cnt
+= 1;
3166 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3167 "************************************************\n");
3168 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3169 "Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n",
3170 board_info
->pg_ant_num
, board_info
->btdm_ant_num
,
3171 board_info
->btdm_ant_pos
);
3172 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3173 "BT stack/ hci ext ver = %s / %d\n",
3174 ((stack_info
->profile_notified
) ? "Yes" : "No"),
3175 stack_info
->hci_version
);
3176 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_BT_PATCH_VER
,
3178 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_FW_VER
, &fw_ver
);
3179 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3180 "CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",
3181 glcoex_ver_date_8192e_2ant
, glcoex_ver_8192e_2ant
,
3182 fw_ver
, bt_patch_ver
, bt_patch_ver
);
3183 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3184 "************************************************\n");
3187 if (!btcoexist
->auto_report_2ant
) {
3188 btc8192e2ant_query_bt_info(btcoexist
);
3189 btc8192e2ant_monitor_bt_ctr(btcoexist
);
3190 btc8192e2ant_monitor_bt_enable_disable(btcoexist
);
3192 if (btc8192e2ant_is_wifi_status_changed(btcoexist
) ||
3193 coex_dm
->auto_tdma_adjust
)
3194 btc8192e2ant_run_coexist_mechanism(btcoexist
);