1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
4 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
8 #include "Mp_Precomp.h"
11 #define HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(val) \
13 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, val); \
14 pCoexDm->psTdmaDuAdjType = val; \
17 /* Global variables, these are static variables */
18 static struct coex_dm_8723b_2ant GLCoexDm8723b2Ant;
19 static struct coex_dm_8723b_2ant *pCoexDm = &GLCoexDm8723b2Ant;
20 static struct coex_sta_8723b_2ant GLCoexSta8723b2Ant;
21 static struct coex_sta_8723b_2ant *pCoexSta = &GLCoexSta8723b2Ant;
23 /* local function start with halbtc8723b2ant_ */
24 static u8 halbtc8723b2ant_BtRssiState(
25 u8 levelNum, u8 rssiThresh, u8 rssiThresh1
29 u8 btRssiState = pCoexSta->preBtRssiState;
31 btRssi = pCoexSta->btRssi;
35 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
36 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
38 if (btRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
39 btRssiState = BTC_RSSI_STATE_HIGH;
41 btRssiState = BTC_RSSI_STATE_STAY_LOW;
44 if (btRssi < rssiThresh) {
45 btRssiState = BTC_RSSI_STATE_LOW;
47 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
50 } else if (levelNum == 3) {
51 if (rssiThresh > rssiThresh1) {
52 return pCoexSta->preBtRssiState;
56 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
57 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
59 if (btRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
60 btRssiState = BTC_RSSI_STATE_MEDIUM;
62 btRssiState = BTC_RSSI_STATE_STAY_LOW;
65 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
66 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)
68 if (btRssi >= (rssiThresh1 + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
69 btRssiState = BTC_RSSI_STATE_HIGH;
70 } else if (btRssi < rssiThresh) {
71 btRssiState = BTC_RSSI_STATE_LOW;
73 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
76 if (btRssi < rssiThresh1) {
77 btRssiState = BTC_RSSI_STATE_MEDIUM;
79 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
84 pCoexSta->preBtRssiState = btRssiState;
89 static u8 halbtc8723b2ant_WifiRssiState(
90 struct btc_coexist *pBtCoexist,
98 u8 wifiRssiState = pCoexSta->preWifiRssiState[index];
100 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
104 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
105 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
107 if (wifiRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
108 wifiRssiState = BTC_RSSI_STATE_HIGH;
110 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
113 if (wifiRssi < rssiThresh) {
114 wifiRssiState = BTC_RSSI_STATE_LOW;
116 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
119 } else if (levelNum == 3) {
120 if (rssiThresh > rssiThresh1) {
121 return pCoexSta->preWifiRssiState[index];
125 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
126 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
128 if (wifiRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
129 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
131 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
134 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
135 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)
137 if (wifiRssi >= (rssiThresh1 + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
138 wifiRssiState = BTC_RSSI_STATE_HIGH;
139 } else if (wifiRssi < rssiThresh) {
140 wifiRssiState = BTC_RSSI_STATE_LOW;
142 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
145 if (wifiRssi < rssiThresh1) {
146 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
148 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
153 pCoexSta->preWifiRssiState[index] = wifiRssiState;
155 return wifiRssiState;
158 static void halbtc8723b2ant_LimitedRx(
159 struct btc_coexist *pBtCoexist,
162 bool bBtCtrlAggBufSize,
166 bool bRejectRxAgg = bRejApAggPkt;
167 bool bBtCtrlRxAggSize = bBtCtrlAggBufSize;
168 u8 rxAggSize = aggBufSize;
171 /* Rx Aggregation related setting */
173 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);
174 /* decide BT control aggregation buf size or not */
175 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);
176 /* aggregation buf size, only work when BT control Rx aggregation size. */
177 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
178 /* real update aggregation setting */
179 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
182 static void halbtc8723b2ant_QueryBtInfo(struct btc_coexist *pBtCoexist)
184 u8 H2C_Parameter[1] = {0};
186 pCoexSta->bC2hBtInfoReqSent = true;
188 H2C_Parameter[0] |= BIT0; /* trigger */
190 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
193 static bool halbtc8723b2ant_IsWifiStatusChanged(struct btc_coexist *pBtCoexist)
195 static bool bPreWifiBusy, bPreUnder4way, bPreBtHsOn;
196 bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false;
197 bool bWifiConnected = false;
199 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
200 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
201 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
202 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
204 if (bWifiConnected) {
205 if (bWifiBusy != bPreWifiBusy) {
206 bPreWifiBusy = bWifiBusy;
210 if (bUnder4way != bPreUnder4way) {
211 bPreUnder4way = bUnder4way;
215 if (bBtHsOn != bPreBtHsOn) {
216 bPreBtHsOn = bBtHsOn;
224 static void halbtc8723b2ant_UpdateBtLinkInfo(struct btc_coexist *pBtCoexist)
226 struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
227 bool bBtHsOn = false;
229 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
231 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
232 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
233 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
234 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
235 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
237 /* work around for HS mode. */
239 pBtLinkInfo->bPanExist = true;
240 pBtLinkInfo->bBtLinkExist = true;
243 /* check if Sco only */
245 pBtLinkInfo->bScoExist &&
246 !pBtLinkInfo->bA2dpExist &&
247 !pBtLinkInfo->bPanExist &&
248 !pBtLinkInfo->bHidExist
250 pBtLinkInfo->bScoOnly = true;
252 pBtLinkInfo->bScoOnly = false;
254 /* check if A2dp only */
256 !pBtLinkInfo->bScoExist &&
257 pBtLinkInfo->bA2dpExist &&
258 !pBtLinkInfo->bPanExist &&
259 !pBtLinkInfo->bHidExist
261 pBtLinkInfo->bA2dpOnly = true;
263 pBtLinkInfo->bA2dpOnly = false;
265 /* check if Pan only */
267 !pBtLinkInfo->bScoExist &&
268 !pBtLinkInfo->bA2dpExist &&
269 pBtLinkInfo->bPanExist &&
270 !pBtLinkInfo->bHidExist
272 pBtLinkInfo->bPanOnly = true;
274 pBtLinkInfo->bPanOnly = false;
276 /* check if Hid only */
278 !pBtLinkInfo->bScoExist &&
279 !pBtLinkInfo->bA2dpExist &&
280 !pBtLinkInfo->bPanExist &&
281 pBtLinkInfo->bHidExist
283 pBtLinkInfo->bHidOnly = true;
285 pBtLinkInfo->bHidOnly = false;
288 static u8 halbtc8723b2ant_ActionAlgorithm(struct btc_coexist *pBtCoexist)
290 struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
291 bool bBtHsOn = false;
292 u8 algorithm = BT_8723B_2ANT_COEX_ALGO_UNDEFINED;
293 u8 numOfDiffProfile = 0;
295 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
297 if (!pBtLinkInfo->bBtLinkExist) {
301 if (pBtLinkInfo->bScoExist)
304 if (pBtLinkInfo->bHidExist)
307 if (pBtLinkInfo->bPanExist)
310 if (pBtLinkInfo->bA2dpExist)
313 if (numOfDiffProfile == 1) {
314 if (pBtLinkInfo->bScoExist) {
315 algorithm = BT_8723B_2ANT_COEX_ALGO_SCO;
317 if (pBtLinkInfo->bHidExist) {
318 algorithm = BT_8723B_2ANT_COEX_ALGO_HID;
319 } else if (pBtLinkInfo->bA2dpExist) {
320 algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP;
321 } else if (pBtLinkInfo->bPanExist) {
323 algorithm = BT_8723B_2ANT_COEX_ALGO_PANHS;
325 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR;
329 } else if (numOfDiffProfile == 2) {
330 if (pBtLinkInfo->bScoExist) {
331 if (pBtLinkInfo->bHidExist) {
332 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
333 } else if (pBtLinkInfo->bA2dpExist) {
334 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
335 } else if (pBtLinkInfo->bPanExist) {
337 algorithm = BT_8723B_2ANT_COEX_ALGO_SCO;
339 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
344 pBtLinkInfo->bHidExist &&
345 pBtLinkInfo->bA2dpExist
347 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
349 pBtLinkInfo->bHidExist &&
350 pBtLinkInfo->bPanExist
353 algorithm = BT_8723B_2ANT_COEX_ALGO_HID;
355 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
358 pBtLinkInfo->bPanExist &&
359 pBtLinkInfo->bA2dpExist
362 algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS;
364 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP;
368 } else if (numOfDiffProfile == 3) {
369 if (pBtLinkInfo->bScoExist) {
371 pBtLinkInfo->bHidExist &&
372 pBtLinkInfo->bA2dpExist
374 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
376 pBtLinkInfo->bHidExist &&
377 pBtLinkInfo->bPanExist
379 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
381 pBtLinkInfo->bPanExist &&
382 pBtLinkInfo->bA2dpExist
384 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
388 pBtLinkInfo->bHidExist &&
389 pBtLinkInfo->bPanExist &&
390 pBtLinkInfo->bA2dpExist
393 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
395 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
399 } else if (numOfDiffProfile >= 3) {
400 if (pBtLinkInfo->bScoExist) {
402 pBtLinkInfo->bHidExist &&
403 pBtLinkInfo->bPanExist &&
404 pBtLinkInfo->bA2dpExist
408 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
417 static void halbtc8723b2ant_SetFwDacSwingLevel(
418 struct btc_coexist *pBtCoexist, u8 dacSwingLvl
421 u8 H2C_Parameter[1] = {0};
423 /* There are several type of dacswing */
424 /* 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */
425 H2C_Parameter[0] = dacSwingLvl;
427 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter);
430 static void halbtc8723b2ant_SetFwDecBtPwr(
431 struct btc_coexist *pBtCoexist, u8 decBtPwrLvl
434 u8 H2C_Parameter[1] = {0};
436 H2C_Parameter[0] = decBtPwrLvl;
438 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter);
441 static void halbtc8723b2ant_DecBtPwr(
442 struct btc_coexist *pBtCoexist, bool bForceExec, u8 decBtPwrLvl
445 pCoexDm->curBtDecPwrLvl = decBtPwrLvl;
448 if (pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl)
451 halbtc8723b2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
453 pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
456 static void halbtc8723b2ant_FwDacSwingLvl(
457 struct btc_coexist *pBtCoexist, bool bForceExec, u8 fwDacSwingLvl
460 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
463 if (pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
467 halbtc8723b2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
469 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
472 static void halbtc8723b2ant_SetSwRfRxLpfCorner(
473 struct btc_coexist *pBtCoexist,
478 /* Shrink RF Rx LPF corner */
479 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc);
481 /* Resume RF Rx LPF corner */
482 /* After initialized, we can use pCoexDm->btRf0x1eBackup */
483 if (pBtCoexist->bInitilized) {
484 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
489 static void halbtc8723b2ant_RfShrink(
490 struct btc_coexist *pBtCoexist, bool bForceExec, bool bRxRfShrinkOn
493 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
496 if (pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
499 halbtc8723b2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
501 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
504 static void halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(
505 struct btc_coexist *pBtCoexist, bool bLowPenaltyRa
508 u8 H2C_Parameter[6] = {0};
510 H2C_Parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */
513 H2C_Parameter[1] |= BIT0;
514 H2C_Parameter[2] = 0x00; /* normal rate except MCS7/6/5, OFDM54/48/36 */
515 H2C_Parameter[3] = 0xf7; /* MCS7 or OFDM54 */
516 H2C_Parameter[4] = 0xf8; /* MCS6 or OFDM48 */
517 H2C_Parameter[5] = 0xf9; /* MCS5 or OFDM36 */
520 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
523 static void halbtc8723b2ant_LowPenaltyRa(
524 struct btc_coexist *pBtCoexist, bool bForceExec, bool bLowPenaltyRa
528 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
531 if (pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
534 halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
536 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
539 static void halbtc8723b2ant_SetDacSwingReg(struct btc_coexist *pBtCoexist, u32 level)
543 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val);
546 static void halbtc8723b2ant_SetSwFullTimeDacSwing(
547 struct btc_coexist *pBtCoexist, bool bSwDacSwingOn, u32 swDacSwingLvl
551 halbtc8723b2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
553 halbtc8723b2ant_SetDacSwingReg(pBtCoexist, 0x18);
557 static void halbtc8723b2ant_DacSwing(
558 struct btc_coexist *pBtCoexist,
564 pCoexDm->bCurDacSwingOn = bDacSwingOn;
565 pCoexDm->curDacSwingLvl = dacSwingLvl;
568 if ((pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
569 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl))
573 halbtc8723b2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
575 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
576 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
579 static void halbtc8723b2ant_SetAgcTable(
580 struct btc_coexist *pBtCoexist, bool bAgcTableEn
583 u8 rssiAdjustVal = 0;
585 /* BB AGC Gain Table */
587 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e1A0001);
588 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d1B0001);
589 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6c1C0001);
590 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6b1D0001);
591 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1E0001);
592 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691F0001);
593 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68200001);
595 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001);
596 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001);
597 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001);
598 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001);
599 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001);
600 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001);
601 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa4200001);
606 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
608 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff);
609 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe);
611 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3);
612 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6);
614 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
616 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1);
618 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff);
619 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe);
621 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3);
622 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6);
624 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0);
626 /* set rssiAdjustVal for wifi module. */
630 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
633 static void halbtc8723b2ant_AgcTable(
634 struct btc_coexist *pBtCoexist, bool bForceExec, bool bAgcTableEn
637 pCoexDm->bCurAgcTableEn = bAgcTableEn;
640 if (pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
643 halbtc8723b2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
645 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
648 static void halbtc8723b2ant_SetCoexTable(
649 struct btc_coexist *pBtCoexist,
656 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
658 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
660 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
662 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
665 static void halbtc8723b2ant_CoexTable(
666 struct btc_coexist *pBtCoexist,
674 pCoexDm->curVal0x6c0 = val0x6c0;
675 pCoexDm->curVal0x6c4 = val0x6c4;
676 pCoexDm->curVal0x6c8 = val0x6c8;
677 pCoexDm->curVal0x6cc = val0x6cc;
681 (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
682 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
683 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
684 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc)
688 halbtc8723b2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
690 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
691 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
692 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
693 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
696 static void halbtc8723b2ant_CoexTableWithType(
697 struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
702 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffff, 0x3);
705 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
708 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3);
711 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff, 0x3);
714 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffff, 0x3);
717 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffff, 0x3);
720 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3);
723 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0xfafafafa, 0xffff, 0x3);
726 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3);
729 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aea5aea, 0xffff, 0x3);
732 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aff5aff, 0xffff, 0x3);
735 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5f5a5f, 0xffff, 0x3);
738 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5f5f5f5f, 0xffff, 0x3);
745 static void halbtc8723b2ant_SetFwIgnoreWlanAct(
746 struct btc_coexist *pBtCoexist, bool bEnable
749 u8 H2C_Parameter[1] = {0};
752 H2C_Parameter[0] |= BIT0; /* function enable */
754 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
757 static void halbtc8723b2ant_IgnoreWlanAct(
758 struct btc_coexist *pBtCoexist, bool bForceExec, bool bEnable
761 pCoexDm->bCurIgnoreWlanAct = bEnable;
764 if (pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
767 halbtc8723b2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
769 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
772 static void halbtc8723b2ant_SetFwPstdma(
773 struct btc_coexist *pBtCoexist,
781 u8 H2C_Parameter[5] = {0};
783 H2C_Parameter[0] = byte1;
784 H2C_Parameter[1] = byte2;
785 H2C_Parameter[2] = byte3;
786 H2C_Parameter[3] = byte4;
787 H2C_Parameter[4] = byte5;
789 pCoexDm->psTdmaPara[0] = byte1;
790 pCoexDm->psTdmaPara[1] = byte2;
791 pCoexDm->psTdmaPara[2] = byte3;
792 pCoexDm->psTdmaPara[3] = byte4;
793 pCoexDm->psTdmaPara[4] = byte5;
795 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
798 static void halbtc8723b2ant_SwMechanism1(
799 struct btc_coexist *pBtCoexist,
806 halbtc8723b2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);
807 halbtc8723b2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
810 static void halbtc8723b2ant_SwMechanism2(
811 struct btc_coexist *pBtCoexist,
818 halbtc8723b2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);
819 halbtc8723b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);
822 static void halbtc8723b2ant_SetAntPath(
823 struct btc_coexist *pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
826 struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
827 u32 fwVer = 0, u4Tmp = 0;
828 bool bPgExtSwitch = false;
829 bool bUseExtSwitch = false;
830 u8 H2C_Parameter[2] = {0};
832 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch);
833 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); /* [31:16]=fw ver, [15:0]=fw sub ver */
835 if ((fwVer > 0 && fwVer < 0xc0000) || bPgExtSwitch)
836 bUseExtSwitch = true;
839 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1);
840 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff);
841 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3);
842 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77);
843 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1);
845 if (fwVer >= 0x180000) {
846 /* Use H2C to set GNT_BT to LOW */
847 H2C_Parameter[0] = 0;
848 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
850 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0);
853 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
855 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); /* WiFi TRx Mask off */
856 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); /* BT TRx Mask off */
858 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) {
859 /* tell firmware "no antenna inverse" */
860 H2C_Parameter[0] = 0;
862 /* tell firmware "antenna inverse" */
863 H2C_Parameter[0] = 1;
867 /* ext switch type */
868 H2C_Parameter[1] = 1;
870 /* int switch type */
871 H2C_Parameter[1] = 0;
873 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
876 /* ext switch setting */
879 /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */
880 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
883 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
886 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */
887 switch (antPosType) {
888 case BTC_ANT_WIFI_AT_MAIN:
889 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); /* ext switch main at wifi */
891 case BTC_ANT_WIFI_AT_AUX:
892 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); /* ext switch aux at wifi */
895 } else { /* internal switch */
897 /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */
898 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
901 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
904 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); /* fixed external switch S1->Main, S0->Aux */
905 switch (antPosType) {
906 case BTC_ANT_WIFI_AT_MAIN:
907 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */
909 case BTC_ANT_WIFI_AT_AUX:
910 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); /* fixed internal switch S0->WiFi, S1->BT */
916 static void halbtc8723b2ant_PsTdma(
917 struct btc_coexist *pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
920 pCoexDm->bCurPsTdmaOn = bTurnOn;
921 pCoexDm->curPsTdma = type;
925 (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
926 (pCoexDm->prePsTdma == pCoexDm->curPsTdma)
935 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
938 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
941 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);
944 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90);
947 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
950 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
953 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);
956 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90);
959 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
962 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
965 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90);
968 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
971 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
974 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
977 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90);
980 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90);
983 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90);
986 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
989 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90);
992 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90);
995 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);
998 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1002 /* disable PS tdma */
1005 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
1008 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0);
1011 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
1016 /* update pre state */
1017 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1018 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1021 static void halbtc8723b2ant_CoexAllOff(struct btc_coexist *pBtCoexist)
1024 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1025 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1026 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1029 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1030 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1033 /* pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); */
1034 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1037 static void halbtc8723b2ant_InitCoexDm(struct btc_coexist *pBtCoexist)
1039 /* force to reset coex mechanism */
1041 halbtc8723b2ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 1);
1042 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
1043 halbtc8723b2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
1045 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1046 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1049 static void halbtc8723b2ant_ActionBtInquiry(struct btc_coexist *pBtCoexist)
1051 bool bWifiConnected = false;
1052 bool bLowPwrDisable = true;
1054 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1055 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1057 if (bWifiConnected) {
1058 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1059 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1061 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1062 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1065 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
1066 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1068 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1069 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1071 pCoexDm->bNeedRecover0x948 = true;
1072 pCoexDm->backup0x948 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
1074 halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, false, false);
1077 static bool halbtc8723b2ant_IsCommonAction(struct btc_coexist *pBtCoexist)
1079 u8 btRssiState = BTC_RSSI_STATE_HIGH;
1080 bool bCommon = false, bWifiConnected = false, bWifiBusy = false;
1081 bool bBtHsOn = false, bLowPwrDisable = false;
1083 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
1084 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1085 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
1087 if (!bWifiConnected) {
1088 bLowPwrDisable = false;
1089 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1090 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1092 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1093 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1094 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1095 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1096 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1098 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1099 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1103 if (BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) {
1104 bLowPwrDisable = false;
1105 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1106 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1108 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1109 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1110 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1111 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
1112 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1114 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1115 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1118 } else if (BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) {
1119 bLowPwrDisable = true;
1120 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1125 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1127 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1128 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1129 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1130 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
1131 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1133 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1134 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1138 bLowPwrDisable = true;
1139 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1147 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1148 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1150 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1151 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1152 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 21);
1153 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
1155 if (BTC_RSSI_HIGH(btRssiState))
1156 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1158 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1160 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1161 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1170 static void halbtc8723b2ant_TdmaDurationAdjust(
1171 struct btc_coexist *pBtCoexist, bool bScoHid, bool bTxPause, u8 maxInterval
1174 static s32 up, dn, m, n, WaitCount;
1175 s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */
1178 if (!pCoexDm->bAutoTdmaAdjust) {
1179 pCoexDm->bAutoTdmaAdjust = true;
1183 if (maxInterval == 1)
1184 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(13);
1185 else if (maxInterval == 2)
1186 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14);
1188 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1190 if (maxInterval == 1)
1191 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(9);
1192 else if (maxInterval == 2)
1193 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10);
1195 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1199 if (maxInterval == 1)
1200 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(5);
1201 else if (maxInterval == 2)
1202 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6);
1204 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1206 if (maxInterval == 1)
1207 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(1);
1208 else if (maxInterval == 2)
1209 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2);
1211 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1223 /* acquire the BT TRx retry count from BT_Info byte2 */
1224 retryCount = pCoexSta->btRetryCnt;
1228 if (retryCount == 0) { /* no retry in the last 2-second duration */
1235 if (up >= n) { /* if 連續 n 個2秒 retry count為0, 則調寬WiFi duration */
1242 } else if (retryCount <= 3) { /* <=3 retry in the last 2-second duration */
1249 if (dn == 2) { /* if 連續 2 個2秒 retry count< 3, 則調窄WiFi duration */
1251 m++; /* 避免一直在兩個level中來回 */
1255 if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
1264 } else { /* retry count > 3, 只要1次 retry count > 3, 則調窄WiFi duration */
1266 m++; /* 避免一直在兩個level中來回 */
1270 if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
1280 if (maxInterval == 1) {
1282 if (pCoexDm->curPsTdma == 71)
1283 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(5);
1284 else if (pCoexDm->curPsTdma == 1)
1285 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(5);
1286 else if (pCoexDm->curPsTdma == 2)
1287 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6);
1288 else if (pCoexDm->curPsTdma == 3)
1289 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1290 else if (pCoexDm->curPsTdma == 4)
1291 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8);
1293 if (pCoexDm->curPsTdma == 9)
1294 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(13);
1295 else if (pCoexDm->curPsTdma == 10)
1296 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14);
1297 else if (pCoexDm->curPsTdma == 11)
1298 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1299 else if (pCoexDm->curPsTdma == 12)
1300 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16);
1303 if (pCoexDm->curPsTdma == 5)
1304 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6);
1305 else if (pCoexDm->curPsTdma == 6)
1306 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1307 else if (pCoexDm->curPsTdma == 7)
1308 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8);
1309 else if (pCoexDm->curPsTdma == 13)
1310 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14);
1311 else if (pCoexDm->curPsTdma == 14)
1312 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1313 else if (pCoexDm->curPsTdma == 15)
1314 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16);
1315 } else if (result == 1) {
1316 if (pCoexDm->curPsTdma == 8)
1317 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1318 else if (pCoexDm->curPsTdma == 7)
1319 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6);
1320 else if (pCoexDm->curPsTdma == 6)
1321 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(5);
1322 else if (pCoexDm->curPsTdma == 16)
1323 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1324 else if (pCoexDm->curPsTdma == 15)
1325 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14);
1326 else if (pCoexDm->curPsTdma == 14)
1327 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(13);
1330 if (pCoexDm->curPsTdma == 5)
1331 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(71);
1332 else if (pCoexDm->curPsTdma == 6)
1333 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2);
1334 else if (pCoexDm->curPsTdma == 7)
1335 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1336 else if (pCoexDm->curPsTdma == 8)
1337 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4);
1339 if (pCoexDm->curPsTdma == 13)
1340 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(9);
1341 else if (pCoexDm->curPsTdma == 14)
1342 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10);
1343 else if (pCoexDm->curPsTdma == 15)
1344 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1345 else if (pCoexDm->curPsTdma == 16)
1346 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12);
1349 if (pCoexDm->curPsTdma == 71)
1350 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(1);
1351 else if (pCoexDm->curPsTdma == 1)
1352 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2);
1353 else if (pCoexDm->curPsTdma == 2)
1354 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1355 else if (pCoexDm->curPsTdma == 3)
1356 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4);
1357 else if (pCoexDm->curPsTdma == 9)
1358 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10);
1359 else if (pCoexDm->curPsTdma == 10)
1360 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1361 else if (pCoexDm->curPsTdma == 11)
1362 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12);
1363 } else if (result == 1) {
1364 if (pCoexDm->curPsTdma == 4)
1365 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1366 else if (pCoexDm->curPsTdma == 3)
1367 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2);
1368 else if (pCoexDm->curPsTdma == 2)
1369 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(1);
1370 else if (pCoexDm->curPsTdma == 1)
1371 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(71);
1372 else if (pCoexDm->curPsTdma == 12)
1373 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1374 else if (pCoexDm->curPsTdma == 11)
1375 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10);
1376 else if (pCoexDm->curPsTdma == 10)
1377 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(9);
1380 } else if (maxInterval == 2) {
1382 if (pCoexDm->curPsTdma == 1)
1383 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6);
1384 else if (pCoexDm->curPsTdma == 2)
1385 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6);
1386 else if (pCoexDm->curPsTdma == 3)
1387 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1388 else if (pCoexDm->curPsTdma == 4)
1389 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8);
1391 if (pCoexDm->curPsTdma == 9)
1392 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14);
1393 else if (pCoexDm->curPsTdma == 10)
1394 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14);
1395 else if (pCoexDm->curPsTdma == 11)
1396 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1397 else if (pCoexDm->curPsTdma == 12)
1398 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16);
1401 if (pCoexDm->curPsTdma == 5)
1402 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6);
1403 else if (pCoexDm->curPsTdma == 6)
1404 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1405 else if (pCoexDm->curPsTdma == 7)
1406 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8);
1407 else if (pCoexDm->curPsTdma == 13)
1408 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14);
1409 else if (pCoexDm->curPsTdma == 14)
1410 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1411 else if (pCoexDm->curPsTdma == 15)
1412 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16);
1413 } else if (result == 1) {
1414 if (pCoexDm->curPsTdma == 8)
1415 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1416 else if (pCoexDm->curPsTdma == 7)
1417 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6);
1418 else if (pCoexDm->curPsTdma == 6)
1419 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6);
1420 else if (pCoexDm->curPsTdma == 16)
1421 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1422 else if (pCoexDm->curPsTdma == 15)
1423 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14);
1424 else if (pCoexDm->curPsTdma == 14)
1425 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14);
1428 if (pCoexDm->curPsTdma == 5)
1429 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2);
1430 else if (pCoexDm->curPsTdma == 6)
1431 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2);
1432 else if (pCoexDm->curPsTdma == 7)
1433 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1434 else if (pCoexDm->curPsTdma == 8)
1435 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4);
1437 if (pCoexDm->curPsTdma == 13)
1438 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10);
1439 else if (pCoexDm->curPsTdma == 14)
1440 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10);
1441 else if (pCoexDm->curPsTdma == 15)
1442 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1443 else if (pCoexDm->curPsTdma == 16)
1444 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12);
1447 if (pCoexDm->curPsTdma == 1)
1448 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2);
1449 else if (pCoexDm->curPsTdma == 2)
1450 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1451 else if (pCoexDm->curPsTdma == 3)
1452 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4);
1453 else if (pCoexDm->curPsTdma == 9)
1454 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10);
1455 else if (pCoexDm->curPsTdma == 10)
1456 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1457 else if (pCoexDm->curPsTdma == 11)
1458 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12);
1459 } else if (result == 1) {
1460 if (pCoexDm->curPsTdma == 4)
1461 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1462 else if (pCoexDm->curPsTdma == 3)
1463 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2);
1464 else if (pCoexDm->curPsTdma == 2)
1465 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2);
1466 else if (pCoexDm->curPsTdma == 12)
1467 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1468 else if (pCoexDm->curPsTdma == 11)
1469 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10);
1470 else if (pCoexDm->curPsTdma == 10)
1471 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10);
1474 } else if (maxInterval == 3) {
1476 if (pCoexDm->curPsTdma == 1)
1477 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1478 else if (pCoexDm->curPsTdma == 2)
1479 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1480 else if (pCoexDm->curPsTdma == 3)
1481 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1482 else if (pCoexDm->curPsTdma == 4)
1483 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8);
1485 if (pCoexDm->curPsTdma == 9)
1486 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1487 else if (pCoexDm->curPsTdma == 10)
1488 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1489 else if (pCoexDm->curPsTdma == 11)
1490 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1491 else if (pCoexDm->curPsTdma == 12)
1492 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16);
1495 if (pCoexDm->curPsTdma == 5)
1496 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1497 else if (pCoexDm->curPsTdma == 6)
1498 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1499 else if (pCoexDm->curPsTdma == 7)
1500 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8);
1501 else if (pCoexDm->curPsTdma == 13)
1502 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1503 else if (pCoexDm->curPsTdma == 14)
1504 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1505 else if (pCoexDm->curPsTdma == 15)
1506 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16);
1507 } else if (result == 1) {
1508 if (pCoexDm->curPsTdma == 8)
1509 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1510 else if (pCoexDm->curPsTdma == 7)
1511 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1512 else if (pCoexDm->curPsTdma == 6)
1513 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7);
1514 else if (pCoexDm->curPsTdma == 16)
1515 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1516 else if (pCoexDm->curPsTdma == 15)
1517 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1518 else if (pCoexDm->curPsTdma == 14)
1519 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15);
1522 if (pCoexDm->curPsTdma == 5)
1523 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1524 else if (pCoexDm->curPsTdma == 6)
1525 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1526 else if (pCoexDm->curPsTdma == 7)
1527 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1528 else if (pCoexDm->curPsTdma == 8)
1529 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4);
1531 if (pCoexDm->curPsTdma == 13)
1532 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1533 else if (pCoexDm->curPsTdma == 14)
1534 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1535 else if (pCoexDm->curPsTdma == 15)
1536 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1537 else if (pCoexDm->curPsTdma == 16)
1538 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12);
1541 if (pCoexDm->curPsTdma == 1)
1542 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1543 else if (pCoexDm->curPsTdma == 2)
1544 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1545 else if (pCoexDm->curPsTdma == 3)
1546 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4);
1547 else if (pCoexDm->curPsTdma == 9)
1548 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1549 else if (pCoexDm->curPsTdma == 10)
1550 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1551 else if (pCoexDm->curPsTdma == 11)
1552 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12);
1553 } else if (result == 1) {
1554 if (pCoexDm->curPsTdma == 4)
1555 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1556 else if (pCoexDm->curPsTdma == 3)
1557 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1558 else if (pCoexDm->curPsTdma == 2)
1559 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3);
1560 else if (pCoexDm->curPsTdma == 12)
1561 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1562 else if (pCoexDm->curPsTdma == 11)
1563 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1564 else if (pCoexDm->curPsTdma == 10)
1565 HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11);
1571 /* if current PsTdma not match with the recorded one (when scan, dhcp...), */
1572 /* then we have to adjust it back to the previous record one. */
1573 if (pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) {
1574 bool bScan = false, bLink = false, bRoam = false;
1576 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
1577 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
1578 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
1580 if (!bScan && !bLink && !bRoam)
1581 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType);
1586 /* SCO only or SCO+PAN(HS) */
1587 static void halbtc8723b2ant_ActionSco(struct btc_coexist *pBtCoexist)
1589 u8 wifiRssiState, btRssiState;
1592 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
1593 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1595 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1597 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1599 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4);
1601 if (BTC_RSSI_HIGH(btRssiState))
1602 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1604 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1606 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1608 if (BTC_WIFI_BW_LEGACY == wifiBw) /* for SCO quality at 11b/g mode */
1609 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
1610 else /* for SCO quality & wifi performance balance at 11n mode */
1611 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
1613 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0); /* for voice quality */
1616 if (BTC_WIFI_BW_HT40 == wifiBw) {
1618 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1619 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1621 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
1622 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4);
1624 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
1625 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4);
1629 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1630 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1632 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
1633 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4);
1635 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
1636 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4);
1642 static void halbtc8723b2ant_ActionHid(struct btc_coexist *pBtCoexist)
1644 u8 wifiRssiState, btRssiState;
1647 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
1648 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1650 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1652 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1654 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1656 if (BTC_RSSI_HIGH(btRssiState))
1657 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1659 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1661 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1663 if (BTC_WIFI_BW_LEGACY == wifiBw) /* for HID at 11b/g mode */
1664 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1665 else /* for HID quality & wifi performance balance at 11n mode */
1666 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 9);
1669 (btRssiState == BTC_RSSI_STATE_HIGH) ||
1670 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
1672 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1674 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1677 if (BTC_WIFI_BW_HT40 == wifiBw) {
1679 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1680 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1682 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
1683 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1685 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
1686 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1690 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1691 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1693 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
1694 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1696 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
1697 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1702 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
1703 static void halbtc8723b2ant_ActionA2dp(struct btc_coexist *pBtCoexist)
1705 u8 wifiRssiState, wifiRssiState1, btRssiState;
1709 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
1710 wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, 40, 0);
1711 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1713 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
1715 /* define the office environment */
1716 if (apNum >= 10 && BTC_RSSI_HIGH(wifiRssiState1)) {
1717 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1718 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1719 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1720 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1721 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1722 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1725 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1726 if (BTC_WIFI_BW_HT40 == wifiBw) {
1727 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1728 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x18);
1730 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1731 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x18);
1736 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1737 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1739 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1741 if (BTC_RSSI_HIGH(btRssiState))
1742 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1744 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1746 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1749 (btRssiState == BTC_RSSI_STATE_HIGH) ||
1750 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
1752 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 1);
1754 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 1);
1757 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1758 if (BTC_WIFI_BW_HT40 == wifiBw) {
1760 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1761 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1763 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1764 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1766 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1767 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1771 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1772 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1774 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1775 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1777 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1778 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1783 static void halbtc8723b2ant_ActionA2dpPanHs(struct btc_coexist *pBtCoexist)
1785 u8 wifiRssiState, btRssiState;
1788 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
1789 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1791 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1793 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1795 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1797 if (BTC_RSSI_HIGH(btRssiState))
1798 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1800 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1802 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1804 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 2);
1807 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1808 if (BTC_WIFI_BW_HT40 == wifiBw) {
1810 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1811 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1813 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1814 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1816 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1817 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1821 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1822 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1824 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1825 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1827 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1828 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1833 static void halbtc8723b2ant_ActionPanEdr(struct btc_coexist *pBtCoexist)
1835 u8 wifiRssiState, btRssiState;
1838 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
1839 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1841 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1843 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1845 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1847 if (BTC_RSSI_HIGH(btRssiState))
1848 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1850 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1852 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10);
1855 (btRssiState == BTC_RSSI_STATE_HIGH) ||
1856 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
1858 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1860 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1863 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1864 if (BTC_WIFI_BW_HT40 == wifiBw) {
1866 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1867 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1869 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1870 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1872 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1873 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1877 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1878 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1880 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1881 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1883 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1884 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1891 static void halbtc8723b2ant_ActionPanHs(struct btc_coexist *pBtCoexist)
1893 u8 wifiRssiState, btRssiState;
1896 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
1897 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1899 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1901 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1903 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1905 if (BTC_RSSI_HIGH(btRssiState))
1906 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1908 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1910 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1912 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1914 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1915 if (BTC_WIFI_BW_HT40 == wifiBw) {
1917 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1918 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1920 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1921 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1923 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1924 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1928 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1929 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1931 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1932 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1934 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1935 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1941 static void halbtc8723b2ant_ActionPanEdrA2dp(struct btc_coexist *pBtCoexist)
1943 u8 wifiRssiState, btRssiState;
1946 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
1947 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1949 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1951 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1953 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1955 if (BTC_RSSI_HIGH(btRssiState))
1956 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1958 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1960 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1963 (btRssiState == BTC_RSSI_STATE_HIGH) ||
1964 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
1966 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12);
1967 if (BTC_WIFI_BW_HT40 == wifiBw)
1968 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3);
1970 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 3);
1972 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1973 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3);
1977 if (BTC_WIFI_BW_HT40 == wifiBw) {
1979 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1980 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1982 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1983 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1985 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1986 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1990 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
1991 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
1993 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1994 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
1996 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1997 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2002 static void halbtc8723b2ant_ActionPanEdrHid(struct btc_coexist *pBtCoexist)
2004 u8 wifiRssiState, btRssiState;
2007 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2008 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2009 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2011 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2013 if (BTC_RSSI_HIGH(btRssiState))
2014 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2016 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2019 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2020 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2022 if (BTC_WIFI_BW_HT40 == wifiBw) {
2023 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3);
2024 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11);
2025 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780);
2027 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2028 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2029 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2031 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2);
2033 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2034 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11);
2035 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2036 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2040 if (BTC_WIFI_BW_HT40 == wifiBw) {
2042 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2043 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2045 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2046 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2048 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2049 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2053 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2054 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2056 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2057 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2059 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2060 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2065 /* HID+A2DP+PAN(EDR) */
2066 static void halbtc8723b2ant_ActionHidA2dpPanEdr(struct btc_coexist *pBtCoexist)
2068 u8 wifiRssiState, btRssiState;
2071 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2072 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2074 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2076 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2078 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2080 if (BTC_RSSI_HIGH(btRssiState))
2081 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2083 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2085 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2087 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2090 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2091 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2093 if (BTC_WIFI_BW_HT40 == wifiBw)
2094 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2096 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 3);
2098 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 3);
2101 if (BTC_WIFI_BW_HT40 == wifiBw) {
2103 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2104 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2106 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2107 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2109 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2110 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2114 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2115 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2117 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2118 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2120 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2121 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2126 static void halbtc8723b2ant_ActionHidA2dp(struct btc_coexist *pBtCoexist)
2128 u8 wifiRssiState, btRssiState;
2132 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2133 /* btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); */
2134 btRssiState = halbtc8723b2ant_BtRssiState(3, 29, 37);
2136 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2138 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, true, 0x5);
2140 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2142 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2143 if (BTC_WIFI_BW_LEGACY == wifiBw) {
2144 if (BTC_RSSI_HIGH(btRssiState))
2145 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2146 else if (BTC_RSSI_MEDIUM(btRssiState))
2147 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2149 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2151 /* only 802.11N mode we have to dec bt power to 4 degree */
2152 if (BTC_RSSI_HIGH(btRssiState)) {
2153 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
2154 /* need to check ap Number of Not */
2156 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
2158 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2159 } else if (BTC_RSSI_MEDIUM(btRssiState))
2160 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2162 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2165 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2168 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2169 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2171 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2);
2173 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2176 if (BTC_WIFI_BW_HT40 == wifiBw) {
2178 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2179 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2181 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2182 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2184 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2185 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2189 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2190 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2192 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2193 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2195 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2196 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2201 static void halbtc8723b2ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
2205 if (pBtCoexist->bManualControl) {
2209 if (pCoexSta->bUnderIps) {
2213 algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist);
2214 if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
2215 halbtc8723b2ant_ActionBtInquiry(pBtCoexist);
2218 if (pCoexDm->bNeedRecover0x948) {
2219 pCoexDm->bNeedRecover0x948 = false;
2220 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, pCoexDm->backup0x948);
2224 pCoexDm->curAlgorithm = algorithm;
2226 if (halbtc8723b2ant_IsCommonAction(pBtCoexist)) {
2227 pCoexDm->bAutoTdmaAdjust = false;
2229 if (pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) {
2230 pCoexDm->bAutoTdmaAdjust = false;
2234 switch (pCoexDm->curAlgorithm) {
2235 case BT_8723B_2ANT_COEX_ALGO_SCO:
2236 halbtc8723b2ant_ActionSco(pBtCoexist);
2238 case BT_8723B_2ANT_COEX_ALGO_HID:
2239 halbtc8723b2ant_ActionHid(pBtCoexist);
2241 case BT_8723B_2ANT_COEX_ALGO_A2DP:
2242 halbtc8723b2ant_ActionA2dp(pBtCoexist);
2244 case BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS:
2245 halbtc8723b2ant_ActionA2dpPanHs(pBtCoexist);
2247 case BT_8723B_2ANT_COEX_ALGO_PANEDR:
2248 halbtc8723b2ant_ActionPanEdr(pBtCoexist);
2250 case BT_8723B_2ANT_COEX_ALGO_PANHS:
2251 halbtc8723b2ant_ActionPanHs(pBtCoexist);
2253 case BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP:
2254 halbtc8723b2ant_ActionPanEdrA2dp(pBtCoexist);
2256 case BT_8723B_2ANT_COEX_ALGO_PANEDR_HID:
2257 halbtc8723b2ant_ActionPanEdrHid(pBtCoexist);
2259 case BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
2260 halbtc8723b2ant_ActionHidA2dpPanEdr(pBtCoexist);
2262 case BT_8723B_2ANT_COEX_ALGO_HID_A2DP:
2263 halbtc8723b2ant_ActionHidA2dp(pBtCoexist);
2266 halbtc8723b2ant_CoexAllOff(pBtCoexist);
2269 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
2273 static void halbtc8723b2ant_WifiOffHwCfg(struct btc_coexist *pBtCoexist)
2275 bool bIsInMpMode = false;
2276 u8 H2C_Parameter[2] = {0};
2279 /* set wlan_act to low */
2280 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
2282 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); /* WiFi goto standby while GNT_BT 0-->1 */
2283 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
2284 if (fwVer >= 0x180000) {
2285 /* Use H2C to set GNT_BT to HIGH */
2286 H2C_Parameter[0] = 1;
2287 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
2289 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
2291 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode);
2293 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); /* BT select s0/s1 is controlled by BT */
2295 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); /* BT select s0/s1 is controlled by WiFi */
2298 static void halbtc8723b2ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bBackUp)
2302 /* backup rf 0x1e value */
2303 pCoexDm->btRf0x1eBackup =
2304 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
2306 /* 0x790[5:0]= 0x5 */
2307 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
2310 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
2312 /* Antenna config */
2313 halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, true, false);
2316 halbtc8723b2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
2318 /* Enable counter statistics */
2319 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); /* 0x76e[3] = 1, WLAN_Act control by PTA */
2320 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);
2321 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
2325 /* work around function start with wa_halbtc8723b2ant_ */
2328 /* extern function start with EXhalbtc8723b2ant_ */
2330 void EXhalbtc8723b2ant_PowerOnSetting(struct btc_coexist *pBtCoexist)
2332 struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
2333 u8 u1Tmp = 0x4; /* Set BIT2 by default since it's 2ant case */
2336 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20);
2338 /* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. */
2339 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
2340 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp | BIT0 | BIT1);
2342 /* set GRAN_BT = 1 */
2343 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
2344 /* set WLAN_ACT = 0 */
2345 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
2348 /* S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) */
2349 /* Local setting bit define */
2350 /* BIT0: "0" for no antenna inverse; "1" for antenna inverse */
2351 /* BIT1: "0" for internal switch; "1" for external switch */
2352 /* BIT2: "0" for one antenna; "1" for two antenna */
2353 /* NOTE: here default all internal switch and 1-antenna ==> BIT1 = 0 and BIT2 = 0 */
2354 if (pBtCoexist->chipInterface == BTC_INTF_USB) {
2355 /* fixed at S0 for USB interface */
2356 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
2358 u1Tmp |= 0x1; /* antenna inverse */
2359 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);
2361 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
2363 /* for PCIE and SDIO interface, we check efuse 0xc3[6] */
2364 if (pBoardInfo->singleAntPath == 0) {
2366 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
2367 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
2368 } else if (pBoardInfo->singleAntPath == 1) {
2370 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
2371 u1Tmp |= 0x1; /* antenna inverse */
2372 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
2375 if (pBtCoexist->chipInterface == BTC_INTF_PCI)
2376 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp);
2377 else if (pBtCoexist->chipInterface == BTC_INTF_SDIO)
2378 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp);
2382 void EXhalbtc8723b2ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly)
2384 halbtc8723b2ant_InitHwConfig(pBtCoexist, true);
2387 void EXhalbtc8723b2ant_InitCoexDm(struct btc_coexist *pBtCoexist)
2389 halbtc8723b2ant_InitCoexDm(pBtCoexist);
2392 void EXhalbtc8723b2ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type)
2394 if (BTC_IPS_ENTER == type) {
2395 pCoexSta->bUnderIps = true;
2396 halbtc8723b2ant_WifiOffHwCfg(pBtCoexist);
2397 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
2398 halbtc8723b2ant_CoexAllOff(pBtCoexist);
2399 } else if (BTC_IPS_LEAVE == type) {
2400 pCoexSta->bUnderIps = false;
2401 halbtc8723b2ant_InitHwConfig(pBtCoexist, false);
2402 halbtc8723b2ant_InitCoexDm(pBtCoexist);
2403 halbtc8723b2ant_QueryBtInfo(pBtCoexist);
2407 void EXhalbtc8723b2ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type)
2409 if (BTC_LPS_ENABLE == type) {
2410 pCoexSta->bUnderLps = true;
2411 } else if (BTC_LPS_DISABLE == type) {
2412 pCoexSta->bUnderLps = false;
2416 void EXhalbtc8723b2ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type)
2418 if (BTC_SCAN_START == type) {
2419 } else if (BTC_SCAN_FINISH == type) {
2423 void EXhalbtc8723b2ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type)
2425 if (BTC_ASSOCIATE_START == type) {
2426 } else if (BTC_ASSOCIATE_FINISH == type) {
2430 void EXhalbtc8723b2ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type)
2432 u8 H2C_Parameter[3] = {0};
2437 /* only 2.4G we need to inform bt the chnl mask */
2438 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
2439 if ((BTC_MEDIA_CONNECT == type) && (wifiCentralChnl <= 14)) {
2440 H2C_Parameter[0] = 0x1;
2441 H2C_Parameter[1] = wifiCentralChnl;
2442 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2443 if (BTC_WIFI_BW_HT40 == wifiBw)
2444 H2C_Parameter[2] = 0x30;
2446 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
2448 H2C_Parameter[2] = 0x30;
2450 H2C_Parameter[2] = 0x20;
2454 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
2455 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
2456 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
2458 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
2461 void EXhalbtc8723b2ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type)
2465 void EXhalbtc8723b2ant_BtInfoNotify(
2466 struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
2470 u8 i, rspSource = 0;
2471 bool bBtBusy = false, bLimitedDig = false;
2472 bool bWifiConnected = false;
2474 pCoexSta->bC2hBtInfoReqSent = false;
2476 rspSource = tmpBuf[0] & 0xf;
2477 if (rspSource >= BT_INFO_SRC_8723B_2ANT_MAX)
2478 rspSource = BT_INFO_SRC_8723B_2ANT_WIFI_FW;
2480 pCoexSta->btInfoC2hCnt[rspSource]++;
2482 for (i = 0; i < length; i++) {
2483 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
2489 if (pBtCoexist->bManualControl) {
2493 if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
2494 pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2] & 0xf; /* [3:0] */
2496 pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3] * 2 + 10;
2498 pCoexSta->btInfoExt = pCoexSta->btInfoC2h[rspSource][4];
2500 pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2] & 0x40);
2501 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
2502 if (pCoexSta->bBtTxRxMask) {
2503 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */
2504 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01);
2507 /* Here we need to resend some wifi info to BT */
2508 /* because bt is reset and loss of the info. */
2509 if ((pCoexSta->btInfoExt & BIT1)) {
2510 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2513 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
2515 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
2518 if ((pCoexSta->btInfoExt & BIT3)) {
2519 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, false);
2521 /* BT already NOT ignore Wlan active, do nothing here. */
2525 /* check BIT2 first ==> check if bt is under inquiry or page scan */
2526 if (btInfo & BT_INFO_8723B_2ANT_B_INQ_PAGE)
2527 pCoexSta->bC2hBtInquiryPage = true;
2529 pCoexSta->bC2hBtInquiryPage = false;
2531 /* set link exist status */
2532 if (!(btInfo & BT_INFO_8723B_2ANT_B_CONNECTION)) {
2533 pCoexSta->bBtLinkExist = false;
2534 pCoexSta->bPanExist = false;
2535 pCoexSta->bA2dpExist = false;
2536 pCoexSta->bHidExist = false;
2537 pCoexSta->bScoExist = false;
2538 } else { /* connection exists */
2539 pCoexSta->bBtLinkExist = true;
2540 if (btInfo & BT_INFO_8723B_2ANT_B_FTP)
2541 pCoexSta->bPanExist = true;
2543 pCoexSta->bPanExist = false;
2544 if (btInfo & BT_INFO_8723B_2ANT_B_A2DP)
2545 pCoexSta->bA2dpExist = true;
2547 pCoexSta->bA2dpExist = false;
2548 if (btInfo & BT_INFO_8723B_2ANT_B_HID)
2549 pCoexSta->bHidExist = true;
2551 pCoexSta->bHidExist = false;
2552 if (btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO)
2553 pCoexSta->bScoExist = true;
2555 pCoexSta->bScoExist = false;
2558 halbtc8723b2ant_UpdateBtLinkInfo(pBtCoexist);
2560 if (!(btInfo & BT_INFO_8723B_2ANT_B_CONNECTION)) {
2561 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
2562 } else if (btInfo == BT_INFO_8723B_2ANT_B_CONNECTION) { /* connection exists but no busy */
2563 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE;
2565 (btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO) ||
2566 (btInfo & BT_INFO_8723B_2ANT_B_SCO_BUSY)
2568 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_SCO_BUSY;
2569 } else if (btInfo & BT_INFO_8723B_2ANT_B_ACL_BUSY) {
2570 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_ACL_BUSY;
2572 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_MAX;
2576 (BT_8723B_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
2577 (BT_8723B_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2578 (BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)
2584 bLimitedDig = false;
2587 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
2589 pCoexDm->bLimitedDig = bLimitedDig;
2590 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig);
2592 halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);
2595 void EXhalbtc8723b2ant_HaltNotify(struct btc_coexist *pBtCoexist)
2597 halbtc8723b2ant_WifiOffHwCfg(pBtCoexist);
2598 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); /* BT goto standby while GNT_BT 1-->0 */
2599 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
2601 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
2604 void EXhalbtc8723b2ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState)
2606 if (BTC_WIFI_PNP_SLEEP == pnpState) {
2607 } else if (BTC_WIFI_PNP_WAKE_UP == pnpState) {
2608 halbtc8723b2ant_InitHwConfig(pBtCoexist, false);
2609 halbtc8723b2ant_InitCoexDm(pBtCoexist);
2610 halbtc8723b2ant_QueryBtInfo(pBtCoexist);
2614 void EXhalbtc8723b2ant_Periodical(struct btc_coexist *pBtCoexist)
2616 static u8 disVerInfoCnt;
2617 u32 fwVer = 0, btPatchVer = 0;
2619 if (disVerInfoCnt <= 5) {
2621 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
2622 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
2626 halbtc8723b2ant_IsWifiStatusChanged(pBtCoexist) ||
2627 pCoexDm->bAutoTdmaAdjust
2629 halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);