1 //============================================================
4 // This file is for RTL8192E Co-exist mechanism
7 // 2012/11/15 Cosa first check in.
9 //============================================================
11 //============================================================
13 //============================================================
14 #include "Mp_Precomp.h"
16 #if WPP_SOFTWARE_TRACE
17 #include "HalBtc8192e1Ant.tmh"
20 #if(BT_30_SUPPORT == 1)
21 //============================================================
22 // Global variables, these are static variables
23 //============================================================
24 static COEX_DM_8192E_1ANT GLCoexDm8192e1Ant;
25 static PCOEX_DM_8192E_1ANT pCoexDm=&GLCoexDm8192e1Ant;
26 static COEX_STA_8192E_1ANT GLCoexSta8192e1Ant;
27 static PCOEX_STA_8192E_1ANT pCoexSta=&GLCoexSta8192e1Ant;
29 const char *const GLBtInfoSrc8192e1Ant[]={
32 "BT Info[bt auto report]",
35 u4Byte GLCoexVerDate8192e1Ant=20140527;
36 u4Byte GLCoexVer8192e1Ant=0x4f;
38 //============================================================
39 // local function proto type if needed
40 //============================================================
41 //============================================================
42 // local function start with halbtc8192e1ant_
43 //============================================================
45 halbtc8192e1ant_BtRssiState(
52 u1Byte btRssiState=pCoexSta->preBtRssiState;
54 btRssi = pCoexSta->btRssi;
58 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
59 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
61 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
63 btRssiState = BTC_RSSI_STATE_HIGH;
67 btRssiState = BTC_RSSI_STATE_STAY_LOW;
72 if(btRssi < rssiThresh)
74 btRssiState = BTC_RSSI_STATE_LOW;
78 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
82 else if(levelNum == 3)
84 if(rssiThresh > rssiThresh1)
86 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n"));
87 return pCoexSta->preBtRssiState;
90 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
91 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
93 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
95 btRssiState = BTC_RSSI_STATE_MEDIUM;
99 btRssiState = BTC_RSSI_STATE_STAY_LOW;
102 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
103 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
105 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
107 btRssiState = BTC_RSSI_STATE_HIGH;
109 else if(btRssi < rssiThresh)
111 btRssiState = BTC_RSSI_STATE_LOW;
115 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
120 if(btRssi < rssiThresh1)
122 btRssiState = BTC_RSSI_STATE_MEDIUM;
126 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
131 pCoexSta->preBtRssiState = btRssiState;
137 halbtc8192e1ant_WifiRssiState(
138 IN PBTC_COEXIST pBtCoexist,
141 IN u1Byte rssiThresh,
142 IN u1Byte rssiThresh1
146 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
148 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
152 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
153 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
155 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
157 wifiRssiState = BTC_RSSI_STATE_HIGH;
161 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
166 if(wifiRssi < rssiThresh)
168 wifiRssiState = BTC_RSSI_STATE_LOW;
172 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
176 else if(levelNum == 3)
178 if(rssiThresh > rssiThresh1)
180 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n"));
181 return pCoexSta->preWifiRssiState[index];
184 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
185 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
187 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
189 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
193 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
196 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
197 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
199 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
201 wifiRssiState = BTC_RSSI_STATE_HIGH;
203 else if(wifiRssi < rssiThresh)
205 wifiRssiState = BTC_RSSI_STATE_LOW;
209 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
214 if(wifiRssi < rssiThresh1)
216 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
220 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
225 pCoexSta->preWifiRssiState[index] = wifiRssiState;
227 return wifiRssiState;
231 halbtc8192e1ant_UpdateRaMask(
232 IN PBTC_COEXIST pBtCoexist,
233 IN BOOLEAN bForceExec,
234 IN u4Byte disRateMask
237 pCoexDm->curRaMask = disRateMask;
239 if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask))
241 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask);
243 pCoexDm->preRaMask = pCoexDm->curRaMask;
247 halbtc8192e1ant_AutoRateFallbackRetry(
248 IN PBTC_COEXIST pBtCoexist,
249 IN BOOLEAN bForceExec,
253 BOOLEAN bWifiUnderBMode=FALSE;
255 pCoexDm->curArfrType = type;
257 if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType))
259 switch(pCoexDm->curArfrType)
261 case 0: // normal mode
262 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1);
263 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2);
266 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
269 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
270 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101);
274 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
275 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201);
283 pCoexDm->preArfrType = pCoexDm->curArfrType;
287 halbtc8192e1ant_RetryLimit(
288 IN PBTC_COEXIST pBtCoexist,
289 IN BOOLEAN bForceExec,
293 pCoexDm->curRetryLimitType = type;
295 if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType))
297 switch(pCoexDm->curRetryLimitType)
299 case 0: // normal mode
300 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit);
302 case 1: // retry limit=8
303 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808);
310 pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType;
314 halbtc8192e1ant_AmpduMaxTime(
315 IN PBTC_COEXIST pBtCoexist,
316 IN BOOLEAN bForceExec,
320 pCoexDm->curAmpduTimeType = type;
322 if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType))
324 switch(pCoexDm->curAmpduTimeType)
326 case 0: // normal mode
327 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime);
329 case 1: // AMPDU timw = 0x38 * 32us
330 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38);
337 pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType;
341 halbtc8192e1ant_LimitedTx(
342 IN PBTC_COEXIST pBtCoexist,
343 IN BOOLEAN bForceExec,
344 IN u1Byte raMaskType,
346 IN u1Byte retryLimitType,
347 IN u1Byte ampduTimeType
352 case 0: // normal mode
353 halbtc8192e1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0);
355 case 1: // disable cck 1/2
356 halbtc8192e1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003);
358 case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4
359 halbtc8192e1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7);
365 halbtc8192e1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType);
366 halbtc8192e1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType);
367 halbtc8192e1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType);
371 halbtc8192e1ant_LimitedRx(
372 IN PBTC_COEXIST pBtCoexist,
373 IN BOOLEAN bForceExec,
374 IN BOOLEAN bRejApAggPkt,
375 IN BOOLEAN bBtCtrlAggBufSize,
379 BOOLEAN bRejectRxAgg=bRejApAggPkt;
380 BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize;
381 u1Byte rxAggSize=aggBufSize;
383 //============================================
384 // Rx Aggregation related setting
385 //============================================
386 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);
387 // decide BT control aggregation buf size or not
388 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);
389 // aggregation buf size, only work when BT control Rx aggregation size.
390 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
391 // real update aggregation setting
392 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
398 halbtc8192e1ant_QueryBtInfo(
399 IN PBTC_COEXIST pBtCoexist
402 u1Byte H2C_Parameter[1] ={0};
404 pCoexSta->bC2hBtInfoReqSent = TRUE;
406 H2C_Parameter[0] |= BIT0; // trigger
408 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
411 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
415 halbtc8192e1ant_MonitorBtCtr(
416 IN PBTC_COEXIST pBtCoexist
419 u4Byte regHPTxRx, regLPTxRx, u4Tmp, u4Tmp1;
420 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
421 u1Byte u1Tmp, u1Tmp1;
423 static u1Byte NumOfBtCounterChk = 0;
425 //to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS
426 //if (! (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) & 0x8) )
428 if (pCoexSta->bUnderIps)
430 pCoexSta->highPriorityTx = 65535;
431 pCoexSta->highPriorityRx = 65535;
432 pCoexSta->lowPriorityTx = 65535;
433 pCoexSta->lowPriorityRx = 65535;
440 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
441 regHPTx = u4Tmp & bMaskLWord;
442 regHPRx = (u4Tmp & bMaskHWord)>>16;
444 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
445 regLPTx = u4Tmp & bMaskLWord;
446 regLPRx = (u4Tmp & bMaskHWord)>>16;
448 pCoexSta->highPriorityTx = regHPTx;
449 pCoexSta->highPriorityRx = regHPRx;
450 pCoexSta->lowPriorityTx = regLPTx;
451 pCoexSta->lowPriorityRx = regLPRx;
453 if( (pCoexSta->lowPriorityTx >= 1050) && (!pCoexSta->bC2hBtInquiryPage))
454 pCoexSta->popEventCnt++;
456 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n",
457 regHPRx, regHPTx, regLPRx, regLPTx));
460 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
462 if ((regHPTx == 0) && (regHPRx ==0) && (regLPTx == 0) && (regLPRx == 0))
465 if (NumOfBtCounterChk >= 3)
467 halbtc8192e1ant_QueryBtInfo(pBtCoexist);
468 NumOfBtCounterChk = 0;
475 halbtc8192e1ant_MonitorWiFiCtr(
476 IN PBTC_COEXIST pBtCoexist
482 BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE;
483 static u1Byte nCCKLockCounter = 0;
485 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
486 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
487 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
489 if (pCoexSta->bUnderIps)
491 pCoexSta->nCRCOK_CCK = 0;
492 pCoexSta->nCRCOK_11g = 0;
493 pCoexSta->nCRCOK_11n = 0;
494 pCoexSta->nCRCOK_11nAgg = 0;
496 pCoexSta->nCRCErr_CCK = 0;
497 pCoexSta->nCRCErr_11g = 0;
498 pCoexSta->nCRCErr_11n = 0;
499 pCoexSta->nCRCErr_11nAgg = 0;
503 pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88);
504 pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94);
505 pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90);
506 pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8);
508 pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84);
509 pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96);
510 pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92);
511 pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba);
516 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1);
517 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0);
519 if ( (bWifiBusy) && (wifiRssi >= 30) && (!bWifiUnderBMode))
521 if ( (pCoexDm->btStatus == BT_8192E_1ANT_BT_STATUS_ACL_BUSY) ||
522 (pCoexDm->btStatus == BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY) ||
523 (pCoexDm->btStatus == BT_8192E_1ANT_BT_STATUS_SCO_BUSY) )
525 if (pCoexSta->nCRCOK_CCK >(pCoexSta->nCRCOK_11g + pCoexSta->nCRCOK_11n +
526 pCoexSta->nCRCOK_11nAgg) )
528 if (nCCKLockCounter < 5)
533 if (nCCKLockCounter > 0)
540 if (nCCKLockCounter > 0)
546 if (nCCKLockCounter > 0)
550 if (!pCoexSta->bPreCCKLock)
553 if (nCCKLockCounter >= 5)
554 pCoexSta->bCCKLock = TRUE;
556 pCoexSta->bCCKLock = FALSE;
560 if (nCCKLockCounter == 0)
561 pCoexSta->bCCKLock = FALSE;
563 pCoexSta->bCCKLock = TRUE;
566 pCoexSta->bPreCCKLock = pCoexSta->bCCKLock;
572 halbtc8192e1ant_IsWifiStatusChanged(
573 IN PBTC_COEXIST pBtCoexist
576 static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;
577 BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;
578 BOOLEAN bWifiConnected=FALSE;
580 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
581 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
582 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
583 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
587 if(bWifiBusy != bPreWifiBusy)
589 bPreWifiBusy = bWifiBusy;
592 if(bUnder4way != bPreUnder4way)
594 bPreUnder4way = bUnder4way;
597 if(bBtHsOn != bPreBtHsOn)
599 bPreBtHsOn = bBtHsOn;
608 halbtc8192e1ant_UpdateBtLinkInfo(
609 IN PBTC_COEXIST pBtCoexist
612 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
613 BOOLEAN bBtHsOn=FALSE;
615 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
617 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
618 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
619 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
620 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
621 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
623 // work around for HS mode.
626 pBtLinkInfo->bPanExist = TRUE;
627 pBtLinkInfo->bBtLinkExist = TRUE;
631 if( pBtLinkInfo->bScoExist &&
632 !pBtLinkInfo->bA2dpExist &&
633 !pBtLinkInfo->bPanExist &&
634 !pBtLinkInfo->bHidExist )
635 pBtLinkInfo->bScoOnly = TRUE;
637 pBtLinkInfo->bScoOnly = FALSE;
639 // check if A2dp only
640 if( !pBtLinkInfo->bScoExist &&
641 pBtLinkInfo->bA2dpExist &&
642 !pBtLinkInfo->bPanExist &&
643 !pBtLinkInfo->bHidExist )
644 pBtLinkInfo->bA2dpOnly = TRUE;
646 pBtLinkInfo->bA2dpOnly = FALSE;
649 if( !pBtLinkInfo->bScoExist &&
650 !pBtLinkInfo->bA2dpExist &&
651 pBtLinkInfo->bPanExist &&
652 !pBtLinkInfo->bHidExist )
653 pBtLinkInfo->bPanOnly = TRUE;
655 pBtLinkInfo->bPanOnly = FALSE;
658 if( !pBtLinkInfo->bScoExist &&
659 !pBtLinkInfo->bA2dpExist &&
660 !pBtLinkInfo->bPanExist &&
661 pBtLinkInfo->bHidExist )
662 pBtLinkInfo->bHidOnly = TRUE;
664 pBtLinkInfo->bHidOnly = FALSE;
668 halbtc8192e1ant_ActionAlgorithm(
669 IN PBTC_COEXIST pBtCoexist
672 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
673 BOOLEAN bBtHsOn=FALSE;
674 u1Byte algorithm=BT_8192E_1ANT_COEX_ALGO_UNDEFINED;
675 u1Byte numOfDiffProfile=0;
677 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
679 if(!pBtLinkInfo->bBtLinkExist)
681 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n"));
685 if(pBtLinkInfo->bScoExist)
687 if(pBtLinkInfo->bHidExist)
689 if(pBtLinkInfo->bPanExist)
691 if(pBtLinkInfo->bA2dpExist)
694 if(numOfDiffProfile == 1)
696 if(pBtLinkInfo->bScoExist)
698 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO only\n"));
699 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
703 if(pBtLinkInfo->bHidExist)
705 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID only\n"));
706 algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
708 else if(pBtLinkInfo->bA2dpExist)
710 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP only\n"));
711 algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP;
713 else if(pBtLinkInfo->bPanExist)
717 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(HS) only\n"));
718 algorithm = BT_8192E_1ANT_COEX_ALGO_PANHS;
722 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(EDR) only\n"));
723 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR;
728 else if(numOfDiffProfile == 2)
730 if(pBtLinkInfo->bScoExist)
732 if(pBtLinkInfo->bHidExist)
734 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID\n"));
735 algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
737 else if(pBtLinkInfo->bA2dpExist)
739 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n"));
740 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
742 else if(pBtLinkInfo->bPanExist)
746 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(HS)\n"));
747 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
751 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n"));
752 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
758 if( pBtLinkInfo->bHidExist &&
759 pBtLinkInfo->bA2dpExist )
761 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP\n"));
762 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
764 else if( pBtLinkInfo->bHidExist &&
765 pBtLinkInfo->bPanExist )
769 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(HS)\n"));
770 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
774 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(EDR)\n"));
775 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
778 else if( pBtLinkInfo->bPanExist &&
779 pBtLinkInfo->bA2dpExist )
783 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n"));
784 algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS;
788 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n"));
789 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP;
794 else if(numOfDiffProfile == 3)
796 if(pBtLinkInfo->bScoExist)
798 if( pBtLinkInfo->bHidExist &&
799 pBtLinkInfo->bA2dpExist )
801 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n"));
802 algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
804 else if( pBtLinkInfo->bHidExist &&
805 pBtLinkInfo->bPanExist )
809 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n"));
810 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
814 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n"));
815 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
818 else if( pBtLinkInfo->bPanExist &&
819 pBtLinkInfo->bA2dpExist )
823 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n"));
824 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
828 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n"));
829 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
835 if( pBtLinkInfo->bHidExist &&
836 pBtLinkInfo->bPanExist &&
837 pBtLinkInfo->bA2dpExist )
841 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n"));
842 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
846 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n"));
847 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
852 else if(numOfDiffProfile >= 3)
854 if(pBtLinkInfo->bScoExist)
856 if( pBtLinkInfo->bHidExist &&
857 pBtLinkInfo->bPanExist &&
858 pBtLinkInfo->bA2dpExist )
862 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n"));
867 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
868 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
878 halbtc8192e1ant_SetBtAutoReport(
879 IN PBTC_COEXIST pBtCoexist,
880 IN BOOLEAN bEnableAutoReport
883 u1Byte H2C_Parameter[1] ={0};
885 H2C_Parameter[0] = 0;
887 if(bEnableAutoReport)
889 H2C_Parameter[0] |= BIT0;
892 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
893 (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));
895 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter);
899 halbtc8192e1ant_BtAutoReport(
900 IN PBTC_COEXIST pBtCoexist,
901 IN BOOLEAN bForceExec,
902 IN BOOLEAN bEnableAutoReport
905 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n",
906 (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
907 pCoexDm->bCurBtAutoReport = bEnableAutoReport;
911 if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
914 halbtc8192e1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
916 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
920 halbtc8192e1ant_SetSwPenaltyTxRateAdaptive(
921 IN PBTC_COEXIST pBtCoexist,
922 IN BOOLEAN bLowPenaltyRa
925 u1Byte H2C_Parameter[6] ={0};
927 H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty
931 H2C_Parameter[1] |= BIT0;
932 H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36
933 H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54
934 H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48
935 H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36
938 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s",
939 (bLowPenaltyRa? "ON!!":"OFF!!") ));
941 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
945 halbtc8192e1ant_LowPenaltyRa(
946 IN PBTC_COEXIST pBtCoexist,
947 IN BOOLEAN bForceExec,
948 IN BOOLEAN bLowPenaltyRa
951 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
955 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
958 halbtc8192e1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
960 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
964 halbtc8192e1ant_SetCoexTable(
965 IN PBTC_COEXIST pBtCoexist,
972 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
973 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
975 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
976 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
978 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
979 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
981 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
982 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
986 halbtc8192e1ant_CoexTable(
987 IN PBTC_COEXIST pBtCoexist,
988 IN BOOLEAN bForceExec,
995 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6cc=0x%x\n",
996 (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6cc));
997 pCoexDm->curVal0x6c0 = val0x6c0;
998 pCoexDm->curVal0x6c4 = val0x6c4;
999 pCoexDm->curVal0x6c8 = val0x6c8;
1000 pCoexDm->curVal0x6cc = val0x6cc;
1004 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
1005 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
1006 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
1007 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
1010 halbtc8192e1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
1012 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
1013 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
1014 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
1015 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
1019 halbtc8192e1ant_CoexTableWithType(
1020 IN PBTC_COEXIST pBtCoexist,
1021 IN BOOLEAN bForceExec,
1025 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** CoexTable(%d) **********\n", type));
1027 pCoexSta->nCoexTableType = type;
1032 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);
1035 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
1038 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);
1041 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
1044 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3);
1047 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaa5a5a5a, 0xffffff, 0x3);
1050 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3);
1053 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
1061 halbtc8192e1ant_SetFwIgnoreWlanAct(
1062 IN PBTC_COEXIST pBtCoexist,
1066 u1Byte H2C_Parameter[1] ={0};
1070 H2C_Parameter[0] |= BIT0; // function enable
1073 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
1076 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
1080 halbtc8192e1ant_IgnoreWlanAct(
1081 IN PBTC_COEXIST pBtCoexist,
1082 IN BOOLEAN bForceExec,
1086 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n",
1087 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
1088 pCoexDm->bCurIgnoreWlanAct = bEnable;
1092 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
1095 halbtc8192e1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
1097 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
1101 halbtc8192e1ant_SetLpsRpwm(
1102 IN PBTC_COEXIST pBtCoexist,
1108 u1Byte rpwm=rpwmVal;
1110 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
1111 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
1115 halbtc8192e1ant_LpsRpwm(
1116 IN PBTC_COEXIST pBtCoexist,
1117 IN BOOLEAN bForceExec,
1122 BOOLEAN bForceExecPwrCmd=FALSE;
1124 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
1125 (bForceExec? "force to":""), lpsVal, rpwmVal));
1126 pCoexDm->curLps = lpsVal;
1127 pCoexDm->curRpwm = rpwmVal;
1131 if( (pCoexDm->preLps == pCoexDm->curLps) &&
1132 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
1137 halbtc8192e1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
1139 pCoexDm->preLps = pCoexDm->curLps;
1140 pCoexDm->preRpwm = pCoexDm->curRpwm;
1144 halbtc8192e1ant_SwMechanism(
1145 IN PBTC_COEXIST pBtCoexist,
1146 IN BOOLEAN bLowPenaltyRA
1149 halbtc8192e1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
1153 halbtc8192e1ant_SetAntPath(
1154 IN PBTC_COEXIST pBtCoexist,
1155 IN u1Byte antPosType,
1156 IN BOOLEAN bInitHwCfg,
1164 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x944, 0x24);
1165 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x930, 0x700700);
1166 if(pBtCoexist->chipInterface == BTC_INTF_USB)
1167 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004);
1169 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004);
1171 // 0x4c[27][24]='00', Set Antenna to BB
1172 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1175 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1179 if(pBtCoexist->chipInterface == BTC_INTF_USB)
1180 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004);
1182 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004);
1184 // 0x4c[27][24]='11', Set Antenna to BT, 0x64[8:7]=0, 0x64[2]=1
1185 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1188 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1191 // ext switch setting
1194 case BTC_ANT_PATH_WIFI:
1195 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4);
1197 case BTC_ANT_PATH_BT:
1198 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x20);
1201 case BTC_ANT_PATH_PTA:
1202 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4);
1208 halbtc8192e1ant_SetFwPstdma(
1209 IN PBTC_COEXIST pBtCoexist,
1217 u1Byte H2C_Parameter[5] ={0};
1218 u1Byte realByte1=byte1, realByte5=byte5;
1219 BOOLEAN bApEnable=FALSE;
1221 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
1225 if(byte1&BIT4 && !(byte1&BIT5))
1227 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n"));
1236 H2C_Parameter[0] = realByte1;
1237 H2C_Parameter[1] = byte2;
1238 H2C_Parameter[2] = byte3;
1239 H2C_Parameter[3] = byte4;
1240 H2C_Parameter[4] = realByte5;
1242 pCoexDm->psTdmaPara[0] = realByte1;
1243 pCoexDm->psTdmaPara[1] = byte2;
1244 pCoexDm->psTdmaPara[2] = byte3;
1245 pCoexDm->psTdmaPara[3] = byte4;
1246 pCoexDm->psTdmaPara[4] = realByte5;
1248 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n",
1250 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
1252 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
1257 halbtc8192e1ant_PsTdma(
1258 IN PBTC_COEXIST pBtCoexist,
1259 IN BOOLEAN bForceExec,
1264 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
1265 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
1266 BOOLEAN bTurnOnByCnt=FALSE, bWifiBusy=FALSE, bWiFiNoisy=FALSE;
1267 u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0;
1268 u1Byte psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10;
1269 s1Byte nWiFiDurationAdjust = 0x0;
1271 pCoexDm->bCurPsTdmaOn = bTurnOn;
1272 pCoexDm->curPsTdma = type;
1274 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
1276 if (pCoexDm->bCurPsTdmaOn)
1278 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n",
1279 pCoexDm->curPsTdma));
1283 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(off, %d) **********\n",
1284 pCoexDm->curPsTdma));
1289 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
1290 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
1294 if (pCoexSta->nScanAPNum <= 5)
1295 nWiFiDurationAdjust = 5;
1296 else if (pCoexSta->nScanAPNum >= 40)
1297 nWiFiDurationAdjust = -15;
1298 else if (pCoexSta->nScanAPNum >= 20)
1299 nWiFiDurationAdjust = -10;
1301 if (!pCoexSta->bForceLpsOn) //only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30
1303 psTdmaByte0Val = 0x61; //no null-pkt
1304 psTdmaByte3Val = 0x11; // no tx-pause at BT-slot
1305 psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle
1308 if ( (type == 3) || (type == 13) || (type == 14) )
1309 psTdmaByte4Val = psTdmaByte4Val & 0xbf; //no dynamic slot for multi-profile
1311 if (pBtLinkInfo->bSlaveRole == TRUE)
1312 psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts)
1319 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val);
1322 halbtc8192e1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val);
1325 halbtc8192e1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val);
1328 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, psTdmaByte4Val);
1331 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
1334 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x11);
1337 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x11);
1340 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
1343 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
1346 halbtc8192e1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val);
1349 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
1352 halbtc8192e1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val);
1355 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50);
1358 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, psTdmaByte4Val);
1361 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, psTdmaByte4Val);
1364 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0);
1367 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0);
1370 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
1373 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x3f, 0x03, 0x11, 0x10);
1376 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11);
1379 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10);
1382 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);
1385 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);
1388 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
1391 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
1394 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);
1397 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0);
1400 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10);
1403 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10);
1406 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);
1409 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11);
1412 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90);
1415 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10);
1418 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10);
1421 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50);
1423 case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving
1424 /* here softap mode screen off will cost 70-80mA for phone */
1425 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24);
1435 case 8: //PTA Control
1436 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
1437 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE);
1440 default: //Software control, Antenna at BT side
1441 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
1442 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
1444 case 9: //Software control, Antenna at WiFi side
1445 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
1446 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE);
1451 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal);
1454 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n",
1455 pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67)));
1458 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1459 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1463 halbtc8192e1ant_CoexAllOff(
1464 IN PBTC_COEXIST pBtCoexist
1468 halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1471 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1475 halbtc8192e1ant_IsCommonAction(
1476 IN PBTC_COEXIST pBtCoexist
1479 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
1481 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1482 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
1484 if(!bWifiConnected &&
1485 BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
1487 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));
1489 //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1493 else if(bWifiConnected &&
1494 (BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) )
1496 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
1498 //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1502 else if(!bWifiConnected &&
1503 (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
1505 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));
1507 //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1511 else if(bWifiConnected &&
1512 (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
1514 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
1516 //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1520 else if(!bWifiConnected &&
1521 (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) )
1523 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
1525 //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1533 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
1537 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));
1548 halbtc8192e1ant_TdmaDurationAdjustForAcl(
1549 IN PBTC_COEXIST pBtCoexist,
1550 IN u1Byte wifiStatus
1553 static s4Byte up,dn,m,n,WaitCount;
1554 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
1555 u1Byte retryCount=0, btInfoExt;
1556 static BOOLEAN bPreWifiBusy=FALSE;
1557 BOOLEAN bWifiBusy = FALSE;
1559 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjustForAcl()\n"));
1561 if(BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus)
1566 if( (BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
1567 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
1568 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
1570 if( pCoexDm->curPsTdma != 1 &&
1571 pCoexDm->curPsTdma != 2 &&
1572 pCoexDm->curPsTdma != 3 &&
1573 pCoexDm->curPsTdma != 9 )
1575 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
1576 pCoexDm->psTdmaDuAdjType = 9;
1588 if(!pCoexDm->bAutoTdmaAdjust)
1590 pCoexDm->bAutoTdmaAdjust = TRUE;
1591 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
1593 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
1594 pCoexDm->psTdmaDuAdjType = 2;
1605 //accquire the BT TRx retry count from BT_Info byte2
1606 retryCount = pCoexSta->btRetryCnt;
1607 btInfoExt = pCoexSta->btInfoExt;
1609 if ( (pCoexSta->lowPriorityTx) > 1050 || (pCoexSta->lowPriorityRx) > 1250 )
1615 if(retryCount == 0) // no retry in the last 2-second duration
1623 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
1630 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n"));
1633 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
1641 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
1644 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
1648 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
1656 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
1659 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
1662 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
1666 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
1674 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
1679 if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
1680 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
1682 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
1683 pCoexDm->psTdmaDuAdjType = 9;
1685 else if(pCoexDm->curPsTdma == 1)
1687 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
1688 pCoexDm->psTdmaDuAdjType = 2;
1690 else if(pCoexDm->curPsTdma == 2)
1692 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
1693 pCoexDm->psTdmaDuAdjType = 9;
1695 else if(pCoexDm->curPsTdma == 9)
1697 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
1698 pCoexDm->psTdmaDuAdjType = 11;
1701 else if(result == 1)
1703 if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
1704 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
1706 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
1707 pCoexDm->psTdmaDuAdjType = 9;
1709 else if(pCoexDm->curPsTdma == 11)
1711 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
1712 pCoexDm->psTdmaDuAdjType = 9;
1714 else if(pCoexDm->curPsTdma == 9)
1716 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
1717 pCoexDm->psTdmaDuAdjType = 2;
1719 else if(pCoexDm->curPsTdma == 2)
1721 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
1722 pCoexDm->psTdmaDuAdjType = 1;
1728 if(bWifiBusy != bPreWifiBusy) //if busy / idle change
1730 bPreWifiBusy = bWifiBusy;
1731 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, pCoexDm->curPsTdma);
1735 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], ********** TDMA(on, %d) **********\n",
1736 pCoexDm->curPsTdma));
1739 if( pCoexDm->curPsTdma != 1 &&
1740 pCoexDm->curPsTdma != 2 &&
1741 pCoexDm->curPsTdma != 9 &&
1742 pCoexDm->curPsTdma != 11 )
1744 // recover to previous adjust type
1745 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
1751 halbtc8192e1ant_PsTdmaCheckForPowerSaveState(
1752 IN PBTC_COEXIST pBtCoexist,
1753 IN BOOLEAN bNewPsState
1758 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
1760 if(lpsMode) // already under LPS state
1764 // keep state under LPS, do nothing.
1768 // will leave LPS state, turn off psTdma first
1769 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1776 // will enter LPS state, turn off psTdma first
1777 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1781 // keep state under NO PS state, do nothing.
1787 halbtc8192e1ant_PowerSaveState(
1788 IN PBTC_COEXIST pBtCoexist,
1794 BOOLEAN bLowPwrDisable=FALSE;
1798 case BTC_PS_WIFI_NATIVE:
1799 // recover to original 32k low power setting
1800 bLowPwrDisable = FALSE;
1801 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1802 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
1803 pCoexSta->bForceLpsOn = FALSE;
1806 halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);
1807 halbtc8192e1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
1808 // when coex force to enter LPS, do not enter 32k low power.
1809 bLowPwrDisable = TRUE;
1810 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1811 // power save must executed before psTdma.
1812 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
1813 pCoexSta->bForceLpsOn = TRUE;
1815 case BTC_PS_LPS_OFF:
1816 halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
1817 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
1818 pCoexSta->bForceLpsOn = FALSE;
1826 halbtc8192e1ant_ActionWifiOnly(
1827 IN PBTC_COEXIST pBtCoexist
1830 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1831 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
1835 halbtc8192e1ant_MonitorBtEnableDisable(
1836 IN PBTC_COEXIST pBtCoexist
1839 static BOOLEAN bPreBtDisabled=FALSE;
1840 static u4Byte btDisableCnt=0;
1841 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
1843 // This function check if bt is disabled
1845 if( pCoexSta->highPriorityTx == 0 &&
1846 pCoexSta->highPriorityRx == 0 &&
1847 pCoexSta->lowPriorityTx == 0 &&
1848 pCoexSta->lowPriorityRx == 0)
1852 if( pCoexSta->highPriorityTx == 0xffff &&
1853 pCoexSta->highPriorityRx == 0xffff &&
1854 pCoexSta->lowPriorityTx == 0xffff &&
1855 pCoexSta->lowPriorityRx == 0xffff)
1862 bBtDisabled = FALSE;
1863 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
1864 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n"));
1869 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n",
1871 if(btDisableCnt >= 2)
1874 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
1875 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n"));
1876 halbtc8192e1ant_ActionWifiOnly(pBtCoexist);
1879 if(bPreBtDisabled != bBtDisabled)
1881 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n",
1882 (bPreBtDisabled ? "disabled":"enabled"),
1883 (bBtDisabled ? "disabled":"enabled")));
1884 bPreBtDisabled = bBtDisabled;
1890 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
1891 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
1896 //=============================================
1898 // Software Coex Mechanism start
1900 //=============================================
1902 // SCO only or SCO+PAN(HS)
1906 halbtc8192e1ant_ActionSco(
1907 IN PBTC_COEXIST pBtCoexist
1910 halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE);
1915 halbtc8192e1ant_ActionHid(
1916 IN PBTC_COEXIST pBtCoexist
1919 halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE);
1922 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
1924 halbtc8192e1ant_ActionA2dp(
1925 IN PBTC_COEXIST pBtCoexist
1928 halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1932 halbtc8192e1ant_ActionA2dpPanHs(
1933 IN PBTC_COEXIST pBtCoexist
1936 halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1940 halbtc8192e1ant_ActionPanEdr(
1941 IN PBTC_COEXIST pBtCoexist
1944 halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1949 halbtc8192e1ant_ActionPanHs(
1950 IN PBTC_COEXIST pBtCoexist
1953 halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1958 halbtc8192e1ant_ActionPanEdrA2dp(
1959 IN PBTC_COEXIST pBtCoexist
1962 halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
1966 halbtc8192e1ant_ActionPanEdrHid(
1967 IN PBTC_COEXIST pBtCoexist
1970 halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE);
1973 // HID+A2DP+PAN(EDR)
1975 halbtc8192e1ant_ActionHidA2dpPanEdr(
1976 IN PBTC_COEXIST pBtCoexist
1979 halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE);
1983 halbtc8192e1ant_ActionHidA2dp(
1984 IN PBTC_COEXIST pBtCoexist
1987 halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE);
1992 //=============================================
1994 // Non-Software Coex Mechanism start
1996 //=============================================
1998 halbtc8192e1ant_ActionWifiMultiPort(
1999 IN PBTC_COEXIST pBtCoexist
2002 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2004 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2005 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2009 halbtc8192e1ant_ActionHs(
2010 IN PBTC_COEXIST pBtCoexist
2013 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
2014 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2018 halbtc8192e1ant_ActionBtInquiry(
2019 IN PBTC_COEXIST pBtCoexist
2022 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2023 BOOLEAN bWifiConnected=FALSE, bApEnable=FALSE, bWifiBusy=FALSE, bBtBusy=FALSE;
2025 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
2026 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2027 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
2028 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
2030 if((!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask))
2032 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2033 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2035 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2037 else if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist))
2039 // SCO/HID/A2DP busy
2040 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2041 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
2043 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2045 else if ((pBtLinkInfo->bPanExist) || (bWifiBusy))
2047 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2048 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
2050 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2054 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2055 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2057 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2062 halbtc8192e1ant_ActionBtScoHidOnlyBusy(
2063 IN PBTC_COEXIST pBtCoexist,
2064 IN u1Byte wifiStatus
2067 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2068 BOOLEAN bWifiConnected=FALSE;
2069 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
2071 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2073 // tdma and coex table
2075 if(pBtLinkInfo->bScoExist)
2077 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
2078 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);
2082 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2083 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);
2088 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(
2089 IN PBTC_COEXIST pBtCoexist,
2090 IN u1Byte wifiStatus
2095 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2096 btRssiState = halbtc8192e1ant_BtRssiState(2, 28, 0);
2098 if ( (pCoexSta->lowPriorityRx >= 1000) && (pCoexSta->lowPriorityRx != 65535) )
2100 pBtLinkInfo->bSlaveRole = TRUE;
2104 pBtLinkInfo->bSlaveRole = FALSE;
2107 if(pBtLinkInfo->bHidOnly) //HID
2109 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);
2110 pCoexDm->bAutoTdmaAdjust = FALSE;
2113 else if(pBtLinkInfo->bA2dpOnly) //A2DP
2115 if(BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus)
2117 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
2118 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2119 pCoexDm->bAutoTdmaAdjust = FALSE;
2123 halbtc8192e1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);
2125 if (pCoexSta->bCCKLock)
2126 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3);
2129 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2130 pCoexDm->bAutoTdmaAdjust = TRUE;
2133 else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) ||
2134 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP)
2136 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
2137 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2138 pCoexDm->bAutoTdmaAdjust = FALSE;
2140 else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) //HID+A2DP
2142 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2143 pCoexDm->bAutoTdmaAdjust = FALSE;
2145 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3);
2147 else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP)
2149 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2150 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2151 pCoexDm->bAutoTdmaAdjust = FALSE;
2155 //BT no-profile busy (0x9)
2156 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
2157 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2158 pCoexDm->bAutoTdmaAdjust = FALSE;
2163 halbtc8192e1ant_ActionWifiNotConnected(
2164 IN PBTC_COEXIST pBtCoexist
2168 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2170 // tdma and coex table
2171 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
2172 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2176 halbtc8192e1ant_ActionWifiNotConnectedScan(
2177 IN PBTC_COEXIST pBtCoexist
2180 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2182 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2184 // tdma and coex table
2185 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
2187 if (pBtLinkInfo->bA2dpExist)
2189 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
2190 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2192 else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)
2194 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
2195 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2199 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
2200 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2203 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2204 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
2206 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
2207 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN);
2212 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2213 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2218 halbtc8192e1ant_ActionWifiNotConnectedAssoAuth(
2219 IN PBTC_COEXIST pBtCoexist
2222 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2224 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2226 // tdma and coex table
2227 if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) )
2229 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
2230 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2232 else if (pBtLinkInfo->bPanExist)
2234 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
2235 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2239 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2240 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2245 halbtc8192e1ant_ActionWifiConnectedScan(
2246 IN PBTC_COEXIST pBtCoexist
2249 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2251 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2253 // tdma and coex table
2254 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
2256 if (pBtLinkInfo->bA2dpExist)
2258 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
2259 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2261 else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)
2263 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
2264 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2268 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
2269 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2272 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2273 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
2275 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
2276 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN);
2281 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2282 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2287 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(
2288 IN PBTC_COEXIST pBtCoexist
2291 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2293 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2295 // tdma and coex table
2296 if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist))
2298 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
2299 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2301 else if(pBtLinkInfo->bPanExist)
2303 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
2304 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
2308 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2309 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2314 halbtc8192e1ant_ActionWifiConnected(
2315 IN PBTC_COEXIST pBtCoexist
2318 BOOLEAN bWifiBusy=FALSE;
2319 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
2320 BOOLEAN bUnder4way=FALSE, bApEnable=FALSE;
2323 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect()===>\n"));
2325 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
2328 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
2329 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));
2333 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2334 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2335 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2336 if(bScan || bLink || bRoam)
2339 halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist);
2341 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
2342 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));
2346 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
2347 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
2350 if(!bApEnable && BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
2352 if(pBtCoexist->btLinkInfo.bA2dpOnly) //A2DP
2355 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2358 if (pCoexSta->nScanAPNum >= BT_8192E_1ANT_WIFI_NOISY_THRESH) //no force LPS, no PS-TDMA, use pure TDMA
2360 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2364 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
2368 else if ((pCoexSta->bPanExist == FALSE) && (pCoexSta->bA2dpExist == FALSE) && (pCoexSta->bHidExist == FALSE))
2369 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2371 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
2374 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2376 // tdma and coex table
2379 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
2381 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
2382 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE);
2384 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2385 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
2387 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
2388 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE);
2392 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2394 if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 )
2395 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2397 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2402 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
2404 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
2405 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
2407 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2408 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
2410 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
2411 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
2415 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2417 if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 )
2418 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2420 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2426 halbtc8192e1ant_RunSwCoexistMechanism(
2427 IN PBTC_COEXIST pBtCoexist
2432 algorithm = halbtc8192e1ant_ActionAlgorithm(pBtCoexist);
2433 pCoexDm->curAlgorithm = algorithm;
2435 if(halbtc8192e1ant_IsCommonAction(pBtCoexist))
2441 switch(pCoexDm->curAlgorithm)
2443 case BT_8192E_1ANT_COEX_ALGO_SCO:
2444 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = SCO.\n"));
2445 //halbtc8192e1ant_ActionSco(pBtCoexist);
2447 case BT_8192E_1ANT_COEX_ALGO_HID:
2448 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID.\n"));
2449 //halbtc8192e1ant_ActionHid(pBtCoexist);
2451 case BT_8192E_1ANT_COEX_ALGO_A2DP:
2452 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP.\n"));
2453 //halbtc8192e1ant_ActionA2dp(pBtCoexist);
2455 case BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS:
2456 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
2457 //halbtc8192e1ant_ActionA2dpPanHs(pBtCoexist);
2459 case BT_8192E_1ANT_COEX_ALGO_PANEDR:
2460 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
2461 //halbtc8192e1ant_ActionPanEdr(pBtCoexist);
2463 case BT_8192E_1ANT_COEX_ALGO_PANHS:
2464 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HS mode.\n"));
2465 //halbtc8192e1ant_ActionPanHs(pBtCoexist);
2467 case BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP:
2468 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
2469 //halbtc8192e1ant_ActionPanEdrA2dp(pBtCoexist);
2471 case BT_8192E_1ANT_COEX_ALGO_PANEDR_HID:
2472 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
2473 //halbtc8192e1ant_ActionPanEdrHid(pBtCoexist);
2475 case BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
2476 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
2477 //halbtc8192e1ant_ActionHidA2dpPanEdr(pBtCoexist);
2479 case BT_8192E_1ANT_COEX_ALGO_HID_A2DP:
2480 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
2481 //halbtc8192e1ant_ActionHidA2dp(pBtCoexist);
2484 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
2485 //halbtc8192e1ant_CoexAllOff(pBtCoexist);
2488 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
2493 halbtc8192e1ant_RunCoexistMechanism(
2494 IN PBTC_COEXIST pBtCoexist
2497 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2498 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
2499 BOOLEAN bIncreaseScanDevNum=FALSE;
2500 BOOLEAN bBtCtrlAggBufSize=FALSE;
2501 BOOLEAN bMiracastPlusBt=FALSE;
2502 u1Byte aggBufSize=5;
2503 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
2504 u4Byte wifiLinkStatus=0;
2505 u4Byte numOfWifiLink=0;
2507 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n"));
2509 if(pBtCoexist->bManualControl)
2511 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
2515 if(pBtCoexist->bStopCoexDm)
2517 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
2521 if(pCoexSta->bUnderIps)
2523 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n"));
2527 if( (BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
2528 (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2529 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
2531 bIncreaseScanDevNum = TRUE;
2534 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum);
2535 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2537 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
2538 numOfWifiLink = wifiLinkStatus>>16;
2540 if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED))
2542 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) );
2544 if(pBtLinkInfo->bBtLinkExist)
2546 halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1);
2547 bMiracastPlusBt = TRUE;
2551 halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
2552 bMiracastPlusBt = FALSE;
2554 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);
2555 halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
2557 if ( (pBtLinkInfo->bA2dpExist) && (pCoexSta->bC2hBtInquiryPage) )
2559 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") );
2560 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
2563 halbtc8192e1ant_ActionWifiMultiPort(pBtCoexist);
2569 bMiracastPlusBt = FALSE;
2570 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);
2573 if ( (pBtLinkInfo->bBtLinkExist) && (bWifiConnected) )
2575 halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1);
2577 if(pBtLinkInfo->bScoExist)
2578 halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x5);
2580 halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8);
2582 halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE);
2583 halbtc8192e1ant_RunSwCoexistMechanism(pBtCoexist); //just print debug message
2587 halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
2589 halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5);
2591 halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
2592 halbtc8192e1ant_RunSwCoexistMechanism(pBtCoexist); ////just print debug message
2595 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
2596 if(pCoexSta->bC2hBtInquiryPage)
2598 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") );
2599 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
2604 halbtc8192e1ant_ActionHs(pBtCoexist);
2611 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
2613 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is non connected-idle !!!\n"));
2615 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2616 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2617 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2619 if(bScan || bLink || bRoam)
2622 halbtc8192e1ant_ActionWifiNotConnectedScan(pBtCoexist);
2624 halbtc8192e1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
2627 halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
2629 else // wifi LPS/Busy
2631 halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
2636 halbtc8192e1ant_InitCoexDm(
2637 IN PBTC_COEXIST pBtCoexist
2640 // force to reset coex mechanism
2643 halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE);
2645 //halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
2646 halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
2648 pCoexSta->popEventCnt = 0;
2652 halbtc8192e1ant_InitHwConfig(
2653 IN PBTC_COEXIST pBtCoexist,
2654 IN BOOLEAN bWifiOnly
2661 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Init HW Config!!\n"));
2663 // antenna sw ctrl to bt
2664 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, TRUE, FALSE);
2666 halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
2668 // antenna switch control parameter
2669 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x858, 0x55555555);
2672 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1);
2674 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
2677 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
2679 // enable counter statistics
2680 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
2683 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20);
2684 // enable mailbox interface
2685 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x40);
2687 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x40, u2Tmp);
2689 // enable PTA I2C mailbox
2690 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x101);
2692 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x101, u1Tmp);
2694 // enable bt clock when wifi is disabled.
2695 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x93);
2697 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x93, u1Tmp);
2698 // enable bt clock when suspend.
2699 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7);
2701 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x7, u1Tmp);
2707 halbtc8192e1ant_WifiOffHwCfg(
2708 IN PBTC_COEXIST pBtCoexist
2711 // set wlan_act to low
2712 //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
2716 //============================================================
2717 // work around function start with wa_halbtc8192e1ant_
2718 //============================================================
2719 //============================================================
2720 // extern function start with EXhalbtc8192e1ant_
2721 //============================================================
2723 EXhalbtc8192e1ant_PowerOnSetting(
2724 IN PBTC_COEXIST pBtCoexist
2728 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
2732 pBtCoexist->bStopCoexDm = TRUE;
2734 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20);
2736 // enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly.
2737 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
2738 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1);
2741 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
2743 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
2746 // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info)
2747 // Local setting bit define
2748 // BIT0: "0" for no antenna inverse; "1" for antenna inverse
2749 // BIT1: "0" for internal switch; "1" for external switch
2750 // BIT2: "0" for one antenna; "1" for two antenna
2751 // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0
2752 if(pBtCoexist->chipInterface == BTC_INTF_USB)
2754 // fixed at S0 for USB interface
2755 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
2757 u1Tmp |= 0x1; // antenna inverse
2758 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);
2760 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
2764 // for PCIE and SDIO interface, we check efuse 0xc3[6]
2765 if(pBoardInfo->singleAntPath == 0)
2768 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
2769 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
2771 else if(pBoardInfo->singleAntPath == 1)
2774 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
2775 u1Tmp |= 0x1; // antenna inverse
2776 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
2779 if(pBtCoexist->chipInterface == BTC_INTF_PCI)
2781 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp);
2783 else if(pBtCoexist->chipInterface == BTC_INTF_SDIO)
2785 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp);
2792 EXhalbtc8192e1ant_PreLoadFirmware(
2793 IN PBTC_COEXIST pBtCoexist
2799 EXhalbtc8192e1ant_InitHwConfig(
2800 IN PBTC_COEXIST pBtCoexist,
2801 IN BOOLEAN bWifiOnly
2804 halbtc8192e1ant_InitHwConfig(pBtCoexist, bWifiOnly);
2805 pBtCoexist->bStopCoexDm = FALSE;
2809 EXhalbtc8192e1ant_InitCoexDm(
2810 IN PBTC_COEXIST pBtCoexist
2813 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n"));
2815 pBtCoexist->bStopCoexDm = FALSE;
2817 halbtc8192e1ant_InitCoexDm(pBtCoexist);
2819 halbtc8192e1ant_QueryBtInfo(pBtCoexist);
2823 EXhalbtc8192e1ant_DisplayCoexInfo(
2824 IN PBTC_COEXIST pBtCoexist
2827 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
2828 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
2829 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2830 pu1Byte cliBuf=pBtCoexist->cliBuf;
2831 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
2833 u4Byte fwVer=0, btPatchVer=0;
2835 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
2838 if(pBtCoexist->bManualControl)
2840 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
2842 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
2845 if(pBtCoexist->bStopCoexDm)
2847 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");
2849 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
2853 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
2854 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
2857 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
2858 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
2861 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
2862 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
2863 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
2864 GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer);
2867 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \
2868 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
2869 pCoexDm->wifiChnlInfo[2]);
2873 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
2875 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
2877 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
2880 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
2881 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
2882 ( (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
2883 pCoexSta->btRssi, pCoexSta->btRetryCnt);
2886 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
2887 pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);
2889 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
2891 btInfoExt = pCoexSta->btInfoExt;
2892 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
2893 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
2896 for(i=0; i<BT_INFO_SRC_8192E_1ANT_MAX; i++)
2898 if(pCoexSta->btInfoC2hCnt[i])
2900 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8192e1Ant[i], \
2901 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
2902 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
2903 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
2904 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
2909 if(!pBtCoexist->bManualControl)
2912 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
2915 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \
2916 (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"),
2917 pBtCoexist->btInfo.aggBufSize);
2919 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \
2920 pBtCoexist->btInfo.raMask);
2924 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
2927 psTdmaCase = pCoexDm->curPsTdma;
2928 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
2929 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
2930 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
2931 pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
2934 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
2935 pCoexDm->errorCondition);
2938 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \
2939 pCoexDm->bCurIgnoreWlanAct);
2944 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
2947 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc04);
2948 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xd04);
2949 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x90c);
2950 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xc04/ 0xd04/ 0x90c", \
2951 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
2954 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
2955 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \
2959 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x92c);
2960 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
2961 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x92c/ 0x930", \
2962 (u1Tmp[0]), u4Tmp[0]);
2965 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
2966 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4f);
2967 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x40/ 0x4f", \
2968 u1Tmp[0], u1Tmp[1]);
2971 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
2972 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
2973 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
2974 u4Tmp[0], u1Tmp[0]);
2977 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
2978 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
2982 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
2983 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
2984 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
2985 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
2986 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
2987 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
2990 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \
2991 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
2993 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
2994 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
2996 #if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 1)
2997 halbtc8192e1ant_MonitorBtCtr(pBtCoexist);
3000 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
3004 EXhalbtc8192e1ant_IpsNotify(
3005 IN PBTC_COEXIST pBtCoexist,
3011 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
3014 if(BTC_IPS_ENTER == type)
3016 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n"));
3017 pCoexSta->bUnderIps = TRUE;
3019 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
3020 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3021 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
3023 else if(BTC_IPS_LEAVE == type)
3025 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n"));
3026 pCoexSta->bUnderIps = FALSE;
3028 halbtc8192e1ant_InitHwConfig(pBtCoexist, FALSE);
3029 halbtc8192e1ant_InitCoexDm(pBtCoexist);
3030 halbtc8192e1ant_QueryBtInfo(pBtCoexist);
3035 EXhalbtc8192e1ant_LpsNotify(
3036 IN PBTC_COEXIST pBtCoexist,
3040 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
3043 if(BTC_LPS_ENABLE == type)
3045 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n"));
3046 pCoexSta->bUnderLps = TRUE;
3048 else if(BTC_LPS_DISABLE == type)
3050 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n"));
3051 pCoexSta->bUnderLps = FALSE;
3056 EXhalbtc8192e1ant_ScanNotify(
3057 IN PBTC_COEXIST pBtCoexist,
3061 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
3062 u4Byte wifiLinkStatus=0;
3063 u4Byte numOfWifiLink=0;
3064 BOOLEAN bBtCtrlAggBufSize=FALSE;
3065 u1Byte aggBufSize=5;
3067 u1Byte u1Tmpa, u1Tmpb;
3070 if(pBtCoexist->bManualControl ||
3071 pBtCoexist->bStopCoexDm )
3074 if(BTC_SCAN_START == type)
3076 pCoexSta->bWiFiIsHighPriTask = TRUE;
3077 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));
3079 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue
3080 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
3081 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
3082 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
3085 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n",
3086 u4Tmp, u1Tmpa, u1Tmpb));
3090 pCoexSta->bWiFiIsHighPriTask = FALSE;
3091 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));
3093 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum);
3096 if(pBtCoexist->btInfo.bBtDisabled)
3099 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3100 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3102 halbtc8192e1ant_QueryBtInfo(pBtCoexist);
3104 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
3105 numOfWifiLink = wifiLinkStatus>>16;
3106 if(numOfWifiLink >= 2)
3108 halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
3109 halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
3110 halbtc8192e1ant_ActionWifiMultiPort(pBtCoexist);
3114 if(pCoexSta->bC2hBtInquiryPage)
3116 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
3121 halbtc8192e1ant_ActionHs(pBtCoexist);
3125 if(BTC_SCAN_START == type)
3127 //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));
3128 if(!bWifiConnected) // non-connected scan
3130 halbtc8192e1ant_ActionWifiNotConnectedScan(pBtCoexist);
3132 else // wifi is connected
3134 halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist);
3137 else if(BTC_SCAN_FINISH == type)
3139 //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));
3140 if(!bWifiConnected) // non-connected scan
3142 halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
3146 halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
3152 EXhalbtc8192e1ant_ConnectNotify(
3153 IN PBTC_COEXIST pBtCoexist,
3157 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
3158 u4Byte wifiLinkStatus=0;
3159 u4Byte numOfWifiLink=0;
3160 BOOLEAN bBtCtrlAggBufSize=FALSE;
3161 u1Byte aggBufSize=5;
3163 if(pBtCoexist->bManualControl ||
3164 pBtCoexist->bStopCoexDm ||
3165 pBtCoexist->btInfo.bBtDisabled )
3168 if(BTC_ASSOCIATE_START == type)
3170 pCoexSta->bWiFiIsHighPriTask = TRUE;
3171 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));
3172 pCoexDm->nArpCnt = 0;
3176 pCoexSta->bWiFiIsHighPriTask = FALSE;
3177 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));
3178 //pCoexDm->nArpCnt = 0;
3181 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
3182 numOfWifiLink = wifiLinkStatus>>16;
3183 if(numOfWifiLink >= 2)
3185 halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
3186 halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
3187 halbtc8192e1ant_ActionWifiMultiPort(pBtCoexist);
3191 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3192 if(pCoexSta->bC2hBtInquiryPage)
3194 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
3199 halbtc8192e1ant_ActionHs(pBtCoexist);
3203 if(BTC_ASSOCIATE_START == type)
3205 //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));
3206 halbtc8192e1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
3208 else if(BTC_ASSOCIATE_FINISH == type)
3210 //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));
3212 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3213 if(!bWifiConnected) // non-connected scan
3215 halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
3219 halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
3225 EXhalbtc8192e1ant_MediaStatusNotify(
3226 IN PBTC_COEXIST pBtCoexist,
3230 u1Byte H2C_Parameter[3] ={0};
3232 u1Byte wifiCentralChnl;
3233 BOOLEAN bWifiUnderBMode = FALSE;
3235 if(pBtCoexist->bManualControl ||
3236 pBtCoexist->bStopCoexDm ||
3237 pBtCoexist->btInfo.bBtDisabled )
3240 if(BTC_MEDIA_CONNECT == type)
3242 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n"));
3244 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
3246 //Set CCK Tx/Rx high Pri except 11b mode
3247 if (bWifiUnderBMode)
3249 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); //CCK Tx
3250 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x00); //CCK Rx
3254 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10); //CCK Tx
3255 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); //CCK Rx
3258 pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
3259 pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
3260 pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
3261 pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
3265 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n"));
3266 pCoexDm->nArpCnt = 0;
3268 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x0); //CCK Tx
3269 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x0); //CCK Rx
3272 // only 2.4G we need to inform bt the chnl mask
3273 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
3274 if( (BTC_MEDIA_CONNECT == type) &&
3275 (wifiCentralChnl <= 14) )
3277 //H2C_Parameter[0] = 0x1;
3278 H2C_Parameter[0] = 0x0;
3279 H2C_Parameter[1] = wifiCentralChnl;
3280 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3281 if(BTC_WIFI_BW_HT40 == wifiBw)
3282 H2C_Parameter[2] = 0x30;
3284 H2C_Parameter[2] = 0x20;
3287 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
3288 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
3289 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
3291 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n",
3292 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
3294 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
3298 EXhalbtc8192e1ant_SpecialPacketNotify(
3299 IN PBTC_COEXIST pBtCoexist,
3303 BOOLEAN bBtHsOn=FALSE;
3304 u4Byte wifiLinkStatus=0;
3305 u4Byte numOfWifiLink=0;
3306 BOOLEAN bBtCtrlAggBufSize=FALSE;
3307 u1Byte aggBufSize=5;
3309 if(pBtCoexist->bManualControl ||
3310 pBtCoexist->bStopCoexDm ||
3311 pBtCoexist->btInfo.bBtDisabled )
3314 if( BTC_PACKET_DHCP == type ||
3315 BTC_PACKET_EAPOL == type ||
3316 BTC_PACKET_ARP == type )
3318 if(BTC_PACKET_ARP == type)
3320 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet ARP notify\n"));
3323 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt));
3325 if(pCoexDm->nArpCnt >= 10) // if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist)
3327 pCoexSta->bWiFiIsHighPriTask = FALSE;
3331 pCoexSta->bWiFiIsHighPriTask = TRUE;
3336 pCoexSta->bWiFiIsHighPriTask = TRUE;
3337 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet DHCP or EAPOL notify\n"));
3342 pCoexSta->bWiFiIsHighPriTask = FALSE;
3343 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet [Type = %d] notify\n", type));
3346 pCoexSta->specialPktPeriodCnt = 0;
3348 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
3349 numOfWifiLink = wifiLinkStatus>>16;
3350 if(numOfWifiLink >= 2)
3352 halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
3353 halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
3354 halbtc8192e1ant_ActionWifiMultiPort(pBtCoexist);
3358 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3359 if(pCoexSta->bC2hBtInquiryPage)
3361 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
3366 halbtc8192e1ant_ActionHs(pBtCoexist);
3370 if( BTC_PACKET_DHCP == type ||
3371 BTC_PACKET_EAPOL == type ||
3372 ( (BTC_PACKET_ARP == type ) && (pCoexSta->bWiFiIsHighPriTask) ) )
3374 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
3379 EXhalbtc8192e1ant_BtInfoNotify(
3380 IN PBTC_COEXIST pBtCoexist,
3385 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
3387 u1Byte i, rspSource=0;
3388 BOOLEAN bWifiConnected=FALSE;
3389 BOOLEAN bBtBusy=FALSE;
3391 pCoexSta->bC2hBtInfoReqSent = FALSE;
3393 rspSource = tmpBuf[0]&0xf;
3394 if(rspSource >= BT_INFO_SRC_8192E_1ANT_MAX)
3395 rspSource = BT_INFO_SRC_8192E_1ANT_WIFI_FW;
3396 pCoexSta->btInfoC2hCnt[rspSource]++;
3398 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
3399 for(i=0; i<length; i++)
3401 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
3406 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i]));
3410 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i]));
3414 if(BT_INFO_SRC_8192E_1ANT_WIFI_FW != rspSource)
3416 pCoexSta->btRetryCnt = // [3:0]
3417 pCoexSta->btInfoC2h[rspSource][2]&0xf;
3419 if (pCoexSta->btRetryCnt >= 1)
3420 pCoexSta->popEventCnt++;
3422 if (pCoexSta->btInfoC2h[rspSource][2]&0x20)
3423 pCoexSta->bC2hBtPage = TRUE;
3425 pCoexSta->bC2hBtPage = FALSE;
3428 pCoexSta->btInfoC2h[rspSource][3]*2-90;
3429 //pCoexSta->btInfoC2h[rspSource][3]*2+10;
3431 pCoexSta->btInfoExt =
3432 pCoexSta->btInfoC2h[rspSource][4];
3434 pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
3435 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
3436 if(!pCoexSta->bBtTxRxMask)
3438 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */
3439 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n"));
3440 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15);
3443 // Here we need to resend some wifi info to BT
3444 // because bt is reset and loss of the info.
3445 if(pCoexSta->btInfoExt & BIT1)
3447 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
3448 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3451 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
3455 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3459 if(pCoexSta->btInfoExt & BIT3)
3461 if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm)
3463 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
3464 halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
3469 // BT already NOT ignore Wlan active, do nothing here.
3471 #if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0)
3472 if( (pCoexSta->btInfoExt & BIT4) )
3474 // BT auto report already enabled, do nothing
3478 halbtc8192e1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);
3483 // check BIT2 first ==> check if bt is under inquiry or page scan
3484 if(btInfo & BT_INFO_8192E_1ANT_B_INQ_PAGE)
3485 pCoexSta->bC2hBtInquiryPage = TRUE;
3487 pCoexSta->bC2hBtInquiryPage = FALSE;
3489 // set link exist status
3490 if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION))
3492 pCoexSta->bBtLinkExist = FALSE;
3493 pCoexSta->bPanExist = FALSE;
3494 pCoexSta->bA2dpExist = FALSE;
3495 pCoexSta->bHidExist = FALSE;
3496 pCoexSta->bScoExist = FALSE;
3498 else // connection exists
3500 pCoexSta->bBtLinkExist = TRUE;
3501 if(btInfo & BT_INFO_8192E_1ANT_B_FTP)
3502 pCoexSta->bPanExist = TRUE;
3504 pCoexSta->bPanExist = FALSE;
3505 if(btInfo & BT_INFO_8192E_1ANT_B_A2DP)
3506 pCoexSta->bA2dpExist = TRUE;
3508 pCoexSta->bA2dpExist = FALSE;
3509 if(btInfo & BT_INFO_8192E_1ANT_B_HID)
3510 pCoexSta->bHidExist = TRUE;
3512 pCoexSta->bHidExist = FALSE;
3513 if(btInfo & BT_INFO_8192E_1ANT_B_SCO_ESCO)
3514 pCoexSta->bScoExist = TRUE;
3516 pCoexSta->bScoExist = FALSE;
3519 halbtc8192e1ant_UpdateBtLinkInfo(pBtCoexist);
3521 btInfo = btInfo & 0x1f; //mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41)
3523 if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION))
3525 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
3526 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
3528 else if(btInfo == BT_INFO_8192E_1ANT_B_CONNECTION) // connection exists but no busy
3530 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE;
3531 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
3533 else if((btInfo&BT_INFO_8192E_1ANT_B_SCO_ESCO) ||
3534 (btInfo&BT_INFO_8192E_1ANT_B_SCO_BUSY))
3536 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_SCO_BUSY;
3537 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
3539 else if(btInfo&BT_INFO_8192E_1ANT_B_ACL_BUSY)
3541 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
3542 pCoexDm->bAutoTdmaAdjust = FALSE;
3543 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_ACL_BUSY;
3544 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
3548 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_MAX;
3549 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
3552 if( (BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
3553 (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
3554 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
3558 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
3560 halbtc8192e1ant_RunCoexistMechanism(pBtCoexist);
3564 EXhalbtc8192e1ant_RfStatusNotify(
3565 IN PBTC_COEXIST pBtCoexist,
3570 u1Byte u1Tmpa,u1Tmpb, u1Tmpc;
3572 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF Status notify\n"));
3574 if(BTC_RF_ON == type)
3576 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned ON!!\n"));
3577 pBtCoexist->bStopCoexDm = FALSE;
3579 else if(BTC_RF_OFF == type)
3581 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned OFF!!\n"));
3583 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3584 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
3585 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
3587 halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
3588 pBtCoexist->bStopCoexDm = TRUE;
3590 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
3591 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
3592 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
3593 u1Tmpc = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);
3596 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x, 0x76e=0x%x\n",
3597 u4Tmp, u1Tmpa, u1Tmpb, u1Tmpc));
3603 EXhalbtc8192e1ant_HaltNotify(
3604 IN PBTC_COEXIST pBtCoexist
3609 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n"));
3611 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3612 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
3613 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
3615 halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
3617 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3619 pBtCoexist->bStopCoexDm = TRUE;
3623 EXhalbtc8192e1ant_PnpNotify(
3624 IN PBTC_COEXIST pBtCoexist,
3628 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n"));
3630 if(BTC_WIFI_PNP_SLEEP == pnpState)
3632 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n"));
3634 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3635 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
3636 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
3637 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
3639 pBtCoexist->bStopCoexDm = TRUE;
3641 else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
3643 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n"));
3644 pBtCoexist->bStopCoexDm = FALSE;
3645 halbtc8192e1ant_InitHwConfig(pBtCoexist, FALSE);
3646 halbtc8192e1ant_InitCoexDm(pBtCoexist);
3647 halbtc8192e1ant_QueryBtInfo(pBtCoexist);
3652 EXhalbtc8192e1ant_CoexDmReset(
3653 IN PBTC_COEXIST pBtCoexist
3656 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], *****************Coex DM Reset*****************\n"));
3658 halbtc8192e1ant_InitHwConfig(pBtCoexist, FALSE);
3659 //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
3660 //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x2, 0xfffff, 0x0);
3661 halbtc8192e1ant_InitCoexDm(pBtCoexist);
3665 EXhalbtc8192e1ant_Periodical(
3666 IN PBTC_COEXIST pBtCoexist
3669 static u1Byte disVerInfoCnt=0;
3670 u4Byte fwVer=0, btPatchVer=0;
3671 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
3672 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
3674 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n"));
3676 if(disVerInfoCnt <= 5)
3679 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));
3680 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n",
3681 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));
3682 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n",
3683 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
3684 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
3685 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
3686 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",
3687 GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer));
3688 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));
3691 #if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0)
3692 halbtc8192e1ant_QueryBtInfo(pBtCoexist);
3693 halbtc8192e1ant_MonitorBtEnableDisable(pBtCoexist);
3695 halbtc8192e1ant_MonitorBtCtr(pBtCoexist);
3696 halbtc8192e1ant_MonitorWiFiCtr(pBtCoexist);
3698 if( halbtc8192e1ant_IsWifiStatusChanged(pBtCoexist) ||
3699 pCoexDm->bAutoTdmaAdjust )
3702 halbtc8192e1ant_RunCoexistMechanism(pBtCoexist);
3705 pCoexSta->specialPktPeriodCnt++;
3711 EXhalbtc8192e1ant_DbgControl(
3712 IN PBTC_COEXIST pBtCoexist,
3720 case BTC_DBG_SET_COEX_NORMAL:
3721 pBtCoexist->bManualControl = FALSE;
3722 halbtc8192e1ant_InitCoexDm(pBtCoexist);
3724 case BTC_DBG_SET_COEX_WIFI_ONLY:
3725 pBtCoexist->bManualControl = TRUE;
3726 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3727 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
3729 case BTC_DBG_SET_COEX_BT_ONLY: