1 //============================================================
\r
4 // This file is for 8821A_1ANT Co-exist mechanism
\r
7 // 2012/11/15 Cosa first check in.
\r
9 //============================================================
\r
11 //============================================================
\r
13 //============================================================
\r
14 #include "Mp_Precomp.h"
\r
15 #if(BT_30_SUPPORT == 1)
\r
16 //============================================================
\r
17 // Global variables, these are static variables
\r
18 //============================================================
\r
19 static COEX_DM_8821A_1ANT GLCoexDm8821a1Ant;
\r
20 static PCOEX_DM_8821A_1ANT pCoexDm=&GLCoexDm8821a1Ant;
\r
21 static COEX_STA_8821A_1ANT GLCoexSta8821a1Ant;
\r
22 static PCOEX_STA_8821A_1ANT pCoexSta=&GLCoexSta8821a1Ant;
\r
24 const char *const GLBtInfoSrc8821a1Ant[]={
\r
27 "BT Info[bt auto report]",
\r
30 u4Byte GLCoexVerDate8821a1Ant=20140306;
\r
31 u4Byte GLCoexVer8821a1Ant=0x4b;
\r
33 //============================================================
\r
34 // local function proto type if needed
\r
35 //============================================================
\r
36 //============================================================
\r
37 // local function start with halbtc8821a1ant_
\r
38 //============================================================
\r
40 halbtc8821a1ant_BtRssiState(
\r
47 u1Byte btRssiState=pCoexSta->preBtRssiState;
\r
49 btRssi = pCoexSta->btRssi;
\r
53 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
54 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
56 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT))
\r
58 btRssiState = BTC_RSSI_STATE_HIGH;
\r
59 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
\r
63 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
64 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
\r
69 if(btRssi < rssiThresh)
\r
71 btRssiState = BTC_RSSI_STATE_LOW;
\r
72 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
\r
76 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
77 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
\r
81 else if(levelNum == 3)
\r
83 if(rssiThresh > rssiThresh1)
\r
85 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
\r
86 return pCoexSta->preBtRssiState;
\r
89 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
90 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
92 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT))
\r
94 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
95 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
\r
99 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
100 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
\r
103 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
\r
104 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
\r
106 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT))
\r
108 btRssiState = BTC_RSSI_STATE_HIGH;
\r
109 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
\r
111 else if(btRssi < rssiThresh)
\r
113 btRssiState = BTC_RSSI_STATE_LOW;
\r
114 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
\r
118 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
119 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
\r
124 if(btRssi < rssiThresh1)
\r
126 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
127 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
\r
131 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
132 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
\r
137 pCoexSta->preBtRssiState = btRssiState;
\r
139 return btRssiState;
\r
143 halbtc8821a1ant_WifiRssiState(
\r
144 IN PBTC_COEXIST pBtCoexist,
\r
146 IN u1Byte levelNum,
\r
147 IN u1Byte rssiThresh,
\r
148 IN u1Byte rssiThresh1
\r
152 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
\r
154 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
158 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
159 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
161 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT))
\r
163 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
164 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
168 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
169 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
174 if(wifiRssi < rssiThresh)
\r
176 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
177 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
181 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
182 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
186 else if(levelNum == 3)
\r
188 if(rssiThresh > rssiThresh1)
\r
190 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
\r
191 return pCoexSta->preWifiRssiState[index];
\r
194 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
195 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
197 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT))
\r
199 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
200 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
204 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
205 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
208 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
\r
209 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
\r
211 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT))
\r
213 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
214 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
216 else if(wifiRssi < rssiThresh)
\r
218 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
219 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
223 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
224 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
\r
229 if(wifiRssi < rssiThresh1)
\r
231 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
232 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
236 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
237 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
242 pCoexSta->preWifiRssiState[index] = wifiRssiState;
\r
244 return wifiRssiState;
\r
248 halbtc8821a1ant_UpdateRaMask(
\r
249 IN PBTC_COEXIST pBtCoexist,
\r
250 IN BOOLEAN bForceExec,
\r
251 IN u4Byte disRateMask
\r
254 pCoexDm->curRaMask = disRateMask;
\r
256 if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask))
\r
258 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask);
\r
260 pCoexDm->preRaMask = pCoexDm->curRaMask;
\r
264 halbtc8821a1ant_AutoRateFallbackRetry(
\r
265 IN PBTC_COEXIST pBtCoexist,
\r
266 IN BOOLEAN bForceExec,
\r
270 BOOLEAN bWifiUnderBMode=FALSE;
\r
272 pCoexDm->curArfrType = type;
\r
274 if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType))
\r
276 switch(pCoexDm->curArfrType)
\r
278 case 0: // normal mode
\r
279 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1);
\r
280 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2);
\r
283 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
\r
284 if(bWifiUnderBMode)
\r
286 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
\r
287 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101);
\r
291 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
\r
292 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201);
\r
300 pCoexDm->preArfrType = pCoexDm->curArfrType;
\r
304 halbtc8821a1ant_RetryLimit(
\r
305 IN PBTC_COEXIST pBtCoexist,
\r
306 IN BOOLEAN bForceExec,
\r
310 pCoexDm->curRetryLimitType = type;
\r
312 if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType))
\r
314 switch(pCoexDm->curRetryLimitType)
\r
316 case 0: // normal mode
\r
317 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit);
\r
319 case 1: // retry limit=8
\r
320 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808);
\r
327 pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType;
\r
331 halbtc8821a1ant_AmpduMaxTime(
\r
332 IN PBTC_COEXIST pBtCoexist,
\r
333 IN BOOLEAN bForceExec,
\r
337 pCoexDm->curAmpduTimeType = type;
\r
339 if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType))
\r
341 switch(pCoexDm->curAmpduTimeType)
\r
343 case 0: // normal mode
\r
344 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime);
\r
346 case 1: // AMPDU timw = 0x38 * 32us
\r
347 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38);
\r
354 pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType;
\r
358 halbtc8821a1ant_LimitedTx(
\r
359 IN PBTC_COEXIST pBtCoexist,
\r
360 IN BOOLEAN bForceExec,
\r
361 IN u1Byte raMaskType,
\r
362 IN u1Byte arfrType,
\r
363 IN u1Byte retryLimitType,
\r
364 IN u1Byte ampduTimeType
\r
369 case 0: // normal mode
\r
370 halbtc8821a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0);
\r
372 case 1: // disable cck 1/2
\r
373 halbtc8821a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003);
\r
375 case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4
\r
376 halbtc8821a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7);
\r
382 halbtc8821a1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType);
\r
383 halbtc8821a1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType);
\r
384 halbtc8821a1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType);
\r
388 halbtc8821a1ant_LimitedRx(
\r
389 IN PBTC_COEXIST pBtCoexist,
\r
390 IN BOOLEAN bForceExec,
\r
391 IN BOOLEAN bRejApAggPkt,
\r
392 IN BOOLEAN bBtCtrlAggBufSize,
\r
393 IN u1Byte aggBufSize
\r
396 BOOLEAN bRejectRxAgg=bRejApAggPkt;
\r
397 BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize;
\r
398 u1Byte rxAggSize=aggBufSize;
\r
400 //============================================
\r
401 // Rx Aggregation related setting
\r
402 //============================================
\r
403 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);
\r
404 // decide BT control aggregation buf size or not
\r
405 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);
\r
406 // aggregation buf size, only work when BT control Rx aggregation size.
\r
407 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
\r
408 // real update aggregation setting
\r
409 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
\r
415 halbtc8821a1ant_MonitorBtCtr(
\r
416 IN PBTC_COEXIST pBtCoexist
\r
419 u4Byte regHPTxRx, regLPTxRx, u4Tmp, u4Tmp1;
\r
420 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
\r
421 u1Byte u1Tmp, u1Tmp1;
\r
424 //to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS
\r
425 if (! (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) & 0x8) )
\r
427 pCoexSta->highPriorityTx = 65535;
\r
428 pCoexSta->highPriorityRx = 65535;
\r
429 pCoexSta->lowPriorityTx = 65535;
\r
430 pCoexSta->lowPriorityRx = 65535;
\r
437 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
\r
438 regHPTx = u4Tmp & bMaskLWord;
\r
439 regHPRx = (u4Tmp & bMaskHWord)>>16;
\r
441 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
\r
442 regLPTx = u4Tmp & bMaskLWord;
\r
443 regLPRx = (u4Tmp & bMaskHWord)>>16;
\r
445 pCoexSta->highPriorityTx = regHPTx;
\r
446 pCoexSta->highPriorityRx = regHPRx;
\r
447 pCoexSta->lowPriorityTx = regLPTx;
\r
448 pCoexSta->lowPriorityRx = regLPRx;
\r
451 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
455 halbtc8821a1ant_QueryBtInfo(
\r
456 IN PBTC_COEXIST pBtCoexist
\r
459 u1Byte H2C_Parameter[1] ={0};
\r
461 pCoexSta->bC2hBtInfoReqSent = TRUE;
\r
463 H2C_Parameter[0] |= BIT0; // trigger
\r
465 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
\r
466 H2C_Parameter[0]));
\r
468 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
\r
472 halbtc8821a1ant_IsWifiStatusChanged(
\r
473 IN PBTC_COEXIST pBtCoexist
\r
476 static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;
\r
477 BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;
\r
478 BOOLEAN bWifiConnected=FALSE;
\r
480 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
481 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
482 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
483 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
487 if(bWifiBusy != bPreWifiBusy)
\r
489 bPreWifiBusy = bWifiBusy;
\r
492 if(bUnder4way != bPreUnder4way)
\r
494 bPreUnder4way = bUnder4way;
\r
497 if(bBtHsOn != bPreBtHsOn)
\r
499 bPreBtHsOn = bBtHsOn;
\r
508 halbtc8821a1ant_UpdateBtLinkInfo(
\r
509 IN PBTC_COEXIST pBtCoexist
\r
512 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
513 BOOLEAN bBtHsOn=FALSE;
\r
515 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
517 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
\r
518 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
\r
519 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
\r
520 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
\r
521 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
\r
523 // work around for HS mode.
\r
526 pBtLinkInfo->bPanExist = TRUE;
\r
527 pBtLinkInfo->bBtLinkExist = TRUE;
\r
530 // check if Sco only
\r
531 if( pBtLinkInfo->bScoExist &&
\r
532 !pBtLinkInfo->bA2dpExist &&
\r
533 !pBtLinkInfo->bPanExist &&
\r
534 !pBtLinkInfo->bHidExist )
\r
535 pBtLinkInfo->bScoOnly = TRUE;
\r
537 pBtLinkInfo->bScoOnly = FALSE;
\r
539 // check if A2dp only
\r
540 if( !pBtLinkInfo->bScoExist &&
\r
541 pBtLinkInfo->bA2dpExist &&
\r
542 !pBtLinkInfo->bPanExist &&
\r
543 !pBtLinkInfo->bHidExist )
\r
544 pBtLinkInfo->bA2dpOnly = TRUE;
\r
546 pBtLinkInfo->bA2dpOnly = FALSE;
\r
548 // check if Pan only
\r
549 if( !pBtLinkInfo->bScoExist &&
\r
550 !pBtLinkInfo->bA2dpExist &&
\r
551 pBtLinkInfo->bPanExist &&
\r
552 !pBtLinkInfo->bHidExist )
\r
553 pBtLinkInfo->bPanOnly = TRUE;
\r
555 pBtLinkInfo->bPanOnly = FALSE;
\r
557 // check if Hid only
\r
558 if( !pBtLinkInfo->bScoExist &&
\r
559 !pBtLinkInfo->bA2dpExist &&
\r
560 !pBtLinkInfo->bPanExist &&
\r
561 pBtLinkInfo->bHidExist )
\r
562 pBtLinkInfo->bHidOnly = TRUE;
\r
564 pBtLinkInfo->bHidOnly = FALSE;
\r
568 halbtc8821a1ant_ActionAlgorithm(
\r
569 IN PBTC_COEXIST pBtCoexist
\r
572 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
573 BOOLEAN bBtHsOn=FALSE;
\r
574 u1Byte algorithm=BT_8821A_1ANT_COEX_ALGO_UNDEFINED;
\r
575 u1Byte numOfDiffProfile=0;
\r
577 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
579 if(!pBtLinkInfo->bBtLinkExist)
\r
581 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n"));
\r
585 if(pBtLinkInfo->bScoExist)
\r
586 numOfDiffProfile++;
\r
587 if(pBtLinkInfo->bHidExist)
\r
588 numOfDiffProfile++;
\r
589 if(pBtLinkInfo->bPanExist)
\r
590 numOfDiffProfile++;
\r
591 if(pBtLinkInfo->bA2dpExist)
\r
592 numOfDiffProfile++;
\r
594 if(numOfDiffProfile == 1)
\r
596 if(pBtLinkInfo->bScoExist)
\r
598 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO only\n"));
\r
599 algorithm = BT_8821A_1ANT_COEX_ALGO_SCO;
\r
603 if(pBtLinkInfo->bHidExist)
\r
605 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID only\n"));
\r
606 algorithm = BT_8821A_1ANT_COEX_ALGO_HID;
\r
608 else if(pBtLinkInfo->bA2dpExist)
\r
610 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP only\n"));
\r
611 algorithm = BT_8821A_1ANT_COEX_ALGO_A2DP;
\r
613 else if(pBtLinkInfo->bPanExist)
\r
617 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = PAN(HS) only\n"));
\r
618 algorithm = BT_8821A_1ANT_COEX_ALGO_PANHS;
\r
622 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = PAN(EDR) only\n"));
\r
623 algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR;
\r
628 else if(numOfDiffProfile == 2)
\r
630 if(pBtLinkInfo->bScoExist)
\r
632 if(pBtLinkInfo->bHidExist)
\r
634 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID\n"));
\r
635 algorithm = BT_8821A_1ANT_COEX_ALGO_HID;
\r
637 else if(pBtLinkInfo->bA2dpExist)
\r
639 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n"));
\r
640 algorithm = BT_8821A_1ANT_COEX_ALGO_SCO;
\r
642 else if(pBtLinkInfo->bPanExist)
\r
646 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + PAN(HS)\n"));
\r
647 algorithm = BT_8821A_1ANT_COEX_ALGO_SCO;
\r
651 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n"));
\r
652 algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
\r
658 if( pBtLinkInfo->bHidExist &&
\r
659 pBtLinkInfo->bA2dpExist )
\r
661 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP\n"));
\r
662 algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP;
\r
664 else if( pBtLinkInfo->bHidExist &&
\r
665 pBtLinkInfo->bPanExist )
\r
669 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + PAN(HS)\n"));
\r
670 algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP;
\r
674 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + PAN(EDR)\n"));
\r
675 algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
\r
678 else if( pBtLinkInfo->bPanExist &&
\r
679 pBtLinkInfo->bA2dpExist )
\r
683 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n"));
\r
684 algorithm = BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS;
\r
688 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n"));
\r
689 algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP;
\r
694 else if(numOfDiffProfile == 3)
\r
696 if(pBtLinkInfo->bScoExist)
\r
698 if( pBtLinkInfo->bHidExist &&
\r
699 pBtLinkInfo->bA2dpExist )
\r
701 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n"));
\r
702 algorithm = BT_8821A_1ANT_COEX_ALGO_HID;
\r
704 else if( pBtLinkInfo->bHidExist &&
\r
705 pBtLinkInfo->bPanExist )
\r
709 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n"));
\r
710 algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP;
\r
714 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n"));
\r
715 algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
\r
718 else if( pBtLinkInfo->bPanExist &&
\r
719 pBtLinkInfo->bA2dpExist )
\r
723 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n"));
\r
724 algorithm = BT_8821A_1ANT_COEX_ALGO_SCO;
\r
728 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n"));
\r
729 algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
\r
735 if( pBtLinkInfo->bHidExist &&
\r
736 pBtLinkInfo->bPanExist &&
\r
737 pBtLinkInfo->bA2dpExist )
\r
741 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n"));
\r
742 algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP;
\r
746 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n"));
\r
747 algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
\r
752 else if(numOfDiffProfile >= 3)
\r
754 if(pBtLinkInfo->bScoExist)
\r
756 if( pBtLinkInfo->bHidExist &&
\r
757 pBtLinkInfo->bPanExist &&
\r
758 pBtLinkInfo->bA2dpExist )
\r
762 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n"));
\r
767 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
\r
768 algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
\r
778 halbtc8821a1ant_SetBtAutoReport(
\r
779 IN PBTC_COEXIST pBtCoexist,
\r
780 IN BOOLEAN bEnableAutoReport
\r
783 u1Byte H2C_Parameter[1] ={0};
\r
785 H2C_Parameter[0] = 0;
\r
787 if(bEnableAutoReport)
\r
789 H2C_Parameter[0] |= BIT0;
\r
792 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
\r
793 (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));
\r
795 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter);
\r
799 halbtc8821a1ant_BtAutoReport(
\r
800 IN PBTC_COEXIST pBtCoexist,
\r
801 IN BOOLEAN bForceExec,
\r
802 IN BOOLEAN bEnableAutoReport
\r
805 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Auto report = %s\n",
\r
806 (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
\r
807 pCoexDm->bCurBtAutoReport = bEnableAutoReport;
\r
811 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
\r
812 pCoexDm->bPreBtAutoReport, pCoexDm->bCurBtAutoReport));
\r
814 if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
\r
817 halbtc8821a1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
\r
819 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
\r
823 halbtc8821a1ant_SetSwPenaltyTxRateAdaptive(
\r
824 IN PBTC_COEXIST pBtCoexist,
\r
825 IN BOOLEAN bLowPenaltyRa
\r
828 u1Byte H2C_Parameter[6] ={0};
\r
830 H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty
\r
834 H2C_Parameter[1] |= BIT0;
\r
835 H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36
\r
836 H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54
\r
837 H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48
\r
838 H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36
\r
841 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set WiFi Low-Penalty Retry: %s",
\r
842 (bLowPenaltyRa? "ON!!":"OFF!!") ));
\r
844 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
\r
848 halbtc8821a1ant_LowPenaltyRa(
\r
849 IN PBTC_COEXIST pBtCoexist,
\r
850 IN BOOLEAN bForceExec,
\r
851 IN BOOLEAN bLowPenaltyRa
\r
854 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
858 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
861 halbtc8821a1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
863 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
867 halbtc8821a1ant_SetCoexTable(
\r
868 IN PBTC_COEXIST pBtCoexist,
\r
869 IN u4Byte val0x6c0,
\r
870 IN u4Byte val0x6c4,
\r
871 IN u4Byte val0x6c8,
\r
875 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
\r
876 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
\r
878 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
\r
879 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
\r
881 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
882 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
884 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
885 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
889 halbtc8821a1ant_CoexTable(
\r
890 IN PBTC_COEXIST pBtCoexist,
\r
891 IN BOOLEAN bForceExec,
\r
892 IN u4Byte val0x6c0,
\r
893 IN u4Byte val0x6c4,
\r
894 IN u4Byte val0x6c8,
\r
898 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
\r
899 (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc));
\r
900 pCoexDm->curVal0x6c0 = val0x6c0;
\r
901 pCoexDm->curVal0x6c4 = val0x6c4;
\r
902 pCoexDm->curVal0x6c8 = val0x6c8;
\r
903 pCoexDm->curVal0x6cc = val0x6cc;
\r
907 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
\r
908 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
\r
909 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
910 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
913 halbtc8821a1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
\r
915 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
\r
916 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
\r
917 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
918 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
922 halbtc8821a1ant_CoexTableWithType(
\r
923 IN PBTC_COEXIST pBtCoexist,
\r
924 IN BOOLEAN bForceExec,
\r
928 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ********** CoexTable(%d) **********\n", type));
\r
933 halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);
\r
936 halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
\r
939 halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);
\r
942 halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaaaaaa, 0xffffff, 0x3);
\r
945 halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3);
\r
948 halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaa5a5a, 0xffffff, 0x3);
\r
951 halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3);
\r
954 halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
\r
962 halbtc8821a1ant_SetFwIgnoreWlanAct(
\r
963 IN PBTC_COEXIST pBtCoexist,
\r
967 u1Byte H2C_Parameter[1] ={0};
\r
971 H2C_Parameter[0] |= BIT0; // function enable
\r
974 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
\r
975 H2C_Parameter[0]));
\r
977 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
\r
981 halbtc8821a1ant_IgnoreWlanAct(
\r
982 IN PBTC_COEXIST pBtCoexist,
\r
983 IN BOOLEAN bForceExec,
\r
987 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
\r
988 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
\r
989 pCoexDm->bCurIgnoreWlanAct = bEnable;
\r
993 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
\r
994 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
\r
996 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
\r
999 halbtc8821a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
\r
1001 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
\r
1005 halbtc8821a1ant_SetFwPstdma(
\r
1006 IN PBTC_COEXIST pBtCoexist,
\r
1014 u1Byte H2C_Parameter[5] ={0};
\r
1015 u1Byte realByte1=byte1, realByte5=byte5;
\r
1016 BOOLEAN bApEnable=FALSE;
\r
1018 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
1022 if(byte1&BIT4 && !(byte1&BIT5))
\r
1024 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], FW for 1Ant AP mode\n"));
\r
1025 realByte1 &= ~BIT4;
\r
1026 realByte1 |= BIT5;
\r
1028 realByte5 |= BIT5;
\r
1029 realByte5 &= ~BIT6;
\r
1033 H2C_Parameter[0] = realByte1;
\r
1034 H2C_Parameter[1] = byte2;
\r
1035 H2C_Parameter[2] = byte3;
\r
1036 H2C_Parameter[3] = byte4;
\r
1037 H2C_Parameter[4] = realByte5;
\r
1039 pCoexDm->psTdmaPara[0] = realByte1;
\r
1040 pCoexDm->psTdmaPara[1] = byte2;
\r
1041 pCoexDm->psTdmaPara[2] = byte3;
\r
1042 pCoexDm->psTdmaPara[3] = byte4;
\r
1043 pCoexDm->psTdmaPara[4] = realByte5;
\r
1045 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n",
\r
1046 H2C_Parameter[0],
\r
1047 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
\r
1049 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
\r
1053 halbtc8821a1ant_SetLpsRpwm(
\r
1054 IN PBTC_COEXIST pBtCoexist,
\r
1059 u1Byte lps=lpsVal;
\r
1060 u1Byte rpwm=rpwmVal;
\r
1062 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
\r
1063 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
\r
1067 halbtc8821a1ant_LpsRpwm(
\r
1068 IN PBTC_COEXIST pBtCoexist,
\r
1069 IN BOOLEAN bForceExec,
\r
1074 BOOLEAN bForceExecPwrCmd=FALSE;
\r
1076 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
\r
1077 (bForceExec? "force to":""), lpsVal, rpwmVal));
\r
1078 pCoexDm->curLps = lpsVal;
\r
1079 pCoexDm->curRpwm = rpwmVal;
\r
1083 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], LPS-RxBeaconMode=0x%x , LPS-RPWM=0x%x!!\n",
\r
1084 pCoexDm->curLps, pCoexDm->curRpwm));
\r
1086 if( (pCoexDm->preLps == pCoexDm->curLps) &&
\r
1087 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
\r
1089 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], LPS-RPWM_Last=0x%x , LPS-RPWM_Now=0x%x!!\n",
\r
1090 pCoexDm->preRpwm, pCoexDm->curRpwm));
\r
1095 halbtc8821a1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
\r
1097 pCoexDm->preLps = pCoexDm->curLps;
\r
1098 pCoexDm->preRpwm = pCoexDm->curRpwm;
\r
1102 halbtc8821a1ant_SwMechanism(
\r
1103 IN PBTC_COEXIST pBtCoexist,
\r
1104 IN BOOLEAN bLowPenaltyRA
\r
1107 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], SM[LpRA] = %d\n",
\r
1110 halbtc8821a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
\r
1114 halbtc8821a1ant_SetAntPath(
\r
1115 IN PBTC_COEXIST pBtCoexist,
\r
1116 IN u1Byte antPosType,
\r
1117 IN BOOLEAN bInitHwCfg,
\r
1118 IN BOOLEAN bWifiOff
\r
1121 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1122 u4Byte fwVer=0, u4Tmp=0;
\r
1123 u1Byte H2C_Parameter[2] ={0};
\r
1127 // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT
\r
1128 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1131 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1134 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x765, 0x18, 0x3);
\r
1136 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1138 //tell firmware "antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix
\r
1139 H2C_Parameter[0] = 1;
\r
1140 H2C_Parameter[1] = 1;
\r
1141 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1143 //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x1); //Main Ant to BT for IPS case 0x4c[23]=1
\r
1147 //tell firmware "no antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix
\r
1148 H2C_Parameter[0] = 0;
\r
1149 H2C_Parameter[1] = 1;
\r
1150 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1152 //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); //Aux Ant to BT for IPS case 0x4c[23]=1
\r
1157 // 0x4c[24:23]=00, Set Antenna control by BT_RFE_CTRL BT Vendor 0xac=0xf002
\r
1158 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1161 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1164 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x765, 0x18, 0x3);
\r
1169 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x765, 0x18, 0x0);
\r
1172 // ext switch setting
\r
1173 switch(antPosType)
\r
1175 case BTC_ANT_PATH_WIFI:
\r
1176 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x77);
\r
1177 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1178 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1);
\r
1180 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2);
\r
1182 case BTC_ANT_PATH_BT:
\r
1183 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x77);
\r
1184 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1185 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2);
\r
1187 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1);
\r
1190 case BTC_ANT_PATH_PTA:
\r
1191 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x66);
\r
1192 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1193 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1);
\r
1195 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2);
\r
1201 halbtc8821a1ant_PsTdma(
\r
1202 IN PBTC_COEXIST pBtCoexist,
\r
1203 IN BOOLEAN bForceExec,
\r
1204 IN BOOLEAN bTurnOn,
\r
1208 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1209 BOOLEAN bTurnOnByCnt=FALSE;
\r
1210 u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0;
\r
1213 pCoexDm->bCurPsTdmaOn = bTurnOn;
\r
1214 pCoexDm->curPsTdma = type;
\r
1216 if (pCoexDm->bCurPsTdmaOn)
\r
1218 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ********** TDMA(on, %d) **********\n",
\r
1219 pCoexDm->curPsTdma));
\r
1223 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ********** TDMA(off, %d) **********\n",
\r
1224 pCoexDm->curPsTdma));
\r
1229 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
\r
1230 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
\r
1238 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, 0x50);
\r
1241 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x3a, 0x03, 0x10, 0x50);
\r
1242 rssiAdjustVal = 11;
\r
1245 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x2b, 0x03, 0x10, 0x50);
\r
1246 rssiAdjustVal = 14;
\r
1249 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, 0x52);
\r
1252 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
\r
1253 rssiAdjustVal = 17;
\r
1256 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x10);
\r
1259 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x13);
\r
1262 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
\r
1265 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1268 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, 0x50);
\r
1269 rssiAdjustVal = 18;
\r
1272 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
\r
1275 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x15, 0x03, 0x10, 0x50);
\r
1276 rssiAdjustVal = 20;
\r
1279 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50);
\r
1282 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, 0x50);
\r
1285 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, 0x52);
\r
1288 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0);
\r
1291 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0);
\r
1292 rssiAdjustVal = 18;
\r
1295 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1296 rssiAdjustVal = 14;
\r
1299 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x03, 0x11, 0x10);
\r
1302 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11);
\r
1305 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10);
\r
1308 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);
\r
1309 rssiAdjustVal = 22;
\r
1312 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);
\r
1313 rssiAdjustVal = 22;
\r
1316 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1317 rssiAdjustVal = 22;
\r
1320 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1321 rssiAdjustVal = 22;
\r
1324 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);
\r
1325 rssiAdjustVal = 22;
\r
1328 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0);
\r
1331 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10);
\r
1334 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10);
\r
1337 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);
\r
1340 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11);
\r
1343 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90);
\r
1346 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10);
\r
1349 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10);
\r
1352 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50);
\r
1354 case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving
\r
1355 /* here softap mode screen off will cost 70-80mA for phone */
\r
1356 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24);
\r
1362 // disable PS tdma
\r
1365 case 8: //PTA Control
\r
1366 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
\r
1367 halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE);
\r
1370 default: //Software control, Antenna at BT side
\r
1371 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1372 halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
\r
1374 case 9: //Software control, Antenna at WiFi side
\r
1375 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1376 halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE);
\r
1378 case 10: // under 5G
\r
1379 halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
\r
1380 halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
\r
1385 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal);
\r
1387 // update pre state
\r
1388 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
\r
1389 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
\r
1393 halbtc8821a1ant_CoexAllOff(
\r
1394 IN PBTC_COEXIST pBtCoexist
\r
1398 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1401 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1405 halbtc8821a1ant_IsCommonAction(
\r
1406 IN PBTC_COEXIST pBtCoexist
\r
1409 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
1411 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1412 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1414 if(!bWifiConnected &&
\r
1415 BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
1417 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));
\r
1418 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1422 else if(bWifiConnected &&
\r
1423 (BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1425 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
\r
1426 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1430 else if(!bWifiConnected &&
\r
1431 (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1433 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));
\r
1434 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1438 else if(bWifiConnected &&
\r
1439 (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1441 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
\r
1442 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1446 else if(!bWifiConnected &&
\r
1447 (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) )
\r
1449 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
\r
1450 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1458 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
\r
1462 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));
\r
1473 halbtc8821a1ant_TdmaDurationAdjustForAcl(
\r
1474 IN PBTC_COEXIST pBtCoexist,
\r
1475 IN u1Byte wifiStatus
\r
1478 static s4Byte up,dn,m,n,WaitCount;
\r
1479 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
\r
1480 u1Byte retryCount=0, btInfoExt;
\r
1482 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjustForAcl()\n"));
\r
1484 if( (BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
\r
1485 (BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
\r
1486 (BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
\r
1488 if( pCoexDm->curPsTdma != 1 &&
\r
1489 pCoexDm->curPsTdma != 2 &&
\r
1490 pCoexDm->curPsTdma != 3 &&
\r
1491 pCoexDm->curPsTdma != 9 )
\r
1493 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1494 pCoexDm->psTdmaDuAdjType = 9;
\r
1506 if(!pCoexDm->bAutoTdmaAdjust)
\r
1508 pCoexDm->bAutoTdmaAdjust = TRUE;
\r
1509 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
\r
1511 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1512 pCoexDm->psTdmaDuAdjType = 2;
\r
1523 //accquire the BT TRx retry count from BT_Info byte2
\r
1524 retryCount = pCoexSta->btRetryCnt;
\r
1525 btInfoExt = pCoexSta->btInfoExt;
\r
1526 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
\r
1527 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
\r
1528 // up, dn, m, n, WaitCount));
\r
1532 if(retryCount == 0) // no retry in the last 2-second duration
\r
1540 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
\r
1547 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
\r
1550 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
\r
1558 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
\r
1560 if (WaitCount <= 2)
\r
1561 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1565 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1573 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
\r
1576 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
\r
1578 if (WaitCount == 1)
\r
1579 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1583 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1591 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
\r
1596 if( (BT_INFO_8821A_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1597 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1599 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1600 pCoexDm->psTdmaDuAdjType = 9;
\r
1602 else if(pCoexDm->curPsTdma == 1)
\r
1604 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1605 pCoexDm->psTdmaDuAdjType = 2;
\r
1607 else if(pCoexDm->curPsTdma == 2)
\r
1609 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1610 pCoexDm->psTdmaDuAdjType = 9;
\r
1612 else if(pCoexDm->curPsTdma == 9)
\r
1614 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
1615 pCoexDm->psTdmaDuAdjType = 11;
\r
1618 else if(result == 1)
\r
1620 if( (BT_INFO_8821A_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1621 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1623 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1624 pCoexDm->psTdmaDuAdjType = 9;
\r
1626 else if(pCoexDm->curPsTdma == 11)
\r
1628 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1629 pCoexDm->psTdmaDuAdjType = 9;
\r
1631 else if(pCoexDm->curPsTdma == 9)
\r
1633 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1634 pCoexDm->psTdmaDuAdjType = 2;
\r
1636 else if(pCoexDm->curPsTdma == 2)
\r
1638 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
1639 pCoexDm->psTdmaDuAdjType = 1;
\r
1644 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], ********** TDMA(on, %d) **********\n",
\r
1645 pCoexDm->curPsTdma));
\r
1648 if( pCoexDm->curPsTdma != 1 &&
\r
1649 pCoexDm->curPsTdma != 2 &&
\r
1650 pCoexDm->curPsTdma != 9 &&
\r
1651 pCoexDm->curPsTdma != 11 )
\r
1653 // recover to previous adjust type
\r
1654 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
\r
1660 halbtc8821a1ant_PsTdmaCheckForPowerSaveState(
\r
1661 IN PBTC_COEXIST pBtCoexist,
\r
1662 IN BOOLEAN bNewPsState
\r
1665 u1Byte lpsMode=0x0;
\r
1667 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
\r
1669 if(lpsMode) // already under LPS state
\r
1673 // keep state under LPS, do nothing.
\r
1677 // will leave LPS state, turn off psTdma first
\r
1678 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1681 else // NO PS state
\r
1685 // will enter LPS state, turn off psTdma first
\r
1686 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1690 // keep state under NO PS state, do nothing.
\r
1696 halbtc8821a1ant_PowerSaveState(
\r
1697 IN PBTC_COEXIST pBtCoexist,
\r
1703 BOOLEAN bLowPwrDisable=FALSE;
\r
1707 case BTC_PS_WIFI_NATIVE:
\r
1708 // recover to original 32k low power setting
\r
1709 bLowPwrDisable = FALSE;
\r
1710 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1711 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1713 case BTC_PS_LPS_ON:
\r
1714 halbtc8821a1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);
\r
1715 halbtc8821a1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
\r
1716 // when coex force to enter LPS, do not enter 32k low power.
\r
1717 bLowPwrDisable = TRUE;
\r
1718 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1719 // power save must executed before psTdma.
\r
1720 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
\r
1722 case BTC_PS_LPS_OFF:
\r
1723 halbtc8821a1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
\r
1724 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1732 halbtc8821a1ant_CoexUnder5G(
\r
1733 IN PBTC_COEXIST pBtCoexist
\r
1736 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1738 halbtc8821a1ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1740 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 10);
\r
1742 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1744 halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
1746 halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 5);
\r
1750 halbtc8821a1ant_ActionWifiOnly(
\r
1751 IN PBTC_COEXIST pBtCoexist
\r
1754 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1755 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1759 halbtc8821a1ant_MonitorBtEnableDisable(
\r
1760 IN PBTC_COEXIST pBtCoexist
\r
1763 static BOOLEAN bPreBtDisabled=FALSE;
\r
1764 static u4Byte btDisableCnt=0;
\r
1765 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
\r
1767 // This function check if bt is disabled
\r
1769 if( pCoexSta->highPriorityTx == 0 &&
\r
1770 pCoexSta->highPriorityRx == 0 &&
\r
1771 pCoexSta->lowPriorityTx == 0 &&
\r
1772 pCoexSta->lowPriorityRx == 0)
\r
1774 bBtActive = FALSE;
\r
1776 if( pCoexSta->highPriorityTx == 0xffff &&
\r
1777 pCoexSta->highPriorityRx == 0xffff &&
\r
1778 pCoexSta->lowPriorityTx == 0xffff &&
\r
1779 pCoexSta->lowPriorityRx == 0xffff)
\r
1781 bBtActive = FALSE;
\r
1786 bBtDisabled = FALSE;
\r
1787 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
1788 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
\r
1793 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
\r
1795 if(btDisableCnt >= 2)
\r
1797 bBtDisabled = TRUE;
\r
1798 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
1799 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
\r
1800 halbtc8821a1ant_ActionWifiOnly(pBtCoexist);
\r
1803 if(bPreBtDisabled != bBtDisabled)
\r
1805 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
\r
1806 (bPreBtDisabled ? "disabled":"enabled"),
\r
1807 (bBtDisabled ? "disabled":"enabled")));
\r
1808 bPreBtDisabled = bBtDisabled;
\r
1814 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1815 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1820 //=============================================
\r
1822 // Software Coex Mechanism start
\r
1824 //=============================================
\r
1826 // SCO only or SCO+PAN(HS)
\r
1828 halbtc8821a1ant_ActionSco(
\r
1829 IN PBTC_COEXIST pBtCoexist
\r
1832 halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE);
\r
1836 halbtc8821a1ant_ActionHid(
\r
1837 IN PBTC_COEXIST pBtCoexist
\r
1840 halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE);
\r
1843 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
\r
1845 halbtc8821a1ant_ActionA2dp(
\r
1846 IN PBTC_COEXIST pBtCoexist
\r
1849 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1853 halbtc8821a1ant_ActionA2dpPanHs(
\r
1854 IN PBTC_COEXIST pBtCoexist
\r
1857 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1861 halbtc8821a1ant_ActionPanEdr(
\r
1862 IN PBTC_COEXIST pBtCoexist
\r
1865 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1870 halbtc8821a1ant_ActionPanHs(
\r
1871 IN PBTC_COEXIST pBtCoexist
\r
1874 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1879 halbtc8821a1ant_ActionPanEdrA2dp(
\r
1880 IN PBTC_COEXIST pBtCoexist
\r
1883 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
1887 halbtc8821a1ant_ActionPanEdrHid(
\r
1888 IN PBTC_COEXIST pBtCoexist
\r
1891 halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE);
\r
1894 // HID+A2DP+PAN(EDR)
\r
1896 halbtc8821a1ant_ActionHidA2dpPanEdr(
\r
1897 IN PBTC_COEXIST pBtCoexist
\r
1900 halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE);
\r
1904 halbtc8821a1ant_ActionHidA2dp(
\r
1905 IN PBTC_COEXIST pBtCoexist
\r
1908 halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE);
\r
1911 //=============================================
\r
1913 // Non-Software Coex Mechanism start
\r
1915 //=============================================
\r
1917 halbtc8821a1ant_ActionWifiMultiPort(
\r
1918 IN PBTC_COEXIST pBtCoexist
\r
1921 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1923 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1924 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1928 halbtc8821a1ant_ActionHs(
\r
1929 IN PBTC_COEXIST pBtCoexist
\r
1932 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
1933 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1937 halbtc8821a1ant_ActionBtInquiry(
\r
1938 IN PBTC_COEXIST pBtCoexist
\r
1941 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
1942 BOOLEAN bWifiConnected=FALSE, bApEnable=FALSE, bWifiBusy=FALSE, bBtBusy=FALSE;
\r
1944 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
1945 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1946 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1947 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
1949 if((!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask))
\r
1951 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1952 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1954 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1956 else if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist))
\r
1958 // SCO/HID/A2DP busy
\r
1959 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1960 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
1962 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
1964 else if ((pBtLinkInfo->bPanExist) || (bWifiBusy))
\r
1966 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1967 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
1969 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
1973 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1974 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1976 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
1981 halbtc8821a1ant_ActionBtScoHidOnlyBusy(
\r
1982 IN PBTC_COEXIST pBtCoexist,
\r
1983 IN u1Byte wifiStatus
\r
1986 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
1987 BOOLEAN bWifiConnected=FALSE;
\r
1988 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
\r
1990 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1992 // tdma and coex table
\r
1994 if(pBtLinkInfo->bScoExist)
\r
1996 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
1997 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2001 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2002 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);
\r
2007 halbtc8821a1ant_ActionWifiConnectedBtAclBusy(
\r
2008 IN PBTC_COEXIST pBtCoexist,
\r
2009 IN u1Byte wifiStatus
\r
2012 u1Byte btRssiState;
\r
2014 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2015 btRssiState = halbtc8821a1ant_BtRssiState(2, 28, 0);
\r
2017 if(pBtLinkInfo->bHidOnly) //HID
\r
2019 halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);
\r
2020 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2023 else if(pBtLinkInfo->bA2dpOnly) //A2DP
\r
2025 if(BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus)
\r
2027 //halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2028 //halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2029 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2030 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2031 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2033 else if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
2034 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
2036 halbtc8821a1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);
\r
2037 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2039 else //for low BT RSSI
\r
2041 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2042 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2043 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2046 else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) //HID+A2DP
\r
2048 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
2049 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
2051 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2052 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2054 else //for low BT RSSI
\r
2056 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2057 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2060 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 6);
\r
2062 else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP)
\r
2064 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2065 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 6);
\r
2066 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2068 else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) ||
\r
2069 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP)
\r
2071 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
2072 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2073 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2077 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2078 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2079 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2084 halbtc8821a1ant_ActionWifiNotConnected(
\r
2085 IN PBTC_COEXIST pBtCoexist
\r
2088 // power save state
\r
2089 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2091 // tdma and coex table
\r
2092 halbtc8821a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
2093 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2097 halbtc8821a1ant_ActionWifiNotConnectedScan(
\r
2098 IN PBTC_COEXIST pBtCoexist
\r
2101 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2103 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2105 // tdma and coex table
\r
2106 if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2108 if (pBtLinkInfo->bA2dpExist)
\r
2110 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2111 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2113 else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)
\r
2115 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
2116 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2120 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2121 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2124 else if( (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2125 (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2127 halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2128 BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
2132 //halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2133 //halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2136 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2137 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2142 halbtc8821a1ant_ActionWifiNotConnectedAssoAuth(
\r
2143 IN PBTC_COEXIST pBtCoexist
\r
2146 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2148 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2150 // tdma and coex table
\r
2151 if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) )
\r
2153 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2154 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2156 else if( (pBtLinkInfo->bA2dpExist) || (pBtLinkInfo->bPanExist) )
\r
2158 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2159 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2163 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2164 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2169 halbtc8821a1ant_ActionWifiConnectedScan(
\r
2170 IN PBTC_COEXIST pBtCoexist
\r
2173 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2175 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2177 // tdma and coex table
\r
2178 if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2180 if (pBtLinkInfo->bA2dpExist)
\r
2182 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2183 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2185 else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)
\r
2187 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
2188 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2192 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2193 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2196 else if( (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2197 (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2199 halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2200 BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
2204 //halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2205 //halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2208 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2209 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2214 halbtc8821a1ant_ActionWifiConnectedSpecialPacket(
\r
2215 IN PBTC_COEXIST pBtCoexist
\r
2218 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2220 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2222 // tdma and coex table
\r
2223 if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist))
\r
2225 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2226 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2228 else if(pBtLinkInfo->bPanExist)
\r
2230 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2231 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2235 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2236 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2241 halbtc8821a1ant_ActionWifiConnected(
\r
2242 IN PBTC_COEXIST pBtCoexist
\r
2245 BOOLEAN bWifiBusy=FALSE;
\r
2246 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2247 BOOLEAN bUnder4way=FALSE, bApEnable=FALSE;
\r
2250 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect()===>\n"));
\r
2252 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
2255 halbtc8821a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
2256 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));
\r
2260 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2261 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2262 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2263 if(bScan || bLink || bRoam)
\r
2266 halbtc8821a1ant_ActionWifiConnectedScan(pBtCoexist);
\r
2268 halbtc8821a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
2269 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));
\r
2273 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
2274 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
2275 // power save state
\r
2276 if(!bApEnable && BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
\r
2278 if(!bWifiBusy && pBtCoexist->btLinkInfo.bA2dpOnly) //A2DP
\r
2279 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2281 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
2284 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2286 // tdma and coex table
\r
2289 if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2291 halbtc8821a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2292 BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
2294 else if( (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2295 (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2297 halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2298 BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
2302 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2303 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2308 if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2310 halbtc8821a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2311 BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
2313 else if( (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2314 (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2316 halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2317 BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
2321 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2322 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2328 halbtc8821a1ant_RunSwCoexistMechanism(
\r
2329 IN PBTC_COEXIST pBtCoexist
\r
2332 u1Byte algorithm=0;
\r
2334 algorithm = halbtc8821a1ant_ActionAlgorithm(pBtCoexist);
\r
2335 pCoexDm->curAlgorithm = algorithm;
\r
2337 if(halbtc8821a1ant_IsCommonAction(pBtCoexist))
\r
2343 switch(pCoexDm->curAlgorithm)
\r
2345 case BT_8821A_1ANT_COEX_ALGO_SCO:
\r
2346 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n"));
\r
2347 halbtc8821a1ant_ActionSco(pBtCoexist);
\r
2349 case BT_8821A_1ANT_COEX_ALGO_HID:
\r
2350 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n"));
\r
2351 halbtc8821a1ant_ActionHid(pBtCoexist);
\r
2353 case BT_8821A_1ANT_COEX_ALGO_A2DP:
\r
2354 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n"));
\r
2355 halbtc8821a1ant_ActionA2dp(pBtCoexist);
\r
2357 case BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS:
\r
2358 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
\r
2359 halbtc8821a1ant_ActionA2dpPanHs(pBtCoexist);
\r
2361 case BT_8821A_1ANT_COEX_ALGO_PANEDR:
\r
2362 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
\r
2363 halbtc8821a1ant_ActionPanEdr(pBtCoexist);
\r
2365 case BT_8821A_1ANT_COEX_ALGO_PANHS:
\r
2366 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n"));
\r
2367 halbtc8821a1ant_ActionPanHs(pBtCoexist);
\r
2369 case BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP:
\r
2370 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
\r
2371 halbtc8821a1ant_ActionPanEdrA2dp(pBtCoexist);
\r
2373 case BT_8821A_1ANT_COEX_ALGO_PANEDR_HID:
\r
2374 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
\r
2375 halbtc8821a1ant_ActionPanEdrHid(pBtCoexist);
\r
2377 case BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
\r
2378 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
\r
2379 halbtc8821a1ant_ActionHidA2dpPanEdr(pBtCoexist);
\r
2381 case BT_8821A_1ANT_COEX_ALGO_HID_A2DP:
\r
2382 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
\r
2383 halbtc8821a1ant_ActionHidA2dp(pBtCoexist);
\r
2386 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
\r
2387 //halbtc8821a1ant_CoexAllOff(pBtCoexist);
\r
2390 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
\r
2395 halbtc8821a1ant_RunCoexistMechanism(
\r
2396 IN PBTC_COEXIST pBtCoexist
\r
2399 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2400 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2401 BOOLEAN bIncreaseScanDevNum=FALSE;
\r
2402 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
2403 u1Byte aggBufSize=5;
\r
2404 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
\r
2405 u4Byte wifiLinkStatus=0;
\r
2406 u4Byte numOfWifiLink=0;
\r
2407 BOOLEAN bWifiUnder5G=FALSE;
\r
2409 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n"));
\r
2411 if(pBtCoexist->bManualControl)
\r
2413 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
\r
2417 if(pBtCoexist->bStopCoexDm)
\r
2419 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
\r
2423 if(pCoexSta->bUnderIps)
\r
2425 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
\r
2429 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
2432 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for 5G <===\n"));
\r
2433 halbtc8821a1ant_CoexUnder5G(pBtCoexist);
\r
2437 if( (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
2438 (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2439 (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2441 bIncreaseScanDevNum = TRUE;
\r
2444 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum);
\r
2445 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2447 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
2448 numOfWifiLink = wifiLinkStatus>>16;
\r
2449 if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED))
\r
2451 halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2452 halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
2453 halbtc8821a1ant_ActionWifiMultiPort(pBtCoexist);
\r
2457 if(!pBtLinkInfo->bScoExist && !pBtLinkInfo->bHidExist)
\r
2459 halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2463 if(bWifiConnected)
\r
2465 wifiRssiState = halbtc8821a1ant_WifiRssiState(pBtCoexist, 1, 2, 30, 0);
\r
2466 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
2467 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
2469 halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 1, 1);
\r
2473 halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 1, 1);
\r
2478 halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2483 if(pBtLinkInfo->bScoExist)
\r
2485 bBtCtrlAggBufSize = TRUE;
\r
2488 else if(pBtLinkInfo->bHidExist)
\r
2490 bBtCtrlAggBufSize = TRUE;
\r
2493 else if(pBtLinkInfo->bA2dpExist || pBtLinkInfo->bPanExist)
\r
2495 bBtCtrlAggBufSize = TRUE;
\r
2498 halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
2500 halbtc8821a1ant_RunSwCoexistMechanism(pBtCoexist);
\r
2502 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2503 if(pCoexSta->bC2hBtInquiryPage)
\r
2505 halbtc8821a1ant_ActionBtInquiry(pBtCoexist);
\r
2510 halbtc8821a1ant_ActionHs(pBtCoexist);
\r
2515 if(!bWifiConnected)
\r
2517 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2519 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n"));
\r
2521 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2522 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2523 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2525 if(bScan || bLink || bRoam)
\r
2528 halbtc8821a1ant_ActionWifiNotConnectedScan(pBtCoexist);
\r
2530 halbtc8821a1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
\r
2533 halbtc8821a1ant_ActionWifiNotConnected(pBtCoexist);
\r
2535 else // wifi LPS/Busy
\r
2537 halbtc8821a1ant_ActionWifiConnected(pBtCoexist);
\r
2542 halbtc8821a1ant_InitCoexDm(
\r
2543 IN PBTC_COEXIST pBtCoexist
\r
2546 // force to reset coex mechanism
\r
2548 halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE);
\r
2550 //halbtc8821a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
2551 halbtc8821a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
2555 halbtc8821a1ant_InitHwConfig(
\r
2556 IN PBTC_COEXIST pBtCoexist,
\r
2557 IN BOOLEAN bBackUp,
\r
2558 IN BOOLEAN bWifiOnly
\r
2561 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
2565 u1Byte H2C_Parameter[2] ={0};
\r
2566 BOOLEAN bWifiUnder5G=FALSE;
\r
2569 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
\r
2576 pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
\r
2577 pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
\r
2578 pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
\r
2579 pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
\r
2583 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
\r
2586 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
\r
2588 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
2592 halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, TRUE, FALSE);
\r
2594 halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, TRUE, FALSE);
\r
2597 halbtc8821a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
2599 // Enable counter statistics
\r
2600 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); //0x76e[3] =1, WLAN_Act control by PTA
\r
2601 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);
\r
2602 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
\r
2605 //============================================================
\r
2606 // work around function start with wa_halbtc8821a1ant_
\r
2607 //============================================================
\r
2608 //============================================================
\r
2609 // extern function start with EXhalbtc8821a1ant_
\r
2610 //============================================================
\r
2612 EXhalbtc8821a1ant_PowerOnSetting(
\r
2613 IN PBTC_COEXIST pBtCoexist
\r
2619 EXhalbtc8821a1ant_InitHwConfig(
\r
2620 IN PBTC_COEXIST pBtCoexist,
\r
2621 IN BOOLEAN bWifiOnly
\r
2624 halbtc8821a1ant_InitHwConfig(pBtCoexist, TRUE, bWifiOnly);
\r
2628 EXhalbtc8821a1ant_InitCoexDm(
\r
2629 IN PBTC_COEXIST pBtCoexist
\r
2632 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
2634 pBtCoexist->bStopCoexDm = FALSE;
\r
2636 halbtc8821a1ant_InitCoexDm(pBtCoexist);
\r
2638 halbtc8821a1ant_QueryBtInfo(pBtCoexist);
\r
2642 EXhalbtc8821a1ant_DisplayCoexInfo(
\r
2643 IN PBTC_COEXIST pBtCoexist
\r
2646 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
2647 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
2648 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2649 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
2650 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
2653 u4Byte faOfdm, faCck;
\r
2654 u4Byte fwVer=0, btPatchVer=0;
\r
2656 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
2657 CL_PRINTF(cliBuf);
\r
2659 if(pBtCoexist->bManualControl)
\r
2661 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
\r
2662 CL_PRINTF(cliBuf);
\r
2663 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
2664 CL_PRINTF(cliBuf);
\r
2666 if(pBtCoexist->bStopCoexDm)
\r
2668 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");
\r
2669 CL_PRINTF(cliBuf);
\r
2670 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
2671 CL_PRINTF(cliBuf);
\r
2674 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Ant Mech/ Ant Pos:", \
\r
2675 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos);
\r
2676 CL_PRINTF(cliBuf);
\r
2678 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
2679 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
2680 CL_PRINTF(cliBuf);
\r
2682 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
2683 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
2684 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
\r
2685 GLCoexVerDate8821a1Ant, GLCoexVer8821a1Ant, fwVer, btPatchVer, btPatchVer);
\r
2686 CL_PRINTF(cliBuf);
\r
2688 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \
\r
2689 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
\r
2690 pCoexDm->wifiChnlInfo[2]);
\r
2691 CL_PRINTF(cliBuf);
\r
2694 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
\r
2695 CL_PRINTF(cliBuf);
\r
2696 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
\r
2698 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
\r
2699 CL_PRINTF(cliBuf);
\r
2701 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
\r
2702 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
\r
2703 ( (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
\r
2704 pCoexSta->btRssi, pCoexSta->btRetryCnt);
\r
2705 CL_PRINTF(cliBuf);
\r
2707 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
2708 pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);
\r
2709 CL_PRINTF(cliBuf);
\r
2710 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
2712 btInfoExt = pCoexSta->btInfoExt;
\r
2713 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
\r
2714 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
\r
2715 CL_PRINTF(cliBuf);
\r
2717 for(i=0; i<BT_INFO_SRC_8821A_1ANT_MAX; i++)
\r
2719 if(pCoexSta->btInfoC2hCnt[i])
\r
2721 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8821a1Ant[i], \
\r
2722 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
\r
2723 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
\r
2724 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
\r
2725 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
\r
2726 CL_PRINTF(cliBuf);
\r
2730 if(!pBtCoexist->bManualControl)
\r
2733 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
2734 CL_PRINTF(cliBuf);
\r
2736 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "SM[LowPenaltyRA]", \
\r
2737 pCoexDm->bCurLowPenaltyRa);
\r
2738 CL_PRINTF(cliBuf);
\r
2740 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \
\r
2741 (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"),
\r
2742 pBtCoexist->btInfo.aggBufSize);
\r
2743 CL_PRINTF(cliBuf);
\r
2744 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \
\r
2745 pBtCoexist->btInfo.raMask);
\r
2746 CL_PRINTF(cliBuf);
\r
2749 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
2750 CL_PRINTF(cliBuf);
\r
2752 psTdmaCase = pCoexDm->curPsTdma;
\r
2753 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
\r
2754 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
\r
2755 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
\r
2756 pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
\r
2757 CL_PRINTF(cliBuf);
\r
2759 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \
\r
2760 pCoexDm->bCurIgnoreWlanAct);
\r
2761 CL_PRINTF(cliBuf);
\r
2763 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
\r
2764 pCoexDm->errorCondition);
\r
2765 CL_PRINTF(cliBuf);
\r
2769 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
2770 CL_PRINTF(cliBuf);
\r
2772 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", \
\r
2773 pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime);
\r
2774 CL_PRINTF(cliBuf);
\r
2776 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
\r
2777 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
\r
2778 u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
\r
2779 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
\r
2780 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \
\r
2781 u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]);
\r
2782 CL_PRINTF(cliBuf);
\r
2784 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
\r
2785 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc58);
\r
2786 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x778/ 0xc58[29:25]", \
\r
2787 u1Tmp[0], (u4Tmp[0]&0x3e000000) >> 25);
\r
2788 CL_PRINTF(cliBuf);
\r
2790 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x8db);
\r
2791 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x8db[6:5]", \
\r
2792 ((u1Tmp[0]&0x60)>>5));
\r
2793 CL_PRINTF(cliBuf);
\r
2795 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x975);
\r
2796 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcb4);
\r
2797 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xcb4[29:28]/0xcb4[7:0]/0x974[9:8]", \
\r
2798 (u4Tmp[0]&0x30000000)>>28, u4Tmp[0]&0xff, u1Tmp[0]& 0x3);
\r
2799 CL_PRINTF(cliBuf);
\r
2802 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
2803 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
2804 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64);
\r
2805 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x40/0x4c[24:23]/0x64[0]", \
\r
2806 u1Tmp[0], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[1]&0x1);
\r
2807 CL_PRINTF(cliBuf);
\r
2809 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
\r
2810 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
\r
2811 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
\r
2812 u4Tmp[0], u1Tmp[0]);
\r
2813 CL_PRINTF(cliBuf);
\r
2815 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
2816 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
\r
2818 CL_PRINTF(cliBuf);
\r
2820 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf48);
\r
2821 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5d);
\r
2822 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
\r
2823 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "OFDM-FA/ CCK-FA", \
\r
2824 u4Tmp[0], (u1Tmp[0]<<8) + u1Tmp[1] );
\r
2825 CL_PRINTF(cliBuf);
\r
2827 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
\r
2828 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
2829 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
2830 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", \
\r
2831 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
\r
2832 CL_PRINTF(cliBuf);
\r
2834 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \
\r
2835 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
\r
2836 CL_PRINTF(cliBuf);
\r
2837 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \
\r
2838 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
\r
2839 CL_PRINTF(cliBuf);
\r
2840 #if(BT_AUTO_REPORT_ONLY_8821A_1ANT == 1)
\r
2841 halbtc8821a1ant_MonitorBtCtr(pBtCoexist);
\r
2843 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
2848 EXhalbtc8821a1ant_IpsNotify(
\r
2849 IN PBTC_COEXIST pBtCoexist,
\r
2855 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
2858 if(BTC_IPS_ENTER == type)
\r
2860 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
\r
2861 pCoexSta->bUnderIps = TRUE;
\r
2863 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2864 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2865 halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
2866 //halbtc8821a1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF);
\r
2868 else if(BTC_IPS_LEAVE == type)
\r
2870 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
\r
2871 pCoexSta->bUnderIps = FALSE;
\r
2873 halbtc8821a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE);
\r
2874 halbtc8821a1ant_InitCoexDm(pBtCoexist);
\r
2875 halbtc8821a1ant_QueryBtInfo(pBtCoexist);
\r
2880 EXhalbtc8821a1ant_LpsNotify(
\r
2881 IN PBTC_COEXIST pBtCoexist,
\r
2885 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
2888 if(BTC_LPS_ENABLE == type)
\r
2890 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
\r
2891 pCoexSta->bUnderLps = TRUE;
\r
2893 else if(BTC_LPS_DISABLE == type)
\r
2895 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
\r
2896 pCoexSta->bUnderLps = FALSE;
\r
2901 EXhalbtc8821a1ant_ScanNotify(
\r
2902 IN PBTC_COEXIST pBtCoexist,
\r
2906 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2907 u4Byte wifiLinkStatus=0;
\r
2908 u4Byte numOfWifiLink=0;
\r
2909 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
2910 u1Byte aggBufSize=5;
\r
2912 if(pBtCoexist->bManualControl ||
\r
2913 pBtCoexist->bStopCoexDm )
\r
2916 if(BTC_SCAN_START == type)
\r
2918 pCoexSta->bWiFiIsHighPriTask = TRUE;
\r
2919 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
\r
2921 halbtc8821a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue
\r
2925 pCoexSta->bWiFiIsHighPriTask = FALSE;
\r
2926 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
\r
2929 if(pBtCoexist->btInfo.bBtDisabled)
\r
2932 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2933 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2935 halbtc8821a1ant_QueryBtInfo(pBtCoexist);
\r
2937 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
2938 numOfWifiLink = wifiLinkStatus>>16;
\r
2939 if(numOfWifiLink >= 2)
\r
2941 halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2942 halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
2943 halbtc8821a1ant_ActionWifiMultiPort(pBtCoexist);
\r
2947 if(pCoexSta->bC2hBtInquiryPage)
\r
2949 halbtc8821a1ant_ActionBtInquiry(pBtCoexist);
\r
2954 halbtc8821a1ant_ActionHs(pBtCoexist);
\r
2958 if(BTC_SCAN_START == type)
\r
2960 //BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
\r
2961 if(!bWifiConnected) // non-connected scan
\r
2963 halbtc8821a1ant_ActionWifiNotConnectedScan(pBtCoexist);
\r
2965 else // wifi is connected
\r
2967 halbtc8821a1ant_ActionWifiConnectedScan(pBtCoexist);
\r
2970 else if(BTC_SCAN_FINISH == type)
\r
2972 //BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
\r
2973 if(!bWifiConnected) // non-connected scan
\r
2975 halbtc8821a1ant_ActionWifiNotConnected(pBtCoexist);
\r
2979 halbtc8821a1ant_ActionWifiConnected(pBtCoexist);
\r
2985 EXhalbtc8821a1ant_ConnectNotify(
\r
2986 IN PBTC_COEXIST pBtCoexist,
\r
2990 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2991 u4Byte wifiLinkStatus=0;
\r
2992 u4Byte numOfWifiLink=0;
\r
2993 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
2994 u1Byte aggBufSize=5;
\r
2996 if(pBtCoexist->bManualControl ||
\r
2997 pBtCoexist->bStopCoexDm ||
\r
2998 pBtCoexist->btInfo.bBtDisabled )
\r
3001 if(BTC_ASSOCIATE_START == type)
\r
3003 pCoexSta->bWiFiIsHighPriTask = TRUE;
\r
3004 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
\r
3005 pCoexDm->nArpCnt = 0;
\r
3009 pCoexSta->bWiFiIsHighPriTask = FALSE;
\r
3010 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
\r
3011 pCoexDm->nArpCnt = 0;
\r
3014 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
3015 numOfWifiLink = wifiLinkStatus>>16;
\r
3016 if(numOfWifiLink >= 2)
\r
3018 halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
3019 halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
3020 halbtc8821a1ant_ActionWifiMultiPort(pBtCoexist);
\r
3024 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
3025 if(pCoexSta->bC2hBtInquiryPage)
\r
3027 halbtc8821a1ant_ActionBtInquiry(pBtCoexist);
\r
3032 halbtc8821a1ant_ActionHs(pBtCoexist);
\r
3036 if(BTC_ASSOCIATE_START == type)
\r
3038 //BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
\r
3039 halbtc8821a1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
\r
3041 else if(BTC_ASSOCIATE_FINISH == type)
\r
3043 //BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
\r
3045 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
3046 if(!bWifiConnected) // non-connected scan
\r
3048 halbtc8821a1ant_ActionWifiNotConnected(pBtCoexist);
\r
3052 halbtc8821a1ant_ActionWifiConnected(pBtCoexist);
\r
3058 EXhalbtc8821a1ant_MediaStatusNotify(
\r
3059 IN PBTC_COEXIST pBtCoexist,
\r
3063 u1Byte H2C_Parameter[3] ={0};
\r
3065 u1Byte wifiCentralChnl;
\r
3067 if(pBtCoexist->bManualControl ||
\r
3068 pBtCoexist->bStopCoexDm ||
\r
3069 pBtCoexist->btInfo.bBtDisabled )
\r
3072 if(BTC_MEDIA_CONNECT == type)
\r
3074 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
\r
3078 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
\r
3079 pCoexDm->nArpCnt = 0;
\r
3082 // only 2.4G we need to inform bt the chnl mask
\r
3083 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
\r
3084 if( (BTC_MEDIA_CONNECT == type) &&
\r
3085 (wifiCentralChnl <= 14) )
\r
3087 //H2C_Parameter[0] = 0x1;
\r
3088 H2C_Parameter[0] = 0x0;
\r
3089 H2C_Parameter[1] = wifiCentralChnl;
\r
3090 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3091 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3092 H2C_Parameter[2] = 0x30;
\r
3094 H2C_Parameter[2] = 0x20;
\r
3097 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
\r
3098 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
\r
3099 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
\r
3101 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x66=0x%x\n",
\r
3102 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
\r
3104 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
\r
3108 EXhalbtc8821a1ant_SpecialPacketNotify(
\r
3109 IN PBTC_COEXIST pBtCoexist,
\r
3113 BOOLEAN bBtHsOn=FALSE;
\r
3114 u4Byte wifiLinkStatus=0;
\r
3115 u4Byte numOfWifiLink=0;
\r
3116 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
3117 u1Byte aggBufSize=5;
\r
3119 if(pBtCoexist->bManualControl ||
\r
3120 pBtCoexist->bStopCoexDm ||
\r
3121 pBtCoexist->btInfo.bBtDisabled )
\r
3124 if( BTC_PACKET_DHCP == type ||
\r
3125 BTC_PACKET_EAPOL == type ||
\r
3126 BTC_PACKET_ARP == type )
\r
3128 pCoexSta->bWiFiIsHighPriTask = TRUE;
\r
3130 if(BTC_PACKET_ARP == type)
\r
3132 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet ARP notify\n"));
\r
3136 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet DHCP or EAPOL notify\n"));
\r
3141 pCoexSta->bWiFiIsHighPriTask = FALSE;
\r
3142 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet [Type = %d] notify\n", type));
\r
3145 pCoexSta->specialPktPeriodCnt = 0;
\r
3147 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
3148 numOfWifiLink = wifiLinkStatus>>16;
\r
3149 if(numOfWifiLink >= 2)
\r
3151 halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
3152 halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
3153 halbtc8821a1ant_ActionWifiMultiPort(pBtCoexist);
\r
3157 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
3158 if(pCoexSta->bC2hBtInquiryPage)
\r
3160 halbtc8821a1ant_ActionBtInquiry(pBtCoexist);
\r
3165 halbtc8821a1ant_ActionHs(pBtCoexist);
\r
3169 if( BTC_PACKET_DHCP == type ||
\r
3170 BTC_PACKET_EAPOL == type ||
\r
3171 BTC_PACKET_ARP == type )
\r
3173 //BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet(%d) notify\n", type));
\r
3174 if(BTC_PACKET_ARP == type)
\r
3176 pCoexDm->nArpCnt++;
\r
3177 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt));
\r
3178 if(pCoexDm->nArpCnt >= 10) // if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist)
\r
3182 halbtc8821a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
3187 EXhalbtc8821a1ant_BtInfoNotify(
\r
3188 IN PBTC_COEXIST pBtCoexist,
\r
3189 IN pu1Byte tmpBuf,
\r
3193 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
3195 u1Byte i, rspSource=0;
\r
3196 BOOLEAN bWifiConnected=FALSE;
\r
3197 BOOLEAN bBtBusy=FALSE;
\r
3198 BOOLEAN bWifiUnder5G=FALSE;
\r
3200 pCoexSta->bC2hBtInfoReqSent = FALSE;
\r
3202 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
3204 rspSource = tmpBuf[0]&0xf;
\r
3205 if(rspSource >= BT_INFO_SRC_8821A_1ANT_MAX)
\r
3206 rspSource = BT_INFO_SRC_8821A_1ANT_WIFI_FW;
\r
3207 pCoexSta->btInfoC2hCnt[rspSource]++;
\r
3209 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
\r
3210 for(i=0; i<length; i++)
\r
3212 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
\r
3214 btInfo = tmpBuf[i];
\r
3217 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
\r
3221 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
\r
3225 if(BT_INFO_SRC_8821A_1ANT_WIFI_FW != rspSource)
\r
3227 pCoexSta->btRetryCnt = // [3:0]
\r
3228 pCoexSta->btInfoC2h[rspSource][2]&0xf;
\r
3230 if (pCoexSta->btInfoC2h[rspSource][2]&0x20)
\r
3231 pCoexSta->bC2hBtPage = TRUE;
\r
3233 pCoexSta->bC2hBtPage = FALSE;
\r
3235 pCoexSta->btRssi =
\r
3236 pCoexSta->btInfoC2h[rspSource][3]*2+10;
\r
3238 pCoexSta->btInfoExt =
\r
3239 pCoexSta->btInfoC2h[rspSource][4];
\r
3241 pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
\r
3242 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
\r
3243 if(!pCoexSta->bBtTxRxMask)
\r
3245 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */
\r
3246 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n"));
\r
3247 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15);
\r
3250 // Here we need to resend some wifi info to BT
\r
3251 // because bt is reset and loss of the info.
\r
3252 if(pCoexSta->btInfoExt & BIT1)
\r
3254 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
\r
3255 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
3256 if(bWifiConnected)
\r
3258 EXhalbtc8821a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
\r
3262 EXhalbtc8821a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
3266 if( (pCoexSta->btInfoExt & BIT3) && !bWifiUnder5G)
\r
3268 if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm)
\r
3270 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
\r
3271 halbtc8821a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
3276 // BT already NOT ignore Wlan active, do nothing here.
\r
3278 #if(BT_AUTO_REPORT_ONLY_8821A_1ANT == 0)
\r
3279 if( (pCoexSta->btInfoExt & BIT4) )
\r
3281 // BT auto report already enabled, do nothing
\r
3285 halbtc8821a1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);
\r
3290 // check BIT2 first ==> check if bt is under inquiry or page scan
\r
3291 if(btInfo & BT_INFO_8821A_1ANT_B_INQ_PAGE)
\r
3292 pCoexSta->bC2hBtInquiryPage = TRUE;
\r
3294 pCoexSta->bC2hBtInquiryPage = FALSE;
\r
3296 // set link exist status
\r
3297 if(!(btInfo&BT_INFO_8821A_1ANT_B_CONNECTION))
\r
3299 pCoexSta->bBtLinkExist = FALSE;
\r
3300 pCoexSta->bPanExist = FALSE;
\r
3301 pCoexSta->bA2dpExist = FALSE;
\r
3302 pCoexSta->bHidExist = FALSE;
\r
3303 pCoexSta->bScoExist = FALSE;
\r
3305 else // connection exists
\r
3307 pCoexSta->bBtLinkExist = TRUE;
\r
3308 if(btInfo & BT_INFO_8821A_1ANT_B_FTP)
\r
3309 pCoexSta->bPanExist = TRUE;
\r
3311 pCoexSta->bPanExist = FALSE;
\r
3312 if(btInfo & BT_INFO_8821A_1ANT_B_A2DP)
\r
3313 pCoexSta->bA2dpExist = TRUE;
\r
3315 pCoexSta->bA2dpExist = FALSE;
\r
3316 if(btInfo & BT_INFO_8821A_1ANT_B_HID)
\r
3317 pCoexSta->bHidExist = TRUE;
\r
3319 pCoexSta->bHidExist = FALSE;
\r
3320 if(btInfo & BT_INFO_8821A_1ANT_B_SCO_ESCO)
\r
3321 pCoexSta->bScoExist = TRUE;
\r
3323 pCoexSta->bScoExist = FALSE;
\r
3326 halbtc8821a1ant_UpdateBtLinkInfo(pBtCoexist);
\r
3328 btInfo = btInfo & 0x1f; //mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41)
\r
3330 if(!(btInfo&BT_INFO_8821A_1ANT_B_CONNECTION))
\r
3332 pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
\r
3333 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
\r
3335 else if(btInfo == BT_INFO_8821A_1ANT_B_CONNECTION) // connection exists but no busy
\r
3337 pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE;
\r
3338 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
\r
3340 else if((btInfo&BT_INFO_8821A_1ANT_B_SCO_ESCO) ||
\r
3341 (btInfo&BT_INFO_8821A_1ANT_B_SCO_BUSY))
\r
3343 pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_SCO_BUSY;
\r
3344 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
\r
3346 else if(btInfo&BT_INFO_8821A_1ANT_B_ACL_BUSY)
\r
3348 if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
\r
3349 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
3350 pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_ACL_BUSY;
\r
3351 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
\r
3355 pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_MAX;
\r
3356 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
\r
3359 if( (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
3360 (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
3361 (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
3365 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
3367 halbtc8821a1ant_RunCoexistMechanism(pBtCoexist);
\r
3371 EXhalbtc8821a1ant_HaltNotify(
\r
3372 IN PBTC_COEXIST pBtCoexist
\r
3377 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
\r
3379 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3380 halbtc8821a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
\r
3381 halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
3382 //halbtc8821a1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF);
\r
3384 halbtc8821a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
3386 EXhalbtc8821a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
3388 pBtCoexist->bStopCoexDm = TRUE;
\r
3392 EXhalbtc8821a1ant_PnpNotify(
\r
3393 IN PBTC_COEXIST pBtCoexist,
\r
3394 IN u1Byte pnpState
\r
3397 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
\r
3399 if(BTC_WIFI_PNP_SLEEP == pnpState)
\r
3401 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to SLEEP\n"));
\r
3403 halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3404 halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
3405 halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
3406 halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
3407 //halbtc8821a1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF);
\r
3409 pBtCoexist->bStopCoexDm = TRUE;
\r
3411 else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
\r
3413 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to WAKE UP\n"));
\r
3414 pBtCoexist->bStopCoexDm = FALSE;
\r
3415 halbtc8821a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE);
\r
3416 halbtc8821a1ant_InitCoexDm(pBtCoexist);
\r
3417 halbtc8821a1ant_QueryBtInfo(pBtCoexist);
\r
3422 EXhalbtc8821a1ant_Periodical(
\r
3423 IN PBTC_COEXIST pBtCoexist
\r
3426 static u1Byte disVerInfoCnt=0;
\r
3427 u4Byte fwVer=0, btPatchVer=0;
\r
3428 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
3429 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
3431 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical===========================\n"));
\r
3433 if(disVerInfoCnt <= 5)
\r
3435 disVerInfoCnt += 1;
\r
3436 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
3437 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", \
\r
3438 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));
\r
3439 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", \
\r
3440 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
\r
3441 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
3442 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
3443 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
\r
3444 GLCoexVerDate8821a1Ant, GLCoexVer8821a1Ant, fwVer, btPatchVer, btPatchVer));
\r
3445 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
3448 #if(BT_AUTO_REPORT_ONLY_8821A_1ANT == 0)
\r
3449 halbtc8821a1ant_QueryBtInfo(pBtCoexist);
\r
3450 halbtc8821a1ant_MonitorBtCtr(pBtCoexist);
\r
3451 halbtc8821a1ant_MonitorBtEnableDisable(pBtCoexist);
\r
3453 if( halbtc8821a1ant_IsWifiStatusChanged(pBtCoexist) ||
\r
3454 pCoexDm->bAutoTdmaAdjust )
\r
3456 //if(pCoexSta->specialPktPeriodCnt > 2)
\r
3458 halbtc8821a1ant_RunCoexistMechanism(pBtCoexist);
\r
3462 pCoexSta->specialPktPeriodCnt++;
\r