1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
4 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
8 #include "Mp_Precomp.h"
10 /* Global variables, these are static variables */
11 static COEX_DM_8723B_1ANT GLCoexDm8723b1Ant;
12 static PCOEX_DM_8723B_1ANT pCoexDm = &GLCoexDm8723b1Ant;
13 static COEX_STA_8723B_1ANT GLCoexSta8723b1Ant;
14 static PCOEX_STA_8723B_1ANT pCoexSta = &GLCoexSta8723b1Ant;
16 static const char *const GLBtInfoSrc8723b1Ant[] = {
19 "BT Info[bt auto report]",
22 static u32 GLCoexVerDate8723b1Ant = 20140507;
23 static u32 GLCoexVer8723b1Ant = 0x4e;
25 /* local function proto type if needed */
26 /* local function start with halbtc8723b1ant_ */
27 static u8 halbtc8723b1ant_BtRssiState(
28 u8 levelNum, u8 rssiThresh, u8 rssiThresh1
32 u8 btRssiState = pCoexSta->preBtRssiState;
34 btRssi = pCoexSta->btRssi;
38 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
39 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
41 if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) {
43 btRssiState = BTC_RSSI_STATE_HIGH;
47 ("[BTCoex], BT Rssi state switch to High\n")
50 btRssiState = BTC_RSSI_STATE_STAY_LOW;
54 ("[BTCoex], BT Rssi state stay at Low\n")
58 if (btRssi < rssiThresh) {
59 btRssiState = BTC_RSSI_STATE_LOW;
63 ("[BTCoex], BT Rssi state switch to Low\n")
66 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
70 ("[BTCoex], BT Rssi state stay at High\n")
74 } else if (levelNum == 3) {
75 if (rssiThresh > rssiThresh1) {
79 ("[BTCoex], BT Rssi thresh error!!\n")
81 return pCoexSta->preBtRssiState;
85 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
86 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
88 if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) {
89 btRssiState = BTC_RSSI_STATE_MEDIUM;
93 ("[BTCoex], BT Rssi state switch to Medium\n")
96 btRssiState = BTC_RSSI_STATE_STAY_LOW;
100 ("[BTCoex], BT Rssi state stay at Low\n")
104 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
105 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)
107 if (btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) {
108 btRssiState = BTC_RSSI_STATE_HIGH;
112 ("[BTCoex], BT Rssi state switch to High\n")
114 } else if (btRssi < rssiThresh) {
115 btRssiState = BTC_RSSI_STATE_LOW;
119 ("[BTCoex], BT Rssi state switch to Low\n")
122 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
126 ("[BTCoex], BT Rssi state stay at Medium\n")
130 if (btRssi < rssiThresh1) {
131 btRssiState = BTC_RSSI_STATE_MEDIUM;
135 ("[BTCoex], BT Rssi state switch to Medium\n")
138 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
142 ("[BTCoex], BT Rssi state stay at High\n")
148 pCoexSta->preBtRssiState = btRssiState;
153 static void halbtc8723b1ant_UpdateRaMask(
154 PBTC_COEXIST pBtCoexist, bool bForceExec, u32 disRateMask
157 pCoexDm->curRaMask = disRateMask;
159 if (bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask))
162 BTC_SET_ACT_UPDATE_RAMASK,
165 pCoexDm->preRaMask = pCoexDm->curRaMask;
168 static void halbtc8723b1ant_AutoRateFallbackRetry(
169 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
172 bool bWifiUnderBMode = false;
174 pCoexDm->curArfrType = type;
176 if (bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) {
177 switch (pCoexDm->curArfrType) {
178 case 0: /* normal mode */
179 pBtCoexist->fBtcWrite4Byte(
180 pBtCoexist, 0x430, pCoexDm->backupArfrCnt1
182 pBtCoexist->fBtcWrite4Byte(
183 pBtCoexist, 0x434, pCoexDm->backupArfrCnt2
188 pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode
190 if (bWifiUnderBMode) {
191 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
192 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101);
194 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
195 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201);
203 pCoexDm->preArfrType = pCoexDm->curArfrType;
206 static void halbtc8723b1ant_RetryLimit(
207 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
210 pCoexDm->curRetryLimitType = type;
214 (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)
216 switch (pCoexDm->curRetryLimitType) {
217 case 0: /* normal mode */
218 pBtCoexist->fBtcWrite2Byte(
219 pBtCoexist, 0x42a, pCoexDm->backupRetryLimit
222 case 1: /* retry limit =8 */
223 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808);
230 pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType;
233 static void halbtc8723b1ant_AmpduMaxTime(
234 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
237 pCoexDm->curAmpduTimeType = type;
240 bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)
242 switch (pCoexDm->curAmpduTimeType) {
243 case 0: /* normal mode */
244 pBtCoexist->fBtcWrite1Byte(
245 pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime
248 case 1: /* AMPDU timw = 0x38 * 32us */
249 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38);
256 pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType;
259 static void halbtc8723b1ant_LimitedTx(
260 PBTC_COEXIST pBtCoexist,
268 switch (raMaskType) {
269 case 0: /* normal mode */
270 halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0);
272 case 1: /* disable cck 1/2 */
273 halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003);
275 case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */
276 halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7);
282 halbtc8723b1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType);
283 halbtc8723b1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType);
284 halbtc8723b1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType);
287 static void halbtc8723b1ant_LimitedRx(
288 PBTC_COEXIST pBtCoexist,
291 bool bBtCtrlAggBufSize,
295 bool bRejectRxAgg = bRejApAggPkt;
296 bool bBtCtrlRxAggSize = bBtCtrlAggBufSize;
297 u8 rxAggSize = aggBufSize;
300 /* Rx Aggregation related setting */
303 pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg
305 /* decide BT control aggregation buf size or not */
307 pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize
309 /* aggregation buf size, only work when BT control Rx aggregation size. */
310 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
311 /* real update aggregation setting */
312 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
317 static void halbtc8723b1ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
319 u8 H2C_Parameter[1] = {0};
321 pCoexSta->bC2hBtInfoReqSent = true;
323 H2C_Parameter[0] |= BIT0; /* trigger */
328 ("[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", H2C_Parameter[0])
331 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
334 static void halbtc8723b1ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
336 u32 regHPTxRx, regLPTxRx, u4Tmp;
337 u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0;
338 static u8 NumOfBtCounterChk;
340 /* to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS */
341 /* if (! (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) & 0x8)) */
343 if (pCoexSta->bUnderIps) {
344 pCoexSta->highPriorityTx = 65535;
345 pCoexSta->highPriorityRx = 65535;
346 pCoexSta->lowPriorityTx = 65535;
347 pCoexSta->lowPriorityRx = 65535;
354 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
355 regHPTx = u4Tmp & bMaskLWord;
356 regHPRx = (u4Tmp & bMaskHWord)>>16;
358 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
359 regLPTx = u4Tmp & bMaskLWord;
360 regLPRx = (u4Tmp & bMaskHWord)>>16;
362 pCoexSta->highPriorityTx = regHPTx;
363 pCoexSta->highPriorityRx = regHPRx;
364 pCoexSta->lowPriorityTx = regLPTx;
365 pCoexSta->lowPriorityRx = regLPRx;
367 if ((pCoexSta->lowPriorityTx >= 1050) && (!pCoexSta->bC2hBtInquiryPage))
368 pCoexSta->popEventCnt++;
374 "[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n",
383 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
385 if ((regHPTx == 0) && (regHPRx == 0) && (regLPTx == 0) && (regLPRx == 0)) {
387 if (NumOfBtCounterChk >= 3) {
388 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
389 NumOfBtCounterChk = 0;
395 static void halbtc8723b1ant_MonitorWiFiCtr(PBTC_COEXIST pBtCoexist)
398 bool bWifiBusy = false, bWifiUnderBMode = false;
399 static u8 nCCKLockCounter;
401 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
402 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
404 pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode
407 if (pCoexSta->bUnderIps) {
408 pCoexSta->nCRCOK_CCK = 0;
409 pCoexSta->nCRCOK_11g = 0;
410 pCoexSta->nCRCOK_11n = 0;
411 pCoexSta->nCRCOK_11nAgg = 0;
413 pCoexSta->nCRCErr_CCK = 0;
414 pCoexSta->nCRCErr_11g = 0;
415 pCoexSta->nCRCErr_11n = 0;
416 pCoexSta->nCRCErr_11nAgg = 0;
418 pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88);
419 pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94);
420 pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90);
421 pCoexSta->nCRCOK_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8);
423 pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84);
424 pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96);
425 pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92);
426 pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba);
431 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1);
432 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0);
434 if (bWifiBusy && (wifiRssi >= 30) && !bWifiUnderBMode) {
436 (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) ||
437 (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY) ||
438 (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_SCO_BUSY)
441 pCoexSta->nCRCOK_CCK > (
442 pCoexSta->nCRCOK_11g +
443 pCoexSta->nCRCOK_11n +
444 pCoexSta->nCRCOK_11nAgg
447 if (nCCKLockCounter < 5)
450 if (nCCKLockCounter > 0)
455 if (nCCKLockCounter > 0)
459 if (nCCKLockCounter > 0)
463 if (!pCoexSta->bPreCCKLock) {
465 if (nCCKLockCounter >= 5)
466 pCoexSta->bCCKLock = true;
468 pCoexSta->bCCKLock = false;
470 if (nCCKLockCounter == 0)
471 pCoexSta->bCCKLock = false;
473 pCoexSta->bCCKLock = true;
476 pCoexSta->bPreCCKLock = pCoexSta->bCCKLock;
481 static bool halbtc8723b1ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
483 static bool bPreWifiBusy, bPreUnder4way, bPreBtHsOn;
484 bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false;
485 bool bWifiConnected = false;
488 pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected
490 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
491 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
493 pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way
496 if (bWifiConnected) {
497 if (bWifiBusy != bPreWifiBusy) {
498 bPreWifiBusy = bWifiBusy;
502 if (bUnder4way != bPreUnder4way) {
503 bPreUnder4way = bUnder4way;
507 if (bBtHsOn != bPreBtHsOn) {
508 bPreBtHsOn = bBtHsOn;
516 static void halbtc8723b1ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
518 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
519 bool bBtHsOn = false;
521 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
523 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
524 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
525 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
526 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
527 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
529 /* work around for HS mode. */
531 pBtLinkInfo->bPanExist = true;
532 pBtLinkInfo->bBtLinkExist = true;
535 /* check if Sco only */
537 pBtLinkInfo->bScoExist &&
538 !pBtLinkInfo->bA2dpExist &&
539 !pBtLinkInfo->bPanExist &&
540 !pBtLinkInfo->bHidExist
542 pBtLinkInfo->bScoOnly = true;
544 pBtLinkInfo->bScoOnly = false;
546 /* check if A2dp only */
548 !pBtLinkInfo->bScoExist &&
549 pBtLinkInfo->bA2dpExist &&
550 !pBtLinkInfo->bPanExist &&
551 !pBtLinkInfo->bHidExist
553 pBtLinkInfo->bA2dpOnly = true;
555 pBtLinkInfo->bA2dpOnly = false;
557 /* check if Pan only */
559 !pBtLinkInfo->bScoExist &&
560 !pBtLinkInfo->bA2dpExist &&
561 pBtLinkInfo->bPanExist &&
562 !pBtLinkInfo->bHidExist
564 pBtLinkInfo->bPanOnly = true;
566 pBtLinkInfo->bPanOnly = false;
568 /* check if Hid only */
570 !pBtLinkInfo->bScoExist &&
571 !pBtLinkInfo->bA2dpExist &&
572 !pBtLinkInfo->bPanExist &&
573 pBtLinkInfo->bHidExist
575 pBtLinkInfo->bHidOnly = true;
577 pBtLinkInfo->bHidOnly = false;
580 static u8 halbtc8723b1ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
582 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
583 bool bBtHsOn = false;
584 u8 algorithm = BT_8723B_1ANT_COEX_ALGO_UNDEFINED;
585 u8 numOfDiffProfile = 0;
587 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
589 if (!pBtLinkInfo->bBtLinkExist) {
593 ("[BTCoex], No BT link exists!!!\n")
598 if (pBtLinkInfo->bScoExist)
600 if (pBtLinkInfo->bHidExist)
602 if (pBtLinkInfo->bPanExist)
604 if (pBtLinkInfo->bA2dpExist)
607 if (numOfDiffProfile == 1) {
608 if (pBtLinkInfo->bScoExist) {
612 ("[BTCoex], BT Profile = SCO only\n")
614 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
616 if (pBtLinkInfo->bHidExist) {
620 ("[BTCoex], BT Profile = HID only\n")
622 algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
623 } else if (pBtLinkInfo->bA2dpExist) {
627 ("[BTCoex], BT Profile = A2DP only\n")
629 algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP;
630 } else if (pBtLinkInfo->bPanExist) {
635 ("[BTCoex], BT Profile = PAN(HS) only\n")
637 algorithm = BT_8723B_1ANT_COEX_ALGO_PANHS;
642 ("[BTCoex], BT Profile = PAN(EDR) only\n")
644 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR;
648 } else if (numOfDiffProfile == 2) {
649 if (pBtLinkInfo->bScoExist) {
650 if (pBtLinkInfo->bHidExist) {
654 ("[BTCoex], BT Profile = SCO + HID\n")
656 algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
657 } else if (pBtLinkInfo->bA2dpExist) {
661 ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n")
663 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
664 } else if (pBtLinkInfo->bPanExist) {
669 ("[BTCoex], BT Profile = SCO + PAN(HS)\n")
671 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
676 ("[BTCoex], BT Profile = SCO + PAN(EDR)\n")
678 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
682 if (pBtLinkInfo->bHidExist && pBtLinkInfo->bA2dpExist) {
686 ("[BTCoex], BT Profile = HID + A2DP\n")
688 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
689 } else if (pBtLinkInfo->bHidExist && pBtLinkInfo->bPanExist) {
694 ("[BTCoex], BT Profile = HID + PAN(HS)\n")
696 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
701 ("[BTCoex], BT Profile = HID + PAN(EDR)\n")
703 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
705 } else if (pBtLinkInfo->bPanExist && pBtLinkInfo->bA2dpExist) {
710 ("[BTCoex], BT Profile = A2DP + PAN(HS)\n")
712 algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS;
717 ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n")
719 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP;
723 } else if (numOfDiffProfile == 3) {
724 if (pBtLinkInfo->bScoExist) {
725 if (pBtLinkInfo->bHidExist && pBtLinkInfo->bA2dpExist) {
729 ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n")
731 algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
733 pBtLinkInfo->bHidExist && pBtLinkInfo->bPanExist
736 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n"));
737 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
739 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n"));
740 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
742 } else if (pBtLinkInfo->bPanExist && pBtLinkInfo->bA2dpExist) {
744 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n"));
745 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
750 ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n")
752 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
757 pBtLinkInfo->bHidExist &&
758 pBtLinkInfo->bPanExist &&
759 pBtLinkInfo->bA2dpExist
765 ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n")
767 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
772 ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n")
774 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
778 } else if (numOfDiffProfile >= 3) {
779 if (pBtLinkInfo->bScoExist) {
781 pBtLinkInfo->bHidExist &&
782 pBtLinkInfo->bPanExist &&
783 pBtLinkInfo->bA2dpExist
789 ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n")
796 ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n")
798 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
807 static void halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(
808 PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa
811 u8 H2C_Parameter[6] = {0};
813 H2C_Parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */
816 H2C_Parameter[1] |= BIT0;
817 H2C_Parameter[2] = 0x00; /* normal rate except MCS7/6/5, OFDM54/48/36 */
818 H2C_Parameter[3] = 0xf7; /* MCS7 or OFDM54 */
819 H2C_Parameter[4] = 0xf8; /* MCS6 or OFDM48 */
820 H2C_Parameter[5] = 0xf9; /* MCS5 or OFDM36 */
827 "[BTCoex], set WiFi Low-Penalty Retry: %s",
828 (bLowPenaltyRa ? "ON!!" : "OFF!!")
832 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
835 static void halbtc8723b1ant_LowPenaltyRa(
836 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa
839 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
842 if (pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
845 halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(
846 pBtCoexist, pCoexDm->bCurLowPenaltyRa
849 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
852 static void halbtc8723b1ant_SetCoexTable(
853 PBTC_COEXIST pBtCoexist,
863 ("[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0)
865 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
870 ("[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4)
872 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
877 ("[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8)
879 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
884 ("[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc)
886 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
889 static void halbtc8723b1ant_CoexTable(
890 PBTC_COEXIST pBtCoexist,
902 "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6cc = 0x%x\n",
903 (bForceExec ? "force to" : ""),
904 val0x6c0, val0x6c4, val0x6cc
907 pCoexDm->curVal0x6c0 = val0x6c0;
908 pCoexDm->curVal0x6c4 = val0x6c4;
909 pCoexDm->curVal0x6c8 = val0x6c8;
910 pCoexDm->curVal0x6cc = val0x6cc;
914 (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
915 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
916 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
917 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc)
922 halbtc8723b1ant_SetCoexTable(
923 pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc
926 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
927 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
928 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
929 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
932 static void halbtc8723b1ant_CoexTableWithType(
933 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
939 ("[BTCoex], ********** CoexTable(%d) **********\n", type)
942 pCoexSta->nCoexTableType = type;
946 halbtc8723b1ant_CoexTable(
947 pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3
951 halbtc8723b1ant_CoexTable(
952 pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3
956 halbtc8723b1ant_CoexTable(
957 pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3
961 halbtc8723b1ant_CoexTable(
962 pBtCoexist, bForceExec, 0xaaaa5555, 0xaaaa5a5a, 0xffffff, 0x3
966 halbtc8723b1ant_CoexTable(
967 pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3
971 halbtc8723b1ant_CoexTable(
972 pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaa5a5a, 0xffffff, 0x3
976 halbtc8723b1ant_CoexTable(
977 pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3
981 halbtc8723b1ant_CoexTable(
982 pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3
990 static void halbtc8723b1ant_SetFwIgnoreWlanAct(
991 PBTC_COEXIST pBtCoexist, bool bEnable
994 u8 H2C_Parameter[1] = {0};
997 H2C_Parameter[0] |= BIT0; /* function enable */
1003 "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n",
1008 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
1011 static void halbtc8723b1ant_IgnoreWlanAct(
1012 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable
1019 "[BTCoex], %s turn Ignore WlanAct %s\n",
1020 (bForceExec ? "force to" : ""),
1021 (bEnable ? "ON" : "OFF")
1024 pCoexDm->bCurIgnoreWlanAct = bEnable;
1029 ALGO_TRACE_FW_DETAIL,
1031 "[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
1032 pCoexDm->bPreIgnoreWlanAct,
1033 pCoexDm->bCurIgnoreWlanAct
1037 if (pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
1040 halbtc8723b1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
1042 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
1045 static void halbtc8723b1ant_SetLpsRpwm(
1046 PBTC_COEXIST pBtCoexist, u8 lpsVal, u8 rpwmVal
1052 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
1053 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
1056 static void halbtc8723b1ant_LpsRpwm(
1057 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 lpsVal, u8 rpwmVal
1064 "[BTCoex], %s set lps/rpwm = 0x%x/0x%x\n",
1065 (bForceExec ? "force to" : ""),
1070 pCoexDm->curLps = lpsVal;
1071 pCoexDm->curRpwm = rpwmVal;
1076 ALGO_TRACE_FW_DETAIL,
1078 "[BTCoex], LPS-RxBeaconMode = 0x%x , LPS-RPWM = 0x%x!!\n",
1085 (pCoexDm->preLps == pCoexDm->curLps) &&
1086 (pCoexDm->preRpwm == pCoexDm->curRpwm)
1090 ALGO_TRACE_FW_DETAIL,
1092 "[BTCoex], LPS-RPWM_Last = 0x%x , LPS-RPWM_Now = 0x%x!!\n",
1101 halbtc8723b1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
1103 pCoexDm->preLps = pCoexDm->curLps;
1104 pCoexDm->preRpwm = pCoexDm->curRpwm;
1107 static void halbtc8723b1ant_SwMechanism(
1108 PBTC_COEXIST pBtCoexist, bool bLowPenaltyRA
1114 ("[BTCoex], SM[LpRA] = %d\n", bLowPenaltyRA)
1117 halbtc8723b1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
1120 static void halbtc8723b1ant_SetAntPath(
1121 PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
1124 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
1125 u32 fwVer = 0, u4Tmp = 0, cntBtCalChk = 0;
1126 bool bPgExtSwitch = false;
1127 bool bUseExtSwitch = false;
1128 bool bIsInMpMode = false;
1129 u8 H2C_Parameter[2] = {0}, u1Tmp = 0;
1131 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch);
1132 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); /* [31:16]=fw ver, [15:0]=fw sub ver */
1134 if ((fwVer > 0 && fwVer < 0xc0000) || bPgExtSwitch)
1135 bUseExtSwitch = true;
1138 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); /* WiFi TRx Mask on */
1139 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); /* BT TRx Mask on */
1141 if (fwVer >= 0x180000) {
1142 /* Use H2C to set GNT_BT to HIGH */
1143 H2C_Parameter[0] = 1;
1144 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
1145 } else /* set grant_bt to high */
1146 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
1148 /* set wlan_act control by PTA */
1149 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
1151 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); /* BT select s0/s1 is controlled by WiFi */
1153 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1);
1154 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff);
1155 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3);
1156 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77);
1157 } else if (bWifiOff) {
1158 if (fwVer >= 0x180000) {
1159 /* Use H2C to set GNT_BT to HIGH */
1160 H2C_Parameter[0] = 1;
1161 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
1162 } else /* set grant_bt to high */
1163 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
1165 /* set wlan_act to always low */
1166 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
1168 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode);
1170 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); /* BT select s0/s1 is controlled by BT */
1172 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); /* BT select s0/s1 is controlled by WiFi */
1174 /* 0x4c[24:23]= 00, Set Antenna control by BT_RFE_CTRL BT Vendor 0xac = 0xf002 */
1175 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1178 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1180 /* Use H2C to set GNT_BT to LOW */
1181 if (fwVer >= 0x180000) {
1182 if (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765) != 0) {
1183 H2C_Parameter[0] = 0;
1184 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
1187 /* BT calibration check */
1188 while (cntBtCalChk <= 20) {
1189 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49d);
1193 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ########### BT is calibrating (wait cnt =%d) ###########\n", cntBtCalChk));
1196 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ********** BT is NOT calibrating (wait cnt =%d)**********\n", cntBtCalChk));
1201 /* set grant_bt to PTA */
1202 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0);
1205 if (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) != 0xc)
1206 /* set wlan_act control by PTA */
1207 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
1210 if (bUseExtSwitch) {
1212 /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */
1213 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1216 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1218 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */
1220 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) {
1221 /* tell firmware "no antenna inverse" */
1222 H2C_Parameter[0] = 0;
1223 H2C_Parameter[1] = 1; /* ext switch type */
1224 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
1226 /* tell firmware "antenna inverse" */
1227 H2C_Parameter[0] = 1;
1228 H2C_Parameter[1] = 1; /* ext switch type */
1229 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
1234 /* ext switch setting */
1235 switch (antPosType) {
1236 case BTC_ANT_PATH_WIFI:
1237 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
1238 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
1240 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
1242 case BTC_ANT_PATH_BT:
1243 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
1244 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
1246 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
1249 case BTC_ANT_PATH_PTA:
1250 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
1251 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
1253 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
1259 /* 0x4c[23]= 1, 0x4c[24]= 0 Antenna control by 0x64 */
1260 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1263 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1265 /* Fix Ext switch Main->S1, Aux->S0 */
1266 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0);
1268 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) {
1270 /* tell firmware "no antenna inverse" */
1271 H2C_Parameter[0] = 0;
1272 H2C_Parameter[1] = 0; /* internal switch type */
1273 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
1276 /* tell firmware "antenna inverse" */
1277 H2C_Parameter[0] = 1;
1278 H2C_Parameter[1] = 0; /* internal switch type */
1279 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
1284 /* internal switch setting */
1285 switch (antPosType) {
1286 case BTC_ANT_PATH_WIFI:
1287 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
1288 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
1290 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
1292 case BTC_ANT_PATH_BT:
1293 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
1294 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
1296 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
1299 case BTC_ANT_PATH_PTA:
1300 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
1301 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x200);
1303 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x80);
1309 static void halbtc8723b1ant_SetFwPstdma(
1310 PBTC_COEXIST pBtCoexist, u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5
1313 u8 H2C_Parameter[5] = {0};
1314 u8 realByte1 = byte1, realByte5 = byte5;
1315 bool bApEnable = false;
1317 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
1320 if (byte1&BIT4 && !(byte1&BIT5)) {
1324 ("[BTCoex], FW for 1Ant AP mode\n")
1334 H2C_Parameter[0] = realByte1;
1335 H2C_Parameter[1] = byte2;
1336 H2C_Parameter[2] = byte3;
1337 H2C_Parameter[3] = byte4;
1338 H2C_Parameter[4] = realByte5;
1340 pCoexDm->psTdmaPara[0] = realByte1;
1341 pCoexDm->psTdmaPara[1] = byte2;
1342 pCoexDm->psTdmaPara[2] = byte3;
1343 pCoexDm->psTdmaPara[3] = byte4;
1344 pCoexDm->psTdmaPara[4] = realByte5;
1350 "[BTCoex], PS-TDMA H2C cmd = 0x%x%08x\n",
1352 H2C_Parameter[1]<<24|
1353 H2C_Parameter[2]<<16|
1354 H2C_Parameter[3]<<8|
1359 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
1363 static void halbtc8723b1ant_PsTdma(
1364 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
1367 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
1368 bool bWifiBusy = false;
1369 u8 rssiAdjustVal = 0;
1370 u8 psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10;
1371 s8 nWiFiDurationAdjust = 0x0;
1372 /* u32 fwVer = 0; */
1374 /* BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type =%d\n", */
1375 /* (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); */
1376 pCoexDm->bCurPsTdmaOn = bTurnOn;
1377 pCoexDm->curPsTdma = type;
1379 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
1381 if (pCoexDm->bCurPsTdmaOn) {
1386 "[BTCoex], ********** TDMA(on, %d) **********\n",
1395 "[BTCoex], ********** TDMA(off, %d) **********\n",
1403 (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
1404 (pCoexDm->prePsTdma == pCoexDm->curPsTdma)
1409 if (pCoexSta->nScanAPNum <= 5)
1410 nWiFiDurationAdjust = 5;
1411 else if (pCoexSta->nScanAPNum >= 40)
1412 nWiFiDurationAdjust = -15;
1413 else if (pCoexSta->nScanAPNum >= 20)
1414 nWiFiDurationAdjust = -10;
1416 if (!pCoexSta->bForceLpsOn) { /* only for A2DP-only case 1/2/9/11 */
1417 psTdmaByte0Val = 0x61; /* no null-pkt */
1418 psTdmaByte3Val = 0x11; /* no tx-pause at BT-slot */
1419 psTdmaByte4Val = 0x10; /* 0x778 = d/1 toggle */
1424 if (pBtLinkInfo->bSlaveRole == true)
1425 psTdmaByte4Val = psTdmaByte4Val | 0x1; /* 0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) */
1430 halbtc8723b1ant_SetFwPstdma(
1431 pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val
1435 halbtc8723b1ant_SetFwPstdma(
1438 0x3a+nWiFiDurationAdjust,
1445 halbtc8723b1ant_SetFwPstdma(
1448 0x2d+nWiFiDurationAdjust,
1455 halbtc8723b1ant_SetFwPstdma(
1456 pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, 0x10
1460 halbtc8723b1ant_SetFwPstdma(
1461 pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0
1465 halbtc8723b1ant_SetFwPstdma(
1466 pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x10
1470 halbtc8723b1ant_SetFwPstdma(
1471 pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x11
1475 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
1478 halbtc8723b1ant_SetFwPstdma(
1479 pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0
1483 halbtc8723b1ant_SetFwPstdma(
1493 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
1496 halbtc8723b1ant_SetFwPstdma(
1506 halbtc8723b1ant_SetFwPstdma(
1507 pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50
1511 halbtc8723b1ant_SetFwPstdma(
1512 pBtCoexist, 0x51, 0x12, 0x12, 0x0, 0x10
1516 halbtc8723b1ant_SetFwPstdma(
1517 pBtCoexist, 0x51, 0x21, 0x3, 0x10, psTdmaByte4Val
1521 halbtc8723b1ant_SetFwPstdma(
1522 pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0
1526 halbtc8723b1ant_SetFwPstdma(
1527 pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0
1531 halbtc8723b1ant_SetFwPstdma(
1532 pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0
1536 halbtc8723b1ant_SetFwPstdma(
1537 pBtCoexist, 0x61, 0x3f, 0x03, 0x11, 0x10
1542 halbtc8723b1ant_SetFwPstdma(
1543 pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11
1547 halbtc8723b1ant_SetFwPstdma(
1548 pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10
1552 halbtc8723b1ant_SetFwPstdma(
1553 pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18
1557 halbtc8723b1ant_SetFwPstdma(
1558 pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18
1562 halbtc8723b1ant_SetFwPstdma(
1563 pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18
1567 halbtc8723b1ant_SetFwPstdma(
1568 pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18
1572 halbtc8723b1ant_SetFwPstdma(
1573 pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98
1577 halbtc8723b1ant_SetFwPstdma(
1578 pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0
1582 halbtc8723b1ant_SetFwPstdma(
1583 pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10
1587 halbtc8723b1ant_SetFwPstdma(
1588 pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10
1592 halbtc8723b1ant_SetFwPstdma(
1593 pBtCoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x58
1597 halbtc8723b1ant_SetFwPstdma(
1598 pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11
1602 halbtc8723b1ant_SetFwPstdma(
1603 pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90
1607 halbtc8723b1ant_SetFwPstdma(
1608 pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10
1612 halbtc8723b1ant_SetFwPstdma(
1613 pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10
1617 halbtc8723b1ant_SetFwPstdma(
1618 pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50
1621 case 40: /* SoftAP only with no sta associated, BT disable , TDMA mode for power saving */
1622 /* here softap mode screen off will cost 70-80mA for phone */
1623 halbtc8723b1ant_SetFwPstdma(
1624 pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24
1630 /* disable PS tdma */
1632 case 8: /* PTA Control */
1633 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
1634 halbtc8723b1ant_SetAntPath(
1635 pBtCoexist, BTC_ANT_PATH_PTA, false, false
1639 default: /* Software control, Antenna at BT side */
1640 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
1641 halbtc8723b1ant_SetAntPath(
1642 pBtCoexist, BTC_ANT_PATH_BT, false, false
1645 case 9: /* Software control, Antenna at WiFi side */
1646 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
1647 halbtc8723b1ant_SetAntPath(
1648 pBtCoexist, BTC_ANT_PATH_WIFI, false, false
1655 pBtCoexist->fBtcSet(
1656 pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal
1659 /* update pre state */
1660 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1661 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1664 static bool halbtc8723b1ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
1666 bool bCommon = false, bWifiConnected = false, bWifiBusy = false;
1668 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1669 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
1673 BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus
1678 ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n")
1681 /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */
1686 (BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
1691 ("[BTCoex], Wifi connected + BT non connected-idle!!\n")
1694 /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */
1699 (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
1704 ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n")
1707 /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */
1712 (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
1714 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
1716 /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */
1721 (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus)
1726 ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")
1729 /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */
1737 ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")
1743 ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")
1754 static void halbtc8723b1ant_TdmaDurationAdjustForAcl(
1755 PBTC_COEXIST pBtCoexist, u8 wifiStatus
1758 static s32 up, dn, m, n, WaitCount;
1759 s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */
1760 u8 retryCount = 0, btInfoExt;
1761 bool bWifiBusy = false;
1766 ("[BTCoex], TdmaDurationAdjustForAcl()\n")
1769 if (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus)
1775 (BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
1776 (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
1777 (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus)
1780 pCoexDm->curPsTdma != 1 &&
1781 pCoexDm->curPsTdma != 2 &&
1782 pCoexDm->curPsTdma != 3 &&
1783 pCoexDm->curPsTdma != 9
1785 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1786 pCoexDm->psTdmaDuAdjType = 9;
1798 if (!pCoexDm->bAutoTdmaAdjust) {
1799 pCoexDm->bAutoTdmaAdjust = true;
1802 ALGO_TRACE_FW_DETAIL,
1803 ("[BTCoex], first run TdmaDurationAdjust()!!\n")
1806 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1807 pCoexDm->psTdmaDuAdjType = 2;
1816 /* accquire the BT TRx retry count from BT_Info byte2 */
1817 retryCount = pCoexSta->btRetryCnt;
1818 btInfoExt = pCoexSta->btInfoExt;
1819 /* BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount)); */
1820 /* BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up =%d, dn =%d, m =%d, n =%d, WaitCount =%d\n", */
1821 /* up, dn, m, n, WaitCount)); */
1823 if (pCoexSta->lowPriorityTx > 1050 || pCoexSta->lowPriorityRx > 1250)
1829 if (retryCount == 0) { /* no retry in the last 2-second duration */
1836 if (up >= n) { /* if 連續 n 個2秒 retry count為0, 則調寬WiFi duration */
1844 ALGO_TRACE_FW_DETAIL,
1845 ("[BTCoex], Increase wifi duration!!\n")
1848 } else if (retryCount <= 3) { /* <=3 retry in the last 2-second duration */
1855 if (dn == 2) { /* if 連續 2 個2秒 retry count< 3, 則調窄WiFi duration */
1857 m++; /* 避免一直在兩個level中來回 */
1861 if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
1869 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
1871 } else { /* retry count > 3, 只要1次 retry count > 3, 則調窄WiFi duration */
1873 m++; /* 避免一直在兩個level中來回 */
1877 if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
1887 ALGO_TRACE_FW_DETAIL,
1888 ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")
1894 BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt) &&
1895 ((pCoexDm->curPsTdma == 1) || (pCoexDm->curPsTdma == 2))
1897 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1898 pCoexDm->psTdmaDuAdjType = 9;
1899 } else if (pCoexDm->curPsTdma == 1) {
1900 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1901 pCoexDm->psTdmaDuAdjType = 2;
1902 } else if (pCoexDm->curPsTdma == 2) {
1903 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1904 pCoexDm->psTdmaDuAdjType = 9;
1905 } else if (pCoexDm->curPsTdma == 9) {
1906 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1907 pCoexDm->psTdmaDuAdjType = 11;
1909 } else if (result == 1) {
1911 BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt) &&
1912 ((pCoexDm->curPsTdma == 1) || (pCoexDm->curPsTdma == 2))
1914 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1915 pCoexDm->psTdmaDuAdjType = 9;
1916 } else if (pCoexDm->curPsTdma == 11) {
1917 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1918 pCoexDm->psTdmaDuAdjType = 9;
1919 } else if (pCoexDm->curPsTdma == 9) {
1920 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1921 pCoexDm->psTdmaDuAdjType = 2;
1922 } else if (pCoexDm->curPsTdma == 2) {
1923 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1924 pCoexDm->psTdmaDuAdjType = 1;
1926 } else { /* no change */
1929 ALGO_TRACE_FW_DETAIL,
1931 "[BTCoex], ********** TDMA(on, %d) **********\n",
1938 pCoexDm->curPsTdma != 1 &&
1939 pCoexDm->curPsTdma != 2 &&
1940 pCoexDm->curPsTdma != 9 &&
1941 pCoexDm->curPsTdma != 11
1942 ) /* recover to previous adjust type */
1943 halbtc8723b1ant_PsTdma(
1944 pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType
1949 static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState(
1950 PBTC_COEXIST pBtCoexist, bool bNewPsState
1955 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
1957 if (lpsMode) { /* already under LPS state */
1959 /* keep state under LPS, do nothing. */
1960 } else /* will leave LPS state, turn off psTdma first */
1961 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0);
1962 } else { /* NO PS state */
1963 if (bNewPsState) /* will enter LPS state, turn off psTdma first */
1964 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0);
1966 /* keep state under NO PS state, do nothing. */
1971 static void halbtc8723b1ant_PowerSaveState(
1972 PBTC_COEXIST pBtCoexist, u8 psType, u8 lpsVal, u8 rpwmVal
1975 bool bLowPwrDisable = false;
1978 case BTC_PS_WIFI_NATIVE:
1979 /* recover to original 32k low power setting */
1980 bLowPwrDisable = false;
1981 pBtCoexist->fBtcSet(
1982 pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable
1984 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
1985 pCoexSta->bForceLpsOn = false;
1988 halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, true);
1989 halbtc8723b1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
1990 /* when coex force to enter LPS, do not enter 32k low power. */
1991 bLowPwrDisable = true;
1992 pBtCoexist->fBtcSet(
1993 pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable
1995 /* power save must executed before psTdma. */
1996 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
1997 pCoexSta->bForceLpsOn = true;
1999 case BTC_PS_LPS_OFF:
2000 halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, false);
2001 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
2002 pCoexSta->bForceLpsOn = false;
2011 /* Software Coex Mechanism start */
2017 /* Non-Software Coex Mechanism start */
2020 static void halbtc8723b1ant_ActionWifiMultiPort(PBTC_COEXIST pBtCoexist)
2022 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2024 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8);
2025 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2028 static void halbtc8723b1ant_ActionHs(PBTC_COEXIST pBtCoexist)
2030 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
2031 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2034 static void halbtc8723b1ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
2036 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
2037 bool bWifiConnected = false;
2038 bool bApEnable = false;
2039 bool bWifiBusy = false;
2040 bool bBtBusy = false;
2042 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
2043 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2044 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
2045 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
2047 if (!bWifiConnected && !pCoexSta->bWiFiIsHighPriTask) {
2048 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2049 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8);
2051 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2053 pBtLinkInfo->bScoExist ||
2054 pBtLinkInfo->bHidExist ||
2055 pBtLinkInfo->bA2dpExist
2057 /* SCO/HID/A2DP busy */
2058 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2059 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32);
2061 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2062 } else if (pBtLinkInfo->bPanExist || bWifiBusy) {
2063 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2064 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20);
2066 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2068 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2069 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8);
2071 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2075 static void halbtc8723b1ant_ActionBtScoHidOnlyBusy(
2076 PBTC_COEXIST pBtCoexist, u8 wifiStatus
2079 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
2080 bool bWifiConnected = false;
2082 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2084 /* tdma and coex table */
2086 if (pBtLinkInfo->bScoExist) {
2087 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
2088 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);
2090 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
2091 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);
2095 static void halbtc8723b1ant_ActionWifiConnectedBtAclBusy(
2096 PBTC_COEXIST pBtCoexist, u8 wifiStatus
2101 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
2102 btRssiState = halbtc8723b1ant_BtRssiState(2, 28, 0);
2104 if ((pCoexSta->lowPriorityRx >= 1000) && (pCoexSta->lowPriorityRx != 65535))
2105 pBtLinkInfo->bSlaveRole = true;
2107 pBtLinkInfo->bSlaveRole = false;
2109 if (pBtLinkInfo->bHidOnly) { /* HID */
2110 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);
2111 pCoexDm->bAutoTdmaAdjust = false;
2113 } else if (pBtLinkInfo->bA2dpOnly) { /* A2DP */
2114 if (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus) {
2115 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32);
2116 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2117 pCoexDm->bAutoTdmaAdjust = false;
2119 halbtc8723b1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);
2120 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2121 pCoexDm->bAutoTdmaAdjust = true;
2123 } else if (pBtLinkInfo->bHidExist && pBtLinkInfo->bA2dpExist) { /* HID+A2DP */
2124 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
2125 pCoexDm->bAutoTdmaAdjust = false;
2127 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2129 pBtLinkInfo->bPanOnly ||
2130 (pBtLinkInfo->bHidExist && pBtLinkInfo->bPanExist)
2131 ) { /* PAN(OPP, FTP), HID+PAN(OPP, FTP) */
2132 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2133 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2134 pCoexDm->bAutoTdmaAdjust = false;
2136 (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) ||
2137 (pBtLinkInfo->bHidExist && pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)
2138 ) { /* A2DP+PAN(OPP, FTP), HID+A2DP+PAN(OPP, FTP) */
2139 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
2140 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2141 pCoexDm->bAutoTdmaAdjust = false;
2143 /* BT no-profile busy (0x9) */
2144 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32);
2145 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2146 pCoexDm->bAutoTdmaAdjust = false;
2150 static void halbtc8723b1ant_ActionWifiNotConnected(PBTC_COEXIST pBtCoexist)
2152 /* power save state */
2153 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2155 /* tdma and coex table */
2156 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 8);
2157 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2160 static void halbtc8723b1ant_ActionWifiNotConnectedScan(
2161 PBTC_COEXIST pBtCoexist
2164 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
2166 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2168 /* tdma and coex table */
2169 if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) {
2170 if (pBtLinkInfo->bA2dpExist) {
2171 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32);
2172 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2173 } else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) {
2174 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 22);
2175 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2177 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20);
2178 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2181 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2182 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)
2184 halbtc8723b1ant_ActionBtScoHidOnlyBusy(
2185 pBtCoexist, BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN
2189 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8);
2190 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2194 static void halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(
2195 PBTC_COEXIST pBtCoexist
2198 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
2200 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2202 /* tdma and coex table */
2204 (pBtLinkInfo->bScoExist) ||
2205 (pBtLinkInfo->bHidExist) ||
2206 (pBtLinkInfo->bA2dpExist)
2208 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32);
2209 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2210 } else if (pBtLinkInfo->bPanExist) {
2211 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20);
2212 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2214 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8);
2215 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2219 static void halbtc8723b1ant_ActionWifiConnectedScan(PBTC_COEXIST pBtCoexist)
2221 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
2223 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2225 /* tdma and coex table */
2226 if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) {
2227 if (pBtLinkInfo->bA2dpExist) {
2228 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32);
2229 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2230 } else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) {
2231 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 22);
2232 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2234 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20);
2235 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2238 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2239 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)
2241 halbtc8723b1ant_ActionBtScoHidOnlyBusy(
2242 pBtCoexist, BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN
2246 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8);
2247 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2251 static void halbtc8723b1ant_ActionWifiConnectedSpecialPacket(
2252 PBTC_COEXIST pBtCoexist
2255 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
2257 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2259 /* tdma and coex table */
2261 (pBtLinkInfo->bScoExist) ||
2262 (pBtLinkInfo->bHidExist) ||
2263 (pBtLinkInfo->bA2dpExist)
2265 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32);
2266 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2267 } else if (pBtLinkInfo->bPanExist) {
2268 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20);
2269 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2271 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8);
2272 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2276 static void halbtc8723b1ant_ActionWifiConnected(PBTC_COEXIST pBtCoexist)
2278 bool bWifiBusy = false;
2279 bool bScan = false, bLink = false, bRoam = false;
2280 bool bUnder4way = false, bApEnable = false;
2285 ("[BTCoex], CoexForWifiConnect() ===>\n")
2288 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
2290 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
2294 ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n")
2299 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2300 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2301 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2302 if (bScan || bLink || bRoam) {
2304 halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist);
2306 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
2310 ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n")
2315 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
2316 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
2318 /* power save state */
2321 BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus &&
2322 !pBtCoexist->btLinkInfo.bHidOnly
2324 if (pBtCoexist->btLinkInfo.bA2dpOnly) { /* A2DP */
2326 halbtc8723b1ant_PowerSaveState(
2327 pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0
2330 if (pCoexSta->nScanAPNum >= BT_8723B_1ANT_WIFI_NOISY_THRESH) /* no force LPS, no PS-TDMA, use pure TDMA */
2331 halbtc8723b1ant_PowerSaveState(
2332 pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0
2335 halbtc8723b1ant_PowerSaveState(
2336 pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4
2340 (pCoexSta->bPanExist == false) &&
2341 (pCoexSta->bA2dpExist == false) &&
2342 (pCoexSta->bHidExist == false)
2344 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2346 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
2348 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2350 /* tdma and coex table */
2352 if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) {
2353 halbtc8723b1ant_ActionWifiConnectedBtAclBusy(
2355 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE
2358 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2359 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)
2361 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
2362 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE);
2364 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8);
2366 if ((pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60)
2367 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2369 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2372 if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) {
2373 halbtc8723b1ant_ActionWifiConnectedBtAclBusy(
2375 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY
2378 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2379 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)
2381 halbtc8723b1ant_ActionBtScoHidOnlyBusy(
2383 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY
2386 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8);
2388 if ((pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60)
2389 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2391 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2396 static void halbtc8723b1ant_RunSwCoexistMechanism(PBTC_COEXIST pBtCoexist)
2400 algorithm = halbtc8723b1ant_ActionAlgorithm(pBtCoexist);
2401 pCoexDm->curAlgorithm = algorithm;
2403 if (halbtc8723b1ant_IsCommonAction(pBtCoexist)) {
2406 switch (pCoexDm->curAlgorithm) {
2407 case BT_8723B_1ANT_COEX_ALGO_SCO:
2408 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n"));
2409 /* halbtc8723b1ant_ActionSco(pBtCoexist); */
2411 case BT_8723B_1ANT_COEX_ALGO_HID:
2412 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n"));
2413 /* halbtc8723b1ant_ActionHid(pBtCoexist); */
2415 case BT_8723B_1ANT_COEX_ALGO_A2DP:
2416 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n"));
2417 /* halbtc8723b1ant_ActionA2dp(pBtCoexist); */
2419 case BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS:
2420 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
2421 /* halbtc8723b1ant_ActionA2dpPanHs(pBtCoexist); */
2423 case BT_8723B_1ANT_COEX_ALGO_PANEDR:
2424 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
2425 /* halbtc8723b1ant_ActionPanEdr(pBtCoexist); */
2427 case BT_8723B_1ANT_COEX_ALGO_PANHS:
2428 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n"));
2429 /* halbtc8723b1ant_ActionPanHs(pBtCoexist); */
2431 case BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP:
2432 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
2433 /* halbtc8723b1ant_ActionPanEdrA2dp(pBtCoexist); */
2435 case BT_8723B_1ANT_COEX_ALGO_PANEDR_HID:
2436 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
2437 /* halbtc8723b1ant_ActionPanEdrHid(pBtCoexist); */
2439 case BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
2440 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
2441 /* halbtc8723b1ant_ActionHidA2dpPanEdr(pBtCoexist); */
2443 case BT_8723B_1ANT_COEX_ALGO_HID_A2DP:
2444 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
2445 /* halbtc8723b1ant_ActionHidA2dp(pBtCoexist); */
2448 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
2451 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
2455 static void halbtc8723b1ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
2457 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
2458 bool bWifiConnected = false, bBtHsOn = false;
2459 bool bIncreaseScanDevNum = false;
2460 bool bBtCtrlAggBufSize = false;
2462 u32 wifiLinkStatus = 0;
2463 u32 numOfWifiLink = 0;
2465 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism() ===>\n"));
2467 if (pBtCoexist->bManualControl) {
2468 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
2472 if (pBtCoexist->bStopCoexDm) {
2473 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
2477 if (pCoexSta->bUnderIps) {
2478 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
2483 (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
2484 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2485 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)
2487 bIncreaseScanDevNum = true;
2490 pBtCoexist->fBtcSet(
2492 BTC_SET_BL_INC_SCAN_DEV_NUM,
2493 &bIncreaseScanDevNum
2495 pBtCoexist->fBtcGet(
2497 BTC_GET_BL_WIFI_CONNECTED,
2501 pBtCoexist->fBtcGet(
2503 BTC_GET_U4_WIFI_LINK_STATUS,
2506 numOfWifiLink = wifiLinkStatus>>16;
2508 if ((numOfWifiLink >= 2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) {
2513 "############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n",
2518 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
2519 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize);
2521 if ((pBtLinkInfo->bA2dpExist) && (pCoexSta->bC2hBtInquiryPage)) {
2525 ("############# [BTCoex], BT Is Inquirying\n")
2527 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
2529 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
2534 if ((pBtLinkInfo->bBtLinkExist) && (bWifiConnected)) {
2535 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1);
2537 if (pBtLinkInfo->bScoExist)
2538 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, true, 0x5);
2540 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, true, 0x8);
2542 halbtc8723b1ant_SwMechanism(pBtCoexist, true);
2543 halbtc8723b1ant_RunSwCoexistMechanism(pBtCoexist); /* just print debug message */
2545 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
2547 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x5);
2549 halbtc8723b1ant_SwMechanism(pBtCoexist, false);
2550 halbtc8723b1ant_RunSwCoexistMechanism(pBtCoexist); /* just print debug message */
2553 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
2554 if (pCoexSta->bC2hBtInquiryPage) {
2558 ("############# [BTCoex], BT Is Inquirying\n")
2560 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
2562 } else if (bBtHsOn) {
2563 halbtc8723b1ant_ActionHs(pBtCoexist);
2568 if (!bWifiConnected) {
2569 bool bScan = false, bLink = false, bRoam = false;
2571 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n"));
2573 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2574 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2575 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2577 if (bScan || bLink || bRoam) {
2579 halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist);
2581 halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
2583 halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist);
2584 } else /* wifi LPS/Busy */
2585 halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
2588 static void halbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
2590 /* force to reset coex mechanism */
2593 halbtc8723b1ant_SwMechanism(pBtCoexist, false);
2595 /* halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 8); */
2596 halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
2598 pCoexSta->popEventCnt = 0;
2601 static void halbtc8723b1ant_InitHwConfig(
2602 PBTC_COEXIST pBtCoexist,
2607 u32 u4Tmp = 0;/* fwVer; */
2608 u8 u1Tmpa = 0, u1Tmpb = 0;
2613 ("[BTCoex], 1Ant Init HW Config!!\n")
2616 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x550, 0x8, 0x1); /* enable TBTT nterrupt */
2618 /* 0x790[5:0]= 0x5 */
2619 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, 0x5);
2621 /* Enable counter statistics */
2622 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1);
2623 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
2625 /* Antenna config */
2627 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, true, false);
2628 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 9);
2630 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, true, false);
2633 halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
2635 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
2636 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
2637 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
2643 "############# [BTCoex], 0x948 = 0x%x, 0x765 = 0x%x, 0x67 = 0x%x\n",
2652 /* work around function start with wa_halbtc8723b1ant_ */
2655 /* extern function start with EXhalbtc8723b1ant_ */
2657 void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
2659 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
2663 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20);
2665 /* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. */
2666 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
2667 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1);
2669 /* set GRAN_BT = 1 */
2670 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
2671 /* set WLAN_ACT = 0 */
2672 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
2675 /* S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) */
2676 /* Local setting bit define */
2677 /* BIT0: "0" for no antenna inverse; "1" for antenna inverse */
2678 /* BIT1: "0" for internal switch; "1" for external switch */
2679 /* BIT2: "0" for one antenna; "1" for two antenna */
2680 /* NOTE: here default all internal switch and 1-antenna ==> BIT1 = 0 and BIT2 = 0 */
2681 if (pBtCoexist->chipInterface == BTC_INTF_USB) {
2682 /* fixed at S0 for USB interface */
2683 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
2685 u1Tmp |= 0x1; /* antenna inverse */
2686 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);
2688 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
2690 /* for PCIE and SDIO interface, we check efuse 0xc3[6] */
2691 if (pBoardInfo->singleAntPath == 0) {
2693 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
2694 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
2695 } else if (pBoardInfo->singleAntPath == 1) {
2697 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
2698 u1Tmp |= 0x1; /* antenna inverse */
2699 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
2702 if (pBtCoexist->chipInterface == BTC_INTF_PCI)
2703 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp);
2704 else if (pBtCoexist->chipInterface == BTC_INTF_SDIO)
2705 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp);
2709 void EXhalbtc8723b1ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly)
2711 halbtc8723b1ant_InitHwConfig(pBtCoexist, true, bWifiOnly);
2714 void EXhalbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
2719 ("[BTCoex], Coex Mechanism Init!!\n")
2722 pBtCoexist->bStopCoexDm = false;
2724 halbtc8723b1ant_InitCoexDm(pBtCoexist);
2726 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
2729 void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
2731 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
2732 PBTC_STACK_INFO pStackInfo = &pBtCoexist->stackInfo;
2733 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
2734 u8 *cliBuf = pBtCoexist->cliBuf;
2735 u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0;
2741 bool bWifiUnder5G = false;
2742 bool bWifiUnderBMode = false;
2743 bool bBtHsOn = false;
2744 bool bWifiBusy = false;
2745 s32 wifiRssi = 0, btHsRssi = 0;
2746 u32 wifiBw, wifiTrafficDir, faOfdm, faCck, wifiLinkStatus;
2747 u8 wifiDot11Chnl, wifiHsChnl;
2748 u32 fwVer = 0, btPatchVer = 0;
2749 static u8 PopReportIn10s;
2754 "\r\n ============[BT Coexist info]============"
2758 if (pBtCoexist->bManualControl) {
2762 "\r\n ============[Under Manual Control]============"
2767 "\r\n =========================================="
2771 if (pBtCoexist->bStopCoexDm) {
2775 "\r\n ============[Coex is STOPPED]============"
2781 "\r\n =========================================="
2789 "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Ant Mech/ Ant Pos:", \
2790 pBoardInfo->pgAntNum,
2791 pBoardInfo->btdmAntNum,
2792 pBoardInfo->btdmAntPos
2799 "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
2800 ((pStackInfo->bProfileNotified) ? "Yes" : "No"),
2801 pStackInfo->hciVersion
2805 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
2806 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
2810 "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
2811 GLCoexVerDate8723b1Ant,
2819 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
2820 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
2821 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
2825 "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
2835 "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
2836 pCoexDm->wifiChnlInfo[0],
2837 pCoexDm->wifiChnlInfo[1],
2838 pCoexDm->wifiChnlInfo[2]
2842 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
2843 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
2847 "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
2848 wifiRssi-100, btHsRssi-100
2852 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2853 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2854 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2858 "\r\n %-35s = %d/ %d/ %d/ %s", "Wifi bLink/ bRoam/ bScan/ bHi-Pri", \
2859 bLink, bRoam, bScan, ((pCoexSta->bWiFiIsHighPriTask) ? "1" : "0")
2863 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
2864 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2865 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
2866 pBtCoexist->fBtcGet(
2867 pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir
2869 pBtCoexist->fBtcGet(
2870 pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode
2876 "\r\n %-35s = %s / %s/ %s/ AP =%d/ %s ", "Wifi status", \
2877 (bWifiUnder5G ? "5G" : "2.4G"),
2878 ((bWifiUnderBMode) ? "11b" : ((BTC_WIFI_BW_LEGACY == wifiBw) ? "11bg" : (((BTC_WIFI_BW_HT40 == wifiBw) ? "HT40" : "HT20")))),
2879 ((!bWifiBusy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) ? "uplink" : "downlink")),
2880 pCoexSta->nScanAPNum,
2881 (pCoexSta->bCCKLock) ? "Lock" : "noLock"
2885 pBtCoexist->fBtcGet(
2886 pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus
2891 "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "sta/vwifi/hs/p2pGo/p2pGc", \
2892 ((wifiLinkStatus&WIFI_STA_CONNECTED) ? 1 : 0),
2893 ((wifiLinkStatus&WIFI_AP_CONNECTED) ? 1 : 0),
2894 ((wifiLinkStatus&WIFI_HS_CONNECTED) ? 1 : 0),
2895 ((wifiLinkStatus&WIFI_P2P_GO_CONNECTED) ? 1 : 0),
2896 ((wifiLinkStatus&WIFI_P2P_GC_CONNECTED) ? 1 : 0)
2905 "\r\n %-35s = [%s/ %d/ %d/ %d] ", "BT [status/ rssi/ retryCnt/ popCnt]", \
2906 ((pBtCoexist->btInfo.bBtDisabled) ? ("disabled") : ((pCoexSta->bC2hBtInquiryPage) ? ("inquiry/page scan") : ((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ? "non-connected idle" :
2907 ((BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ? "connected-idle" : "busy")))),
2908 pCoexSta->btRssi, pCoexSta->btRetryCnt, pCoexSta->popEventCnt
2912 if (PopReportIn10s >= 5) {
2913 pCoexSta->popEventCnt = 0;
2921 "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
2922 pBtLinkInfo->bScoExist,
2923 pBtLinkInfo->bHidExist,
2924 pBtLinkInfo->bPanExist,
2925 pBtLinkInfo->bA2dpExist
2929 if (pStackInfo->bProfileNotified) {
2930 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
2932 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \
2933 (pBtLinkInfo->bSlaveRole) ? "Slave" : "Master");
2938 btInfoExt = pCoexSta->btInfoExt;
2942 "\r\n %-35s = %s", "BT Info A2DP rate", \
2943 (btInfoExt&BIT0) ? "Basic rate" : "EDR rate"
2947 for (i = 0; i < BT_INFO_SRC_8723B_1ANT_MAX; i++) {
2948 if (pCoexSta->btInfoC2hCnt[i]) {
2952 "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b1Ant[i], \
2953 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
2954 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
2955 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
2956 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]
2964 "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", \
2965 (pCoexSta->bUnderIps ? "IPS ON" : "IPS OFF"),
2966 (pCoexSta->bUnderLps ? "LPS ON" : "LPS OFF"),
2967 pBtCoexist->btInfo.lpsVal,
2968 pBtCoexist->btInfo.rpwmVal
2971 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
2973 if (!pBtCoexist->bManualControl) {
2978 "\r\n %-35s", "============[Sw mechanism]============"
2985 "\r\n %-35s = %d", "SM[LowPenaltyRA]", \
2986 pCoexDm->bCurLowPenaltyRa
2993 "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \
2994 (pBtCoexist->btInfo.bRejectAggPkt ? "Yes" : "No"),
2995 (pBtCoexist->btInfo.bBtCtrlAggBufSize ? "Yes" : "No"),
2996 pBtCoexist->btInfo.aggBufSize
3002 "\r\n %-35s = 0x%x ", "Rate Mask", \
3003 pBtCoexist->btInfo.raMask
3008 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
3011 psTdmaCase = pCoexDm->curPsTdma;
3012 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
3013 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
3014 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
3015 pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
3018 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", \
3019 pCoexSta->nCoexTableType);
3022 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "IgnWlanAct", \
3023 pCoexDm->bCurIgnoreWlanAct);
3027 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
3028 pCoexDm->errorCondition);
3034 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
3037 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", \
3038 pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime);
3041 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
3042 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
3043 u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
3044 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
3045 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \
3046 u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]);
3049 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
3050 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc);
3051 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
3053 cliBuf, BT_TMP_BUF_SIZE,
3054 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x6cc/0x880[29:25]", \
3055 u1Tmp[0], u4Tmp[0], (u4Tmp[1]&0x3e000000) >> 25
3059 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
3060 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
3061 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x764);
3062 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);
3066 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x764 / 0x76e", \
3067 u4Tmp[0], ((u1Tmp[0]&0x20) >> 5), (u4Tmp[1] & 0xffff), u1Tmp[1]
3071 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c);
3072 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
3073 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944);
3077 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \
3078 u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3
3082 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39);
3083 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
3084 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
3085 u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64);
3089 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \
3090 ((u1Tmp[0] & 0x8)>>3),
3092 ((u4Tmp[0]&0x01800000)>>23),
3097 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
3098 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
3102 "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
3107 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
3108 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c);
3112 "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
3113 u4Tmp[0]&0xff, u1Tmp[0]
3117 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
3118 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
3119 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
3120 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0);
3122 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b);
3123 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
3126 ((u4Tmp[0]&0xffff0000) >> 16) +
3127 ((u4Tmp[1]&0xffff0000) >> 16) +
3128 (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \
3129 ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff);
3130 faCck = (u1Tmp[0] << 8) + u1Tmp[1];
3135 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
3136 u4Tmp[0]&0xffff, faOfdm, faCck
3144 "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \
3145 pCoexSta->nCRCOK_CCK,
3146 pCoexSta->nCRCOK_11g,
3147 pCoexSta->nCRCOK_11n,
3148 pCoexSta->nCRCOK_11nAgg
3155 "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \
3156 pCoexSta->nCRCErr_CCK,
3157 pCoexSta->nCRCErr_11g,
3158 pCoexSta->nCRCErr_11n,
3159 pCoexSta->nCRCErr_11nAgg
3163 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
3164 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
3165 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
3169 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", \
3170 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
3176 "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \
3177 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx
3183 "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \
3184 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx
3188 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
3192 void EXhalbtc8723b1ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
3194 if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
3197 if (BTC_IPS_ENTER == type) {
3199 BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n")
3201 pCoexSta->bUnderIps = true;
3203 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0);
3204 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3205 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, false, true);
3206 } else if (BTC_IPS_LEAVE == type) {
3208 BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n")
3210 pCoexSta->bUnderIps = false;
3212 halbtc8723b1ant_InitHwConfig(pBtCoexist, false, false);
3213 halbtc8723b1ant_InitCoexDm(pBtCoexist);
3214 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
3218 void EXhalbtc8723b1ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
3220 if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
3223 if (BTC_LPS_ENABLE == type) {
3225 BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n")
3227 pCoexSta->bUnderLps = true;
3228 } else if (BTC_LPS_DISABLE == type) {
3230 BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n")
3232 pCoexSta->bUnderLps = false;
3236 void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
3238 bool bWifiConnected = false, bBtHsOn = false;
3239 u32 wifiLinkStatus = 0;
3240 u32 numOfWifiLink = 0;
3241 bool bBtCtrlAggBufSize = false;
3247 if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
3250 if (BTC_SCAN_START == type) {
3251 pCoexSta->bWiFiIsHighPriTask = true;
3253 BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n")
3256 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 8); /* Force antenna setup for no scan result issue */
3257 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
3258 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
3259 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
3266 "[BTCoex], 0x948 = 0x%x, 0x765 = 0x%x, 0x67 = 0x%x\n",
3273 pCoexSta->bWiFiIsHighPriTask = false;
3275 BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n")
3278 pBtCoexist->fBtcGet(
3279 pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum
3283 if (pBtCoexist->btInfo.bBtDisabled)
3286 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3287 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3289 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
3291 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
3292 numOfWifiLink = wifiLinkStatus>>16;
3294 if (numOfWifiLink >= 2) {
3295 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
3296 halbtc8723b1ant_LimitedRx(
3297 pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize
3299 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
3303 if (pCoexSta->bC2hBtInquiryPage) {
3304 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
3306 } else if (bBtHsOn) {
3307 halbtc8723b1ant_ActionHs(pBtCoexist);
3311 if (BTC_SCAN_START == type) {
3312 /* BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n")); */
3313 if (!bWifiConnected) /* non-connected scan */
3314 halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist);
3315 else /* wifi is connected */
3316 halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist);
3317 } else if (BTC_SCAN_FINISH == type) {
3318 /* BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n")); */
3319 if (!bWifiConnected) /* non-connected scan */
3320 halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist);
3322 halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
3326 void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
3328 bool bWifiConnected = false, bBtHsOn = false;
3329 u32 wifiLinkStatus = 0;
3330 u32 numOfWifiLink = 0;
3331 bool bBtCtrlAggBufSize = false;
3335 pBtCoexist->bManualControl ||
3336 pBtCoexist->bStopCoexDm ||
3337 pBtCoexist->btInfo.bBtDisabled
3341 if (BTC_ASSOCIATE_START == type) {
3342 pCoexSta->bWiFiIsHighPriTask = true;
3343 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
3344 pCoexDm->nArpCnt = 0;
3346 pCoexSta->bWiFiIsHighPriTask = false;
3347 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
3348 /* pCoexDm->nArpCnt = 0; */
3351 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
3352 numOfWifiLink = wifiLinkStatus>>16;
3353 if (numOfWifiLink >= 2) {
3354 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
3355 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize);
3356 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
3360 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3361 if (pCoexSta->bC2hBtInquiryPage) {
3362 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
3364 } else if (bBtHsOn) {
3365 halbtc8723b1ant_ActionHs(pBtCoexist);
3369 if (BTC_ASSOCIATE_START == type) {
3370 /* BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n")); */
3371 halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
3372 } else if (BTC_ASSOCIATE_FINISH == type) {
3373 /* BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n")); */
3375 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3376 if (!bWifiConnected) /* non-connected scan */
3377 halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist);
3379 halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
3383 void EXhalbtc8723b1ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
3385 u8 H2C_Parameter[3] = {0};
3388 bool bWifiUnderBMode = false;
3391 pBtCoexist->bManualControl ||
3392 pBtCoexist->bStopCoexDm ||
3393 pBtCoexist->btInfo.bBtDisabled
3397 if (BTC_MEDIA_CONNECT == type) {
3398 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
3400 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
3402 /* Set CCK Tx/Rx high Pri except 11b mode */
3403 if (bWifiUnderBMode) {
3404 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); /* CCK Tx */
3405 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x00); /* CCK Rx */
3407 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10); /* CCK Tx */
3408 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); /* CCK Rx */
3411 pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
3412 pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
3413 pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
3414 pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
3416 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
3417 pCoexDm->nArpCnt = 0;
3419 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x0); /* CCK Tx */
3420 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x0); /* CCK Rx */
3423 /* only 2.4G we need to inform bt the chnl mask */
3424 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
3425 if ((BTC_MEDIA_CONNECT == type) && (wifiCentralChnl <= 14)) {
3426 /* H2C_Parameter[0] = 0x1; */
3427 H2C_Parameter[0] = 0x0;
3428 H2C_Parameter[1] = wifiCentralChnl;
3429 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3431 if (BTC_WIFI_BW_HT40 == wifiBw)
3432 H2C_Parameter[2] = 0x30;
3434 H2C_Parameter[2] = 0x20;
3437 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
3438 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
3439 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
3445 "[BTCoex], FW write 0x66 = 0x%x\n",
3446 H2C_Parameter[0]<<16 | H2C_Parameter[1]<<8 | H2C_Parameter[2]
3450 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
3453 void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
3455 bool bBtHsOn = false;
3456 u32 wifiLinkStatus = 0;
3457 u32 numOfWifiLink = 0;
3458 bool bBtCtrlAggBufSize = false;
3462 pBtCoexist->bManualControl ||
3463 pBtCoexist->bStopCoexDm ||
3464 pBtCoexist->btInfo.bBtDisabled
3469 BTC_PACKET_DHCP == type ||
3470 BTC_PACKET_EAPOL == type ||
3471 BTC_PACKET_ARP == type
3473 if (BTC_PACKET_ARP == type) {
3477 ("[BTCoex], special Packet ARP notify\n")
3484 ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt)
3487 if (pCoexDm->nArpCnt >= 10) /* if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist) */
3488 pCoexSta->bWiFiIsHighPriTask = false;
3490 pCoexSta->bWiFiIsHighPriTask = true;
3492 pCoexSta->bWiFiIsHighPriTask = true;
3496 ("[BTCoex], special Packet DHCP or EAPOL notify\n")
3500 pCoexSta->bWiFiIsHighPriTask = false;
3504 ("[BTCoex], special Packet [Type = %d] notify\n", type)
3508 pCoexSta->specialPktPeriodCnt = 0;
3510 pBtCoexist->fBtcGet(
3511 pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus
3513 numOfWifiLink = wifiLinkStatus>>16;
3515 if (numOfWifiLink >= 2) {
3516 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
3517 halbtc8723b1ant_LimitedRx(
3518 pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize
3520 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
3524 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3525 if (pCoexSta->bC2hBtInquiryPage) {
3526 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
3528 } else if (bBtHsOn) {
3529 halbtc8723b1ant_ActionHs(pBtCoexist);
3534 BTC_PACKET_DHCP == type ||
3535 BTC_PACKET_EAPOL == type ||
3536 ((BTC_PACKET_ARP == type) && (pCoexSta->bWiFiIsHighPriTask))
3538 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
3541 void EXhalbtc8723b1ant_BtInfoNotify(
3542 PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
3546 u8 i, rspSource = 0;
3547 bool bWifiConnected = false;
3548 bool bBtBusy = false;
3550 pCoexSta->bC2hBtInfoReqSent = false;
3552 rspSource = tmpBuf[0]&0xf;
3553 if (rspSource >= BT_INFO_SRC_8723B_1ANT_MAX)
3554 rspSource = BT_INFO_SRC_8723B_1ANT_WIFI_FW;
3555 pCoexSta->btInfoC2hCnt[rspSource]++;
3560 ("[BTCoex], Bt info[%d], length =%d, hex data =[",
3564 for (i = 0; i < length; i++) {
3565 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
3570 BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i])
3573 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
3576 if (BT_INFO_SRC_8723B_1ANT_WIFI_FW != rspSource) {
3577 pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2]&0xf;
3579 if (pCoexSta->btRetryCnt >= 1)
3580 pCoexSta->popEventCnt++;
3582 if (pCoexSta->btInfoC2h[rspSource][2]&0x20)
3583 pCoexSta->bC2hBtPage = true;
3585 pCoexSta->bC2hBtPage = false;
3587 pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3]*2-90;
3588 /* pCoexSta->btInfoC2h[rspSource][3]*2+10; */
3590 pCoexSta->btInfoExt = pCoexSta->btInfoC2h[rspSource][4];
3592 pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
3593 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
3595 if (!pCoexSta->bBtTxRxMask) {
3596 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */
3597 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n"));
3598 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15);
3601 /* Here we need to resend some wifi info to BT */
3602 /* because bt is reset and loss of the info. */
3603 if (pCoexSta->btInfoExt & BIT1) {
3607 ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")
3609 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3611 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
3613 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3616 if (pCoexSta->btInfoExt & BIT3) {
3617 if (!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) {
3621 ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")
3623 halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, false);
3626 /* BT already NOT ignore Wlan active, do nothing here. */
3630 /* check BIT2 first ==> check if bt is under inquiry or page scan */
3631 if (btInfo & BT_INFO_8723B_1ANT_B_INQ_PAGE)
3632 pCoexSta->bC2hBtInquiryPage = true;
3634 pCoexSta->bC2hBtInquiryPage = false;
3636 /* set link exist status */
3637 if (!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) {
3638 pCoexSta->bBtLinkExist = false;
3639 pCoexSta->bPanExist = false;
3640 pCoexSta->bA2dpExist = false;
3641 pCoexSta->bHidExist = false;
3642 pCoexSta->bScoExist = false;
3643 } else { /* connection exists */
3644 pCoexSta->bBtLinkExist = true;
3645 if (btInfo & BT_INFO_8723B_1ANT_B_FTP)
3646 pCoexSta->bPanExist = true;
3648 pCoexSta->bPanExist = false;
3650 if (btInfo & BT_INFO_8723B_1ANT_B_A2DP)
3651 pCoexSta->bA2dpExist = true;
3653 pCoexSta->bA2dpExist = false;
3655 if (btInfo & BT_INFO_8723B_1ANT_B_HID)
3656 pCoexSta->bHidExist = true;
3658 pCoexSta->bHidExist = false;
3660 if (btInfo & BT_INFO_8723B_1ANT_B_SCO_ESCO)
3661 pCoexSta->bScoExist = true;
3663 pCoexSta->bScoExist = false;
3666 halbtc8723b1ant_UpdateBtLinkInfo(pBtCoexist);
3668 btInfo = btInfo & 0x1f; /* mask profile bit for connect-ilde identification (for CSR case: A2DP idle --> 0x41) */
3670 if (!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) {
3671 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
3672 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
3673 } else if (btInfo == BT_INFO_8723B_1ANT_B_CONNECTION) {
3674 /* connection exists but no busy */
3675 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE;
3676 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
3678 (btInfo&BT_INFO_8723B_1ANT_B_SCO_ESCO) ||
3679 (btInfo&BT_INFO_8723B_1ANT_B_SCO_BUSY)
3681 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_SCO_BUSY;
3682 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
3683 } else if (btInfo&BT_INFO_8723B_1ANT_B_ACL_BUSY) {
3684 if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
3685 pCoexDm->bAutoTdmaAdjust = false;
3687 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_ACL_BUSY;
3688 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
3690 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_MAX;
3691 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
3695 (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
3696 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
3697 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)
3702 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
3704 halbtc8723b1ant_RunCoexistMechanism(pBtCoexist);
3707 void EXhalbtc8723b1ant_HaltNotify(PBTC_COEXIST pBtCoexist)
3709 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
3711 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3712 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 0);
3713 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, false, true);
3715 halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
3717 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3719 pBtCoexist->bStopCoexDm = true;
3722 void EXhalbtc8723b1ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
3724 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
3726 if (BTC_WIFI_PNP_SLEEP == pnpState) {
3727 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to SLEEP\n"));
3729 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3730 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0);
3731 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
3732 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, false, true);
3734 pBtCoexist->bStopCoexDm = true;
3735 } else if (BTC_WIFI_PNP_WAKE_UP == pnpState) {
3736 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to WAKE UP\n"));
3737 pBtCoexist->bStopCoexDm = false;
3738 halbtc8723b1ant_InitHwConfig(pBtCoexist, false, false);
3739 halbtc8723b1ant_InitCoexDm(pBtCoexist);
3740 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
3744 void EXhalbtc8723b1ant_Periodical(PBTC_COEXIST pBtCoexist)
3746 static u8 disVerInfoCnt;
3747 u32 fwVer = 0, btPatchVer = 0;
3749 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical ===========================\n"));
3751 if (disVerInfoCnt <= 5) {
3753 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
3754 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
3755 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
3756 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
3757 GLCoexVerDate8723b1Ant, GLCoexVer8723b1Ant, fwVer, btPatchVer, btPatchVer));
3758 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
3761 halbtc8723b1ant_MonitorBtCtr(pBtCoexist);
3762 halbtc8723b1ant_MonitorWiFiCtr(pBtCoexist);
3765 halbtc8723b1ant_IsWifiStatusChanged(pBtCoexist) ||
3766 pCoexDm->bAutoTdmaAdjust
3768 halbtc8723b1ant_RunCoexistMechanism(pBtCoexist);
3770 pCoexSta->specialPktPeriodCnt++;