1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2012 Realtek Corporation.*/
4 /************************************************************
7 * This file is for RTL8821A Co-exist mechanism
10 * 2012/08/22 Cosa first check in.
11 * 2012/11/14 Cosa Revise for 8821A 2Ant out sourcing.
13 ************************************************************/
15 /************************************************************
17 ************************************************************/
18 #include "halbt_precomp.h"
19 /************************************************************
20 * Global variables, these are static variables
21 ************************************************************/
22 static struct coex_dm_8821a_2ant glcoex_dm_8821a_2ant
;
23 static struct coex_dm_8821a_2ant
*coex_dm
= &glcoex_dm_8821a_2ant
;
24 static struct coex_sta_8821a_2ant glcoex_sta_8821a_2ant
;
25 static struct coex_sta_8821a_2ant
*coex_sta
= &glcoex_sta_8821a_2ant
;
27 static const char *const glbt_info_src_8821a_2ant
[] = {
30 "BT Info[bt auto report]",
33 static u32 glcoex_ver_date_8821a_2ant
= 20130618;
34 static u32 glcoex_ver_8821a_2ant
= 0x5050;
36 /************************************************************
37 * local function proto type if needed
39 * local function start with btc8821a2ant_
40 ************************************************************/
41 static u8
btc8821a2ant_bt_rssi_state(struct btc_coexist
*btcoexist
,
42 u8 level_num
, u8 rssi_thresh
,
45 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
47 u8 bt_rssi_state
= coex_sta
->pre_bt_rssi_state
;
49 bt_rssi
= coex_sta
->bt_rssi
;
52 if ((coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
53 (coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
55 rssi_thresh
+ BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT
) {
56 bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
57 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
58 "[BTCoex], BT Rssi state switch to High\n");
60 bt_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
61 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
62 "[BTCoex], BT Rssi state stay at Low\n");
65 if (bt_rssi
< rssi_thresh
) {
66 bt_rssi_state
= BTC_RSSI_STATE_LOW
;
67 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
68 "[BTCoex], BT Rssi state switch to Low\n");
70 bt_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
71 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
72 "[BTCoex], BT Rssi state stay at High\n");
75 } else if (level_num
== 3) {
76 if (rssi_thresh
> rssi_thresh1
) {
77 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
78 "[BTCoex], BT Rssi thresh error!!\n");
79 return coex_sta
->pre_bt_rssi_state
;
82 if ((coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
83 (coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
86 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT
)) {
87 bt_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
88 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
89 "[BTCoex], BT Rssi state switch to Medium\n");
91 bt_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
92 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
93 "[BTCoex], BT Rssi state stay at Low\n");
95 } else if ((coex_sta
->pre_bt_rssi_state
==
96 BTC_RSSI_STATE_MEDIUM
) ||
97 (coex_sta
->pre_bt_rssi_state
==
98 BTC_RSSI_STATE_STAY_MEDIUM
)) {
101 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT
)) {
102 bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
103 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
104 "[BTCoex], BT Rssi state switch to High\n");
105 } else if (bt_rssi
< rssi_thresh
) {
106 bt_rssi_state
= BTC_RSSI_STATE_LOW
;
107 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
108 "[BTCoex], BT Rssi state switch to Low\n");
110 bt_rssi_state
= BTC_RSSI_STATE_STAY_MEDIUM
;
111 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
112 "[BTCoex], BT Rssi state stay at Medium\n");
115 if (bt_rssi
< rssi_thresh1
) {
116 bt_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
117 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
118 "[BTCoex], BT Rssi state switch to Medium\n");
120 bt_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
121 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
122 "[BTCoex], BT Rssi state stay at High\n");
127 coex_sta
->pre_bt_rssi_state
= bt_rssi_state
;
129 return bt_rssi_state
;
132 static u8
btc8821a2ant_wifi_rssi_state(struct btc_coexist
*btcoexist
,
133 u8 index
, u8 level_num
,
134 u8 rssi_thresh
, u8 rssi_thresh1
)
136 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
138 u8 wifi_rssi_state
= coex_sta
->pre_wifi_rssi_state
[index
];
140 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_WIFI_RSSI
, &wifi_rssi
);
142 if (level_num
== 2) {
143 if ((coex_sta
->pre_wifi_rssi_state
[index
] ==
144 BTC_RSSI_STATE_LOW
) ||
145 (coex_sta
->pre_wifi_rssi_state
[index
] ==
146 BTC_RSSI_STATE_STAY_LOW
)) {
148 (rssi_thresh
+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT
)) {
149 wifi_rssi_state
= BTC_RSSI_STATE_HIGH
;
150 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
151 "[BTCoex], wifi RSSI state switch to High\n");
153 wifi_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
154 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
155 "[BTCoex], wifi RSSI state stay at Low\n");
158 if (wifi_rssi
< rssi_thresh
) {
159 wifi_rssi_state
= BTC_RSSI_STATE_LOW
;
160 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
161 "[BTCoex], wifi RSSI state switch to Low\n");
163 wifi_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
164 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
165 "[BTCoex], wifi RSSI state stay at High\n");
168 } else if (level_num
== 3) {
169 if (rssi_thresh
> rssi_thresh1
) {
170 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
171 "[BTCoex], wifi RSSI thresh error!!\n");
172 return coex_sta
->pre_wifi_rssi_state
[index
];
175 if ((coex_sta
->pre_wifi_rssi_state
[index
] ==
176 BTC_RSSI_STATE_LOW
) ||
177 (coex_sta
->pre_wifi_rssi_state
[index
] ==
178 BTC_RSSI_STATE_STAY_LOW
)) {
181 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT
)) {
182 wifi_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
183 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
184 "[BTCoex], wifi RSSI state switch to Medium\n");
186 wifi_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
187 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
188 "[BTCoex], wifi RSSI state stay at Low\n");
190 } else if ((coex_sta
->pre_wifi_rssi_state
[index
] ==
191 BTC_RSSI_STATE_MEDIUM
) ||
192 (coex_sta
->pre_wifi_rssi_state
[index
] ==
193 BTC_RSSI_STATE_STAY_MEDIUM
)) {
194 if (wifi_rssi
>= (rssi_thresh1
+
195 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT
)) {
196 wifi_rssi_state
= BTC_RSSI_STATE_HIGH
;
197 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
198 "[BTCoex], wifi RSSI state switch to High\n");
199 } else if (wifi_rssi
< rssi_thresh
) {
200 wifi_rssi_state
= BTC_RSSI_STATE_LOW
;
201 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
202 "[BTCoex], wifi RSSI state switch to Low\n");
204 wifi_rssi_state
= BTC_RSSI_STATE_STAY_MEDIUM
;
205 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
206 "[BTCoex], wifi RSSI state stay at Medium\n");
209 if (wifi_rssi
< rssi_thresh1
) {
210 wifi_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
211 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
212 "[BTCoex], wifi RSSI state switch to Medium\n");
214 wifi_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
215 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
216 "[BTCoex], wifi RSSI state stay at High\n");
220 coex_sta
->pre_wifi_rssi_state
[index
] = wifi_rssi_state
;
222 return wifi_rssi_state
;
226 void btc8821a2ant_limited_rx(struct btc_coexist
*btcoexist
, bool force_exec
,
227 bool rej_ap_agg_pkt
, bool bt_ctrl_agg_buf_size
,
230 bool reject_rx_agg
= rej_ap_agg_pkt
;
231 bool bt_ctrl_rx_agg_size
= bt_ctrl_agg_buf_size
;
232 u8 rx_agg_size
= agg_buf_size
;
234 /* Rx Aggregation related setting */
235 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_TO_REJ_AP_AGG_PKT
,
237 /* decide BT control aggregation buf size or not */
238 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_CTRL_AGG_SIZE
,
239 &bt_ctrl_rx_agg_size
);
240 /* aggregation buf size, works when BT control Rx aggregation size */
241 btcoexist
->btc_set(btcoexist
, BTC_SET_U1_AGG_BUF_SIZE
, &rx_agg_size
);
242 /* real update aggregation setting */
243 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_AGGREGATE_CTRL
, NULL
);
246 static void btc8821a2ant_monitor_bt_ctr(struct btc_coexist
*btcoexist
)
248 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
249 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
250 u32 reg_hp_txrx
, reg_lp_txrx
, u4tmp
;
251 u32 reg_hp_tx
= 0, reg_hp_rx
= 0, reg_lp_tx
= 0, reg_lp_rx
= 0;
256 u4tmp
= btcoexist
->btc_read_4byte(btcoexist
, reg_hp_txrx
);
257 reg_hp_tx
= u4tmp
& MASKLWORD
;
258 reg_hp_rx
= (u4tmp
& MASKHWORD
) >> 16;
260 u4tmp
= btcoexist
->btc_read_4byte(btcoexist
, reg_lp_txrx
);
261 reg_lp_tx
= u4tmp
& MASKLWORD
;
262 reg_lp_rx
= (u4tmp
& MASKHWORD
) >> 16;
264 coex_sta
->high_priority_tx
= reg_hp_tx
;
265 coex_sta
->high_priority_rx
= reg_hp_rx
;
266 coex_sta
->low_priority_tx
= reg_lp_tx
;
267 coex_sta
->low_priority_rx
= reg_lp_rx
;
269 if ((coex_sta
->low_priority_rx
>= 950) &&
270 (coex_sta
->low_priority_rx
>= coex_sta
->low_priority_tx
) &&
271 (!coex_sta
->under_ips
))
272 bt_link_info
->slave_role
= true;
274 bt_link_info
->slave_role
= false;
276 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
277 "[BTCoex], High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
278 reg_hp_txrx
, reg_hp_tx
, reg_hp_tx
, reg_hp_rx
, reg_hp_rx
);
279 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
280 "[BTCoex], Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
281 reg_lp_txrx
, reg_lp_tx
, reg_lp_tx
, reg_lp_rx
, reg_lp_rx
);
284 btcoexist
->btc_write_1byte(btcoexist
, 0x76e, 0xc);
287 static void btc8821a2ant_monitor_wifi_ctr(struct btc_coexist
*btcoexist
)
289 if (coex_sta
->under_ips
) {
290 coex_sta
->crc_ok_cck
= 0;
291 coex_sta
->crc_ok_11g
= 0;
292 coex_sta
->crc_ok_11n
= 0;
293 coex_sta
->crc_ok_11n_agg
= 0;
295 coex_sta
->crc_err_cck
= 0;
296 coex_sta
->crc_err_11g
= 0;
297 coex_sta
->crc_err_11n
= 0;
298 coex_sta
->crc_err_11n_agg
= 0;
300 coex_sta
->crc_ok_cck
=
301 btcoexist
->btc_read_4byte(btcoexist
, 0xf88);
302 coex_sta
->crc_ok_11g
=
303 btcoexist
->btc_read_2byte(btcoexist
, 0xf94);
304 coex_sta
->crc_ok_11n
=
305 btcoexist
->btc_read_2byte(btcoexist
, 0xf90);
306 coex_sta
->crc_ok_11n_agg
=
307 btcoexist
->btc_read_2byte(btcoexist
, 0xfb8);
309 coex_sta
->crc_err_cck
=
310 btcoexist
->btc_read_4byte(btcoexist
, 0xf84);
311 coex_sta
->crc_err_11g
=
312 btcoexist
->btc_read_2byte(btcoexist
, 0xf96);
313 coex_sta
->crc_err_11n
=
314 btcoexist
->btc_read_2byte(btcoexist
, 0xf92);
315 coex_sta
->crc_err_11n_agg
=
316 btcoexist
->btc_read_2byte(btcoexist
, 0xfba);
320 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0xf16, 0x1, 0x1);
321 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0xf16, 0x1, 0x0);
324 static void btc8821a2ant_query_bt_info(struct btc_coexist
*btcoexist
)
326 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
327 u8 h2c_parameter
[1] = {0};
329 coex_sta
->c2h_bt_info_req_sent
= true;
331 h2c_parameter
[0] |= BIT0
; /* trigger */
333 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
334 "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n",
337 btcoexist
->btc_fill_h2c(btcoexist
, 0x61, 1, h2c_parameter
);
340 static bool btc8821a2ant_is_wifi_status_changed(struct btc_coexist
*btcoexist
)
342 static bool pre_wifi_busy
= true;
343 static bool pre_under_4way
= true;
344 static bool pre_bt_hs_on
= true;
345 bool wifi_busy
= false, under_4way
= false, bt_hs_on
= false;
346 bool wifi_connected
= false;
347 u8 wifi_rssi_state
= BTC_RSSI_STATE_HIGH
;
349 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
351 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
352 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
353 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_4_WAY_PROGRESS
,
356 if (wifi_connected
) {
357 if (wifi_busy
!= pre_wifi_busy
) {
358 pre_wifi_busy
= wifi_busy
;
361 if (under_4way
!= pre_under_4way
) {
362 pre_under_4way
= under_4way
;
365 if (bt_hs_on
!= pre_bt_hs_on
) {
366 pre_bt_hs_on
= bt_hs_on
;
370 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 3, 2,
371 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
373 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
374 (wifi_rssi_state
== BTC_RSSI_STATE_LOW
))
381 static void btc8821a2ant_update_bt_link_info(struct btc_coexist
*btcoexist
)
383 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
384 bool bt_hs_on
= false;
386 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
388 bt_link_info
->bt_link_exist
= coex_sta
->bt_link_exist
;
389 bt_link_info
->sco_exist
= coex_sta
->sco_exist
;
390 bt_link_info
->a2dp_exist
= coex_sta
->a2dp_exist
;
391 bt_link_info
->pan_exist
= coex_sta
->pan_exist
;
392 bt_link_info
->hid_exist
= coex_sta
->hid_exist
;
394 /* work around for HS mode. */
396 bt_link_info
->pan_exist
= true;
397 bt_link_info
->bt_link_exist
= true;
400 /* check if Sco only */
401 if (bt_link_info
->sco_exist
&& !bt_link_info
->a2dp_exist
&&
402 !bt_link_info
->pan_exist
&& !bt_link_info
->hid_exist
)
403 bt_link_info
->sco_only
= true;
405 bt_link_info
->sco_only
= false;
407 /* check if A2dp only */
408 if (!bt_link_info
->sco_exist
&& bt_link_info
->a2dp_exist
&&
409 !bt_link_info
->pan_exist
&& !bt_link_info
->hid_exist
)
410 bt_link_info
->a2dp_only
= true;
412 bt_link_info
->a2dp_only
= false;
414 /* check if Pan only */
415 if (!bt_link_info
->sco_exist
&& !bt_link_info
->a2dp_exist
&&
416 bt_link_info
->pan_exist
&& !bt_link_info
->hid_exist
)
417 bt_link_info
->pan_only
= true;
419 bt_link_info
->pan_only
= false;
421 /* check if Hid only */
422 if (!bt_link_info
->sco_exist
&& !bt_link_info
->a2dp_exist
&&
423 !bt_link_info
->pan_exist
&& bt_link_info
->hid_exist
)
424 bt_link_info
->hid_only
= true;
426 bt_link_info
->hid_only
= false;
429 static u8
btc8821a2ant_action_algorithm(struct btc_coexist
*btcoexist
)
431 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
432 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
433 bool bt_hs_on
= false;
434 u8 algorithm
= BT_8821A_2ANT_COEX_ALGO_UNDEFINED
;
435 u8 num_of_diff_profile
= 0;
437 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
439 if (!bt_link_info
->bt_link_exist
) {
440 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
441 "[BTCoex], No BT link exists!!!\n");
445 if (bt_link_info
->sco_exist
)
446 num_of_diff_profile
++;
447 if (bt_link_info
->hid_exist
)
448 num_of_diff_profile
++;
449 if (bt_link_info
->pan_exist
)
450 num_of_diff_profile
++;
451 if (bt_link_info
->a2dp_exist
)
452 num_of_diff_profile
++;
454 if (num_of_diff_profile
== 1) {
455 if (bt_link_info
->sco_exist
) {
456 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
457 "[BTCoex], SCO only\n");
458 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
460 if (bt_link_info
->hid_exist
) {
461 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
462 "[BTCoex], HID only\n");
463 algorithm
= BT_8821A_2ANT_COEX_ALGO_HID
;
464 } else if (bt_link_info
->a2dp_exist
) {
465 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
466 "[BTCoex], A2DP only\n");
467 algorithm
= BT_8821A_2ANT_COEX_ALGO_A2DP
;
468 } else if (bt_link_info
->pan_exist
) {
470 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
472 "[BTCoex], PAN(HS) only\n");
473 algorithm
= BT_8821A_2ANT_COEX_ALGO_PANHS
;
475 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
477 "[BTCoex], PAN(EDR) only\n");
478 algorithm
= BT_8821A_2ANT_COEX_ALGO_PANEDR
;
482 } else if (num_of_diff_profile
== 2) {
483 if (bt_link_info
->sco_exist
) {
484 if (bt_link_info
->hid_exist
) {
485 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
486 "[BTCoex], SCO + HID\n");
487 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
488 } else if (bt_link_info
->a2dp_exist
) {
489 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
490 "[BTCoex], SCO + A2DP ==> SCO\n");
491 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
492 } else if (bt_link_info
->pan_exist
) {
494 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
496 "[BTCoex], SCO + PAN(HS)\n");
497 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
499 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
501 "[BTCoex], SCO + PAN(EDR)\n");
502 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
506 if (bt_link_info
->hid_exist
&&
507 bt_link_info
->a2dp_exist
) {
508 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
509 "[BTCoex], HID + A2DP\n");
510 algorithm
= BT_8821A_2ANT_COEX_ALGO_HID_A2DP
;
511 } else if (bt_link_info
->hid_exist
&&
512 bt_link_info
->pan_exist
) {
514 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
516 "[BTCoex], HID + PAN(HS)\n");
517 algorithm
= BT_8821A_2ANT_COEX_ALGO_HID
;
519 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
521 "[BTCoex], HID + PAN(EDR)\n");
523 BT_8821A_2ANT_COEX_ALGO_PANEDR_HID
;
525 } else if (bt_link_info
->pan_exist
&&
526 bt_link_info
->a2dp_exist
) {
528 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
530 "[BTCoex], A2DP + PAN(HS)\n");
532 BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS
;
534 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
536 "[BTCoex], A2DP + PAN(EDR)\n");
538 BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP
;
542 } else if (num_of_diff_profile
== 3) {
543 if (bt_link_info
->sco_exist
) {
544 if (bt_link_info
->hid_exist
&&
545 bt_link_info
->a2dp_exist
) {
546 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
547 "[BTCoex], SCO + HID + A2DP ==> HID\n");
548 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
549 } else if (bt_link_info
->hid_exist
&&
550 bt_link_info
->pan_exist
) {
552 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
554 "[BTCoex], SCO + HID + PAN(HS)\n");
555 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
557 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
559 "[BTCoex], SCO + HID + PAN(EDR)\n");
560 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
562 } else if (bt_link_info
->pan_exist
&&
563 bt_link_info
->a2dp_exist
) {
565 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
567 "[BTCoex], SCO + A2DP + PAN(HS)\n");
568 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
570 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
572 "[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n");
573 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
577 if (bt_link_info
->hid_exist
&&
578 bt_link_info
->pan_exist
&&
579 bt_link_info
->a2dp_exist
) {
581 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
583 "[BTCoex], HID + A2DP + PAN(HS)\n");
585 BT_8821A_2ANT_COEX_ALGO_HID_A2DP
;
587 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
589 "[BTCoex], HID + A2DP + PAN(EDR)\n");
591 BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR
;
595 } else if (num_of_diff_profile
>= 3) {
596 if (bt_link_info
->sco_exist
) {
597 if (bt_link_info
->hid_exist
&&
598 bt_link_info
->pan_exist
&&
599 bt_link_info
->a2dp_exist
) {
601 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
603 "[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n");
606 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
608 "[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n");
609 algorithm
= BT_8821A_2ANT_COEX_ALGO_SCO
;
617 static void btc8821a2ant_set_fw_dac_swing_lvl(struct btc_coexist
*btcoexist
,
620 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
621 u8 h2c_parameter
[1] = {0};
623 /* There are several type of dacswing
624 * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
626 h2c_parameter
[0] = dac_swing_lvl
;
628 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
629 "[BTCoex], Set Dac Swing Level = 0x%x\n", dac_swing_lvl
);
630 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
631 "[BTCoex], FW write 0x64 = 0x%x\n", h2c_parameter
[0]);
633 btcoexist
->btc_fill_h2c(btcoexist
, 0x64, 1, h2c_parameter
);
636 static void btc8821a2ant_set_fw_dec_bt_pwr(struct btc_coexist
*btcoexist
,
639 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
640 u8 h2c_parameter
[1] = {0};
642 h2c_parameter
[0] = dec_bt_pwr_lvl
;
644 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
645 "[BTCoex], decrease Bt Power Level : %u, FW write 0x62 = 0x%x\n",
646 dec_bt_pwr_lvl
, h2c_parameter
[0]);
648 btcoexist
->btc_fill_h2c(btcoexist
, 0x62, 1, h2c_parameter
);
651 static void btc8821a2ant_dec_bt_pwr(struct btc_coexist
*btcoexist
,
652 bool force_exec
, u8 dec_bt_pwr_lvl
)
654 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
656 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
657 "[BTCoex], %s Dec BT power level = %u\n",
658 (force_exec
? "force to" : ""), dec_bt_pwr_lvl
);
659 coex_dm
->cur_dec_bt_pwr_lvl
= dec_bt_pwr_lvl
;
662 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
663 "[BTCoex], pre_dec_bt_pwr_lvl = %d, cur_dec_bt_pwr_lvl = %d\n",
664 coex_dm
->pre_dec_bt_pwr_lvl
,
665 coex_dm
->cur_dec_bt_pwr_lvl
);
667 if (coex_dm
->pre_dec_bt_pwr_lvl
== coex_dm
->cur_dec_bt_pwr_lvl
)
670 btc8821a2ant_set_fw_dec_bt_pwr(btcoexist
, coex_dm
->cur_dec_bt_pwr_lvl
);
672 coex_dm
->pre_dec_bt_pwr_lvl
= coex_dm
->cur_dec_bt_pwr_lvl
;
675 static void btc8821a2ant_fw_dac_swing_lvl(struct btc_coexist
*btcoexist
,
676 bool force_exec
, u8 fw_dac_swing_lvl
)
678 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
680 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
681 "[BTCoex], %s set FW Dac Swing level = %d\n",
682 (force_exec
? "force to" : ""), fw_dac_swing_lvl
);
683 coex_dm
->cur_fw_dac_swing_lvl
= fw_dac_swing_lvl
;
686 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
687 "[BTCoex], pre_fw_dac_swing_lvl = %d, cur_fw_dac_swing_lvl = %d\n",
688 coex_dm
->pre_fw_dac_swing_lvl
,
689 coex_dm
->cur_fw_dac_swing_lvl
);
691 if (coex_dm
->pre_fw_dac_swing_lvl
==
692 coex_dm
->cur_fw_dac_swing_lvl
)
696 btc8821a2ant_set_fw_dac_swing_lvl(btcoexist
,
697 coex_dm
->cur_fw_dac_swing_lvl
);
699 coex_dm
->pre_fw_dac_swing_lvl
= coex_dm
->cur_fw_dac_swing_lvl
;
702 static void btc8821a2ant_set_sw_penalty_tx_rate_adaptive(
703 struct btc_coexist
*btcoexist
, bool low_penalty_ra
)
705 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
706 u8 h2c_parameter
[6] = {0};
708 h2c_parameter
[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */
710 if (low_penalty_ra
) {
711 h2c_parameter
[1] |= BIT0
;
712 /* normal rate except MCS7/6/5, OFDM54/48/36 */
713 h2c_parameter
[2] = 0x00;
715 h2c_parameter
[3] = 0xf5;
717 h2c_parameter
[4] = 0xa0;
719 h2c_parameter
[5] = 0xa0;
722 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
723 "[BTCoex], set WiFi Low-Penalty Retry: %s",
724 (low_penalty_ra
? "ON!!" : "OFF!!"));
726 btcoexist
->btc_fill_h2c(btcoexist
, 0x69, 6, h2c_parameter
);
729 static void btc8821a2ant_low_penalty_ra(struct btc_coexist
*btcoexist
,
730 bool force_exec
, bool low_penalty_ra
)
732 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
734 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
735 "[BTCoex], %s turn LowPenaltyRA = %s\n",
736 (force_exec
? "force to" : ""),
737 ((low_penalty_ra
) ? "ON" : "OFF"));
738 coex_dm
->cur_low_penalty_ra
= low_penalty_ra
;
741 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
742 "[BTCoex], pre_low_penalty_ra = %d, cur_low_penalty_ra = %d\n",
743 coex_dm
->pre_low_penalty_ra
,
744 coex_dm
->cur_low_penalty_ra
);
746 if (coex_dm
->pre_low_penalty_ra
== coex_dm
->cur_low_penalty_ra
)
749 btc8821a2ant_set_sw_penalty_tx_rate_adaptive(btcoexist
,
750 coex_dm
->cur_low_penalty_ra
);
752 coex_dm
->pre_low_penalty_ra
= coex_dm
->cur_low_penalty_ra
;
755 static void btc8821a2ant_set_dac_swing_reg(struct btc_coexist
*btcoexist
,
758 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
761 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
762 "[BTCoex], Write SwDacSwing = 0x%x\n", level
);
763 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0xc5b, 0x3e, val
);
766 static void btc8821a2ant_set_sw_full_dac_swing(struct btc_coexist
*btcoexist
,
767 bool sw_dac_swing_on
,
768 u32 sw_dac_swing_lvl
)
771 btc8821a2ant_set_dac_swing_reg(btcoexist
, sw_dac_swing_lvl
);
773 btc8821a2ant_set_dac_swing_reg(btcoexist
, 0x18);
776 static void btc8821a2ant_dac_swing(struct btc_coexist
*btcoexist
,
777 bool force_exec
, bool dac_swing_on
,
780 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
782 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
783 "[BTCoex], %s turn DacSwing = %s, dac_swing_lvl = 0x%x\n",
784 (force_exec
? "force to" : ""),
785 ((dac_swing_on
) ? "ON" : "OFF"),
787 coex_dm
->cur_dac_swing_on
= dac_swing_on
;
788 coex_dm
->cur_dac_swing_lvl
= dac_swing_lvl
;
791 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
792 "[BTCoex], pre_dac_swing_on = %d, pre_dac_swing_lvl = 0x%x, cur_dac_swing_on = %d, cur_dac_swing_lvl = 0x%x\n",
793 coex_dm
->pre_dac_swing_on
,
794 coex_dm
->pre_dac_swing_lvl
,
795 coex_dm
->cur_dac_swing_on
,
796 coex_dm
->cur_dac_swing_lvl
);
798 if ((coex_dm
->pre_dac_swing_on
== coex_dm
->cur_dac_swing_on
) &&
799 (coex_dm
->pre_dac_swing_lvl
==
800 coex_dm
->cur_dac_swing_lvl
))
804 btc8821a2ant_set_sw_full_dac_swing(btcoexist
, dac_swing_on
,
807 coex_dm
->pre_dac_swing_on
= coex_dm
->cur_dac_swing_on
;
808 coex_dm
->pre_dac_swing_lvl
= coex_dm
->cur_dac_swing_lvl
;
811 static void btc8821a2ant_set_coex_table(struct btc_coexist
*btcoexist
,
812 u32 val0x6c0
, u32 val0x6c4
,
813 u32 val0x6c8
, u8 val0x6cc
)
815 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
817 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
818 "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0
);
819 btcoexist
->btc_write_4byte(btcoexist
, 0x6c0, val0x6c0
);
821 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
822 "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4
);
823 btcoexist
->btc_write_4byte(btcoexist
, 0x6c4, val0x6c4
);
825 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
826 "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8
);
827 btcoexist
->btc_write_4byte(btcoexist
, 0x6c8, val0x6c8
);
829 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
830 "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc
);
831 btcoexist
->btc_write_1byte(btcoexist
, 0x6cc, val0x6cc
);
834 static void btc8821a2ant_coex_table(struct btc_coexist
*btcoexist
,
835 bool force_exec
, u32 val0x6c0
,
836 u32 val0x6c4
, u32 val0x6c8
, u8 val0x6cc
)
838 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
840 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
841 "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n",
842 (force_exec
? "force to" : ""),
843 val0x6c0
, val0x6c4
, val0x6c8
, val0x6cc
);
844 coex_dm
->cur_val0x6c0
= val0x6c0
;
845 coex_dm
->cur_val0x6c4
= val0x6c4
;
846 coex_dm
->cur_val0x6c8
= val0x6c8
;
847 coex_dm
->cur_val0x6cc
= val0x6cc
;
850 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
851 "[BTCoex], pre_val0x6c0 = 0x%x, pre_val0x6c4 = 0x%x, pre_val0x6c8 = 0x%x, pre_val0x6cc = 0x%x !!\n",
852 coex_dm
->pre_val0x6c0
,
853 coex_dm
->pre_val0x6c4
,
854 coex_dm
->pre_val0x6c8
,
855 coex_dm
->pre_val0x6cc
);
856 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
857 "[BTCoex], cur_val0x6c0 = 0x%x, cur_val0x6c4 = 0x%x, cur_val0x6c8 = 0x%x, cur_val0x6cc = 0x%x !!\n",
858 coex_dm
->cur_val0x6c0
,
859 coex_dm
->cur_val0x6c4
,
860 coex_dm
->cur_val0x6c8
,
861 coex_dm
->cur_val0x6cc
);
863 if ((coex_dm
->pre_val0x6c0
== coex_dm
->cur_val0x6c0
) &&
864 (coex_dm
->pre_val0x6c4
== coex_dm
->cur_val0x6c4
) &&
865 (coex_dm
->pre_val0x6c8
== coex_dm
->cur_val0x6c8
) &&
866 (coex_dm
->pre_val0x6cc
== coex_dm
->cur_val0x6cc
))
869 btc8821a2ant_set_coex_table(btcoexist
, val0x6c0
, val0x6c4
, val0x6c8
,
872 coex_dm
->pre_val0x6c0
= coex_dm
->cur_val0x6c0
;
873 coex_dm
->pre_val0x6c4
= coex_dm
->cur_val0x6c4
;
874 coex_dm
->pre_val0x6c8
= coex_dm
->cur_val0x6c8
;
875 coex_dm
->pre_val0x6cc
= coex_dm
->cur_val0x6cc
;
878 static void btc8821a2ant_coex_table_with_type(struct btc_coexist
*btcoexist
,
879 bool force_exec
, u8 type
)
881 coex_sta
->coex_table_type
= type
;
885 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55555555,
886 0x55555555, 0xffffff, 0x3);
889 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55555555,
890 0x5afa5afa, 0xffffff, 0x3);
893 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x5ada5ada,
894 0x5ada5ada, 0xffffff, 0x3);
897 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0xaaaaaaaa,
898 0xaaaaaaaa, 0xffffff, 0x3);
901 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0xffffffff,
902 0xffffffff, 0xffffff, 0x3);
905 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x5fff5fff,
906 0x5fff5fff, 0xffffff, 0x3);
909 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55ff55ff,
910 0x5a5a5a5a, 0xffffff, 0x3);
913 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55dd55dd,
914 0x5ada5ada, 0xffffff, 0x3);
917 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55dd55dd,
918 0x5ada5ada, 0xffffff, 0x3);
921 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55dd55dd,
922 0x5ada5ada, 0xffffff, 0x3);
925 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55dd55dd,
926 0x5ada5ada, 0xffffff, 0x3);
929 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55dd55dd,
930 0x5ada5ada, 0xffffff, 0x3);
933 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55dd55dd,
934 0x5ada5ada, 0xffffff, 0x3);
937 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x5fff5fff,
938 0xaaaaaaaa, 0xffffff, 0x3);
941 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x5fff5fff,
942 0x5ada5ada, 0xffffff, 0x3);
945 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x55dd55dd,
946 0xaaaaaaaa, 0xffffff, 0x3);
949 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0x5fdf5fdf,
950 0x5fdb5fdb, 0xffffff, 0x3);
953 btc8821a2ant_coex_table(btcoexist
, force_exec
, 0xfafafafa,
954 0xfafafafa, 0xffffff, 0x3);
961 static void btc8821a2ant_set_fw_ignore_wlan_act(struct btc_coexist
*btcoex
,
964 struct rtl_priv
*rtlpriv
= btcoex
->adapter
;
965 u8 h2c_parameter
[1] = {0};
968 h2c_parameter
[0] |= BIT0
; /* function enable */
970 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
971 "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n",
974 btcoex
->btc_fill_h2c(btcoex
, 0x63, 1, h2c_parameter
);
977 static void btc8821a2ant_set_lps_rpwm(struct btc_coexist
*btcoexist
, u8 lps_val
,
983 btcoexist
->btc_set(btcoexist
, BTC_SET_U1_LPS_VAL
, &lps
);
984 btcoexist
->btc_set(btcoexist
, BTC_SET_U1_RPWM_VAL
, &rpwm
);
987 static void btc8821a2ant_lps_rpwm(struct btc_coexist
*btcoexist
,
988 bool force_exec
, u8 lps_val
, u8 rpwm_val
)
990 coex_dm
->cur_lps
= lps_val
;
991 coex_dm
->cur_rpwm
= rpwm_val
;
994 if ((coex_dm
->pre_lps
== coex_dm
->cur_lps
) &&
995 (coex_dm
->pre_rpwm
== coex_dm
->cur_rpwm
))
998 btc8821a2ant_set_lps_rpwm(btcoexist
, lps_val
, rpwm_val
);
1000 coex_dm
->pre_lps
= coex_dm
->cur_lps
;
1001 coex_dm
->pre_rpwm
= coex_dm
->cur_rpwm
;
1004 static void btc8821a2ant_ignore_wlan_act(struct btc_coexist
*btcoexist
,
1005 bool force_exec
, bool enable
)
1007 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1009 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1010 "[BTCoex], %s turn Ignore WlanAct %s\n",
1011 (force_exec
? "force to" : ""), (enable
? "ON" : "OFF"));
1012 coex_dm
->cur_ignore_wlan_act
= enable
;
1015 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1016 "[BTCoex], pre_ignore_wlan_act = %d, cur_ignore_wlan_act = %d!!\n",
1017 coex_dm
->pre_ignore_wlan_act
,
1018 coex_dm
->cur_ignore_wlan_act
);
1020 if (coex_dm
->pre_ignore_wlan_act
==
1021 coex_dm
->cur_ignore_wlan_act
)
1024 btc8821a2ant_set_fw_ignore_wlan_act(btcoexist
, enable
);
1026 coex_dm
->pre_ignore_wlan_act
= coex_dm
->cur_ignore_wlan_act
;
1029 static void btc8821a2ant_set_fw_ps_tdma(struct btc_coexist
*btcoexist
,
1030 u8 byte1
, u8 byte2
, u8 byte3
,
1033 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1034 u8 h2c_parameter
[5];
1036 h2c_parameter
[0] = byte1
;
1037 h2c_parameter
[1] = byte2
;
1038 h2c_parameter
[2] = byte3
;
1039 h2c_parameter
[3] = byte4
;
1040 h2c_parameter
[4] = byte5
;
1042 coex_dm
->ps_tdma_para
[0] = byte1
;
1043 coex_dm
->ps_tdma_para
[1] = byte2
;
1044 coex_dm
->ps_tdma_para
[2] = byte3
;
1045 coex_dm
->ps_tdma_para
[3] = byte4
;
1046 coex_dm
->ps_tdma_para
[4] = byte5
;
1048 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1049 "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n",
1051 h2c_parameter
[1] << 24 |
1052 h2c_parameter
[2] << 16 |
1053 h2c_parameter
[3] << 8 |
1056 btcoexist
->btc_fill_h2c(btcoexist
, 0x60, 5, h2c_parameter
);
1059 static void btc8821a2ant_sw_mechanism1(struct btc_coexist
*btcoexist
,
1060 bool shrink_rx_lpf
, bool low_penalty_ra
,
1061 bool limited_dig
, bool bt_lna_constrain
)
1063 btc8821a2ant_low_penalty_ra(btcoexist
, NORMAL_EXEC
, low_penalty_ra
);
1066 static void btc8821a2ant_sw_mechanism2(struct btc_coexist
*btcoexist
,
1067 bool agc_table_shift
, bool adc_back_off
,
1068 bool sw_dac_swing
, u32 dac_swing_lvl
)
1070 btc8821a2ant_dac_swing(btcoexist
, NORMAL_EXEC
, sw_dac_swing
,
1074 static void btc8821a2ant_set_ant_path(struct btc_coexist
*btcoexist
,
1075 u8 ant_pos_type
, bool init_hw_cfg
,
1078 struct btc_board_info
*board_info
= &btcoexist
->board_info
;
1080 u8 h2c_parameter
[2] = {0};
1083 /* 0x4c[23] = 0, 0x4c[24] = 1 Antenna control by WL/BT */
1084 u4tmp
= btcoexist
->btc_read_4byte(btcoexist
, 0x4c);
1087 btcoexist
->btc_write_4byte(btcoexist
, 0x4c, u4tmp
);
1089 btcoexist
->btc_write_4byte(btcoexist
, 0x974, 0x3ff);
1091 if (board_info
->btdm_ant_pos
== BTC_ANTENNA_AT_MAIN_PORT
) {
1092 /* tell firmware "antenna inverse" ==> WRONG firmware
1093 * antenna control code ==>need fw to fix
1095 h2c_parameter
[0] = 1;
1096 h2c_parameter
[1] = 1;
1097 btcoexist
->btc_fill_h2c(btcoexist
, 0x65, 2,
1100 /* tell firmware "no antenna inverse" ==> WRONG firmware
1101 * antenna control code ==>need fw to fix
1103 h2c_parameter
[0] = 0;
1104 h2c_parameter
[1] = 1;
1105 btcoexist
->btc_fill_h2c(btcoexist
, 0x65, 2,
1110 /* ext switch setting */
1111 switch (ant_pos_type
) {
1112 case BTC_ANT_WIFI_AT_MAIN
:
1113 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0xcb7, 0x30, 0x1);
1115 case BTC_ANT_WIFI_AT_AUX
:
1116 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0xcb7, 0x30, 0x2);
1121 static void btc8821a2ant_ps_tdma(struct btc_coexist
*btcoexist
,
1122 bool force_exec
, bool turn_on
, u8 type
)
1124 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1126 u8 wifi_rssi_state
, bt_rssi_state
;
1128 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
1129 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
1130 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
, 2,
1131 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
1133 if (!(BTC_RSSI_HIGH(wifi_rssi_state
) &&
1134 BTC_RSSI_HIGH(bt_rssi_state
)) &&
1136 /* for WiFi RSSI low or BT RSSI low */
1140 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1141 "[BTCoex], %s turn %s PS TDMA, type = %d\n",
1142 (force_exec
? "force to" : ""), (turn_on
? "ON" : "OFF"),
1144 coex_dm
->cur_ps_tdma_on
= turn_on
;
1145 coex_dm
->cur_ps_tdma
= type
;
1148 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1149 "[BTCoex], pre_ps_tdma_on = %d, cur_ps_tdma_on = %d!!\n",
1150 coex_dm
->pre_ps_tdma_on
, coex_dm
->cur_ps_tdma_on
);
1151 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1152 "[BTCoex], pre_ps_tdma = %d, cur_ps_tdma = %d!!\n",
1153 coex_dm
->pre_ps_tdma
, coex_dm
->cur_ps_tdma
);
1155 if ((coex_dm
->pre_ps_tdma_on
== coex_dm
->cur_ps_tdma_on
) &&
1156 (coex_dm
->pre_ps_tdma
== coex_dm
->cur_ps_tdma
))
1163 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x3c,
1167 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x2d,
1171 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1c,
1175 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x10,
1179 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x3c,
1183 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x2d,
1187 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1c,
1191 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xa3, 0x10,
1195 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x3c,
1199 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x2d,
1203 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1c,
1207 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x10,
1211 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x3c,
1215 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x2d,
1219 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1c,
1223 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x10,
1227 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xa3, 0x2f,
1231 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x5, 0x5,
1235 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x25,
1239 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x25,
1243 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x15,
1247 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1e,
1252 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xd3, 0x3c,
1256 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x14,
1260 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x30,
1264 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x3c,
1270 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xd3, 0x3a,
1277 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xd3, 0x2d,
1284 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xd3, 0x1c,
1291 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xd3, 0x10,
1295 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x3c,
1299 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x3c,
1303 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x15,
1308 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x35,
1312 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xd3, 0x1c,
1316 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xd3, 0x14,
1320 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0xd3, 0x30,
1325 /* disable PS tdma */
1328 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0x0, 0x0, 0x0,
1332 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0x0, 0x0, 0x0,
1336 btc8821a2ant_set_fw_ps_tdma(btcoexist
, 0x0, 0x0, 0x0,
1342 /* update pre state */
1343 coex_dm
->pre_ps_tdma_on
= coex_dm
->cur_ps_tdma_on
;
1344 coex_dm
->pre_ps_tdma
= coex_dm
->cur_ps_tdma
;
1348 btc8821a2ant_ps_tdma_check_for_power_save_state(struct btc_coexist
*btcoexist
,
1353 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_LPS_MODE
, &lps_mode
);
1356 /* already under LPS state */
1358 /* keep state under LPS, do nothing */
1360 /* will leave LPS state, turn off psTdma first */
1361 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1366 /* will enter LPS state, turn off psTdma first */
1367 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1369 /* keep state under NO PS state, do nothing */
1374 static void btc8821a2ant_power_save_state(struct btc_coexist
*btcoexist
,
1375 u8 ps_type
, u8 lps_val
, u8 rpwm_val
)
1377 bool low_pwr_disable
= false;
1380 case BTC_PS_WIFI_NATIVE
:
1381 /* recover to original 32k low power setting */
1382 low_pwr_disable
= false;
1383 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_DISABLE_LOW_POWER
,
1385 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_NORMAL_LPS
, NULL
);
1386 coex_sta
->force_lps_on
= false;
1389 btc8821a2ant_ps_tdma_check_for_power_save_state(btcoexist
,
1391 btc8821a2ant_lps_rpwm(btcoexist
, NORMAL_EXEC
, lps_val
,
1393 /* when coex force to enter LPS, do not enter 32k low power */
1394 low_pwr_disable
= true;
1395 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_DISABLE_LOW_POWER
,
1397 /* power save must executed before psTdma */
1398 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_ENTER_LPS
, NULL
);
1399 coex_sta
->force_lps_on
= true;
1401 case BTC_PS_LPS_OFF
:
1402 btc8821a2ant_ps_tdma_check_for_power_save_state(btcoexist
,
1404 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_LEAVE_LPS
, NULL
);
1405 coex_sta
->force_lps_on
= false;
1412 static void btc8821a2ant_coex_all_off(struct btc_coexist
*btcoexist
)
1415 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
, 0x0, 0x0);
1416 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1417 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1418 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1421 btc8821a2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1422 btc8821a2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1425 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
1428 static void btc8821a2ant_coex_under_5g(struct btc_coexist
*btcoexist
)
1430 btc8821a2ant_coex_all_off(btcoexist
);
1431 btc8821a2ant_ignore_wlan_act(btcoexist
, NORMAL_EXEC
, true);
1434 static void btc8821a2ant_init_coex_dm(struct btc_coexist
*btcoexist
)
1436 /* force to reset coex mechanism */
1437 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
1439 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
, 0x0, 0x0);
1440 btc8821a2ant_ps_tdma(btcoexist
, FORCE_EXEC
, false, 1);
1441 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, FORCE_EXEC
, 6);
1442 btc8821a2ant_dec_bt_pwr(btcoexist
, FORCE_EXEC
, 0);
1444 btc8821a2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1445 btc8821a2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1448 static void btc8821a2ant_action_bt_inquiry(struct btc_coexist
*btcoexist
)
1450 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1451 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
1452 bool wifi_connected
= false;
1453 bool low_pwr_disable
= true;
1454 bool scan
= false, link
= false, roam
= false;
1457 btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
1458 wifi_rssi_state1
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
1459 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
1460 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
1461 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
1463 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_DISABLE_LOW_POWER
,
1465 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
1468 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_SCAN
, &scan
);
1469 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_LINK
, &link
);
1470 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_ROAM
, &roam
);
1472 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
, 0x0, 0x0);
1474 if (scan
|| link
|| roam
) {
1475 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1476 "[BTCoex], Wifi link process + BT Inq/Page!!\n");
1477 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 15);
1478 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 22);
1479 } else if (wifi_connected
) {
1480 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1481 "[BTCoex], Wifi connected + BT Inq/Page!!\n");
1482 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 15);
1483 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 22);
1485 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1486 "[BTCoex], Wifi no-link + BT Inq/Page!!\n");
1487 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
1488 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1491 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, FORCE_EXEC
, 6);
1492 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1494 btc8821a2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1495 btc8821a2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1498 static void btc8821a2ant_action_wifi_link_process(struct btc_coexist
*btcoexist
)
1500 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1503 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 15);
1504 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 22);
1506 btc8821a2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1507 btc8821a2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1509 u8tmpa
= btcoexist
->btc_read_1byte(btcoexist
, 0x765);
1510 u8tmpb
= btcoexist
->btc_read_1byte(btcoexist
, 0x76e);
1512 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1513 "[BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u8tmpa
, u8tmpb
);
1516 static bool btc8821a2ant_action_wifi_idle_process(struct btc_coexist
*btcoexist
)
1518 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1519 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
1523 btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
1524 wifi_rssi_state1
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
1525 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
- 20, 0);
1526 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
1527 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
1529 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_AP_NUM
, &ap_num
);
1531 /* define the office environment */
1532 if (BTC_RSSI_HIGH(wifi_rssi_state1
) && (coex_sta
->hid_exist
) &&
1533 (coex_sta
->a2dp_exist
)) {
1534 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1535 "[BTCoex], Wifi idle process for BT HID+A2DP exist!!\n");
1537 btc8821a2ant_dac_swing(btcoexist
, NORMAL_EXEC
, true, 0x6);
1538 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1541 btc8821a2ant_sw_mechanism1(btcoexist
, false, false, false,
1543 btc8821a2ant_sw_mechanism2(btcoexist
, false, false, false,
1546 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
1547 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
1549 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1552 } else if (coex_sta
->pan_exist
) {
1553 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1554 "[BTCoex], Wifi idle process for BT PAN exist!!\n");
1556 btc8821a2ant_dac_swing(btcoexist
, NORMAL_EXEC
, true, 0x6);
1557 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1560 btc8821a2ant_sw_mechanism1(btcoexist
, false, false, false,
1562 btc8821a2ant_sw_mechanism2(btcoexist
, false, false, false,
1565 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
1566 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
1568 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1572 btc8821a2ant_dac_swing(btcoexist
, NORMAL_EXEC
, true, 0x18);
1576 static bool btc8821a2ant_is_common_action(struct btc_coexist
*btcoexist
)
1578 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1579 bool common
= false, wifi_connected
= false, wifi_busy
= false;
1580 bool low_pwr_disable
= false;
1581 bool bt_hs_on
= false;
1583 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
1584 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
1586 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
1588 if (!wifi_connected
) {
1589 low_pwr_disable
= false;
1590 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_DISABLE_LOW_POWER
,
1592 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false,
1595 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1596 "[BTCoex], Wifi non-connected idle!!\n");
1598 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff,
1600 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
1601 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
1603 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1604 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1605 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1607 btc8821a2ant_sw_mechanism1(btcoexist
, false, false, false,
1609 btc8821a2ant_sw_mechanism2(btcoexist
, false, false, false,
1614 if (BT_8821A_2ANT_BT_STATUS_IDLE
==
1615 coex_dm
->bt_status
) {
1616 low_pwr_disable
= false;
1617 btcoexist
->btc_set(btcoexist
,
1618 BTC_SET_ACT_DISABLE_LOW_POWER
,
1620 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
,
1623 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1624 "[BTCoex], Wifi connected + BT non connected-idle!!\n");
1626 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1,
1628 btc8821a2ant_coex_table_with_type(btcoexist
,
1631 btc8821a2ant_power_save_state(
1632 btcoexist
, BTC_PS_WIFI_NATIVE
, 0x0, 0x0);
1633 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1634 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
,
1636 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1638 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
1640 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
1644 } else if (BT_8821A_2ANT_BT_STATUS_CON_IDLE
==
1645 coex_dm
->bt_status
) {
1646 low_pwr_disable
= true;
1647 btcoexist
->btc_set(btcoexist
,
1648 BTC_SET_ACT_DISABLE_LOW_POWER
,
1653 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1654 "[BTCoex], Wifi connected + BT connected-idle!!\n");
1655 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
,
1658 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1,
1660 btc8821a2ant_coex_table_with_type(btcoexist
,
1663 btc8821a2ant_power_save_state(
1664 btcoexist
, BTC_PS_WIFI_NATIVE
, 0x0, 0x0);
1665 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1666 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
,
1668 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
1670 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
1672 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
1676 low_pwr_disable
= true;
1677 btcoexist
->btc_set(btcoexist
,
1678 BTC_SET_ACT_DISABLE_LOW_POWER
,
1682 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1683 "[BTCoex], Wifi Connected-Busy + BT Busy!!\n");
1686 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1687 "[BTCoex], Wifi Connected-Idle + BT Busy!!\n");
1689 btc8821a2ant_action_wifi_idle_process(
1697 static void btc8821a2ant_tdma_duration_adjust(struct btc_coexist
*btcoexist
,
1698 bool sco_hid
, bool tx_pause
,
1701 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1702 static long up
, dn
, m
, n
, wait_count
;
1704 * +1: increase WiFi duration
1705 * -1: decrease WiFi duration
1710 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1711 "[BTCoex], TdmaDurationAdjust()\n");
1713 if (coex_dm
->auto_tdma_adjust
) {
1714 coex_dm
->auto_tdma_adjust
= false;
1715 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1716 "[BTCoex], first run TdmaDurationAdjust()!!\n");
1719 if (max_interval
== 1) {
1720 btc8821a2ant_ps_tdma(btcoexist
,
1721 NORMAL_EXEC
, true, 13);
1722 coex_dm
->ps_tdma_du_adj_type
= 13;
1723 } else if (max_interval
== 2) {
1724 btc8821a2ant_ps_tdma(btcoexist
,
1725 NORMAL_EXEC
, true, 14);
1726 coex_dm
->ps_tdma_du_adj_type
= 14;
1727 } else if (max_interval
== 3) {
1728 btc8821a2ant_ps_tdma(btcoexist
,
1729 NORMAL_EXEC
, true, 15);
1730 coex_dm
->ps_tdma_du_adj_type
= 15;
1732 btc8821a2ant_ps_tdma(btcoexist
,
1733 NORMAL_EXEC
, true, 15);
1734 coex_dm
->ps_tdma_du_adj_type
= 15;
1737 if (max_interval
== 1) {
1738 btc8821a2ant_ps_tdma(btcoexist
,
1739 NORMAL_EXEC
, true, 9);
1740 coex_dm
->ps_tdma_du_adj_type
= 9;
1741 } else if (max_interval
== 2) {
1742 btc8821a2ant_ps_tdma(btcoexist
,
1743 NORMAL_EXEC
, true, 10);
1744 coex_dm
->ps_tdma_du_adj_type
= 10;
1745 } else if (max_interval
== 3) {
1746 btc8821a2ant_ps_tdma(btcoexist
,
1747 NORMAL_EXEC
, true, 11);
1748 coex_dm
->ps_tdma_du_adj_type
= 11;
1750 btc8821a2ant_ps_tdma(btcoexist
,
1751 NORMAL_EXEC
, true, 11);
1752 coex_dm
->ps_tdma_du_adj_type
= 11;
1757 if (max_interval
== 1) {
1758 btc8821a2ant_ps_tdma(btcoexist
,
1759 NORMAL_EXEC
, true, 5);
1760 coex_dm
->ps_tdma_du_adj_type
= 5;
1761 } else if (max_interval
== 2) {
1762 btc8821a2ant_ps_tdma(btcoexist
,
1763 NORMAL_EXEC
, true, 6);
1764 coex_dm
->ps_tdma_du_adj_type
= 6;
1765 } else if (max_interval
== 3) {
1766 btc8821a2ant_ps_tdma(btcoexist
,
1767 NORMAL_EXEC
, true, 7);
1768 coex_dm
->ps_tdma_du_adj_type
= 7;
1770 btc8821a2ant_ps_tdma(btcoexist
,
1771 NORMAL_EXEC
, true, 7);
1772 coex_dm
->ps_tdma_du_adj_type
= 7;
1775 if (max_interval
== 1) {
1776 btc8821a2ant_ps_tdma(btcoexist
,
1777 NORMAL_EXEC
, true, 1);
1778 coex_dm
->ps_tdma_du_adj_type
= 1;
1779 } else if (max_interval
== 2) {
1780 btc8821a2ant_ps_tdma(btcoexist
,
1781 NORMAL_EXEC
, true, 2);
1782 coex_dm
->ps_tdma_du_adj_type
= 2;
1783 } else if (max_interval
== 3) {
1784 btc8821a2ant_ps_tdma(btcoexist
,
1785 NORMAL_EXEC
, true, 3);
1786 coex_dm
->ps_tdma_du_adj_type
= 3;
1788 btc8821a2ant_ps_tdma(btcoexist
,
1789 NORMAL_EXEC
, true, 3);
1790 coex_dm
->ps_tdma_du_adj_type
= 3;
1802 /* accquire the BT TRx retry count from BT_Info byte2 */
1803 retry_count
= coex_sta
->bt_retry_cnt
;
1804 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1805 "[BTCoex], retry_count = %d\n", retry_count
);
1806 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1807 "[BTCoex], up = %d, dn = %d, m = %d, n = %d, wait_count = %d\n",
1808 (int)up
, (int)dn
, (int)m
, (int)n
, (int)wait_count
);
1812 if (retry_count
== 0) {
1813 /* no retry in the last 2-second duration */
1821 /* if (retry count == 0) for 2*n seconds,
1822 * make WiFi duration wider
1829 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1830 "[BTCoex], Increase wifi duration!!\n");
1832 } else if (retry_count
<= 3) {
1833 /* <=3 retry in the last 2-second duration */
1841 /* if retry count < 3 for 2*2 seconds,
1842 * shrink wifi duration
1844 if (wait_count
<= 2)
1845 m
++; /* avoid bounce in two levels */
1848 /* m max value is 20, max time is 120 second,
1849 * recheck if adjust WiFi duration.
1859 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1860 "[BTCoex], Decrease wifi duration for retryCounter<3!!\n");
1863 /* retry count > 3, if retry count > 3 happens once,
1864 * shrink WiFi duration
1866 if (wait_count
== 1)
1867 m
++; /* avoid bounce in two levels */
1870 /* m max value is 20, max time is 120 second,
1871 * recheck if adjust WiFi duration.
1881 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1882 "[BTCoex], Decrease wifi duration for retryCounter>3!!\n");
1885 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1886 "[BTCoex], max Interval = %d\n", max_interval
);
1888 if (max_interval
== 1) {
1890 if (coex_dm
->cur_ps_tdma
== 71) {
1891 btc8821a2ant_ps_tdma(btcoexist
,
1892 NORMAL_EXEC
, true, 5);
1893 coex_dm
->ps_tdma_du_adj_type
= 5;
1894 } else if (coex_dm
->cur_ps_tdma
== 1) {
1895 btc8821a2ant_ps_tdma(btcoexist
,
1896 NORMAL_EXEC
, true, 5);
1897 coex_dm
->ps_tdma_du_adj_type
= 5;
1898 } else if (coex_dm
->cur_ps_tdma
== 2) {
1899 btc8821a2ant_ps_tdma(btcoexist
,
1900 NORMAL_EXEC
, true, 6);
1901 coex_dm
->ps_tdma_du_adj_type
= 6;
1902 } else if (coex_dm
->cur_ps_tdma
== 3) {
1903 btc8821a2ant_ps_tdma(btcoexist
,
1904 NORMAL_EXEC
, true, 7);
1905 coex_dm
->ps_tdma_du_adj_type
= 7;
1906 } else if (coex_dm
->cur_ps_tdma
== 4) {
1907 btc8821a2ant_ps_tdma(btcoexist
,
1908 NORMAL_EXEC
, true, 8);
1909 coex_dm
->ps_tdma_du_adj_type
= 8;
1911 if (coex_dm
->cur_ps_tdma
== 9) {
1912 btc8821a2ant_ps_tdma(btcoexist
,
1913 NORMAL_EXEC
, true, 13);
1914 coex_dm
->ps_tdma_du_adj_type
= 13;
1915 } else if (coex_dm
->cur_ps_tdma
== 10) {
1916 btc8821a2ant_ps_tdma(btcoexist
,
1917 NORMAL_EXEC
, true, 14);
1918 coex_dm
->ps_tdma_du_adj_type
= 14;
1919 } else if (coex_dm
->cur_ps_tdma
== 11) {
1920 btc8821a2ant_ps_tdma(btcoexist
,
1921 NORMAL_EXEC
, true, 15);
1922 coex_dm
->ps_tdma_du_adj_type
= 15;
1923 } else if (coex_dm
->cur_ps_tdma
== 12) {
1924 btc8821a2ant_ps_tdma(btcoexist
,
1925 NORMAL_EXEC
, true, 16);
1926 coex_dm
->ps_tdma_du_adj_type
= 16;
1930 if (coex_dm
->cur_ps_tdma
== 5) {
1931 btc8821a2ant_ps_tdma(
1932 btcoexist
, NORMAL_EXEC
,
1934 coex_dm
->ps_tdma_du_adj_type
=
1936 } else if (coex_dm
->cur_ps_tdma
== 6) {
1937 btc8821a2ant_ps_tdma(
1938 btcoexist
, NORMAL_EXEC
,
1940 coex_dm
->ps_tdma_du_adj_type
=
1942 } else if (coex_dm
->cur_ps_tdma
== 7) {
1943 btc8821a2ant_ps_tdma(
1944 btcoexist
, NORMAL_EXEC
,
1946 coex_dm
->ps_tdma_du_adj_type
=
1948 } else if (coex_dm
->cur_ps_tdma
== 13) {
1949 btc8821a2ant_ps_tdma(
1950 btcoexist
, NORMAL_EXEC
,
1952 coex_dm
->ps_tdma_du_adj_type
=
1954 } else if (coex_dm
->cur_ps_tdma
== 14) {
1955 btc8821a2ant_ps_tdma(
1956 btcoexist
, NORMAL_EXEC
,
1958 coex_dm
->ps_tdma_du_adj_type
=
1960 } else if (coex_dm
->cur_ps_tdma
== 15) {
1961 btc8821a2ant_ps_tdma(
1962 btcoexist
, NORMAL_EXEC
,
1964 coex_dm
->ps_tdma_du_adj_type
=
1967 } else if (result
== 1) {
1968 if (coex_dm
->cur_ps_tdma
== 8) {
1969 btc8821a2ant_ps_tdma(
1970 btcoexist
, NORMAL_EXEC
,
1972 coex_dm
->ps_tdma_du_adj_type
=
1974 } else if (coex_dm
->cur_ps_tdma
== 7) {
1975 btc8821a2ant_ps_tdma(
1976 btcoexist
, NORMAL_EXEC
,
1978 coex_dm
->ps_tdma_du_adj_type
=
1980 } else if (coex_dm
->cur_ps_tdma
== 6) {
1981 btc8821a2ant_ps_tdma(
1982 btcoexist
, NORMAL_EXEC
,
1984 coex_dm
->ps_tdma_du_adj_type
=
1986 } else if (coex_dm
->cur_ps_tdma
== 16) {
1987 btc8821a2ant_ps_tdma(
1988 btcoexist
, NORMAL_EXEC
,
1990 coex_dm
->ps_tdma_du_adj_type
=
1992 } else if (coex_dm
->cur_ps_tdma
== 15) {
1993 btc8821a2ant_ps_tdma(
1994 btcoexist
, NORMAL_EXEC
,
1996 coex_dm
->ps_tdma_du_adj_type
=
1998 } else if (coex_dm
->cur_ps_tdma
== 14) {
1999 btc8821a2ant_ps_tdma(
2000 btcoexist
, NORMAL_EXEC
,
2002 coex_dm
->ps_tdma_du_adj_type
=
2007 if (coex_dm
->cur_ps_tdma
== 5) {
2008 btc8821a2ant_ps_tdma(btcoexist
,
2009 NORMAL_EXEC
, true, 71);
2010 coex_dm
->ps_tdma_du_adj_type
= 71;
2011 } else if (coex_dm
->cur_ps_tdma
== 6) {
2012 btc8821a2ant_ps_tdma(btcoexist
,
2013 NORMAL_EXEC
, true, 2);
2014 coex_dm
->ps_tdma_du_adj_type
= 2;
2015 } else if (coex_dm
->cur_ps_tdma
== 7) {
2016 btc8821a2ant_ps_tdma(btcoexist
,
2017 NORMAL_EXEC
, true, 3);
2018 coex_dm
->ps_tdma_du_adj_type
= 3;
2019 } else if (coex_dm
->cur_ps_tdma
== 8) {
2020 btc8821a2ant_ps_tdma(btcoexist
,
2021 NORMAL_EXEC
, true, 4);
2022 coex_dm
->ps_tdma_du_adj_type
= 4;
2024 if (coex_dm
->cur_ps_tdma
== 13) {
2025 btc8821a2ant_ps_tdma(btcoexist
,
2026 NORMAL_EXEC
, true, 9);
2027 coex_dm
->ps_tdma_du_adj_type
= 9;
2028 } else if (coex_dm
->cur_ps_tdma
== 14) {
2029 btc8821a2ant_ps_tdma(btcoexist
,
2030 NORMAL_EXEC
, true, 10);
2031 coex_dm
->ps_tdma_du_adj_type
= 10;
2032 } else if (coex_dm
->cur_ps_tdma
== 15) {
2033 btc8821a2ant_ps_tdma(btcoexist
,
2034 NORMAL_EXEC
, true, 11);
2035 coex_dm
->ps_tdma_du_adj_type
= 11;
2036 } else if (coex_dm
->cur_ps_tdma
== 16) {
2037 btc8821a2ant_ps_tdma(btcoexist
,
2038 NORMAL_EXEC
, true, 12);
2039 coex_dm
->ps_tdma_du_adj_type
= 12;
2043 if (coex_dm
->cur_ps_tdma
== 71) {
2044 btc8821a2ant_ps_tdma(
2045 btcoexist
, NORMAL_EXEC
,
2047 coex_dm
->ps_tdma_du_adj_type
=
2049 } else if (coex_dm
->cur_ps_tdma
== 1) {
2050 btc8821a2ant_ps_tdma(
2051 btcoexist
, NORMAL_EXEC
,
2053 coex_dm
->ps_tdma_du_adj_type
=
2055 } else if (coex_dm
->cur_ps_tdma
== 2) {
2056 btc8821a2ant_ps_tdma(
2057 btcoexist
, NORMAL_EXEC
,
2059 coex_dm
->ps_tdma_du_adj_type
=
2061 } else if (coex_dm
->cur_ps_tdma
== 3) {
2062 btc8821a2ant_ps_tdma(
2063 btcoexist
, NORMAL_EXEC
,
2065 coex_dm
->ps_tdma_du_adj_type
=
2067 } else if (coex_dm
->cur_ps_tdma
== 9) {
2068 btc8821a2ant_ps_tdma(
2069 btcoexist
, NORMAL_EXEC
,
2071 coex_dm
->ps_tdma_du_adj_type
=
2073 } else if (coex_dm
->cur_ps_tdma
== 10) {
2074 btc8821a2ant_ps_tdma(
2075 btcoexist
, NORMAL_EXEC
,
2077 coex_dm
->ps_tdma_du_adj_type
=
2079 } else if (coex_dm
->cur_ps_tdma
== 11) {
2080 btc8821a2ant_ps_tdma(
2081 btcoexist
, NORMAL_EXEC
,
2083 coex_dm
->ps_tdma_du_adj_type
=
2086 } else if (result
== 1) {
2087 if (coex_dm
->cur_ps_tdma
== 4) {
2088 btc8821a2ant_ps_tdma(
2089 btcoexist
, NORMAL_EXEC
,
2091 coex_dm
->ps_tdma_du_adj_type
=
2093 } else if (coex_dm
->cur_ps_tdma
== 3) {
2094 btc8821a2ant_ps_tdma(
2095 btcoexist
, NORMAL_EXEC
,
2097 coex_dm
->ps_tdma_du_adj_type
=
2099 } else if (coex_dm
->cur_ps_tdma
== 2) {
2100 btc8821a2ant_ps_tdma(
2101 btcoexist
, NORMAL_EXEC
,
2103 coex_dm
->ps_tdma_du_adj_type
=
2105 } else if (coex_dm
->cur_ps_tdma
== 1) {
2106 btc8821a2ant_ps_tdma(
2107 btcoexist
, NORMAL_EXEC
,
2109 coex_dm
->ps_tdma_du_adj_type
=
2111 } else if (coex_dm
->cur_ps_tdma
== 12) {
2112 btc8821a2ant_ps_tdma(
2113 btcoexist
, NORMAL_EXEC
,
2115 coex_dm
->ps_tdma_du_adj_type
=
2117 } else if (coex_dm
->cur_ps_tdma
== 11) {
2118 btc8821a2ant_ps_tdma(
2119 btcoexist
, NORMAL_EXEC
,
2121 coex_dm
->ps_tdma_du_adj_type
=
2123 } else if (coex_dm
->cur_ps_tdma
== 10) {
2124 btc8821a2ant_ps_tdma(
2125 btcoexist
, NORMAL_EXEC
,
2127 coex_dm
->ps_tdma_du_adj_type
=
2132 } else if (max_interval
== 2) {
2134 if (coex_dm
->cur_ps_tdma
== 1) {
2135 btc8821a2ant_ps_tdma(btcoexist
,
2136 NORMAL_EXEC
, true, 6);
2137 coex_dm
->ps_tdma_du_adj_type
= 6;
2138 } else if (coex_dm
->cur_ps_tdma
== 2) {
2139 btc8821a2ant_ps_tdma(btcoexist
,
2140 NORMAL_EXEC
, true, 6);
2141 coex_dm
->ps_tdma_du_adj_type
= 6;
2142 } else if (coex_dm
->cur_ps_tdma
== 3) {
2143 btc8821a2ant_ps_tdma(btcoexist
,
2144 NORMAL_EXEC
, true, 7);
2145 coex_dm
->ps_tdma_du_adj_type
= 7;
2146 } else if (coex_dm
->cur_ps_tdma
== 4) {
2147 btc8821a2ant_ps_tdma(btcoexist
,
2148 NORMAL_EXEC
, true, 8);
2149 coex_dm
->ps_tdma_du_adj_type
= 8;
2151 if (coex_dm
->cur_ps_tdma
== 9) {
2152 btc8821a2ant_ps_tdma(btcoexist
,
2153 NORMAL_EXEC
, true, 14);
2154 coex_dm
->ps_tdma_du_adj_type
= 14;
2155 } else if (coex_dm
->cur_ps_tdma
== 10) {
2156 btc8821a2ant_ps_tdma(btcoexist
,
2157 NORMAL_EXEC
, true, 14);
2158 coex_dm
->ps_tdma_du_adj_type
= 14;
2159 } else if (coex_dm
->cur_ps_tdma
== 11) {
2160 btc8821a2ant_ps_tdma(btcoexist
,
2161 NORMAL_EXEC
, true, 15);
2162 coex_dm
->ps_tdma_du_adj_type
= 15;
2163 } else if (coex_dm
->cur_ps_tdma
== 12) {
2164 btc8821a2ant_ps_tdma(btcoexist
,
2165 NORMAL_EXEC
, true, 16);
2166 coex_dm
->ps_tdma_du_adj_type
= 16;
2169 if (coex_dm
->cur_ps_tdma
== 5) {
2170 btc8821a2ant_ps_tdma(
2171 btcoexist
, NORMAL_EXEC
,
2173 coex_dm
->ps_tdma_du_adj_type
=
2175 } else if (coex_dm
->cur_ps_tdma
== 6) {
2176 btc8821a2ant_ps_tdma(
2177 btcoexist
, NORMAL_EXEC
,
2179 coex_dm
->ps_tdma_du_adj_type
=
2181 } else if (coex_dm
->cur_ps_tdma
== 7) {
2182 btc8821a2ant_ps_tdma(
2183 btcoexist
, NORMAL_EXEC
,
2185 coex_dm
->ps_tdma_du_adj_type
=
2187 } else if (coex_dm
->cur_ps_tdma
== 13) {
2188 btc8821a2ant_ps_tdma(
2189 btcoexist
, NORMAL_EXEC
,
2191 coex_dm
->ps_tdma_du_adj_type
=
2193 } else if (coex_dm
->cur_ps_tdma
== 14) {
2194 btc8821a2ant_ps_tdma(
2195 btcoexist
, NORMAL_EXEC
,
2197 coex_dm
->ps_tdma_du_adj_type
=
2199 } else if (coex_dm
->cur_ps_tdma
== 15) {
2200 btc8821a2ant_ps_tdma(
2201 btcoexist
, NORMAL_EXEC
,
2203 coex_dm
->ps_tdma_du_adj_type
=
2206 } else if (result
== 1) {
2207 if (coex_dm
->cur_ps_tdma
== 8) {
2208 btc8821a2ant_ps_tdma(
2209 btcoexist
, NORMAL_EXEC
,
2211 coex_dm
->ps_tdma_du_adj_type
=
2213 } else if (coex_dm
->cur_ps_tdma
== 7) {
2214 btc8821a2ant_ps_tdma(
2215 btcoexist
, NORMAL_EXEC
,
2217 coex_dm
->ps_tdma_du_adj_type
=
2219 } else if (coex_dm
->cur_ps_tdma
== 6) {
2220 btc8821a2ant_ps_tdma(
2221 btcoexist
, NORMAL_EXEC
,
2223 coex_dm
->ps_tdma_du_adj_type
=
2225 } else if (coex_dm
->cur_ps_tdma
== 16) {
2226 btc8821a2ant_ps_tdma(
2227 btcoexist
, NORMAL_EXEC
,
2229 coex_dm
->ps_tdma_du_adj_type
=
2231 } else if (coex_dm
->cur_ps_tdma
== 15) {
2232 btc8821a2ant_ps_tdma(
2233 btcoexist
, NORMAL_EXEC
,
2235 coex_dm
->ps_tdma_du_adj_type
=
2237 } else if (coex_dm
->cur_ps_tdma
== 14) {
2238 btc8821a2ant_ps_tdma(
2239 btcoexist
, NORMAL_EXEC
,
2241 coex_dm
->ps_tdma_du_adj_type
=
2246 if (coex_dm
->cur_ps_tdma
== 5) {
2247 btc8821a2ant_ps_tdma(btcoexist
,
2248 NORMAL_EXEC
, true, 2);
2249 coex_dm
->ps_tdma_du_adj_type
= 2;
2250 } else if (coex_dm
->cur_ps_tdma
== 6) {
2251 btc8821a2ant_ps_tdma(btcoexist
,
2252 NORMAL_EXEC
, true, 2);
2253 coex_dm
->ps_tdma_du_adj_type
= 2;
2254 } else if (coex_dm
->cur_ps_tdma
== 7) {
2255 btc8821a2ant_ps_tdma(btcoexist
,
2256 NORMAL_EXEC
, true, 3);
2257 coex_dm
->ps_tdma_du_adj_type
= 3;
2258 } else if (coex_dm
->cur_ps_tdma
== 8) {
2259 btc8821a2ant_ps_tdma(btcoexist
,
2260 NORMAL_EXEC
, true, 4);
2261 coex_dm
->ps_tdma_du_adj_type
= 4;
2263 if (coex_dm
->cur_ps_tdma
== 13) {
2264 btc8821a2ant_ps_tdma(btcoexist
,
2265 NORMAL_EXEC
, true, 10);
2266 coex_dm
->ps_tdma_du_adj_type
= 10;
2267 } else if (coex_dm
->cur_ps_tdma
== 14) {
2268 btc8821a2ant_ps_tdma(btcoexist
,
2269 NORMAL_EXEC
, true, 10);
2270 coex_dm
->ps_tdma_du_adj_type
= 10;
2271 } else if (coex_dm
->cur_ps_tdma
== 15) {
2272 btc8821a2ant_ps_tdma(btcoexist
,
2273 NORMAL_EXEC
, true, 11);
2274 coex_dm
->ps_tdma_du_adj_type
= 11;
2275 } else if (coex_dm
->cur_ps_tdma
== 16) {
2276 btc8821a2ant_ps_tdma(btcoexist
,
2277 NORMAL_EXEC
, true, 12);
2278 coex_dm
->ps_tdma_du_adj_type
= 12;
2281 if (coex_dm
->cur_ps_tdma
== 1) {
2282 btc8821a2ant_ps_tdma(
2283 btcoexist
, NORMAL_EXEC
,
2285 coex_dm
->ps_tdma_du_adj_type
=
2287 } else if (coex_dm
->cur_ps_tdma
== 2) {
2288 btc8821a2ant_ps_tdma(
2289 btcoexist
, NORMAL_EXEC
,
2291 coex_dm
->ps_tdma_du_adj_type
=
2293 } else if (coex_dm
->cur_ps_tdma
== 3) {
2294 btc8821a2ant_ps_tdma(
2295 btcoexist
, NORMAL_EXEC
,
2297 coex_dm
->ps_tdma_du_adj_type
=
2299 } else if (coex_dm
->cur_ps_tdma
== 9) {
2300 btc8821a2ant_ps_tdma(
2301 btcoexist
, NORMAL_EXEC
,
2303 coex_dm
->ps_tdma_du_adj_type
=
2305 } else if (coex_dm
->cur_ps_tdma
== 10) {
2306 btc8821a2ant_ps_tdma(
2307 btcoexist
, NORMAL_EXEC
,
2309 coex_dm
->ps_tdma_du_adj_type
=
2311 } else if (coex_dm
->cur_ps_tdma
== 11) {
2312 btc8821a2ant_ps_tdma(
2313 btcoexist
, NORMAL_EXEC
,
2315 coex_dm
->ps_tdma_du_adj_type
=
2318 } else if (result
== 1) {
2319 if (coex_dm
->cur_ps_tdma
== 4) {
2320 btc8821a2ant_ps_tdma(
2321 btcoexist
, NORMAL_EXEC
,
2323 coex_dm
->ps_tdma_du_adj_type
=
2325 } else if (coex_dm
->cur_ps_tdma
== 3) {
2326 btc8821a2ant_ps_tdma(
2327 btcoexist
, NORMAL_EXEC
,
2329 coex_dm
->ps_tdma_du_adj_type
=
2331 } else if (coex_dm
->cur_ps_tdma
== 2) {
2332 btc8821a2ant_ps_tdma(
2333 btcoexist
, NORMAL_EXEC
,
2335 coex_dm
->ps_tdma_du_adj_type
=
2337 } else if (coex_dm
->cur_ps_tdma
== 12) {
2338 btc8821a2ant_ps_tdma(
2339 btcoexist
, NORMAL_EXEC
,
2341 coex_dm
->ps_tdma_du_adj_type
=
2343 } else if (coex_dm
->cur_ps_tdma
== 11) {
2344 btc8821a2ant_ps_tdma(
2345 btcoexist
, NORMAL_EXEC
,
2347 coex_dm
->ps_tdma_du_adj_type
=
2349 } else if (coex_dm
->cur_ps_tdma
== 10) {
2350 btc8821a2ant_ps_tdma(
2351 btcoexist
, NORMAL_EXEC
,
2353 coex_dm
->ps_tdma_du_adj_type
=
2358 } else if (max_interval
== 3) {
2360 if (coex_dm
->cur_ps_tdma
== 1) {
2361 btc8821a2ant_ps_tdma(btcoexist
,
2362 NORMAL_EXEC
, true, 7);
2363 coex_dm
->ps_tdma_du_adj_type
= 7;
2364 } else if (coex_dm
->cur_ps_tdma
== 2) {
2365 btc8821a2ant_ps_tdma(btcoexist
,
2366 NORMAL_EXEC
, true, 7);
2367 coex_dm
->ps_tdma_du_adj_type
= 7;
2368 } else if (coex_dm
->cur_ps_tdma
== 3) {
2369 btc8821a2ant_ps_tdma(btcoexist
,
2370 NORMAL_EXEC
, true, 7);
2371 coex_dm
->ps_tdma_du_adj_type
= 7;
2372 } else if (coex_dm
->cur_ps_tdma
== 4) {
2373 btc8821a2ant_ps_tdma(btcoexist
,
2374 NORMAL_EXEC
, true, 8);
2375 coex_dm
->ps_tdma_du_adj_type
= 8;
2377 if (coex_dm
->cur_ps_tdma
== 9) {
2378 btc8821a2ant_ps_tdma(btcoexist
,
2379 NORMAL_EXEC
, true, 15);
2380 coex_dm
->ps_tdma_du_adj_type
= 15;
2381 } else if (coex_dm
->cur_ps_tdma
== 10) {
2382 btc8821a2ant_ps_tdma(btcoexist
,
2383 NORMAL_EXEC
, true, 15);
2384 coex_dm
->ps_tdma_du_adj_type
= 15;
2385 } else if (coex_dm
->cur_ps_tdma
== 11) {
2386 btc8821a2ant_ps_tdma(btcoexist
,
2387 NORMAL_EXEC
, true, 15);
2388 coex_dm
->ps_tdma_du_adj_type
= 15;
2389 } else if (coex_dm
->cur_ps_tdma
== 12) {
2390 btc8821a2ant_ps_tdma(btcoexist
,
2391 NORMAL_EXEC
, true, 16);
2392 coex_dm
->ps_tdma_du_adj_type
= 16;
2395 if (coex_dm
->cur_ps_tdma
== 5) {
2396 btc8821a2ant_ps_tdma(
2397 btcoexist
, NORMAL_EXEC
,
2399 coex_dm
->ps_tdma_du_adj_type
=
2401 } else if (coex_dm
->cur_ps_tdma
== 6) {
2402 btc8821a2ant_ps_tdma(
2403 btcoexist
, NORMAL_EXEC
,
2405 coex_dm
->ps_tdma_du_adj_type
=
2407 } else if (coex_dm
->cur_ps_tdma
== 7) {
2408 btc8821a2ant_ps_tdma(
2409 btcoexist
, NORMAL_EXEC
,
2411 coex_dm
->ps_tdma_du_adj_type
=
2413 } else if (coex_dm
->cur_ps_tdma
== 13) {
2414 btc8821a2ant_ps_tdma(
2415 btcoexist
, NORMAL_EXEC
,
2417 coex_dm
->ps_tdma_du_adj_type
=
2419 } else if (coex_dm
->cur_ps_tdma
== 14) {
2420 btc8821a2ant_ps_tdma(
2421 btcoexist
, NORMAL_EXEC
,
2423 coex_dm
->ps_tdma_du_adj_type
=
2425 } else if (coex_dm
->cur_ps_tdma
== 15) {
2426 btc8821a2ant_ps_tdma(
2427 btcoexist
, NORMAL_EXEC
,
2429 coex_dm
->ps_tdma_du_adj_type
=
2432 } else if (result
== 1) {
2433 if (coex_dm
->cur_ps_tdma
== 8) {
2434 btc8821a2ant_ps_tdma(
2435 btcoexist
, NORMAL_EXEC
,
2437 coex_dm
->ps_tdma_du_adj_type
=
2439 } else if (coex_dm
->cur_ps_tdma
== 7) {
2440 btc8821a2ant_ps_tdma(
2441 btcoexist
, NORMAL_EXEC
,
2443 coex_dm
->ps_tdma_du_adj_type
=
2445 } else if (coex_dm
->cur_ps_tdma
== 6) {
2446 btc8821a2ant_ps_tdma(
2447 btcoexist
, NORMAL_EXEC
,
2449 coex_dm
->ps_tdma_du_adj_type
=
2451 } else if (coex_dm
->cur_ps_tdma
== 16) {
2452 btc8821a2ant_ps_tdma(
2453 btcoexist
, NORMAL_EXEC
,
2455 coex_dm
->ps_tdma_du_adj_type
=
2457 } else if (coex_dm
->cur_ps_tdma
== 15) {
2458 btc8821a2ant_ps_tdma(
2459 btcoexist
, NORMAL_EXEC
,
2461 coex_dm
->ps_tdma_du_adj_type
=
2463 } else if (coex_dm
->cur_ps_tdma
== 14) {
2464 btc8821a2ant_ps_tdma(
2465 btcoexist
, NORMAL_EXEC
,
2467 coex_dm
->ps_tdma_du_adj_type
=
2472 if (coex_dm
->cur_ps_tdma
== 5) {
2473 btc8821a2ant_ps_tdma(btcoexist
,
2474 NORMAL_EXEC
, true, 3);
2475 coex_dm
->ps_tdma_du_adj_type
= 3;
2476 } else if (coex_dm
->cur_ps_tdma
== 6) {
2477 btc8821a2ant_ps_tdma(btcoexist
,
2478 NORMAL_EXEC
, true, 3);
2479 coex_dm
->ps_tdma_du_adj_type
= 3;
2480 } else if (coex_dm
->cur_ps_tdma
== 7) {
2481 btc8821a2ant_ps_tdma(btcoexist
,
2482 NORMAL_EXEC
, true, 3);
2483 coex_dm
->ps_tdma_du_adj_type
= 3;
2484 } else if (coex_dm
->cur_ps_tdma
== 8) {
2485 btc8821a2ant_ps_tdma(btcoexist
,
2486 NORMAL_EXEC
, true, 4);
2487 coex_dm
->ps_tdma_du_adj_type
= 4;
2489 if (coex_dm
->cur_ps_tdma
== 13) {
2490 btc8821a2ant_ps_tdma(btcoexist
,
2491 NORMAL_EXEC
, true, 11);
2492 coex_dm
->ps_tdma_du_adj_type
= 11;
2493 } else if (coex_dm
->cur_ps_tdma
== 14) {
2494 btc8821a2ant_ps_tdma(btcoexist
,
2495 NORMAL_EXEC
, true, 11);
2496 coex_dm
->ps_tdma_du_adj_type
= 11;
2497 } else if (coex_dm
->cur_ps_tdma
== 15) {
2498 btc8821a2ant_ps_tdma(btcoexist
,
2499 NORMAL_EXEC
, true, 11);
2500 coex_dm
->ps_tdma_du_adj_type
= 11;
2501 } else if (coex_dm
->cur_ps_tdma
== 16) {
2502 btc8821a2ant_ps_tdma(btcoexist
,
2503 NORMAL_EXEC
, true, 12);
2504 coex_dm
->ps_tdma_du_adj_type
= 12;
2507 if (coex_dm
->cur_ps_tdma
== 1) {
2508 btc8821a2ant_ps_tdma(
2509 btcoexist
, NORMAL_EXEC
,
2511 coex_dm
->ps_tdma_du_adj_type
=
2513 } else if (coex_dm
->cur_ps_tdma
== 2) {
2514 btc8821a2ant_ps_tdma(
2515 btcoexist
, NORMAL_EXEC
,
2517 coex_dm
->ps_tdma_du_adj_type
=
2519 } else if (coex_dm
->cur_ps_tdma
== 3) {
2520 btc8821a2ant_ps_tdma(
2521 btcoexist
, NORMAL_EXEC
,
2523 coex_dm
->ps_tdma_du_adj_type
=
2525 } else if (coex_dm
->cur_ps_tdma
== 9) {
2526 btc8821a2ant_ps_tdma(
2527 btcoexist
, NORMAL_EXEC
,
2529 coex_dm
->ps_tdma_du_adj_type
=
2531 } else if (coex_dm
->cur_ps_tdma
== 10) {
2532 btc8821a2ant_ps_tdma(
2533 btcoexist
, NORMAL_EXEC
,
2535 coex_dm
->ps_tdma_du_adj_type
=
2537 } else if (coex_dm
->cur_ps_tdma
== 11) {
2538 btc8821a2ant_ps_tdma(
2539 btcoexist
, NORMAL_EXEC
,
2541 coex_dm
->ps_tdma_du_adj_type
=
2544 } else if (result
== 1) {
2545 if (coex_dm
->cur_ps_tdma
== 4) {
2546 btc8821a2ant_ps_tdma(
2547 btcoexist
, NORMAL_EXEC
,
2549 coex_dm
->ps_tdma_du_adj_type
=
2551 } else if (coex_dm
->cur_ps_tdma
== 3) {
2552 btc8821a2ant_ps_tdma(
2553 btcoexist
, NORMAL_EXEC
,
2555 coex_dm
->ps_tdma_du_adj_type
=
2557 } else if (coex_dm
->cur_ps_tdma
== 2) {
2558 btc8821a2ant_ps_tdma(
2559 btcoexist
, NORMAL_EXEC
,
2561 coex_dm
->ps_tdma_du_adj_type
=
2563 } else if (coex_dm
->cur_ps_tdma
== 12) {
2564 btc8821a2ant_ps_tdma(
2565 btcoexist
, NORMAL_EXEC
,
2567 coex_dm
->ps_tdma_du_adj_type
=
2569 } else if (coex_dm
->cur_ps_tdma
== 11) {
2570 btc8821a2ant_ps_tdma(
2571 btcoexist
, NORMAL_EXEC
,
2573 coex_dm
->ps_tdma_du_adj_type
=
2575 } else if (coex_dm
->cur_ps_tdma
== 10) {
2576 btc8821a2ant_ps_tdma(
2577 btcoexist
, NORMAL_EXEC
,
2579 coex_dm
->ps_tdma_du_adj_type
=
2587 /* if current PsTdma not match with the recorded one
2588 * (when scan, dhcp...), then we have to adjust it back to
2589 * the previous recorded one.
2591 if (coex_dm
->cur_ps_tdma
!= coex_dm
->ps_tdma_du_adj_type
) {
2592 bool scan
= false, link
= false, roam
= false;
2594 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2595 "[BTCoex], PsTdma type mismatch!!!, cur_ps_tdma = %d, recordPsTdma = %d\n",
2596 coex_dm
->cur_ps_tdma
, coex_dm
->ps_tdma_du_adj_type
);
2598 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_SCAN
, &scan
);
2599 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_LINK
, &link
);
2600 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_ROAM
, &roam
);
2602 if (!scan
&& !link
&& !roam
) {
2603 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true,
2604 coex_dm
->ps_tdma_du_adj_type
);
2606 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
2607 "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n");
2612 /* SCO only or SCO+PAN(HS)*/
2613 static void btc8821a2ant_action_sco(struct btc_coexist
*btcoexist
)
2615 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
2616 u8 wifi_rssi_state
, bt_rssi_state
;
2619 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2620 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
, 2, 35, 0);
2622 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2624 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2625 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 4);
2627 if (BTC_RSSI_HIGH(bt_rssi_state
))
2628 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2630 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2632 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2634 if (wifi_bw
== BTC_WIFI_BW_LEGACY
) {
2635 /* for SCO quality at 11b/g mode */
2636 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 2);
2638 /* for SCO quality & wifi performance balance at 11n mode */
2639 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
2640 btc8821a2ant_coex_table_with_type(btcoexist
,
2643 if (bt_link_info
->sco_only
)
2644 btc8821a2ant_coex_table_with_type(
2645 btcoexist
, NORMAL_EXEC
, 17);
2647 btc8821a2ant_coex_table_with_type(
2648 btcoexist
, NORMAL_EXEC
, 12);
2652 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
, 0x0, 0x0);
2653 /* for voice quality */
2654 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 0);
2657 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
2658 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2659 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2660 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
2662 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2665 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
2667 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2671 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2672 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2673 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
2675 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2678 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
2680 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2686 static void btc8821a2ant_action_hid(struct btc_coexist
*btcoexist
)
2688 u8 wifi_rssi_state
, bt_rssi_state
;
2691 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2692 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
2693 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
2695 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2697 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2698 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2700 if (BTC_RSSI_HIGH(bt_rssi_state
))
2701 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2703 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2705 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2707 if (wifi_bw
== BTC_WIFI_BW_LEGACY
) {
2708 /* for HID at 11b/g mode */
2709 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 7);
2711 /* for HID quality & wifi performance balance at 11n mode */
2712 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 2);
2715 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
, 0x0, 0x0);
2716 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 24);
2718 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
2720 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2721 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2722 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
2724 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2727 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
2729 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2734 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2735 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2736 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
2738 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2741 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
2743 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2749 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
2750 static void btc8821a2ant_action_a2dp(struct btc_coexist
*btcoexist
)
2752 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
2756 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2757 wifi_rssi_state1
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
2758 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
2759 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
2760 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
2762 if ((ap_num
>= 10) && BTC_RSSI_HIGH(wifi_rssi_state1
) &&
2763 BTC_RSSI_HIGH(bt_rssi_state
)) {
2764 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
2767 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff,
2769 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false,
2771 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2772 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2774 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
2776 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
2778 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 23);
2781 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2782 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
2783 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
2785 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2788 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
2790 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2796 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2797 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2799 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2801 if (BTC_RSSI_HIGH(bt_rssi_state
))
2802 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2804 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
2806 if (BTC_RSSI_HIGH(wifi_rssi_state1
) && BTC_RSSI_HIGH(bt_rssi_state
)) {
2807 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 7);
2808 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
2811 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 13);
2812 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_LPS_ON
, 0x50,
2816 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2817 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2818 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 23);
2820 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 23);
2824 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2825 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
2826 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2827 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2828 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
2830 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2833 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
2835 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2839 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2840 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2841 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
2843 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2846 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
2848 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2854 static void btc8821a2ant_action_a2dp_pan_hs(struct btc_coexist
*btcoexist
)
2856 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
2859 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2860 wifi_rssi_state1
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
2861 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
2862 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
2863 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
2865 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2867 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2868 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2870 if (BTC_RSSI_HIGH(bt_rssi_state
))
2871 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
2873 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
2875 if (BTC_RSSI_HIGH(wifi_rssi_state1
) && BTC_RSSI_HIGH(bt_rssi_state
)) {
2876 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 7);
2877 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
2880 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 13);
2881 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_LPS_ON
, 0x50,
2885 btc8821a2ant_tdma_duration_adjust(btcoexist
, false, true, 2);
2888 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2889 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
2890 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2891 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2892 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
2894 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2897 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
2899 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2903 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2904 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2905 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
2907 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2910 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
2912 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2918 static void btc8821a2ant_action_pan_edr(struct btc_coexist
*btcoexist
)
2920 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
2923 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2924 wifi_rssi_state1
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
2925 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
2926 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
2927 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
2929 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2931 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
2933 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2935 if (BTC_RSSI_HIGH(bt_rssi_state
))
2936 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2938 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2940 if (BTC_RSSI_HIGH(wifi_rssi_state1
) && BTC_RSSI_HIGH(bt_rssi_state
)) {
2941 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 10);
2942 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
2945 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 13);
2946 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_LPS_ON
, 0x50,
2950 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2951 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
))
2952 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 26);
2954 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 26);
2957 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2958 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
2959 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2960 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2961 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
2963 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2966 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
2968 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2972 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2973 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2974 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
2976 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
2979 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
2981 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
2988 static void btc8821a2ant_action_pan_hs(struct btc_coexist
*btcoexist
)
2990 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
2993 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
2994 wifi_rssi_state1
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
2995 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
2996 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
2997 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
2999 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
3001 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
3002 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
3004 if (BTC_RSSI_HIGH(bt_rssi_state
))
3005 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
3007 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
3009 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 7);
3010 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
, 0x0, 0x0);
3011 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
3013 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
3014 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
3015 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3016 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3017 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
3019 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3022 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
3024 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3028 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3029 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3030 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
3032 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3035 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
3037 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3044 static void btc8821a2ant_action_pan_edr_a2dp(struct btc_coexist
*btcoexist
)
3046 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
3049 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
3050 wifi_rssi_state1
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
3051 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
3052 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
3053 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
3055 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
3057 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
3059 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
3061 if (BTC_RSSI_HIGH(bt_rssi_state
))
3062 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
3064 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
3066 if (BTC_RSSI_HIGH(wifi_rssi_state1
) && BTC_RSSI_HIGH(bt_rssi_state
))
3067 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
3070 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_LPS_ON
, 0x50,
3073 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
3075 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3076 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3077 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 12);
3079 if (wifi_bw
== BTC_WIFI_BW_HT40
)
3080 btc8821a2ant_tdma_duration_adjust(btcoexist
, false,
3083 btc8821a2ant_tdma_duration_adjust(btcoexist
, false,
3086 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 13);
3087 btc8821a2ant_tdma_duration_adjust(btcoexist
, false, true, 3);
3091 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
3092 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3093 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3094 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
3096 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3099 btc8821a2ant_sw_mechanism1(btcoexist
, true, false,
3101 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3105 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3106 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3107 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
3109 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3112 btc8821a2ant_sw_mechanism1(btcoexist
, false, false,
3114 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3120 static void btc8821a2ant_action_pan_edr_hid(struct btc_coexist
*btcoexist
)
3122 u8 wifi_rssi_state
, bt_rssi_state
;
3125 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
3126 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
3127 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
3129 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
3131 if (BTC_RSSI_HIGH(bt_rssi_state
))
3132 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
3134 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
3136 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
3138 if (wifi_bw
== BTC_WIFI_BW_LEGACY
) {
3139 /* for HID at 11b/g mode */
3140 btc8821a2ant_coex_table(btcoexist
, NORMAL_EXEC
, 0x55ff55ff,
3141 0x5a5f5a5f, 0xffff, 0x3);
3143 /* for HID quality & wifi performance balance at 11n mode */
3144 btc8821a2ant_coex_table(btcoexist
, NORMAL_EXEC
, 0x55ff55ff,
3145 0x5a5f5a5f, 0xffff, 0x3);
3148 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
3149 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 3);
3151 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3152 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3153 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
3156 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 14);
3160 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3161 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3162 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
3164 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3167 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
3169 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3173 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
3175 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3176 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3177 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 10);
3179 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 14);
3183 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3184 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3185 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
3187 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3190 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
3192 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3198 /* HID+A2DP+PAN(EDR) */
3199 static void btc8821a2ant_act_hid_a2dp_pan_edr(struct btc_coexist
*btcoexist
)
3201 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
3204 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
3205 wifi_rssi_state1
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
3206 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
3207 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
3208 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 0);
3210 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
3212 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, false, 0x8);
3213 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
3215 if (BTC_RSSI_HIGH(bt_rssi_state
))
3216 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
3218 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
3220 if (BTC_RSSI_HIGH(wifi_rssi_state1
) && BTC_RSSI_HIGH(bt_rssi_state
)) {
3221 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 7);
3222 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
3225 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 14);
3226 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_LPS_ON
, 0x50,
3230 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
3232 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3233 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3234 if (wifi_bw
== BTC_WIFI_BW_HT40
)
3235 btc8821a2ant_tdma_duration_adjust(btcoexist
, true,
3238 btc8821a2ant_tdma_duration_adjust(btcoexist
, true,
3241 btc8821a2ant_tdma_duration_adjust(btcoexist
, true, true, 3);
3245 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
3246 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3247 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3248 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
3250 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3253 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
3255 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3259 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3260 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3261 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
3263 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3266 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
3268 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3274 static void btc8821a2ant_action_hid_a2dp(struct btc_coexist
*btcoexist
)
3277 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
3280 wifi_rssi_state
= btc8821a2ant_wifi_rssi_state(btcoexist
, 0, 2, 15, 0);
3281 wifi_rssi_state1
= btc8821a2ant_wifi_rssi_state(btcoexist
, 1, 2,
3282 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES
, 0);
3283 bt_rssi_state
= btc8821a2ant_bt_rssi_state(btcoexist
,
3284 3, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES
, 37);
3286 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
3288 btc8821a2ant_limited_rx(btcoexist
, NORMAL_EXEC
, false, true, 0x5);
3289 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
3291 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
3292 if (wifi_bw
== BTC_WIFI_BW_LEGACY
) {
3293 if (BTC_RSSI_HIGH(bt_rssi_state
))
3294 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
3295 else if (BTC_RSSI_MEDIUM(bt_rssi_state
))
3296 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
3298 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
3300 /* only 802.11N mode we have to dec bt power to 4 degree */
3301 if (BTC_RSSI_HIGH(bt_rssi_state
)) {
3302 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_AP_NUM
,
3305 btc8821a2ant_dec_bt_pwr(btcoexist
,
3308 btc8821a2ant_dec_bt_pwr(btcoexist
,
3310 } else if (BTC_RSSI_MEDIUM(bt_rssi_state
)) {
3311 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 2);
3313 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
3317 if (wifi_bw
== BTC_WIFI_BW_LEGACY
) {
3318 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 7);
3319 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
,
3322 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 14);
3323 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_LPS_ON
, 0x50,
3327 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3328 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3329 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 23);
3331 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 23);
3335 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
3336 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3337 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3338 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
3340 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3343 btc8821a2ant_sw_mechanism1(btcoexist
, true, true,
3345 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3349 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
3350 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
3351 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
3353 btc8821a2ant_sw_mechanism2(btcoexist
, true, false,
3356 btc8821a2ant_sw_mechanism1(btcoexist
, false, true,
3358 btc8821a2ant_sw_mechanism2(btcoexist
, false, false,
3364 static void btc8821a2ant_action_wifi_multi_port(struct btc_coexist
*btcoexist
)
3366 btc8821a2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
3367 btc8821a2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, 0);
3370 btc8821a2ant_sw_mechanism1(btcoexist
, false, false, false, false);
3371 btc8821a2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
3374 btc8821a2ant_coex_table_with_type(btcoexist
, NORMAL_EXEC
, 0);
3376 btc8821a2ant_power_save_state(btcoexist
, BTC_PS_WIFI_NATIVE
, 0x0, 0x0);
3377 btc8821a2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
3380 static void btc8821a2ant_run_coexist_mechanism(struct btc_coexist
*btcoexist
)
3382 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3383 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
3384 bool wifi_under_5g
= false;
3386 u32 num_of_wifi_link
= 0;
3387 u32 wifi_link_status
= 0;
3388 bool miracast_plus_bt
= false;
3389 bool scan
= false, link
= false, roam
= false;
3391 if (btcoexist
->manual_control
) {
3392 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3393 "[BTCoex], Manual control!!!\n");
3397 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_UNDER_5G
, &wifi_under_5g
);
3399 if (wifi_under_5g
) {
3400 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3401 "[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n");
3402 btc8821a2ant_coex_under_5g(btcoexist
);
3406 if (coex_sta
->under_ips
) {
3407 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3408 "[BTCoex], wifi is under IPS !!!\n");
3412 algorithm
= btc8821a2ant_action_algorithm(btcoexist
);
3413 if (coex_sta
->c2h_bt_inquiry_page
&&
3414 (BT_8821A_2ANT_COEX_ALGO_PANHS
!= algorithm
)) {
3415 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3416 "[BTCoex], BT is under inquiry/page scan !!\n");
3417 btc8821a2ant_action_bt_inquiry(btcoexist
);
3421 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_SCAN
, &scan
);
3422 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_LINK
, &link
);
3423 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_ROAM
, &roam
);
3425 if (scan
|| link
|| roam
) {
3426 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3427 "[BTCoex], WiFi is under Link Process !!\n");
3428 btc8821a2ant_action_wifi_link_process(btcoexist
);
3433 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_LINK_STATUS
,
3435 num_of_wifi_link
= wifi_link_status
>> 16;
3437 if ((num_of_wifi_link
>= 2) ||
3438 (wifi_link_status
& WIFI_P2P_GO_CONNECTED
)) {
3439 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3440 "############# [BTCoex], Multi-Port num_of_wifi_link = %d, wifi_link_status = 0x%x\n",
3441 num_of_wifi_link
, wifi_link_status
);
3443 if (bt_link_info
->bt_link_exist
)
3444 miracast_plus_bt
= true;
3446 miracast_plus_bt
= false;
3448 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_MIRACAST_PLUS_BT
,
3450 btc8821a2ant_action_wifi_multi_port(btcoexist
);
3455 miracast_plus_bt
= false;
3456 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_MIRACAST_PLUS_BT
,
3459 coex_dm
->cur_algorithm
= algorithm
;
3460 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3461 "[BTCoex], Algorithm = %d\n", coex_dm
->cur_algorithm
);
3463 if (btc8821a2ant_is_common_action(btcoexist
)) {
3464 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3465 "[BTCoex], Action 2-Ant common\n");
3466 coex_dm
->auto_tdma_adjust
= true;
3468 if (coex_dm
->cur_algorithm
!= coex_dm
->pre_algorithm
) {
3469 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3470 "[BTCoex], pre_algorithm = %d, cur_algorithm = %d\n",
3471 coex_dm
->pre_algorithm
,
3472 coex_dm
->cur_algorithm
);
3473 coex_dm
->auto_tdma_adjust
= false;
3475 switch (coex_dm
->cur_algorithm
) {
3476 case BT_8821A_2ANT_COEX_ALGO_SCO
:
3477 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3478 "[BTCoex], Action 2-Ant, algorithm = SCO\n");
3479 btc8821a2ant_action_sco(btcoexist
);
3481 case BT_8821A_2ANT_COEX_ALGO_HID
:
3482 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3483 "[BTCoex], Action 2-Ant, algorithm = HID\n");
3484 btc8821a2ant_action_hid(btcoexist
);
3486 case BT_8821A_2ANT_COEX_ALGO_A2DP
:
3487 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3488 "[BTCoex], Action 2-Ant, algorithm = A2DP\n");
3489 btc8821a2ant_action_a2dp(btcoexist
);
3491 case BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS
:
3492 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3493 "[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS)\n");
3494 btc8821a2ant_action_a2dp_pan_hs(btcoexist
);
3496 case BT_8821A_2ANT_COEX_ALGO_PANEDR
:
3497 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3498 "[BTCoex], Action 2-Ant, algorithm = PAN(EDR)\n");
3499 btc8821a2ant_action_pan_edr(btcoexist
);
3501 case BT_8821A_2ANT_COEX_ALGO_PANHS
:
3502 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3503 "[BTCoex], Action 2-Ant, algorithm = HS mode\n");
3504 btc8821a2ant_action_pan_hs(btcoexist
);
3506 case BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP
:
3507 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3508 "[BTCoex], Action 2-Ant, algorithm = PAN+A2DP\n");
3509 btc8821a2ant_action_pan_edr_a2dp(btcoexist
);
3511 case BT_8821A_2ANT_COEX_ALGO_PANEDR_HID
:
3512 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3513 "[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID\n");
3514 btc8821a2ant_action_pan_edr_hid(btcoexist
);
3516 case BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR
:
3517 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3518 "[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN\n");
3519 btc8821a2ant_act_hid_a2dp_pan_edr(btcoexist
);
3521 case BT_8821A_2ANT_COEX_ALGO_HID_A2DP
:
3522 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3523 "[BTCoex], Action 2-Ant, algorithm = HID+A2DP\n");
3524 btc8821a2ant_action_hid_a2dp(btcoexist
);
3527 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3528 "[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n");
3529 btc8821a2ant_coex_all_off(btcoexist
);
3532 coex_dm
->pre_algorithm
= coex_dm
->cur_algorithm
;
3536 static void btc8821a2ant_wifi_off_hw_cfg(struct btc_coexist
*btcoexist
)
3538 u8 h2c_parameter
[2] = {0};
3541 /* set wlan_act to low */
3542 btcoexist
->btc_write_1byte(btcoexist
, 0x76e, 0x4);
3544 /* WiFi goto standby while GNT_BT 0-->1 */
3545 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x780);
3546 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_FW_VER
, &fw_ver
);
3547 if (fw_ver
>= 0x180000) {
3548 /* Use H2C to set GNT_BT to HIGH */
3549 h2c_parameter
[0] = 1;
3550 btcoexist
->btc_fill_h2c(btcoexist
, 0x6E, 1, h2c_parameter
);
3552 btcoexist
->btc_write_1byte(btcoexist
, 0x765, 0x18);
3556 /**************************************************************
3557 * extern function start with ex_btc8821a2ant_
3558 **************************************************************/
3559 void ex_btc8821a2ant_init_hwconfig(struct btc_coexist
*btcoexist
)
3561 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3564 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3565 "[BTCoex], 2Ant Init HW Config!!\n");
3567 /* backup rf 0x1e value */
3568 coex_dm
->bt_rf0x1e_backup
=
3569 btcoexist
->btc_get_rf_reg(btcoexist
, BTC_RF_A
, 0x1e, 0xfffff);
3571 /* 0x790[5:0] = 0x5 */
3572 u1tmp
= btcoexist
->btc_read_1byte(btcoexist
, 0x790);
3575 btcoexist
->btc_write_1byte(btcoexist
, 0x790, u1tmp
);
3577 /* Antenna config */
3578 btc8821a2ant_set_ant_path(btcoexist
, BTC_ANT_WIFI_AT_MAIN
, true, false);
3579 coex_sta
->dis_ver_info_cnt
= 0;
3582 btc8821a2ant_coex_table_with_type(btcoexist
, FORCE_EXEC
, 0);
3584 /* Enable counter statistics */
3585 /* 0x76e[3] = 1, WLAN_Act control by PTA */
3586 btcoexist
->btc_write_1byte(btcoexist
, 0x76e, 0x4);
3587 btcoexist
->btc_write_1byte(btcoexist
, 0x778, 0x3);
3588 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x40, 0x20, 0x1);
3591 void ex_btc8821a2ant_pre_load_firmware(struct btc_coexist
*btcoexist
)
3593 struct btc_board_info
*board_info
= &btcoexist
->board_info
;
3594 u8 u8tmp
= 0x4; /* Set BIT2 by default since it's 2ant case */
3597 * S0 or S1 setting and Local register setting(By the setting fw can get
3598 * ant number, S0/S1, ... info)
3600 * Local setting bit define
3601 * BIT0: "0" for no antenna inverse; "1" for antenna inverse
3602 * BIT1: "0" for internal switch; "1" for external switch
3603 * BIT2: "0" for one antenna; "1" for two antenna
3604 * NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and
3607 if (btcoexist
->chip_interface
== BTC_INTF_USB
) {
3608 /* fixed at S0 for USB interface */
3609 u8tmp
|= 0x1; /* antenna inverse */
3610 btcoexist
->btc_write_local_reg_1byte(btcoexist
, 0xfe08, u8tmp
);
3612 /* for PCIE and SDIO interface, we check efuse 0xc3[6] */
3613 if (board_info
->single_ant_path
== 0) {
3614 } else if (board_info
->single_ant_path
== 1) {
3616 u8tmp
|= 0x1; /* antenna inverse */
3619 if (btcoexist
->chip_interface
== BTC_INTF_PCI
)
3620 btcoexist
->btc_write_local_reg_1byte(btcoexist
, 0x384,
3622 else if (btcoexist
->chip_interface
== BTC_INTF_SDIO
)
3623 btcoexist
->btc_write_local_reg_1byte(btcoexist
, 0x60,
3628 void ex_btc8821a2ant_init_coex_dm(struct btc_coexist
*btcoexist
)
3630 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3632 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3633 "[BTCoex], Coex Mechanism Init!!\n");
3635 btc8821a2ant_init_coex_dm(btcoexist
);
3638 void ex_btc8821a2ant_display_coex_info(struct btc_coexist
*btcoexist
,
3641 struct btc_board_info
*board_info
= &btcoexist
->board_info
;
3642 struct btc_stack_info
*stack_info
= &btcoexist
->stack_info
;
3643 u8 u1tmp
[4], i
, bt_info_ext
, ps_tdma_case
= 0;
3645 bool roam
= false, scan
= false, link
= false, wifi_under_5g
= false;
3646 bool bt_hs_on
= false, wifi_busy
= false;
3647 long wifi_rssi
= 0, bt_hs_rssi
= 0;
3648 u32 wifi_bw
, wifi_traffic_dir
;
3649 u8 wifi_dot_11_chnl
, wifi_hs_chnl
;
3650 u32 fw_ver
= 0, bt_patch_ver
= 0;
3652 seq_puts(m
, "\n ============[BT Coexist info]============");
3654 seq_printf(m
, "\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:",
3655 board_info
->pg_ant_num
, board_info
->btdm_ant_num
);
3657 if (btcoexist
->manual_control
) {
3658 seq_printf(m
, "\n %-35s", "[Action Manual control]!!");
3661 seq_printf(m
, "\n %-35s = %s / %d", "BT stack/ hci ext ver",
3662 ((stack_info
->profile_notified
) ? "Yes" : "No"),
3663 stack_info
->hci_version
);
3665 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_BT_PATCH_VER
, &bt_patch_ver
);
3666 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_FW_VER
, &fw_ver
);
3667 seq_printf(m
, "\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)",
3668 "CoexVer/ FwVer/ PatchVer",
3669 glcoex_ver_date_8821a_2ant
, glcoex_ver_8821a_2ant
,
3670 fw_ver
, bt_patch_ver
, bt_patch_ver
);
3672 btcoexist
->btc_get(btcoexist
,
3673 BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
3674 btcoexist
->btc_get(btcoexist
,
3675 BTC_GET_U1_WIFI_DOT11_CHNL
, &wifi_dot_11_chnl
);
3676 btcoexist
->btc_get(btcoexist
,
3677 BTC_GET_U1_WIFI_HS_CHNL
, &wifi_hs_chnl
);
3678 seq_printf(m
, "\n %-35s = %d / %d(%d)",
3679 "Dot11 channel / HsMode(HsChnl)",
3680 wifi_dot_11_chnl
, bt_hs_on
, wifi_hs_chnl
);
3682 seq_printf(m
, "\n %-35s = %3ph ",
3683 "H2C Wifi inform bt chnl Info",
3684 coex_dm
->wifi_chnl_info
);
3686 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_WIFI_RSSI
, &wifi_rssi
);
3687 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_HS_RSSI
, &bt_hs_rssi
);
3688 seq_printf(m
, "\n %-35s = %ld/ %ld", "Wifi rssi/ HS rssi",
3689 wifi_rssi
, bt_hs_rssi
);
3691 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_SCAN
, &scan
);
3692 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_LINK
, &link
);
3693 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_ROAM
, &roam
);
3694 seq_printf(m
, "\n %-35s = %d/ %d/ %d ", "Wifi link/ roam/ scan",
3697 btcoexist
->btc_get(btcoexist
,
3698 BTC_GET_BL_WIFI_UNDER_5G
, &wifi_under_5g
);
3699 btcoexist
->btc_get(btcoexist
,
3700 BTC_GET_U4_WIFI_BW
, &wifi_bw
);
3701 btcoexist
->btc_get(btcoexist
,
3702 BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
3703 btcoexist
->btc_get(btcoexist
,
3704 BTC_GET_U4_WIFI_TRAFFIC_DIRECTION
, &wifi_traffic_dir
);
3705 seq_printf(m
, "\n %-35s = %s / %s/ %s ", "Wifi status",
3706 (wifi_under_5g
? "5G" : "2.4G"),
3707 ((BTC_WIFI_BW_LEGACY
== wifi_bw
) ? "Legacy" :
3708 (((BTC_WIFI_BW_HT40
== wifi_bw
) ? "HT40" : "HT20"))),
3709 ((!wifi_busy
) ? "idle" :
3710 ((BTC_WIFI_TRAFFIC_TX
== wifi_traffic_dir
) ?
3711 "uplink" : "downlink")));
3713 if (stack_info
->profile_notified
) {
3714 seq_printf(m
, "\n %-35s = %d / %d / %d / %d",
3716 stack_info
->sco_exist
, stack_info
->hid_exist
,
3717 stack_info
->pan_exist
, stack_info
->a2dp_exist
);
3719 btcoexist
->btc_disp_dbg_msg(btcoexist
,
3720 BTC_DBG_DISP_BT_LINK_INFO
,
3724 bt_info_ext
= coex_sta
->bt_info_ext
;
3725 seq_printf(m
, "\n %-35s = %s", "BT Info A2DP rate",
3726 (bt_info_ext
&BIT0
) ? "Basic rate" : "EDR rate");
3728 for (i
= 0; i
< BT_INFO_SRC_8821A_2ANT_MAX
; i
++) {
3729 if (coex_sta
->bt_info_c2h_cnt
[i
]) {
3730 seq_printf(m
, "\n %-35s = %7ph(%d)",
3731 glbt_info_src_8821a_2ant
[i
],
3732 coex_sta
->bt_info_c2h
[i
],
3733 coex_sta
->bt_info_c2h_cnt
[i
]);
3737 seq_printf(m
, "\n %-35s = %s/%s",
3738 "PS state, IPS/LPS",
3739 ((coex_sta
->under_ips
? "IPS ON" : "IPS OFF")),
3740 ((coex_sta
->under_lps
? "LPS ON" : "LPS OFF")));
3741 btcoexist
->btc_disp_dbg_msg(btcoexist
, BTC_DBG_DISP_FW_PWR_MODE_CMD
, m
);
3744 seq_printf(m
, "\n %-35s",
3745 "============[Sw mechanism]============");
3746 seq_printf(m
, "\n %-35s = %d/ %d/ %d(0x%x) ",
3747 "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]",
3748 coex_dm
->cur_agc_table_en
, coex_dm
->cur_adc_back_off
,
3749 coex_dm
->cur_dac_swing_on
, coex_dm
->cur_dac_swing_lvl
);
3752 seq_printf(m
, "\n %-35s",
3753 "============[Fw mechanism]============");
3755 if (!btcoexist
->manual_control
) {
3756 ps_tdma_case
= coex_dm
->cur_ps_tdma
;
3757 seq_printf(m
, "\n %-35s = %5ph case-%d",
3759 coex_dm
->ps_tdma_para
, ps_tdma_case
);
3761 seq_printf(m
, "\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct",
3762 coex_dm
->cur_dec_bt_pwr_lvl
,
3763 coex_dm
->cur_ignore_wlan_act
);
3767 seq_printf(m
, "\n %-35s", "============[Hw setting]============");
3769 seq_printf(m
, "\n %-35s = 0x%x", "RF-A, 0x1e initVal",
3770 coex_dm
->bt_rf0x1e_backup
);
3772 u1tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x778);
3773 u1tmp
[1] = btcoexist
->btc_read_1byte(btcoexist
, 0x6cc);
3774 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x ",
3775 "0x778 (W_Act)/ 0x6cc (CoTab Sel)",
3776 u1tmp
[0], u1tmp
[1]);
3778 u1tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x8db);
3779 u1tmp
[1] = btcoexist
->btc_read_1byte(btcoexist
, 0xc5b);
3780 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x",
3781 "0x8db(ADC)/0xc5b[29:25](DAC)",
3782 ((u1tmp
[0] & 0x60) >> 5), ((u1tmp
[1] & 0x3e) >> 1));
3784 u4tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0xcb4);
3785 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x",
3786 "0xcb4[7:0](ctrl)/ 0xcb4[29:28](val)",
3787 u4tmp
[0] & 0xff, ((u4tmp
[0] & 0x30000000) >> 28));
3789 u1tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x40);
3790 u4tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x4c);
3791 u4tmp
[1] = btcoexist
->btc_read_4byte(btcoexist
, 0x974);
3792 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x/ 0x%x",
3793 "0x40/ 0x4c[24:23]/ 0x974",
3794 u1tmp
[0], ((u4tmp
[0] & 0x01800000) >> 23), u4tmp
[1]);
3796 u4tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x550);
3797 u1tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x522);
3798 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x",
3799 "0x550(bcn ctrl)/0x522",
3800 u4tmp
[0], u1tmp
[0]);
3802 u4tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0xc50);
3803 u1tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0xa0a);
3804 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x",
3805 "0xc50(DIG)/0xa0a(CCK-TH)",
3806 u4tmp
[0], u1tmp
[0]);
3808 u4tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0xf48);
3809 u1tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0xa5b);
3810 u1tmp
[1] = btcoexist
->btc_read_1byte(btcoexist
, 0xa5c);
3811 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x",
3813 u4tmp
[0], (u1tmp
[0] << 8) + u1tmp
[1]);
3815 u4tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x6c0);
3816 u4tmp
[1] = btcoexist
->btc_read_4byte(btcoexist
, 0x6c4);
3817 u4tmp
[2] = btcoexist
->btc_read_4byte(btcoexist
, 0x6c8);
3818 seq_printf(m
, "\n %-35s = 0x%x/ 0x%x/ 0x%x",
3819 "0x6c0/0x6c4/0x6c8",
3820 u4tmp
[0], u4tmp
[1], u4tmp
[2]);
3822 seq_printf(m
, "\n %-35s = %d/ %d",
3823 "0x770 (hi-pri Rx/Tx)",
3824 coex_sta
->high_priority_rx
, coex_sta
->high_priority_tx
);
3825 seq_printf(m
, "\n %-35s = %d/ %d",
3826 "0x774(low-pri Rx/Tx)",
3827 coex_sta
->low_priority_rx
, coex_sta
->low_priority_tx
);
3829 /* Tx mgnt queue hang or not, 0x41b should = 0xf, ex: 0xd ==>hang*/
3830 u1tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x41b);
3831 seq_printf(m
, "\n %-35s = 0x%x",
3832 "0x41b (mgntQ hang chk == 0xf)",
3835 btcoexist
->btc_disp_dbg_msg(btcoexist
, BTC_DBG_DISP_COEX_STATISTICS
, m
);
3838 void ex_btc8821a2ant_ips_notify(struct btc_coexist
*btcoexist
, u8 type
)
3840 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3842 if (BTC_IPS_ENTER
== type
) {
3843 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3844 "[BTCoex], IPS ENTER notify\n");
3845 coex_sta
->under_ips
= true;
3846 btc8821a2ant_wifi_off_hw_cfg(btcoexist
);
3847 btc8821a2ant_ignore_wlan_act(btcoexist
, FORCE_EXEC
, true);
3848 btc8821a2ant_coex_all_off(btcoexist
);
3849 } else if (BTC_IPS_LEAVE
== type
) {
3850 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3851 "[BTCoex], IPS LEAVE notify\n");
3852 coex_sta
->under_ips
= false;
3853 ex_btc8821a2ant_init_hwconfig(btcoexist
);
3854 btc8821a2ant_init_coex_dm(btcoexist
);
3855 btc8821a2ant_query_bt_info(btcoexist
);
3859 void ex_btc8821a2ant_lps_notify(struct btc_coexist
*btcoexist
, u8 type
)
3861 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3863 if (BTC_LPS_ENABLE
== type
) {
3864 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3865 "[BTCoex], LPS ENABLE notify\n");
3866 coex_sta
->under_lps
= true;
3867 } else if (BTC_LPS_DISABLE
== type
) {
3868 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3869 "[BTCoex], LPS DISABLE notify\n");
3870 coex_sta
->under_lps
= false;
3874 void ex_btc8821a2ant_scan_notify(struct btc_coexist
*btcoexist
, u8 type
)
3876 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3878 if (BTC_SCAN_START
== type
) {
3879 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3880 "[BTCoex], SCAN START notify\n");
3881 } else if (BTC_SCAN_FINISH
== type
) {
3882 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3883 "[BTCoex], SCAN FINISH notify\n");
3887 void ex_btc8821a2ant_connect_notify(struct btc_coexist
*btcoexist
, u8 type
)
3889 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3891 if (BTC_ASSOCIATE_START
== type
) {
3892 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3893 "[BTCoex], CONNECT START notify\n");
3894 } else if (BTC_ASSOCIATE_FINISH
== type
) {
3895 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3896 "[BTCoex], CONNECT FINISH notify\n");
3900 void ex_btc8821a2ant_media_status_notify(struct btc_coexist
*btcoexist
,
3903 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3904 u8 h2c_parameter
[3] = {0};
3906 u8 wifi_central_chnl
;
3909 if (BTC_MEDIA_CONNECT
== type
) {
3910 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3911 "[BTCoex], MEDIA connect notify\n");
3913 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3914 "[BTCoex], MEDIA disconnect notify\n");
3917 /* only 2.4G we need to inform bt the chnl mask */
3918 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_WIFI_CENTRAL_CHNL
,
3919 &wifi_central_chnl
);
3920 if ((BTC_MEDIA_CONNECT
== type
) &&
3921 (wifi_central_chnl
<= 14)) {
3922 h2c_parameter
[0] = 0x1;
3923 h2c_parameter
[1] = wifi_central_chnl
;
3924 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
3925 if (wifi_bw
== BTC_WIFI_BW_HT40
) {
3926 h2c_parameter
[2] = 0x30;
3928 h2c_parameter
[2] = 0x20;
3930 h2c_parameter
[2] = 0x30;
3932 h2c_parameter
[2] = 0x20;
3936 coex_dm
->wifi_chnl_info
[0] = h2c_parameter
[0];
3937 coex_dm
->wifi_chnl_info
[1] = h2c_parameter
[1];
3938 coex_dm
->wifi_chnl_info
[2] = h2c_parameter
[2];
3940 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3941 "[BTCoex], FW write 0x66 = 0x%x\n",
3942 h2c_parameter
[0] << 16 |
3943 h2c_parameter
[1] << 8 |
3946 btcoexist
->btc_fill_h2c(btcoexist
, 0x66, 3, h2c_parameter
);
3949 void ex_btc8821a2ant_special_packet_notify(struct btc_coexist
*btcoexist
,
3952 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3954 if (type
== BTC_PACKET_DHCP
) {
3955 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3956 "[BTCoex], DHCP Packet notify\n");
3960 void ex_btc8821a2ant_bt_info_notify(struct btc_coexist
*btcoexist
,
3961 u8
*tmp_buf
, u8 length
)
3963 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3965 u8 i
, rsp_source
= 0;
3966 bool bt_busy
= false, limited_dig
= false;
3967 bool wifi_connected
= false, wifi_under_5g
= false;
3969 coex_sta
->c2h_bt_info_req_sent
= false;
3970 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_UNDER_5G
, &wifi_under_5g
);
3971 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
3974 rsp_source
= tmp_buf
[0] & 0xf;
3975 if (rsp_source
>= BT_INFO_SRC_8821A_2ANT_MAX
)
3976 rsp_source
= BT_INFO_SRC_8821A_2ANT_WIFI_FW
;
3977 coex_sta
->bt_info_c2h_cnt
[rsp_source
]++;
3979 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3980 "[BTCoex], Bt info[%d], length = %d, hex data = [",
3981 rsp_source
, length
);
3982 for (i
= 0; i
< length
; i
++) {
3983 coex_sta
->bt_info_c2h
[rsp_source
][i
] = tmp_buf
[i
];
3985 bt_info
= tmp_buf
[i
];
3986 if (i
== length
- 1) {
3987 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3988 "0x%02x]\n", tmp_buf
[i
]);
3990 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3991 "0x%02x, ", tmp_buf
[i
]);
3995 if (btcoexist
->manual_control
) {
3996 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
3997 "[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n");
4001 if (BT_INFO_SRC_8821A_2ANT_WIFI_FW
!= rsp_source
) {
4003 coex_sta
->bt_retry_cnt
=
4004 coex_sta
->bt_info_c2h
[rsp_source
][2]&0xf;
4007 coex_sta
->bt_info_c2h
[rsp_source
][3] * 2 + 10;
4009 coex_sta
->bt_info_ext
= coex_sta
->bt_info_c2h
[rsp_source
][4];
4011 coex_sta
->bt_tx_rx_mask
=
4012 (coex_sta
->bt_info_c2h
[rsp_source
][2] & 0x40);
4013 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_TX_RX_MASK
,
4014 &coex_sta
->bt_tx_rx_mask
);
4015 if (coex_sta
->bt_tx_rx_mask
) {
4016 /* BT into is responded by BT FW and BT RF REG 0x3C !=
4017 * 0x01 => Need to switch BT TRx Mask
4019 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4020 "[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n");
4021 btcoexist
->btc_set_bt_reg(btcoexist
, BTC_BT_REG_RF
,
4025 /* Here we need to resend some wifi info to BT
4026 * because bt is reset and loss of the info
4028 if ((coex_sta
->bt_info_ext
& BIT1
)) {
4029 btcoexist
->btc_get(btcoexist
,
4030 BTC_GET_BL_WIFI_CONNECTED
, &wifi_connected
);
4031 if (wifi_connected
) {
4032 ex_btc8821a2ant_media_status_notify(btcoexist
,
4035 ex_btc8821a2ant_media_status_notify(btcoexist
,
4036 BTC_MEDIA_DISCONNECT
);
4041 if (!btcoexist
->manual_control
&& !wifi_under_5g
) {
4042 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4043 "[BTCoex], BT ext info = 0x%x!!\n",
4044 coex_sta
->bt_info_ext
);
4045 if ((coex_sta
->bt_info_ext
& BIT(3))) {
4046 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4047 "[BTCoex], BT ext info bit3=1, wifi_connected=%d\n",
4049 if (wifi_connected
) {
4050 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
4052 "[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n");
4053 btc8821a2ant_ignore_wlan_act(btcoexist
,
4058 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4059 "[BTCoex], BT ext info bit3=0, wifi_connected=%d\n",
4061 /* BT already NOT ignore Wlan active, do nothing
4064 if (!wifi_connected
) {
4065 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
,
4067 "[BTCoex], BT ext info bit3 check, set BT to ignore Wlan active!!\n");
4068 btc8821a2ant_ignore_wlan_act(
4069 btcoexist
, FORCE_EXEC
, true);
4075 /* check BIT2 first ==> check if bt is under inquiry or page scan*/
4076 if (bt_info
& BT_INFO_8821A_2ANT_B_INQ_PAGE
) {
4077 coex_sta
->c2h_bt_inquiry_page
= true;
4079 coex_sta
->c2h_bt_inquiry_page
= false;
4081 /* set link exist status */
4082 if (!(bt_info
& BT_INFO_8821A_2ANT_B_CONNECTION
)) {
4083 coex_sta
->bt_link_exist
= false;
4084 coex_sta
->pan_exist
= false;
4085 coex_sta
->a2dp_exist
= false;
4086 coex_sta
->hid_exist
= false;
4087 coex_sta
->sco_exist
= false;
4088 } else { /* connection exists */
4089 coex_sta
->bt_link_exist
= true;
4090 if (bt_info
& BT_INFO_8821A_2ANT_B_FTP
)
4091 coex_sta
->pan_exist
= true;
4093 coex_sta
->pan_exist
= false;
4094 if (bt_info
& BT_INFO_8821A_2ANT_B_A2DP
)
4095 coex_sta
->a2dp_exist
= true;
4097 coex_sta
->a2dp_exist
= false;
4098 if (bt_info
& BT_INFO_8821A_2ANT_B_HID
)
4099 coex_sta
->hid_exist
= true;
4101 coex_sta
->hid_exist
= false;
4102 if (bt_info
& BT_INFO_8821A_2ANT_B_SCO_ESCO
)
4103 coex_sta
->sco_exist
= true;
4105 coex_sta
->sco_exist
= false;
4107 if ((!coex_sta
->hid_exist
) &&
4108 (!coex_sta
->c2h_bt_inquiry_page
) &&
4109 (!coex_sta
->sco_exist
)) {
4110 if (coex_sta
->high_priority_tx
+
4111 coex_sta
->high_priority_rx
>= 160)
4112 coex_sta
->hid_exist
= true;
4116 btc8821a2ant_update_bt_link_info(btcoexist
);
4118 if (!(bt_info
& BT_INFO_8821A_2ANT_B_CONNECTION
)) {
4119 coex_dm
->bt_status
= BT_8821A_2ANT_BT_STATUS_IDLE
;
4120 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4121 "[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n");
4122 } else if (bt_info
== BT_INFO_8821A_2ANT_B_CONNECTION
) {
4123 /* connection exists but no busy */
4124 coex_dm
->bt_status
= BT_8821A_2ANT_BT_STATUS_CON_IDLE
;
4125 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4126 "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
4127 } else if ((bt_info
& BT_INFO_8821A_2ANT_B_SCO_ESCO
) ||
4128 (bt_info
& BT_INFO_8821A_2ANT_B_SCO_BUSY
)) {
4129 coex_dm
->bt_status
= BT_8821A_2ANT_BT_STATUS_SCO_BUSY
;
4130 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4131 "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n");
4132 } else if (bt_info
& BT_INFO_8821A_2ANT_B_ACL_BUSY
) {
4133 coex_dm
->bt_status
= BT_8821A_2ANT_BT_STATUS_ACL_BUSY
;
4134 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4135 "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n");
4137 coex_dm
->bt_status
= BT_8821A_2ANT_BT_STATUS_MAX
;
4138 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4139 "[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n");
4142 if ((coex_dm
->bt_status
== BT_8821A_2ANT_BT_STATUS_ACL_BUSY
) ||
4143 (coex_dm
->bt_status
== BT_8821A_2ANT_BT_STATUS_SCO_BUSY
) ||
4144 (coex_dm
->bt_status
== BT_8821A_2ANT_BT_STATUS_ACL_SCO_BUSY
)) {
4149 limited_dig
= false;
4152 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_TRAFFIC_BUSY
, &bt_busy
);
4154 coex_dm
->limited_dig
= limited_dig
;
4155 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_LIMITED_DIG
, &limited_dig
);
4157 btc8821a2ant_run_coexist_mechanism(btcoexist
);
4160 void ex_btc8821a2ant_halt_notify(struct btc_coexist
*btcoexist
)
4162 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
4164 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4165 "[BTCoex], Halt notify\n");
4167 btc8821a2ant_wifi_off_hw_cfg(btcoexist
);
4168 btc8821a2ant_ignore_wlan_act(btcoexist
, FORCE_EXEC
, true);
4169 ex_btc8821a2ant_media_status_notify(btcoexist
, BTC_MEDIA_DISCONNECT
);
4172 void ex_btc8821a2ant_pnp_notify(struct btc_coexist
*btcoexist
, u8 pnp_state
)
4174 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
4176 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
, "[BTCoex], Pnp notify\n");
4178 if (pnp_state
== BTC_WIFI_PNP_SLEEP
) {
4179 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4180 "[BTCoex], Pnp notify to SLEEP\n");
4181 } else if (pnp_state
== BTC_WIFI_PNP_WAKE_UP
) {
4182 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4183 "[BTCoex], Pnp notify to WAKE UP\n");
4184 ex_btc8821a2ant_init_hwconfig(btcoexist
);
4185 btc8821a2ant_init_coex_dm(btcoexist
);
4186 btc8821a2ant_query_bt_info(btcoexist
);
4190 void ex_btc8821a2ant_periodical(struct btc_coexist
*btcoexist
)
4192 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
4194 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4195 "[BTCoex], ==========================Periodical===========================\n");
4197 if (coex_sta
->dis_ver_info_cnt
<= 5) {
4198 coex_sta
->dis_ver_info_cnt
+= 1;
4199 if (coex_sta
->dis_ver_info_cnt
== 3) {
4200 /* Antenna config to set 0x765 = 0x0 (GNT_BT control by
4201 * PTA) after initial
4203 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
4204 "[BTCoex], Set GNT_BT control by PTA\n");
4205 btc8821a2ant_set_ant_path(btcoexist
,
4206 BTC_ANT_WIFI_AT_MAIN
, false, false);
4210 if (btcoexist
->auto_report_2ant
) {
4211 btc8821a2ant_query_bt_info(btcoexist
);
4213 btc8821a2ant_monitor_bt_ctr(btcoexist
);
4214 btc8821a2ant_monitor_wifi_ctr(btcoexist
);
4216 if (btc8821a2ant_is_wifi_status_changed(btcoexist
) ||
4217 coex_dm
->auto_tdma_adjust
)
4218 btc8821a2ant_run_coexist_mechanism(btcoexist
);