1 /******************************************************************************
3 * Copyright(c) 2012 Realtek Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 *****************************************************************************/
25 /***************************************************************
28 * This file is for RTL8723B Co-exist mechanism
31 * 2012/11/15 Cosa first check in.
33 **************************************************************/
34 /**************************************************************
36 **************************************************************/
37 #include "halbt_precomp.h"
38 /**************************************************************
39 * Global variables, these are static variables
40 **************************************************************/
41 static struct coex_dm_8723b_2ant glcoex_dm_8723b_2ant
;
42 static struct coex_dm_8723b_2ant
*coex_dm
= &glcoex_dm_8723b_2ant
;
43 static struct coex_sta_8723b_2ant glcoex_sta_8723b_2ant
;
44 static struct coex_sta_8723b_2ant
*coex_sta
= &glcoex_sta_8723b_2ant
;
46 static const char *const glbt_info_src_8723b_2ant
[] = {
49 "BT Info[bt auto report]",
52 static u32 glcoex_ver_date_8723b_2ant
= 20131113;
53 static u32 glcoex_ver_8723b_2ant
= 0x3f;
55 /**************************************************************
56 * local function proto type if needed
57 **************************************************************/
58 /**************************************************************
59 * local function start with btc8723b2ant_
60 **************************************************************/
61 static u8
btc8723b2ant_bt_rssi_state(u8 level_num
, u8 rssi_thresh
,
65 u8 bt_rssi_state
= coex_sta
->pre_bt_rssi_state
;
67 bt_rssi
= coex_sta
->bt_rssi
;
70 if ((coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
71 (coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
72 if (bt_rssi
>= rssi_thresh
+
73 BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT
) {
74 bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
75 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
76 "[BTCoex], BT Rssi state "
79 bt_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
80 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
81 "[BTCoex], BT Rssi state "
85 if (bt_rssi
< rssi_thresh
) {
86 bt_rssi_state
= BTC_RSSI_STATE_LOW
;
87 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
88 "[BTCoex], BT Rssi state "
91 bt_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
92 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
93 "[BTCoex], BT Rssi state "
97 } else if (level_num
== 3) {
98 if (rssi_thresh
> rssi_thresh1
) {
99 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
100 "[BTCoex], BT Rssi thresh error!!\n");
101 return coex_sta
->pre_bt_rssi_state
;
104 if ((coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_LOW
) ||
105 (coex_sta
->pre_bt_rssi_state
== BTC_RSSI_STATE_STAY_LOW
)) {
106 if (bt_rssi
>= rssi_thresh
+
107 BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT
) {
108 bt_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
109 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
110 "[BTCoex], BT Rssi state "
111 "switch to Medium\n");
113 bt_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
114 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
115 "[BTCoex], BT Rssi state "
118 } else if ((coex_sta
->pre_bt_rssi_state
==
119 BTC_RSSI_STATE_MEDIUM
) ||
120 (coex_sta
->pre_bt_rssi_state
==
121 BTC_RSSI_STATE_STAY_MEDIUM
)) {
122 if (bt_rssi
>= rssi_thresh1
+
123 BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT
) {
124 bt_rssi_state
= BTC_RSSI_STATE_HIGH
;
125 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
126 "[BTCoex], BT Rssi state "
128 } else if (bt_rssi
< rssi_thresh
) {
129 bt_rssi_state
= BTC_RSSI_STATE_LOW
;
130 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
131 "[BTCoex], BT Rssi state "
134 bt_rssi_state
= BTC_RSSI_STATE_STAY_MEDIUM
;
135 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
136 "[BTCoex], BT Rssi state "
140 if (bt_rssi
< rssi_thresh1
) {
141 bt_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
142 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
143 "[BTCoex], BT Rssi state "
144 "switch to Medium\n");
146 bt_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
147 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_RSSI_STATE
,
148 "[BTCoex], BT Rssi state "
154 coex_sta
->pre_bt_rssi_state
= bt_rssi_state
;
156 return bt_rssi_state
;
159 static u8
btc8723b2ant_wifi_rssi_state(struct btc_coexist
*btcoexist
,
160 u8 index
, u8 level_num
,
161 u8 rssi_thresh
, u8 rssi_thresh1
)
164 u8 wifi_rssi_state
= coex_sta
->pre_wifi_rssi_state
[index
];
166 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_WIFI_RSSI
, &wifi_rssi
);
168 if (level_num
== 2) {
169 if ((coex_sta
->pre_wifi_rssi_state
[index
] ==
170 BTC_RSSI_STATE_LOW
) ||
171 (coex_sta
->pre_wifi_rssi_state
[index
] ==
172 BTC_RSSI_STATE_STAY_LOW
)) {
173 if (wifi_rssi
>= rssi_thresh
+
174 BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT
) {
175 wifi_rssi_state
= BTC_RSSI_STATE_HIGH
;
176 BTC_PRINT(BTC_MSG_ALGORITHM
,
177 ALGO_WIFI_RSSI_STATE
,
178 "[BTCoex], wifi RSSI state "
181 wifi_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
182 BTC_PRINT(BTC_MSG_ALGORITHM
,
183 ALGO_WIFI_RSSI_STATE
,
184 "[BTCoex], wifi RSSI state "
188 if (wifi_rssi
< rssi_thresh
) {
189 wifi_rssi_state
= BTC_RSSI_STATE_LOW
;
190 BTC_PRINT(BTC_MSG_ALGORITHM
,
191 ALGO_WIFI_RSSI_STATE
,
192 "[BTCoex], wifi RSSI state "
195 wifi_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
196 BTC_PRINT(BTC_MSG_ALGORITHM
,
197 ALGO_WIFI_RSSI_STATE
,
198 "[BTCoex], wifi RSSI state "
202 } else if (level_num
== 3) {
203 if (rssi_thresh
> rssi_thresh1
) {
204 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_WIFI_RSSI_STATE
,
205 "[BTCoex], wifi RSSI thresh error!!\n");
206 return coex_sta
->pre_wifi_rssi_state
[index
];
209 if ((coex_sta
->pre_wifi_rssi_state
[index
] ==
210 BTC_RSSI_STATE_LOW
) ||
211 (coex_sta
->pre_wifi_rssi_state
[index
] ==
212 BTC_RSSI_STATE_STAY_LOW
)) {
213 if (wifi_rssi
>= rssi_thresh
+
214 BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT
) {
215 wifi_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
216 BTC_PRINT(BTC_MSG_ALGORITHM
,
217 ALGO_WIFI_RSSI_STATE
,
218 "[BTCoex], wifi RSSI state "
219 "switch to Medium\n");
221 wifi_rssi_state
= BTC_RSSI_STATE_STAY_LOW
;
222 BTC_PRINT(BTC_MSG_ALGORITHM
,
223 ALGO_WIFI_RSSI_STATE
,
224 "[BTCoex], wifi RSSI state "
227 } else if ((coex_sta
->pre_wifi_rssi_state
[index
] ==
228 BTC_RSSI_STATE_MEDIUM
) ||
229 (coex_sta
->pre_wifi_rssi_state
[index
] ==
230 BTC_RSSI_STATE_STAY_MEDIUM
)) {
231 if (wifi_rssi
>= rssi_thresh1
+
232 BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT
) {
233 wifi_rssi_state
= BTC_RSSI_STATE_HIGH
;
234 BTC_PRINT(BTC_MSG_ALGORITHM
,
235 ALGO_WIFI_RSSI_STATE
,
236 "[BTCoex], wifi RSSI state "
238 } else if (wifi_rssi
< rssi_thresh
) {
239 wifi_rssi_state
= BTC_RSSI_STATE_LOW
;
240 BTC_PRINT(BTC_MSG_ALGORITHM
,
241 ALGO_WIFI_RSSI_STATE
,
242 "[BTCoex], wifi RSSI state "
245 wifi_rssi_state
= BTC_RSSI_STATE_STAY_MEDIUM
;
246 BTC_PRINT(BTC_MSG_ALGORITHM
,
247 ALGO_WIFI_RSSI_STATE
,
248 "[BTCoex], wifi RSSI state "
252 if (wifi_rssi
< rssi_thresh1
) {
253 wifi_rssi_state
= BTC_RSSI_STATE_MEDIUM
;
254 BTC_PRINT(BTC_MSG_ALGORITHM
,
255 ALGO_WIFI_RSSI_STATE
,
256 "[BTCoex], wifi RSSI state "
257 "switch to Medium\n");
259 wifi_rssi_state
= BTC_RSSI_STATE_STAY_HIGH
;
260 BTC_PRINT(BTC_MSG_ALGORITHM
,
261 ALGO_WIFI_RSSI_STATE
,
262 "[BTCoex], wifi RSSI state "
268 coex_sta
->pre_wifi_rssi_state
[index
] = wifi_rssi_state
;
270 return wifi_rssi_state
;
273 static void btc8723b2ant_monitor_bt_ctr(struct btc_coexist
*btcoexist
)
275 u32 reg_hp_txrx
, reg_lp_txrx
, u32tmp
;
276 u32 reg_hp_tx
= 0, reg_hp_rx
= 0;
277 u32 reg_lp_tx
= 0, reg_lp_rx
= 0;
282 u32tmp
= btcoexist
->btc_read_4byte(btcoexist
, reg_hp_txrx
);
283 reg_hp_tx
= u32tmp
& MASKLWORD
;
284 reg_hp_rx
= (u32tmp
& MASKHWORD
) >> 16;
286 u32tmp
= btcoexist
->btc_read_4byte(btcoexist
, reg_lp_txrx
);
287 reg_lp_tx
= u32tmp
& MASKLWORD
;
288 reg_lp_rx
= (u32tmp
& MASKHWORD
) >> 16;
290 coex_sta
->high_priority_tx
= reg_hp_tx
;
291 coex_sta
->high_priority_rx
= reg_hp_rx
;
292 coex_sta
->low_priority_tx
= reg_lp_tx
;
293 coex_sta
->low_priority_rx
= reg_lp_rx
;
295 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_MONITOR
,
296 "[BTCoex], High Priority Tx/Rx(reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
297 reg_hp_txrx
, reg_hp_tx
, reg_hp_tx
, reg_hp_rx
, reg_hp_rx
);
298 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_BT_MONITOR
,
299 "[BTCoex], Low Priority Tx/Rx(reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
300 reg_lp_txrx
, reg_lp_tx
, reg_lp_tx
, reg_lp_rx
, reg_lp_rx
);
303 btcoexist
->btc_write_1byte(btcoexist
, 0x76e, 0xc);
306 static void btc8723b2ant_query_bt_info(struct btc_coexist
*btcoexist
)
308 u8 h2c_parameter
[1] = {0};
310 coex_sta
->c2h_bt_info_req_sent
= true;
312 h2c_parameter
[0] |= BIT0
; /* trigger */
314 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_EXEC
,
315 "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n",
318 btcoexist
->btc_fill_h2c(btcoexist
, 0x61, 1, h2c_parameter
);
321 static bool btc8723b2ant_is_wifi_status_changed(struct btc_coexist
*btcoexist
)
323 static bool pre_wifi_busy
;
324 static bool pre_under_4way
;
325 static bool pre_bt_hs_on
;
326 bool wifi_busy
= false, under_4way
= false, bt_hs_on
= false;
327 bool wifi_connected
= false;
329 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
331 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
332 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
333 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_4_WAY_PROGRESS
,
336 if (wifi_connected
) {
337 if (wifi_busy
!= pre_wifi_busy
) {
338 pre_wifi_busy
= wifi_busy
;
342 if (under_4way
!= pre_under_4way
) {
343 pre_under_4way
= under_4way
;
347 if (bt_hs_on
!= pre_bt_hs_on
) {
348 pre_bt_hs_on
= bt_hs_on
;
356 static void btc8723b2ant_update_bt_link_info(struct btc_coexist
*btcoexist
)
358 /*struct btc_stack_info *stack_info = &btcoexist->stack_info;*/
359 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
360 bool bt_hs_on
= false;
362 #if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 1) /* profile from bt patch */
363 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
365 bt_link_info
->bt_link_exist
= coex_sta
->bt_link_exist
;
366 bt_link_info
->sco_exist
= coex_sta
->sco_exist
;
367 bt_link_info
->a2dp_exist
= coex_sta
->a2dp_exist
;
368 bt_link_info
->pan_exist
= coex_sta
->pan_exist
;
369 bt_link_info
->hid_exist
= coex_sta
->hid_exist
;
371 /* work around for HS mode. */
373 bt_link_info
->pan_exist
= true;
374 bt_link_info
->bt_link_exist
= true;
376 #else /* profile from bt stack */
377 bt_link_info
->bt_link_exist
= stack_info
->bt_link_exist
;
378 bt_link_info
->sco_exist
= stack_info
->sco_exist
;
379 bt_link_info
->a2dp_exist
= stack_info
->a2dp_exist
;
380 bt_link_info
->pan_exist
= stack_info
->pan_exist
;
381 bt_link_info
->hid_exist
= stack_info
->hid_exist
;
383 /*for win-8 stack HID report error*/
384 if (!stack_info
->hid_exist
)
385 stack_info
->hid_exist
= coex_sta
->hid_exist
;
386 /*sync BTInfo with BT firmware and stack*/
387 /* when stack HID report error, here we use the info from bt fw.*/
388 if (!stack_info
->bt_link_exist
)
389 stack_info
->bt_link_exist
= coex_sta
->bt_link_exist
;
391 /* check if Sco only */
392 if (bt_link_info
->sco_exist
&& !bt_link_info
->a2dp_exist
&&
393 !bt_link_info
->pan_exist
&& !bt_link_info
->hid_exist
)
394 bt_link_info
->sco_only
= true;
396 bt_link_info
->sco_only
= false;
398 /* check if A2dp only */
399 if (!bt_link_info
->sco_exist
&& bt_link_info
->a2dp_exist
&&
400 !bt_link_info
->pan_exist
&& !bt_link_info
->hid_exist
)
401 bt_link_info
->a2dp_only
= true;
403 bt_link_info
->a2dp_only
= false;
405 /* check if Pan only */
406 if (!bt_link_info
->sco_exist
&& !bt_link_info
->a2dp_exist
&&
407 bt_link_info
->pan_exist
&& !bt_link_info
->hid_exist
)
408 bt_link_info
->pan_only
= true;
410 bt_link_info
->pan_only
= false;
412 /* check if Hid only */
413 if (!bt_link_info
->sco_exist
&& !bt_link_info
->a2dp_exist
&&
414 !bt_link_info
->pan_exist
&& bt_link_info
->hid_exist
)
415 bt_link_info
->hid_only
= true;
417 bt_link_info
->hid_only
= false;
420 static u8
btc8723b2ant_action_algorithm(struct btc_coexist
*btcoexist
)
422 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
423 bool bt_hs_on
= false;
424 u8 algorithm
= BT_8723B_2ANT_COEX_ALGO_UNDEFINED
;
425 u8 num_of_diff_profile
= 0;
427 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
429 if (!bt_link_info
->bt_link_exist
) {
430 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
431 "[BTCoex], No BT link exists!!!\n");
435 if (bt_link_info
->sco_exist
)
436 num_of_diff_profile
++;
437 if (bt_link_info
->hid_exist
)
438 num_of_diff_profile
++;
439 if (bt_link_info
->pan_exist
)
440 num_of_diff_profile
++;
441 if (bt_link_info
->a2dp_exist
)
442 num_of_diff_profile
++;
444 if (num_of_diff_profile
== 1) {
445 if (bt_link_info
->sco_exist
) {
446 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
447 "[BTCoex], SCO only\n");
448 algorithm
= BT_8723B_2ANT_COEX_ALGO_SCO
;
450 if (bt_link_info
->hid_exist
) {
451 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
452 "[BTCoex], HID only\n");
453 algorithm
= BT_8723B_2ANT_COEX_ALGO_HID
;
454 } else if (bt_link_info
->a2dp_exist
) {
455 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
456 "[BTCoex], A2DP only\n");
457 algorithm
= BT_8723B_2ANT_COEX_ALGO_A2DP
;
458 } else if (bt_link_info
->pan_exist
) {
460 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
461 "[BTCoex], PAN(HS) only\n");
463 BT_8723B_2ANT_COEX_ALGO_PANHS
;
465 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
466 "[BTCoex], PAN(EDR) only\n");
468 BT_8723B_2ANT_COEX_ALGO_PANEDR
;
472 } else if (num_of_diff_profile
== 2) {
473 if (bt_link_info
->sco_exist
) {
474 if (bt_link_info
->hid_exist
) {
475 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
476 "[BTCoex], SCO + HID\n");
477 algorithm
= BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
478 } else if (bt_link_info
->a2dp_exist
) {
479 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
480 "[BTCoex], SCO + A2DP ==> SCO\n");
481 algorithm
= BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
482 } else if (bt_link_info
->pan_exist
) {
484 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
485 "[BTCoex], SCO + PAN(HS)\n");
486 algorithm
= BT_8723B_2ANT_COEX_ALGO_SCO
;
488 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
489 "[BTCoex], SCO + PAN(EDR)\n");
491 BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
495 if (bt_link_info
->hid_exist
&&
496 bt_link_info
->a2dp_exist
) {
497 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
498 "[BTCoex], HID + A2DP\n");
499 algorithm
= BT_8723B_2ANT_COEX_ALGO_HID_A2DP
;
500 } else if (bt_link_info
->hid_exist
&&
501 bt_link_info
->pan_exist
) {
503 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
504 "[BTCoex], HID + PAN(HS)\n");
505 algorithm
= BT_8723B_2ANT_COEX_ALGO_HID
;
507 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
508 "[BTCoex], HID + PAN(EDR)\n");
510 BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
512 } else if (bt_link_info
->pan_exist
&&
513 bt_link_info
->a2dp_exist
) {
515 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
516 "[BTCoex], A2DP + PAN(HS)\n");
518 BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS
;
520 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
521 "[BTCoex],A2DP + PAN(EDR)\n");
523 BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP
;
527 } else if (num_of_diff_profile
== 3) {
528 if (bt_link_info
->sco_exist
) {
529 if (bt_link_info
->hid_exist
&&
530 bt_link_info
->a2dp_exist
) {
531 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
532 "[BTCoex], SCO + HID + A2DP"
534 algorithm
= BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
535 } else if (bt_link_info
->hid_exist
&&
536 bt_link_info
->pan_exist
) {
538 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
539 "[BTCoex], SCO + HID + "
542 BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
544 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
545 "[BTCoex], SCO + HID + "
548 BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
550 } else if (bt_link_info
->pan_exist
&&
551 bt_link_info
->a2dp_exist
) {
553 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
554 "[BTCoex], SCO + A2DP + "
557 BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
559 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
560 "[BTCoex], SCO + A2DP + "
561 "PAN(EDR) ==> HID\n");
563 BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
567 if (bt_link_info
->hid_exist
&&
568 bt_link_info
->pan_exist
&&
569 bt_link_info
->a2dp_exist
) {
571 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
572 "[BTCoex], HID + A2DP + "
575 BT_8723B_2ANT_COEX_ALGO_HID_A2DP
;
577 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
578 "[BTCoex], HID + A2DP + "
581 BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR
;
585 } else if (num_of_diff_profile
>= 3) {
586 if (bt_link_info
->sco_exist
) {
587 if (bt_link_info
->hid_exist
&&
588 bt_link_info
->pan_exist
&&
589 bt_link_info
->a2dp_exist
) {
591 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
592 "[BTCoex], Error!!! SCO + HID"
593 " + A2DP + PAN(HS)\n");
595 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
596 "[BTCoex], SCO + HID + A2DP +"
597 " PAN(EDR)==>PAN(EDR)+HID\n");
599 BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
;
607 static bool btc8723b_need_dec_pwr(struct btc_coexist
*btcoexist
)
610 bool bt_hs_on
= false, wifi_connected
= false;
614 if (!btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
))
616 if (!btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
619 if (!btcoexist
->btc_get(btcoexist
, BTC_GET_S4_HS_RSSI
, &bt_hs_rssi
))
622 bt_rssi_state
= btc8723b2ant_bt_rssi_state(2, 29, 0);
624 if (wifi_connected
) {
626 if (bt_hs_rssi
> 37) {
627 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW
,
628 "[BTCoex], Need to decrease bt "
629 "power for HS mode!!\n");
633 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
634 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
635 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW
,
636 "[BTCoex], Need to decrease bt "
637 "power for Wifi is connected!!\n");
646 static void btc8723b2ant_set_fw_dac_swing_level(struct btc_coexist
*btcoexist
,
649 u8 h2c_parameter
[1] = {0};
651 /* There are several type of dacswing
652 * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
654 h2c_parameter
[0] = dac_swing_lvl
;
656 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_EXEC
,
657 "[BTCoex], Set Dac Swing Level=0x%x\n", dac_swing_lvl
);
658 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_EXEC
,
659 "[BTCoex], FW write 0x64=0x%x\n", h2c_parameter
[0]);
661 btcoexist
->btc_fill_h2c(btcoexist
, 0x64, 1, h2c_parameter
);
664 static void btc8723b2ant_set_fw_dec_bt_pwr(struct btc_coexist
*btcoexist
,
667 u8 h2c_parameter
[1] = {0};
669 h2c_parameter
[0] = 0;
672 h2c_parameter
[0] |= BIT1
;
674 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_EXEC
,
675 "[BTCoex], decrease Bt Power : %s, FW write 0x62=0x%x\n",
676 (dec_bt_pwr
? "Yes!!" : "No!!"), h2c_parameter
[0]);
678 btcoexist
->btc_fill_h2c(btcoexist
, 0x62, 1, h2c_parameter
);
681 static void btc8723b2ant_dec_bt_pwr(struct btc_coexist
*btcoexist
,
682 bool force_exec
, bool dec_bt_pwr
)
684 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW
,
685 "[BTCoex], %s Dec BT power = %s\n",
686 (force_exec
? "force to" : ""), (dec_bt_pwr
? "ON" : "OFF"));
687 coex_dm
->cur_dec_bt_pwr
= dec_bt_pwr
;
690 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
691 "[BTCoex], bPreDecBtPwr=%d, bCurDecBtPwr=%d\n",
692 coex_dm
->pre_dec_bt_pwr
, coex_dm
->cur_dec_bt_pwr
);
694 if (coex_dm
->pre_dec_bt_pwr
== coex_dm
->cur_dec_bt_pwr
)
697 btc8723b2ant_set_fw_dec_bt_pwr(btcoexist
, coex_dm
->cur_dec_bt_pwr
);
699 coex_dm
->pre_dec_bt_pwr
= coex_dm
->cur_dec_bt_pwr
;
702 static void btc8723b2ant_fw_dac_swing_lvl(struct btc_coexist
*btcoexist
,
703 bool force_exec
, u8 fw_dac_swing_lvl
)
705 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW
,
706 "[BTCoex], %s set FW Dac Swing level = %d\n",
707 (force_exec
? "force to" : ""), fw_dac_swing_lvl
);
708 coex_dm
->cur_fw_dac_swing_lvl
= fw_dac_swing_lvl
;
711 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
712 "[BTCoex], preFwDacSwingLvl=%d, "
713 "curFwDacSwingLvl=%d\n",
714 coex_dm
->pre_fw_dac_swing_lvl
,
715 coex_dm
->cur_fw_dac_swing_lvl
);
717 if (coex_dm
->pre_fw_dac_swing_lvl
==
718 coex_dm
->cur_fw_dac_swing_lvl
)
722 btc8723b2ant_set_fw_dac_swing_level(btcoexist
,
723 coex_dm
->cur_fw_dac_swing_lvl
);
724 coex_dm
->pre_fw_dac_swing_lvl
= coex_dm
->cur_fw_dac_swing_lvl
;
727 static void btc8723b2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist
*btcoexist
,
728 bool rx_rf_shrink_on
)
730 if (rx_rf_shrink_on
) {
731 /* Shrink RF Rx LPF corner */
732 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
733 "[BTCoex], Shrink RF Rx LPF corner!!\n");
734 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1e,
737 /* Resume RF Rx LPF corner */
738 /* After initialized, we can use coex_dm->btRf0x1eBackup */
739 if (btcoexist
->initilized
) {
740 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
741 "[BTCoex], Resume RF Rx LPF corner!!\n");
742 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1e,
744 coex_dm
->bt_rf0x1e_backup
);
749 static void btc8723b2ant_rf_shrink(struct btc_coexist
*btcoexist
,
750 bool force_exec
, bool rx_rf_shrink_on
)
752 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW
,
753 "[BTCoex], %s turn Rx RF Shrink = %s\n",
754 (force_exec
? "force to" : ""), (rx_rf_shrink_on
?
756 coex_dm
->cur_rf_rx_lpf_shrink
= rx_rf_shrink_on
;
759 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_DETAIL
,
760 "[BTCoex], bPreRfRxLpfShrink=%d, "
761 "bCurRfRxLpfShrink=%d\n",
762 coex_dm
->pre_rf_rx_lpf_shrink
,
763 coex_dm
->cur_rf_rx_lpf_shrink
);
765 if (coex_dm
->pre_rf_rx_lpf_shrink
==
766 coex_dm
->cur_rf_rx_lpf_shrink
)
769 btc8723b2ant_set_sw_rf_rx_lpf_corner(btcoexist
,
770 coex_dm
->cur_rf_rx_lpf_shrink
);
772 coex_dm
->pre_rf_rx_lpf_shrink
= coex_dm
->cur_rf_rx_lpf_shrink
;
775 static void btc8723b_set_penalty_txrate(struct btc_coexist
*btcoexist
,
778 u8 h2c_parameter
[6] = {0};
780 h2c_parameter
[0] = 0x6; /* opCode, 0x6= Retry_Penalty*/
782 if (low_penalty_ra
) {
783 h2c_parameter
[1] |= BIT0
;
784 /*normal rate except MCS7/6/5, OFDM54/48/36*/
785 h2c_parameter
[2] = 0x00;
786 h2c_parameter
[3] = 0xf7; /*MCS7 or OFDM54*/
787 h2c_parameter
[4] = 0xf8; /*MCS6 or OFDM48*/
788 h2c_parameter
[5] = 0xf9; /*MCS5 or OFDM36*/
791 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_EXEC
,
792 "[BTCoex], set WiFi Low-Penalty Retry: %s",
793 (low_penalty_ra
? "ON!!" : "OFF!!"));
795 btcoexist
->btc_fill_h2c(btcoexist
, 0x69, 6, h2c_parameter
);
798 static void btc8723b2ant_low_penalty_ra(struct btc_coexist
*btcoexist
,
799 bool force_exec
, bool low_penalty_ra
)
802 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW
,
803 "[BTCoex], %s turn LowPenaltyRA = %s\n",
804 (force_exec
? "force to" : ""), (low_penalty_ra
?
806 coex_dm
->cur_low_penalty_ra
= low_penalty_ra
;
809 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_DETAIL
,
810 "[BTCoex], bPreLowPenaltyRa=%d, "
811 "bCurLowPenaltyRa=%d\n",
812 coex_dm
->pre_low_penalty_ra
,
813 coex_dm
->cur_low_penalty_ra
);
815 if (coex_dm
->pre_low_penalty_ra
== coex_dm
->cur_low_penalty_ra
)
818 btc8723b_set_penalty_txrate(btcoexist
, coex_dm
->cur_low_penalty_ra
);
820 coex_dm
->pre_low_penalty_ra
= coex_dm
->cur_low_penalty_ra
;
823 static void btc8723b2ant_set_dac_swing_reg(struct btc_coexist
*btcoexist
,
827 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
828 "[BTCoex], Write SwDacSwing = 0x%x\n", level
);
829 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x883, 0x3e, val
);
832 static void btc8723b2ant_set_sw_fulltime_dac_swing(struct btc_coexist
*btcoex
,
833 bool sw_dac_swing_on
,
834 u32 sw_dac_swing_lvl
)
837 btc8723b2ant_set_dac_swing_reg(btcoex
, sw_dac_swing_lvl
);
839 btc8723b2ant_set_dac_swing_reg(btcoex
, 0x18);
842 static void btc8723b2ant_dac_swing(struct btc_coexist
*btcoexist
,
843 bool force_exec
, bool dac_swing_on
,
846 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW
,
847 "[BTCoex], %s turn DacSwing=%s, dac_swing_lvl=0x%x\n",
848 (force_exec
? "force to" : ""),
849 (dac_swing_on
? "ON" : "OFF"), dac_swing_lvl
);
850 coex_dm
->cur_dac_swing_on
= dac_swing_on
;
851 coex_dm
->cur_dac_swing_lvl
= dac_swing_lvl
;
854 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_DETAIL
,
855 "[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x,"
856 " bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
857 coex_dm
->pre_dac_swing_on
, coex_dm
->pre_dac_swing_lvl
,
858 coex_dm
->cur_dac_swing_on
,
859 coex_dm
->cur_dac_swing_lvl
);
861 if ((coex_dm
->pre_dac_swing_on
== coex_dm
->cur_dac_swing_on
) &&
862 (coex_dm
->pre_dac_swing_lvl
== coex_dm
->cur_dac_swing_lvl
))
866 btc8723b2ant_set_sw_fulltime_dac_swing(btcoexist
, dac_swing_on
,
869 coex_dm
->pre_dac_swing_on
= coex_dm
->cur_dac_swing_on
;
870 coex_dm
->pre_dac_swing_lvl
= coex_dm
->cur_dac_swing_lvl
;
873 static void btc8723b2ant_set_agc_table(struct btc_coexist
*btcoexist
,
876 u8 rssi_adjust_val
= 0;
878 /* BB AGC Gain Table */
880 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
881 "[BTCoex], BB Agc Table On!\n");
882 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x6e1A0001);
883 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x6d1B0001);
884 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x6c1C0001);
885 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x6b1D0001);
886 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x6a1E0001);
887 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x691F0001);
888 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0x68200001);
890 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
891 "[BTCoex], BB Agc Table Off!\n");
892 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xaa1A0001);
893 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa91B0001);
894 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa81C0001);
895 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa71D0001);
896 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa61E0001);
897 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa51F0001);
898 btcoexist
->btc_write_4byte(btcoexist
, 0xc78, 0xa4200001);
902 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0xef, 0xfffff, 0x02000);
904 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
905 "[BTCoex], Agc Table On!\n");
906 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x3b,
908 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x3b,
911 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
912 "[BTCoex], Agc Table Off!\n");
913 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x3b,
915 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x3b,
918 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0xef, 0xfffff, 0x0);
920 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0xed, 0xfffff, 0x1);
923 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
924 "[BTCoex], Agc Table On!\n");
925 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x40,
927 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x40,
930 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
931 "[BTCoex], Agc Table Off!\n");
932 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x40,
934 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x40,
937 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0xed, 0xfffff, 0x0);
939 /* set rssiAdjustVal for wifi module. */
942 btcoexist
->btc_set(btcoexist
, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON
,
946 static void btc8723b2ant_agc_table(struct btc_coexist
*btcoexist
,
947 bool force_exec
, bool agc_table_en
)
949 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW
,
950 "[BTCoex], %s %s Agc Table\n",
951 (force_exec
? "force to" : ""),
952 (agc_table_en
? "Enable" : "Disable"));
953 coex_dm
->cur_agc_table_en
= agc_table_en
;
956 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_DETAIL
,
957 "[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
958 coex_dm
->pre_agc_table_en
, coex_dm
->cur_agc_table_en
);
960 if (coex_dm
->pre_agc_table_en
== coex_dm
->cur_agc_table_en
)
963 btc8723b2ant_set_agc_table(btcoexist
, agc_table_en
);
965 coex_dm
->pre_agc_table_en
= coex_dm
->cur_agc_table_en
;
968 static void btc8723b2ant_set_coex_table(struct btc_coexist
*btcoexist
,
969 u32 val0x6c0
, u32 val0x6c4
,
970 u32 val0x6c8
, u8 val0x6cc
)
972 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
973 "[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0
);
974 btcoexist
->btc_write_4byte(btcoexist
, 0x6c0, val0x6c0
);
976 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
977 "[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4
);
978 btcoexist
->btc_write_4byte(btcoexist
, 0x6c4, val0x6c4
);
980 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
981 "[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8
);
982 btcoexist
->btc_write_4byte(btcoexist
, 0x6c8, val0x6c8
);
984 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_EXEC
,
985 "[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc
);
986 btcoexist
->btc_write_1byte(btcoexist
, 0x6cc, val0x6cc
);
989 static void btc8723b2ant_coex_table(struct btc_coexist
*btcoexist
,
990 bool force_exec
, u32 val0x6c0
,
991 u32 val0x6c4
, u32 val0x6c8
,
994 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW
,
995 "[BTCoex], %s write Coex Table 0x6c0=0x%x,"
996 " 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
997 (force_exec
? "force to" : ""), val0x6c0
,
998 val0x6c4
, val0x6c8
, val0x6cc
);
999 coex_dm
->cur_val0x6c0
= val0x6c0
;
1000 coex_dm
->cur_val0x6c4
= val0x6c4
;
1001 coex_dm
->cur_val0x6c8
= val0x6c8
;
1002 coex_dm
->cur_val0x6cc
= val0x6cc
;
1005 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_DETAIL
,
1006 "[BTCoex], preVal0x6c0=0x%x, "
1007 "preVal0x6c4=0x%x, preVal0x6c8=0x%x, "
1008 "preVal0x6cc=0x%x !!\n",
1009 coex_dm
->pre_val0x6c0
, coex_dm
->pre_val0x6c4
,
1010 coex_dm
->pre_val0x6c8
, coex_dm
->pre_val0x6cc
);
1011 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_SW_DETAIL
,
1012 "[BTCoex], curVal0x6c0=0x%x, "
1013 "curVal0x6c4=0x%x, curVal0x6c8=0x%x, "
1014 "curVal0x6cc=0x%x !!\n",
1015 coex_dm
->cur_val0x6c0
, coex_dm
->cur_val0x6c4
,
1016 coex_dm
->cur_val0x6c8
, coex_dm
->cur_val0x6cc
);
1018 if ((coex_dm
->pre_val0x6c0
== coex_dm
->cur_val0x6c0
) &&
1019 (coex_dm
->pre_val0x6c4
== coex_dm
->cur_val0x6c4
) &&
1020 (coex_dm
->pre_val0x6c8
== coex_dm
->cur_val0x6c8
) &&
1021 (coex_dm
->pre_val0x6cc
== coex_dm
->cur_val0x6cc
))
1024 btc8723b2ant_set_coex_table(btcoexist
, val0x6c0
, val0x6c4
,
1025 val0x6c8
, val0x6cc
);
1027 coex_dm
->pre_val0x6c0
= coex_dm
->cur_val0x6c0
;
1028 coex_dm
->pre_val0x6c4
= coex_dm
->cur_val0x6c4
;
1029 coex_dm
->pre_val0x6c8
= coex_dm
->cur_val0x6c8
;
1030 coex_dm
->pre_val0x6cc
= coex_dm
->cur_val0x6cc
;
1033 static void btc8723b_coex_tbl_type(struct btc_coexist
*btcoexist
,
1034 bool force_exec
, u8 type
)
1038 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x55555555,
1039 0x55555555, 0xffff, 0x3);
1042 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x55555555,
1043 0x5afa5afa, 0xffff, 0x3);
1046 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x5a5a5a5a,
1047 0x5a5a5a5a, 0xffff, 0x3);
1050 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0xaaaaaaaa,
1051 0xaaaaaaaa, 0xffff, 0x3);
1054 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0xffffffff,
1055 0xffffffff, 0xffff, 0x3);
1058 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x5fff5fff,
1059 0x5fff5fff, 0xffff, 0x3);
1062 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x55ff55ff,
1063 0x5a5a5a5a, 0xffff, 0x3);
1066 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x55ff55ff,
1067 0x5afa5afa, 0xffff, 0x3);
1070 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x5aea5aea,
1071 0x5aea5aea, 0xffff, 0x3);
1074 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x55ff55ff,
1075 0x5aea5aea, 0xffff, 0x3);
1078 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x55ff55ff,
1079 0x5aff5aff, 0xffff, 0x3);
1082 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x55ff55ff,
1083 0x5a5f5a5f, 0xffff, 0x3);
1086 btc8723b2ant_coex_table(btcoexist
, force_exec
, 0x55ff55ff,
1087 0x5f5f5f5f, 0xffff, 0x3);
1094 static void btc8723b2ant_set_fw_ignore_wlan_act(struct btc_coexist
*btcoexist
,
1097 u8 h2c_parameter
[1] = {0};
1100 h2c_parameter
[0] |= BIT0
;/* function enable*/
1102 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_EXEC
,
1103 "[BTCoex], set FW for BT Ignore Wlan_Act, "
1104 "FW write 0x63=0x%x\n", h2c_parameter
[0]);
1106 btcoexist
->btc_fill_h2c(btcoexist
, 0x63, 1, h2c_parameter
);
1109 static void btc8723b2ant_ignore_wlan_act(struct btc_coexist
*btcoexist
,
1110 bool force_exec
, bool enable
)
1112 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW
,
1113 "[BTCoex], %s turn Ignore WlanAct %s\n",
1114 (force_exec
? "force to" : ""), (enable
? "ON" : "OFF"));
1115 coex_dm
->cur_ignore_wlan_act
= enable
;
1118 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
1119 "[BTCoex], bPreIgnoreWlanAct = %d, "
1120 "bCurIgnoreWlanAct = %d!!\n",
1121 coex_dm
->pre_ignore_wlan_act
,
1122 coex_dm
->cur_ignore_wlan_act
);
1124 if (coex_dm
->pre_ignore_wlan_act
==
1125 coex_dm
->cur_ignore_wlan_act
)
1128 btc8723b2ant_set_fw_ignore_wlan_act(btcoexist
, enable
);
1130 coex_dm
->pre_ignore_wlan_act
= coex_dm
->cur_ignore_wlan_act
;
1133 static void btc8723b2ant_set_fw_ps_tdma(struct btc_coexist
*btcoexist
, u8 byte1
,
1134 u8 byte2
, u8 byte3
, u8 byte4
, u8 byte5
)
1136 u8 h2c_parameter
[5];
1138 h2c_parameter
[0] = byte1
;
1139 h2c_parameter
[1] = byte2
;
1140 h2c_parameter
[2] = byte3
;
1141 h2c_parameter
[3] = byte4
;
1142 h2c_parameter
[4] = byte5
;
1144 coex_dm
->ps_tdma_para
[0] = byte1
;
1145 coex_dm
->ps_tdma_para
[1] = byte2
;
1146 coex_dm
->ps_tdma_para
[2] = byte3
;
1147 coex_dm
->ps_tdma_para
[3] = byte4
;
1148 coex_dm
->ps_tdma_para
[4] = byte5
;
1150 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_EXEC
,
1151 "[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n",
1153 h2c_parameter
[1] << 24 | h2c_parameter
[2] << 16 |
1154 h2c_parameter
[3] << 8 | h2c_parameter
[4]);
1156 btcoexist
->btc_fill_h2c(btcoexist
, 0x60, 5, h2c_parameter
);
1159 static void btc8723b2ant_sw_mechanism1(struct btc_coexist
*btcoexist
,
1160 bool shrink_rx_lpf
, bool low_penalty_ra
,
1161 bool limited_dig
, bool bt_lna_constrain
)
1163 btc8723b2ant_rf_shrink(btcoexist
, NORMAL_EXEC
, shrink_rx_lpf
);
1164 btc8723b2ant_low_penalty_ra(btcoexist
, NORMAL_EXEC
, low_penalty_ra
);
1167 static void btc8723b2ant_sw_mechanism2(struct btc_coexist
*btcoexist
,
1168 bool agc_table_shift
, bool adc_backoff
,
1169 bool sw_dac_swing
, u32 dac_swing_lvl
)
1171 btc8723b2ant_agc_table(btcoexist
, NORMAL_EXEC
, agc_table_shift
);
1172 btc8723b2ant_dac_swing(btcoexist
, NORMAL_EXEC
, sw_dac_swing
,
1176 static void btc8723b2ant_set_ant_path(struct btc_coexist
*btcoexist
,
1177 u8 antpos_type
, bool init_hwcfg
,
1180 struct btc_board_info
*board_info
= &btcoexist
->board_info
;
1181 u32 fw_ver
= 0, u32tmp
= 0;
1182 bool pg_ext_switch
= false;
1183 bool use_ext_switch
= false;
1184 u8 h2c_parameter
[2] = {0};
1186 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_EXT_SWITCH
, &pg_ext_switch
);
1187 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_FW_VER
, &fw_ver
);
1189 if ((fw_ver
< 0xc0000) || pg_ext_switch
)
1190 use_ext_switch
= true;
1193 /* 0x4c[23] = 0, 0x4c[24] = 1 Antenna control by WL/BT */
1194 u32tmp
= btcoexist
->btc_read_4byte(btcoexist
, 0x4c);
1197 btcoexist
->btc_write_4byte(btcoexist
, 0x4c, u32tmp
);
1199 btcoexist
->btc_write_1byte(btcoexist
, 0x974, 0xff);
1200 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x944, 0x3, 0x3);
1201 btcoexist
->btc_write_1byte(btcoexist
, 0x930, 0x77);
1202 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x67, 0x20, 0x1);
1204 /* Force GNT_BT to low */
1205 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x765, 0x18, 0x0);
1206 btcoexist
->btc_write_2byte(btcoexist
, 0x948, 0x0);
1208 if (board_info
->btdm_ant_pos
== BTC_ANTENNA_AT_MAIN_PORT
) {
1209 /* tell firmware "no antenna inverse" */
1210 h2c_parameter
[0] = 0;
1211 h2c_parameter
[1] = 1; /* ext switch type */
1212 btcoexist
->btc_fill_h2c(btcoexist
, 0x65, 2,
1215 /* tell firmware "antenna inverse" */
1216 h2c_parameter
[0] = 1;
1217 h2c_parameter
[1] = 1; /* ext switch type */
1218 btcoexist
->btc_fill_h2c(btcoexist
, 0x65, 2,
1223 /* ext switch setting */
1224 if (use_ext_switch
) {
1225 /* fixed internal switch S1->WiFi, S0->BT */
1226 btcoexist
->btc_write_2byte(btcoexist
, 0x948, 0x0);
1227 switch (antpos_type
) {
1228 case BTC_ANT_WIFI_AT_MAIN
:
1229 /* ext switch main at wifi */
1230 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x92c,
1233 case BTC_ANT_WIFI_AT_AUX
:
1234 /* ext switch aux at wifi */
1235 btcoexist
->btc_write_1byte_bitmask(btcoexist
,
1239 } else { /* internal switch */
1240 /* fixed ext switch */
1241 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x92c, 0x3, 0x1);
1242 switch (antpos_type
) {
1243 case BTC_ANT_WIFI_AT_MAIN
:
1244 /* fixed internal switch S1->WiFi, S0->BT */
1245 btcoexist
->btc_write_2byte(btcoexist
, 0x948, 0x0);
1247 case BTC_ANT_WIFI_AT_AUX
:
1248 /* fixed internal switch S0->WiFi, S1->BT */
1249 btcoexist
->btc_write_2byte(btcoexist
, 0x948, 0x280);
1255 static void btc8723b2ant_ps_tdma(struct btc_coexist
*btcoexist
, bool force_exec
,
1256 bool turn_on
, u8 type
)
1258 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW
,
1259 "[BTCoex], %s turn %s PS TDMA, type=%d\n",
1260 (force_exec
? "force to" : ""),
1261 (turn_on
? "ON" : "OFF"), type
);
1262 coex_dm
->cur_ps_tdma_on
= turn_on
;
1263 coex_dm
->cur_ps_tdma
= type
;
1266 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
1267 "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
1268 coex_dm
->pre_ps_tdma_on
, coex_dm
->cur_ps_tdma_on
);
1269 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
1270 "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
1271 coex_dm
->pre_ps_tdma
, coex_dm
->cur_ps_tdma
);
1273 if ((coex_dm
->pre_ps_tdma_on
== coex_dm
->cur_ps_tdma_on
) &&
1274 (coex_dm
->pre_ps_tdma
== coex_dm
->cur_ps_tdma
))
1281 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1285 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x12,
1289 /* This call breaks BT when wireless is active -
1290 * comment it out for now until a better fix is found:
1291 * btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c,
1296 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x10,
1300 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1304 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x12,
1308 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1c,
1312 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xa3, 0x10,
1316 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1320 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x12,
1324 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0xa,
1328 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x5,
1332 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1336 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x12,
1340 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0xa,
1344 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x5,
1348 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xa3, 0x2f,
1352 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x5,
1356 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x25,
1360 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x25,
1364 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x15,
1368 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0xe3, 0x1a,
1373 /* disable PS tdma */
1376 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0x0, 0x0, 0x0,
1380 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0x0, 0x0, 0x0,
1384 btc8723b2ant_set_fw_ps_tdma(btcoexist
, 0x0, 0x0, 0x0,
1390 /* update pre state */
1391 coex_dm
->pre_ps_tdma_on
= coex_dm
->cur_ps_tdma_on
;
1392 coex_dm
->pre_ps_tdma
= coex_dm
->cur_ps_tdma
;
1395 static void btc8723b2ant_coex_alloff(struct btc_coexist
*btcoexist
)
1398 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1399 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1400 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
1403 btc8723b2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1404 btc8723b2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1407 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
1408 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 0);
1411 static void btc8723b2ant_init_coex_dm(struct btc_coexist
*btcoexist
)
1413 /* force to reset coex mechanism*/
1415 btc8723b2ant_ps_tdma(btcoexist
, FORCE_EXEC
, false, 1);
1416 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, FORCE_EXEC
, 6);
1417 btc8723b2ant_dec_bt_pwr(btcoexist
, FORCE_EXEC
, false);
1419 btc8723b2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1420 btc8723b2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1423 static void btc8723b2ant_action_bt_inquiry(struct btc_coexist
*btcoexist
)
1425 bool wifi_connected
= false;
1426 bool low_pwr_disable
= true;
1428 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_DISABLE_LOW_POWER
,
1430 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
1433 if (wifi_connected
) {
1434 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 7);
1435 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 3);
1437 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 0);
1438 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1440 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, FORCE_EXEC
, 6);
1441 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
1443 btc8723b2ant_sw_mechanism1(btcoexist
, false, false, false, false);
1444 btc8723b2ant_sw_mechanism2(btcoexist
, false, false, false, 0x18);
1446 coex_dm
->need_recover_0x948
= true;
1447 coex_dm
->backup_0x948
= btcoexist
->btc_read_2byte(btcoexist
, 0x948);
1449 btc8723b2ant_set_ant_path(btcoexist
, BTC_ANT_WIFI_AT_AUX
,
1453 static bool btc8723b2ant_is_common_action(struct btc_coexist
*btcoexist
)
1455 bool common
= false, wifi_connected
= false;
1456 bool wifi_busy
= false;
1457 bool bt_hs_on
= false, low_pwr_disable
= false;
1459 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
1460 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
1462 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
1464 if (!wifi_connected
) {
1465 low_pwr_disable
= false;
1466 btcoexist
->btc_set(btcoexist
, BTC_SET_ACT_DISABLE_LOW_POWER
,
1469 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
1470 "[BTCoex], Wifi non-connected idle!!\n");
1472 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff,
1474 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 0);
1475 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1476 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
1477 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
1479 btc8723b2ant_sw_mechanism1(btcoexist
, false, false, false,
1481 btc8723b2ant_sw_mechanism2(btcoexist
, false, false, false,
1486 if (BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE
==
1487 coex_dm
->bt_status
) {
1488 low_pwr_disable
= false;
1489 btcoexist
->btc_set(btcoexist
,
1490 BTC_SET_ACT_DISABLE_LOW_POWER
,
1493 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
1494 "[BTCoex], Wifi connected + "
1495 "BT non connected-idle!!\n");
1497 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1,
1499 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 0);
1500 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1501 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
,
1503 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
,
1506 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
1508 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
1512 } else if (BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE
==
1513 coex_dm
->bt_status
) {
1514 low_pwr_disable
= true;
1515 btcoexist
->btc_set(btcoexist
,
1516 BTC_SET_ACT_DISABLE_LOW_POWER
,
1521 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
1522 "[BTCoex], Wifi connected + "
1523 "BT connected-idle!!\n");
1525 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1,
1527 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 0);
1528 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
1529 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
,
1531 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
,
1534 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
1536 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
1541 low_pwr_disable
= true;
1542 btcoexist
->btc_set(btcoexist
,
1543 BTC_SET_ACT_DISABLE_LOW_POWER
,
1547 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
1548 "[BTCoex], Wifi Connected-Busy + "
1555 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
1556 "[BTCoex], Wifi Connected-Idle + "
1559 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
,
1561 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
,
1563 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1565 btc8723b2ant_fw_dac_swing_lvl(btcoexist
,
1568 if (btc8723b_need_dec_pwr(btcoexist
))
1569 btc8723b2ant_dec_bt_pwr(btcoexist
,
1573 btc8723b2ant_dec_bt_pwr(btcoexist
,
1576 btc8723b2ant_sw_mechanism1(btcoexist
, false,
1579 btc8723b2ant_sw_mechanism2(btcoexist
, false,
1590 static void set_tdma_int1(struct btc_coexist
*btcoexist
, bool tx_pause
,
1593 /* Set PS TDMA for max interval == 1 */
1595 BTC_PRINT(BTC_MSG_ALGORITHM
,
1596 ALGO_TRACE_FW_DETAIL
,
1597 "[BTCoex], TxPause = 1\n");
1599 if (coex_dm
->cur_ps_tdma
== 71) {
1600 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1602 coex_dm
->tdma_adj_type
= 5;
1603 } else if (coex_dm
->cur_ps_tdma
== 1) {
1604 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1606 coex_dm
->tdma_adj_type
= 5;
1607 } else if (coex_dm
->cur_ps_tdma
== 2) {
1608 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1610 coex_dm
->tdma_adj_type
= 6;
1611 } else if (coex_dm
->cur_ps_tdma
== 3) {
1612 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1614 coex_dm
->tdma_adj_type
= 7;
1615 } else if (coex_dm
->cur_ps_tdma
== 4) {
1616 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1618 coex_dm
->tdma_adj_type
= 8;
1621 if (coex_dm
->cur_ps_tdma
== 9) {
1622 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1624 coex_dm
->tdma_adj_type
= 13;
1625 } else if (coex_dm
->cur_ps_tdma
== 10) {
1626 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1628 coex_dm
->tdma_adj_type
= 14;
1629 } else if (coex_dm
->cur_ps_tdma
== 11) {
1630 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1632 coex_dm
->tdma_adj_type
= 15;
1633 } else if (coex_dm
->cur_ps_tdma
== 12) {
1634 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1636 coex_dm
->tdma_adj_type
= 16;
1640 if (coex_dm
->cur_ps_tdma
== 5) {
1641 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1643 coex_dm
->tdma_adj_type
= 6;
1644 } else if (coex_dm
->cur_ps_tdma
== 6) {
1645 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1647 coex_dm
->tdma_adj_type
= 7;
1648 } else if (coex_dm
->cur_ps_tdma
== 7) {
1649 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1651 coex_dm
->tdma_adj_type
= 8;
1652 } else if (coex_dm
->cur_ps_tdma
== 13) {
1653 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1655 coex_dm
->tdma_adj_type
= 14;
1656 } else if (coex_dm
->cur_ps_tdma
== 14) {
1657 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1659 coex_dm
->tdma_adj_type
= 15;
1660 } else if (coex_dm
->cur_ps_tdma
== 15) {
1661 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1663 coex_dm
->tdma_adj_type
= 16;
1665 } else if (result
== 1) {
1666 if (coex_dm
->cur_ps_tdma
== 8) {
1667 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1669 coex_dm
->tdma_adj_type
= 7;
1670 } else if (coex_dm
->cur_ps_tdma
== 7) {
1671 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1673 coex_dm
->tdma_adj_type
= 6;
1674 } else if (coex_dm
->cur_ps_tdma
== 6) {
1675 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1677 coex_dm
->tdma_adj_type
= 5;
1678 } else if (coex_dm
->cur_ps_tdma
== 16) {
1679 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1681 coex_dm
->tdma_adj_type
= 15;
1682 } else if (coex_dm
->cur_ps_tdma
== 15) {
1683 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1685 coex_dm
->tdma_adj_type
= 14;
1686 } else if (coex_dm
->cur_ps_tdma
== 14) {
1687 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1689 coex_dm
->tdma_adj_type
= 13;
1693 BTC_PRINT(BTC_MSG_ALGORITHM
,
1694 ALGO_TRACE_FW_DETAIL
,
1695 "[BTCoex], TxPause = 0\n");
1696 if (coex_dm
->cur_ps_tdma
== 5) {
1697 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 71);
1698 coex_dm
->tdma_adj_type
= 71;
1699 } else if (coex_dm
->cur_ps_tdma
== 6) {
1700 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 2);
1701 coex_dm
->tdma_adj_type
= 2;
1702 } else if (coex_dm
->cur_ps_tdma
== 7) {
1703 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 3);
1704 coex_dm
->tdma_adj_type
= 3;
1705 } else if (coex_dm
->cur_ps_tdma
== 8) {
1706 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 4);
1707 coex_dm
->tdma_adj_type
= 4;
1710 if (coex_dm
->cur_ps_tdma
== 13) {
1711 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 9);
1712 coex_dm
->tdma_adj_type
= 9;
1713 } else if (coex_dm
->cur_ps_tdma
== 14) {
1714 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 10);
1715 coex_dm
->tdma_adj_type
= 10;
1716 } else if (coex_dm
->cur_ps_tdma
== 15) {
1717 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 11);
1718 coex_dm
->tdma_adj_type
= 11;
1719 } else if (coex_dm
->cur_ps_tdma
== 16) {
1720 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 12);
1721 coex_dm
->tdma_adj_type
= 12;
1725 if (coex_dm
->cur_ps_tdma
== 71) {
1726 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1728 coex_dm
->tdma_adj_type
= 1;
1729 } else if (coex_dm
->cur_ps_tdma
== 1) {
1730 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1732 coex_dm
->tdma_adj_type
= 2;
1733 } else if (coex_dm
->cur_ps_tdma
== 2) {
1734 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1736 coex_dm
->tdma_adj_type
= 3;
1737 } else if (coex_dm
->cur_ps_tdma
== 3) {
1738 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1740 coex_dm
->tdma_adj_type
= 4;
1741 } else if (coex_dm
->cur_ps_tdma
== 9) {
1742 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1744 coex_dm
->tdma_adj_type
= 10;
1745 } else if (coex_dm
->cur_ps_tdma
== 10) {
1746 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1748 coex_dm
->tdma_adj_type
= 11;
1749 } else if (coex_dm
->cur_ps_tdma
== 11) {
1750 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1752 coex_dm
->tdma_adj_type
= 12;
1754 } else if (result
== 1) {
1755 if (coex_dm
->cur_ps_tdma
== 4) {
1756 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1758 coex_dm
->tdma_adj_type
= 3;
1759 } else if (coex_dm
->cur_ps_tdma
== 3) {
1760 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1762 coex_dm
->tdma_adj_type
= 2;
1763 } else if (coex_dm
->cur_ps_tdma
== 2) {
1764 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1766 coex_dm
->tdma_adj_type
= 1;
1767 } else if (coex_dm
->cur_ps_tdma
== 1) {
1768 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1770 coex_dm
->tdma_adj_type
= 71;
1771 } else if (coex_dm
->cur_ps_tdma
== 12) {
1772 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1774 coex_dm
->tdma_adj_type
= 11;
1775 } else if (coex_dm
->cur_ps_tdma
== 11) {
1776 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1778 coex_dm
->tdma_adj_type
= 10;
1779 } else if (coex_dm
->cur_ps_tdma
== 10) {
1780 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1782 coex_dm
->tdma_adj_type
= 9;
1788 static void set_tdma_int2(struct btc_coexist
*btcoexist
, bool tx_pause
,
1791 /* Set PS TDMA for max interval == 2 */
1793 BTC_PRINT(BTC_MSG_ALGORITHM
,
1794 ALGO_TRACE_FW_DETAIL
,
1795 "[BTCoex], TxPause = 1\n");
1796 if (coex_dm
->cur_ps_tdma
== 1) {
1797 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 6);
1798 coex_dm
->tdma_adj_type
= 6;
1799 } else if (coex_dm
->cur_ps_tdma
== 2) {
1800 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 6);
1801 coex_dm
->tdma_adj_type
= 6;
1802 } else if (coex_dm
->cur_ps_tdma
== 3) {
1803 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 7);
1804 coex_dm
->tdma_adj_type
= 7;
1805 } else if (coex_dm
->cur_ps_tdma
== 4) {
1806 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 8);
1807 coex_dm
->tdma_adj_type
= 8;
1809 if (coex_dm
->cur_ps_tdma
== 9) {
1810 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 14);
1811 coex_dm
->tdma_adj_type
= 14;
1812 } else if (coex_dm
->cur_ps_tdma
== 10) {
1813 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 14);
1814 coex_dm
->tdma_adj_type
= 14;
1815 } else if (coex_dm
->cur_ps_tdma
== 11) {
1816 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 15);
1817 coex_dm
->tdma_adj_type
= 15;
1818 } else if (coex_dm
->cur_ps_tdma
== 12) {
1819 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 16);
1820 coex_dm
->tdma_adj_type
= 16;
1823 if (coex_dm
->cur_ps_tdma
== 5) {
1824 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1826 coex_dm
->tdma_adj_type
= 6;
1827 } else if (coex_dm
->cur_ps_tdma
== 6) {
1828 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1830 coex_dm
->tdma_adj_type
= 7;
1831 } else if (coex_dm
->cur_ps_tdma
== 7) {
1832 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1834 coex_dm
->tdma_adj_type
= 8;
1835 } else if (coex_dm
->cur_ps_tdma
== 13) {
1836 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1838 coex_dm
->tdma_adj_type
= 14;
1839 } else if (coex_dm
->cur_ps_tdma
== 14) {
1840 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1842 coex_dm
->tdma_adj_type
= 15;
1843 } else if (coex_dm
->cur_ps_tdma
== 15) {
1844 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1846 coex_dm
->tdma_adj_type
= 16;
1848 } else if (result
== 1) {
1849 if (coex_dm
->cur_ps_tdma
== 8) {
1850 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1852 coex_dm
->tdma_adj_type
= 7;
1853 } else if (coex_dm
->cur_ps_tdma
== 7) {
1854 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1856 coex_dm
->tdma_adj_type
= 6;
1857 } else if (coex_dm
->cur_ps_tdma
== 6) {
1858 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1860 coex_dm
->tdma_adj_type
= 6;
1861 } else if (coex_dm
->cur_ps_tdma
== 16) {
1862 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1864 coex_dm
->tdma_adj_type
= 15;
1865 } else if (coex_dm
->cur_ps_tdma
== 15) {
1866 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1868 coex_dm
->tdma_adj_type
= 14;
1869 } else if (coex_dm
->cur_ps_tdma
== 14) {
1870 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1872 coex_dm
->tdma_adj_type
= 14;
1876 BTC_PRINT(BTC_MSG_ALGORITHM
,
1877 ALGO_TRACE_FW_DETAIL
,
1878 "[BTCoex], TxPause = 0\n");
1879 if (coex_dm
->cur_ps_tdma
== 5) {
1880 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 2);
1881 coex_dm
->tdma_adj_type
= 2;
1882 } else if (coex_dm
->cur_ps_tdma
== 6) {
1883 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 2);
1884 coex_dm
->tdma_adj_type
= 2;
1885 } else if (coex_dm
->cur_ps_tdma
== 7) {
1886 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 3);
1887 coex_dm
->tdma_adj_type
= 3;
1888 } else if (coex_dm
->cur_ps_tdma
== 8) {
1889 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 4);
1890 coex_dm
->tdma_adj_type
= 4;
1892 if (coex_dm
->cur_ps_tdma
== 13) {
1893 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 10);
1894 coex_dm
->tdma_adj_type
= 10;
1895 } else if (coex_dm
->cur_ps_tdma
== 14) {
1896 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 10);
1897 coex_dm
->tdma_adj_type
= 10;
1898 } else if (coex_dm
->cur_ps_tdma
== 15) {
1899 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 11);
1900 coex_dm
->tdma_adj_type
= 11;
1901 } else if (coex_dm
->cur_ps_tdma
== 16) {
1902 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 12);
1903 coex_dm
->tdma_adj_type
= 12;
1906 if (coex_dm
->cur_ps_tdma
== 1) {
1907 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1909 coex_dm
->tdma_adj_type
= 2;
1910 } else if (coex_dm
->cur_ps_tdma
== 2) {
1911 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1913 coex_dm
->tdma_adj_type
= 3;
1914 } else if (coex_dm
->cur_ps_tdma
== 3) {
1915 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1917 coex_dm
->tdma_adj_type
= 4;
1918 } else if (coex_dm
->cur_ps_tdma
== 9) {
1919 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1921 coex_dm
->tdma_adj_type
= 10;
1922 } else if (coex_dm
->cur_ps_tdma
== 10) {
1923 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1925 coex_dm
->tdma_adj_type
= 11;
1926 } else if (coex_dm
->cur_ps_tdma
== 11) {
1927 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1929 coex_dm
->tdma_adj_type
= 12;
1931 } else if (result
== 1) {
1932 if (coex_dm
->cur_ps_tdma
== 4) {
1933 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1935 coex_dm
->tdma_adj_type
= 3;
1936 } else if (coex_dm
->cur_ps_tdma
== 3) {
1937 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1939 coex_dm
->tdma_adj_type
= 2;
1940 } else if (coex_dm
->cur_ps_tdma
== 2) {
1941 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1943 coex_dm
->tdma_adj_type
= 2;
1944 } else if (coex_dm
->cur_ps_tdma
== 12) {
1945 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1947 coex_dm
->tdma_adj_type
= 11;
1948 } else if (coex_dm
->cur_ps_tdma
== 11) {
1949 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1951 coex_dm
->tdma_adj_type
= 10;
1952 } else if (coex_dm
->cur_ps_tdma
== 10) {
1953 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1955 coex_dm
->tdma_adj_type
= 10;
1961 static void set_tdma_int3(struct btc_coexist
*btcoexist
, bool tx_pause
,
1964 /* Set PS TDMA for max interval == 3 */
1966 BTC_PRINT(BTC_MSG_ALGORITHM
,
1967 ALGO_TRACE_FW_DETAIL
,
1968 "[BTCoex], TxPause = 1\n");
1969 if (coex_dm
->cur_ps_tdma
== 1) {
1970 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 7);
1971 coex_dm
->tdma_adj_type
= 7;
1972 } else if (coex_dm
->cur_ps_tdma
== 2) {
1973 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 7);
1974 coex_dm
->tdma_adj_type
= 7;
1975 } else if (coex_dm
->cur_ps_tdma
== 3) {
1976 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 7);
1977 coex_dm
->tdma_adj_type
= 7;
1978 } else if (coex_dm
->cur_ps_tdma
== 4) {
1979 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 8);
1980 coex_dm
->tdma_adj_type
= 8;
1982 if (coex_dm
->cur_ps_tdma
== 9) {
1983 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 15);
1984 coex_dm
->tdma_adj_type
= 15;
1985 } else if (coex_dm
->cur_ps_tdma
== 10) {
1986 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 15);
1987 coex_dm
->tdma_adj_type
= 15;
1988 } else if (coex_dm
->cur_ps_tdma
== 11) {
1989 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 15);
1990 coex_dm
->tdma_adj_type
= 15;
1991 } else if (coex_dm
->cur_ps_tdma
== 12) {
1992 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 16);
1993 coex_dm
->tdma_adj_type
= 16;
1996 if (coex_dm
->cur_ps_tdma
== 5) {
1997 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
1999 coex_dm
->tdma_adj_type
= 7;
2000 } else if (coex_dm
->cur_ps_tdma
== 6) {
2001 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2003 coex_dm
->tdma_adj_type
= 7;
2004 } else if (coex_dm
->cur_ps_tdma
== 7) {
2005 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2007 coex_dm
->tdma_adj_type
= 8;
2008 } else if (coex_dm
->cur_ps_tdma
== 13) {
2009 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2011 coex_dm
->tdma_adj_type
= 15;
2012 } else if (coex_dm
->cur_ps_tdma
== 14) {
2013 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2015 coex_dm
->tdma_adj_type
= 15;
2016 } else if (coex_dm
->cur_ps_tdma
== 15) {
2017 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2019 coex_dm
->tdma_adj_type
= 16;
2021 } else if (result
== 1) {
2022 if (coex_dm
->cur_ps_tdma
== 8) {
2023 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2025 coex_dm
->tdma_adj_type
= 7;
2026 } else if (coex_dm
->cur_ps_tdma
== 7) {
2027 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2029 coex_dm
->tdma_adj_type
= 7;
2030 } else if (coex_dm
->cur_ps_tdma
== 6) {
2031 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2033 coex_dm
->tdma_adj_type
= 7;
2034 } else if (coex_dm
->cur_ps_tdma
== 16) {
2035 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2037 coex_dm
->tdma_adj_type
= 15;
2038 } else if (coex_dm
->cur_ps_tdma
== 15) {
2039 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2041 coex_dm
->tdma_adj_type
= 15;
2042 } else if (coex_dm
->cur_ps_tdma
== 14) {
2043 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2045 coex_dm
->tdma_adj_type
= 15;
2049 BTC_PRINT(BTC_MSG_ALGORITHM
,
2050 ALGO_TRACE_FW_DETAIL
,
2051 "[BTCoex], TxPause = 0\n");
2052 if (coex_dm
->cur_ps_tdma
== 5) {
2053 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 3);
2054 coex_dm
->tdma_adj_type
= 3;
2055 } else if (coex_dm
->cur_ps_tdma
== 6) {
2056 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 3);
2057 coex_dm
->tdma_adj_type
= 3;
2058 } else if (coex_dm
->cur_ps_tdma
== 7) {
2059 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 3);
2060 coex_dm
->tdma_adj_type
= 3;
2061 } else if (coex_dm
->cur_ps_tdma
== 8) {
2062 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 4);
2063 coex_dm
->tdma_adj_type
= 4;
2065 if (coex_dm
->cur_ps_tdma
== 13) {
2066 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 11);
2067 coex_dm
->tdma_adj_type
= 11;
2068 } else if (coex_dm
->cur_ps_tdma
== 14) {
2069 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 11);
2070 coex_dm
->tdma_adj_type
= 11;
2071 } else if (coex_dm
->cur_ps_tdma
== 15) {
2072 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 11);
2073 coex_dm
->tdma_adj_type
= 11;
2074 } else if (coex_dm
->cur_ps_tdma
== 16) {
2075 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 12);
2076 coex_dm
->tdma_adj_type
= 12;
2079 if (coex_dm
->cur_ps_tdma
== 1) {
2080 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2082 coex_dm
->tdma_adj_type
= 3;
2083 } else if (coex_dm
->cur_ps_tdma
== 2) {
2084 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2086 coex_dm
->tdma_adj_type
= 3;
2087 } else if (coex_dm
->cur_ps_tdma
== 3) {
2088 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2090 coex_dm
->tdma_adj_type
= 4;
2091 } else if (coex_dm
->cur_ps_tdma
== 9) {
2092 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2094 coex_dm
->tdma_adj_type
= 11;
2095 } else if (coex_dm
->cur_ps_tdma
== 10) {
2096 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2098 coex_dm
->tdma_adj_type
= 11;
2099 } else if (coex_dm
->cur_ps_tdma
== 11) {
2100 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2102 coex_dm
->tdma_adj_type
= 12;
2104 } else if (result
== 1) {
2105 if (coex_dm
->cur_ps_tdma
== 4) {
2106 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2108 coex_dm
->tdma_adj_type
= 3;
2109 } else if (coex_dm
->cur_ps_tdma
== 3) {
2110 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2112 coex_dm
->tdma_adj_type
= 3;
2113 } else if (coex_dm
->cur_ps_tdma
== 2) {
2114 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2116 coex_dm
->tdma_adj_type
= 3;
2117 } else if (coex_dm
->cur_ps_tdma
== 12) {
2118 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2120 coex_dm
->tdma_adj_type
= 11;
2121 } else if (coex_dm
->cur_ps_tdma
== 11) {
2122 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2124 coex_dm
->tdma_adj_type
= 11;
2125 } else if (coex_dm
->cur_ps_tdma
== 10) {
2126 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
,
2128 coex_dm
->tdma_adj_type
= 11;
2134 static void btc8723b2ant_tdma_duration_adjust(struct btc_coexist
*btcoexist
,
2135 bool sco_hid
, bool tx_pause
,
2138 static s32 up
, dn
, m
, n
, wait_count
;
2139 /*0: no change, +1: increase WiFi duration, -1: decrease WiFi duration*/
2143 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW
,
2144 "[BTCoex], TdmaDurationAdjust()\n");
2146 if (!coex_dm
->auto_tdma_adjust
) {
2147 coex_dm
->auto_tdma_adjust
= true;
2148 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
2149 "[BTCoex], first run TdmaDurationAdjust()!!\n");
2152 if (max_interval
== 1) {
2153 btc8723b2ant_ps_tdma(btcoexist
,
2156 coex_dm
->tdma_adj_type
= 13;
2157 } else if (max_interval
== 2) {
2158 btc8723b2ant_ps_tdma(btcoexist
,
2161 coex_dm
->tdma_adj_type
= 14;
2162 } else if (max_interval
== 3) {
2163 btc8723b2ant_ps_tdma(btcoexist
,
2166 coex_dm
->tdma_adj_type
= 15;
2168 btc8723b2ant_ps_tdma(btcoexist
,
2171 coex_dm
->tdma_adj_type
= 15;
2174 if (max_interval
== 1) {
2175 btc8723b2ant_ps_tdma(btcoexist
,
2178 coex_dm
->tdma_adj_type
= 9;
2179 } else if (max_interval
== 2) {
2180 btc8723b2ant_ps_tdma(btcoexist
,
2183 coex_dm
->tdma_adj_type
= 10;
2184 } else if (max_interval
== 3) {
2185 btc8723b2ant_ps_tdma(btcoexist
,
2188 coex_dm
->tdma_adj_type
= 11;
2190 btc8723b2ant_ps_tdma(btcoexist
,
2193 coex_dm
->tdma_adj_type
= 11;
2198 if (max_interval
== 1) {
2199 btc8723b2ant_ps_tdma(btcoexist
,
2202 coex_dm
->tdma_adj_type
= 5;
2203 } else if (max_interval
== 2) {
2204 btc8723b2ant_ps_tdma(btcoexist
,
2207 coex_dm
->tdma_adj_type
= 6;
2208 } else if (max_interval
== 3) {
2209 btc8723b2ant_ps_tdma(btcoexist
,
2212 coex_dm
->tdma_adj_type
= 7;
2214 btc8723b2ant_ps_tdma(btcoexist
,
2217 coex_dm
->tdma_adj_type
= 7;
2220 if (max_interval
== 1) {
2221 btc8723b2ant_ps_tdma(btcoexist
,
2224 coex_dm
->tdma_adj_type
= 1;
2225 } else if (max_interval
== 2) {
2226 btc8723b2ant_ps_tdma(btcoexist
,
2229 coex_dm
->tdma_adj_type
= 2;
2230 } else if (max_interval
== 3) {
2231 btc8723b2ant_ps_tdma(btcoexist
,
2234 coex_dm
->tdma_adj_type
= 3;
2236 btc8723b2ant_ps_tdma(btcoexist
,
2239 coex_dm
->tdma_adj_type
= 3;
2251 /*accquire the BT TRx retry count from BT_Info byte2*/
2252 retry_count
= coex_sta
->bt_retry_cnt
;
2253 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
2254 "[BTCoex], retry_count = %d\n", retry_count
);
2255 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
2256 "[BTCoex], up=%d, dn=%d, m=%d, n=%d, wait_count=%d\n",
2257 up
, dn
, m
, n
, wait_count
);
2260 /* no retry in the last 2-second duration*/
2261 if (retry_count
== 0) {
2274 BTC_PRINT(BTC_MSG_ALGORITHM
,
2275 ALGO_TRACE_FW_DETAIL
,
2276 "[BTCoex], Increase wifi "
2278 } /* <=3 retry in the last 2-second duration*/
2279 } else if (retry_count
<= 3) {
2287 if (wait_count
<= 2)
2300 BTC_PRINT(BTC_MSG_ALGORITHM
,
2301 ALGO_TRACE_FW_DETAIL
,
2302 "[BTCoex], Decrease wifi duration "
2303 "for retry_counter<3!!\n");
2306 if (wait_count
== 1)
2319 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
2320 "[BTCoex], Decrease wifi duration "
2321 "for retry_counter>3!!\n");
2324 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
2325 "[BTCoex], max Interval = %d\n", max_interval
);
2326 if (max_interval
== 1)
2327 set_tdma_int1(btcoexist
, tx_pause
, result
);
2328 else if (max_interval
== 2)
2329 set_tdma_int2(btcoexist
, tx_pause
, result
);
2330 else if (max_interval
== 3)
2331 set_tdma_int3(btcoexist
, tx_pause
, result
);
2334 /*if current PsTdma not match with the recorded one (when scan, dhcp..),
2335 *then we have to adjust it back to the previous recorded one.
2337 if (coex_dm
->cur_ps_tdma
!= coex_dm
->tdma_adj_type
) {
2338 bool scan
= false, link
= false, roam
= false;
2339 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
2340 "[BTCoex], PsTdma type dismatch!!!, "
2341 "curPsTdma=%d, recordPsTdma=%d\n",
2342 coex_dm
->cur_ps_tdma
, coex_dm
->tdma_adj_type
);
2344 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_SCAN
, &scan
);
2345 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_LINK
, &link
);
2346 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_ROAM
, &roam
);
2348 if (!scan
&& !link
&& !roam
)
2349 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true,
2350 coex_dm
->tdma_adj_type
);
2352 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_DETAIL
,
2353 "[BTCoex], roaming/link/scan is under"
2354 " progress, will adjust next time!!!\n");
2358 /* SCO only or SCO+PAN(HS) */
2359 static void btc8723b2ant_action_sco(struct btc_coexist
*btcoexist
)
2364 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2367 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2369 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 4);
2371 if (btc8723b_need_dec_pwr(btcoexist
))
2372 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2374 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2376 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2378 /*for SCO quality at 11b/g mode*/
2379 if (BTC_WIFI_BW_LEGACY
== wifi_bw
)
2380 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 2);
2381 else /*for SCO quality & wifi performance balance at 11n mode*/
2382 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 8);
2384 /*for voice quality */
2385 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 0);
2388 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2389 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2390 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2391 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2393 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2396 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2398 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2402 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2403 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2404 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2406 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2409 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2411 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2417 static void btc8723b2ant_action_hid(struct btc_coexist
*btcoexist
)
2419 u8 wifi_rssi_state
, bt_rssi_state
;
2422 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2424 bt_rssi_state
= btc8723b2ant_bt_rssi_state(2, 29, 0);
2426 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2428 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2430 if (btc8723b_need_dec_pwr(btcoexist
))
2431 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2433 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2435 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2437 if (BTC_WIFI_BW_LEGACY
== wifi_bw
) /*/for HID at 11b/g mode*/
2438 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 7);
2439 else /*for HID quality & wifi performance balance at 11n mode*/
2440 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 9);
2442 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2443 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
))
2444 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 9);
2446 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 13);
2449 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2450 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2451 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2452 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2454 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2457 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2459 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2463 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2464 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2465 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2467 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2470 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2472 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2478 /*A2DP only / PAN(EDR) only/ A2DP+PAN(HS)*/
2479 static void btc8723b2ant_action_a2dp(struct btc_coexist
*btcoexist
)
2481 u8 wifi_rssi_state
, wifi_rssi_state1
, bt_rssi_state
;
2485 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2487 wifi_rssi_state1
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2489 bt_rssi_state
= btc8723b2ant_bt_rssi_state(2, 29, 0);
2491 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_AP_NUM
, &ap_num
);
2493 /* define the office environment */
2494 /* driver don't know AP num in Linux, so we will never enter this if */
2495 if (ap_num
>= 10 && BTC_RSSI_HIGH(wifi_rssi_state1
)) {
2496 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff,
2498 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2499 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2500 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 0);
2501 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
2504 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2505 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2506 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2508 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2511 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2513 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2519 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2521 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2523 if (btc8723b_need_dec_pwr(btcoexist
))
2524 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2526 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2528 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 7);
2530 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2531 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
))
2532 btc8723b2ant_tdma_duration_adjust(btcoexist
, false,
2535 btc8723b2ant_tdma_duration_adjust(btcoexist
, false, true, 1);
2538 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2539 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2540 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2541 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2542 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2544 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2547 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2549 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2553 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2554 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2555 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2557 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2560 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2562 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2568 static void btc8723b2ant_action_a2dp_pan_hs(struct btc_coexist
*btcoexist
)
2573 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2576 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2578 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2580 if (btc8723b_need_dec_pwr(btcoexist
))
2581 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2583 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2585 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 7);
2587 btc8723b2ant_tdma_duration_adjust(btcoexist
, false, true, 2);
2590 btcoexist
->btc_get(btcoexist
,
2591 BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2592 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2593 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2594 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2595 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2597 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2600 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2602 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2606 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2607 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2608 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2610 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2613 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2615 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2621 static void btc8723b2ant_action_pan_edr(struct btc_coexist
*btcoexist
)
2623 u8 wifi_rssi_state
, bt_rssi_state
;
2626 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2628 bt_rssi_state
= btc8723b2ant_bt_rssi_state(2, 29, 0);
2630 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2632 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2634 if (btc8723b_need_dec_pwr(btcoexist
))
2635 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2637 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2639 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 10);
2641 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2642 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
))
2643 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 1);
2645 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, true, 5);
2648 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2649 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2650 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2651 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2652 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2654 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2657 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2659 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2663 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2664 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2665 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2667 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2670 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2672 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2679 static void btc8723b2ant_action_pan_hs(struct btc_coexist
*btcoexist
)
2684 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2687 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2689 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2691 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2692 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
))
2693 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2695 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2697 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 7);
2699 btc8723b2ant_ps_tdma(btcoexist
, NORMAL_EXEC
, false, 1);
2701 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2702 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2703 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2704 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2705 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2707 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2710 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2712 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2716 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2717 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2718 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2720 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2723 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2725 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2732 static void btc8723b2ant_action_pan_edr_a2dp(struct btc_coexist
*btcoexist
)
2734 u8 wifi_rssi_state
, bt_rssi_state
;
2737 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2739 bt_rssi_state
= btc8723b2ant_bt_rssi_state(2, 29, 0);
2741 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2743 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2745 if (btc8723b_need_dec_pwr(btcoexist
))
2746 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2748 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2750 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2752 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2753 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2754 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 12);
2755 if (BTC_WIFI_BW_HT40
== wifi_bw
)
2756 btc8723b2ant_tdma_duration_adjust(btcoexist
, false,
2759 btc8723b2ant_tdma_duration_adjust(btcoexist
, false,
2762 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 7);
2763 btc8723b2ant_tdma_duration_adjust(btcoexist
, false, true, 3);
2767 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2768 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2769 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2770 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2772 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2775 btc8723b2ant_sw_mechanism1(btcoexist
, true, false,
2777 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2781 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2782 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2783 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2785 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2788 btc8723b2ant_sw_mechanism1(btcoexist
, false, false,
2790 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2796 static void btc8723b2ant_action_pan_edr_hid(struct btc_coexist
*btcoexist
)
2798 u8 wifi_rssi_state
, bt_rssi_state
;
2801 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2803 bt_rssi_state
= btc8723b2ant_bt_rssi_state(2, 29, 0);
2804 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2806 if (btc8723b_need_dec_pwr(btcoexist
))
2807 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2809 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2811 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2812 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2813 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2814 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
,
2816 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 11);
2817 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1,
2820 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
,
2822 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 7);
2823 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1,
2826 btc8723b2ant_tdma_duration_adjust(btcoexist
, true, false, 2);
2828 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2829 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 11);
2830 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff,
2832 btc8723b2ant_tdma_duration_adjust(btcoexist
, true, true, 2);
2836 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2837 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2838 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2839 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2841 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2844 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2846 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2850 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2851 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2852 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2854 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2857 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2859 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2865 /* HID+A2DP+PAN(EDR) */
2866 static void btc8723b2ant_action_hid_a2dp_pan_edr(struct btc_coexist
*btcoexist
)
2868 u8 wifi_rssi_state
, bt_rssi_state
;
2871 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2873 bt_rssi_state
= btc8723b2ant_bt_rssi_state(2, 29, 0);
2875 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2877 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2879 if (btc8723b_need_dec_pwr(btcoexist
))
2880 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2882 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2884 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2886 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 7);
2888 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2889 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2890 if (BTC_WIFI_BW_HT40
== wifi_bw
)
2891 btc8723b2ant_tdma_duration_adjust(btcoexist
, true,
2894 btc8723b2ant_tdma_duration_adjust(btcoexist
, true,
2897 btc8723b2ant_tdma_duration_adjust(btcoexist
, true, true, 3);
2901 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2902 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2903 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2904 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2906 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2909 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2911 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2915 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2916 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2917 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2919 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2922 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2924 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2930 static void btc8723b2ant_action_hid_a2dp(struct btc_coexist
*btcoexist
)
2932 u8 wifi_rssi_state
, bt_rssi_state
;
2935 wifi_rssi_state
= btc8723b2ant_wifi_rssi_state(btcoexist
,
2937 bt_rssi_state
= btc8723b2ant_bt_rssi_state(2, 29, 0);
2939 btcoexist
->btc_set_rf_reg(btcoexist
, BTC_RF_A
, 0x1, 0xfffff, 0x0);
2941 btc8723b2ant_fw_dac_swing_lvl(btcoexist
, NORMAL_EXEC
, 6);
2943 if (btc8723b_need_dec_pwr(btcoexist
))
2944 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, true);
2946 btc8723b2ant_dec_bt_pwr(btcoexist
, NORMAL_EXEC
, false);
2948 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
2950 btc8723b_coex_tbl_type(btcoexist
, NORMAL_EXEC
, 7);
2952 if ((bt_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2953 (bt_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
))
2954 btc8723b2ant_tdma_duration_adjust(btcoexist
, true, false, 2);
2956 btc8723b2ant_tdma_duration_adjust(btcoexist
, true, true, 2);
2959 if (BTC_WIFI_BW_HT40
== wifi_bw
) {
2960 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2961 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2962 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2964 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2967 btc8723b2ant_sw_mechanism1(btcoexist
, true, true,
2969 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2973 if ((wifi_rssi_state
== BTC_RSSI_STATE_HIGH
) ||
2974 (wifi_rssi_state
== BTC_RSSI_STATE_STAY_HIGH
)) {
2975 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2977 btc8723b2ant_sw_mechanism2(btcoexist
, true, false,
2980 btc8723b2ant_sw_mechanism1(btcoexist
, false, true,
2982 btc8723b2ant_sw_mechanism2(btcoexist
, false, false,
2988 static void btc8723b2ant_run_coexist_mechanism(struct btc_coexist
*btcoexist
)
2992 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
2993 "[BTCoex], RunCoexistMechanism()===>\n");
2995 if (btcoexist
->manual_control
) {
2996 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
2997 "[BTCoex], RunCoexistMechanism(), "
2998 "return for Manual CTRL <===\n");
3002 if (coex_sta
->under_ips
) {
3003 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3004 "[BTCoex], wifi is under IPS !!!\n");
3008 algorithm
= btc8723b2ant_action_algorithm(btcoexist
);
3009 if (coex_sta
->c2h_bt_inquiry_page
&&
3010 (BT_8723B_2ANT_COEX_ALGO_PANHS
!= algorithm
)) {
3011 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3012 "[BTCoex], BT is under inquiry/page scan !!\n");
3013 btc8723b2ant_action_bt_inquiry(btcoexist
);
3016 if (coex_dm
->need_recover_0x948
) {
3017 coex_dm
->need_recover_0x948
= false;
3018 btcoexist
->btc_write_2byte(btcoexist
, 0x948,
3019 coex_dm
->backup_0x948
);
3023 coex_dm
->cur_algorithm
= algorithm
;
3024 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
, "[BTCoex], Algorithm = %d\n",
3025 coex_dm
->cur_algorithm
);
3027 if (btc8723b2ant_is_common_action(btcoexist
)) {
3028 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3029 "[BTCoex], Action 2-Ant common.\n");
3030 coex_dm
->auto_tdma_adjust
= false;
3032 if (coex_dm
->cur_algorithm
!= coex_dm
->pre_algorithm
) {
3033 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3034 "[BTCoex], preAlgorithm=%d, "
3035 "curAlgorithm=%d\n", coex_dm
->pre_algorithm
,
3036 coex_dm
->cur_algorithm
);
3037 coex_dm
->auto_tdma_adjust
= false;
3039 switch (coex_dm
->cur_algorithm
) {
3040 case BT_8723B_2ANT_COEX_ALGO_SCO
:
3041 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3042 "[BTCoex], Action 2-Ant, algorithm = SCO.\n");
3043 btc8723b2ant_action_sco(btcoexist
);
3045 case BT_8723B_2ANT_COEX_ALGO_HID
:
3046 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3047 "[BTCoex], Action 2-Ant, algorithm = HID.\n");
3048 btc8723b2ant_action_hid(btcoexist
);
3050 case BT_8723B_2ANT_COEX_ALGO_A2DP
:
3051 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3052 "[BTCoex], Action 2-Ant, "
3053 "algorithm = A2DP.\n");
3054 btc8723b2ant_action_a2dp(btcoexist
);
3056 case BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS
:
3057 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3058 "[BTCoex], Action 2-Ant, "
3059 "algorithm = A2DP+PAN(HS).\n");
3060 btc8723b2ant_action_a2dp_pan_hs(btcoexist
);
3062 case BT_8723B_2ANT_COEX_ALGO_PANEDR
:
3063 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3064 "[BTCoex], Action 2-Ant, "
3065 "algorithm = PAN(EDR).\n");
3066 btc8723b2ant_action_pan_edr(btcoexist
);
3068 case BT_8723B_2ANT_COEX_ALGO_PANHS
:
3069 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3070 "[BTCoex], Action 2-Ant, "
3071 "algorithm = HS mode.\n");
3072 btc8723b2ant_action_pan_hs(btcoexist
);
3074 case BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP
:
3075 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3076 "[BTCoex], Action 2-Ant, "
3077 "algorithm = PAN+A2DP.\n");
3078 btc8723b2ant_action_pan_edr_a2dp(btcoexist
);
3080 case BT_8723B_2ANT_COEX_ALGO_PANEDR_HID
:
3081 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3082 "[BTCoex], Action 2-Ant, "
3083 "algorithm = PAN(EDR)+HID.\n");
3084 btc8723b2ant_action_pan_edr_hid(btcoexist
);
3086 case BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR
:
3087 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3088 "[BTCoex], Action 2-Ant, "
3089 "algorithm = HID+A2DP+PAN.\n");
3090 btc8723b2ant_action_hid_a2dp_pan_edr(btcoexist
);
3092 case BT_8723B_2ANT_COEX_ALGO_HID_A2DP
:
3093 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3094 "[BTCoex], Action 2-Ant, "
3095 "algorithm = HID+A2DP.\n");
3096 btc8723b2ant_action_hid_a2dp(btcoexist
);
3099 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3100 "[BTCoex], Action 2-Ant, "
3101 "algorithm = coexist All Off!!\n");
3102 btc8723b2ant_coex_alloff(btcoexist
);
3105 coex_dm
->pre_algorithm
= coex_dm
->cur_algorithm
;
3109 static void btc8723b2ant_wifioff_hwcfg(struct btc_coexist
*btcoexist
)
3111 /* set wlan_act to low */
3112 btcoexist
->btc_write_1byte(btcoexist
, 0x76e, 0x4);
3113 /* Force GNT_BT to High */
3114 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x765, 0x18, 0x3);
3115 /* BT select s0/s1 is controlled by BT */
3116 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x67, 0x20, 0x0);
3119 /*********************************************************************
3120 * work around function start with wa_btc8723b2ant_
3121 *********************************************************************/
3122 /*********************************************************************
3123 * extern function start with EXbtc8723b2ant_
3124 *********************************************************************/
3125 void ex_btc8723b2ant_init_hwconfig(struct btc_coexist
*btcoexist
)
3129 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_INIT
,
3130 "[BTCoex], 2Ant Init HW Config!!\n");
3131 coex_dm
->bt_rf0x1e_backup
=
3132 btcoexist
->btc_get_rf_reg(btcoexist
, BTC_RF_A
, 0x1e, 0xfffff);
3134 /* 0x790[5:0] = 0x5 */
3135 u8tmp
= btcoexist
->btc_read_1byte(btcoexist
, 0x790);
3138 btcoexist
->btc_write_1byte(btcoexist
, 0x790, u8tmp
);
3141 btc8723b2ant_set_ant_path(btcoexist
, BTC_ANT_WIFI_AT_MAIN
,
3144 btc8723b_coex_tbl_type(btcoexist
, FORCE_EXEC
, 0);
3146 /* Enable counter statistics */
3147 /*0x76e[3] =1, WLAN_Act control by PTA*/
3148 btcoexist
->btc_write_1byte(btcoexist
, 0x76e, 0xc);
3149 btcoexist
->btc_write_1byte(btcoexist
, 0x778, 0x3);
3150 btcoexist
->btc_write_1byte_bitmask(btcoexist
, 0x40, 0x20, 0x1);
3153 void ex_btc8723b2ant_init_coex_dm(struct btc_coexist
*btcoexist
)
3155 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_INIT
,
3156 "[BTCoex], Coex Mechanism Init!!\n");
3157 btc8723b2ant_init_coex_dm(btcoexist
);
3160 void ex_btc8723b2ant_display_coex_info(struct btc_coexist
*btcoexist
)
3162 struct btc_board_info
*board_info
= &btcoexist
->board_info
;
3163 struct btc_stack_info
*stack_info
= &btcoexist
->stack_info
;
3164 struct btc_bt_link_info
*bt_link_info
= &btcoexist
->bt_link_info
;
3165 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
3166 u8 u8tmp
[4], i
, bt_info_ext
, ps_tdma_case
= 0;
3168 bool roam
= false, scan
= false;
3169 bool link
= false, wifi_under_5g
= false;
3170 bool bt_hs_on
= false, wifi_busy
= false;
3171 s32 wifi_rssi
= 0, bt_hs_rssi
= 0;
3172 u32 wifi_bw
, wifi_traffic_dir
, fa_ofdm
, fa_cck
;
3173 u8 wifi_dot11_chnl
, wifi_hs_chnl
;
3174 u32 fw_ver
= 0, bt_patch_ver
= 0;
3177 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
3178 "\r\n ============[BT Coexist info]============");
3180 if (btcoexist
->manual_control
) {
3181 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
3182 "\r\n ==========[Under Manual Control]============");
3183 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
3184 "\r\n ==========================================");
3187 if (!board_info
->bt_exist
) {
3188 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n BT not exists !!!");
3192 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d/ %d ",
3193 "Ant PG number/ Ant mechanism:",
3194 board_info
->pg_ant_num
, board_info
->btdm_ant_num
);
3196 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %s / %d",
3197 "BT stack/ hci ext ver",
3198 ((stack_info
->profile_notified
) ? "Yes" : "No"),
3199 stack_info
->hci_version
);
3201 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_BT_PATCH_VER
, &bt_patch_ver
);
3202 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_FW_VER
, &fw_ver
);
3203 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
3204 "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)",
3205 "CoexVer/ FwVer/ PatchVer",
3206 glcoex_ver_date_8723b_2ant
, glcoex_ver_8723b_2ant
,
3207 fw_ver
, bt_patch_ver
, bt_patch_ver
);
3209 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
3210 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_WIFI_DOT11_CHNL
,
3212 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_WIFI_HS_CHNL
, &wifi_hs_chnl
);
3214 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d / %d(%d)",
3215 "Dot11 channel / HsChnl(HsMode)",
3216 wifi_dot11_chnl
, wifi_hs_chnl
, bt_hs_on
);
3218 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %3ph ",
3219 "H2C Wifi inform bt chnl Info", coex_dm
->wifi_chnl_info
);
3221 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_WIFI_RSSI
, &wifi_rssi
);
3222 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_HS_RSSI
, &bt_hs_rssi
);
3223 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_AP_NUM
, &ap_num
);
3224 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d/ %d/ %d",
3225 "Wifi rssi/ HS rssi/ AP#", wifi_rssi
, bt_hs_rssi
, ap_num
);
3227 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_SCAN
, &scan
);
3228 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_LINK
, &link
);
3229 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_ROAM
, &roam
);
3230 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d/ %d/ %d ",
3231 "Wifi link/ roam/ scan", link
, roam
, scan
);
3233 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_UNDER_5G
, &wifi_under_5g
);
3234 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
3235 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
3236 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION
,
3238 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %s / %s/ %s ",
3239 "Wifi status", (wifi_under_5g
? "5G" : "2.4G"),
3240 ((BTC_WIFI_BW_LEGACY
== wifi_bw
) ? "Legacy" :
3241 (((BTC_WIFI_BW_HT40
== wifi_bw
) ? "HT40" : "HT20"))),
3242 ((!wifi_busy
) ? "idle" :
3243 ((BTC_WIFI_TRAFFIC_TX
== wifi_traffic_dir
) ?
3244 "uplink" : "downlink")));
3247 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d / %d / %d / %d",
3249 bt_link_info
->sco_exist
, bt_link_info
->hid_exist
,
3250 bt_link_info
->pan_exist
, bt_link_info
->a2dp_exist
);
3251 btcoexist
->btc_disp_dbg_msg(btcoexist
, BTC_DBG_DISP_BT_LINK_INFO
);
3253 bt_info_ext
= coex_sta
->bt_info_ext
;
3254 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %s",
3255 "BT Info A2DP rate",
3256 (bt_info_ext
&BIT0
) ? "Basic rate" : "EDR rate");
3258 for (i
= 0; i
< BT_INFO_SRC_8723B_2ANT_MAX
; i
++) {
3259 if (coex_sta
->bt_info_c2h_cnt
[i
]) {
3260 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
3261 "\r\n %-35s = %7ph(%d)",
3262 glbt_info_src_8723b_2ant
[i
],
3263 coex_sta
->bt_info_c2h
[i
],
3264 coex_sta
->bt_info_c2h_cnt
[i
]);
3268 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %s/%s",
3269 "PS state, IPS/LPS",
3270 ((coex_sta
->under_ips
? "IPS ON" : "IPS OFF")),
3271 ((coex_sta
->under_lps
? "LPS ON" : "LPS OFF")));
3272 btcoexist
->btc_disp_dbg_msg(btcoexist
, BTC_DBG_DISP_FW_PWR_MODE_CMD
);
3275 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
3276 "\r\n %-35s", "============[Sw mechanism]============");
3277 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d/ %d/ %d ",
3278 "SM1[ShRf/ LpRA/ LimDig]", coex_dm
->cur_rf_rx_lpf_shrink
,
3279 coex_dm
->cur_low_penalty_ra
, coex_dm
->limited_dig
);
3280 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d/ %d/ %d(0x%x) ",
3281 "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]",
3282 coex_dm
->cur_agc_table_en
, coex_dm
->cur_adc_back_off
,
3283 coex_dm
->cur_dac_swing_on
, coex_dm
->cur_dac_swing_lvl
);
3286 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s",
3287 "============[Fw mechanism]============");
3289 ps_tdma_case
= coex_dm
->cur_ps_tdma
;
3290 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
3291 "\r\n %-35s = %5ph case-%d (auto:%d)",
3292 "PS TDMA", coex_dm
->ps_tdma_para
,
3293 ps_tdma_case
, coex_dm
->auto_tdma_adjust
);
3295 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d/ %d ",
3296 "DecBtPwr/ IgnWlanAct", coex_dm
->cur_dec_bt_pwr
,
3297 coex_dm
->cur_ignore_wlan_act
);
3300 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s",
3301 "============[Hw setting]============");
3303 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = 0x%x",
3304 "RF-A, 0x1e initVal", coex_dm
->bt_rf0x1e_backup
);
3306 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x778);
3307 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x880);
3308 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = 0x%x/ 0x%x",
3309 "0x778/0x880[29:25]", u8tmp
[0],
3310 (u32tmp
[0]&0x3e000000) >> 25);
3312 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x948);
3313 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x67);
3314 u8tmp
[1] = btcoexist
->btc_read_1byte(btcoexist
, 0x765);
3315 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
3316 "0x948/ 0x67[5] / 0x765",
3317 u32tmp
[0], ((u8tmp
[0]&0x20) >> 5), u8tmp
[1]);
3319 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x92c);
3320 u32tmp
[1] = btcoexist
->btc_read_4byte(btcoexist
, 0x930);
3321 u32tmp
[2] = btcoexist
->btc_read_4byte(btcoexist
, 0x944);
3322 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
3323 "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]",
3324 u32tmp
[0]&0x3, u32tmp
[1]&0xff, u32tmp
[2]&0x3);
3326 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x39);
3327 u8tmp
[1] = btcoexist
->btc_read_1byte(btcoexist
, 0x40);
3328 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x4c);
3329 u8tmp
[2] = btcoexist
->btc_read_1byte(btcoexist
, 0x64);
3330 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
3331 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
3332 "0x38[11]/0x40/0x4c[24:23]/0x64[0]",
3333 ((u8tmp
[0] & 0x8)>>3), u8tmp
[1],
3334 ((u32tmp
[0]&0x01800000)>>23), u8tmp
[2]&0x1);
3336 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x550);
3337 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x522);
3338 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = 0x%x/ 0x%x",
3339 "0x550(bcn ctrl)/0x522", u32tmp
[0], u8tmp
[0]);
3341 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0xc50);
3342 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x49c);
3343 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = 0x%x/ 0x%x",
3344 "0xc50(dig)/0x49c(null-drop)", u32tmp
[0]&0xff, u8tmp
[0]);
3346 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0xda0);
3347 u32tmp
[1] = btcoexist
->btc_read_4byte(btcoexist
, 0xda4);
3348 u32tmp
[2] = btcoexist
->btc_read_4byte(btcoexist
, 0xda8);
3349 u32tmp
[3] = btcoexist
->btc_read_4byte(btcoexist
, 0xcf0);
3351 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0xa5b);
3352 u8tmp
[1] = btcoexist
->btc_read_1byte(btcoexist
, 0xa5c);
3354 fa_ofdm
= ((u32tmp
[0]&0xffff0000) >> 16) +
3355 ((u32tmp
[1]&0xffff0000) >> 16) +
3356 (u32tmp
[1] & 0xffff) +
3357 (u32tmp
[2] & 0xffff) +
3358 ((u32tmp
[3]&0xffff0000) >> 16) +
3359 (u32tmp
[3] & 0xffff);
3360 fa_cck
= (u8tmp
[0] << 8) + u8tmp
[1];
3362 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
3363 "OFDM-CCA/OFDM-FA/CCK-FA",
3364 u32tmp
[0]&0xffff, fa_ofdm
, fa_cck
);
3366 u32tmp
[0] = btcoexist
->btc_read_4byte(btcoexist
, 0x6c0);
3367 u32tmp
[1] = btcoexist
->btc_read_4byte(btcoexist
, 0x6c4);
3368 u32tmp
[2] = btcoexist
->btc_read_4byte(btcoexist
, 0x6c8);
3369 u8tmp
[0] = btcoexist
->btc_read_1byte(btcoexist
, 0x6cc);
3370 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
3371 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
3372 "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)",
3373 u32tmp
[0], u32tmp
[1], u32tmp
[2], u8tmp
[0]);
3375 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d/ %d",
3376 "0x770(high-pri rx/tx)",
3377 coex_sta
->high_priority_rx
, coex_sta
->high_priority_tx
);
3378 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "\r\n %-35s = %d/ %d",
3379 "0x774(low-pri rx/tx)", coex_sta
->low_priority_rx
,
3380 coex_sta
->low_priority_tx
);
3381 #if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 1)
3382 btc8723b2ant_monitor_bt_ctr(btcoexist
);
3384 btcoexist
->btc_disp_dbg_msg(btcoexist
,
3385 BTC_DBG_DISP_COEX_STATISTICS
);
3388 void ex_btc8723b2ant_ips_notify(struct btc_coexist
*btcoexist
, u8 type
)
3390 if (BTC_IPS_ENTER
== type
) {
3391 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3392 "[BTCoex], IPS ENTER notify\n");
3393 coex_sta
->under_ips
= true;
3394 btc8723b2ant_wifioff_hwcfg(btcoexist
);
3395 btc8723b2ant_ignore_wlan_act(btcoexist
, FORCE_EXEC
, true);
3396 btc8723b2ant_coex_alloff(btcoexist
);
3397 } else if (BTC_IPS_LEAVE
== type
) {
3398 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3399 "[BTCoex], IPS LEAVE notify\n");
3400 coex_sta
->under_ips
= false;
3401 ex_btc8723b2ant_init_hwconfig(btcoexist
);
3402 btc8723b2ant_init_coex_dm(btcoexist
);
3403 btc8723b2ant_query_bt_info(btcoexist
);
3407 void ex_btc8723b2ant_lps_notify(struct btc_coexist
*btcoexist
, u8 type
)
3409 if (BTC_LPS_ENABLE
== type
) {
3410 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3411 "[BTCoex], LPS ENABLE notify\n");
3412 coex_sta
->under_lps
= true;
3413 } else if (BTC_LPS_DISABLE
== type
) {
3414 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3415 "[BTCoex], LPS DISABLE notify\n");
3416 coex_sta
->under_lps
= false;
3420 void ex_btc8723b2ant_scan_notify(struct btc_coexist
*btcoexist
, u8 type
)
3422 if (BTC_SCAN_START
== type
)
3423 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3424 "[BTCoex], SCAN START notify\n");
3425 else if (BTC_SCAN_FINISH
== type
)
3426 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3427 "[BTCoex], SCAN FINISH notify\n");
3430 void ex_btc8723b2ant_connect_notify(struct btc_coexist
*btcoexist
, u8 type
)
3432 if (BTC_ASSOCIATE_START
== type
)
3433 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3434 "[BTCoex], CONNECT START notify\n");
3435 else if (BTC_ASSOCIATE_FINISH
== type
)
3436 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3437 "[BTCoex], CONNECT FINISH notify\n");
3440 void ex_btc8723b2ant_media_status_notify(struct btc_coexist
*btcoexist
,
3443 u8 h2c_parameter
[3] = {0};
3445 u8 wifi_central_chnl
;
3447 if (BTC_MEDIA_CONNECT
== type
)
3448 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3449 "[BTCoex], MEDIA connect notify\n");
3451 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3452 "[BTCoex], MEDIA disconnect notify\n");
3454 /* only 2.4G we need to inform bt the chnl mask */
3455 btcoexist
->btc_get(btcoexist
,
3456 BTC_GET_U1_WIFI_CENTRAL_CHNL
, &wifi_central_chnl
);
3457 if ((BTC_MEDIA_CONNECT
== type
) &&
3458 (wifi_central_chnl
<= 14)) {
3459 h2c_parameter
[0] = 0x1;
3460 h2c_parameter
[1] = wifi_central_chnl
;
3461 btcoexist
->btc_get(btcoexist
,
3462 BTC_GET_U4_WIFI_BW
, &wifi_bw
);
3463 if (BTC_WIFI_BW_HT40
== wifi_bw
)
3464 h2c_parameter
[2] = 0x30;
3466 h2c_parameter
[2] = 0x20;
3469 coex_dm
->wifi_chnl_info
[0] = h2c_parameter
[0];
3470 coex_dm
->wifi_chnl_info
[1] = h2c_parameter
[1];
3471 coex_dm
->wifi_chnl_info
[2] = h2c_parameter
[2];
3473 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE_FW_EXEC
,
3474 "[BTCoex], FW write 0x66=0x%x\n",
3475 h2c_parameter
[0] << 16 | h2c_parameter
[1] << 8 |
3478 btcoexist
->btc_fill_h2c(btcoexist
, 0x66, 3, h2c_parameter
);
3481 void ex_btc8723b2ant_special_packet_notify(struct btc_coexist
*btcoexist
,
3484 if (type
== BTC_PACKET_DHCP
)
3485 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3486 "[BTCoex], DHCP Packet notify\n");
3489 void ex_btc8723b2ant_bt_info_notify(struct btc_coexist
*btcoexist
,
3490 u8
*tmpbuf
, u8 length
)
3493 u8 i
, rsp_source
= 0;
3494 bool bt_busy
= false, limited_dig
= false;
3495 bool wifi_connected
= false;
3497 coex_sta
->c2h_bt_info_req_sent
= false;
3499 rsp_source
= tmpbuf
[0]&0xf;
3500 if (rsp_source
>= BT_INFO_SRC_8723B_2ANT_MAX
)
3501 rsp_source
= BT_INFO_SRC_8723B_2ANT_WIFI_FW
;
3502 coex_sta
->bt_info_c2h_cnt
[rsp_source
]++;
3504 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3505 "[BTCoex], Bt info[%d], length=%d, hex data=[",
3506 rsp_source
, length
);
3507 for (i
= 0; i
< length
; i
++) {
3508 coex_sta
->bt_info_c2h
[rsp_source
][i
] = tmpbuf
[i
];
3510 bt_info
= tmpbuf
[i
];
3512 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3513 "0x%02x]\n", tmpbuf
[i
]);
3515 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
,
3516 "0x%02x, ", tmpbuf
[i
]);
3519 if (btcoexist
->manual_control
) {
3520 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3521 "[BTCoex], BtInfoNotify(), "
3522 "return for Manual CTRL<===\n");
3526 if (BT_INFO_SRC_8723B_2ANT_WIFI_FW
!= rsp_source
) {
3527 coex_sta
->bt_retry_cnt
= /* [3:0]*/
3528 coex_sta
->bt_info_c2h
[rsp_source
][2] & 0xf;
3531 coex_sta
->bt_info_c2h
[rsp_source
][3] * 2 + 10;
3533 coex_sta
->bt_info_ext
=
3534 coex_sta
->bt_info_c2h
[rsp_source
][4];
3536 /* Here we need to resend some wifi info to BT
3537 because bt is reset and loss of the info.
3539 if ((coex_sta
->bt_info_ext
& BIT1
)) {
3540 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3541 "[BTCoex], BT ext info bit1 check,"
3542 " send wifi BW&Chnl to BT!!\n");
3543 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_CONNECTED
,
3546 ex_btc8723b2ant_media_status_notify(
3550 ex_btc8723b2ant_media_status_notify(
3552 BTC_MEDIA_DISCONNECT
);
3555 if ((coex_sta
->bt_info_ext
& BIT3
)) {
3556 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3557 "[BTCoex], BT ext info bit3 check, "
3558 "set BT NOT to ignore Wlan active!!\n");
3559 btc8723b2ant_ignore_wlan_act(btcoexist
, FORCE_EXEC
,
3562 /* BT already NOT ignore Wlan active, do nothing here.*/
3564 #if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 0)
3565 if ((coex_sta
->bt_info_ext
& BIT4
)) {
3566 /* BT auto report already enabled, do nothing*/
3568 btc8723b2ant_bt_auto_report(btcoexist
, FORCE_EXEC
,
3574 /* check BIT2 first ==> check if bt is under inquiry or page scan*/
3575 if (bt_info
& BT_INFO_8723B_2ANT_B_INQ_PAGE
)
3576 coex_sta
->c2h_bt_inquiry_page
= true;
3578 coex_sta
->c2h_bt_inquiry_page
= false;
3580 /* set link exist status*/
3581 if (!(bt_info
& BT_INFO_8723B_2ANT_B_CONNECTION
)) {
3582 coex_sta
->bt_link_exist
= false;
3583 coex_sta
->pan_exist
= false;
3584 coex_sta
->a2dp_exist
= false;
3585 coex_sta
->hid_exist
= false;
3586 coex_sta
->sco_exist
= false;
3587 } else { /* connection exists */
3588 coex_sta
->bt_link_exist
= true;
3589 if (bt_info
& BT_INFO_8723B_2ANT_B_FTP
)
3590 coex_sta
->pan_exist
= true;
3592 coex_sta
->pan_exist
= false;
3593 if (bt_info
& BT_INFO_8723B_2ANT_B_A2DP
)
3594 coex_sta
->a2dp_exist
= true;
3596 coex_sta
->a2dp_exist
= false;
3597 if (bt_info
& BT_INFO_8723B_2ANT_B_HID
)
3598 coex_sta
->hid_exist
= true;
3600 coex_sta
->hid_exist
= false;
3601 if (bt_info
& BT_INFO_8723B_2ANT_B_SCO_ESCO
)
3602 coex_sta
->sco_exist
= true;
3604 coex_sta
->sco_exist
= false;
3607 btc8723b2ant_update_bt_link_info(btcoexist
);
3609 if (!(bt_info
& BT_INFO_8723B_2ANT_B_CONNECTION
)) {
3610 coex_dm
->bt_status
= BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE
;
3611 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3612 "[BTCoex], BtInfoNotify(), "
3613 "BT Non-Connected idle!!!\n");
3614 /* connection exists but no busy */
3615 } else if (bt_info
== BT_INFO_8723B_2ANT_B_CONNECTION
) {
3616 coex_dm
->bt_status
= BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE
;
3617 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3618 "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
3619 } else if ((bt_info
& BT_INFO_8723B_2ANT_B_SCO_ESCO
) ||
3620 (bt_info
& BT_INFO_8723B_2ANT_B_SCO_BUSY
)) {
3621 coex_dm
->bt_status
= BT_8723B_2ANT_BT_STATUS_SCO_BUSY
;
3622 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3623 "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n");
3624 } else if (bt_info
&BT_INFO_8723B_2ANT_B_ACL_BUSY
) {
3625 coex_dm
->bt_status
= BT_8723B_2ANT_BT_STATUS_ACL_BUSY
;
3626 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3627 "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n");
3629 coex_dm
->bt_status
= BT_8723B_2ANT_BT_STATUS_MAX
;
3630 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3631 "[BTCoex], BtInfoNotify(), "
3632 "BT Non-Defined state!!!\n");
3635 if ((BT_8723B_2ANT_BT_STATUS_ACL_BUSY
== coex_dm
->bt_status
) ||
3636 (BT_8723B_2ANT_BT_STATUS_SCO_BUSY
== coex_dm
->bt_status
) ||
3637 (BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY
== coex_dm
->bt_status
)) {
3642 limited_dig
= false;
3645 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_TRAFFIC_BUSY
, &bt_busy
);
3647 coex_dm
->limited_dig
= limited_dig
;
3648 btcoexist
->btc_set(btcoexist
, BTC_SET_BL_BT_LIMITED_DIG
, &limited_dig
);
3650 btc8723b2ant_run_coexist_mechanism(btcoexist
);
3653 void ex_btc8723b2ant_halt_notify(struct btc_coexist
*btcoexist
)
3655 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_NOTIFY
, "[BTCoex], Halt notify\n");
3657 btc8723b2ant_wifioff_hwcfg(btcoexist
);
3658 btc8723b2ant_ignore_wlan_act(btcoexist
, FORCE_EXEC
, true);
3659 ex_btc8723b2ant_media_status_notify(btcoexist
, BTC_MEDIA_DISCONNECT
);
3662 void ex_btc8723b2ant_periodical(struct btc_coexist
*btcoexist
)
3664 struct btc_board_info
*board_info
= &btcoexist
->board_info
;
3665 struct btc_stack_info
*stack_info
= &btcoexist
->stack_info
;
3666 static u8 dis_ver_info_cnt
;
3667 u32 fw_ver
= 0, bt_patch_ver
= 0;
3669 BTC_PRINT(BTC_MSG_ALGORITHM
, ALGO_TRACE
,
3670 "[BTCoex], =========================="
3671 "Periodical===========================\n");
3673 if (dis_ver_info_cnt
<= 5) {
3674 dis_ver_info_cnt
+= 1;
3675 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_INIT
,
3676 "[BTCoex], ****************************"
3677 "************************************\n");
3678 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_INIT
,
3679 "[BTCoex], Ant PG Num/ Ant Mech/ "
3680 "Ant Pos = %d/ %d/ %d\n", board_info
->pg_ant_num
,
3681 board_info
->btdm_ant_num
, board_info
->btdm_ant_pos
);
3682 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_INIT
,
3683 "[BTCoex], BT stack/ hci ext ver = %s / %d\n",
3684 ((stack_info
->profile_notified
) ? "Yes" : "No"),
3685 stack_info
->hci_version
);
3686 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_BT_PATCH_VER
,
3688 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_FW_VER
, &fw_ver
);
3689 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_INIT
,
3690 "[BTCoex], CoexVer/ fw_ver/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",
3691 glcoex_ver_date_8723b_2ant
, glcoex_ver_8723b_2ant
,
3692 fw_ver
, bt_patch_ver
, bt_patch_ver
);
3693 BTC_PRINT(BTC_MSG_INTERFACE
, INTF_INIT
,
3694 "[BTCoex], *****************************"
3695 "***********************************\n");
3698 #if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 0)
3699 btc8723b2ant_query_bt_info(btcoexist
);
3700 btc8723b2ant_monitor_bt_ctr(btcoexist
);
3701 btc8723b2ant_monitor_bt_enable_disable(btcoexist
);
3703 if (btc8723b2ant_is_wifi_status_changed(btcoexist
) ||
3704 coex_dm
->auto_tdma_adjust
)
3705 btc8723b2ant_run_coexist_mechanism(btcoexist
);