1 /* ************************************************************
4 * This file is for RTL8812A Co-exist mechanism
7 * 2012/08/22 Cosa first check in.
8 * 2012/11/14 Cosa Revise for 8812A 2Ant out sourcing.
10 * ************************************************************ */
12 /* ************************************************************
14 * ************************************************************ */
15 #include "Mp_Precomp.h"
17 #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)
19 #if (RTL8812A_SUPPORT == 1)
20 /* ************************************************************
21 * Global variables, these are static variables
22 * ************************************************************ */
23 static u8 *trace_buf = &gl_btc_trace_buf[0];
24 static struct coex_dm_8812a_2ant glcoex_dm_8812a_2ant;
25 static struct coex_dm_8812a_2ant *coex_dm = &glcoex_dm_8812a_2ant;
26 static struct coex_sta_8812a_2ant glcoex_sta_8812a_2ant;
27 static struct coex_sta_8812a_2ant *coex_sta = &glcoex_sta_8812a_2ant;
29 const char *const glbt_info_src_8812a_2ant[] = {
32 "BT Info[bt auto report]",
35 u32 glcoex_ver_date_8812a_2ant = 20150724;
36 u32 glcoex_ver_8812a_2ant = 0x37;
38 /* ************************************************************
39 * local function proto type if needed
40 * ************************************************************
41 * ************************************************************
42 * local function start with halbtc8812a2ant_
43 * ************************************************************ */
44 u8 halbtc8812a2ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1)
47 u8 bt_rssi_state = coex_sta->pre_bt_rssi_state;
49 bt_rssi = coex_sta->bt_rssi;
52 if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
53 (coex_sta->pre_bt_rssi_state ==
54 BTC_RSSI_STATE_STAY_LOW)) {
55 if (bt_rssi >= (rssi_thresh +
56 BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT))
57 bt_rssi_state = BTC_RSSI_STATE_HIGH;
59 bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
61 if (bt_rssi < rssi_thresh)
62 bt_rssi_state = BTC_RSSI_STATE_LOW;
64 bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
66 } else if (level_num == 3) {
67 if (rssi_thresh > rssi_thresh1) {
68 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
69 "[BTCoex], BT Rssi thresh error!!\n");
71 return coex_sta->pre_bt_rssi_state;
74 if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
75 (coex_sta->pre_bt_rssi_state ==
76 BTC_RSSI_STATE_STAY_LOW)) {
77 if (bt_rssi >= (rssi_thresh +
78 BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT))
79 bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
81 bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
82 } else if ((coex_sta->pre_bt_rssi_state ==
83 BTC_RSSI_STATE_MEDIUM) ||
84 (coex_sta->pre_bt_rssi_state ==
85 BTC_RSSI_STATE_STAY_MEDIUM)) {
86 if (bt_rssi >= (rssi_thresh1 +
87 BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT))
88 bt_rssi_state = BTC_RSSI_STATE_HIGH;
89 else if (bt_rssi < rssi_thresh)
90 bt_rssi_state = BTC_RSSI_STATE_LOW;
92 bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
94 if (bt_rssi < rssi_thresh1)
95 bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
97 bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
101 coex_sta->pre_bt_rssi_state = bt_rssi_state;
103 return bt_rssi_state;
106 u8 halbtc8812a2ant_wifi_rssi_state(IN struct btc_coexist *btcoexist,
107 IN u8 index, IN u8 level_num, IN u8 rssi_thresh, IN u8 rssi_thresh1)
110 u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index];
112 btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
114 if (level_num == 2) {
115 if ((coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_LOW)
117 (coex_sta->pre_wifi_rssi_state[index] ==
118 BTC_RSSI_STATE_STAY_LOW)) {
119 if (wifi_rssi >= (rssi_thresh +
120 BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT))
121 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
123 wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
125 if (wifi_rssi < rssi_thresh)
126 wifi_rssi_state = BTC_RSSI_STATE_LOW;
128 wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
130 } else if (level_num == 3) {
131 if (rssi_thresh > rssi_thresh1) {
132 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
133 "[BTCoex], wifi RSSI thresh error!!\n");
134 BTC_TRACE(trace_buf);
135 return coex_sta->pre_wifi_rssi_state[index];
138 if ((coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_LOW)
140 (coex_sta->pre_wifi_rssi_state[index] ==
141 BTC_RSSI_STATE_STAY_LOW)) {
142 if (wifi_rssi >= (rssi_thresh +
143 BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT))
144 wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
146 wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
147 } else if ((coex_sta->pre_wifi_rssi_state[index] ==
148 BTC_RSSI_STATE_MEDIUM) ||
149 (coex_sta->pre_wifi_rssi_state[index] ==
150 BTC_RSSI_STATE_STAY_MEDIUM)) {
151 if (wifi_rssi >= (rssi_thresh1 +
152 BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT))
153 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
154 else if (wifi_rssi < rssi_thresh)
155 wifi_rssi_state = BTC_RSSI_STATE_LOW;
157 wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
159 if (wifi_rssi < rssi_thresh1)
160 wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
162 wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
166 coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state;
168 return wifi_rssi_state;
171 void halbtc8812a2ant_monitor_bt_enable_disable(IN struct btc_coexist *btcoexist)
173 struct btc_stack_info *stack_info = &btcoexist->stack_info;
174 static u32 bt_disable_cnt = 0;
175 boolean bt_active = true, bt_disabled = false;
177 /* This function check if bt is disabled */
179 /* only 8812a need to consider if core stack is installed. */
180 if (!stack_info->hci_version)
183 if (coex_sta->high_priority_tx == 0 &&
184 coex_sta->high_priority_rx == 0 &&
185 coex_sta->low_priority_tx == 0 &&
186 coex_sta->low_priority_rx == 0)
188 if (coex_sta->high_priority_tx == 0xffff &&
189 coex_sta->high_priority_rx == 0xffff &&
190 coex_sta->low_priority_tx == 0xffff &&
191 coex_sta->low_priority_rx == 0xffff)
196 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
198 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
199 "[BTCoex], BT is enabled !!\n");
200 BTC_TRACE(trace_buf);
203 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
204 "[BTCoex], bt is detected as disabled %d times!!\n",
206 BTC_TRACE(trace_buf);
207 if (bt_disable_cnt >= 2) {
209 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
211 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
212 "[BTCoex], BT is disabled !!\n");
213 BTC_TRACE(trace_buf);
216 if (coex_sta->bt_disabled != bt_disabled) {
217 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
218 "[BTCoex], BT is from %s to %s!!\n",
219 (coex_sta->bt_disabled ? "disabled" : "enabled"),
220 (bt_disabled ? "disabled" : "enabled"));
221 BTC_TRACE(trace_buf);
222 coex_sta->bt_disabled = bt_disabled;
229 u32 halbtc8812a2ant_decide_ra_mask(IN struct btc_coexist *btcoexist,
232 u32 dis_ra_mask = 0x0;
234 switch (ra_mask_type) {
235 case 0: /* normal mode */
238 case 1: /* disable cck 1/2 */
239 dis_ra_mask = 0x00000003;
241 case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */
242 dis_ra_mask = 0x0001f1f7;
251 void halbtc8812a2ant_update_ra_mask(IN struct btc_coexist *btcoexist,
252 IN boolean force_exec, IN u32 dis_rate_mask)
254 coex_dm->cur_ra_mask = dis_rate_mask;
256 if (force_exec || (coex_dm->pre_ra_mask != coex_dm->cur_ra_mask))
257 btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_RAMASK,
258 &coex_dm->cur_ra_mask);
259 coex_dm->pre_ra_mask = coex_dm->cur_ra_mask;
262 void halbtc8812a2ant_auto_rate_fallback_retry(IN struct btc_coexist *btcoexist,
263 IN boolean force_exec, IN u8 type)
265 boolean wifi_under_b_mode = false;
267 coex_dm->cur_arfr_type = type;
269 if (force_exec || (coex_dm->pre_arfr_type != coex_dm->cur_arfr_type)) {
270 switch (coex_dm->cur_arfr_type) {
271 case 0: /* normal mode */
272 btcoexist->btc_write_4byte(btcoexist, 0x430,
273 coex_dm->backup_arfr_cnt1);
274 btcoexist->btc_write_4byte(btcoexist, 0x434,
275 coex_dm->backup_arfr_cnt2);
278 btcoexist->btc_get(btcoexist,
279 BTC_GET_BL_WIFI_UNDER_B_MODE,
281 if (wifi_under_b_mode) {
282 btcoexist->btc_write_4byte(btcoexist,
284 btcoexist->btc_write_4byte(btcoexist,
287 btcoexist->btc_write_4byte(btcoexist,
289 btcoexist->btc_write_4byte(btcoexist,
298 coex_dm->pre_arfr_type = coex_dm->cur_arfr_type;
301 void halbtc8812a2ant_retry_limit(IN struct btc_coexist *btcoexist,
302 IN boolean force_exec, IN u8 type)
304 coex_dm->cur_retry_limit_type = type;
307 (coex_dm->pre_retry_limit_type !=
308 coex_dm->cur_retry_limit_type)) {
309 switch (coex_dm->cur_retry_limit_type) {
310 case 0: /* normal mode */
311 btcoexist->btc_write_2byte(btcoexist, 0x42a,
312 coex_dm->backup_retry_limit);
314 case 1: /* retry limit=8 */
315 btcoexist->btc_write_2byte(btcoexist, 0x42a,
323 coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type;
326 void halbtc8812a2ant_ampdu_max_time(IN struct btc_coexist *btcoexist,
327 IN boolean force_exec, IN u8 type)
329 coex_dm->cur_ampdu_time_type = type;
332 (coex_dm->pre_ampdu_time_type != coex_dm->cur_ampdu_time_type)) {
333 switch (coex_dm->cur_ampdu_time_type) {
334 case 0: /* normal mode */
335 btcoexist->btc_write_1byte(btcoexist, 0x456,
336 coex_dm->backup_ampdu_max_time);
338 case 1: /* AMPDU timw = 0x38 * 32us */
339 btcoexist->btc_write_1byte(btcoexist, 0x456,
347 coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type;
350 void halbtc8812a2ant_limited_tx(IN struct btc_coexist *btcoexist,
351 IN boolean force_exec, IN u8 ra_mask_type, IN u8 arfr_type,
352 IN u8 retry_limit_type, IN u8 ampdu_time_type)
354 u32 dis_ra_mask = 0x0;
356 coex_dm->cur_ra_mask_type = ra_mask_type;
357 dis_ra_mask = halbtc8812a2ant_decide_ra_mask(btcoexist, ra_mask_type);
358 halbtc8812a2ant_update_ra_mask(btcoexist, force_exec, dis_ra_mask);
360 halbtc8812a2ant_auto_rate_fallback_retry(btcoexist, force_exec,
362 halbtc8812a2ant_retry_limit(btcoexist, force_exec, retry_limit_type);
363 halbtc8812a2ant_ampdu_max_time(btcoexist, force_exec, ampdu_time_type);
366 void halbtc8812a2ant_limited_rx(IN struct btc_coexist *btcoexist,
367 IN boolean force_exec, IN boolean rej_ap_agg_pkt,
368 IN boolean bt_ctrl_agg_buf_size, IN u8 agg_buf_size)
370 boolean reject_rx_agg = rej_ap_agg_pkt;
371 boolean bt_ctrl_rx_agg_size = bt_ctrl_agg_buf_size;
372 u8 rx_agg_size = agg_buf_size;
374 /* ============================================ */
375 /* Rx Aggregation related setting */
376 /* ============================================ */
377 btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT,
379 /* decide BT control aggregation buf size or not */
380 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE,
381 &bt_ctrl_rx_agg_size);
382 /* aggregation buf size, only work when BT control Rx aggregation size. */
383 btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rx_agg_size);
384 /* real update aggregation setting */
385 btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
390 void halbtc8812a2ant_monitor_bt_ctr(IN struct btc_coexist *btcoexist)
392 u32 reg_hp_txrx, reg_lp_txrx, u32tmp;
393 u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0;
398 u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx);
399 reg_hp_tx = u32tmp & MASKLWORD;
400 reg_hp_rx = (u32tmp & MASKHWORD) >> 16;
402 u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx);
403 reg_lp_tx = u32tmp & MASKLWORD;
404 reg_lp_rx = (u32tmp & MASKHWORD) >> 16;
406 coex_sta->high_priority_tx = reg_hp_tx;
407 coex_sta->high_priority_rx = reg_hp_rx;
408 coex_sta->low_priority_tx = reg_lp_tx;
409 coex_sta->low_priority_rx = reg_lp_rx;
411 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
412 "[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
413 reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx);
414 BTC_TRACE(trace_buf);
415 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
416 "[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
417 reg_lp_txrx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx);
418 BTC_TRACE(trace_buf);
421 btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
424 void halbtc8812a2ant_query_bt_info(IN struct btc_coexist *btcoexist)
429 if (!coex_sta->bt_disabled) {
430 if (!coex_sta->bt_info_query_cnt ||
431 (coex_sta->bt_info_c2h_cnt[BT_INFO_SRC_8812A_2ANT_BT_RSP]
432 - coex_sta->bt_info_query_cnt) > 2) {
434 buf[1] = 0x1; /* polling enable, 1=enable, 0=disable */
435 buf[2] = 0x2; /* polling time in seconds */
436 buf[3] = 0x1; /* auto report enable, 1=enable, 0=disable */
438 btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_INFO,
442 coex_sta->bt_info_query_cnt++;
445 boolean halbtc8812a2ant_is_wifi_status_changed(IN struct btc_coexist *btcoexist)
447 static boolean pre_wifi_busy = false, pre_under_4way = false,
448 pre_bt_hs_on = false;
449 boolean wifi_busy = false, under_4way = false, bt_hs_on = false;
450 boolean wifi_connected = false;
452 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
454 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
455 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
456 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
459 if (wifi_connected) {
460 if (wifi_busy != pre_wifi_busy) {
461 pre_wifi_busy = wifi_busy;
464 if (under_4way != pre_under_4way) {
465 pre_under_4way = under_4way;
468 if (bt_hs_on != pre_bt_hs_on) {
469 pre_bt_hs_on = bt_hs_on;
477 void halbtc8812a2ant_update_bt_link_info(IN struct btc_coexist *btcoexist)
479 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
480 boolean bt_hs_on = false;
482 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
484 bt_link_info->bt_link_exist = coex_sta->bt_link_exist;
485 bt_link_info->sco_exist = coex_sta->sco_exist;
486 bt_link_info->a2dp_exist = coex_sta->a2dp_exist;
487 bt_link_info->pan_exist = coex_sta->pan_exist;
488 bt_link_info->hid_exist = coex_sta->hid_exist;
489 bt_link_info->acl_busy = coex_sta->acl_busy;
491 /* work around for HS mode. */
493 bt_link_info->pan_exist = true;
494 bt_link_info->bt_link_exist = true;
497 /* check if Sco only */
498 if (bt_link_info->sco_exist &&
499 !bt_link_info->a2dp_exist &&
500 !bt_link_info->pan_exist &&
501 !bt_link_info->hid_exist)
502 bt_link_info->sco_only = true;
504 bt_link_info->sco_only = false;
506 /* check if A2dp only */
507 if (!bt_link_info->sco_exist &&
508 bt_link_info->a2dp_exist &&
509 !bt_link_info->pan_exist &&
510 !bt_link_info->hid_exist)
511 bt_link_info->a2dp_only = true;
513 bt_link_info->a2dp_only = false;
515 /* check if Pan only */
516 if (!bt_link_info->sco_exist &&
517 !bt_link_info->a2dp_exist &&
518 bt_link_info->pan_exist &&
519 !bt_link_info->hid_exist)
520 bt_link_info->pan_only = true;
522 bt_link_info->pan_only = false;
524 /* check if Hid only */
525 if (!bt_link_info->sco_exist &&
526 !bt_link_info->a2dp_exist &&
527 !bt_link_info->pan_exist &&
528 bt_link_info->hid_exist)
529 bt_link_info->hid_only = true;
531 bt_link_info->hid_only = false;
534 u8 halbtc8812a2ant_action_algorithm(IN struct btc_coexist *btcoexist)
536 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
537 struct btc_stack_info *stack_info = &btcoexist->stack_info;
538 boolean bt_hs_on = false;
539 u8 algorithm = BT_8812A_2ANT_COEX_ALGO_UNDEFINED;
540 u8 num_of_diff_profile = 0;
542 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
544 if (!bt_link_info->bt_link_exist) {
545 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
546 "[BTCoex], No BT link exists!!!\n");
547 BTC_TRACE(trace_buf);
551 if (bt_link_info->sco_exist)
552 num_of_diff_profile++;
553 if (bt_link_info->hid_exist)
554 num_of_diff_profile++;
555 if (bt_link_info->pan_exist)
556 num_of_diff_profile++;
557 if (bt_link_info->a2dp_exist)
558 num_of_diff_profile++;
560 if (num_of_diff_profile == 0) {
561 if (bt_link_info->acl_busy) {
562 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
563 "[BTCoex], ACL Busy only\n");
564 BTC_TRACE(trace_buf);
565 algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR;
567 } else if (num_of_diff_profile == 1) {
568 if (bt_link_info->sco_exist) {
569 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
570 "[BTCoex], SCO only\n");
571 BTC_TRACE(trace_buf);
572 algorithm = BT_8812A_2ANT_COEX_ALGO_SCO;
574 if (bt_link_info->hid_exist) {
575 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
576 "[BTCoex], HID only\n");
577 BTC_TRACE(trace_buf);
578 algorithm = BT_8812A_2ANT_COEX_ALGO_HID;
579 } else if (bt_link_info->a2dp_exist) {
580 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
581 "[BTCoex], A2DP only\n");
582 BTC_TRACE(trace_buf);
583 algorithm = BT_8812A_2ANT_COEX_ALGO_A2DP;
584 } else if (bt_link_info->pan_exist) {
586 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
587 "[BTCoex], PAN(HS) only\n");
588 BTC_TRACE(trace_buf);
590 BT_8812A_2ANT_COEX_ALGO_PANHS;
592 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
593 "[BTCoex], PAN(EDR) only\n");
594 BTC_TRACE(trace_buf);
596 BT_8812A_2ANT_COEX_ALGO_PANEDR;
600 } else if (num_of_diff_profile == 2) {
601 if (bt_link_info->sco_exist) {
602 if (bt_link_info->hid_exist) {
603 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
604 "[BTCoex], SCO + HID\n");
605 BTC_TRACE(trace_buf);
606 algorithm = BT_8812A_2ANT_COEX_ALGO_SCO_HID;
607 } else if (bt_link_info->a2dp_exist) {
608 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
609 "[BTCoex], SCO + A2DP ==> SCO\n");
610 BTC_TRACE(trace_buf);
611 algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR_HID;
612 } else if (bt_link_info->pan_exist) {
614 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
615 "[BTCoex], SCO + PAN(HS)\n");
616 BTC_TRACE(trace_buf);
617 algorithm = BT_8812A_2ANT_COEX_ALGO_SCO;
619 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
620 "[BTCoex], SCO + PAN(EDR)\n");
621 BTC_TRACE(trace_buf);
622 algorithm = BT_8812A_2ANT_COEX_ALGO_SCO;
626 if (bt_link_info->hid_exist &&
627 bt_link_info->a2dp_exist) {
628 if (stack_info->num_of_hid >= 2) {
629 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
630 "[BTCoex], HID*2 + A2DP\n");
631 BTC_TRACE(trace_buf);
633 BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
635 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
636 "[BTCoex], HID + A2DP\n");
637 BTC_TRACE(trace_buf);
639 BT_8812A_2ANT_COEX_ALGO_HID_A2DP;
641 } else if (bt_link_info->hid_exist &&
642 bt_link_info->pan_exist) {
644 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
645 "[BTCoex], HID + PAN(HS)\n");
646 BTC_TRACE(trace_buf);
648 BT_8812A_2ANT_COEX_ALGO_HID;
650 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
651 "[BTCoex], HID + PAN(EDR)\n");
652 BTC_TRACE(trace_buf);
654 BT_8812A_2ANT_COEX_ALGO_PANEDR_HID;
656 } else if (bt_link_info->pan_exist &&
657 bt_link_info->a2dp_exist) {
659 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
660 "[BTCoex], A2DP + PAN(HS)\n");
661 BTC_TRACE(trace_buf);
663 BT_8812A_2ANT_COEX_ALGO_A2DP_PANHS;
665 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
666 "[BTCoex], A2DP + PAN(EDR)\n");
667 BTC_TRACE(trace_buf);
669 BT_8812A_2ANT_COEX_ALGO_PANEDR_A2DP;
673 } else if (num_of_diff_profile == 3) {
674 if (bt_link_info->sco_exist) {
675 if (bt_link_info->hid_exist &&
676 bt_link_info->a2dp_exist) {
677 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
678 "[BTCoex], SCO + HID + A2DP ==> HID\n");
679 BTC_TRACE(trace_buf);
680 algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR_HID;
681 } else if (bt_link_info->hid_exist &&
682 bt_link_info->pan_exist) {
684 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
685 "[BTCoex], SCO + HID + PAN(HS)\n");
686 BTC_TRACE(trace_buf);
688 BT_8812A_2ANT_COEX_ALGO_SCO_HID;
690 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
691 "[BTCoex], SCO + HID + PAN(EDR)\n");
692 BTC_TRACE(trace_buf);
694 BT_8812A_2ANT_COEX_ALGO_SCO_HID;
696 } else if (bt_link_info->pan_exist &&
697 bt_link_info->a2dp_exist) {
699 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
700 "[BTCoex], SCO + A2DP + PAN(HS)\n");
701 BTC_TRACE(trace_buf);
702 algorithm = BT_8812A_2ANT_COEX_ALGO_SCO;
704 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
705 "[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n");
706 BTC_TRACE(trace_buf);
708 BT_8812A_2ANT_COEX_ALGO_PANEDR_HID;
712 if (bt_link_info->hid_exist &&
713 bt_link_info->pan_exist &&
714 bt_link_info->a2dp_exist) {
716 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
717 "[BTCoex], HID + A2DP + PAN(HS)\n");
718 BTC_TRACE(trace_buf);
720 BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANHS;
722 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
723 "[BTCoex], HID + A2DP + PAN(EDR)\n");
724 BTC_TRACE(trace_buf);
726 BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
730 } else if (num_of_diff_profile >= 3) {
731 if (bt_link_info->sco_exist) {
732 if (bt_link_info->hid_exist &&
733 bt_link_info->pan_exist &&
734 bt_link_info->a2dp_exist) {
736 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
737 "[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n");
738 BTC_TRACE(trace_buf);
740 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
741 "[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n");
742 BTC_TRACE(trace_buf);
744 BT_8812A_2ANT_COEX_ALGO_PANEDR_HID;
753 void halbtc8812a2ant_set_fw_dac_swing_level(IN struct btc_coexist *btcoexist,
756 u8 h2c_parameter[1] = {0};
758 /* There are several type of dacswing */
759 /* 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */
760 h2c_parameter[0] = dac_swing_lvl;
762 btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter);
765 void halbtc8812a2ant_set_fw_dec_bt_pwr(IN struct btc_coexist *btcoexist,
766 IN u8 dec_bt_pwr_lvl)
772 buf[1] = 0x3; /* OP_Code */
773 buf[2] = 0x2; /* OP_Code_Length */
775 buf[3] = 0x1; /* OP_Code_Content */
778 buf[4] = dec_bt_pwr_lvl;/* pwr_level */
780 btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_COEX,
784 void halbtc8812a2ant_dec_bt_pwr(IN struct btc_coexist *btcoexist,
785 IN boolean force_exec, IN u8 dec_bt_pwr_lvl)
787 coex_dm->cur_bt_dec_pwr_lvl = dec_bt_pwr_lvl;
790 if (coex_dm->pre_bt_dec_pwr_lvl == coex_dm->cur_bt_dec_pwr_lvl)
793 halbtc8812a2ant_set_fw_dec_bt_pwr(btcoexist,
794 coex_dm->cur_bt_dec_pwr_lvl);
796 coex_dm->pre_bt_dec_pwr_lvl = coex_dm->cur_bt_dec_pwr_lvl;
799 void halbtc8812a2ant_fw_dac_swing_lvl(IN struct btc_coexist *btcoexist,
800 IN boolean force_exec, IN u8 fw_dac_swing_lvl)
802 coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl;
805 if (coex_dm->pre_fw_dac_swing_lvl ==
806 coex_dm->cur_fw_dac_swing_lvl)
810 halbtc8812a2ant_set_fw_dac_swing_level(btcoexist,
811 coex_dm->cur_fw_dac_swing_lvl);
813 coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl;
816 void halbtc8812a2ant_set_sw_rf_rx_lpf_corner(IN struct btc_coexist *btcoexist,
817 IN boolean rx_rf_shrink_on)
819 if (rx_rf_shrink_on) {
820 /* Shrink RF Rx LPF corner */
821 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
822 "[BTCoex], Shrink RF Rx LPF corner!!\n");
823 BTC_TRACE(trace_buf);
824 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff,
827 /* Resume RF Rx LPF corner */
828 /* After initialized, we can use coex_dm->bt_rf_0x1e_backup */
829 if (btcoexist->initilized) {
830 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
831 "[BTCoex], Resume RF Rx LPF corner!!\n");
832 BTC_TRACE(trace_buf);
833 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e,
834 0xfffff, coex_dm->bt_rf_0x1e_backup);
839 void halbtc8812a2ant_rf_shrink(IN struct btc_coexist *btcoexist,
840 IN boolean force_exec, IN boolean rx_rf_shrink_on)
842 coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on;
845 if (coex_dm->pre_rf_rx_lpf_shrink ==
846 coex_dm->cur_rf_rx_lpf_shrink)
849 halbtc8812a2ant_set_sw_rf_rx_lpf_corner(btcoexist,
850 coex_dm->cur_rf_rx_lpf_shrink);
852 coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink;
855 void halbtc8812a2ant_set_sw_penalty_tx_rate_adaptive(IN struct btc_coexist
856 *btcoexist, IN boolean low_penalty_ra)
860 tmp_u1 = btcoexist->btc_read_1byte(btcoexist, 0x4fd);
862 if (low_penalty_ra) {
863 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
864 "[BTCoex], Tx rate adaptive, set low penalty!!\n");
865 BTC_TRACE(trace_buf);
868 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
869 "[BTCoex], Tx rate adaptive, set normal!!\n");
870 BTC_TRACE(trace_buf);
874 btcoexist->btc_write_1byte(btcoexist, 0x4fd, tmp_u1);
877 void halbtc8812a2ant_low_penalty_ra(IN struct btc_coexist *btcoexist,
878 IN boolean force_exec, IN boolean low_penalty_ra)
881 coex_dm->cur_low_penalty_ra = low_penalty_ra;
884 if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra)
887 halbtc8812a2ant_set_sw_penalty_tx_rate_adaptive(btcoexist,
888 coex_dm->cur_low_penalty_ra);
890 coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
893 void halbtc8812a2ant_set_dac_swing_reg(IN struct btc_coexist *btcoexist,
898 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
899 "[BTCoex], Write SwDacSwing = 0x%x\n", level);
900 BTC_TRACE(trace_buf);
901 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc5b, 0x3e, val);
904 void halbtc8812a2ant_set_sw_full_time_dac_swing(IN struct btc_coexist
905 *btcoexist, IN boolean sw_dac_swing_on, IN u32 sw_dac_swing_lvl)
908 halbtc8812a2ant_set_dac_swing_reg(btcoexist, sw_dac_swing_lvl);
910 halbtc8812a2ant_set_dac_swing_reg(btcoexist, 0x18);
914 void halbtc8812a2ant_dac_swing(IN struct btc_coexist *btcoexist,
915 IN boolean force_exec, IN boolean dac_swing_on, IN u32 dac_swing_lvl)
917 coex_dm->cur_dac_swing_on = dac_swing_on;
918 coex_dm->cur_dac_swing_lvl = dac_swing_lvl;
921 if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) &&
922 (coex_dm->pre_dac_swing_lvl ==
923 coex_dm->cur_dac_swing_lvl))
927 halbtc8812a2ant_set_sw_full_time_dac_swing(btcoexist, dac_swing_on,
930 coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on;
931 coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl;
934 void halbtc8812a2ant_set_adc_back_off(IN struct btc_coexist *btcoexist,
935 IN boolean adc_back_off)
938 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
939 "[BTCoex], BB BackOff Level On!\n");
940 BTC_TRACE(trace_buf);
941 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x3);
943 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
944 "[BTCoex], BB BackOff Level Off!\n");
945 BTC_TRACE(trace_buf);
946 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x1);
950 void halbtc8812a2ant_adc_back_off(IN struct btc_coexist *btcoexist,
951 IN boolean force_exec, IN boolean adc_back_off)
953 coex_dm->cur_adc_back_off = adc_back_off;
956 if (coex_dm->pre_adc_back_off == coex_dm->cur_adc_back_off)
959 halbtc8812a2ant_set_adc_back_off(btcoexist, coex_dm->cur_adc_back_off);
961 coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off;
964 void halbtc8812a2ant_set_agc_table(IN struct btc_coexist *btcoexist,
965 IN boolean agc_table_en)
967 u8 rssi_adjust_val = 0;
969 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
971 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
972 "[BTCoex], Agc Table On!\n");
973 BTC_TRACE(trace_buf);
974 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff,
976 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff,
980 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
981 "[BTCoex], Agc Table Off!\n");
982 BTC_TRACE(trace_buf);
983 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff,
985 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff,
988 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
990 /* set rssi_adjust_val for wifi module. */
991 btcoexist->btc_set(btcoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON,
995 void halbtc8812a2ant_agc_table(IN struct btc_coexist *btcoexist,
996 IN boolean force_exec, IN boolean agc_table_en)
998 coex_dm->cur_agc_table_en = agc_table_en;
1001 if (coex_dm->pre_agc_table_en == coex_dm->cur_agc_table_en)
1004 halbtc8812a2ant_set_agc_table(btcoexist, agc_table_en);
1006 coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en;
1009 void halbtc8812a2ant_set_coex_table(IN struct btc_coexist *btcoexist,
1010 IN u32 val0x6c0, IN u32 val0x6c4, IN u32 val0x6c8, IN u8 val0x6cc)
1012 btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
1014 btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
1016 btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
1018 btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
1021 void halbtc8812a2ant_coex_table(IN struct btc_coexist *btcoexist,
1022 IN boolean force_exec, IN u32 val0x6c0, IN u32 val0x6c4,
1023 IN u32 val0x6c8, IN u8 val0x6cc)
1025 coex_dm->cur_val0x6c0 = val0x6c0;
1026 coex_dm->cur_val0x6c4 = val0x6c4;
1027 coex_dm->cur_val0x6c8 = val0x6c8;
1028 coex_dm->cur_val0x6cc = val0x6cc;
1031 if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) &&
1032 (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) &&
1033 (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) &&
1034 (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc))
1037 halbtc8812a2ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, val0x6c8,
1040 coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0;
1041 coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4;
1042 coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8;
1043 coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
1046 void halbtc8812a2ant_coex_table_with_type(IN struct btc_coexist *btcoexist,
1047 IN boolean force_exec, IN u8 type)
1051 halbtc8812a2ant_coex_table(btcoexist, force_exec,
1052 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
1055 halbtc8812a2ant_coex_table(btcoexist, force_exec,
1056 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);
1059 halbtc8812a2ant_coex_table(btcoexist, force_exec,
1060 0x55555555, 0x5ffb5ffb, 0xffffff, 0x3);
1063 halbtc8812a2ant_coex_table(btcoexist, force_exec,
1064 0x5fdf5fdf, 0x5fdb5fdb, 0xffffff, 0x3);
1067 halbtc8812a2ant_coex_table(btcoexist, force_exec,
1068 0xdfffdfff, 0x5fdb5fdb, 0xffffff, 0x3);
1071 halbtc8812a2ant_coex_table(btcoexist, force_exec,
1072 0x5ddd5ddd, 0x5fdb5fdb, 0xffffff, 0x3);
1080 void halbtc8812a2ant_set_fw_ignore_wlan_act(IN struct btc_coexist *btcoexist,
1087 buf[1] = 0x1; /* OP_Code */
1088 buf[2] = 0x1; /* OP_Code_Length */
1090 buf[3] = 0x1; /* OP_Code_Content */
1094 btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_COEX,
1098 void halbtc8812a2ant_ignore_wlan_act(IN struct btc_coexist *btcoexist,
1099 IN boolean force_exec, IN boolean enable)
1101 coex_dm->cur_ignore_wlan_act = enable;
1104 if (coex_dm->pre_ignore_wlan_act ==
1105 coex_dm->cur_ignore_wlan_act)
1108 halbtc8812a2ant_set_fw_ignore_wlan_act(btcoexist, enable);
1110 coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
1113 void halbtc8812a2ant_set_fw_pstdma(IN struct btc_coexist *btcoexist,
1114 IN u8 byte1, IN u8 byte2, IN u8 byte3, IN u8 byte4, IN u8 byte5)
1116 u8 h2c_parameter[5] = {0};
1117 u8 real_byte1 = byte1, real_byte5 = byte5;
1118 boolean ap_enable = false;
1120 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
1124 if (byte1 & BIT(4) && !(byte1 & BIT(5))) {
1125 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1126 "[BTCoex], FW for 1Ant AP mode\n");
1127 BTC_TRACE(trace_buf);
1128 real_byte1 &= ~BIT(4);
1129 real_byte1 |= BIT(5);
1131 real_byte5 |= BIT(5);
1132 real_byte5 &= ~BIT(6);
1136 h2c_parameter[0] = real_byte1;
1137 h2c_parameter[1] = byte2;
1138 h2c_parameter[2] = byte3;
1139 h2c_parameter[3] = byte4;
1140 h2c_parameter[4] = real_byte5;
1143 coex_dm->ps_tdma_para[0] = real_byte1;
1144 coex_dm->ps_tdma_para[1] = byte2;
1145 coex_dm->ps_tdma_para[2] = byte3;
1146 coex_dm->ps_tdma_para[3] = byte4;
1147 coex_dm->ps_tdma_para[4] = real_byte5;
1149 btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
1152 void halbtc8812a2ant_set_lps_rpwm(IN struct btc_coexist *btcoexist,
1153 IN u8 lps_val, IN u8 rpwm_val)
1158 btcoexist->btc_set(btcoexist, BTC_SET_U1_LPS_VAL, &lps);
1159 btcoexist->btc_set(btcoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
1162 void halbtc8812a2ant_lps_rpwm(IN struct btc_coexist *btcoexist,
1163 IN boolean force_exec, IN u8 lps_val, IN u8 rpwm_val)
1165 coex_dm->cur_lps = lps_val;
1166 coex_dm->cur_rpwm = rpwm_val;
1169 if ((coex_dm->pre_lps == coex_dm->cur_lps) &&
1170 (coex_dm->pre_rpwm == coex_dm->cur_rpwm))
1173 halbtc8812a2ant_set_lps_rpwm(btcoexist, lps_val, rpwm_val);
1175 coex_dm->pre_lps = coex_dm->cur_lps;
1176 coex_dm->pre_rpwm = coex_dm->cur_rpwm;
1179 void halbtc8812a2ant_sw_mechanism1(IN struct btc_coexist *btcoexist,
1180 IN boolean shrink_rx_lpf, IN boolean low_penalty_ra,
1181 IN boolean limited_dig, IN boolean bt_lna_constrain)
1186 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
1188 if(BTC_WIFI_BW_HT40 != wifi_bw)
1191 shrink_rx_lpf = false;
1195 halbtc8812a2ant_rf_shrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf);
1196 /* halbtc8812a2ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); */
1199 void halbtc8812a2ant_sw_mechanism2(IN struct btc_coexist *btcoexist,
1200 IN boolean agc_table_shift, IN boolean adc_back_off,
1201 IN boolean sw_dac_swing, IN u32 dac_swing_lvl)
1203 /* halbtc8812a2ant_agc_table(btcoexist, NORMAL_EXEC, agc_table_shift); */
1204 halbtc8812a2ant_adc_back_off(btcoexist, NORMAL_EXEC, adc_back_off);
1205 halbtc8812a2ant_dac_swing(btcoexist, NORMAL_EXEC, sw_dac_swing,
1209 void halbtc8812a2ant_set_ant_path(IN struct btc_coexist *btcoexist,
1210 IN u8 ant_pos_type, IN boolean init_hwcfg, IN boolean wifi_off)
1215 btcoexist->btc_write_4byte(btcoexist, 0x900, 0x00000400);
1216 btcoexist->btc_write_1byte(btcoexist, 0x76d, 0x1);
1217 } else if (wifi_off) {
1221 /* ext switch setting */
1222 switch (ant_pos_type) {
1223 case BTC_ANT_WIFI_AT_CPL_MAIN:
1225 case BTC_ANT_WIFI_AT_CPL_AUX:
1226 u8tmp = btcoexist->btc_read_1byte(btcoexist, 0xcb7);
1229 btcoexist->btc_write_1byte(btcoexist, 0xcb7, u8tmp);
1236 void halbtc8812a2ant_ps_tdma(IN struct btc_coexist *btcoexist,
1237 IN boolean force_exec, IN boolean turn_on, IN u8 type)
1239 coex_dm->cur_ps_tdma_on = turn_on;
1240 coex_dm->cur_ps_tdma = type;
1243 if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
1244 (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma))
1251 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1252 0x1a, 0x1a, 0xa1, 0x90);
1255 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1256 0x12, 0x12, 0xa1, 0x90);
1259 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1260 0x1c, 0x3, 0xb1, 0x90);
1263 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1264 0x10, 0x3, 0xb1, 0x90);
1267 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1268 0x1a, 0x1a, 0x21, 0x10);
1271 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1272 0x12, 0x12, 0x21, 0x10);
1275 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1276 0x1c, 0x3, 0x21, 0x10);
1279 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1280 0x10, 0x3, 0x21, 0x10);
1283 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1284 0x1a, 0x1a, 0xa1, 0x10);
1287 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1288 0x12, 0x12, 0xa1, 0x10);
1291 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1292 0x1c, 0x3, 0xb1, 0x10);
1295 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1296 0x10, 0x3, 0xb1, 0x10);
1299 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1300 0x1a, 0x1a, 0x21, 0x10);
1303 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1304 0x12, 0x12, 0x21, 0x10);
1307 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1308 0x1c, 0x3, 0x21, 0x10);
1311 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1312 0x10, 0x3, 0x21, 0x10);
1315 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1316 0x35, 0x3, 0xb1, 0x11);
1319 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1320 0x5, 0x5, 0xe1, 0x90);
1323 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1324 0x25, 0x25, 0xe1, 0x90);
1327 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1328 0x25, 0x25, 0x60, 0x90);
1331 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1332 0x15, 0x3, 0x70, 0x90);
1335 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0x61,
1336 0x1a, 0x1a, 0x21, 0x10);
1339 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1340 0x1c, 0x03, 0x31, 0x10);
1344 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xe3,
1345 0x1a, 0x1a, 0xe1, 0x90);
1348 /* following cases is for wifi rssi low, started from 81 */
1350 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xd3,
1351 0x3a, 0x3, 0x90, 0x50);
1354 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xd3,
1355 0x2b, 0x3, 0x90, 0x50);
1358 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xd3,
1359 0x21, 0x3, 0x90, 0x50);
1362 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xd3,
1363 0x15, 0x3, 0x90, 0x50);
1366 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xd3,
1367 0x1d, 0x1d, 0x80, 0x50);
1370 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0xd3,
1371 0x15, 0x15, 0x80, 0x50);
1375 /* disable PS tdma */
1377 case 0: /* ANT2PTA, 0x778=0x1 */
1378 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0x8,
1379 0x0, 0x0, 0x0, 0x0);
1381 case 1: /* ANT2BT, 0x778=3 */
1382 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0x0,
1383 0x0, 0x0, 0x8, 0x0);
1385 halbtc8812a2ant_set_ant_path(btcoexist,
1386 BTC_ANT_WIFI_AT_CPL_AUX, false, false);
1389 halbtc8812a2ant_set_fw_pstdma(btcoexist, 0x0,
1390 0x0, 0x0, 0x0, 0x0);
1395 /* update pre state */
1396 coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
1397 coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
1400 void halbtc8812a2ant_coex_all_off(IN struct btc_coexist *btcoexist)
1403 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1404 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1405 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1408 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false, false, false);
1409 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
1412 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
1415 void halbtc8812a2ant_init_coex_dm(IN struct btc_coexist *btcoexist)
1417 /* force to reset coex mechanism */
1419 halbtc8812a2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1);
1420 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6);
1421 halbtc8812a2ant_dec_bt_pwr(btcoexist, FORCE_EXEC, 0);
1423 halbtc8812a2ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
1425 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false, false, false);
1426 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
1429 void halbtc8812a2ant_ps_tdma_check_for_power_save_state(
1430 IN struct btc_coexist *btcoexist, IN boolean new_ps_state)
1434 btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode);
1436 if (lps_mode) { /* already under LPS state */
1438 /* keep state under LPS, do nothing. */
1440 /* will leave LPS state, turn off psTdma first */
1441 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1444 } else { /* NO PS state */
1446 /* will enter LPS state, turn off psTdma first */
1447 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1450 /* keep state under NO PS state, do nothing. */
1455 void halbtc8812a2ant_power_save_state(IN struct btc_coexist *btcoexist,
1456 IN u8 ps_type, IN boolean low_pwr_disable, IN u8 lps_val,
1460 case BTC_PS_WIFI_NATIVE:
1461 btcoexist->btc_set(btcoexist,
1462 BTC_SET_ACT_DISABLE_LOW_POWER,
1464 btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS,
1468 halbtc8812a2ant_ps_tdma_check_for_power_save_state(
1470 halbtc8812a2ant_lps_rpwm(btcoexist, NORMAL_EXEC,
1472 btcoexist->btc_set(btcoexist,
1473 BTC_SET_ACT_DISABLE_LOW_POWER,
1475 /* power save must executed before psTdma. */
1476 btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS,
1484 void halbtc8812a2ant_action_bt_inquiry(IN struct btc_coexist *btcoexist)
1486 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, true,
1489 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
1490 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3);
1491 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1492 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1494 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false, false, false);
1495 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
1498 boolean halbtc8812a2ant_is_common_action(IN struct btc_coexist *btcoexist)
1500 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
1501 boolean common = false, wifi_connected = false, wifi_busy = false;
1502 boolean bt_hs_on = false;
1504 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
1505 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
1507 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
1510 if (coex_sta->c2h_bt_inquiry_page) {
1511 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1512 "[BTCoex], BT is under inquiry/page scan !!\n");
1513 BTC_TRACE(trace_buf);
1514 halbtc8812a2ant_action_bt_inquiry(btcoexist);
1518 if (bt_link_info->sco_exist || bt_link_info->hid_exist)
1519 halbtc8812a2ant_limited_tx(btcoexist, NORMAL_EXEC, 1, 0, 0, 0);
1521 halbtc8812a2ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
1523 if (!wifi_connected) {
1524 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
1526 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
1529 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1530 "[BTCoex], Wifi non-connected idle!!\n");
1531 BTC_TRACE(trace_buf);
1533 if ((BT_8812A_2ANT_BT_STATUS_NON_CONNECTED_IDLE ==
1534 coex_dm->bt_status) ||
1535 (BT_8812A_2ANT_BT_STATUS_CONNECTED_IDLE ==
1536 coex_dm->bt_status)) {
1537 halbtc8812a2ant_coex_table_with_type(btcoexist,
1539 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1542 halbtc8812a2ant_coex_table_with_type(btcoexist,
1544 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1548 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1549 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1551 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false, false,
1553 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false, false,
1558 if (BT_8812A_2ANT_BT_STATUS_NON_CONNECTED_IDLE ==
1559 coex_dm->bt_status) {
1560 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1561 "[BTCoex], Wifi connected + BT non connected-idle!!\n");
1562 BTC_TRACE(trace_buf);
1563 halbtc8812a2ant_power_save_state(btcoexist,
1564 BTC_PS_WIFI_NATIVE, false, 0x0, 0x0);
1565 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC,
1568 halbtc8812a2ant_coex_table_with_type(btcoexist,
1570 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1572 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
1574 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1576 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
1578 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
1582 } else if (BT_8812A_2ANT_BT_STATUS_CONNECTED_IDLE ==
1583 coex_dm->bt_status) {
1587 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1588 "[BTCoex], Wifi connected + BT connected-idle!!\n");
1589 BTC_TRACE(trace_buf);
1590 halbtc8812a2ant_power_save_state(btcoexist,
1591 BTC_PS_WIFI_NATIVE, true, 0x0, 0x0);
1592 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC,
1595 halbtc8812a2ant_coex_table_with_type(btcoexist,
1597 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
1599 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
1601 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
1603 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
1605 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
1611 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1612 "[BTCoex], Wifi Connected-Busy + BT Busy!!\n");
1613 BTC_TRACE(trace_buf);
1616 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1617 "[BTCoex], Wifi Connected-Idle + BT Busy!!\n");
1618 BTC_TRACE(trace_buf);
1620 halbtc8812a2ant_power_save_state(btcoexist,
1621 BTC_PS_WIFI_NATIVE, true, 0x0, 0x0);
1623 halbtc8812a2ant_limited_rx(btcoexist,
1624 NORMAL_EXEC, false, false, 0x8);
1626 halbtc8812a2ant_coex_table_with_type(btcoexist,
1629 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1632 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist,
1634 halbtc8812a2ant_dec_bt_pwr(btcoexist,
1636 halbtc8812a2ant_sw_mechanism1(btcoexist, false,
1637 false, false, false);
1638 halbtc8812a2ant_sw_mechanism2(btcoexist, false,
1639 false, false, 0x18);
1648 void halbtc8812a2ant_tdma_duration_adjust(IN struct btc_coexist *btcoexist,
1649 IN boolean sco_hid, IN boolean tx_pause, IN u8 max_interval)
1651 static s32 up, dn, m, n, wait_count;
1652 s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */
1655 coex_dm->auto_tdma_adjust_low_rssi = false;
1657 if (!coex_dm->auto_tdma_adjust) {
1658 coex_dm->auto_tdma_adjust = true;
1662 if (max_interval == 1) {
1663 halbtc8812a2ant_ps_tdma(
1664 btcoexist, NORMAL_EXEC,
1666 coex_dm->ps_tdma_du_adj_type =
1668 } else if (max_interval == 2) {
1669 halbtc8812a2ant_ps_tdma(
1670 btcoexist, NORMAL_EXEC,
1672 coex_dm->ps_tdma_du_adj_type =
1674 } else if (max_interval == 3) {
1675 halbtc8812a2ant_ps_tdma(
1676 btcoexist, NORMAL_EXEC,
1678 coex_dm->ps_tdma_du_adj_type =
1681 halbtc8812a2ant_ps_tdma(
1682 btcoexist, NORMAL_EXEC,
1684 coex_dm->ps_tdma_du_adj_type =
1688 if (max_interval == 1) {
1689 halbtc8812a2ant_ps_tdma(
1690 btcoexist, NORMAL_EXEC,
1692 coex_dm->ps_tdma_du_adj_type =
1694 } else if (max_interval == 2) {
1695 halbtc8812a2ant_ps_tdma(
1696 btcoexist, NORMAL_EXEC,
1698 coex_dm->ps_tdma_du_adj_type =
1700 } else if (max_interval == 3) {
1701 halbtc8812a2ant_ps_tdma(
1702 btcoexist, NORMAL_EXEC,
1704 coex_dm->ps_tdma_du_adj_type =
1707 halbtc8812a2ant_ps_tdma(
1708 btcoexist, NORMAL_EXEC,
1710 coex_dm->ps_tdma_du_adj_type =
1716 if (max_interval == 1) {
1717 halbtc8812a2ant_ps_tdma(
1718 btcoexist, NORMAL_EXEC,
1720 coex_dm->ps_tdma_du_adj_type =
1722 } else if (max_interval == 2) {
1723 halbtc8812a2ant_ps_tdma(
1724 btcoexist, NORMAL_EXEC,
1726 coex_dm->ps_tdma_du_adj_type =
1728 } else if (max_interval == 3) {
1729 halbtc8812a2ant_ps_tdma(
1730 btcoexist, NORMAL_EXEC,
1732 coex_dm->ps_tdma_du_adj_type =
1735 halbtc8812a2ant_ps_tdma(
1736 btcoexist, NORMAL_EXEC,
1738 coex_dm->ps_tdma_du_adj_type =
1742 if (max_interval == 1) {
1743 halbtc8812a2ant_ps_tdma(
1744 btcoexist, NORMAL_EXEC,
1746 coex_dm->ps_tdma_du_adj_type =
1748 } else if (max_interval == 2) {
1749 halbtc8812a2ant_ps_tdma(
1750 btcoexist, NORMAL_EXEC,
1752 coex_dm->ps_tdma_du_adj_type =
1754 } else if (max_interval == 3) {
1755 halbtc8812a2ant_ps_tdma(
1756 btcoexist, NORMAL_EXEC,
1758 coex_dm->ps_tdma_du_adj_type =
1761 halbtc8812a2ant_ps_tdma(
1762 btcoexist, NORMAL_EXEC,
1764 coex_dm->ps_tdma_du_adj_type =
1778 /* accquire the BT TRx retry count from BT_Info byte2 */
1779 retry_count = coex_sta->bt_retry_cnt;
1784 0) { /* no retry in the last 2-second duration */
1791 if (up >= n) { /* if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration */
1798 } else if (retry_count <=
1799 3) { /* <=3 retry in the last 2-second duration */
1806 if (dn == 2) { /* if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration */
1807 if (wait_count <= 2)
1808 m++; /* ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^ */
1812 if (m >= 20) /* m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. */
1821 } else { /* retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration */
1822 if (wait_count == 1)
1823 m++; /* ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^ */
1827 if (m >= 20) /* m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. */
1837 if (max_interval == 1) {
1839 if (coex_dm->cur_ps_tdma == 71) {
1840 halbtc8812a2ant_ps_tdma(btcoexist,
1841 NORMAL_EXEC, true, 5);
1842 coex_dm->ps_tdma_du_adj_type = 5;
1843 } else if (coex_dm->cur_ps_tdma == 1) {
1844 halbtc8812a2ant_ps_tdma(btcoexist,
1845 NORMAL_EXEC, true, 5);
1846 coex_dm->ps_tdma_du_adj_type = 5;
1847 } else if (coex_dm->cur_ps_tdma == 2) {
1848 halbtc8812a2ant_ps_tdma(btcoexist,
1849 NORMAL_EXEC, true, 6);
1850 coex_dm->ps_tdma_du_adj_type = 6;
1851 } else if (coex_dm->cur_ps_tdma == 3) {
1852 halbtc8812a2ant_ps_tdma(btcoexist,
1853 NORMAL_EXEC, true, 7);
1854 coex_dm->ps_tdma_du_adj_type = 7;
1855 } else if (coex_dm->cur_ps_tdma == 4) {
1856 halbtc8812a2ant_ps_tdma(btcoexist,
1857 NORMAL_EXEC, true, 8);
1858 coex_dm->ps_tdma_du_adj_type = 8;
1860 if (coex_dm->cur_ps_tdma == 9) {
1861 halbtc8812a2ant_ps_tdma(btcoexist,
1862 NORMAL_EXEC, true, 13);
1863 coex_dm->ps_tdma_du_adj_type = 13;
1864 } else if (coex_dm->cur_ps_tdma == 10) {
1865 halbtc8812a2ant_ps_tdma(btcoexist,
1866 NORMAL_EXEC, true, 14);
1867 coex_dm->ps_tdma_du_adj_type = 14;
1868 } else if (coex_dm->cur_ps_tdma == 11) {
1869 halbtc8812a2ant_ps_tdma(btcoexist,
1870 NORMAL_EXEC, true, 15);
1871 coex_dm->ps_tdma_du_adj_type = 15;
1872 } else if (coex_dm->cur_ps_tdma == 12) {
1873 halbtc8812a2ant_ps_tdma(btcoexist,
1874 NORMAL_EXEC, true, 16);
1875 coex_dm->ps_tdma_du_adj_type = 16;
1879 if (coex_dm->cur_ps_tdma == 5) {
1880 halbtc8812a2ant_ps_tdma(
1881 btcoexist, NORMAL_EXEC,
1883 coex_dm->ps_tdma_du_adj_type =
1885 } else if (coex_dm->cur_ps_tdma == 6) {
1886 halbtc8812a2ant_ps_tdma(
1887 btcoexist, NORMAL_EXEC,
1889 coex_dm->ps_tdma_du_adj_type =
1891 } else if (coex_dm->cur_ps_tdma == 7) {
1892 halbtc8812a2ant_ps_tdma(
1893 btcoexist, NORMAL_EXEC,
1895 coex_dm->ps_tdma_du_adj_type =
1897 } else if (coex_dm->cur_ps_tdma == 13) {
1898 halbtc8812a2ant_ps_tdma(
1899 btcoexist, NORMAL_EXEC,
1901 coex_dm->ps_tdma_du_adj_type =
1903 } else if (coex_dm->cur_ps_tdma == 14) {
1904 halbtc8812a2ant_ps_tdma(
1905 btcoexist, NORMAL_EXEC,
1907 coex_dm->ps_tdma_du_adj_type =
1909 } else if (coex_dm->cur_ps_tdma == 15) {
1910 halbtc8812a2ant_ps_tdma(
1911 btcoexist, NORMAL_EXEC,
1913 coex_dm->ps_tdma_du_adj_type =
1916 } else if (result == 1) {
1917 if (coex_dm->cur_ps_tdma == 8) {
1918 halbtc8812a2ant_ps_tdma(
1919 btcoexist, NORMAL_EXEC,
1921 coex_dm->ps_tdma_du_adj_type =
1923 } else if (coex_dm->cur_ps_tdma == 7) {
1924 halbtc8812a2ant_ps_tdma(
1925 btcoexist, NORMAL_EXEC,
1927 coex_dm->ps_tdma_du_adj_type =
1929 } else if (coex_dm->cur_ps_tdma == 6) {
1930 halbtc8812a2ant_ps_tdma(
1931 btcoexist, NORMAL_EXEC,
1933 coex_dm->ps_tdma_du_adj_type =
1935 } else if (coex_dm->cur_ps_tdma == 16) {
1936 halbtc8812a2ant_ps_tdma(
1937 btcoexist, NORMAL_EXEC,
1939 coex_dm->ps_tdma_du_adj_type =
1941 } else if (coex_dm->cur_ps_tdma == 15) {
1942 halbtc8812a2ant_ps_tdma(
1943 btcoexist, NORMAL_EXEC,
1945 coex_dm->ps_tdma_du_adj_type =
1947 } else if (coex_dm->cur_ps_tdma == 14) {
1948 halbtc8812a2ant_ps_tdma(
1949 btcoexist, NORMAL_EXEC,
1951 coex_dm->ps_tdma_du_adj_type =
1956 if (coex_dm->cur_ps_tdma == 5) {
1957 halbtc8812a2ant_ps_tdma(btcoexist,
1958 NORMAL_EXEC, true, 71);
1959 coex_dm->ps_tdma_du_adj_type = 71;
1960 } else if (coex_dm->cur_ps_tdma == 6) {
1961 halbtc8812a2ant_ps_tdma(btcoexist,
1962 NORMAL_EXEC, true, 2);
1963 coex_dm->ps_tdma_du_adj_type = 2;
1964 } else if (coex_dm->cur_ps_tdma == 7) {
1965 halbtc8812a2ant_ps_tdma(btcoexist,
1966 NORMAL_EXEC, true, 3);
1967 coex_dm->ps_tdma_du_adj_type = 3;
1968 } else if (coex_dm->cur_ps_tdma == 8) {
1969 halbtc8812a2ant_ps_tdma(btcoexist,
1970 NORMAL_EXEC, true, 4);
1971 coex_dm->ps_tdma_du_adj_type = 4;
1973 if (coex_dm->cur_ps_tdma == 13) {
1974 halbtc8812a2ant_ps_tdma(btcoexist,
1975 NORMAL_EXEC, true, 9);
1976 coex_dm->ps_tdma_du_adj_type = 9;
1977 } else if (coex_dm->cur_ps_tdma == 14) {
1978 halbtc8812a2ant_ps_tdma(btcoexist,
1979 NORMAL_EXEC, true, 10);
1980 coex_dm->ps_tdma_du_adj_type = 10;
1981 } else if (coex_dm->cur_ps_tdma == 15) {
1982 halbtc8812a2ant_ps_tdma(btcoexist,
1983 NORMAL_EXEC, true, 11);
1984 coex_dm->ps_tdma_du_adj_type = 11;
1985 } else if (coex_dm->cur_ps_tdma == 16) {
1986 halbtc8812a2ant_ps_tdma(btcoexist,
1987 NORMAL_EXEC, true, 12);
1988 coex_dm->ps_tdma_du_adj_type = 12;
1992 if (coex_dm->cur_ps_tdma == 71) {
1993 halbtc8812a2ant_ps_tdma(
1994 btcoexist, NORMAL_EXEC,
1996 coex_dm->ps_tdma_du_adj_type =
1998 } else if (coex_dm->cur_ps_tdma == 1) {
1999 halbtc8812a2ant_ps_tdma(
2000 btcoexist, NORMAL_EXEC,
2002 coex_dm->ps_tdma_du_adj_type =
2004 } else if (coex_dm->cur_ps_tdma == 2) {
2005 halbtc8812a2ant_ps_tdma(
2006 btcoexist, NORMAL_EXEC,
2008 coex_dm->ps_tdma_du_adj_type =
2010 } else if (coex_dm->cur_ps_tdma == 3) {
2011 halbtc8812a2ant_ps_tdma(
2012 btcoexist, NORMAL_EXEC,
2014 coex_dm->ps_tdma_du_adj_type =
2016 } else if (coex_dm->cur_ps_tdma == 9) {
2017 halbtc8812a2ant_ps_tdma(
2018 btcoexist, NORMAL_EXEC,
2020 coex_dm->ps_tdma_du_adj_type =
2022 } else if (coex_dm->cur_ps_tdma == 10) {
2023 halbtc8812a2ant_ps_tdma(
2024 btcoexist, NORMAL_EXEC,
2026 coex_dm->ps_tdma_du_adj_type =
2028 } else if (coex_dm->cur_ps_tdma == 11) {
2029 halbtc8812a2ant_ps_tdma(
2030 btcoexist, NORMAL_EXEC,
2032 coex_dm->ps_tdma_du_adj_type =
2035 } else if (result == 1) {
2036 if (coex_dm->cur_ps_tdma == 4) {
2037 halbtc8812a2ant_ps_tdma(
2038 btcoexist, NORMAL_EXEC,
2040 coex_dm->ps_tdma_du_adj_type =
2042 } else if (coex_dm->cur_ps_tdma == 3) {
2043 halbtc8812a2ant_ps_tdma(
2044 btcoexist, NORMAL_EXEC,
2046 coex_dm->ps_tdma_du_adj_type =
2048 } else if (coex_dm->cur_ps_tdma == 2) {
2049 halbtc8812a2ant_ps_tdma(
2050 btcoexist, NORMAL_EXEC,
2052 coex_dm->ps_tdma_du_adj_type =
2054 } else if (coex_dm->cur_ps_tdma == 1) {
2055 halbtc8812a2ant_ps_tdma(
2056 btcoexist, NORMAL_EXEC,
2058 coex_dm->ps_tdma_du_adj_type =
2060 } else if (coex_dm->cur_ps_tdma == 12) {
2061 halbtc8812a2ant_ps_tdma(
2062 btcoexist, NORMAL_EXEC,
2064 coex_dm->ps_tdma_du_adj_type =
2066 } else if (coex_dm->cur_ps_tdma == 11) {
2067 halbtc8812a2ant_ps_tdma(
2068 btcoexist, NORMAL_EXEC,
2070 coex_dm->ps_tdma_du_adj_type =
2072 } else if (coex_dm->cur_ps_tdma == 10) {
2073 halbtc8812a2ant_ps_tdma(
2074 btcoexist, NORMAL_EXEC,
2076 coex_dm->ps_tdma_du_adj_type =
2081 } else if (max_interval == 2) {
2083 if (coex_dm->cur_ps_tdma == 1) {
2084 halbtc8812a2ant_ps_tdma(btcoexist,
2085 NORMAL_EXEC, true, 6);
2086 coex_dm->ps_tdma_du_adj_type = 6;
2087 } else if (coex_dm->cur_ps_tdma == 2) {
2088 halbtc8812a2ant_ps_tdma(btcoexist,
2089 NORMAL_EXEC, true, 6);
2090 coex_dm->ps_tdma_du_adj_type = 6;
2091 } else if (coex_dm->cur_ps_tdma == 3) {
2092 halbtc8812a2ant_ps_tdma(btcoexist,
2093 NORMAL_EXEC, true, 7);
2094 coex_dm->ps_tdma_du_adj_type = 7;
2095 } else if (coex_dm->cur_ps_tdma == 4) {
2096 halbtc8812a2ant_ps_tdma(btcoexist,
2097 NORMAL_EXEC, true, 8);
2098 coex_dm->ps_tdma_du_adj_type = 8;
2100 if (coex_dm->cur_ps_tdma == 9) {
2101 halbtc8812a2ant_ps_tdma(btcoexist,
2102 NORMAL_EXEC, true, 14);
2103 coex_dm->ps_tdma_du_adj_type = 14;
2104 } else if (coex_dm->cur_ps_tdma == 10) {
2105 halbtc8812a2ant_ps_tdma(btcoexist,
2106 NORMAL_EXEC, true, 14);
2107 coex_dm->ps_tdma_du_adj_type = 14;
2108 } else if (coex_dm->cur_ps_tdma == 11) {
2109 halbtc8812a2ant_ps_tdma(btcoexist,
2110 NORMAL_EXEC, true, 15);
2111 coex_dm->ps_tdma_du_adj_type = 15;
2112 } else if (coex_dm->cur_ps_tdma == 12) {
2113 halbtc8812a2ant_ps_tdma(btcoexist,
2114 NORMAL_EXEC, true, 16);
2115 coex_dm->ps_tdma_du_adj_type = 16;
2118 if (coex_dm->cur_ps_tdma == 5) {
2119 halbtc8812a2ant_ps_tdma(
2120 btcoexist, NORMAL_EXEC,
2122 coex_dm->ps_tdma_du_adj_type =
2124 } else if (coex_dm->cur_ps_tdma == 6) {
2125 halbtc8812a2ant_ps_tdma(
2126 btcoexist, NORMAL_EXEC,
2128 coex_dm->ps_tdma_du_adj_type =
2130 } else if (coex_dm->cur_ps_tdma == 7) {
2131 halbtc8812a2ant_ps_tdma(
2132 btcoexist, NORMAL_EXEC,
2134 coex_dm->ps_tdma_du_adj_type =
2136 } else if (coex_dm->cur_ps_tdma == 13) {
2137 halbtc8812a2ant_ps_tdma(
2138 btcoexist, NORMAL_EXEC,
2140 coex_dm->ps_tdma_du_adj_type =
2142 } else if (coex_dm->cur_ps_tdma == 14) {
2143 halbtc8812a2ant_ps_tdma(
2144 btcoexist, NORMAL_EXEC,
2146 coex_dm->ps_tdma_du_adj_type =
2148 } else if (coex_dm->cur_ps_tdma == 15) {
2149 halbtc8812a2ant_ps_tdma(
2150 btcoexist, NORMAL_EXEC,
2152 coex_dm->ps_tdma_du_adj_type =
2155 } else if (result == 1) {
2156 if (coex_dm->cur_ps_tdma == 8) {
2157 halbtc8812a2ant_ps_tdma(
2158 btcoexist, NORMAL_EXEC,
2160 coex_dm->ps_tdma_du_adj_type =
2162 } else if (coex_dm->cur_ps_tdma == 7) {
2163 halbtc8812a2ant_ps_tdma(
2164 btcoexist, NORMAL_EXEC,
2166 coex_dm->ps_tdma_du_adj_type =
2168 } else if (coex_dm->cur_ps_tdma == 6) {
2169 halbtc8812a2ant_ps_tdma(
2170 btcoexist, NORMAL_EXEC,
2172 coex_dm->ps_tdma_du_adj_type =
2174 } else if (coex_dm->cur_ps_tdma == 16) {
2175 halbtc8812a2ant_ps_tdma(
2176 btcoexist, NORMAL_EXEC,
2178 coex_dm->ps_tdma_du_adj_type =
2180 } else if (coex_dm->cur_ps_tdma == 15) {
2181 halbtc8812a2ant_ps_tdma(
2182 btcoexist, NORMAL_EXEC,
2184 coex_dm->ps_tdma_du_adj_type =
2186 } else if (coex_dm->cur_ps_tdma == 14) {
2187 halbtc8812a2ant_ps_tdma(
2188 btcoexist, NORMAL_EXEC,
2190 coex_dm->ps_tdma_du_adj_type =
2195 if (coex_dm->cur_ps_tdma == 5) {
2196 halbtc8812a2ant_ps_tdma(btcoexist,
2197 NORMAL_EXEC, true, 2);
2198 coex_dm->ps_tdma_du_adj_type = 2;
2199 } else if (coex_dm->cur_ps_tdma == 6) {
2200 halbtc8812a2ant_ps_tdma(btcoexist,
2201 NORMAL_EXEC, true, 2);
2202 coex_dm->ps_tdma_du_adj_type = 2;
2203 } else if (coex_dm->cur_ps_tdma == 7) {
2204 halbtc8812a2ant_ps_tdma(btcoexist,
2205 NORMAL_EXEC, true, 3);
2206 coex_dm->ps_tdma_du_adj_type = 3;
2207 } else if (coex_dm->cur_ps_tdma == 8) {
2208 halbtc8812a2ant_ps_tdma(btcoexist,
2209 NORMAL_EXEC, true, 4);
2210 coex_dm->ps_tdma_du_adj_type = 4;
2212 if (coex_dm->cur_ps_tdma == 13) {
2213 halbtc8812a2ant_ps_tdma(btcoexist,
2214 NORMAL_EXEC, true, 10);
2215 coex_dm->ps_tdma_du_adj_type = 10;
2216 } else if (coex_dm->cur_ps_tdma == 14) {
2217 halbtc8812a2ant_ps_tdma(btcoexist,
2218 NORMAL_EXEC, true, 10);
2219 coex_dm->ps_tdma_du_adj_type = 10;
2220 } else if (coex_dm->cur_ps_tdma == 15) {
2221 halbtc8812a2ant_ps_tdma(btcoexist,
2222 NORMAL_EXEC, true, 11);
2223 coex_dm->ps_tdma_du_adj_type = 11;
2224 } else if (coex_dm->cur_ps_tdma == 16) {
2225 halbtc8812a2ant_ps_tdma(btcoexist,
2226 NORMAL_EXEC, true, 12);
2227 coex_dm->ps_tdma_du_adj_type = 12;
2230 if (coex_dm->cur_ps_tdma == 1) {
2231 halbtc8812a2ant_ps_tdma(
2232 btcoexist, NORMAL_EXEC,
2234 coex_dm->ps_tdma_du_adj_type =
2236 } else if (coex_dm->cur_ps_tdma == 2) {
2237 halbtc8812a2ant_ps_tdma(
2238 btcoexist, NORMAL_EXEC,
2240 coex_dm->ps_tdma_du_adj_type =
2242 } else if (coex_dm->cur_ps_tdma == 3) {
2243 halbtc8812a2ant_ps_tdma(
2244 btcoexist, NORMAL_EXEC,
2246 coex_dm->ps_tdma_du_adj_type =
2248 } else if (coex_dm->cur_ps_tdma == 9) {
2249 halbtc8812a2ant_ps_tdma(
2250 btcoexist, NORMAL_EXEC,
2252 coex_dm->ps_tdma_du_adj_type =
2254 } else if (coex_dm->cur_ps_tdma == 10) {
2255 halbtc8812a2ant_ps_tdma(
2256 btcoexist, NORMAL_EXEC,
2258 coex_dm->ps_tdma_du_adj_type =
2260 } else if (coex_dm->cur_ps_tdma == 11) {
2261 halbtc8812a2ant_ps_tdma(
2262 btcoexist, NORMAL_EXEC,
2264 coex_dm->ps_tdma_du_adj_type =
2267 } else if (result == 1) {
2268 if (coex_dm->cur_ps_tdma == 4) {
2269 halbtc8812a2ant_ps_tdma(
2270 btcoexist, NORMAL_EXEC,
2272 coex_dm->ps_tdma_du_adj_type =
2274 } else if (coex_dm->cur_ps_tdma == 3) {
2275 halbtc8812a2ant_ps_tdma(
2276 btcoexist, NORMAL_EXEC,
2278 coex_dm->ps_tdma_du_adj_type =
2280 } else if (coex_dm->cur_ps_tdma == 2) {
2281 halbtc8812a2ant_ps_tdma(
2282 btcoexist, NORMAL_EXEC,
2284 coex_dm->ps_tdma_du_adj_type =
2286 } else if (coex_dm->cur_ps_tdma == 12) {
2287 halbtc8812a2ant_ps_tdma(
2288 btcoexist, NORMAL_EXEC,
2290 coex_dm->ps_tdma_du_adj_type =
2292 } else if (coex_dm->cur_ps_tdma == 11) {
2293 halbtc8812a2ant_ps_tdma(
2294 btcoexist, NORMAL_EXEC,
2296 coex_dm->ps_tdma_du_adj_type =
2298 } else if (coex_dm->cur_ps_tdma == 10) {
2299 halbtc8812a2ant_ps_tdma(
2300 btcoexist, NORMAL_EXEC,
2302 coex_dm->ps_tdma_du_adj_type =
2307 } else if (max_interval == 3) {
2309 if (coex_dm->cur_ps_tdma == 1) {
2310 halbtc8812a2ant_ps_tdma(btcoexist,
2311 NORMAL_EXEC, true, 7);
2312 coex_dm->ps_tdma_du_adj_type = 7;
2313 } else if (coex_dm->cur_ps_tdma == 2) {
2314 halbtc8812a2ant_ps_tdma(btcoexist,
2315 NORMAL_EXEC, true, 7);
2316 coex_dm->ps_tdma_du_adj_type = 7;
2317 } else if (coex_dm->cur_ps_tdma == 3) {
2318 halbtc8812a2ant_ps_tdma(btcoexist,
2319 NORMAL_EXEC, true, 7);
2320 coex_dm->ps_tdma_du_adj_type = 7;
2321 } else if (coex_dm->cur_ps_tdma == 4) {
2322 halbtc8812a2ant_ps_tdma(btcoexist,
2323 NORMAL_EXEC, true, 8);
2324 coex_dm->ps_tdma_du_adj_type = 8;
2326 if (coex_dm->cur_ps_tdma == 9) {
2327 halbtc8812a2ant_ps_tdma(btcoexist,
2328 NORMAL_EXEC, true, 15);
2329 coex_dm->ps_tdma_du_adj_type = 15;
2330 } else if (coex_dm->cur_ps_tdma == 10) {
2331 halbtc8812a2ant_ps_tdma(btcoexist,
2332 NORMAL_EXEC, true, 15);
2333 coex_dm->ps_tdma_du_adj_type = 15;
2334 } else if (coex_dm->cur_ps_tdma == 11) {
2335 halbtc8812a2ant_ps_tdma(btcoexist,
2336 NORMAL_EXEC, true, 15);
2337 coex_dm->ps_tdma_du_adj_type = 15;
2338 } else if (coex_dm->cur_ps_tdma == 12) {
2339 halbtc8812a2ant_ps_tdma(btcoexist,
2340 NORMAL_EXEC, true, 16);
2341 coex_dm->ps_tdma_du_adj_type = 16;
2344 if (coex_dm->cur_ps_tdma == 5) {
2345 halbtc8812a2ant_ps_tdma(
2346 btcoexist, NORMAL_EXEC,
2348 coex_dm->ps_tdma_du_adj_type =
2350 } else if (coex_dm->cur_ps_tdma == 6) {
2351 halbtc8812a2ant_ps_tdma(
2352 btcoexist, NORMAL_EXEC,
2354 coex_dm->ps_tdma_du_adj_type =
2356 } else if (coex_dm->cur_ps_tdma == 7) {
2357 halbtc8812a2ant_ps_tdma(
2358 btcoexist, NORMAL_EXEC,
2360 coex_dm->ps_tdma_du_adj_type =
2362 } else if (coex_dm->cur_ps_tdma == 13) {
2363 halbtc8812a2ant_ps_tdma(
2364 btcoexist, NORMAL_EXEC,
2366 coex_dm->ps_tdma_du_adj_type =
2368 } else if (coex_dm->cur_ps_tdma == 14) {
2369 halbtc8812a2ant_ps_tdma(
2370 btcoexist, NORMAL_EXEC,
2372 coex_dm->ps_tdma_du_adj_type =
2374 } else if (coex_dm->cur_ps_tdma == 15) {
2375 halbtc8812a2ant_ps_tdma(
2376 btcoexist, NORMAL_EXEC,
2378 coex_dm->ps_tdma_du_adj_type =
2381 } else if (result == 1) {
2382 if (coex_dm->cur_ps_tdma == 8) {
2383 halbtc8812a2ant_ps_tdma(
2384 btcoexist, NORMAL_EXEC,
2386 coex_dm->ps_tdma_du_adj_type =
2388 } else if (coex_dm->cur_ps_tdma == 7) {
2389 halbtc8812a2ant_ps_tdma(
2390 btcoexist, NORMAL_EXEC,
2392 coex_dm->ps_tdma_du_adj_type =
2394 } else if (coex_dm->cur_ps_tdma == 6) {
2395 halbtc8812a2ant_ps_tdma(
2396 btcoexist, NORMAL_EXEC,
2398 coex_dm->ps_tdma_du_adj_type =
2400 } else if (coex_dm->cur_ps_tdma == 16) {
2401 halbtc8812a2ant_ps_tdma(
2402 btcoexist, NORMAL_EXEC,
2404 coex_dm->ps_tdma_du_adj_type =
2406 } else if (coex_dm->cur_ps_tdma == 15) {
2407 halbtc8812a2ant_ps_tdma(
2408 btcoexist, NORMAL_EXEC,
2410 coex_dm->ps_tdma_du_adj_type =
2412 } else if (coex_dm->cur_ps_tdma == 14) {
2413 halbtc8812a2ant_ps_tdma(
2414 btcoexist, NORMAL_EXEC,
2416 coex_dm->ps_tdma_du_adj_type =
2421 if (coex_dm->cur_ps_tdma == 5) {
2422 halbtc8812a2ant_ps_tdma(btcoexist,
2423 NORMAL_EXEC, true, 3);
2424 coex_dm->ps_tdma_du_adj_type = 3;
2425 } else if (coex_dm->cur_ps_tdma == 6) {
2426 halbtc8812a2ant_ps_tdma(btcoexist,
2427 NORMAL_EXEC, true, 3);
2428 coex_dm->ps_tdma_du_adj_type = 3;
2429 } else if (coex_dm->cur_ps_tdma == 7) {
2430 halbtc8812a2ant_ps_tdma(btcoexist,
2431 NORMAL_EXEC, true, 3);
2432 coex_dm->ps_tdma_du_adj_type = 3;
2433 } else if (coex_dm->cur_ps_tdma == 8) {
2434 halbtc8812a2ant_ps_tdma(btcoexist,
2435 NORMAL_EXEC, true, 4);
2436 coex_dm->ps_tdma_du_adj_type = 4;
2438 if (coex_dm->cur_ps_tdma == 13) {
2439 halbtc8812a2ant_ps_tdma(btcoexist,
2440 NORMAL_EXEC, true, 11);
2441 coex_dm->ps_tdma_du_adj_type = 11;
2442 } else if (coex_dm->cur_ps_tdma == 14) {
2443 halbtc8812a2ant_ps_tdma(btcoexist,
2444 NORMAL_EXEC, true, 11);
2445 coex_dm->ps_tdma_du_adj_type = 11;
2446 } else if (coex_dm->cur_ps_tdma == 15) {
2447 halbtc8812a2ant_ps_tdma(btcoexist,
2448 NORMAL_EXEC, true, 11);
2449 coex_dm->ps_tdma_du_adj_type = 11;
2450 } else if (coex_dm->cur_ps_tdma == 16) {
2451 halbtc8812a2ant_ps_tdma(btcoexist,
2452 NORMAL_EXEC, true, 12);
2453 coex_dm->ps_tdma_du_adj_type = 12;
2456 if (coex_dm->cur_ps_tdma == 1) {
2457 halbtc8812a2ant_ps_tdma(
2458 btcoexist, NORMAL_EXEC,
2460 coex_dm->ps_tdma_du_adj_type =
2462 } else if (coex_dm->cur_ps_tdma == 2) {
2463 halbtc8812a2ant_ps_tdma(
2464 btcoexist, NORMAL_EXEC,
2466 coex_dm->ps_tdma_du_adj_type =
2468 } else if (coex_dm->cur_ps_tdma == 3) {
2469 halbtc8812a2ant_ps_tdma(
2470 btcoexist, NORMAL_EXEC,
2472 coex_dm->ps_tdma_du_adj_type =
2474 } else if (coex_dm->cur_ps_tdma == 9) {
2475 halbtc8812a2ant_ps_tdma(
2476 btcoexist, NORMAL_EXEC,
2478 coex_dm->ps_tdma_du_adj_type =
2480 } else if (coex_dm->cur_ps_tdma == 10) {
2481 halbtc8812a2ant_ps_tdma(
2482 btcoexist, NORMAL_EXEC,
2484 coex_dm->ps_tdma_du_adj_type =
2486 } else if (coex_dm->cur_ps_tdma == 11) {
2487 halbtc8812a2ant_ps_tdma(
2488 btcoexist, NORMAL_EXEC,
2490 coex_dm->ps_tdma_du_adj_type =
2493 } else if (result == 1) {
2494 if (coex_dm->cur_ps_tdma == 4) {
2495 halbtc8812a2ant_ps_tdma(
2496 btcoexist, NORMAL_EXEC,
2498 coex_dm->ps_tdma_du_adj_type =
2500 } else if (coex_dm->cur_ps_tdma == 3) {
2501 halbtc8812a2ant_ps_tdma(
2502 btcoexist, NORMAL_EXEC,
2504 coex_dm->ps_tdma_du_adj_type =
2506 } else if (coex_dm->cur_ps_tdma == 2) {
2507 halbtc8812a2ant_ps_tdma(
2508 btcoexist, NORMAL_EXEC,
2510 coex_dm->ps_tdma_du_adj_type =
2512 } else if (coex_dm->cur_ps_tdma == 12) {
2513 halbtc8812a2ant_ps_tdma(
2514 btcoexist, NORMAL_EXEC,
2516 coex_dm->ps_tdma_du_adj_type =
2518 } else if (coex_dm->cur_ps_tdma == 11) {
2519 halbtc8812a2ant_ps_tdma(
2520 btcoexist, NORMAL_EXEC,
2522 coex_dm->ps_tdma_du_adj_type =
2524 } else if (coex_dm->cur_ps_tdma == 10) {
2525 halbtc8812a2ant_ps_tdma(
2526 btcoexist, NORMAL_EXEC,
2528 coex_dm->ps_tdma_du_adj_type =
2536 /* if current PsTdma not match with the recorded one (when scan, dhcp...), */
2537 /* then we have to adjust it back to the previous record one. */
2538 if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) {
2539 boolean scan = false, link = false, roam = false;
2540 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2541 "[BTCoex], PsTdma type dismatch!!!, cur_ps_tdma=%d, recordPsTdma=%d\n",
2542 coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type);
2543 BTC_TRACE(trace_buf);
2545 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
2546 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
2547 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
2549 if (!scan && !link && !roam)
2550 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
2551 coex_dm->ps_tdma_du_adj_type);
2553 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2554 "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n");
2555 BTC_TRACE(trace_buf);
2560 /* ******************
2561 * pstdma for wifi rssi low
2562 * ****************** */
2563 void halbtc8812a2ant_tdma_duration_adjust_for_wifi_rssi_low(
2564 IN struct btc_coexist *btcoexist/* , */ /* IN u8 wifi_status */)
2566 static s32 up, dn, m, n, wait_count;
2567 s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */
2568 u8 retry_count = 0, bt_info_ext;
2570 coex_dm->auto_tdma_adjust = false;
2572 retry_count = coex_sta->bt_retry_cnt;
2573 bt_info_ext = coex_sta->bt_info_ext;
2575 if (!coex_dm->auto_tdma_adjust_low_rssi) {
2576 coex_dm->auto_tdma_adjust_low_rssi = true;
2578 if (BT_INFO_8812A_2ANT_A2DP_BASIC_RATE(bt_info_ext)) {
2579 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
2581 coex_dm->ps_tdma_du_adj_type = 83;
2583 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 82);
2584 coex_dm->ps_tdma_du_adj_type = 82;
2594 /* accquire the BT TRx retry count from BT_Info byte2
2595 * retry_count = coex_sta->bt_retry_cnt;
2596 * bt_info_ext = coex_sta->bt_info_ext; */
2600 if ((coex_sta->low_priority_tx) > 1150 ||
2601 (coex_sta->low_priority_rx) > 1250)
2605 0) { /* no retry in the last 2-second duration */
2612 if (up >= n) { /* if retry count during continuous n*2 seconds is 0, enlarge WiFi duration */
2619 } else if (retry_count <=
2620 3) { /* <=3 retry in the last 2-second duration */
2627 if (dn == 2) { /* if continuous 2 retry count(every 2 seconds) >0 and < 3, reduce WiFi duration */
2628 if (wait_count <= 2)
2629 m++; /* to avoid loop between the two levels */
2633 if (m >= 20) /* maximum of m = 20 ' will recheck if need to adjust wifi duration in maximum time interval 120 seconds */
2642 } else { /* retry count > 3, once retry count > 3, to reduce WiFi duration */
2643 if (wait_count == 1)
2644 m++; /* to avoid loop between the two levels */
2648 if (m >= 20) /* maximum of m = 20 ' will recheck if need to adjust wifi duration in maximum time interval 120 seconds */
2659 if ((BT_INFO_8812A_2ANT_A2DP_BASIC_RATE(bt_info_ext)) &&
2660 ((coex_dm->cur_ps_tdma == 81) ||
2661 (coex_dm->cur_ps_tdma == 82))) {
2662 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
2664 coex_dm->ps_tdma_du_adj_type = 84;
2665 } else if (coex_dm->cur_ps_tdma == 81) {
2666 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
2668 coex_dm->ps_tdma_du_adj_type = 82;
2669 } else if (coex_dm->cur_ps_tdma == 82) {
2670 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
2672 coex_dm->ps_tdma_du_adj_type = 83;
2673 } else if (coex_dm->cur_ps_tdma == 83) {
2674 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
2676 coex_dm->ps_tdma_du_adj_type = 84;
2678 } else if (result == 1) {
2679 if ((BT_INFO_8812A_2ANT_A2DP_BASIC_RATE(bt_info_ext)) &&
2680 ((coex_dm->cur_ps_tdma == 81) ||
2681 (coex_dm->cur_ps_tdma == 82))) {
2682 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
2684 coex_dm->ps_tdma_du_adj_type = 83;
2685 } else if (coex_dm->cur_ps_tdma == 84) {
2686 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
2688 coex_dm->ps_tdma_du_adj_type = 83;
2689 } else if (coex_dm->cur_ps_tdma == 83) {
2690 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
2692 coex_dm->ps_tdma_du_adj_type = 82;
2693 } else if (coex_dm->cur_ps_tdma == 82) {
2694 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
2696 coex_dm->ps_tdma_du_adj_type = 81;
2700 if (coex_dm->cur_ps_tdma != 81 &&
2701 coex_dm->cur_ps_tdma != 82 &&
2702 coex_dm->cur_ps_tdma != 83 &&
2703 coex_dm->cur_ps_tdma != 84) {
2704 /* recover to previous adjust type */
2705 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
2706 coex_dm->ps_tdma_du_adj_type);
2711 void halbtc8812a2ant_get_bt_rssi_threshold(IN struct btc_coexist *btcoexist,
2712 IN u8 *pThres0, IN u8 *pThres1)
2716 btcoexist->btc_get(btcoexist, BTC_GET_U1_ANT_TYPE, &ant_type);
2719 case BTC_ANT_TYPE_0:
2723 case BTC_ANT_TYPE_1:
2727 case BTC_ANT_TYPE_2:
2731 case BTC_ANT_TYPE_3:
2735 case BTC_ANT_TYPE_4:
2746 void halbtc8812a2ant_action_sco(IN struct btc_coexist *btcoexist)
2748 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
2749 bt_rssi_state = BTC_RSSI_STATE_HIGH;
2751 u8 bt_thresh0 = 0, bt_thresh1 = 0;
2754 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
2756 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
2759 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
2761 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
2763 /* power save state */
2764 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, true,
2768 if (BTC_RSSI_LOW(bt_rssi_state))
2769 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
2771 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
2774 if (BTC_RSSI_LOW(bt_rssi_state))
2775 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
2777 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9);
2779 /* decrease BT power */
2780 if (BTC_RSSI_LOW(bt_rssi_state))
2781 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
2782 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
2783 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
2785 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
2788 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
2790 /* fw dac swing level */
2791 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
2794 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2796 if (BTC_WIFI_BW_HT40 == wifi_bw) {
2797 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
2798 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
2800 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
2803 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
2805 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
2809 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
2810 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
2812 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
2815 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
2817 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
2823 void halbtc8812a2ant_action_sco_hid(IN struct btc_coexist *btcoexist)
2825 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
2826 bt_rssi_state = BTC_RSSI_STATE_HIGH;
2828 u8 bt_thresh0 = 0, bt_thresh1 = 0;
2830 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
2832 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
2835 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
2837 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
2839 /* power save state */
2840 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, true,
2844 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
2847 if (BTC_RSSI_LOW(bt_rssi_state))
2848 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
2850 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9);
2852 /* decrease BT power */
2853 if (BTC_RSSI_LOW(bt_rssi_state))
2854 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
2855 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
2856 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
2858 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
2861 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true, 0x8);
2863 /* fw dac swing level */
2864 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
2867 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2869 if (BTC_WIFI_BW_HT40 == wifi_bw) {
2870 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
2871 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
2873 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
2876 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
2878 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
2882 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
2883 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
2885 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
2888 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
2890 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
2896 void halbtc8812a2ant_action_hid(IN struct btc_coexist *btcoexist)
2898 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
2899 bt_rssi_state = BTC_RSSI_STATE_HIGH;
2901 u8 bt_thresh0 = 0, bt_thresh1 = 0;
2903 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
2905 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
2908 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
2910 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
2912 /* power save state */
2913 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, true,
2917 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
2918 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
2920 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
2923 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
2924 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9);
2926 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
2928 /* decrease BT power */
2929 if (BTC_RSSI_LOW(bt_rssi_state))
2930 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
2931 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
2932 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
2934 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
2937 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
2938 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
2940 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
2941 (!BTC_RSSI_LOW(bt_rssi_state)))
2942 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
2945 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true,
2949 /* fw dac swing level */
2950 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
2952 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2954 if (BTC_WIFI_BW_HT40 == wifi_bw) {
2955 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
2956 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
2958 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
2961 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
2963 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
2967 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
2968 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
2970 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
2973 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
2975 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
2981 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
2982 void halbtc8812a2ant_action_a2dp(IN struct btc_coexist *btcoexist)
2984 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
2985 bt_rssi_state = BTC_RSSI_STATE_HIGH;
2987 u8 bt_thresh0 = 0, bt_thresh1 = 0;
2988 boolean ap_enable = false;
2990 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
2993 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
2995 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
2998 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
3000 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
3002 /* power save state */
3003 if ((ap_enable == true) || (BTC_RSSI_HIGH(wifi_rssi_state) &&
3004 (!BTC_RSSI_LOW(bt_rssi_state))))
3005 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3008 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, true,
3012 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3013 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
3015 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3018 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3019 halbtc8812a2ant_tdma_duration_adjust(btcoexist, false, false,
3022 halbtc8812a2ant_tdma_duration_adjust_for_wifi_rssi_low(
3025 /* decrease BT power */
3026 if (BTC_RSSI_LOW(bt_rssi_state))
3027 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3028 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3029 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3031 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
3034 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3036 /* fw dac swing level */
3037 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3041 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3042 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3043 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3044 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3046 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3049 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3051 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3055 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3056 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3058 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3061 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3063 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3069 void halbtc8812a2ant_action_a2dp_pan_hs(IN struct btc_coexist *btcoexist)
3071 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
3072 bt_rssi_state = BTC_RSSI_STATE_HIGH;
3074 u8 bt_thresh0 = 0, bt_thresh1 = 0;
3076 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
3078 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
3081 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
3083 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
3085 /* power save state */
3086 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, true,
3090 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3091 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
3093 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
3096 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3097 halbtc8812a2ant_tdma_duration_adjust(btcoexist, false, false,
3100 halbtc8812a2ant_tdma_duration_adjust(btcoexist, false, true, 2);
3102 /* decrease BT power */
3103 if (BTC_RSSI_LOW(bt_rssi_state))
3104 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3105 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3106 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3108 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
3111 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3113 /* fw dac swing level */
3114 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3118 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3119 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3120 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3121 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3123 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3126 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3128 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3132 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3133 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3135 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3138 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3140 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3146 void halbtc8812a2ant_action_pan_edr(IN struct btc_coexist *btcoexist)
3148 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
3149 bt_rssi_state = BTC_RSSI_STATE_HIGH;
3151 u8 bt_thresh0 = 0, bt_thresh1 = 0;
3152 boolean ap_enable = false;
3154 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
3158 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
3160 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
3163 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
3165 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
3167 /* power save state */
3168 if ((ap_enable == true) || (BTC_RSSI_HIGH(wifi_rssi_state) &&
3169 (!BTC_RSSI_LOW(bt_rssi_state))))
3170 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3173 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, true,
3177 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3178 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
3180 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3183 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3184 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1);
3186 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 85);
3188 /* decrease BT power */
3189 if (BTC_RSSI_LOW(bt_rssi_state))
3190 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3191 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3192 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3194 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
3197 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3199 /* fw dac swing level */
3200 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3204 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3205 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3206 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3207 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3209 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3212 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3214 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3218 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3219 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3221 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3224 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3226 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3233 void halbtc8812a2ant_action_pan_hs(IN struct btc_coexist *btcoexist)
3235 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
3236 bt_rssi_state = BTC_RSSI_STATE_HIGH;
3239 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
3241 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42);
3243 /* power save state */
3244 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, true,
3248 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
3251 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
3253 /* decrease BT power */
3254 if (BTC_RSSI_LOW(bt_rssi_state))
3255 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3256 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3257 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3259 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
3262 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3264 /* fw dac swing level */
3265 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3268 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3269 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3270 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3271 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3273 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3276 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3278 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3282 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3283 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3285 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3288 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3290 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3297 void halbtc8812a2ant_action_pan_edr_a2dp(IN struct btc_coexist *btcoexist)
3299 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
3300 bt_rssi_state = BTC_RSSI_STATE_HIGH;
3302 u8 bt_thresh0 = 0, bt_thresh1 = 0;
3303 boolean ap_enable = false;
3305 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
3308 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
3310 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
3314 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
3316 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
3318 /* power save state */
3319 if ((ap_enable == true) || (BTC_RSSI_HIGH(wifi_rssi_state) &&
3320 (!BTC_RSSI_LOW(bt_rssi_state))))
3321 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3323 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3324 (!BTC_RSSI_LOW(bt_rssi_state)))
3325 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3328 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, true,
3332 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3333 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
3334 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3335 (!BTC_RSSI_LOW(bt_rssi_state)))
3336 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
3338 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3341 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3342 halbtc8812a2ant_tdma_duration_adjust(btcoexist, false, false,
3344 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3345 (!BTC_RSSI_LOW(bt_rssi_state)))
3346 halbtc8812a2ant_tdma_duration_adjust(btcoexist, false, true, 3);
3348 coex_dm->auto_tdma_adjust = false;
3349 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 86);
3352 /* decrease BT power */
3353 if (BTC_RSSI_LOW(bt_rssi_state))
3354 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3355 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3356 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3358 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
3361 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
3363 /* fw dac swing level */
3364 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3367 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3369 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3370 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3371 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3373 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3376 halbtc8812a2ant_sw_mechanism1(btcoexist, true, false,
3378 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3382 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3383 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3385 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3388 halbtc8812a2ant_sw_mechanism1(btcoexist, false, false,
3390 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3396 void halbtc8812a2ant_action_pan_edr_hid(IN struct btc_coexist *btcoexist)
3398 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
3399 bt_rssi_state = BTC_RSSI_STATE_HIGH;
3401 u8 bt_thresh0 = 0, bt_thresh1 = 0;
3402 boolean ap_enable = false;
3404 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
3407 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
3409 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
3412 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
3414 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
3416 /* power save state */
3417 if ((ap_enable == true) || (BTC_RSSI_HIGH(wifi_rssi_state) &&
3418 (!BTC_RSSI_LOW(bt_rssi_state))))
3419 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3421 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3422 (!BTC_RSSI_LOW(bt_rssi_state)))
3423 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3426 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, true,
3430 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3431 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
3432 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3433 (!BTC_RSSI_LOW(bt_rssi_state)))
3434 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
3436 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3439 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3440 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
3441 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3442 (!BTC_RSSI_LOW(bt_rssi_state)))
3443 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
3445 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 85);
3447 /* decrease BT power */
3448 if (BTC_RSSI_LOW(bt_rssi_state))
3449 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3450 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3451 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3453 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
3456 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3457 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
3459 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3460 (!BTC_RSSI_LOW(bt_rssi_state)))
3461 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
3464 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true,
3467 /* fw dac swing level */
3468 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3471 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3473 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3474 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3475 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
3477 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3480 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
3482 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3486 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3487 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
3489 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3492 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
3494 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3500 /* HID+A2DP+PAN(EDR) */
3501 void halbtc8812a2ant_action_hid_a2dp_pan_edr(IN struct btc_coexist *btcoexist)
3503 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
3504 bt_rssi_state = BTC_RSSI_STATE_HIGH;
3506 u8 bt_thresh0 = 0, bt_thresh1 = 0;
3507 boolean ap_enable = false;
3509 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
3512 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
3514 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
3517 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
3519 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
3521 /* power save state */
3522 if ((ap_enable == true) || (BTC_RSSI_HIGH(wifi_rssi_state) &&
3523 (!BTC_RSSI_LOW(bt_rssi_state))))
3524 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3526 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3527 (!BTC_RSSI_LOW(bt_rssi_state)))
3528 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3531 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, true,
3535 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3536 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
3537 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3538 (!BTC_RSSI_LOW(bt_rssi_state)))
3539 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
3541 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3544 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3545 halbtc8812a2ant_tdma_duration_adjust(btcoexist, true, false, 3);
3546 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3547 (!BTC_RSSI_LOW(bt_rssi_state)))
3548 halbtc8812a2ant_tdma_duration_adjust(btcoexist, true, true, 3);
3550 coex_dm->auto_tdma_adjust = false;
3551 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 86);
3554 /* decrease BT power */
3555 if (BTC_RSSI_LOW(bt_rssi_state))
3556 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3557 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3558 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3560 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
3563 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3564 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
3566 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3567 (!BTC_RSSI_LOW(bt_rssi_state)))
3568 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
3571 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true,
3575 /* fw dac swing level */
3576 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3578 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3580 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3581 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3582 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
3584 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3587 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
3589 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3593 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3594 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
3596 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3599 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
3601 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3607 void halbtc8812a2ant_action_hid_a2dp_pan_hs(IN struct btc_coexist *btcoexist)
3609 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
3610 bt_rssi_state = BTC_RSSI_STATE_HIGH;
3612 u8 bt_thresh0 = 0, bt_thresh1 = 0;
3614 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
3616 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
3620 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
3622 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
3624 /* power save state */
3625 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, true,
3629 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3630 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
3631 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3632 (!BTC_RSSI_LOW(bt_rssi_state)))
3633 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
3635 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3638 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3639 halbtc8812a2ant_tdma_duration_adjust(btcoexist, true, false, 2);
3640 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3641 (!BTC_RSSI_LOW(bt_rssi_state)))
3642 halbtc8812a2ant_tdma_duration_adjust(btcoexist, true, true, 2);
3644 halbtc8812a2ant_tdma_duration_adjust(btcoexist, true, true, 2);
3646 /* decrease BT power */
3647 if (BTC_RSSI_LOW(bt_rssi_state))
3648 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3649 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3650 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3652 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
3655 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3656 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
3658 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3659 (!BTC_RSSI_LOW(bt_rssi_state)))
3660 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
3663 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true,
3666 /* fw dac swing level */
3667 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3670 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3672 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3673 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3674 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
3676 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3679 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
3681 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3685 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3686 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
3688 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3691 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
3693 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3699 void halbtc8812a2ant_action_hid_a2dp(IN struct btc_coexist *btcoexist)
3701 u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH,
3702 bt_rssi_state = BTC_RSSI_STATE_HIGH;
3704 u8 bt_thresh0 = 0, bt_thresh1 = 0;
3705 boolean ap_enable = false;
3707 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
3710 halbtc8812a2ant_get_bt_rssi_threshold(btcoexist, &bt_thresh0,
3712 bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, bt_thresh0,
3715 wifi_rssi_state = halbtc8812a2ant_wifi_rssi_state(btcoexist, 0, 2, 34,
3717 /* bt_rssi_state = halbtc8812a2ant_bt_rssi_state(3, 34, 42); */
3719 /* power save state */
3720 if ((ap_enable == true) || (BTC_RSSI_HIGH(wifi_rssi_state) &&
3721 (!BTC_RSSI_LOW(bt_rssi_state))))
3722 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3724 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3725 (!BTC_RSSI_LOW(bt_rssi_state)))
3726 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
3729 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, true,
3733 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3734 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
3735 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3736 (!BTC_RSSI_LOW(bt_rssi_state)))
3737 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
3739 halbtc8812a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3742 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3743 halbtc8812a2ant_tdma_duration_adjust(btcoexist, true, false, 2);
3744 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3745 (!BTC_RSSI_LOW(bt_rssi_state)))
3746 halbtc8812a2ant_tdma_duration_adjust(btcoexist, true, true, 2);
3748 coex_dm->auto_tdma_adjust = false;
3749 halbtc8812a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 82);
3752 /* decrease BT power */
3753 if (BTC_RSSI_LOW(bt_rssi_state))
3754 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
3755 else if (BTC_RSSI_MEDIUM(bt_rssi_state))
3756 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 2);
3758 halbtc8812a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 4);
3761 if (BTC_RSSI_HIGH(wifi_rssi_state) && (!BTC_RSSI_LOW(bt_rssi_state)))
3762 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
3764 else if (BTC_RSSI_LOW(wifi_rssi_state) &&
3765 (!BTC_RSSI_LOW(bt_rssi_state)))
3766 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
3769 halbtc8812a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true,
3772 /* fw dac swing level */
3773 halbtc8812a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
3776 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3778 if (BTC_WIFI_BW_HT40 == wifi_bw) {
3779 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3780 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
3782 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3785 halbtc8812a2ant_sw_mechanism1(btcoexist, true, true,
3787 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3791 if (BTC_RSSI_HIGH(wifi_rssi_state)) {
3792 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
3794 halbtc8812a2ant_sw_mechanism2(btcoexist, true, false,
3797 halbtc8812a2ant_sw_mechanism1(btcoexist, false, true,
3799 halbtc8812a2ant_sw_mechanism2(btcoexist, false, false,
3806 void halbtc8812a2ant_coex_under_5g(IN struct btc_coexist *btcoexist)
3808 halbtc8812a2ant_coex_all_off(btcoexist);
3810 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3811 "[BTCoex], Under 5G, force set BT to ignore Wlan active!!\n");
3812 BTC_TRACE(trace_buf);
3813 halbtc8812a2ant_ignore_wlan_act(btcoexist, NORMAL_EXEC, true);
3815 /* **************************************************** */
3816 void halbtc8812a2ant_run_coexist_mechanism(IN struct btc_coexist *btcoexist)
3818 boolean wifi_under_5g = false;
3821 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3822 "[BTCoex], RunCoexistMechanism()===>\n");
3823 BTC_TRACE(trace_buf);
3825 if (btcoexist->manual_control) {
3826 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3827 "[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n");
3828 BTC_TRACE(trace_buf);
3832 if (btcoexist->stop_coex_dm) {
3833 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3834 "[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n");
3835 BTC_TRACE(trace_buf);
3839 if (coex_sta->under_ips) {
3840 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3841 "[BTCoex], wifi is under IPS !!!\n");
3842 BTC_TRACE(trace_buf);
3846 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
3847 if (wifi_under_5g) {
3848 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3849 "[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n");
3850 BTC_TRACE(trace_buf);
3851 halbtc8812a2ant_coex_under_5g(btcoexist);
3856 algorithm = halbtc8812a2ant_action_algorithm(btcoexist);
3857 if (coex_sta->c2h_bt_inquiry_page &&
3858 (BT_8812A_2ANT_COEX_ALGO_PANHS != algorithm)) {
3859 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3860 "[BTCoex], BT is under inquiry/page scan !!\n");
3861 BTC_TRACE(trace_buf);
3862 halbtc8812a2ant_action_bt_inquiry(btcoexist);
3866 coex_dm->cur_algorithm = algorithm;
3867 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "[BTCoex], Algorithm = %d\n",
3868 coex_dm->cur_algorithm);
3869 BTC_TRACE(trace_buf);
3871 if (halbtc8812a2ant_is_common_action(btcoexist)) {
3872 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3873 "[BTCoex], Action 2-Ant common.\n");
3874 BTC_TRACE(trace_buf);
3875 coex_dm->auto_tdma_adjust = false;
3876 coex_dm->auto_tdma_adjust_low_rssi = false;
3878 if (coex_dm->cur_algorithm != coex_dm->pre_algorithm) {
3879 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3880 "[BTCoex], pre_algorithm=%d, cur_algorithm=%d\n",
3881 coex_dm->pre_algorithm, coex_dm->cur_algorithm);
3882 BTC_TRACE(trace_buf);
3883 coex_dm->auto_tdma_adjust = false;
3884 coex_dm->auto_tdma_adjust_low_rssi = false;
3886 switch (coex_dm->cur_algorithm) {
3887 case BT_8812A_2ANT_COEX_ALGO_SCO:
3888 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3889 "[BTCoex], Action 2-Ant, algorithm = SCO.\n");
3890 BTC_TRACE(trace_buf);
3891 halbtc8812a2ant_action_sco(btcoexist);
3893 case BT_8812A_2ANT_COEX_ALGO_SCO_HID:
3894 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3895 "[BTCoex], Action 2-Ant, algorithm = SCO+HID.\n");
3896 BTC_TRACE(trace_buf);
3897 halbtc8812a2ant_action_sco_hid(btcoexist);
3899 case BT_8812A_2ANT_COEX_ALGO_HID:
3900 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3901 "[BTCoex], Action 2-Ant, algorithm = HID.\n");
3902 BTC_TRACE(trace_buf);
3903 halbtc8812a2ant_action_hid(btcoexist);
3905 case BT_8812A_2ANT_COEX_ALGO_A2DP:
3906 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3907 "[BTCoex], Action 2-Ant, algorithm = A2DP.\n");
3908 BTC_TRACE(trace_buf);
3909 halbtc8812a2ant_action_a2dp(btcoexist);
3911 case BT_8812A_2ANT_COEX_ALGO_A2DP_PANHS:
3912 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3913 "[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n");
3914 BTC_TRACE(trace_buf);
3915 halbtc8812a2ant_action_a2dp_pan_hs(btcoexist);
3917 case BT_8812A_2ANT_COEX_ALGO_PANEDR:
3918 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3919 "[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n");
3920 BTC_TRACE(trace_buf);
3921 halbtc8812a2ant_action_pan_edr(btcoexist);
3923 case BT_8812A_2ANT_COEX_ALGO_PANHS:
3924 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3925 "[BTCoex], Action 2-Ant, algorithm = HS mode.\n");
3926 BTC_TRACE(trace_buf);
3927 halbtc8812a2ant_action_pan_hs(btcoexist);
3929 case BT_8812A_2ANT_COEX_ALGO_PANEDR_A2DP:
3930 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3931 "[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n");
3932 BTC_TRACE(trace_buf);
3933 halbtc8812a2ant_action_pan_edr_a2dp(btcoexist);
3935 case BT_8812A_2ANT_COEX_ALGO_PANEDR_HID:
3936 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3937 "[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n");
3938 BTC_TRACE(trace_buf);
3939 halbtc8812a2ant_action_pan_edr_hid(btcoexist);
3941 case BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
3942 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3943 "[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n");
3944 BTC_TRACE(trace_buf);
3945 halbtc8812a2ant_action_hid_a2dp_pan_edr(
3948 case BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANHS:
3949 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3950 "[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN(HS).\n");
3951 BTC_TRACE(trace_buf);
3952 halbtc8812a2ant_action_hid_a2dp_pan_hs(
3955 case BT_8812A_2ANT_COEX_ALGO_HID_A2DP:
3956 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3957 "[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n");
3958 BTC_TRACE(trace_buf);
3959 halbtc8812a2ant_action_hid_a2dp(btcoexist);
3962 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3963 "[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n");
3964 BTC_TRACE(trace_buf);
3965 halbtc8812a2ant_coex_all_off(btcoexist);
3968 coex_dm->pre_algorithm = coex_dm->cur_algorithm;
3973 void halbtc8812a2ant_init_hw_config(IN struct btc_coexist *btcoexist,
3978 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3979 "[BTCoex], 2Ant Init HW Config!!\n");
3980 BTC_TRACE(trace_buf);
3983 /* backup rf 0x1e value */
3984 coex_dm->bt_rf_0x1e_backup =
3985 btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A, 0x1e,
3988 coex_dm->backup_arfr_cnt1 = btcoexist->btc_read_4byte(btcoexist,
3990 coex_dm->backup_arfr_cnt2 = btcoexist->btc_read_4byte(btcoexist,
3992 coex_dm->backup_retry_limit = btcoexist->btc_read_2byte(
3994 coex_dm->backup_ampdu_max_time = btcoexist->btc_read_1byte(
3998 /* ant sw control to BT */
3999 halbtc8812a2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_CPL_AUX, true,
4002 /* 0x790[5:0]=0x5 */
4003 u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790);
4006 btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp);
4009 btcoexist->btc_write_1byte(btcoexist, 0x6cc, 0x0);
4010 btcoexist->btc_write_4byte(btcoexist, 0x6c8, 0xffff);
4011 btcoexist->btc_write_4byte(btcoexist, 0x6c4, 0x55555555);
4012 btcoexist->btc_write_4byte(btcoexist, 0x6c0, 0x55555555);
4014 /* coex parameters */
4015 btcoexist->btc_write_1byte(btcoexist, 0x778, 0x1);
4017 /* enable counter statistics */
4018 btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4);
4021 btcoexist->btc_write_1byte(btcoexist, 0x40, 0x20);
4023 /* bt clock related */
4024 u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x4);
4026 btcoexist->btc_write_1byte(btcoexist, 0x4, u8tmp);
4028 /* bt clock related */
4029 u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x7);
4031 btcoexist->btc_write_1byte(btcoexist, 0x7, u8tmp);
4034 /* ************************************************************
4035 * work around function start with wa_halbtc8812a2ant_
4036 * ************************************************************
4037 * ************************************************************
4038 * extern function start with ex_halbtc8812a2ant_
4039 * ************************************************************ */
4040 void ex_halbtc8812a2ant_power_on_setting(IN struct btc_coexist *btcoexist)
4044 void ex_halbtc8812a2ant_init_hw_config(IN struct btc_coexist *btcoexist,
4045 IN boolean wifi_only)
4047 halbtc8812a2ant_init_hw_config(btcoexist, true);
4048 btcoexist->stop_coex_dm = false;
4051 void ex_halbtc8812a2ant_init_coex_dm(IN struct btc_coexist *btcoexist)
4053 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4054 "[BTCoex], Coex Mechanism Init!!\n");
4055 BTC_TRACE(trace_buf);
4056 btcoexist->stop_coex_dm = false;
4057 halbtc8812a2ant_init_coex_dm(btcoexist);
4060 void ex_halbtc8812a2ant_display_coex_info(IN struct btc_coexist *btcoexist)
4062 struct btc_board_info *board_info = &btcoexist->board_info;
4063 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
4064 u8 *cli_buf = btcoexist->cli_buf;
4065 u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0;
4068 u32 fw_ver = 0, bt_patch_ver = 0;
4070 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4071 "\r\n ============[BT Coexist info]============");
4074 if (btcoexist->manual_control) {
4075 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4076 "\r\n ============[Under Manual Control]============");
4078 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4079 "\r\n ==========================================");
4083 if (btcoexist->stop_coex_dm) {
4084 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4085 "\r\n ============[Coex is STOPPED]============");
4087 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4088 "\r\n ==========================================");
4092 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ",
4093 "Ant PG number/ Ant mechanism:",
4094 board_info->pg_ant_num, board_info->btdm_ant_num);
4097 btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
4098 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
4099 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4100 "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)",
4101 "CoexVer/ FwVer/ PatchVer",
4102 glcoex_ver_date_8812a_2ant, glcoex_ver_8812a_2ant, fw_ver,
4103 bt_patch_ver, bt_patch_ver);
4106 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ",
4107 "Wifi channel informed to BT",
4108 coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1],
4109 coex_dm->wifi_chnl_info[2]);
4113 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
4114 "============[Wifi Status]============");
4116 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_WIFI_STATUS);
4118 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
4119 "============[BT Status]============");
4121 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ",
4122 "BT [status/ rssi/ retryCnt]",
4123 ((coex_sta->bt_disabled) ? ("disabled") : ((
4124 coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan")
4125 : ((BT_8812A_2ANT_BT_STATUS_NON_CONNECTED_IDLE ==
4126 coex_dm->bt_status) ? "non-connected idle" :
4127 ((BT_8812A_2ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)
4128 ? "connected-idle" : "busy")))),
4129 coex_sta->bt_rssi, coex_sta->bt_retry_cnt);
4132 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d",
4134 bt_link_info->sco_exist, bt_link_info->hid_exist,
4135 bt_link_info->pan_exist, bt_link_info->a2dp_exist);
4137 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO);
4139 bt_info_ext = coex_sta->bt_info_ext;
4140 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s",
4141 "BT Info A2DP rate",
4142 (bt_info_ext & BIT(0)) ? "Basic rate" : "EDR rate");
4145 for (i = 0; i < BT_INFO_SRC_8812A_2ANT_MAX; i++) {
4146 if (coex_sta->bt_info_c2h_cnt[i]) {
4147 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4148 "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)",
4149 glbt_info_src_8812a_2ant[i],
4150 coex_sta->bt_info_c2h[i][0],
4151 coex_sta->bt_info_c2h[i][1],
4152 coex_sta->bt_info_c2h[i][2],
4153 coex_sta->bt_info_c2h[i][3],
4154 coex_sta->bt_info_c2h[i][4],
4155 coex_sta->bt_info_c2h[i][5],
4156 coex_sta->bt_info_c2h[i][6],
4157 coex_sta->bt_info_c2h_cnt[i]);
4163 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
4164 "============[Sw mechanism]============");
4166 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ",
4167 "SM1[ShRf/ LpRA/ LimDig]",
4168 coex_dm->cur_rf_rx_lpf_shrink, coex_dm->cur_low_penalty_ra,
4169 coex_dm->limited_dig);
4171 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ",
4172 "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]",
4173 coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off,
4174 coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl);
4178 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
4179 "============[Fw mechanism]============");
4182 ps_tdma_case = coex_dm->cur_ps_tdma;
4183 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4184 "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d/%d)",
4186 coex_dm->ps_tdma_para[0], coex_dm->ps_tdma_para[1],
4187 coex_dm->ps_tdma_para[2], coex_dm->ps_tdma_para[3],
4188 coex_dm->ps_tdma_para[4],
4189 ps_tdma_case, coex_dm->auto_tdma_adjust,
4190 coex_dm->auto_tdma_adjust_low_rssi);
4193 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ",
4194 "DecBtPwr/ IgnWlanAct",
4195 coex_dm->cur_bt_dec_pwr_lvl, coex_dm->cur_ignore_wlan_act);
4199 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
4200 "============[Hw setting]============");
4203 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x",
4204 "RF-A, 0x1e initVal",
4205 coex_dm->bt_rf_0x1e_backup);
4208 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x",
4209 "backup ARFR1/ARFR2/RL/AMaxTime",
4210 coex_dm->backup_arfr_cnt1, coex_dm->backup_arfr_cnt2,
4211 coex_dm->backup_retry_limit,
4212 coex_dm->backup_ampdu_max_time);
4215 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430);
4216 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434);
4217 u16tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a);
4218 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456);
4219 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x",
4220 "0x430/0x434/0x42a/0x456",
4221 u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0]);
4224 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
4225 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x6cc);
4226 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x ",
4227 "0x778 (W_Act)/ 0x6cc (CoTab Sel)",
4228 u8tmp[0], u8tmp[1]);
4231 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x8db);
4232 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xc5b);
4233 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
4234 "0x8db(ADC)/0xc5b[29:25](DAC)",
4235 ((u8tmp[0] & 0x60) >> 5), ((u8tmp[1] & 0x3e) >> 1));
4238 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xcb3);
4239 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xcb7);
4240 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
4242 u8tmp[0], u8tmp[1]);
4245 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40);
4246 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c);
4247 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x974);
4248 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
4249 "0x40/ 0x4c[24:23]/ 0x974",
4250 u8tmp[0], ((u32tmp[0] & 0x01800000) >> 23), u32tmp[1]);
4253 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
4254 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
4255 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
4256 "0x550(bcn ctrl)/0x522",
4257 u32tmp[0], u8tmp[0]);
4260 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50);
4261 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa0a);
4262 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
4263 "0xc50(DIG)/0xa0a(CCK-TH)",
4264 u32tmp[0], u8tmp[0]);
4267 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xf48);
4268 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b);
4269 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c);
4270 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
4271 "0xf48/ 0xa5b (FA cnt-- OFDM : CCK)",
4272 u32tmp[0], (u8tmp[0] << 8) + u8tmp[1]);
4275 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
4276 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
4277 u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
4278 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x6cc);
4279 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4280 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
4281 "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)",
4282 u32tmp[0], u32tmp[1], u32tmp[2], u8tmp[0]);
4285 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
4286 "0x770(high-pri rx/tx)",
4287 coex_sta->high_priority_rx, coex_sta->high_priority_tx);
4289 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
4290 "0x774(low-pri rx/tx)",
4291 coex_sta->low_priority_rx, coex_sta->low_priority_tx);
4293 #if (BT_AUTO_REPORT_ONLY_8812A_2ANT == 1)
4294 halbtc8812a2ant_monitor_bt_ctr(btcoexist);
4296 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS);
4300 void ex_halbtc8812a2ant_ips_notify(IN struct btc_coexist *btcoexist, IN u8 type)
4302 boolean wifi_under_5g = false;
4304 if (btcoexist->manual_control || btcoexist->stop_coex_dm)
4307 if (BTC_IPS_ENTER == type) {
4308 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4309 "[BTCoex], IPS ENTER notify\n");
4310 BTC_TRACE(trace_buf);
4311 coex_sta->under_ips = true;
4312 halbtc8812a2ant_coex_all_off(btcoexist);
4313 halbtc8812a2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_CPL_AUX,
4316 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4317 "[BTCoex], IPS notify, force set BT to ignore Wlan active!!\n");
4318 BTC_TRACE(trace_buf);
4319 halbtc8812a2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
4320 ex_halbtc8812a2ant_media_status_notify(btcoexist,
4321 BTC_MEDIA_DISCONNECT);
4322 } else if (BTC_IPS_LEAVE == type) {
4323 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4324 "[BTCoex], IPS LEAVE notify\n");
4325 BTC_TRACE(trace_buf);
4326 coex_sta->under_ips = false;
4328 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G,
4330 if (!wifi_under_5g) {
4331 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4332 "[BTCoex], IPS notify, force set BT NOT to ignore Wlan active!!\n");
4333 BTC_TRACE(trace_buf);
4334 halbtc8812a2ant_ignore_wlan_act(btcoexist, FORCE_EXEC,
4340 void ex_halbtc8812a2ant_lps_notify(IN struct btc_coexist *btcoexist, IN u8 type)
4343 if (btcoexist->manual_control || btcoexist->stop_coex_dm)
4346 if (BTC_LPS_ENABLE == type) {
4347 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4348 "[BTCoex], LPS ENABLE notify\n");
4349 BTC_TRACE(trace_buf);
4350 coex_sta->under_lps = true;
4351 } else if (BTC_LPS_DISABLE == type) {
4352 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4353 "[BTCoex], LPS DISABLE notify\n");
4354 BTC_TRACE(trace_buf);
4355 coex_sta->under_lps = false;
4359 void ex_halbtc8812a2ant_scan_notify(IN struct btc_coexist *btcoexist,
4362 if (BTC_SCAN_START == type) {
4363 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4364 "[BTCoex], SCAN START notify\n");
4365 BTC_TRACE(trace_buf);
4366 } else if (BTC_SCAN_FINISH == type) {
4367 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4368 "[BTCoex], SCAN FINISH notify\n");
4369 BTC_TRACE(trace_buf);
4373 void ex_halbtc8812a2ant_connect_notify(IN struct btc_coexist *btcoexist,
4376 if (BTC_ASSOCIATE_START == type) {
4377 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4378 "[BTCoex], CONNECT START notify\n");
4379 BTC_TRACE(trace_buf);
4380 } else if (BTC_ASSOCIATE_FINISH == type) {
4381 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4382 "[BTCoex], CONNECT FINISH notify\n");
4383 BTC_TRACE(trace_buf);
4387 void ex_halbtc8812a2ant_media_status_notify(IN struct btc_coexist *btcoexist,
4392 u8 h2c_parameter[3] = {0};
4394 u8 wifi_central_chnl;
4396 if (btcoexist->manual_control ||
4397 btcoexist->stop_coex_dm ||
4398 coex_sta->bt_disabled)
4401 if (BTC_MEDIA_CONNECT == type) {
4402 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4403 "[BTCoex], MEDIA connect notify\n");
4404 BTC_TRACE(trace_buf);
4406 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4407 "[BTCoex], MEDIA disconnect notify\n");
4408 BTC_TRACE(trace_buf);
4411 /* only 2.4G we need to inform bt the chnl mask */
4412 btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL,
4413 &wifi_central_chnl);
4414 if ((BTC_MEDIA_CONNECT == type) &&
4415 (wifi_central_chnl <= 14)) {
4416 h2c_parameter[0] = 0x1;
4417 h2c_parameter[1] = wifi_central_chnl;
4418 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
4419 if (BTC_WIFI_BW_HT40 == wifi_bw)
4420 h2c_parameter[2] = 0x30;
4422 h2c_parameter[2] = 0x20;
4425 coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
4426 coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
4427 coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
4430 buf[1] = 0x5; /* OP_Code */
4431 buf[2] = 0x3; /* OP_Code_Length */
4432 buf[3] = h2c_parameter[0]; /* OP_Code_Content */
4433 buf[4] = h2c_parameter[1];
4434 buf[5] = h2c_parameter[2];
4436 btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_COEX,
4440 void ex_halbtc8812a2ant_specific_packet_notify(IN struct btc_coexist *btcoexist,
4443 if (type == BTC_PACKET_DHCP) {
4444 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4445 "[BTCoex], DHCP Packet notify\n");
4446 BTC_TRACE(trace_buf);
4451 void ex_halbtc8812a2ant_bt_info_notify(IN struct btc_coexist *btcoexist,
4452 IN u8 *tmp_buf, IN u8 length)
4455 u8 i, rsp_source = 0;
4456 boolean bt_busy = false, limited_dig = false;
4457 boolean wifi_connected = false, wifi_under_5g = false;
4459 coex_sta->c2h_bt_info_req_sent = false;
4460 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
4462 rsp_source = tmp_buf[0] & 0xf;
4463 if (rsp_source >= BT_INFO_SRC_8812A_2ANT_MAX)
4464 rsp_source = BT_INFO_SRC_8812A_2ANT_WIFI_FW;
4465 coex_sta->bt_info_c2h_cnt[rsp_source]++;
4467 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4468 "[BTCoex], Bt info[%d], length=%d, hex data=[", rsp_source,
4470 BTC_TRACE(trace_buf);
4471 for (i = 0; i < length; i++) {
4472 coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i];
4474 bt_info = tmp_buf[i];
4475 if (i == length - 1) {
4476 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "0x%02x]\n",
4478 BTC_TRACE(trace_buf);
4480 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "0x%02x, ",
4482 BTC_TRACE(trace_buf);
4486 if (BT_INFO_SRC_8812A_2ANT_WIFI_FW != rsp_source) {
4487 coex_sta->bt_retry_cnt = /* [3:0] */
4488 coex_sta->bt_info_c2h[rsp_source][2] & 0xf;
4491 coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10;
4493 coex_sta->bt_info_ext =
4494 coex_sta->bt_info_c2h[rsp_source][4];
4496 /* Here we need to resend some wifi info to BT */
4497 /* because bt is reset and loss of the info. */
4498 if ((coex_sta->bt_info_ext & BIT(1))) {
4499 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4500 "[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n");
4501 BTC_TRACE(trace_buf);
4502 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
4505 ex_halbtc8812a2ant_media_status_notify(
4506 btcoexist, BTC_MEDIA_CONNECT);
4508 ex_halbtc8812a2ant_media_status_notify(
4509 btcoexist, BTC_MEDIA_DISCONNECT);
4512 if ((coex_sta->bt_info_ext & BIT(3)) && !wifi_under_5g) {
4513 /* BT already ignored WlanAct */
4514 if (!btcoexist->manual_control &&
4515 !btcoexist->stop_coex_dm) {
4516 if (!coex_sta->under_ips) {
4517 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4518 "[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n");
4519 BTC_TRACE(trace_buf);
4520 halbtc8812a2ant_ignore_wlan_act(
4521 btcoexist, FORCE_EXEC, false);
4525 /* BT already NOT ignore Wlan active, do nothing here. */
4527 if (coex_sta->under_ips) {
4528 /* work around for 8812a combo hw bug => when IPS, wlanAct is always high. */
4529 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4530 "[BTCoex], wifi is under IPS, set BT to ignore Wlan active!!\n");
4531 BTC_TRACE(trace_buf);
4532 halbtc8812a2ant_ignore_wlan_act(btcoexist,
4538 /* check BIT2 first ==> check if bt is under inquiry or page scan */
4539 if (bt_info & BT_INFO_8812A_2ANT_B_INQ_PAGE)
4540 coex_sta->c2h_bt_inquiry_page = true;
4542 coex_sta->c2h_bt_inquiry_page = false;
4544 /* set link exist status */
4545 if (!(bt_info & BT_INFO_8812A_2ANT_B_CONNECTION)) {
4546 coex_sta->bt_link_exist = false;
4547 coex_sta->pan_exist = false;
4548 coex_sta->a2dp_exist = false;
4549 coex_sta->hid_exist = false;
4550 coex_sta->sco_exist = false;
4551 coex_sta->acl_busy = false;
4552 } else { /* connection exists */
4553 coex_sta->bt_link_exist = true;
4554 if (bt_info & BT_INFO_8812A_2ANT_B_FTP)
4555 coex_sta->pan_exist = true;
4557 coex_sta->pan_exist = false;
4558 if (bt_info & BT_INFO_8812A_2ANT_B_A2DP)
4559 coex_sta->a2dp_exist = true;
4561 coex_sta->a2dp_exist = false;
4562 if (bt_info & BT_INFO_8812A_2ANT_B_HID)
4563 coex_sta->hid_exist = true;
4565 coex_sta->hid_exist = false;
4566 if (bt_info & BT_INFO_8812A_2ANT_B_SCO_ESCO)
4567 coex_sta->sco_exist = true;
4569 coex_sta->sco_exist = false;
4570 if (bt_info & BT_INFO_8812A_2ANT_B_ACL_BUSY)
4571 coex_sta->acl_busy = true;
4573 coex_sta->acl_busy = false;
4577 halbtc8812a2ant_update_bt_link_info(btcoexist);
4579 if (!(bt_info & BT_INFO_8812A_2ANT_B_CONNECTION)) {
4580 coex_dm->bt_status = BT_8812A_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
4581 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4582 "[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n");
4583 BTC_TRACE(trace_buf);
4584 } else if (bt_info ==
4585 BT_INFO_8812A_2ANT_B_CONNECTION) { /* connection exists but no busy */
4586 coex_dm->bt_status = BT_8812A_2ANT_BT_STATUS_CONNECTED_IDLE;
4587 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4588 "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
4589 BTC_TRACE(trace_buf);
4590 } else if ((bt_info & BT_INFO_8812A_2ANT_B_SCO_ESCO) ||
4591 (bt_info & BT_INFO_8812A_2ANT_B_SCO_BUSY)) {
4592 coex_dm->bt_status = BT_8812A_2ANT_BT_STATUS_SCO_BUSY;
4593 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4594 "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n");
4595 BTC_TRACE(trace_buf);
4596 } else if (bt_info & BT_INFO_8812A_2ANT_B_ACL_BUSY) {
4597 coex_dm->bt_status = BT_8812A_2ANT_BT_STATUS_ACL_BUSY;
4598 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4599 "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n");
4600 BTC_TRACE(trace_buf);
4602 coex_dm->bt_status = BT_8812A_2ANT_BT_STATUS_MAX;
4603 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4604 "[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n");
4605 BTC_TRACE(trace_buf);
4608 if ((BT_8812A_2ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
4609 (BT_8812A_2ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
4610 (BT_8812A_2ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) {
4616 limited_dig = false;
4619 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
4621 coex_dm->limited_dig = limited_dig;
4622 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
4624 halbtc8812a2ant_run_coexist_mechanism(btcoexist);
4627 void ex_halbtc8812a2ant_rf_status_notify(IN struct btc_coexist *btcoexist,
4630 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "[BTCoex], RF Status notify\n");
4631 BTC_TRACE(trace_buf);
4633 if (BTC_RF_ON == type) {
4634 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4635 "[BTCoex], RF is turned ON!!\n");
4636 BTC_TRACE(trace_buf);
4637 btcoexist->stop_coex_dm = false;
4639 if (BTC_RF_OFF == type) {
4640 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4641 "[BTCoex], RF is turned OFF!!\n");
4642 BTC_TRACE(trace_buf);
4644 halbtc8812a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
4646 halbtc8812a2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1);
4647 /* halbtc8812a2ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, FORCE_EXEC, false, true); */
4648 halbtc8812a2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
4649 btcoexist->stop_coex_dm = true;
4655 void ex_halbtc8812a2ant_halt_notify(IN struct btc_coexist *btcoexist)
4658 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "[BTCoex], Halt notify\n");
4659 BTC_TRACE(trace_buf);
4661 halbtc8812a2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_CPL_AUX, false,
4663 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4664 "[BTCoex], Halt notify, force set BT to ignore Wlan active!!\n");
4665 BTC_TRACE(trace_buf);
4666 halbtc8812a2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
4667 ex_halbtc8812a2ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT);
4669 /* 0x522=0xff, pause tx */
4670 btcoexist->btc_write_1byte(btcoexist, 0x522, 0xff);
4671 /* 0x40[7:6]=2'b01, modify BT mode. */
4672 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0xc0, 0x2);
4673 btcoexist->stop_coex_dm = true;
4676 void ex_halbtc8812a2ant_periodical(IN struct btc_coexist *btcoexist)
4678 #if (BT_AUTO_REPORT_ONLY_8812A_2ANT == 0)
4679 halbtc8812a2ant_query_bt_info(btcoexist);
4680 halbtc8812a2ant_monitor_bt_ctr(btcoexist);
4681 halbtc8812a2ant_monitor_bt_enable_disable(btcoexist);
4683 if (halbtc8812a2ant_is_wifi_status_changed(btcoexist) ||
4684 coex_dm->auto_tdma_adjust ||
4685 coex_dm->auto_tdma_adjust_low_rssi)
4686 halbtc8812a2ant_run_coexist_mechanism(btcoexist);
4690 void ex_halbtc8812a2ant_dbg_control(IN struct btc_coexist *btcoexist,
4691 IN u8 op_code, IN u8 op_len, IN u8 *pdata)
4694 case BTC_DBG_SET_COEX_DEC_BT_PWR:
4695 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4696 "[BTCoex], Set Dec BT power\n");
4697 BTC_TRACE(trace_buf);
4701 u8 dec_bt_pwr = 0, pwr_level = 0;
4703 dec_bt_pwr = pdata[0];
4704 pwr_level = pdata[1];
4707 buf[1] = 0x3; /* OP_Code */
4708 buf[2] = 0x2; /* OP_Code_Length */
4710 buf[3] = dec_bt_pwr; /* OP_Code_Content */
4712 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4713 "[BTCoex], Set Dec BT power=%d, pwr_level=%d\n",
4714 dec_bt_pwr, pwr_level);
4715 BTC_TRACE(trace_buf);
4716 btcoexist->btc_set(btcoexist,
4717 BTC_SET_ACT_CTRL_BT_COEX,
4723 case BTC_DBG_SET_COEX_BT_AFH_MAP:
4724 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4725 "[BTCoex], Set BT AFH Map\n");
4726 BTC_TRACE(trace_buf);
4732 buf[1] = 0x5; /* OP_Code */
4733 buf[2] = 0x3; /* OP_Code_Length */
4735 buf[3] = pdata[0]; /* OP_Code_Content */
4739 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4740 "[BTCoex], Set BT AFH Map = %02x %02x %02x\n",
4741 pdata[0], pdata[1], pdata[2]);
4742 BTC_TRACE(trace_buf);
4743 btcoexist->btc_set(btcoexist,
4744 BTC_SET_ACT_CTRL_BT_COEX,
4750 case BTC_DBG_SET_COEX_BT_IGNORE_WLAN_ACT:
4751 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4752 "[BTCoex], Set BT Ignore Wlan Active\n");
4753 BTC_TRACE(trace_buf);
4759 buf[1] = 0x1; /* OP_Code */
4760 buf[2] = 0x1; /* OP_Code_Length */
4762 buf[3] = pdata[0]; /* OP_Code_Content */
4763 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4764 "[BTCoex], Set BT Ignore Wlan Active = 0x%x\n",
4766 BTC_TRACE(trace_buf);
4768 btcoexist->btc_set(btcoexist,
4769 BTC_SET_ACT_CTRL_BT_COEX,
4782 #endif /* #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1) */