1 /* ************************************************************
4 * This file is for RTL8821A Co-exist mechanism
7 * 2012/11/15 Cosa first check in.
9 * ************************************************************ */
11 /* ************************************************************
13 * ************************************************************ */
14 #include "Mp_Precomp.h"
16 #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)
18 #if (RTL8821A_SUPPORT == 1)
19 /* ************************************************************
20 * Global variables, these are static variables
21 * ************************************************************ */
22 static u8 *trace_buf = &gl_btc_trace_buf[0];
23 static struct coex_dm_8821a_2ant glcoex_dm_8821a_2ant;
24 static struct coex_dm_8821a_2ant *coex_dm = &glcoex_dm_8821a_2ant;
25 static struct coex_sta_8821a_2ant glcoex_sta_8821a_2ant;
26 static struct coex_sta_8821a_2ant *coex_sta = &glcoex_sta_8821a_2ant;
28 const char *const glbt_info_src_8821a_2ant[] = {
31 "BT Info[bt auto report]",
34 u32 glcoex_ver_date_8821a_2ant = 20150921;
35 u32 glcoex_ver_8821a_2ant = 0x58;
36 /* modify 20140903v43 a2dpandhid tdmaonoff a2dp glitch _ tdma off 778=3(case1)->778=1(case0)
37 * and to improve tp while a2dphid case23->case25 , case123->case125 for asus spec
38 * and modify for asus bt WHQL test _ tdma off_ 778=3->1_
39 * ************************************************************
40 * local function proto type if needed
41 * ************************************************************
42 * ************************************************************
43 * local function start with halbtc8821a2ant_
44 * ************************************************************ */
45 u8 halbtc8821a2ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1)
48 u8 bt_rssi_state = coex_sta->pre_bt_rssi_state;
50 bt_rssi = coex_sta->bt_rssi;
53 if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
54 (coex_sta->pre_bt_rssi_state ==
55 BTC_RSSI_STATE_STAY_LOW)) {
56 if (bt_rssi >= (rssi_thresh +
57 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
58 bt_rssi_state = BTC_RSSI_STATE_HIGH;
60 bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
62 if (bt_rssi < rssi_thresh)
63 bt_rssi_state = BTC_RSSI_STATE_LOW;
65 bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
67 } else if (level_num == 3) {
68 if (rssi_thresh > rssi_thresh1) {
69 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
70 "[BTCoex], BT Rssi thresh error!!\n");
72 return coex_sta->pre_bt_rssi_state;
75 if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
76 (coex_sta->pre_bt_rssi_state ==
77 BTC_RSSI_STATE_STAY_LOW)) {
78 if (bt_rssi >= (rssi_thresh +
79 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
80 bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
82 bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
83 } else if ((coex_sta->pre_bt_rssi_state ==
84 BTC_RSSI_STATE_MEDIUM) ||
85 (coex_sta->pre_bt_rssi_state ==
86 BTC_RSSI_STATE_STAY_MEDIUM)) {
87 if (bt_rssi >= (rssi_thresh1 +
88 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
89 bt_rssi_state = BTC_RSSI_STATE_HIGH;
90 else if (bt_rssi < rssi_thresh)
91 bt_rssi_state = BTC_RSSI_STATE_LOW;
93 bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
95 if (bt_rssi < rssi_thresh1)
96 bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
98 bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
102 coex_sta->pre_bt_rssi_state = bt_rssi_state;
104 return bt_rssi_state;
107 u8 halbtc8821a2ant_wifi_rssi_state(IN struct btc_coexist *btcoexist,
108 IN u8 index, IN u8 level_num, IN u8 rssi_thresh, IN u8 rssi_thresh1)
111 u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index];
113 btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
115 if (level_num == 2) {
116 if ((coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_LOW)
118 (coex_sta->pre_wifi_rssi_state[index] ==
119 BTC_RSSI_STATE_STAY_LOW)) {
120 if (wifi_rssi >= (rssi_thresh +
121 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
122 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
124 wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
126 if (wifi_rssi < rssi_thresh)
127 wifi_rssi_state = BTC_RSSI_STATE_LOW;
129 wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
131 } else if (level_num == 3) {
132 if (rssi_thresh > rssi_thresh1) {
133 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
134 "[BTCoex], wifi RSSI thresh error!!\n");
135 BTC_TRACE(trace_buf);
136 return coex_sta->pre_wifi_rssi_state[index];
139 if ((coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_LOW)
141 (coex_sta->pre_wifi_rssi_state[index] ==
142 BTC_RSSI_STATE_STAY_LOW)) {
143 if (wifi_rssi >= (rssi_thresh +
144 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
145 wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
147 wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
148 } else if ((coex_sta->pre_wifi_rssi_state[index] ==
149 BTC_RSSI_STATE_MEDIUM) ||
150 (coex_sta->pre_wifi_rssi_state[index] ==
151 BTC_RSSI_STATE_STAY_MEDIUM)) {
152 if (wifi_rssi >= (rssi_thresh1 +
153 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
154 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
155 else if (wifi_rssi < rssi_thresh)
156 wifi_rssi_state = BTC_RSSI_STATE_LOW;
158 wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
160 if (wifi_rssi < rssi_thresh1)
161 wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
163 wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
167 coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state;
169 return wifi_rssi_state;
172 void halbtc8821a2ant_monitor_bt_enable_disable(IN struct btc_coexist *btcoexist)
174 static u32 bt_disable_cnt = 0;
175 boolean bt_active = true, bt_disabled = false;
177 /* This function check if bt is disabled */
179 if (coex_sta->high_priority_tx == 0 &&
180 coex_sta->high_priority_rx == 0 &&
181 coex_sta->low_priority_tx == 0 &&
182 coex_sta->low_priority_rx == 0)
184 if (coex_sta->high_priority_tx == 0xffff &&
185 coex_sta->high_priority_rx == 0xffff &&
186 coex_sta->low_priority_tx == 0xffff &&
187 coex_sta->low_priority_rx == 0xffff)
192 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
194 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
195 "[BTCoex], BT is enabled !!\n");
196 BTC_TRACE(trace_buf);
199 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
200 "[BTCoex], bt all counters=0, %d times!!\n",
202 BTC_TRACE(trace_buf);
203 if (bt_disable_cnt >= 2) {
205 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
207 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
208 "[BTCoex], BT is disabled !!\n");
209 BTC_TRACE(trace_buf);
212 if (coex_sta->bt_disabled != bt_disabled) {
213 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
214 "[BTCoex], BT is from %s to %s!!\n",
215 (coex_sta->bt_disabled ? "disabled" : "enabled"),
216 (bt_disabled ? "disabled" : "enabled"));
217 BTC_TRACE(trace_buf);
218 coex_sta->bt_disabled = bt_disabled;
225 void halbtc8821a2ant_limited_rx(IN struct btc_coexist *btcoexist,
226 IN boolean force_exec, IN boolean rej_ap_agg_pkt,
227 IN boolean bt_ctrl_agg_buf_size, IN u8 agg_buf_size)
229 boolean reject_rx_agg = rej_ap_agg_pkt;
230 boolean bt_ctrl_rx_agg_size = bt_ctrl_agg_buf_size;
231 u8 rx_agg_size = agg_buf_size;
233 /* ============================================ */
234 /* Rx Aggregation related setting */
235 /* ============================================ */
236 btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT,
238 /* decide BT control aggregation buf size or not */
239 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE,
240 &bt_ctrl_rx_agg_size);
241 /* aggregation buf size, only work when BT control Rx aggregation size. */
242 btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rx_agg_size);
243 /* real update aggregation setting */
244 btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
247 void halbtc8821a2ant_monitor_bt_ctr(IN struct btc_coexist *btcoexist)
249 u32 reg_hp_txrx, reg_lp_txrx, u32tmp;
250 u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0;
252 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
257 u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx);
258 reg_hp_tx = u32tmp & MASKLWORD;
259 reg_hp_rx = (u32tmp & MASKHWORD) >> 16;
261 u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx);
262 reg_lp_tx = u32tmp & MASKLWORD;
263 reg_lp_rx = (u32tmp & MASKHWORD) >> 16;
265 coex_sta->high_priority_tx = reg_hp_tx;
266 coex_sta->high_priority_rx = reg_hp_rx;
267 coex_sta->low_priority_tx = reg_lp_tx;
268 coex_sta->low_priority_rx = reg_lp_rx;
270 if ((coex_sta->low_priority_rx >= 950) &&
271 (coex_sta->low_priority_rx >= coex_sta->low_priority_tx) &&
272 (!coex_sta->under_ips))
273 bt_link_info->slave_role = true;
275 bt_link_info->slave_role = false;
277 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
278 "[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
279 reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx);
280 BTC_TRACE(trace_buf);
281 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
282 "[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
283 reg_lp_txrx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx);
284 BTC_TRACE(trace_buf);
287 btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
290 void halbtc8821a2ant_monitor_wifi_ctr(IN struct btc_coexist *btcoexist)
292 if (coex_sta->under_ips) {
293 coex_sta->crc_ok_cck = 0;
294 coex_sta->crc_ok_11g = 0;
295 coex_sta->crc_ok_11n = 0;
296 coex_sta->crc_ok_11n_agg = 0;
298 coex_sta->crc_err_cck = 0;
299 coex_sta->crc_err_11g = 0;
300 coex_sta->crc_err_11n = 0;
301 coex_sta->crc_err_11n_agg = 0;
303 coex_sta->crc_ok_cck = btcoexist->btc_read_4byte(btcoexist,
305 coex_sta->crc_ok_11g = btcoexist->btc_read_2byte(btcoexist,
307 coex_sta->crc_ok_11n = btcoexist->btc_read_2byte(btcoexist,
309 coex_sta->crc_ok_11n_agg = btcoexist->btc_read_2byte(btcoexist,
312 coex_sta->crc_err_cck = btcoexist->btc_read_4byte(btcoexist,
314 coex_sta->crc_err_11g = btcoexist->btc_read_2byte(btcoexist,
316 coex_sta->crc_err_11n = btcoexist->btc_read_2byte(btcoexist,
318 coex_sta->crc_err_11n_agg = btcoexist->btc_read_2byte(btcoexist,
323 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xf16, 0x1, 0x1);
324 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xf16, 0x1, 0x0);
327 void halbtc8821a2ant_query_bt_info(IN struct btc_coexist *btcoexist)
329 u8 h2c_parameter[1] = {0};
331 coex_sta->c2h_bt_info_req_sent = true;
333 h2c_parameter[0] |= BIT(0); /* trigger */
335 btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
338 boolean halbtc8821a2ant_is_wifi_status_changed(IN struct btc_coexist *btcoexist)
340 static boolean pre_wifi_busy = false, pre_under_4way = false,
341 pre_bt_hs_on = false;
342 boolean wifi_busy = false, under_4way = false, bt_hs_on = false;
343 boolean wifi_connected = false;
344 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
347 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
349 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
350 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
351 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
354 if (wifi_connected) {
355 if (wifi_busy != pre_wifi_busy) {
356 pre_wifi_busy = wifi_busy;
359 if (under_4way != pre_under_4way) {
360 pre_under_4way = under_4way;
363 if (bt_hs_on != pre_bt_hs_on) {
364 pre_bt_hs_on = bt_hs_on;
369 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 3,
370 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
372 if ((BTC_RSSI_STATE_HIGH == wifi_rssi_state) ||
373 (BTC_RSSI_STATE_LOW == wifi_rssi_state))
381 void halbtc8821a2ant_update_bt_link_info(IN struct btc_coexist *btcoexist)
383 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
384 boolean 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 &&
402 !bt_link_info->a2dp_exist &&
403 !bt_link_info->pan_exist &&
404 !bt_link_info->hid_exist)
405 bt_link_info->sco_only = true;
407 bt_link_info->sco_only = false;
409 /* check if A2dp only */
410 if (!bt_link_info->sco_exist &&
411 bt_link_info->a2dp_exist &&
412 !bt_link_info->pan_exist &&
413 !bt_link_info->hid_exist)
414 bt_link_info->a2dp_only = true;
416 bt_link_info->a2dp_only = false;
418 /* check if Pan only */
419 if (!bt_link_info->sco_exist &&
420 !bt_link_info->a2dp_exist &&
421 bt_link_info->pan_exist &&
422 !bt_link_info->hid_exist)
423 bt_link_info->pan_only = true;
425 bt_link_info->pan_only = false;
427 /* check if Hid only */
428 if (!bt_link_info->sco_exist &&
429 !bt_link_info->a2dp_exist &&
430 !bt_link_info->pan_exist &&
431 bt_link_info->hid_exist)
432 bt_link_info->hid_only = true;
434 bt_link_info->hid_only = false;
437 u8 halbtc8821a2ant_action_algorithm(IN struct btc_coexist *btcoexist)
439 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
440 boolean bt_hs_on = false;
441 u8 algorithm = BT_8821A_2ANT_COEX_ALGO_UNDEFINED;
442 u8 num_of_diff_profile = 0;
444 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
446 if (!bt_link_info->bt_link_exist) {
447 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
448 "[BTCoex], No BT link exists!!!\n");
449 BTC_TRACE(trace_buf);
453 if (bt_link_info->sco_exist)
454 num_of_diff_profile++;
455 if (bt_link_info->hid_exist)
456 num_of_diff_profile++;
457 if (bt_link_info->pan_exist)
458 num_of_diff_profile++;
459 if (bt_link_info->a2dp_exist)
460 num_of_diff_profile++;
462 if (num_of_diff_profile == 1) {
463 if (bt_link_info->sco_exist) {
464 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
465 "[BTCoex], SCO only\n");
466 BTC_TRACE(trace_buf);
467 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
469 if (bt_link_info->hid_exist) {
470 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
471 "[BTCoex], HID only\n");
472 BTC_TRACE(trace_buf);
473 algorithm = BT_8821A_2ANT_COEX_ALGO_HID;
474 } else if (bt_link_info->a2dp_exist) {
475 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
476 "[BTCoex], A2DP only\n");
477 BTC_TRACE(trace_buf);
478 algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP;
479 } else if (bt_link_info->pan_exist) {
481 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
482 "[BTCoex], PAN(HS) only\n");
483 BTC_TRACE(trace_buf);
485 BT_8821A_2ANT_COEX_ALGO_PANHS;
487 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
488 "[BTCoex], PAN(EDR) only\n");
489 BTC_TRACE(trace_buf);
491 BT_8821A_2ANT_COEX_ALGO_PANEDR;
495 } else if (num_of_diff_profile == 2) {
496 if (bt_link_info->sco_exist) {
497 if (bt_link_info->hid_exist) {
498 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
499 "[BTCoex], SCO + HID\n");
500 BTC_TRACE(trace_buf);
501 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
502 } else if (bt_link_info->a2dp_exist) {
503 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
504 "[BTCoex], SCO + A2DP ==> SCO\n");
505 BTC_TRACE(trace_buf);
506 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
507 } else if (bt_link_info->pan_exist) {
509 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
510 "[BTCoex], SCO + PAN(HS)\n");
511 BTC_TRACE(trace_buf);
512 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
514 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
515 "[BTCoex], SCO + PAN(EDR)\n");
516 BTC_TRACE(trace_buf);
517 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
521 if (bt_link_info->hid_exist &&
522 bt_link_info->a2dp_exist) {
524 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
525 "[BTCoex], HID + A2DP\n");
526 BTC_TRACE(trace_buf);
528 BT_8821A_2ANT_COEX_ALGO_HID_A2DP;
530 } else if (bt_link_info->hid_exist &&
531 bt_link_info->pan_exist) {
533 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
534 "[BTCoex], HID + PAN(HS)\n");
535 BTC_TRACE(trace_buf);
536 algorithm = BT_8821A_2ANT_COEX_ALGO_HID;
538 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
539 "[BTCoex], HID + PAN(EDR)\n");
540 BTC_TRACE(trace_buf);
542 BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
544 } else if (bt_link_info->pan_exist &&
545 bt_link_info->a2dp_exist) {
547 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
548 "[BTCoex], A2DP + PAN(HS)\n");
549 BTC_TRACE(trace_buf);
551 BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS;
553 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
554 "[BTCoex], A2DP + PAN(EDR)\n");
555 BTC_TRACE(trace_buf);
557 BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP;
561 } else if (num_of_diff_profile == 3) {
562 if (bt_link_info->sco_exist) {
563 if (bt_link_info->hid_exist &&
564 bt_link_info->a2dp_exist) {
565 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
566 "[BTCoex], SCO + HID + A2DP ==> SCO\n");
567 BTC_TRACE(trace_buf);
568 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
569 } else if (bt_link_info->hid_exist &&
570 bt_link_info->pan_exist) {
572 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
573 "[BTCoex], SCO + HID + PAN(HS) ==> SCO\n");
574 BTC_TRACE(trace_buf);
575 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
577 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
578 "[BTCoex], SCO + HID + PAN(EDR) ==> SCO\n");
579 BTC_TRACE(trace_buf);
580 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
582 } else if (bt_link_info->pan_exist &&
583 bt_link_info->a2dp_exist) {
585 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
586 "[BTCoex], SCO + A2DP + PAN(HS)\n");
587 BTC_TRACE(trace_buf);
588 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
590 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
591 "[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n");
592 BTC_TRACE(trace_buf);
593 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
597 if (bt_link_info->hid_exist &&
598 bt_link_info->pan_exist &&
599 bt_link_info->a2dp_exist) {
601 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
602 "[BTCoex], HID + A2DP + PAN(HS)\n");
603 BTC_TRACE(trace_buf);
605 BT_8821A_2ANT_COEX_ALGO_HID_A2DP;
607 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
608 "[BTCoex], HID + A2DP + PAN(EDR)\n");
609 BTC_TRACE(trace_buf);
611 BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
615 } else if (num_of_diff_profile >= 3) {
616 if (bt_link_info->sco_exist) {
617 if (bt_link_info->hid_exist &&
618 bt_link_info->pan_exist &&
619 bt_link_info->a2dp_exist) {
621 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
622 "[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n");
623 BTC_TRACE(trace_buf);
626 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
627 "[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n");
628 BTC_TRACE(trace_buf);
629 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
638 void halbtc8821a2ant_set_fw_dac_swing_level(IN struct btc_coexist *btcoexist,
641 u8 h2c_parameter[1] = {0};
643 /* There are several type of dacswing */
644 /* 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */
645 h2c_parameter[0] = dac_swing_lvl;
647 btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter);
650 void halbtc8821a2ant_set_fw_dec_bt_pwr(IN struct btc_coexist *btcoexist,
651 IN u8 dec_bt_pwr_lvl)
653 u8 h2c_parameter[1] = {0};
655 h2c_parameter[0] = dec_bt_pwr_lvl;
657 btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter);
660 void halbtc8821a2ant_dec_bt_pwr(IN struct btc_coexist *btcoexist,
661 IN boolean force_exec, IN u8 dec_bt_pwr_lvl)
663 coex_dm->cur_bt_dec_pwr_lvl = dec_bt_pwr_lvl;
666 if (coex_dm->pre_bt_dec_pwr_lvl == coex_dm->cur_bt_dec_pwr_lvl)
669 halbtc8821a2ant_set_fw_dec_bt_pwr(btcoexist,
670 coex_dm->cur_bt_dec_pwr_lvl);
672 coex_dm->pre_bt_dec_pwr_lvl = coex_dm->cur_bt_dec_pwr_lvl;
675 void halbtc8821a2ant_set_bt_auto_report(IN struct btc_coexist *btcoexist,
676 IN boolean enable_auto_report)
678 u8 h2c_parameter[1] = {0};
680 h2c_parameter[0] = 0;
682 if (enable_auto_report)
683 h2c_parameter[0] |= BIT(0);
685 btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter);
688 void halbtc8821a2ant_bt_auto_report(IN struct btc_coexist *btcoexist,
689 IN boolean force_exec, IN boolean enable_auto_report)
691 coex_dm->cur_bt_auto_report = enable_auto_report;
694 if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report)
697 halbtc8821a2ant_set_bt_auto_report(btcoexist,
698 coex_dm->cur_bt_auto_report);
700 coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report;
703 void halbtc8821a2ant_fw_dac_swing_lvl(IN struct btc_coexist *btcoexist,
704 IN boolean force_exec, IN u8 fw_dac_swing_lvl)
706 coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl;
709 if (coex_dm->pre_fw_dac_swing_lvl ==
710 coex_dm->cur_fw_dac_swing_lvl)
714 halbtc8821a2ant_set_fw_dac_swing_level(btcoexist,
715 coex_dm->cur_fw_dac_swing_lvl);
717 coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl;
720 void halbtc8821a2ant_set_sw_rf_rx_lpf_corner(IN struct btc_coexist *btcoexist,
721 IN boolean rx_rf_shrink_on)
723 if (rx_rf_shrink_on) {
724 /* Shrink RF Rx LPF corner */
725 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
726 "[BTCoex], Shrink RF Rx LPF corner!!\n");
727 BTC_TRACE(trace_buf);
728 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff,
731 /* Resume RF Rx LPF corner */
732 /* After initialized, we can use coex_dm->bt_rf_0x1e_backup */
733 if (btcoexist->initilized) {
734 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
735 "[BTCoex], Resume RF Rx LPF corner!!\n");
736 BTC_TRACE(trace_buf);
737 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e,
738 0xfffff, coex_dm->bt_rf_0x1e_backup);
743 void halbtc8821a2ant_rf_shrink(IN struct btc_coexist *btcoexist,
744 IN boolean force_exec, IN boolean rx_rf_shrink_on)
746 coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on;
749 if (coex_dm->pre_rf_rx_lpf_shrink ==
750 coex_dm->cur_rf_rx_lpf_shrink)
753 halbtc8821a2ant_set_sw_rf_rx_lpf_corner(btcoexist,
754 coex_dm->cur_rf_rx_lpf_shrink);
756 coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink;
759 void halbtc8821a2ant_set_sw_penalty_tx_rate_adaptive(IN struct btc_coexist
760 *btcoexist, IN boolean low_penalty_ra)
762 u8 h2c_parameter[6] = {0};
764 h2c_parameter[0] = 0x6; /* op_code, 0x6= Retry_Penalty */
766 if (low_penalty_ra) {
767 h2c_parameter[1] |= BIT(0);
769 0x00; /* normal rate except MCS7/6/5, OFDM54/48/36 */
770 h2c_parameter[3] = 0xf5; /* MCS7 or OFDM54 */
771 h2c_parameter[4] = 0xa0; /* MCS6 or OFDM48 */
772 h2c_parameter[5] = 0xa0; /* MCS5 or OFDM36 */
773 /* h2c_parameter[3] = 0xf7; //MCS7 or OFDM54 */
774 /* h2c_parameter[4] = 0xf8; //MCS6 or OFDM48 */
775 /* h2c_parameter[5] = 0xf9; //MCS5 or OFDM36 */
778 btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter);
781 void halbtc8821a2ant_low_penalty_ra(IN struct btc_coexist *btcoexist,
782 IN boolean force_exec, IN boolean low_penalty_ra)
784 coex_dm->cur_low_penalty_ra = low_penalty_ra;
787 if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra)
790 halbtc8821a2ant_set_sw_penalty_tx_rate_adaptive(btcoexist,
791 coex_dm->cur_low_penalty_ra);
793 coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
796 void halbtc8821a2ant_set_dac_swing_reg(IN struct btc_coexist *btcoexist,
801 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
802 "[BTCoex], Write SwDacSwing = 0x%x\n", level);
803 BTC_TRACE(trace_buf);
804 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc5b, 0x3e, val);
807 void halbtc8821a2ant_set_sw_full_time_dac_swing(IN struct btc_coexist
808 *btcoexist, IN boolean sw_dac_swing_on, IN u32 sw_dac_swing_lvl)
811 halbtc8821a2ant_set_dac_swing_reg(btcoexist, sw_dac_swing_lvl);
813 halbtc8821a2ant_set_dac_swing_reg(btcoexist, 0x18);
817 void halbtc8821a2ant_dac_swing(IN struct btc_coexist *btcoexist,
818 IN boolean force_exec, IN boolean dac_swing_on, IN u32 dac_swing_lvl)
820 coex_dm->cur_dac_swing_on = dac_swing_on;
821 coex_dm->cur_dac_swing_lvl = dac_swing_lvl;
824 if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) &&
825 (coex_dm->pre_dac_swing_lvl ==
826 coex_dm->cur_dac_swing_lvl))
830 halbtc8821a2ant_set_sw_full_time_dac_swing(btcoexist, dac_swing_on,
833 coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on;
834 coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl;
837 void halbtc8821a2ant_set_adc_back_off(IN struct btc_coexist *btcoexist,
838 IN boolean adc_back_off)
841 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
842 "[BTCoex], BB BackOff Level On!\n");
843 BTC_TRACE(trace_buf);
844 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x3);
846 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
847 "[BTCoex], BB BackOff Level Off!\n");
848 BTC_TRACE(trace_buf);
849 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x1);
853 void halbtc8821a2ant_adc_back_off(IN struct btc_coexist *btcoexist,
854 IN boolean force_exec, IN boolean adc_back_off)
856 coex_dm->cur_adc_back_off = adc_back_off;
859 if (coex_dm->pre_adc_back_off == coex_dm->cur_adc_back_off)
862 halbtc8821a2ant_set_adc_back_off(btcoexist, coex_dm->cur_adc_back_off);
864 coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off;
867 void halbtc8821a2ant_set_agc_table(IN struct btc_coexist *btcoexist,
868 IN boolean agc_table_en)
870 u8 rssi_adjust_val = 0;
872 /* =================BB AGC Gain Table */
874 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
875 "[BTCoex], BB Agc Table On!\n");
876 BTC_TRACE(trace_buf);
877 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6e1A0001);
878 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6d1B0001);
879 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6c1C0001);
880 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6b1D0001);
881 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6a1E0001);
882 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x691F0001);
883 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x68200001);
885 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
886 "[BTCoex], BB Agc Table Off!\n");
887 BTC_TRACE(trace_buf);
888 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xaa1A0001);
889 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa91B0001);
890 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa81C0001);
891 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa71D0001);
892 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa61E0001);
893 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa51F0001);
894 btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa4200001);
898 /* =================RF Gain */
899 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
901 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
902 "[BTCoex], Agc Table On!\n");
903 BTC_TRACE(trace_buf);
904 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff,
906 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff,
909 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
910 "[BTCoex], Agc Table Off!\n");
911 BTC_TRACE(trace_buf);
912 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff,
914 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff,
917 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
919 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xed, 0xfffff, 0x1);
921 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
922 "[BTCoex], Agc Table On!\n");
923 BTC_TRACE(trace_buf);
924 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40, 0xfffff,
926 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40, 0xfffff,
929 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
930 "[BTCoex], Agc Table Off!\n");
931 BTC_TRACE(trace_buf);
932 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40, 0xfffff,
934 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40, 0xfffff,
937 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xed, 0xfffff, 0x0);
939 /* set rssi_adjust_val for wifi module. */
942 btcoexist->btc_set(btcoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON,
946 void halbtc8821a2ant_agc_table(IN struct btc_coexist *btcoexist,
947 IN boolean force_exec, IN boolean agc_table_en)
949 coex_dm->cur_agc_table_en = agc_table_en;
952 if (coex_dm->pre_agc_table_en == coex_dm->cur_agc_table_en)
955 halbtc8821a2ant_set_agc_table(btcoexist, agc_table_en);
957 coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en;
960 void halbtc8821a2ant_set_coex_table(IN struct btc_coexist *btcoexist,
961 IN u32 val0x6c0, IN u32 val0x6c4, IN u32 val0x6c8, IN u8 val0x6cc)
963 btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
965 btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
967 btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
969 btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
972 void halbtc8821a2ant_coex_table(IN struct btc_coexist *btcoexist,
973 IN boolean force_exec, IN u32 val0x6c0, IN u32 val0x6c4,
974 IN u32 val0x6c8, IN u8 val0x6cc)
976 coex_dm->cur_val0x6c0 = val0x6c0;
977 coex_dm->cur_val0x6c4 = val0x6c4;
978 coex_dm->cur_val0x6c8 = val0x6c8;
979 coex_dm->cur_val0x6cc = val0x6cc;
982 if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) &&
983 (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) &&
984 (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) &&
985 (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc))
988 halbtc8821a2ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, val0x6c8,
991 coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0;
992 coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4;
993 coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8;
994 coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
997 void halbtc8821a2ant_coex_table_with_type(IN struct btc_coexist *btcoexist,
998 IN boolean force_exec, IN u8 type)
1000 coex_sta->coex_table_type = type;
1004 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1005 0x55555555, 0x55555555, 0xffffff, 0x3);
1008 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1009 0x55555555, 0x5afa5afa, 0xffffff, 0x3);
1012 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1013 0x5ada5ada, 0x5ada5ada, 0xffffff, 0x3);
1016 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1017 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
1020 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1021 0xffffffff, 0xffffffff, 0xffffff, 0x3);
1024 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1025 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3);
1028 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1029 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3);
1032 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1033 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
1036 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1037 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
1040 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1041 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
1044 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1045 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
1048 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1049 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
1052 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1053 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
1056 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1057 0x5fff5fff, 0xaaaaaaaa, 0xffffff, 0x3);
1060 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1061 0x5fff5fff, 0x5ada5ada, 0xffffff, 0x3);
1064 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1065 0x55dd55dd, 0xaaaaaaaa, 0xffffff, 0x3);
1068 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1069 0x5fdf5fdf, 0x5fdb5fdb, 0xffffff, 0x3);
1072 halbtc8821a2ant_coex_table(btcoexist, force_exec,
1073 0xfafafafa, 0xfafafafa, 0xffffff, 0x3);
1080 void halbtc8821a2ant_set_fw_ignore_wlan_act(IN struct btc_coexist *btcoexist,
1083 u8 h2c_parameter[1] = {0};
1086 h2c_parameter[0] |= BIT(0); /* function enable */
1089 btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter);
1092 void halbtc8821a2ant_set_lps_rpwm(IN struct btc_coexist *btcoexist,
1093 IN u8 lps_val, IN u8 rpwm_val)
1098 btcoexist->btc_set(btcoexist, BTC_SET_U1_LPS_VAL, &lps);
1099 btcoexist->btc_set(btcoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
1102 void halbtc8821a2ant_lps_rpwm(IN struct btc_coexist *btcoexist,
1103 IN boolean force_exec, IN u8 lps_val, IN u8 rpwm_val)
1105 coex_dm->cur_lps = lps_val;
1106 coex_dm->cur_rpwm = rpwm_val;
1109 if ((coex_dm->pre_lps == coex_dm->cur_lps) &&
1110 (coex_dm->pre_rpwm == coex_dm->cur_rpwm))
1113 halbtc8821a2ant_set_lps_rpwm(btcoexist, lps_val, rpwm_val);
1115 coex_dm->pre_lps = coex_dm->cur_lps;
1116 coex_dm->pre_rpwm = coex_dm->cur_rpwm;
1119 void halbtc8821a2ant_ignore_wlan_act(IN struct btc_coexist *btcoexist,
1120 IN boolean force_exec, IN boolean enable)
1122 coex_dm->cur_ignore_wlan_act = enable;
1125 if (coex_dm->pre_ignore_wlan_act ==
1126 coex_dm->cur_ignore_wlan_act)
1129 halbtc8821a2ant_set_fw_ignore_wlan_act(btcoexist, enable);
1131 coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
1134 void halbtc8821a2ant_set_fw_pstdma(IN struct btc_coexist *btcoexist,
1135 IN u8 byte1, IN u8 byte2, IN u8 byte3, IN u8 byte4, IN u8 byte5)
1137 u8 h2c_parameter[5] = {0};
1139 h2c_parameter[0] = byte1;
1140 h2c_parameter[1] = byte2;
1141 h2c_parameter[2] = byte3;
1142 h2c_parameter[3] = byte4;
1143 h2c_parameter[4] = byte5;
1145 coex_dm->ps_tdma_para[0] = byte1;
1146 coex_dm->ps_tdma_para[1] = byte2;
1147 coex_dm->ps_tdma_para[2] = byte3;
1148 coex_dm->ps_tdma_para[3] = byte4;
1149 coex_dm->ps_tdma_para[4] = byte5;
1151 btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
1154 void halbtc8821a2ant_sw_mechanism1(IN struct btc_coexist *btcoexist,
1155 IN boolean shrink_rx_lpf, IN boolean low_penalty_ra,
1156 IN boolean limited_dig, IN boolean bt_lna_constrain)
1161 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
1163 if(BTC_WIFI_BW_HT40 != wifi_bw)
1166 shrink_rx_lpf = false;
1170 /* halbtc8821a2ant_rf_shrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf); */
1171 halbtc8821a2ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra);
1174 void halbtc8821a2ant_sw_mechanism2(IN struct btc_coexist *btcoexist,
1175 IN boolean agc_table_shift, IN boolean adc_back_off,
1176 IN boolean sw_dac_swing, IN u32 dac_swing_lvl)
1178 /* halbtc8821a2ant_agc_table(btcoexist, NORMAL_EXEC, agc_table_shift); */
1179 /* halbtc8821a2ant_adc_back_off(btcoexist, NORMAL_EXEC, adc_back_off); */
1180 halbtc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, sw_dac_swing,
1184 void halbtc8821a2ant_set_ant_path(IN struct btc_coexist *btcoexist,
1185 IN u8 ant_pos_type, IN boolean init_hwcfg, IN boolean wifi_off)
1187 struct btc_board_info *board_info = &btcoexist->board_info;
1189 u8 h2c_parameter[2] = {0};
1192 /* 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT */
1193 u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c);
1196 btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp);
1198 btcoexist->btc_write_4byte(btcoexist, 0x974, 0x3ff);
1199 /* btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77); */
1201 if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) {
1202 /* tell firmware "antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix */
1203 h2c_parameter[0] = 1;
1204 h2c_parameter[1] = 1;
1205 btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
1208 /* tell firmware "no antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix */
1209 h2c_parameter[0] = 0;
1210 h2c_parameter[1] = 1;
1211 btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
1216 /* ext switch setting */
1217 switch (ant_pos_type) {
1218 case BTC_ANT_WIFI_AT_MAIN:
1219 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
1222 case BTC_ANT_WIFI_AT_AUX:
1223 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
1229 void halbtc8821a2ant_ps_tdma(IN struct btc_coexist *btcoexist,
1230 IN boolean force_exec, IN boolean turn_on, IN u8 type)
1232 u8 wifi_rssi_state1, bt_rssi_state;
1235 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
1236 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
1237 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
1238 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
1240 if (!(BTC_RSSI_HIGH(wifi_rssi_state1) &&
1241 BTC_RSSI_HIGH(bt_rssi_state)) && turn_on) {
1242 type = type + 100; /* for WiFi RSSI low or BT RSSI low */
1245 coex_dm->cur_ps_tdma_on = turn_on;
1246 coex_dm->cur_ps_tdma = type;
1249 if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
1250 (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma))
1257 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); */
1258 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1259 0x3c, 0x03, 0xf1, 0x90);
1262 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); */
1263 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1264 0x2d, 0x03, 0xf1, 0x90);
1267 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1268 0x1c, 0x3, 0xf1, 0x90);
1271 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1272 0x10, 0x03, 0xf1, 0x90);
1275 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); */
1276 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1277 0x3c, 0x3, 0x70, 0x90);
1280 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); */
1281 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1282 0x2d, 0x3, 0x70, 0x90);
1285 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1286 0x1c, 0x3, 0x70, 0x90);
1289 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xa3,
1290 0x10, 0x3, 0x70, 0x90);
1293 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); */
1294 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1295 0x3c, 0x03, 0xf1, 0x90);
1298 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); */
1299 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1300 0x2d, 0x03, 0xf1, 0x90);
1303 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90); */
1304 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1305 0x1c, 0x3, 0xf1, 0x90);
1308 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); */
1309 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1310 0x10, 0x3, 0xf1, 0x90);
1313 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); */
1314 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1315 0x3c, 0x3, 0x70, 0x90);
1318 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); */
1319 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1320 0x2d, 0x3, 0x70, 0x90);
1323 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0xa, 0xa, 0x60, 0x90); */
1324 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1325 0x1c, 0x3, 0x70, 0x90);
1328 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x5, 0x5, 0x60, 0x90); */
1329 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1330 0x10, 0x3, 0x70, 0x90);
1333 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xa3,
1334 0x2f, 0x2f, 0x60, 0x90);
1337 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1338 0x5, 0x5, 0xe1, 0x90);
1341 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1342 0x25, 0x25, 0xe1, 0x90);
1345 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1346 0x25, 0x25, 0x60, 0x90);
1349 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1350 0x15, 0x03, 0x70, 0x90);
1353 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1354 0x1e, 0x03, 0xf0, 0x14);
1358 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xd3,
1359 0x3c, 0x03, 0x70, 0x50);
1361 /* case25/case125 : for lenovo bt pan tp degrade<30% while wifi downlink */
1363 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1364 0x14, 0x03, 0xf1, 0x90);
1367 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1368 0x30, 0x03, 0xf1, 0x90);
1371 /* halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); */
1373 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1374 0x3c, 0x03, 0xf1, 0x90);
1379 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xd3,
1380 0x3a, 0x03, 0x70, 0x50);
1386 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xd3,
1387 0x2d, 0x03, 0x70, 0x50);
1393 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xd3,
1394 0x1c, 0x03, 0x70, 0x50);
1400 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xd3,
1401 0x10, 0x03, 0x70, 0x50);
1404 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1405 0x3c, 0x03, 0xf1, 0x90);
1408 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1409 0x3c, 0x03, 0x70, 0x90);
1412 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1413 0x15, 0x03, 0x70, 0x90);
1417 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3,
1418 0x35, 0x03, 0x71, 0x11);
1421 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xd3,
1422 0x1c, 0x03, 0x70, 0x54);
1424 /* case25/case125 : for lenovo bt pan tp degrade<30% while wifi downlink */
1426 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xd3,
1427 0x14, 0x03, 0x70, 0x50);
1430 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xd3,
1431 0x30, 0x03, 0x70, 0x50);
1435 /* disable PS tdma */
1438 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0x0,
1439 0x0, 0x0, 0x40, 0x0);
1442 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0x0,
1443 0x0, 0x0, 0x48, 0x0);
1446 halbtc8821a2ant_set_fw_pstdma(btcoexist, 0x0,
1447 0x0, 0x0, 0x40, 0x0);
1452 /* update pre state */
1453 coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
1454 coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
1457 void halbtc8821a2ant_ps_tdma_check_for_power_save_state(
1458 IN struct btc_coexist *btcoexist, IN boolean new_ps_state)
1462 btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode);
1464 if (lps_mode) { /* already under LPS state */
1466 /* keep state under LPS, do nothing. */
1468 /* will leave LPS state, turn off psTdma first */
1469 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1472 } else { /* NO PS state */
1474 /* will enter LPS state, turn off psTdma first */
1475 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1478 /* keep state under NO PS state, do nothing. */
1483 void halbtc8821a2ant_power_save_state(IN struct btc_coexist *btcoexist,
1484 IN u8 ps_type, IN u8 lps_val, IN u8 rpwm_val)
1486 boolean low_pwr_disable = false;
1489 case BTC_PS_WIFI_NATIVE:
1490 /* recover to original 32k low power setting */
1491 low_pwr_disable = false;
1492 btcoexist->btc_set(btcoexist,
1493 BTC_SET_ACT_DISABLE_LOW_POWER,
1495 btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS,
1497 coex_sta->force_lps_on = false;
1500 halbtc8821a2ant_ps_tdma_check_for_power_save_state(
1502 halbtc8821a2ant_lps_rpwm(btcoexist, NORMAL_EXEC,
1504 /* when coex force to enter LPS, do not enter 32k low power. */
1505 low_pwr_disable = true;
1506 btcoexist->btc_set(btcoexist,
1507 BTC_SET_ACT_DISABLE_LOW_POWER,
1509 /* power save must executed before psTdma. */
1510 btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS,
1512 coex_sta->force_lps_on = true;
1514 case BTC_PS_LPS_OFF:
1515 halbtc8821a2ant_ps_tdma_check_for_power_save_state(
1517 btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS,
1519 coex_sta->force_lps_on = false;
1527 void halbtc8821a2ant_coex_all_off(IN struct btc_coexist *btcoexist)
1530 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
1532 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1533 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1534 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1537 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false, false);
1538 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
1541 /* btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); */
1542 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
1545 void halbtc8821a2ant_coex_under_5g(IN struct btc_coexist *btcoexist)
1547 halbtc8821a2ant_coex_all_off(btcoexist);
1549 halbtc8821a2ant_ignore_wlan_act(btcoexist, NORMAL_EXEC, true);
1552 void halbtc8821a2ant_init_coex_dm(IN struct btc_coexist *btcoexist)
1554 /* force to reset coex mechanism */
1555 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
1557 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
1559 halbtc8821a2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1);
1560 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6);
1561 halbtc8821a2ant_dec_bt_pwr(btcoexist, FORCE_EXEC, 0);
1563 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false, false);
1564 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
1567 void halbtc8821a2ant_action_bt_inquiry(IN struct btc_coexist *btcoexist)
1569 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
1570 boolean wifi_connected = false;
1571 boolean low_pwr_disable = true;
1572 boolean scan = false, link = false, roam = false;
1575 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
1577 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
1578 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
1579 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
1580 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
1582 btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
1584 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
1587 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
1588 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
1589 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
1592 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
1595 if (scan || link || roam) {
1596 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1597 "[BTCoex], Wifi link process + BT Inq/Page!!\n");
1598 BTC_TRACE(trace_buf);
1599 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
1601 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
1602 } else if (wifi_connected) {
1603 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1604 "[BTCoex], Wifi connected + BT Inq/Page!!\n");
1605 BTC_TRACE(trace_buf);
1606 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
1608 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
1610 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1611 "[BTCoex], Wifi no-link + BT Inq/Page!!\n");
1612 BTC_TRACE(trace_buf);
1613 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
1614 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1617 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6);
1618 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1620 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false, false);
1621 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
1626 void halbtc8821a2ant_action_wifi_link_process(IN struct btc_coexist *btcoexist)
1630 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 15);
1631 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
1633 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false, false);
1634 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
1638 u8tmpa = btcoexist->btc_read_1byte(btcoexist, 0x765);
1639 u8tmpb = btcoexist->btc_read_1byte(btcoexist, 0x76e);
1641 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1642 "############# [BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u8tmpa,
1644 BTC_TRACE(trace_buf);
1647 boolean halbtc8821a2ant_action_wifi_idle_process(IN struct btc_coexist
1650 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
1653 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
1655 /* wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); */
1656 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
1657 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES - 20, 0);
1658 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
1659 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
1661 btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num);
1663 /* define the office environment */
1664 if (BTC_RSSI_HIGH(wifi_rssi_state1) &&
1665 (coex_sta->hid_exist == true) &&
1666 (coex_sta->a2dp_exist == true)) {
1668 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1669 "[BTCoex], Wifi idle process for BT HID+A2DP exist!!\n");
1670 BTC_TRACE(trace_buf);
1672 halbtc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, true, 0x6);
1673 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1676 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false,
1678 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
1681 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
1683 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
1685 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1691 else if (coex_sta->pan_exist == true) {
1693 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1694 "[BTCoex], Wifi idle process for BT PAN exist!!\n");
1695 BTC_TRACE(trace_buf);
1697 halbtc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, true, 0x6);
1698 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1701 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false,
1703 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
1706 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
1708 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
1710 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1716 halbtc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, true, 0x18);
1725 boolean halbtc8821a2ant_is_common_action(IN struct btc_coexist *btcoexist)
1727 boolean common = false, wifi_connected = false, wifi_busy = false;
1728 boolean bt_hs_on = false, low_pwr_disable = false;
1730 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
1731 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
1733 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
1735 if (!wifi_connected) {
1736 low_pwr_disable = false;
1737 btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
1739 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
1742 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1743 "[BTCoex], Wifi non-connected idle!!\n");
1744 BTC_TRACE(trace_buf);
1746 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff,
1748 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
1750 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
1752 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1753 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1754 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1756 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false,
1758 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
1763 if (BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE ==
1764 coex_dm->bt_status) {
1765 low_pwr_disable = false;
1766 btcoexist->btc_set(btcoexist,
1767 BTC_SET_ACT_DISABLE_LOW_POWER,
1769 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC,
1772 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1773 "[BTCoex], Wifi connected + BT non connected-idle!!\n");
1774 BTC_TRACE(trace_buf);
1776 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
1778 halbtc8821a2ant_coex_table_with_type(btcoexist,
1781 halbtc8821a2ant_power_save_state(btcoexist,
1782 BTC_PS_WIFI_NATIVE, 0x0, 0x0);
1783 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1785 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
1787 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1789 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false,
1791 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
1795 } else if (BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE ==
1796 coex_dm->bt_status) {
1797 low_pwr_disable = true;
1798 btcoexist->btc_set(btcoexist,
1799 BTC_SET_ACT_DISABLE_LOW_POWER,
1804 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1805 "[BTCoex], Wifi connected + BT connected-idle!!\n");
1806 BTC_TRACE(trace_buf);
1807 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC,
1810 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
1812 halbtc8821a2ant_coex_table_with_type(btcoexist,
1815 halbtc8821a2ant_power_save_state(btcoexist,
1816 BTC_PS_WIFI_NATIVE, 0x0, 0x0);
1817 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1819 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
1821 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1823 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
1825 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
1830 low_pwr_disable = true;
1831 btcoexist->btc_set(btcoexist,
1832 BTC_SET_ACT_DISABLE_LOW_POWER,
1836 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1837 "[BTCoex], Wifi Connected-Busy + BT Busy!!\n");
1838 BTC_TRACE(trace_buf);
1840 /* common = halbtc8821a2ant_action_wifi_idle_process(btcoexist); */
1842 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1843 "[BTCoex], Wifi Connected-Idle + BT Busy!!\n");
1844 BTC_TRACE(trace_buf);
1845 /* common = false; */
1846 common = halbtc8821a2ant_action_wifi_idle_process(
1854 void halbtc8821a2ant_tdma_duration_adjust(IN struct btc_coexist *btcoexist,
1855 IN boolean sco_hid, IN boolean tx_pause, IN u8 max_interval)
1857 static s32 up, dn, m, n, wait_count;
1858 s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */
1861 if (!coex_dm->auto_tdma_adjust) {
1862 coex_dm->auto_tdma_adjust = true;
1866 if (max_interval == 1) {
1867 halbtc8821a2ant_ps_tdma(
1868 btcoexist, NORMAL_EXEC,
1870 coex_dm->ps_tdma_du_adj_type =
1872 } else if (max_interval == 2) {
1873 halbtc8821a2ant_ps_tdma(
1874 btcoexist, NORMAL_EXEC,
1876 coex_dm->ps_tdma_du_adj_type =
1878 } else if (max_interval == 3) {
1879 halbtc8821a2ant_ps_tdma(
1880 btcoexist, NORMAL_EXEC,
1882 coex_dm->ps_tdma_du_adj_type =
1885 halbtc8821a2ant_ps_tdma(
1886 btcoexist, NORMAL_EXEC,
1888 coex_dm->ps_tdma_du_adj_type =
1892 if (max_interval == 1) {
1893 halbtc8821a2ant_ps_tdma(
1894 btcoexist, NORMAL_EXEC,
1896 coex_dm->ps_tdma_du_adj_type =
1898 } else if (max_interval == 2) {
1899 halbtc8821a2ant_ps_tdma(
1900 btcoexist, NORMAL_EXEC,
1902 coex_dm->ps_tdma_du_adj_type =
1904 } else if (max_interval == 3) {
1905 halbtc8821a2ant_ps_tdma(
1906 btcoexist, NORMAL_EXEC,
1908 coex_dm->ps_tdma_du_adj_type =
1911 halbtc8821a2ant_ps_tdma(
1912 btcoexist, NORMAL_EXEC,
1914 coex_dm->ps_tdma_du_adj_type =
1920 if (max_interval == 1) {
1921 halbtc8821a2ant_ps_tdma(
1922 btcoexist, NORMAL_EXEC,
1924 coex_dm->ps_tdma_du_adj_type =
1926 } else if (max_interval == 2) {
1927 halbtc8821a2ant_ps_tdma(
1928 btcoexist, NORMAL_EXEC,
1930 coex_dm->ps_tdma_du_adj_type =
1932 } else if (max_interval == 3) {
1933 halbtc8821a2ant_ps_tdma(
1934 btcoexist, NORMAL_EXEC,
1936 coex_dm->ps_tdma_du_adj_type =
1939 halbtc8821a2ant_ps_tdma(
1940 btcoexist, NORMAL_EXEC,
1942 coex_dm->ps_tdma_du_adj_type =
1946 if (max_interval == 1) {
1947 halbtc8821a2ant_ps_tdma(
1948 btcoexist, NORMAL_EXEC,
1950 coex_dm->ps_tdma_du_adj_type =
1952 } else if (max_interval == 2) {
1953 halbtc8821a2ant_ps_tdma(
1954 btcoexist, NORMAL_EXEC,
1956 coex_dm->ps_tdma_du_adj_type =
1958 } else if (max_interval == 3) {
1959 halbtc8821a2ant_ps_tdma(
1960 btcoexist, NORMAL_EXEC,
1962 coex_dm->ps_tdma_du_adj_type =
1965 halbtc8821a2ant_ps_tdma(
1966 btcoexist, NORMAL_EXEC,
1968 coex_dm->ps_tdma_du_adj_type =
1982 /* accquire the BT TRx retry count from BT_Info byte2 */
1983 retry_count = coex_sta->bt_retry_cnt;
1988 0) { /* no retry in the last 2-second duration */
1995 if (up >= n) { /* if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration */
2002 } else if (retry_count <=
2003 3) { /* <=3 retry in the last 2-second duration */
2010 if (dn == 2) { /* if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration */
2011 if (wait_count <= 2)
2012 m++; /* ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^ */
2016 if (m >= 20) /* m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. */
2025 } else { /* retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration */
2026 if (wait_count == 1)
2027 m++; /* ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^ */
2031 if (m >= 20) /* m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. */
2041 if (max_interval == 1) {
2043 if (coex_dm->cur_ps_tdma == 71) {
2044 halbtc8821a2ant_ps_tdma(btcoexist,
2045 NORMAL_EXEC, true, 5);
2046 coex_dm->ps_tdma_du_adj_type = 5;
2047 } else if (coex_dm->cur_ps_tdma == 1) {
2048 halbtc8821a2ant_ps_tdma(btcoexist,
2049 NORMAL_EXEC, true, 5);
2050 coex_dm->ps_tdma_du_adj_type = 5;
2051 } else if (coex_dm->cur_ps_tdma == 2) {
2052 halbtc8821a2ant_ps_tdma(btcoexist,
2053 NORMAL_EXEC, true, 6);
2054 coex_dm->ps_tdma_du_adj_type = 6;
2055 } else if (coex_dm->cur_ps_tdma == 3) {
2056 halbtc8821a2ant_ps_tdma(btcoexist,
2057 NORMAL_EXEC, true, 7);
2058 coex_dm->ps_tdma_du_adj_type = 7;
2059 } else if (coex_dm->cur_ps_tdma == 4) {
2060 halbtc8821a2ant_ps_tdma(btcoexist,
2061 NORMAL_EXEC, true, 8);
2062 coex_dm->ps_tdma_du_adj_type = 8;
2064 if (coex_dm->cur_ps_tdma == 9) {
2065 halbtc8821a2ant_ps_tdma(btcoexist,
2066 NORMAL_EXEC, true, 13);
2067 coex_dm->ps_tdma_du_adj_type = 13;
2068 } else if (coex_dm->cur_ps_tdma == 10) {
2069 halbtc8821a2ant_ps_tdma(btcoexist,
2070 NORMAL_EXEC, true, 14);
2071 coex_dm->ps_tdma_du_adj_type = 14;
2072 } else if (coex_dm->cur_ps_tdma == 11) {
2073 halbtc8821a2ant_ps_tdma(btcoexist,
2074 NORMAL_EXEC, true, 15);
2075 coex_dm->ps_tdma_du_adj_type = 15;
2076 } else if (coex_dm->cur_ps_tdma == 12) {
2077 halbtc8821a2ant_ps_tdma(btcoexist,
2078 NORMAL_EXEC, true, 16);
2079 coex_dm->ps_tdma_du_adj_type = 16;
2083 if (coex_dm->cur_ps_tdma == 5) {
2084 halbtc8821a2ant_ps_tdma(
2085 btcoexist, NORMAL_EXEC,
2087 coex_dm->ps_tdma_du_adj_type =
2089 } else if (coex_dm->cur_ps_tdma == 6) {
2090 halbtc8821a2ant_ps_tdma(
2091 btcoexist, NORMAL_EXEC,
2093 coex_dm->ps_tdma_du_adj_type =
2095 } else if (coex_dm->cur_ps_tdma == 7) {
2096 halbtc8821a2ant_ps_tdma(
2097 btcoexist, NORMAL_EXEC,
2099 coex_dm->ps_tdma_du_adj_type =
2101 } else if (coex_dm->cur_ps_tdma == 13) {
2102 halbtc8821a2ant_ps_tdma(
2103 btcoexist, NORMAL_EXEC,
2105 coex_dm->ps_tdma_du_adj_type =
2107 } else if (coex_dm->cur_ps_tdma == 14) {
2108 halbtc8821a2ant_ps_tdma(
2109 btcoexist, NORMAL_EXEC,
2111 coex_dm->ps_tdma_du_adj_type =
2113 } else if (coex_dm->cur_ps_tdma == 15) {
2114 halbtc8821a2ant_ps_tdma(
2115 btcoexist, NORMAL_EXEC,
2117 coex_dm->ps_tdma_du_adj_type =
2120 } else if (result == 1) {
2121 if (coex_dm->cur_ps_tdma == 8) {
2122 halbtc8821a2ant_ps_tdma(
2123 btcoexist, NORMAL_EXEC,
2125 coex_dm->ps_tdma_du_adj_type =
2127 } else if (coex_dm->cur_ps_tdma == 7) {
2128 halbtc8821a2ant_ps_tdma(
2129 btcoexist, NORMAL_EXEC,
2131 coex_dm->ps_tdma_du_adj_type =
2133 } else if (coex_dm->cur_ps_tdma == 6) {
2134 halbtc8821a2ant_ps_tdma(
2135 btcoexist, NORMAL_EXEC,
2137 coex_dm->ps_tdma_du_adj_type =
2139 } else if (coex_dm->cur_ps_tdma == 16) {
2140 halbtc8821a2ant_ps_tdma(
2141 btcoexist, NORMAL_EXEC,
2143 coex_dm->ps_tdma_du_adj_type =
2145 } else if (coex_dm->cur_ps_tdma == 15) {
2146 halbtc8821a2ant_ps_tdma(
2147 btcoexist, NORMAL_EXEC,
2149 coex_dm->ps_tdma_du_adj_type =
2151 } else if (coex_dm->cur_ps_tdma == 14) {
2152 halbtc8821a2ant_ps_tdma(
2153 btcoexist, NORMAL_EXEC,
2155 coex_dm->ps_tdma_du_adj_type =
2160 if (coex_dm->cur_ps_tdma == 5) {
2161 halbtc8821a2ant_ps_tdma(btcoexist,
2162 NORMAL_EXEC, true, 71);
2163 coex_dm->ps_tdma_du_adj_type = 71;
2164 } else if (coex_dm->cur_ps_tdma == 6) {
2165 halbtc8821a2ant_ps_tdma(btcoexist,
2166 NORMAL_EXEC, true, 2);
2167 coex_dm->ps_tdma_du_adj_type = 2;
2168 } else if (coex_dm->cur_ps_tdma == 7) {
2169 halbtc8821a2ant_ps_tdma(btcoexist,
2170 NORMAL_EXEC, true, 3);
2171 coex_dm->ps_tdma_du_adj_type = 3;
2172 } else if (coex_dm->cur_ps_tdma == 8) {
2173 halbtc8821a2ant_ps_tdma(btcoexist,
2174 NORMAL_EXEC, true, 4);
2175 coex_dm->ps_tdma_du_adj_type = 4;
2177 if (coex_dm->cur_ps_tdma == 13) {
2178 halbtc8821a2ant_ps_tdma(btcoexist,
2179 NORMAL_EXEC, true, 9);
2180 coex_dm->ps_tdma_du_adj_type = 9;
2181 } else if (coex_dm->cur_ps_tdma == 14) {
2182 halbtc8821a2ant_ps_tdma(btcoexist,
2183 NORMAL_EXEC, true, 10);
2184 coex_dm->ps_tdma_du_adj_type = 10;
2185 } else if (coex_dm->cur_ps_tdma == 15) {
2186 halbtc8821a2ant_ps_tdma(btcoexist,
2187 NORMAL_EXEC, true, 11);
2188 coex_dm->ps_tdma_du_adj_type = 11;
2189 } else if (coex_dm->cur_ps_tdma == 16) {
2190 halbtc8821a2ant_ps_tdma(btcoexist,
2191 NORMAL_EXEC, true, 12);
2192 coex_dm->ps_tdma_du_adj_type = 12;
2196 if (coex_dm->cur_ps_tdma == 71) {
2197 halbtc8821a2ant_ps_tdma(
2198 btcoexist, NORMAL_EXEC,
2200 coex_dm->ps_tdma_du_adj_type =
2202 } else if (coex_dm->cur_ps_tdma == 1) {
2203 halbtc8821a2ant_ps_tdma(
2204 btcoexist, NORMAL_EXEC,
2206 coex_dm->ps_tdma_du_adj_type =
2208 } else if (coex_dm->cur_ps_tdma == 2) {
2209 halbtc8821a2ant_ps_tdma(
2210 btcoexist, NORMAL_EXEC,
2212 coex_dm->ps_tdma_du_adj_type =
2214 } else if (coex_dm->cur_ps_tdma == 3) {
2215 halbtc8821a2ant_ps_tdma(
2216 btcoexist, NORMAL_EXEC,
2218 coex_dm->ps_tdma_du_adj_type =
2220 } else if (coex_dm->cur_ps_tdma == 9) {
2221 halbtc8821a2ant_ps_tdma(
2222 btcoexist, NORMAL_EXEC,
2224 coex_dm->ps_tdma_du_adj_type =
2226 } else if (coex_dm->cur_ps_tdma == 10) {
2227 halbtc8821a2ant_ps_tdma(
2228 btcoexist, NORMAL_EXEC,
2230 coex_dm->ps_tdma_du_adj_type =
2232 } else if (coex_dm->cur_ps_tdma == 11) {
2233 halbtc8821a2ant_ps_tdma(
2234 btcoexist, NORMAL_EXEC,
2236 coex_dm->ps_tdma_du_adj_type =
2239 } else if (result == 1) {
2240 if (coex_dm->cur_ps_tdma == 4) {
2241 halbtc8821a2ant_ps_tdma(
2242 btcoexist, NORMAL_EXEC,
2244 coex_dm->ps_tdma_du_adj_type =
2246 } else if (coex_dm->cur_ps_tdma == 3) {
2247 halbtc8821a2ant_ps_tdma(
2248 btcoexist, NORMAL_EXEC,
2250 coex_dm->ps_tdma_du_adj_type =
2252 } else if (coex_dm->cur_ps_tdma == 2) {
2253 halbtc8821a2ant_ps_tdma(
2254 btcoexist, NORMAL_EXEC,
2256 coex_dm->ps_tdma_du_adj_type =
2258 } else if (coex_dm->cur_ps_tdma == 1) {
2259 halbtc8821a2ant_ps_tdma(
2260 btcoexist, NORMAL_EXEC,
2262 coex_dm->ps_tdma_du_adj_type =
2264 } else if (coex_dm->cur_ps_tdma == 12) {
2265 halbtc8821a2ant_ps_tdma(
2266 btcoexist, NORMAL_EXEC,
2268 coex_dm->ps_tdma_du_adj_type =
2270 } else if (coex_dm->cur_ps_tdma == 11) {
2271 halbtc8821a2ant_ps_tdma(
2272 btcoexist, NORMAL_EXEC,
2274 coex_dm->ps_tdma_du_adj_type =
2276 } else if (coex_dm->cur_ps_tdma == 10) {
2277 halbtc8821a2ant_ps_tdma(
2278 btcoexist, NORMAL_EXEC,
2280 coex_dm->ps_tdma_du_adj_type =
2285 } else if (max_interval == 2) {
2287 if (coex_dm->cur_ps_tdma == 1) {
2288 halbtc8821a2ant_ps_tdma(btcoexist,
2289 NORMAL_EXEC, true, 6);
2290 coex_dm->ps_tdma_du_adj_type = 6;
2291 } else if (coex_dm->cur_ps_tdma == 2) {
2292 halbtc8821a2ant_ps_tdma(btcoexist,
2293 NORMAL_EXEC, true, 6);
2294 coex_dm->ps_tdma_du_adj_type = 6;
2295 } else if (coex_dm->cur_ps_tdma == 3) {
2296 halbtc8821a2ant_ps_tdma(btcoexist,
2297 NORMAL_EXEC, true, 7);
2298 coex_dm->ps_tdma_du_adj_type = 7;
2299 } else if (coex_dm->cur_ps_tdma == 4) {
2300 halbtc8821a2ant_ps_tdma(btcoexist,
2301 NORMAL_EXEC, true, 8);
2302 coex_dm->ps_tdma_du_adj_type = 8;
2304 if (coex_dm->cur_ps_tdma == 9) {
2305 halbtc8821a2ant_ps_tdma(btcoexist,
2306 NORMAL_EXEC, true, 14);
2307 coex_dm->ps_tdma_du_adj_type = 14;
2308 } else if (coex_dm->cur_ps_tdma == 10) {
2309 halbtc8821a2ant_ps_tdma(btcoexist,
2310 NORMAL_EXEC, true, 14);
2311 coex_dm->ps_tdma_du_adj_type = 14;
2312 } else if (coex_dm->cur_ps_tdma == 11) {
2313 halbtc8821a2ant_ps_tdma(btcoexist,
2314 NORMAL_EXEC, true, 15);
2315 coex_dm->ps_tdma_du_adj_type = 15;
2316 } else if (coex_dm->cur_ps_tdma == 12) {
2317 halbtc8821a2ant_ps_tdma(btcoexist,
2318 NORMAL_EXEC, true, 16);
2319 coex_dm->ps_tdma_du_adj_type = 16;
2322 if (coex_dm->cur_ps_tdma == 5) {
2323 halbtc8821a2ant_ps_tdma(
2324 btcoexist, NORMAL_EXEC,
2326 coex_dm->ps_tdma_du_adj_type =
2328 } else if (coex_dm->cur_ps_tdma == 6) {
2329 halbtc8821a2ant_ps_tdma(
2330 btcoexist, NORMAL_EXEC,
2332 coex_dm->ps_tdma_du_adj_type =
2334 } else if (coex_dm->cur_ps_tdma == 7) {
2335 halbtc8821a2ant_ps_tdma(
2336 btcoexist, NORMAL_EXEC,
2338 coex_dm->ps_tdma_du_adj_type =
2340 } else if (coex_dm->cur_ps_tdma == 13) {
2341 halbtc8821a2ant_ps_tdma(
2342 btcoexist, NORMAL_EXEC,
2344 coex_dm->ps_tdma_du_adj_type =
2346 } else if (coex_dm->cur_ps_tdma == 14) {
2347 halbtc8821a2ant_ps_tdma(
2348 btcoexist, NORMAL_EXEC,
2350 coex_dm->ps_tdma_du_adj_type =
2352 } else if (coex_dm->cur_ps_tdma == 15) {
2353 halbtc8821a2ant_ps_tdma(
2354 btcoexist, NORMAL_EXEC,
2356 coex_dm->ps_tdma_du_adj_type =
2359 } else if (result == 1) {
2360 if (coex_dm->cur_ps_tdma == 8) {
2361 halbtc8821a2ant_ps_tdma(
2362 btcoexist, NORMAL_EXEC,
2364 coex_dm->ps_tdma_du_adj_type =
2366 } else if (coex_dm->cur_ps_tdma == 7) {
2367 halbtc8821a2ant_ps_tdma(
2368 btcoexist, NORMAL_EXEC,
2370 coex_dm->ps_tdma_du_adj_type =
2372 } else if (coex_dm->cur_ps_tdma == 6) {
2373 halbtc8821a2ant_ps_tdma(
2374 btcoexist, NORMAL_EXEC,
2376 coex_dm->ps_tdma_du_adj_type =
2378 } else if (coex_dm->cur_ps_tdma == 16) {
2379 halbtc8821a2ant_ps_tdma(
2380 btcoexist, NORMAL_EXEC,
2382 coex_dm->ps_tdma_du_adj_type =
2384 } else if (coex_dm->cur_ps_tdma == 15) {
2385 halbtc8821a2ant_ps_tdma(
2386 btcoexist, NORMAL_EXEC,
2388 coex_dm->ps_tdma_du_adj_type =
2390 } else if (coex_dm->cur_ps_tdma == 14) {
2391 halbtc8821a2ant_ps_tdma(
2392 btcoexist, NORMAL_EXEC,
2394 coex_dm->ps_tdma_du_adj_type =
2399 if (coex_dm->cur_ps_tdma == 5) {
2400 halbtc8821a2ant_ps_tdma(btcoexist,
2401 NORMAL_EXEC, true, 2);
2402 coex_dm->ps_tdma_du_adj_type = 2;
2403 } else if (coex_dm->cur_ps_tdma == 6) {
2404 halbtc8821a2ant_ps_tdma(btcoexist,
2405 NORMAL_EXEC, true, 2);
2406 coex_dm->ps_tdma_du_adj_type = 2;
2407 } else if (coex_dm->cur_ps_tdma == 7) {
2408 halbtc8821a2ant_ps_tdma(btcoexist,
2409 NORMAL_EXEC, true, 3);
2410 coex_dm->ps_tdma_du_adj_type = 3;
2411 } else if (coex_dm->cur_ps_tdma == 8) {
2412 halbtc8821a2ant_ps_tdma(btcoexist,
2413 NORMAL_EXEC, true, 4);
2414 coex_dm->ps_tdma_du_adj_type = 4;
2416 if (coex_dm->cur_ps_tdma == 13) {
2417 halbtc8821a2ant_ps_tdma(btcoexist,
2418 NORMAL_EXEC, true, 10);
2419 coex_dm->ps_tdma_du_adj_type = 10;
2420 } else if (coex_dm->cur_ps_tdma == 14) {
2421 halbtc8821a2ant_ps_tdma(btcoexist,
2422 NORMAL_EXEC, true, 10);
2423 coex_dm->ps_tdma_du_adj_type = 10;
2424 } else if (coex_dm->cur_ps_tdma == 15) {
2425 halbtc8821a2ant_ps_tdma(btcoexist,
2426 NORMAL_EXEC, true, 11);
2427 coex_dm->ps_tdma_du_adj_type = 11;
2428 } else if (coex_dm->cur_ps_tdma == 16) {
2429 halbtc8821a2ant_ps_tdma(btcoexist,
2430 NORMAL_EXEC, true, 12);
2431 coex_dm->ps_tdma_du_adj_type = 12;
2434 if (coex_dm->cur_ps_tdma == 1) {
2435 halbtc8821a2ant_ps_tdma(
2436 btcoexist, NORMAL_EXEC,
2438 coex_dm->ps_tdma_du_adj_type =
2440 } else if (coex_dm->cur_ps_tdma == 2) {
2441 halbtc8821a2ant_ps_tdma(
2442 btcoexist, NORMAL_EXEC,
2444 coex_dm->ps_tdma_du_adj_type =
2446 } else if (coex_dm->cur_ps_tdma == 3) {
2447 halbtc8821a2ant_ps_tdma(
2448 btcoexist, NORMAL_EXEC,
2450 coex_dm->ps_tdma_du_adj_type =
2452 } else if (coex_dm->cur_ps_tdma == 9) {
2453 halbtc8821a2ant_ps_tdma(
2454 btcoexist, NORMAL_EXEC,
2456 coex_dm->ps_tdma_du_adj_type =
2458 } else if (coex_dm->cur_ps_tdma == 10) {
2459 halbtc8821a2ant_ps_tdma(
2460 btcoexist, NORMAL_EXEC,
2462 coex_dm->ps_tdma_du_adj_type =
2464 } else if (coex_dm->cur_ps_tdma == 11) {
2465 halbtc8821a2ant_ps_tdma(
2466 btcoexist, NORMAL_EXEC,
2468 coex_dm->ps_tdma_du_adj_type =
2471 } else if (result == 1) {
2472 if (coex_dm->cur_ps_tdma == 4) {
2473 halbtc8821a2ant_ps_tdma(
2474 btcoexist, NORMAL_EXEC,
2476 coex_dm->ps_tdma_du_adj_type =
2478 } else if (coex_dm->cur_ps_tdma == 3) {
2479 halbtc8821a2ant_ps_tdma(
2480 btcoexist, NORMAL_EXEC,
2482 coex_dm->ps_tdma_du_adj_type =
2484 } else if (coex_dm->cur_ps_tdma == 2) {
2485 halbtc8821a2ant_ps_tdma(
2486 btcoexist, NORMAL_EXEC,
2488 coex_dm->ps_tdma_du_adj_type =
2490 } else if (coex_dm->cur_ps_tdma == 12) {
2491 halbtc8821a2ant_ps_tdma(
2492 btcoexist, NORMAL_EXEC,
2494 coex_dm->ps_tdma_du_adj_type =
2496 } else if (coex_dm->cur_ps_tdma == 11) {
2497 halbtc8821a2ant_ps_tdma(
2498 btcoexist, NORMAL_EXEC,
2500 coex_dm->ps_tdma_du_adj_type =
2502 } else if (coex_dm->cur_ps_tdma == 10) {
2503 halbtc8821a2ant_ps_tdma(
2504 btcoexist, NORMAL_EXEC,
2506 coex_dm->ps_tdma_du_adj_type =
2511 } else if (max_interval == 3) {
2513 if (coex_dm->cur_ps_tdma == 1) {
2514 halbtc8821a2ant_ps_tdma(btcoexist,
2515 NORMAL_EXEC, true, 7);
2516 coex_dm->ps_tdma_du_adj_type = 7;
2517 } else if (coex_dm->cur_ps_tdma == 2) {
2518 halbtc8821a2ant_ps_tdma(btcoexist,
2519 NORMAL_EXEC, true, 7);
2520 coex_dm->ps_tdma_du_adj_type = 7;
2521 } else if (coex_dm->cur_ps_tdma == 3) {
2522 halbtc8821a2ant_ps_tdma(btcoexist,
2523 NORMAL_EXEC, true, 7);
2524 coex_dm->ps_tdma_du_adj_type = 7;
2525 } else if (coex_dm->cur_ps_tdma == 4) {
2526 halbtc8821a2ant_ps_tdma(btcoexist,
2527 NORMAL_EXEC, true, 8);
2528 coex_dm->ps_tdma_du_adj_type = 8;
2530 if (coex_dm->cur_ps_tdma == 9) {
2531 halbtc8821a2ant_ps_tdma(btcoexist,
2532 NORMAL_EXEC, true, 15);
2533 coex_dm->ps_tdma_du_adj_type = 15;
2534 } else if (coex_dm->cur_ps_tdma == 10) {
2535 halbtc8821a2ant_ps_tdma(btcoexist,
2536 NORMAL_EXEC, true, 15);
2537 coex_dm->ps_tdma_du_adj_type = 15;
2538 } else if (coex_dm->cur_ps_tdma == 11) {
2539 halbtc8821a2ant_ps_tdma(btcoexist,
2540 NORMAL_EXEC, true, 15);
2541 coex_dm->ps_tdma_du_adj_type = 15;
2542 } else if (coex_dm->cur_ps_tdma == 12) {
2543 halbtc8821a2ant_ps_tdma(btcoexist,
2544 NORMAL_EXEC, true, 16);
2545 coex_dm->ps_tdma_du_adj_type = 16;
2548 if (coex_dm->cur_ps_tdma == 5) {
2549 halbtc8821a2ant_ps_tdma(
2550 btcoexist, NORMAL_EXEC,
2552 coex_dm->ps_tdma_du_adj_type =
2554 } else if (coex_dm->cur_ps_tdma == 6) {
2555 halbtc8821a2ant_ps_tdma(
2556 btcoexist, NORMAL_EXEC,
2558 coex_dm->ps_tdma_du_adj_type =
2560 } else if (coex_dm->cur_ps_tdma == 7) {
2561 halbtc8821a2ant_ps_tdma(
2562 btcoexist, NORMAL_EXEC,
2564 coex_dm->ps_tdma_du_adj_type =
2566 } else if (coex_dm->cur_ps_tdma == 13) {
2567 halbtc8821a2ant_ps_tdma(
2568 btcoexist, NORMAL_EXEC,
2570 coex_dm->ps_tdma_du_adj_type =
2572 } else if (coex_dm->cur_ps_tdma == 14) {
2573 halbtc8821a2ant_ps_tdma(
2574 btcoexist, NORMAL_EXEC,
2576 coex_dm->ps_tdma_du_adj_type =
2578 } else if (coex_dm->cur_ps_tdma == 15) {
2579 halbtc8821a2ant_ps_tdma(
2580 btcoexist, NORMAL_EXEC,
2582 coex_dm->ps_tdma_du_adj_type =
2585 } else if (result == 1) {
2586 if (coex_dm->cur_ps_tdma == 8) {
2587 halbtc8821a2ant_ps_tdma(
2588 btcoexist, NORMAL_EXEC,
2590 coex_dm->ps_tdma_du_adj_type =
2592 } else if (coex_dm->cur_ps_tdma == 7) {
2593 halbtc8821a2ant_ps_tdma(
2594 btcoexist, NORMAL_EXEC,
2596 coex_dm->ps_tdma_du_adj_type =
2598 } else if (coex_dm->cur_ps_tdma == 6) {
2599 halbtc8821a2ant_ps_tdma(
2600 btcoexist, NORMAL_EXEC,
2602 coex_dm->ps_tdma_du_adj_type =
2604 } else if (coex_dm->cur_ps_tdma == 16) {
2605 halbtc8821a2ant_ps_tdma(
2606 btcoexist, NORMAL_EXEC,
2608 coex_dm->ps_tdma_du_adj_type =
2610 } else if (coex_dm->cur_ps_tdma == 15) {
2611 halbtc8821a2ant_ps_tdma(
2612 btcoexist, NORMAL_EXEC,
2614 coex_dm->ps_tdma_du_adj_type =
2616 } else if (coex_dm->cur_ps_tdma == 14) {
2617 halbtc8821a2ant_ps_tdma(
2618 btcoexist, NORMAL_EXEC,
2620 coex_dm->ps_tdma_du_adj_type =
2625 if (coex_dm->cur_ps_tdma == 5) {
2626 halbtc8821a2ant_ps_tdma(btcoexist,
2627 NORMAL_EXEC, true, 3);
2628 coex_dm->ps_tdma_du_adj_type = 3;
2629 } else if (coex_dm->cur_ps_tdma == 6) {
2630 halbtc8821a2ant_ps_tdma(btcoexist,
2631 NORMAL_EXEC, true, 3);
2632 coex_dm->ps_tdma_du_adj_type = 3;
2633 } else if (coex_dm->cur_ps_tdma == 7) {
2634 halbtc8821a2ant_ps_tdma(btcoexist,
2635 NORMAL_EXEC, true, 3);
2636 coex_dm->ps_tdma_du_adj_type = 3;
2637 } else if (coex_dm->cur_ps_tdma == 8) {
2638 halbtc8821a2ant_ps_tdma(btcoexist,
2639 NORMAL_EXEC, true, 4);
2640 coex_dm->ps_tdma_du_adj_type = 4;
2642 if (coex_dm->cur_ps_tdma == 13) {
2643 halbtc8821a2ant_ps_tdma(btcoexist,
2644 NORMAL_EXEC, true, 11);
2645 coex_dm->ps_tdma_du_adj_type = 11;
2646 } else if (coex_dm->cur_ps_tdma == 14) {
2647 halbtc8821a2ant_ps_tdma(btcoexist,
2648 NORMAL_EXEC, true, 11);
2649 coex_dm->ps_tdma_du_adj_type = 11;
2650 } else if (coex_dm->cur_ps_tdma == 15) {
2651 halbtc8821a2ant_ps_tdma(btcoexist,
2652 NORMAL_EXEC, true, 11);
2653 coex_dm->ps_tdma_du_adj_type = 11;
2654 } else if (coex_dm->cur_ps_tdma == 16) {
2655 halbtc8821a2ant_ps_tdma(btcoexist,
2656 NORMAL_EXEC, true, 12);
2657 coex_dm->ps_tdma_du_adj_type = 12;
2660 if (coex_dm->cur_ps_tdma == 1) {
2661 halbtc8821a2ant_ps_tdma(
2662 btcoexist, NORMAL_EXEC,
2664 coex_dm->ps_tdma_du_adj_type =
2666 } else if (coex_dm->cur_ps_tdma == 2) {
2667 halbtc8821a2ant_ps_tdma(
2668 btcoexist, NORMAL_EXEC,
2670 coex_dm->ps_tdma_du_adj_type =
2672 } else if (coex_dm->cur_ps_tdma == 3) {
2673 halbtc8821a2ant_ps_tdma(
2674 btcoexist, NORMAL_EXEC,
2676 coex_dm->ps_tdma_du_adj_type =
2678 } else if (coex_dm->cur_ps_tdma == 9) {
2679 halbtc8821a2ant_ps_tdma(
2680 btcoexist, NORMAL_EXEC,
2682 coex_dm->ps_tdma_du_adj_type =
2684 } else if (coex_dm->cur_ps_tdma == 10) {
2685 halbtc8821a2ant_ps_tdma(
2686 btcoexist, NORMAL_EXEC,
2688 coex_dm->ps_tdma_du_adj_type =
2690 } else if (coex_dm->cur_ps_tdma == 11) {
2691 halbtc8821a2ant_ps_tdma(
2692 btcoexist, NORMAL_EXEC,
2694 coex_dm->ps_tdma_du_adj_type =
2697 } else if (result == 1) {
2698 if (coex_dm->cur_ps_tdma == 4) {
2699 halbtc8821a2ant_ps_tdma(
2700 btcoexist, NORMAL_EXEC,
2702 coex_dm->ps_tdma_du_adj_type =
2704 } else if (coex_dm->cur_ps_tdma == 3) {
2705 halbtc8821a2ant_ps_tdma(
2706 btcoexist, NORMAL_EXEC,
2708 coex_dm->ps_tdma_du_adj_type =
2710 } else if (coex_dm->cur_ps_tdma == 2) {
2711 halbtc8821a2ant_ps_tdma(
2712 btcoexist, NORMAL_EXEC,
2714 coex_dm->ps_tdma_du_adj_type =
2716 } else if (coex_dm->cur_ps_tdma == 12) {
2717 halbtc8821a2ant_ps_tdma(
2718 btcoexist, NORMAL_EXEC,
2720 coex_dm->ps_tdma_du_adj_type =
2722 } else if (coex_dm->cur_ps_tdma == 11) {
2723 halbtc8821a2ant_ps_tdma(
2724 btcoexist, NORMAL_EXEC,
2726 coex_dm->ps_tdma_du_adj_type =
2728 } else if (coex_dm->cur_ps_tdma == 10) {
2729 halbtc8821a2ant_ps_tdma(
2730 btcoexist, NORMAL_EXEC,
2732 coex_dm->ps_tdma_du_adj_type =
2740 /* if current PsTdma not match with the recorded one (when scan, dhcp...), */
2741 /* then we have to adjust it back to the previous record one. */
2742 if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) {
2743 boolean scan = false, link = false, roam = false;
2744 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2745 "[BTCoex], PsTdma type dismatch!!!, cur_ps_tdma=%d, recordPsTdma=%d\n",
2746 coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type);
2747 BTC_TRACE(trace_buf);
2749 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
2750 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
2751 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
2753 if (!scan && !link && !roam)
2754 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
2755 coex_dm->ps_tdma_du_adj_type);
2757 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2758 "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n");
2759 BTC_TRACE(trace_buf);
2764 /* SCO only or SCO+PAN(HS) */
2765 void halbtc8821a2ant_action_sco(IN struct btc_coexist *btcoexist)
2767 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
2768 u8 wifi_rssi_state, bt_rssi_state;
2771 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
2773 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
2774 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
2776 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2778 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
2780 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 4);
2782 if (BTC_RSSI_HIGH(bt_rssi_state))
2783 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
2785 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
2787 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2789 if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for SCO quality at 11b/g mode */
2790 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
2791 else { /* for SCO quality & wifi performance balance at 11n mode */
2792 if (BTC_WIFI_BW_HT40 == wifi_bw)
2793 halbtc8821a2ant_coex_table_with_type(btcoexist,
2796 if (bt_link_info->sco_only)
2797 halbtc8821a2ant_coex_table_with_type(btcoexist,
2800 halbtc8821a2ant_coex_table_with_type(btcoexist,
2805 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
2807 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
2808 0); /* for voice quality */
2811 if (BTC_WIFI_BW_HT40 == wifi_bw) {
2812 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2813 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2814 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
2816 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
2819 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
2821 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
2825 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2826 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2827 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
2829 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
2832 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
2834 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
2841 void halbtc8821a2ant_action_hid(IN struct btc_coexist *btcoexist)
2843 u8 wifi_rssi_state, bt_rssi_state;
2846 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
2848 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
2849 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
2851 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2853 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
2855 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
2857 if (BTC_RSSI_HIGH(bt_rssi_state))
2858 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
2860 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
2862 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2864 if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */
2865 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
2866 else /* for HID quality & wifi performance balance at 11n mode */
2867 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
2869 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
2872 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 24);
2875 if (BTC_WIFI_BW_HT40 == wifi_bw) {
2876 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2877 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2878 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
2880 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
2883 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
2885 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
2889 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2890 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2891 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
2893 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
2896 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
2898 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
2904 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
2905 void halbtc8821a2ant_action_a2dp(IN struct btc_coexist *btcoexist)
2907 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
2911 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
2913 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
2914 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
2915 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
2916 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
2918 btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num);
2920 /* define the office environment */
2921 if ((ap_num >= 10) && BTC_RSSI_HIGH(wifi_rssi_state1) &&
2922 BTC_RSSI_HIGH(bt_rssi_state)) {
2923 /* dbg_print(" AP#>10(%d)\n", ap_num); */
2924 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
2927 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff,
2929 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
2931 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
2932 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
2934 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
2936 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
2938 /* halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); */
2939 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 23);
2942 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2943 if (BTC_WIFI_BW_HT40 == wifi_bw) {
2944 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
2946 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
2949 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
2951 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
2958 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2959 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
2961 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
2963 if (BTC_RSSI_HIGH(bt_rssi_state))
2964 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
2966 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
2969 if (BTC_RSSI_HIGH(wifi_rssi_state1) && BTC_RSSI_HIGH(bt_rssi_state)) {
2970 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
2971 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
2974 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
2976 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50,
2981 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
2982 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2983 /* halbtc8821a2ant_tdma_duration_adjust(btcoexist, false, false, 1); */
2984 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 23);
2986 /* halbtc8821a2ant_tdma_duration_adjust(btcoexist, false, true, 1); */
2987 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 23);
2991 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2992 if (BTC_WIFI_BW_HT40 == wifi_bw) {
2993 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2994 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2995 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
2997 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3000 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
3002 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3006 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3007 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3008 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3010 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3013 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3015 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3021 void halbtc8821a2ant_action_a2dp_pan_hs(IN struct btc_coexist *btcoexist)
3023 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
3026 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
3028 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
3029 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
3030 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
3031 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
3033 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
3035 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3037 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3039 if (BTC_RSSI_HIGH(bt_rssi_state))
3040 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3042 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3044 if (BTC_RSSI_HIGH(wifi_rssi_state1) && BTC_RSSI_HIGH(bt_rssi_state)) {
3045 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
3046 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3049 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3051 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50,
3055 halbtc8821a2ant_tdma_duration_adjust(btcoexist, false, true, 2);
3058 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3059 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3060 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3061 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3062 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
3064 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3067 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
3069 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3073 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3074 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3075 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3077 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3080 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3082 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3088 void halbtc8821a2ant_action_pan_edr(IN struct btc_coexist *btcoexist)
3090 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
3093 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
3095 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
3096 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
3097 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
3098 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
3100 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
3102 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3104 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3106 if (BTC_RSSI_HIGH(bt_rssi_state))
3107 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3109 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3111 if (BTC_RSSI_HIGH(wifi_rssi_state1) && BTC_RSSI_HIGH(bt_rssi_state)) {
3112 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3114 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3117 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3119 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50,
3123 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
3124 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
3125 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 26);
3127 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 26);
3130 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3131 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3132 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3133 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3134 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
3136 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3139 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
3141 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3145 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3146 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3147 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3149 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3152 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3154 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3162 void halbtc8821a2ant_action_pan_hs(IN struct btc_coexist *btcoexist)
3164 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
3167 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
3169 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
3170 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
3171 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
3172 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
3174 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
3176 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3178 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3180 if (BTC_RSSI_HIGH(bt_rssi_state))
3181 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3183 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3185 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
3187 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
3189 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
3191 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3192 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3193 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3194 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3195 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
3197 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3200 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
3202 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3206 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3207 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3208 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3210 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3213 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3215 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3222 void halbtc8821a2ant_action_pan_edr_a2dp(IN struct btc_coexist *btcoexist)
3224 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
3227 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
3229 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
3230 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
3231 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
3232 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
3234 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
3236 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3238 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3240 if (BTC_RSSI_HIGH(bt_rssi_state))
3241 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3243 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3245 if (BTC_RSSI_HIGH(wifi_rssi_state1) && BTC_RSSI_HIGH(bt_rssi_state))
3246 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3249 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50,
3252 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3254 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
3255 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3256 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3259 if (BTC_WIFI_BW_HT40 == wifi_bw)
3260 halbtc8821a2ant_tdma_duration_adjust(btcoexist, false,
3263 halbtc8821a2ant_tdma_duration_adjust(btcoexist, false,
3266 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3268 halbtc8821a2ant_tdma_duration_adjust(btcoexist, false, true, 3);
3272 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3273 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3274 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3275 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
3277 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3280 halbtc8821a2ant_sw_mechanism1(btcoexist, true, false,
3282 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3286 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3287 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3288 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3290 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3293 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false,
3295 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3301 void halbtc8821a2ant_action_pan_edr_hid(IN struct btc_coexist *btcoexist)
3303 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
3306 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
3308 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
3309 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
3310 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
3311 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
3312 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3314 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3316 if (BTC_RSSI_HIGH(bt_rssi_state))
3317 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3319 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3321 if (BTC_RSSI_HIGH(wifi_rssi_state1) && BTC_RSSI_HIGH(bt_rssi_state)) {
3322 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
3323 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3326 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3328 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50,
3332 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
3333 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3334 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3335 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
3337 /* halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 11); */
3338 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
3341 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
3343 /* halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7); */
3344 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
3347 halbtc8821a2ant_tdma_duration_adjust(btcoexist, true, false, 2);
3349 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3350 /* halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 14); */
3351 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff,
3353 halbtc8821a2ant_tdma_duration_adjust(btcoexist, true, true, 2);
3357 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3358 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3359 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3360 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
3362 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3365 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
3367 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3371 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3372 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3373 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
3375 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3378 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
3380 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3386 /* HID+A2DP+PAN(EDR) */
3387 void halbtc8821a2ant_action_hid_a2dp_pan_edr(IN struct btc_coexist *btcoexist)
3389 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
3392 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
3394 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
3395 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
3396 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2,
3397 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
3399 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
3401 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3403 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3405 if (BTC_RSSI_HIGH(bt_rssi_state))
3406 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3408 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3410 if (BTC_RSSI_HIGH(wifi_rssi_state1) && BTC_RSSI_HIGH(bt_rssi_state)) {
3411 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
3412 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3415 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3417 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50,
3421 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3423 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
3424 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3425 if (BTC_WIFI_BW_HT40 == wifi_bw)
3426 halbtc8821a2ant_tdma_duration_adjust(btcoexist, true,
3429 halbtc8821a2ant_tdma_duration_adjust(btcoexist, true,
3432 halbtc8821a2ant_tdma_duration_adjust(btcoexist, true, true, 3);
3435 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3436 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3437 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3438 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
3440 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3443 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
3445 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3449 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3450 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3451 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
3453 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3456 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
3458 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3464 void halbtc8821a2ant_action_hid_a2dp(IN struct btc_coexist *btcoexist)
3466 u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
3470 wifi_rssi_state = halbtc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15,
3472 /* bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 29, 0); */
3473 wifi_rssi_state1 = halbtc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
3474 BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
3475 bt_rssi_state = halbtc8821a2ant_bt_rssi_state(3,
3476 BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 37);
3478 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
3480 halbtc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true, 0x5);
3482 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3484 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3485 if (BTC_WIFI_BW_LEGACY == wifi_bw) {
3486 if (BTC_RSSI_HIGH(bt_rssi_state))
3487 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3488 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3489 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3491 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3493 /* only 802.11N mode we have to dec bt power to 4 degree */
3494 if (BTC_RSSI_HIGH(bt_rssi_state)) {
3495 btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM,
3497 /* need to check ap Number of Not */
3499 halbtc8821a2ant_dec_bt_pwr(btcoexist,
3502 halbtc8821a2ant_dec_bt_pwr(btcoexist,
3504 } else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3505 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3507 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3510 if (BTC_RSSI_HIGH(wifi_rssi_state1) && BTC_RSSI_HIGH(bt_rssi_state)) {
3511 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
3512 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3515 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3517 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50,
3521 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
3522 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3523 /* halbtc8821a2ant_tdma_duration_adjust(btcoexist, true, false, 3); */
3524 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 23);
3526 /* halbtc8821a2ant_tdma_duration_adjust(btcoexist, true, true, 3); */
3527 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 23);
3531 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3532 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3533 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3534 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
3536 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3539 halbtc8821a2ant_sw_mechanism1(btcoexist, true, true,
3541 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3545 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
3546 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
3547 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
3549 halbtc8821a2ant_sw_mechanism2(btcoexist, true, false,
3552 halbtc8821a2ant_sw_mechanism1(btcoexist, false, true,
3554 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false,
3560 void halbtc8821a2ant_action_bt_whck_test(IN struct btc_coexist *btcoexist)
3562 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3565 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false, false);
3566 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
3568 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
3571 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
3572 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3575 void halbtc8821a2ant_action_wifi_multi_port(IN struct btc_coexist *btcoexist)
3577 halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3578 halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3581 halbtc8821a2ant_sw_mechanism1(btcoexist, false, false, false, false);
3582 halbtc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
3585 /* btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); */
3586 halbtc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3588 halbtc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
3590 halbtc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
3593 void halbtc8821a2ant_run_coexist_mechanism(IN struct btc_coexist *btcoexist)
3595 boolean wifi_under_5g = false;
3597 u32 num_of_wifi_link = 0;
3598 u32 wifi_link_status = 0;
3599 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
3600 boolean miracast_plus_bt = false;
3601 boolean scan = false, link = false, roam = false;
3603 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3604 "[BTCoex], RunCoexistMechanism()===>\n");
3605 BTC_TRACE(trace_buf);
3607 if (btcoexist->manual_control) {
3608 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3609 "[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n");
3610 BTC_TRACE(trace_buf);
3614 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
3615 if (wifi_under_5g) {
3616 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3617 "[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n");
3618 BTC_TRACE(trace_buf);
3619 halbtc8821a2ant_coex_under_5g(btcoexist);
3623 if (coex_sta->under_ips) {
3624 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3625 "[BTCoex], wifi is under IPS !!!\n");
3626 BTC_TRACE(trace_buf);
3630 if (coex_sta->bt_whck_test) {
3631 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3632 "[BTCoex], BT is under WHCK TEST!!!\n");
3633 BTC_TRACE(trace_buf);
3634 halbtc8821a2ant_action_bt_whck_test(btcoexist);
3638 algorithm = halbtc8821a2ant_action_algorithm(btcoexist);
3639 if (coex_sta->c2h_bt_inquiry_page &&
3640 (BT_8821A_2ANT_COEX_ALGO_PANHS != algorithm)) {
3641 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3642 "[BTCoex], BT is under inquiry/page scan !!\n");
3643 BTC_TRACE(trace_buf);
3644 halbtc8821a2ant_action_bt_inquiry(btcoexist);
3650 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
3651 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
3652 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
3654 if (scan || link || roam) {
3655 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3656 "[BTCoex], WiFi is under Link Process !!\n");
3657 BTC_TRACE(trace_buf);
3658 halbtc8821a2ant_action_wifi_link_process(btcoexist);
3664 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
3666 num_of_wifi_link = wifi_link_status >> 16;
3668 if ((num_of_wifi_link >= 2) ||
3669 (wifi_link_status & WIFI_P2P_GO_CONNECTED)) {
3670 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3671 "############# [BTCoex], Multi-Port num_of_wifi_link = %d, wifi_link_status = 0x%x\n",
3672 num_of_wifi_link, wifi_link_status);
3673 BTC_TRACE(trace_buf);
3675 if (bt_link_info->bt_link_exist)
3676 miracast_plus_bt = true;
3678 miracast_plus_bt = false;
3680 btcoexist->btc_set(btcoexist, BTC_SET_BL_MIRACAST_PLUS_BT,
3682 halbtc8821a2ant_action_wifi_multi_port(btcoexist);
3686 miracast_plus_bt = false;
3687 btcoexist->btc_set(btcoexist, BTC_SET_BL_MIRACAST_PLUS_BT,
3691 coex_dm->cur_algorithm = algorithm;
3692 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "[BTCoex], Algorithm = %d\n",
3693 coex_dm->cur_algorithm);
3694 BTC_TRACE(trace_buf);
3696 if (halbtc8821a2ant_is_common_action(btcoexist)) {
3697 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3698 "[BTCoex], Action 2-Ant common.\n");
3699 BTC_TRACE(trace_buf);
3700 coex_dm->auto_tdma_adjust = false;
3702 if (coex_dm->cur_algorithm != coex_dm->pre_algorithm) {
3703 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3704 "[BTCoex], pre_algorithm=%d, cur_algorithm=%d\n",
3705 coex_dm->pre_algorithm, coex_dm->cur_algorithm);
3706 BTC_TRACE(trace_buf);
3707 coex_dm->auto_tdma_adjust = false;
3709 switch (coex_dm->cur_algorithm) {
3710 case BT_8821A_2ANT_COEX_ALGO_SCO:
3711 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3712 "[BTCoex], Action 2-Ant, algorithm = SCO.\n");
3713 BTC_TRACE(trace_buf);
3714 halbtc8821a2ant_action_sco(btcoexist);
3716 case BT_8821A_2ANT_COEX_ALGO_HID:
3717 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3718 "[BTCoex], Action 2-Ant, algorithm = HID.\n");
3719 BTC_TRACE(trace_buf);
3720 halbtc8821a2ant_action_hid(btcoexist);
3722 case BT_8821A_2ANT_COEX_ALGO_A2DP:
3723 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3724 "[BTCoex], Action 2-Ant, algorithm = A2DP.\n");
3725 BTC_TRACE(trace_buf);
3726 halbtc8821a2ant_action_a2dp(btcoexist);
3728 case BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS:
3729 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3730 "[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n");
3731 BTC_TRACE(trace_buf);
3732 halbtc8821a2ant_action_a2dp_pan_hs(btcoexist);
3734 case BT_8821A_2ANT_COEX_ALGO_PANEDR:
3735 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3736 "[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n");
3737 BTC_TRACE(trace_buf);
3738 halbtc8821a2ant_action_pan_edr(btcoexist);
3740 case BT_8821A_2ANT_COEX_ALGO_PANHS:
3741 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3742 "[BTCoex], Action 2-Ant, algorithm = HS mode.\n");
3743 BTC_TRACE(trace_buf);
3744 halbtc8821a2ant_action_pan_hs(btcoexist);
3746 case BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP:
3747 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3748 "[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n");
3749 BTC_TRACE(trace_buf);
3750 halbtc8821a2ant_action_pan_edr_a2dp(btcoexist);
3752 case BT_8821A_2ANT_COEX_ALGO_PANEDR_HID:
3753 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3754 "[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n");
3755 BTC_TRACE(trace_buf);
3756 halbtc8821a2ant_action_pan_edr_hid(btcoexist);
3758 case BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
3759 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3760 "[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n");
3761 BTC_TRACE(trace_buf);
3762 halbtc8821a2ant_action_hid_a2dp_pan_edr(
3765 case BT_8821A_2ANT_COEX_ALGO_HID_A2DP:
3766 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3767 "[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n");
3768 BTC_TRACE(trace_buf);
3769 halbtc8821a2ant_action_hid_a2dp(btcoexist);
3772 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3773 "[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n");
3774 BTC_TRACE(trace_buf);
3775 halbtc8821a2ant_coex_all_off(btcoexist);
3778 coex_dm->pre_algorithm = coex_dm->cur_algorithm;
3782 void halbtc8821a2ant_wifi_off_hw_cfg(IN struct btc_coexist *btcoexist)
3784 u8 h2c_parameter[2] = {0};
3787 /* set wlan_act to low */
3788 btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4);
3790 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff,
3791 0x780); /* WiFi goto standby while GNT_BT 0-->1 */
3792 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
3793 if (fw_ver >= 0x180000) {
3794 /* Use H2C to set GNT_BT to HIGH */
3795 h2c_parameter[0] = 1;
3796 btcoexist->btc_fill_h2c(btcoexist, 0x6E, 1, h2c_parameter);
3798 btcoexist->btc_write_1byte(btcoexist, 0x765, 0x18);
3801 void halbtc8821a2ant_init_hw_config(IN struct btc_coexist *btcoexist,
3807 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3808 "[BTCoex], 2Ant Init HW Config!!\n");
3809 BTC_TRACE(trace_buf);
3811 /* backup rf 0x1e value */
3812 coex_dm->bt_rf_0x1e_backup =
3813 btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff);
3815 /* 0x790[5:0]=0x5 */
3816 u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790);
3819 btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp);
3821 /* Antenna config */
3822 halbtc8821a2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_MAIN, true,
3824 coex_sta->dis_ver_info_cnt = 0;
3827 halbtc8821a2ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
3829 /* Enable counter statistics */
3830 btcoexist->btc_write_1byte(btcoexist, 0x76e,
3831 0x4); /* 0x76e[3] =1, WLAN_Act control by PTA */
3832 btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3);
3833 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1);
3836 /* ************************************************************
3837 * work around function start with wa_halbtc8821a2ant_
3838 * ************************************************************
3839 * ************************************************************
3840 * extern function start with ex_halbtc8821a2ant_
3841 * ************************************************************ */
3842 void ex_halbtc8821a2ant_power_on_setting(IN struct btc_coexist *btcoexist)
3847 void ex_halbtc8821a2ant_pre_load_firmware(IN struct btc_coexist *btcoexist)
3849 struct btc_board_info *board_info = &btcoexist->board_info;
3850 u8 u8tmp = 0x4; /* Set BIT2 by default since it's 2ant case */
3853 /* S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) */
3854 /* Local setting bit define */
3855 /* BIT0: "0" for no antenna inverse; "1" for antenna inverse */
3856 /* BIT1: "0" for internal switch; "1" for external switch */
3857 /* BIT2: "0" for one antenna; "1" for two antenna */
3858 /* NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0 */
3859 if (btcoexist->chip_interface == BTC_INTF_USB) {
3860 /* fixed at S0 for USB interface */
3861 u8tmp |= 0x1; /* antenna inverse */
3862 btcoexist->btc_write_local_reg_1byte(btcoexist, 0xfe08, u8tmp);
3864 /* for PCIE and SDIO interface, we check efuse 0xc3[6] */
3865 if (board_info->single_ant_path == 0) {
3866 } else if (board_info->single_ant_path == 1) {
3868 u8tmp |= 0x1; /* antenna inverse */
3871 if (btcoexist->chip_interface == BTC_INTF_PCI)
3872 btcoexist->btc_write_local_reg_1byte(btcoexist, 0x384,
3874 else if (btcoexist->chip_interface == BTC_INTF_SDIO)
3875 btcoexist->btc_write_local_reg_1byte(btcoexist, 0x60,
3880 void ex_halbtc8821a2ant_init_hw_config(IN struct btc_coexist *btcoexist,
3881 IN boolean wifi_only)
3883 halbtc8821a2ant_init_hw_config(btcoexist, true);
3886 void ex_halbtc8821a2ant_init_coex_dm(IN struct btc_coexist *btcoexist)
3888 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3889 "[BTCoex], Coex Mechanism Init!!\n");
3890 BTC_TRACE(trace_buf);
3892 halbtc8821a2ant_init_coex_dm(btcoexist);
3895 void ex_halbtc8821a2ant_display_coex_info(IN struct btc_coexist *btcoexist)
3897 struct btc_board_info *board_info = &btcoexist->board_info;
3898 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
3899 u8 *cli_buf = btcoexist->cli_buf;
3900 u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0;
3902 u32 fa_of_dm, fa_cck;
3903 u32 fw_ver = 0, bt_patch_ver = 0;
3905 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
3906 "\r\n ============[BT Coexist info]============");
3909 if (btcoexist->manual_control) {
3910 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
3911 "\r\n ============[Under Manual Control]============");
3913 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
3914 "\r\n ==========================================");
3918 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ",
3919 "Ant PG number/ Ant mechanism:",
3920 board_info->pg_ant_num, board_info->btdm_ant_num);
3923 btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
3924 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
3925 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
3926 "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)",
3927 "CoexVer/ FwVer/ PatchVer",
3928 glcoex_ver_date_8821a_2ant, glcoex_ver_8821a_2ant, fw_ver,
3929 bt_patch_ver, bt_patch_ver);
3932 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ",
3933 "Wifi channel informed to BT",
3934 coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1],
3935 coex_dm->wifi_chnl_info[2]);
3939 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
3940 "============[Wifi Status]============");
3942 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_WIFI_STATUS);
3944 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
3945 "============[BT Status]============");
3948 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %ddBm/ %d] ",
3949 "BT [status/ rssi/ retryCnt]",
3950 ((coex_sta->bt_disabled) ? ("disabled") : ((
3951 coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan")
3952 : ((BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE ==
3953 coex_dm->bt_status) ? "non-connected idle" :
3954 ((BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)
3955 ? "connected-idle" : "busy")))),
3956 coex_sta->bt_rssi - 100, coex_sta->bt_retry_cnt);
3959 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d",
3961 bt_link_info->sco_exist, bt_link_info->hid_exist,
3962 bt_link_info->pan_exist, bt_link_info->a2dp_exist);
3966 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s",
3968 (bt_link_info->slave_role) ? "Slave" : "Master");
3972 bt_info_ext = coex_sta->bt_info_ext;
3973 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s",
3974 "BT Info A2DP rate",
3975 (bt_info_ext & BIT(0)) ? "Basic rate" : "EDR rate");
3978 for (i = 0; i < BT_INFO_SRC_8821A_2ANT_MAX; i++) {
3979 if (coex_sta->bt_info_c2h_cnt[i]) {
3980 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
3981 "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)",
3982 glbt_info_src_8821a_2ant[i],
3983 coex_sta->bt_info_c2h[i][0],
3984 coex_sta->bt_info_c2h[i][1],
3985 coex_sta->bt_info_c2h[i][2],
3986 coex_sta->bt_info_c2h[i][3],
3987 coex_sta->bt_info_c2h[i][4],
3988 coex_sta->bt_info_c2h[i][5],
3989 coex_sta->bt_info_c2h[i][6],
3990 coex_sta->bt_info_c2h_cnt[i]);
3996 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
3997 "============[Sw mechanism]============");
3999 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ",
4000 "SM1[ShRf/ LpRA/ LimDig]",
4001 coex_dm->cur_rf_rx_lpf_shrink, coex_dm->cur_low_penalty_ra,
4002 coex_dm->limited_dig);
4004 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ",
4005 "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]",
4006 coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off,
4007 coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl);
4011 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
4012 "============[Fw mechanism]============");
4015 ps_tdma_case = coex_dm->cur_ps_tdma;
4016 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4017 "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)",
4019 coex_dm->ps_tdma_para[0], coex_dm->ps_tdma_para[1],
4020 coex_dm->ps_tdma_para[2], coex_dm->ps_tdma_para[3],
4021 coex_dm->ps_tdma_para[4], ps_tdma_case,
4022 coex_dm->auto_tdma_adjust);
4025 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d",
4027 coex_sta->coex_table_type);
4030 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ",
4031 "DecBtPwr/ IgnWlanAct",
4032 coex_dm->cur_bt_dec_pwr_lvl, coex_dm->cur_ignore_wlan_act);
4036 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
4037 "============[Hw setting]============");
4040 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x",
4041 "RF-A, 0x1e initVal",
4042 coex_dm->bt_rf_0x1e_backup);
4045 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
4046 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xc5b);
4047 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x880);
4048 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
4049 "0x778/0x880[29:25]/0xc58[29:25]",
4050 u8tmp[0], (u32tmp[0] & 0x3e000000) >> 25,
4051 ((u8tmp[1] & 0x3e) >> 1));
4054 u32tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x764);
4055 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x76e);
4056 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
4057 "0x764/ 0x765/ 0x76e",
4058 (u32tmp[0] & 0xff), (u32tmp[0] & 0xff00) >> 8, u8tmp[0]);
4061 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xcb4);
4062 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
4063 "0xcb4[7:0](ctrl)/ 0xcb4[29:28](val)",
4064 u32tmp[0] & 0xff, ((u32tmp[0] & 0x30000000) >> 28));
4067 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40);
4068 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c);
4069 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x974);
4070 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
4071 "0x40/ 0x4c[24:23]/ 0x974",
4072 u8tmp[0], ((u32tmp[0] & 0x01800000) >> 23), u32tmp[1]);
4075 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
4076 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
4077 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
4078 "0x550(bcn ctrl)/0x522",
4079 u32tmp[0], u8tmp[0]);
4082 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50);
4083 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x49c);
4084 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
4085 "0xc50(dig)/0x49c(null-drop)",
4086 u32tmp[0] & 0xff, u8tmp[0]);
4089 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xda0);
4090 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xda4);
4091 u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0xda8);
4092 u32tmp[3] = btcoexist->btc_read_4byte(btcoexist, 0xcf0);
4094 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b);
4095 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c);
4097 fa_of_dm = ((u32tmp[0] & 0xffff0000) >> 16) + ((u32tmp[1] & 0xffff0000)
4098 >> 16) + (u32tmp[1] & 0xffff) + (u32tmp[2] & 0xffff) + \
4099 ((u32tmp[3] & 0xffff0000) >> 16) + (u32tmp[3] &
4101 fa_cck = (u8tmp[0] << 8) + u8tmp[1];
4103 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
4104 "OFDM-CCA/OFDM-FA/CCK-FA",
4105 u32tmp[0] & 0xffff, fa_of_dm, fa_cck);
4108 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
4109 "CRC_OK CCK/11g/11n/11n-Agg",
4110 coex_sta->crc_ok_cck, coex_sta->crc_ok_11g,
4111 coex_sta->crc_ok_11n, coex_sta->crc_ok_11n_agg);
4114 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
4115 "CRC_Err CCK/11g/11n/11n-Agg",
4116 coex_sta->crc_err_cck, coex_sta->crc_err_11g,
4117 coex_sta->crc_err_11n, coex_sta->crc_err_11n_agg);
4120 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
4121 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
4122 u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
4123 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x6cc);
4124 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4125 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
4126 "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)",
4127 u32tmp[0], u32tmp[1], u32tmp[2], u8tmp[0]);
4130 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
4131 "0x770(high-pri rx/tx)",
4132 coex_sta->high_priority_rx, coex_sta->high_priority_tx);
4134 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
4135 "0x774(low-pri rx/tx)",
4136 coex_sta->low_priority_rx, coex_sta->low_priority_tx);
4138 #if (BT_AUTO_REPORT_ONLY_8821A_2ANT == 1)
4139 /* halbtc8821a2ant_monitor_bt_ctr(btcoexist); */
4141 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS);
4145 void ex_halbtc8821a2ant_ips_notify(IN struct btc_coexist *btcoexist, IN u8 type)
4147 if (BTC_IPS_ENTER == type) {
4148 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4149 "[BTCoex], IPS ENTER notify\n");
4150 BTC_TRACE(trace_buf);
4151 coex_sta->under_ips = true;
4152 halbtc8821a2ant_wifi_off_hw_cfg(btcoexist);
4153 halbtc8821a2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
4154 halbtc8821a2ant_coex_all_off(btcoexist);
4155 } else if (BTC_IPS_LEAVE == type) {
4156 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4157 "[BTCoex], IPS LEAVE notify\n");
4158 BTC_TRACE(trace_buf);
4159 coex_sta->under_ips = false;
4160 halbtc8821a2ant_init_hw_config(btcoexist, false);
4161 halbtc8821a2ant_init_coex_dm(btcoexist);
4162 halbtc8821a2ant_query_bt_info(btcoexist);
4166 void ex_halbtc8821a2ant_lps_notify(IN struct btc_coexist *btcoexist, IN u8 type)
4168 if (BTC_LPS_ENABLE == type) {
4169 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4170 "[BTCoex], LPS ENABLE notify\n");
4171 BTC_TRACE(trace_buf);
4172 coex_sta->under_lps = true;
4173 } else if (BTC_LPS_DISABLE == type) {
4174 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4175 "[BTCoex], LPS DISABLE notify\n");
4176 BTC_TRACE(trace_buf);
4177 coex_sta->under_lps = false;
4181 void ex_halbtc8821a2ant_scan_notify(IN struct btc_coexist *btcoexist,
4186 u8tmpa = btcoexist->btc_read_1byte(btcoexist, 0x765);
4187 u8tmpb = btcoexist->btc_read_1byte(btcoexist, 0x76e);
4189 if (BTC_SCAN_START == type) {
4190 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4191 "[BTCoex], SCAN START notify\n");
4192 BTC_TRACE(trace_buf);
4193 } else if (BTC_SCAN_FINISH == type) {
4194 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4195 "[BTCoex], SCAN FINISH notify\n");
4196 BTC_TRACE(trace_buf);
4199 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4200 "############# [BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u8tmpa,
4202 BTC_TRACE(trace_buf);
4205 void ex_halbtc8821a2ant_connect_notify(IN struct btc_coexist *btcoexist,
4208 if (BTC_ASSOCIATE_START == type) {
4209 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4210 "[BTCoex], CONNECT START notify\n");
4211 BTC_TRACE(trace_buf);
4212 } else if (BTC_ASSOCIATE_FINISH == type) {
4213 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4214 "[BTCoex], CONNECT FINISH notify\n");
4215 BTC_TRACE(trace_buf);
4219 void ex_halbtc8821a2ant_media_status_notify(IN struct btc_coexist *btcoexist,
4222 u8 h2c_parameter[3] = {0};
4224 u8 wifi_central_chnl;
4227 if (BTC_MEDIA_CONNECT == type) {
4228 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4229 "[BTCoex], MEDIA connect notify\n");
4230 BTC_TRACE(trace_buf);
4232 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4233 "[BTCoex], MEDIA disconnect notify\n");
4234 BTC_TRACE(trace_buf);
4237 /* only 2.4G we need to inform bt the chnl mask */
4238 btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL,
4239 &wifi_central_chnl);
4240 if ((BTC_MEDIA_CONNECT == type) &&
4241 (wifi_central_chnl <= 14)) {
4242 h2c_parameter[0] = 0x1;
4243 h2c_parameter[1] = wifi_central_chnl;
4244 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
4245 if (BTC_WIFI_BW_HT40 == wifi_bw)
4246 h2c_parameter[2] = 0x30;
4248 btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM,
4251 h2c_parameter[2] = 0x30;
4253 h2c_parameter[2] = 0x20;
4257 coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
4258 coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
4259 coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
4261 btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter);
4264 void ex_halbtc8821a2ant_specific_packet_notify(IN struct btc_coexist *btcoexist,
4267 if (type == BTC_PACKET_DHCP) {
4268 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4269 "[BTCoex], DHCP Packet notify\n");
4270 BTC_TRACE(trace_buf);
4274 void ex_halbtc8821a2ant_bt_info_notify(IN struct btc_coexist *btcoexist,
4275 IN u8 *tmp_buf, IN u8 length)
4278 u8 i, rsp_source = 0;
4279 boolean bt_busy = false, limited_dig = false;
4280 boolean wifi_connected = false, wifi_under_5g = false;
4282 coex_sta->c2h_bt_info_req_sent = false;
4283 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
4284 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
4287 rsp_source = tmp_buf[0] & 0xf;
4288 if (rsp_source >= BT_INFO_SRC_8821A_2ANT_MAX)
4289 rsp_source = BT_INFO_SRC_8821A_2ANT_WIFI_FW;
4290 coex_sta->bt_info_c2h_cnt[rsp_source]++;
4292 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4293 "[BTCoex], Bt info[%d], length=%d, hex data=[", rsp_source,
4295 BTC_TRACE(trace_buf);
4296 for (i = 0; i < length; i++) {
4297 coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i];
4299 bt_info = tmp_buf[i];
4300 if (i == length - 1) {
4301 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "0x%02x]\n",
4303 BTC_TRACE(trace_buf);
4305 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "0x%02x, ",
4307 BTC_TRACE(trace_buf);
4311 if (btcoexist->manual_control) {
4312 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4313 "[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n");
4314 BTC_TRACE(trace_buf);
4318 /* if 0xff, it means BT is under WHCK test */
4319 if (bt_info == 0xff)
4320 coex_sta->bt_whck_test = true;
4322 coex_sta->bt_whck_test = false;
4324 if (BT_INFO_SRC_8821A_2ANT_WIFI_FW != rsp_source) {
4325 coex_sta->bt_retry_cnt = /* [3:0] */
4326 coex_sta->bt_info_c2h[rsp_source][2] & 0xf;
4329 coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10;
4331 coex_sta->bt_info_ext =
4332 coex_sta->bt_info_c2h[rsp_source][4];
4334 coex_sta->bt_tx_rx_mask = (coex_sta->bt_info_c2h[rsp_source][2]
4336 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TX_RX_MASK,
4337 &coex_sta->bt_tx_rx_mask);
4338 if (coex_sta->bt_tx_rx_mask) {
4339 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */
4340 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4341 "[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n");
4342 BTC_TRACE(trace_buf);
4343 btcoexist->btc_set_bt_reg(btcoexist, BTC_BT_REG_RF,
4347 /* Here we need to resend some wifi info to BT */
4348 /* because bt is reset and loss of the info. */
4349 if ((coex_sta->bt_info_ext & BIT(1))) {
4350 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4351 "[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n");
4352 BTC_TRACE(trace_buf);
4354 ex_halbtc8821a2ant_media_status_notify(
4355 btcoexist, BTC_MEDIA_CONNECT);
4357 ex_halbtc8821a2ant_media_status_notify(
4358 btcoexist, BTC_MEDIA_DISCONNECT);
4362 if (!btcoexist->manual_control && !wifi_under_5g) {
4363 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4364 "[BTCoex], BT ext info = 0x%x!!\n",
4365 coex_sta->bt_info_ext);
4366 BTC_TRACE(trace_buf);
4367 if ((coex_sta->bt_info_ext & BIT(3))) {
4368 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4369 "[BTCoex], BT ext info bit3=1, wifi_connected=%d\n",
4371 BTC_TRACE(trace_buf);
4372 if (wifi_connected) {
4373 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4374 "[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n");
4375 BTC_TRACE(trace_buf);
4376 halbtc8821a2ant_ignore_wlan_act(
4377 btcoexist, FORCE_EXEC, false);
4380 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4381 "[BTCoex], BT ext info bit3=0, wifi_connected=%d\n",
4383 BTC_TRACE(trace_buf);
4384 /* BT already NOT ignore Wlan active, do nothing here. */
4385 if (!wifi_connected) {
4386 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4387 "[BTCoex], BT ext info bit3 check, set BT to ignore Wlan active!!\n");
4388 BTC_TRACE(trace_buf);
4389 halbtc8821a2ant_ignore_wlan_act(
4390 btcoexist, FORCE_EXEC, true);
4395 #if (BT_AUTO_REPORT_ONLY_8821A_2ANT == 0)
4396 if ((coex_sta->bt_info_ext & BIT(4))) {
4397 /* BT auto report already enabled, do nothing */
4399 halbtc8821a2ant_bt_auto_report(btcoexist, FORCE_EXEC,
4404 /* check BIT2 first ==> check if bt is under inquiry or page scan */
4405 if (bt_info & BT_INFO_8821A_2ANT_B_INQ_PAGE)
4406 coex_sta->c2h_bt_inquiry_page = true;
4408 coex_sta->c2h_bt_inquiry_page = false;
4410 /* set link exist status */
4411 if (!(bt_info & BT_INFO_8821A_2ANT_B_CONNECTION)) {
4412 coex_sta->bt_link_exist = false;
4413 coex_sta->pan_exist = false;
4414 coex_sta->a2dp_exist = false;
4415 coex_sta->hid_exist = false;
4416 coex_sta->sco_exist = false;
4417 } else { /* connection exists */
4418 coex_sta->bt_link_exist = true;
4419 if (bt_info & BT_INFO_8821A_2ANT_B_FTP)
4420 coex_sta->pan_exist = true;
4422 coex_sta->pan_exist = false;
4423 if (bt_info & BT_INFO_8821A_2ANT_B_A2DP)
4424 coex_sta->a2dp_exist = true;
4426 coex_sta->a2dp_exist = false;
4427 if (bt_info & BT_INFO_8821A_2ANT_B_HID)
4428 coex_sta->hid_exist = true;
4430 coex_sta->hid_exist = false;
4431 if (bt_info & BT_INFO_8821A_2ANT_B_SCO_ESCO)
4432 coex_sta->sco_exist = true;
4434 coex_sta->sco_exist = false;
4436 if ((coex_sta->hid_exist == false) &&
4437 (coex_sta->c2h_bt_inquiry_page == false) &&
4438 (coex_sta->sco_exist == false)) {
4439 if (coex_sta->high_priority_tx +
4440 coex_sta->high_priority_rx >= 160)
4441 coex_sta->hid_exist = true;
4445 halbtc8821a2ant_update_bt_link_info(btcoexist);
4447 if (!(bt_info & BT_INFO_8821A_2ANT_B_CONNECTION)) {
4448 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
4449 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4450 "[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n");
4451 BTC_TRACE(trace_buf);
4452 } else if (bt_info ==
4453 BT_INFO_8821A_2ANT_B_CONNECTION) { /* connection exists but no busy */
4454 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE;
4455 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4456 "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
4457 BTC_TRACE(trace_buf);
4458 } else if ((bt_info & BT_INFO_8821A_2ANT_B_SCO_ESCO) ||
4459 (bt_info & BT_INFO_8821A_2ANT_B_SCO_BUSY)) {
4460 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_SCO_BUSY;
4461 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4462 "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n");
4463 BTC_TRACE(trace_buf);
4464 } else if (bt_info & BT_INFO_8821A_2ANT_B_ACL_BUSY) {
4465 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_ACL_BUSY;
4466 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4467 "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n");
4468 BTC_TRACE(trace_buf);
4470 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_MAX;
4471 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4472 "[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n");
4473 BTC_TRACE(trace_buf);
4476 if ((BT_8821A_2ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
4477 (BT_8821A_2ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
4478 (BT_8821A_2ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) {
4483 limited_dig = false;
4486 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
4488 coex_dm->limited_dig = limited_dig;
4489 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
4491 halbtc8821a2ant_run_coexist_mechanism(btcoexist);
4494 void ex_halbtc8821a2ant_halt_notify(IN struct btc_coexist *btcoexist)
4496 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "[BTCoex], Halt notify\n");
4497 BTC_TRACE(trace_buf);
4499 halbtc8821a2ant_wifi_off_hw_cfg(btcoexist);
4500 /* remove due to interrupt is disabled that polling c2h will fail and delay 100ms. */
4501 /* btcoexist->btc_set_bt_reg(btcoexist, BTC_BT_REG_RF, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0 */
4502 halbtc8821a2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
4504 ex_halbtc8821a2ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT);
4507 void ex_halbtc8821a2ant_pnp_notify(IN struct btc_coexist *btcoexist,
4510 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "[BTCoex], Pnp notify\n");
4511 BTC_TRACE(trace_buf);
4513 if (BTC_WIFI_PNP_SLEEP == pnp_state) {
4514 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4515 "[BTCoex], Pnp notify to SLEEP\n");
4516 BTC_TRACE(trace_buf);
4517 } else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) {
4518 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4519 "[BTCoex], Pnp notify to WAKE UP\n");
4520 BTC_TRACE(trace_buf);
4521 halbtc8821a2ant_init_hw_config(btcoexist, false);
4522 halbtc8821a2ant_init_coex_dm(btcoexist);
4523 halbtc8821a2ant_query_bt_info(btcoexist);
4527 void ex_halbtc8821a2ant_periodical(IN struct btc_coexist *btcoexist)
4529 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4530 "[BTCoex], ==========================Periodical===========================\n");
4531 BTC_TRACE(trace_buf);
4533 if (coex_sta->dis_ver_info_cnt <= 5) {
4534 coex_sta->dis_ver_info_cnt += 1;
4535 if (coex_sta->dis_ver_info_cnt == 3) {
4536 /* Antenna config to set 0x765 = 0x0 (GNT_BT control by PTA) after initial */
4537 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4538 "[BTCoex], Set GNT_BT control by PTA\n");
4539 BTC_TRACE(trace_buf);
4540 halbtc8821a2ant_set_ant_path(btcoexist,
4541 BTC_ANT_WIFI_AT_MAIN, false, false);
4545 #if (BT_AUTO_REPORT_ONLY_8821A_2ANT == 0)
4546 halbtc8821a2ant_query_bt_info(btcoexist);
4547 halbtc8821a2ant_monitor_bt_enable_disable(btcoexist);
4549 halbtc8821a2ant_monitor_bt_ctr(btcoexist);
4550 halbtc8821a2ant_monitor_wifi_ctr(btcoexist);
4552 if (halbtc8821a2ant_is_wifi_status_changed(btcoexist) ||
4553 coex_dm->auto_tdma_adjust)
4554 halbtc8821a2ant_run_coexist_mechanism(btcoexist);
4560 #endif /* #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1) */