1 //============================================================
\r
4 // This file is for RTL8723B 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_8723B_1ANT GLCoexDm8723b1Ant;
\r
20 static PCOEX_DM_8723B_1ANT pCoexDm=&GLCoexDm8723b1Ant;
\r
21 static COEX_STA_8723B_1ANT GLCoexSta8723b1Ant;
\r
22 static PCOEX_STA_8723B_1ANT pCoexSta=&GLCoexSta8723b1Ant;
\r
24 const char *const GLBtInfoSrc8723b1Ant[]={
\r
27 "BT Info[bt auto report]",
\r
30 u4Byte GLCoexVerDate8723b1Ant=20130918;
\r
31 u4Byte GLCoexVer8723b1Ant=0x47;
\r
33 //============================================================
\r
34 // local function proto type if needed
\r
35 //============================================================
\r
36 //============================================================
\r
37 // local function start with halbtc8723b1ant_
\r
38 //============================================================
\r
40 halbtc8723b1ant_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_8723B_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_8723B_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_8723B_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 halbtc8723b1ant_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_8723B_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_8723B_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_8723B_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 halbtc8723b1ant_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 halbtc8723b1ant_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 halbtc8723b1ant_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 halbtc8723b1ant_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 halbtc8723b1ant_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 halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0);
\r
372 case 1: // disable cck 1/2
\r
373 halbtc8723b1ant_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 halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7);
\r
382 halbtc8723b1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType);
\r
383 halbtc8723b1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType);
\r
384 halbtc8723b1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType);
\r
388 halbtc8723b1ant_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 halbtc8723b1ant_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
427 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
\r
428 regHPTx = u4Tmp & bMaskLWord;
\r
429 regHPRx = (u4Tmp & bMaskHWord)>>16;
\r
431 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
\r
432 regLPTx = u4Tmp & bMaskLWord;
\r
433 regLPRx = (u4Tmp & bMaskHWord)>>16;
\r
435 pCoexSta->highPriorityTx = regHPTx;
\r
436 pCoexSta->highPriorityRx = regHPRx;
\r
437 pCoexSta->lowPriorityTx = regLPTx;
\r
438 pCoexSta->lowPriorityRx = regLPRx;
\r
441 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
445 halbtc8723b1ant_QueryBtInfo(
\r
446 IN PBTC_COEXIST pBtCoexist
\r
449 u1Byte H2C_Parameter[1] ={0};
\r
451 pCoexSta->bC2hBtInfoReqSent = TRUE;
\r
453 H2C_Parameter[0] |= BIT0; // trigger
\r
455 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
\r
456 H2C_Parameter[0]));
\r
458 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
\r
462 halbtc8723b1ant_IsWifiStatusChanged(
\r
463 IN PBTC_COEXIST pBtCoexist
\r
466 static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;
\r
467 BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;
\r
468 BOOLEAN bWifiConnected=FALSE;
\r
470 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
471 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
472 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
473 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
477 if(bWifiBusy != bPreWifiBusy)
\r
479 bPreWifiBusy = bWifiBusy;
\r
482 if(bUnder4way != bPreUnder4way)
\r
484 bPreUnder4way = bUnder4way;
\r
487 if(bBtHsOn != bPreBtHsOn)
\r
489 bPreBtHsOn = bBtHsOn;
\r
498 halbtc8723b1ant_UpdateBtLinkInfo(
\r
499 IN PBTC_COEXIST pBtCoexist
\r
502 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
503 BOOLEAN bBtHsOn=FALSE;
\r
505 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
507 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
\r
508 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
\r
509 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
\r
510 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
\r
511 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
\r
513 // work around for HS mode.
\r
516 pBtLinkInfo->bPanExist = TRUE;
\r
517 pBtLinkInfo->bBtLinkExist = TRUE;
\r
520 // check if Sco only
\r
521 if( pBtLinkInfo->bScoExist &&
\r
522 !pBtLinkInfo->bA2dpExist &&
\r
523 !pBtLinkInfo->bPanExist &&
\r
524 !pBtLinkInfo->bHidExist )
\r
525 pBtLinkInfo->bScoOnly = TRUE;
\r
527 pBtLinkInfo->bScoOnly = FALSE;
\r
529 // check if A2dp only
\r
530 if( !pBtLinkInfo->bScoExist &&
\r
531 pBtLinkInfo->bA2dpExist &&
\r
532 !pBtLinkInfo->bPanExist &&
\r
533 !pBtLinkInfo->bHidExist )
\r
534 pBtLinkInfo->bA2dpOnly = TRUE;
\r
536 pBtLinkInfo->bA2dpOnly = FALSE;
\r
538 // check if Pan only
\r
539 if( !pBtLinkInfo->bScoExist &&
\r
540 !pBtLinkInfo->bA2dpExist &&
\r
541 pBtLinkInfo->bPanExist &&
\r
542 !pBtLinkInfo->bHidExist )
\r
543 pBtLinkInfo->bPanOnly = TRUE;
\r
545 pBtLinkInfo->bPanOnly = FALSE;
\r
547 // check if Hid only
\r
548 if( !pBtLinkInfo->bScoExist &&
\r
549 !pBtLinkInfo->bA2dpExist &&
\r
550 !pBtLinkInfo->bPanExist &&
\r
551 pBtLinkInfo->bHidExist )
\r
552 pBtLinkInfo->bHidOnly = TRUE;
\r
554 pBtLinkInfo->bHidOnly = FALSE;
\r
558 halbtc8723b1ant_ActionAlgorithm(
\r
559 IN PBTC_COEXIST pBtCoexist
\r
562 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
563 BOOLEAN bBtHsOn=FALSE;
\r
564 u1Byte algorithm=BT_8723B_1ANT_COEX_ALGO_UNDEFINED;
\r
565 u1Byte numOfDiffProfile=0;
\r
567 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
569 if(!pBtLinkInfo->bBtLinkExist)
\r
571 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n"));
\r
575 if(pBtLinkInfo->bScoExist)
\r
576 numOfDiffProfile++;
\r
577 if(pBtLinkInfo->bHidExist)
\r
578 numOfDiffProfile++;
\r
579 if(pBtLinkInfo->bPanExist)
\r
580 numOfDiffProfile++;
\r
581 if(pBtLinkInfo->bA2dpExist)
\r
582 numOfDiffProfile++;
\r
584 if(numOfDiffProfile == 1)
\r
586 if(pBtLinkInfo->bScoExist)
\r
588 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO only\n"));
\r
589 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
\r
593 if(pBtLinkInfo->bHidExist)
\r
595 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID only\n"));
\r
596 algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
\r
598 else if(pBtLinkInfo->bA2dpExist)
\r
600 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP only\n"));
\r
601 algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP;
\r
603 else if(pBtLinkInfo->bPanExist)
\r
607 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = PAN(HS) only\n"));
\r
608 algorithm = BT_8723B_1ANT_COEX_ALGO_PANHS;
\r
612 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = PAN(EDR) only\n"));
\r
613 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR;
\r
618 else if(numOfDiffProfile == 2)
\r
620 if(pBtLinkInfo->bScoExist)
\r
622 if(pBtLinkInfo->bHidExist)
\r
624 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID\n"));
\r
625 algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
\r
627 else if(pBtLinkInfo->bA2dpExist)
\r
629 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n"));
\r
630 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
\r
632 else if(pBtLinkInfo->bPanExist)
\r
636 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + PAN(HS)\n"));
\r
637 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
\r
641 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n"));
\r
642 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
648 if( pBtLinkInfo->bHidExist &&
\r
649 pBtLinkInfo->bA2dpExist )
\r
651 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP\n"));
\r
652 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
\r
654 else if( pBtLinkInfo->bHidExist &&
\r
655 pBtLinkInfo->bPanExist )
\r
659 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + PAN(HS)\n"));
\r
660 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
\r
664 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + PAN(EDR)\n"));
\r
665 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
668 else if( pBtLinkInfo->bPanExist &&
\r
669 pBtLinkInfo->bA2dpExist )
\r
673 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n"));
\r
674 algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS;
\r
678 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n"));
\r
679 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP;
\r
684 else if(numOfDiffProfile == 3)
\r
686 if(pBtLinkInfo->bScoExist)
\r
688 if( pBtLinkInfo->bHidExist &&
\r
689 pBtLinkInfo->bA2dpExist )
\r
691 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n"));
\r
692 algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
\r
694 else if( pBtLinkInfo->bHidExist &&
\r
695 pBtLinkInfo->bPanExist )
\r
699 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n"));
\r
700 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
\r
704 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n"));
\r
705 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
708 else if( pBtLinkInfo->bPanExist &&
\r
709 pBtLinkInfo->bA2dpExist )
\r
713 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n"));
\r
714 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
\r
718 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n"));
\r
719 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
725 if( pBtLinkInfo->bHidExist &&
\r
726 pBtLinkInfo->bPanExist &&
\r
727 pBtLinkInfo->bA2dpExist )
\r
731 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n"));
\r
732 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
\r
736 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n"));
\r
737 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
\r
742 else if(numOfDiffProfile >= 3)
\r
744 if(pBtLinkInfo->bScoExist)
\r
746 if( pBtLinkInfo->bHidExist &&
\r
747 pBtLinkInfo->bPanExist &&
\r
748 pBtLinkInfo->bA2dpExist )
\r
752 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n"));
\r
757 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
\r
758 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
768 halbtc8723b1ant_SetBtAutoReport(
\r
769 IN PBTC_COEXIST pBtCoexist,
\r
770 IN BOOLEAN bEnableAutoReport
\r
773 u1Byte H2C_Parameter[1] ={0};
\r
775 H2C_Parameter[0] = 0;
\r
777 if(bEnableAutoReport)
\r
779 H2C_Parameter[0] |= BIT0;
\r
782 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
\r
783 (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));
\r
785 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter);
\r
789 halbtc8723b1ant_BtAutoReport(
\r
790 IN PBTC_COEXIST pBtCoexist,
\r
791 IN BOOLEAN bForceExec,
\r
792 IN BOOLEAN bEnableAutoReport
\r
795 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Auto report = %s\n",
\r
796 (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
\r
797 pCoexDm->bCurBtAutoReport = bEnableAutoReport;
\r
801 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
\r
802 pCoexDm->bPreBtAutoReport, pCoexDm->bCurBtAutoReport));
\r
804 if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
\r
807 halbtc8723b1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
\r
809 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
\r
813 halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(
\r
814 IN PBTC_COEXIST pBtCoexist,
\r
815 IN BOOLEAN bLowPenaltyRa
\r
818 u1Byte H2C_Parameter[6] ={0};
\r
820 H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty
\r
824 H2C_Parameter[1] |= BIT0;
\r
825 H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36
\r
826 H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54
\r
827 H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48
\r
828 H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36
\r
831 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set WiFi Low-Penalty Retry: %s",
\r
832 (bLowPenaltyRa? "ON!!":"OFF!!") ));
\r
834 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
\r
838 halbtc8723b1ant_LowPenaltyRa(
\r
839 IN PBTC_COEXIST pBtCoexist,
\r
840 IN BOOLEAN bForceExec,
\r
841 IN BOOLEAN bLowPenaltyRa
\r
844 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
848 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
851 halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
853 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
857 halbtc8723b1ant_SetCoexTable(
\r
858 IN PBTC_COEXIST pBtCoexist,
\r
859 IN u4Byte val0x6c0,
\r
860 IN u4Byte val0x6c4,
\r
861 IN u4Byte val0x6c8,
\r
865 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
\r
866 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
\r
868 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
\r
869 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
\r
871 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
872 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
874 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
875 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
879 halbtc8723b1ant_CoexTable(
\r
880 IN PBTC_COEXIST pBtCoexist,
\r
881 IN BOOLEAN bForceExec,
\r
882 IN u4Byte val0x6c0,
\r
883 IN u4Byte val0x6c4,
\r
884 IN u4Byte val0x6c8,
\r
888 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6cc=0x%x\n",
\r
889 (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6cc));
\r
890 pCoexDm->curVal0x6c0 = val0x6c0;
\r
891 pCoexDm->curVal0x6c4 = val0x6c4;
\r
892 pCoexDm->curVal0x6c8 = val0x6c8;
\r
893 pCoexDm->curVal0x6cc = val0x6cc;
\r
897 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c4=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
\r
898 // pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
\r
899 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
\r
900 // pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
\r
902 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
\r
903 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
\r
904 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
905 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
908 halbtc8723b1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
\r
910 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
\r
911 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
\r
912 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
913 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
917 halbtc8723b1ant_CoexTableWithType(
\r
918 IN PBTC_COEXIST pBtCoexist,
\r
919 IN BOOLEAN bForceExec,
\r
926 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);
\r
929 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
\r
932 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);
\r
935 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3);
\r
938 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5aaa5aaa, 0xffffff, 0x3);
\r
941 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaa5a5a, 0xffffff, 0x3);
\r
944 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3);
\r
947 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
\r
955 halbtc8723b1ant_SetFwIgnoreWlanAct(
\r
956 IN PBTC_COEXIST pBtCoexist,
\r
960 u1Byte H2C_Parameter[1] ={0};
\r
964 H2C_Parameter[0] |= BIT0; // function enable
\r
967 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
\r
968 H2C_Parameter[0]));
\r
970 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
\r
974 halbtc8723b1ant_IgnoreWlanAct(
\r
975 IN PBTC_COEXIST pBtCoexist,
\r
976 IN BOOLEAN bForceExec,
\r
980 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
\r
981 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
\r
982 pCoexDm->bCurIgnoreWlanAct = bEnable;
\r
986 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
\r
987 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
\r
989 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
\r
992 halbtc8723b1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
\r
994 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
\r
998 halbtc8723b1ant_SetFwPstdma(
\r
999 IN PBTC_COEXIST pBtCoexist,
\r
1007 u1Byte H2C_Parameter[5] ={0};
\r
1008 u1Byte realByte1=byte1, realByte5=byte5;
\r
1009 BOOLEAN bApEnable=FALSE;
\r
1011 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
1015 if(byte1&BIT4 && !(byte1&BIT5))
\r
1017 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], FW for 1Ant AP mode\n"));
\r
1018 realByte1 &= ~BIT4;
\r
1019 realByte1 |= BIT5;
\r
1021 realByte5 |= BIT5;
\r
1022 realByte5 &= ~BIT6;
\r
1026 H2C_Parameter[0] = realByte1;
\r
1027 H2C_Parameter[1] = byte2;
\r
1028 H2C_Parameter[2] = byte3;
\r
1029 H2C_Parameter[3] = byte4;
\r
1030 H2C_Parameter[4] = realByte5;
\r
1032 pCoexDm->psTdmaPara[0] = realByte1;
\r
1033 pCoexDm->psTdmaPara[1] = byte2;
\r
1034 pCoexDm->psTdmaPara[2] = byte3;
\r
1035 pCoexDm->psTdmaPara[3] = byte4;
\r
1036 pCoexDm->psTdmaPara[4] = realByte5;
\r
1038 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n",
\r
1039 H2C_Parameter[0],
\r
1040 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
\r
1042 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
\r
1046 halbtc8723b1ant_SetLpsRpwm(
\r
1047 IN PBTC_COEXIST pBtCoexist,
\r
1052 u1Byte lps=lpsVal;
\r
1053 u1Byte rpwm=rpwmVal;
\r
1055 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
\r
1056 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
\r
1060 halbtc8723b1ant_LpsRpwm(
\r
1061 IN PBTC_COEXIST pBtCoexist,
\r
1062 IN BOOLEAN bForceExec,
\r
1067 BOOLEAN bForceExecPwrCmd=FALSE;
\r
1069 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
\r
1070 (bForceExec? "force to":""), lpsVal, rpwmVal));
\r
1071 pCoexDm->curLps = lpsVal;
\r
1072 pCoexDm->curRpwm = rpwmVal;
\r
1076 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], LPS-RxBeaconMode=0x%x , LPS-RPWM=0x%x!!\n",
\r
1077 pCoexDm->curLps, pCoexDm->curRpwm));
\r
1079 if( (pCoexDm->preLps == pCoexDm->curLps) &&
\r
1080 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
\r
1082 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], LPS-RPWM_Last=0x%x , LPS-RPWM_Now=0x%x!!\n",
\r
1083 pCoexDm->preRpwm, pCoexDm->curRpwm));
\r
1088 halbtc8723b1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
\r
1090 pCoexDm->preLps = pCoexDm->curLps;
\r
1091 pCoexDm->preRpwm = pCoexDm->curRpwm;
\r
1095 halbtc8723b1ant_SwMechanism(
\r
1096 IN PBTC_COEXIST pBtCoexist,
\r
1097 IN BOOLEAN bLowPenaltyRA
\r
1100 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], SM[LpRA] = %d\n",
\r
1103 halbtc8723b1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
\r
1107 halbtc8723b1ant_SetAntPath(
\r
1108 IN PBTC_COEXIST pBtCoexist,
\r
1109 IN u1Byte antPosType,
\r
1110 IN BOOLEAN bInitHwCfg,
\r
1111 IN BOOLEAN bWifiOff
\r
1114 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1115 u4Byte fwVer=0, u4Tmp=0;
\r
1116 BOOLEAN bPgExtSwitch=FALSE;
\r
1117 BOOLEAN bUseExtSwitch=FALSE;
\r
1118 u1Byte H2C_Parameter[2] ={0};
\r
1119 PADAPTER padapter=pBtCoexist->Adapter;
\r
1120 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch);
\r
1121 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); // [31:16]=fw ver, [15:0]=fw sub ver
\r
1124 if((fwVer<0xc0000) || bPgExtSwitch)
\r
1125 bUseExtSwitch = TRUE;
\r
1129 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi
\r
1131 //Force GNT_BT to Normal
\r
1132 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x765, 0x18, 0x0);
\r
1134 //set wlan_act control by PTA
\r
1135 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
1137 //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
1141 //Force GNT_BT to High
\r
1142 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x765, 0x18, 0x3);
\r
1144 //set wlan_act to always low
\r
1145 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
1147 if(padapter->registrypriv.mp_mode ==0)
\r
1148 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); //BT select s0/s1 is controlled by BT
\r
1150 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi
\r
1152 // 0x4c[24:23]=00, Set Antenna control by BT_RFE_CTRL BT Vendor 0xac=0xf002
\r
1153 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1156 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1163 // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT
\r
1164 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1167 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1169 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1171 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x1); //Main Ant to BT for IPS case 0x4c[23]=1
\r
1173 //tell firmware "no antenna inverse"
\r
1174 H2C_Parameter[0] = 0;
\r
1175 H2C_Parameter[1] = 1; //ext switch type
\r
1176 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1180 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); //Aux Ant to BT for IPS case 0x4c[23]=1
\r
1182 //tell firmware "antenna inverse"
\r
1183 H2C_Parameter[0] = 1;
\r
1184 H2C_Parameter[1] = 1; //ext switch type
\r
1185 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1189 // fixed internal switch first
\r
1190 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1191 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x948, 0x0); // fixed internal switch S1->WiFi, S0->BT
\r
1193 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x948, 0x280); // fixed internal switch S0->WiFi, S1->BT
\r
1195 // ext switch setting
\r
1196 switch(antPosType)
\r
1198 case BTC_ANT_PATH_WIFI:
\r
1199 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1200 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
\r
1202 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
\r
1204 case BTC_ANT_PATH_BT:
\r
1205 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1206 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
\r
1208 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
\r
1211 case BTC_ANT_PATH_PTA:
\r
1212 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1213 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
\r
1215 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
\r
1224 // 0x4c[23]=1, 0x4c[24]=0 Antenna control by 0x64
\r
1225 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1228 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1230 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1232 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); //Main Ant to WiFi for IPS case 0x4c[23]=1
\r
1234 //tell firmware "no antenna inverse"
\r
1235 H2C_Parameter[0] = 0;
\r
1236 H2C_Parameter[1] = 0; //internal switch type
\r
1237 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1241 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x1); //Aux Ant to BT for IPS case 0x4c[23]=1
\r
1243 //tell firmware "antenna inverse"
\r
1244 H2C_Parameter[0] = 1;
\r
1245 H2C_Parameter[1] = 0; //internal switch type
\r
1246 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1250 // fixed external switch first
\r
1251 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1252 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); //Main->WiFi, Aux->BT
\r
1254 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); //Main->BT, Aux->WiFi
\r
1256 // internal switch setting
\r
1257 switch(antPosType)
\r
1259 case BTC_ANT_PATH_WIFI:
\r
1260 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1261 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x948, 0x0);
\r
1263 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x948, 0x280);
\r
1265 case BTC_ANT_PATH_BT:
\r
1266 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1267 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x948, 0x280);
\r
1269 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x948, 0x0);
\r
1272 case BTC_ANT_PATH_PTA:
\r
1273 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1274 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x948, 0x200);
\r
1276 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x948, 0x80);
\r
1283 halbtc8723b1ant_PsTdma(
\r
1284 IN PBTC_COEXIST pBtCoexist,
\r
1285 IN BOOLEAN bForceExec,
\r
1286 IN BOOLEAN bTurnOn,
\r
1290 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1291 BOOLEAN bTurnOnByCnt=FALSE, bWifiBusy=FALSE;
\r
1292 u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0;
\r
1295 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
\r
1296 // (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
\r
1297 pCoexDm->bCurPsTdmaOn = bTurnOn;
\r
1298 pCoexDm->curPsTdma = type;
\r
1300 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1304 if (pCoexDm->bCurPsTdmaOn)
\r
1306 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], ********** TDMA(on, %d) **********\n",
\r
1307 pCoexDm->curPsTdma));
\r
1311 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], ********** TDMA(off, %d) **********\n",
\r
1312 pCoexDm->curPsTdma));
\r
1316 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
\r
1317 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
\r
1325 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, 0x50);
\r
1329 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x3a, 0x03, 0x10, 0x50);
\r
1331 // halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x3a, 0x03, 0x10, 0x51);
\r
1333 rssiAdjustVal = 11;
\r
1337 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x2b, 0x03, 0x10, 0x50);
\r
1339 // halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x2b, 0x03, 0x10, 0x51);
\r
1340 rssiAdjustVal = 14;
\r
1343 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, 0x52);
\r
1346 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
\r
1347 rssiAdjustVal = 17;
\r
1350 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x10);
\r
1353 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x13);
\r
1356 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
\r
1359 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1363 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, 0x50);
\r
1365 // halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, 0x50);
\r
1366 rssiAdjustVal = 18;
\r
1369 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
\r
1373 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x15, 0x03, 0x10, 0x50);
\r
1375 // halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x15, 0x03, 0x10, 0x50);
\r
1376 rssiAdjustVal = 20;
\r
1379 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50);
\r
1382 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x15, 0x15, 0x0, 0x50);
\r
1385 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, 0x52);
\r
1388 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0);
\r
1391 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0);
\r
1392 rssiAdjustVal = 18;
\r
1395 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1396 rssiAdjustVal = 14;
\r
1399 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x03, 0x11, 0x10);
\r
1402 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11);
\r
1405 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10);
\r
1408 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);
\r
1409 rssiAdjustVal = 22;
\r
1412 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);
\r
1413 rssiAdjustVal = 22;
\r
1416 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1417 rssiAdjustVal = 22;
\r
1420 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1421 rssiAdjustVal = 22;
\r
1424 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);
\r
1425 rssiAdjustVal = 22;
\r
1428 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0);
\r
1431 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10);
\r
1434 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x14, 0x3, 0x10, 0x50);
\r
1437 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);
\r
1440 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0xa, 0x3, 0x10, 0x0);
\r
1443 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90);
\r
1446 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10);
\r
1449 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10);
\r
1452 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50);
\r
1454 case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving
\r
1455 /* here softap mode screen off will cost 70-80mA for phone */
\r
1456 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24);
\r
1462 //pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); // [31:16]=fw ver, [15:0]=fw sub ver
\r
1464 // disable PS tdma
\r
1467 case 8: //PTA Control
\r
1468 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
\r
1469 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE);
\r
1472 default: //Software control, Antenna at BT side
\r
1473 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1474 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
\r
1476 case 9: //Software control, Antenna at WiFi side
\r
1477 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1478 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE);
\r
1483 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal);
\r
1485 // update pre state
\r
1486 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
\r
1487 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
\r
1491 halbtc8723b1ant_CoexAllOff(
\r
1492 IN PBTC_COEXIST pBtCoexist
\r
1496 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1499 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1503 halbtc8723b1ant_IsCommonAction(
\r
1504 IN PBTC_COEXIST pBtCoexist
\r
1507 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
1509 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1510 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1512 if(!bWifiConnected &&
\r
1513 BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
1515 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));
\r
1517 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1521 else if(bWifiConnected &&
\r
1522 (BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1524 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
\r
1526 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1530 else if(!bWifiConnected &&
\r
1531 (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1533 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));
\r
1535 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1539 else if(bWifiConnected &&
\r
1540 (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1542 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
\r
1544 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1548 else if(!bWifiConnected &&
\r
1549 (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) )
\r
1551 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
\r
1553 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1561 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
\r
1565 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));
\r
1576 halbtc8723b1ant_TdmaDurationAdjustForAcl(
\r
1577 IN PBTC_COEXIST pBtCoexist,
\r
1578 IN u1Byte wifiStatus
\r
1581 static s4Byte up,dn,m,n,WaitCount;
\r
1582 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
\r
1583 u1Byte retryCount=0, btInfoExt;
\r
1584 static BOOLEAN bPreWifiBusy=FALSE;
\r
1585 BOOLEAN bWifiBusy = FALSE;
\r
1587 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjustForAcl()\n"));
\r
1589 if(BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus)
\r
1592 bWifiBusy = FALSE;
\r
1594 if( (BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
\r
1595 (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
\r
1596 (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
\r
1598 if( pCoexDm->curPsTdma != 1 &&
\r
1599 pCoexDm->curPsTdma != 2 &&
\r
1600 pCoexDm->curPsTdma != 3 &&
\r
1601 pCoexDm->curPsTdma != 9 )
\r
1603 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1604 pCoexDm->psTdmaDuAdjType = 9;
\r
1616 if(!pCoexDm->bAutoTdmaAdjust)
\r
1618 pCoexDm->bAutoTdmaAdjust = TRUE;
\r
1619 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
\r
1621 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1622 pCoexDm->psTdmaDuAdjType = 2;
\r
1633 //accquire the BT TRx retry count from BT_Info byte2
\r
1634 retryCount = pCoexSta->btRetryCnt;
\r
1635 btInfoExt = pCoexSta->btInfoExt;
\r
1636 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
\r
1637 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
\r
1638 // up, dn, m, n, WaitCount));
\r
1642 if(retryCount == 0) // no retry in the last 2-second duration
\r
1650 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
\r
1657 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
\r
1660 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
\r
1668 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
\r
1670 if (WaitCount <= 2)
\r
1671 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1675 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1683 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
\r
1686 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
\r
1688 if (WaitCount == 1)
\r
1689 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1693 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1701 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
\r
1706 if( (BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1707 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1709 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1710 pCoexDm->psTdmaDuAdjType = 9;
\r
1712 else if(pCoexDm->curPsTdma == 1)
\r
1714 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1715 pCoexDm->psTdmaDuAdjType = 2;
\r
1717 else if(pCoexDm->curPsTdma == 2)
\r
1719 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1720 pCoexDm->psTdmaDuAdjType = 9;
\r
1722 else if(pCoexDm->curPsTdma == 9)
\r
1724 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
1725 pCoexDm->psTdmaDuAdjType = 11;
\r
1728 else if(result == 1)
\r
1730 if( (BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1731 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1733 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1734 pCoexDm->psTdmaDuAdjType = 9;
\r
1736 else if(pCoexDm->curPsTdma == 11)
\r
1738 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1739 pCoexDm->psTdmaDuAdjType = 9;
\r
1741 else if(pCoexDm->curPsTdma == 9)
\r
1743 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1744 pCoexDm->psTdmaDuAdjType = 2;
\r
1746 else if(pCoexDm->curPsTdma == 2)
\r
1748 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
1749 pCoexDm->psTdmaDuAdjType = 1;
\r
1755 if(bWifiBusy != bPreWifiBusy) //if busy / idle change
\r
1757 bPreWifiBusy = bWifiBusy;
\r
1758 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, pCoexDm->curPsTdma);
\r
1762 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], ********** TDMA(on, %d) **********\n",
\r
1763 pCoexDm->curPsTdma));
\r
1766 if( pCoexDm->curPsTdma != 1 &&
\r
1767 pCoexDm->curPsTdma != 2 &&
\r
1768 pCoexDm->curPsTdma != 9 &&
\r
1769 pCoexDm->curPsTdma != 11 )
\r
1771 // recover to previous adjust type
\r
1772 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
\r
1778 halbtc8723b1ant_PsTdmaCheckForPowerSaveState(
\r
1779 IN PBTC_COEXIST pBtCoexist,
\r
1780 IN BOOLEAN bNewPsState
\r
1783 u1Byte lpsMode=0x0;
\r
1785 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
\r
1787 if(lpsMode) // already under LPS state
\r
1791 // keep state under LPS, do nothing.
\r
1795 // will leave LPS state, turn off psTdma first
\r
1796 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1799 else // NO PS state
\r
1803 // will enter LPS state, turn off psTdma first
\r
1804 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1808 // keep state under NO PS state, do nothing.
\r
1814 halbtc8723b1ant_PowerSaveState(
\r
1815 IN PBTC_COEXIST pBtCoexist,
\r
1821 BOOLEAN bLowPwrDisable=FALSE;
\r
1825 case BTC_PS_WIFI_NATIVE:
\r
1826 // recover to original 32k low power setting
\r
1827 bLowPwrDisable = FALSE;
\r
1828 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1829 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1831 case BTC_PS_LPS_ON:
\r
1832 halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);
\r
1833 halbtc8723b1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
\r
1834 // when coex force to enter LPS, do not enter 32k low power.
\r
1835 bLowPwrDisable = TRUE;
\r
1836 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1837 // power save must executed before psTdma.
\r
1838 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
\r
1840 case BTC_PS_LPS_OFF:
\r
1841 halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
\r
1842 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1850 halbtc8723b1ant_ActionWifiOnly(
\r
1851 IN PBTC_COEXIST pBtCoexist
\r
1854 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1855 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1859 halbtc8723b1ant_MonitorBtEnableDisable(
\r
1860 IN PBTC_COEXIST pBtCoexist
\r
1863 static BOOLEAN bPreBtDisabled=FALSE;
\r
1864 static u4Byte btDisableCnt=0;
\r
1865 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
\r
1867 // This function check if bt is disabled
\r
1869 if( pCoexSta->highPriorityTx == 0 &&
\r
1870 pCoexSta->highPriorityRx == 0 &&
\r
1871 pCoexSta->lowPriorityTx == 0 &&
\r
1872 pCoexSta->lowPriorityRx == 0)
\r
1874 bBtActive = FALSE;
\r
1876 if( pCoexSta->highPriorityTx == 0xffff &&
\r
1877 pCoexSta->highPriorityRx == 0xffff &&
\r
1878 pCoexSta->lowPriorityTx == 0xffff &&
\r
1879 pCoexSta->lowPriorityRx == 0xffff)
\r
1881 bBtActive = FALSE;
\r
1886 bBtDisabled = FALSE;
\r
1887 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
1888 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
\r
1893 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
\r
1895 if(btDisableCnt >= 2)
\r
1897 bBtDisabled = TRUE;
\r
1898 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
1899 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
\r
1900 halbtc8723b1ant_ActionWifiOnly(pBtCoexist);
\r
1903 if(bPreBtDisabled != bBtDisabled)
\r
1905 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
\r
1906 (bPreBtDisabled ? "disabled":"enabled"),
\r
1907 (bBtDisabled ? "disabled":"enabled")));
\r
1908 bPreBtDisabled = bBtDisabled;
\r
1914 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1915 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1920 //=============================================
\r
1922 // Software Coex Mechanism start
\r
1924 //=============================================
\r
1926 // SCO only or SCO+PAN(HS)
\r
1928 halbtc8723b1ant_ActionSco(
\r
1929 IN PBTC_COEXIST pBtCoexist
\r
1932 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
1937 halbtc8723b1ant_ActionHid(
\r
1938 IN PBTC_COEXIST pBtCoexist
\r
1941 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
1944 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
\r
1946 halbtc8723b1ant_ActionA2dp(
\r
1947 IN PBTC_COEXIST pBtCoexist
\r
1950 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1954 halbtc8723b1ant_ActionA2dpPanHs(
\r
1955 IN PBTC_COEXIST pBtCoexist
\r
1958 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1962 halbtc8723b1ant_ActionPanEdr(
\r
1963 IN PBTC_COEXIST pBtCoexist
\r
1966 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1971 halbtc8723b1ant_ActionPanHs(
\r
1972 IN PBTC_COEXIST pBtCoexist
\r
1975 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1980 halbtc8723b1ant_ActionPanEdrA2dp(
\r
1981 IN PBTC_COEXIST pBtCoexist
\r
1984 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1988 halbtc8723b1ant_ActionPanEdrHid(
\r
1989 IN PBTC_COEXIST pBtCoexist
\r
1992 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
1995 // HID+A2DP+PAN(EDR)
\r
1997 halbtc8723b1ant_ActionHidA2dpPanEdr(
\r
1998 IN PBTC_COEXIST pBtCoexist
\r
2001 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
2005 halbtc8723b1ant_ActionHidA2dp(
\r
2006 IN PBTC_COEXIST pBtCoexist
\r
2009 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
2012 //=============================================
\r
2014 // Non-Software Coex Mechanism start
\r
2016 //=============================================
\r
2018 halbtc8723b1ant_ActionWifiMultiPort(
\r
2019 IN PBTC_COEXIST pBtCoexist
\r
2022 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2024 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2025 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2029 halbtc8723b1ant_ActionHs(
\r
2030 IN PBTC_COEXIST pBtCoexist
\r
2033 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2034 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2038 halbtc8723b1ant_ActionBtInquiry(
\r
2039 IN PBTC_COEXIST pBtCoexist
\r
2042 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2043 BOOLEAN bWifiConnected=FALSE, bApEnable=FALSE;
\r
2045 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
2046 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2048 if(!bWifiConnected)
\r
2050 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2051 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2052 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2054 else if( (pBtLinkInfo->bScoExist) ||
\r
2055 (pBtLinkInfo->bHidOnly) )
\r
2057 // SCO/HID-only busy
\r
2058 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2059 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2060 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2065 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2067 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
2068 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 30);
\r
2069 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2074 halbtc8723b1ant_ActionBtScoHidOnlyBusy(
\r
2075 IN PBTC_COEXIST pBtCoexist,
\r
2076 IN u1Byte wifiStatus
\r
2079 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2080 BOOLEAN bWifiConnected=FALSE;
\r
2081 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
\r
2083 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2085 // tdma and coex table
\r
2087 if(pBtLinkInfo->bScoExist)
\r
2089 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2090 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2094 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2095 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);
\r
2098 if(pBtLinkInfo->bScoExist || pBtLinkInfo->bHidExist)
\r
2100 if(bWifiConnected)
\r
2102 wifiRssiState = halbtc8723b1ant_WifiRssiState(pBtCoexist, 0, 2, 30, 0);
\r
2103 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
2104 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
2106 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 2, 1, 1, 1);
\r
2110 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 1, 1);
\r
2115 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2122 halbtc8723b1ant_ActionWifiConnectedBtAclBusy(
\r
2123 IN PBTC_COEXIST pBtCoexist,
\r
2124 IN u1Byte wifiStatus
\r
2127 u1Byte btRssiState;
\r
2129 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2130 btRssiState = halbtc8723b1ant_BtRssiState(2, 28, 0);
\r
2132 if(pBtLinkInfo->bHidOnly) //HID
\r
2134 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);
\r
2135 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2138 else if(pBtLinkInfo->bA2dpOnly) //A2DP
\r
2140 if(BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus)
\r
2142 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2143 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2144 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2146 else if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
2147 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
2149 halbtc8723b1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);
\r
2150 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2152 else //for low BT RSSI
\r
2154 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2155 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2156 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2159 else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) //HID+A2DP
\r
2161 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
2162 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
2164 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2165 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2167 else //for low BT RSSI
\r
2169 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2170 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2173 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 6);
\r
2175 else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP)
\r
2177 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2178 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 6);
\r
2179 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2181 else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) ||
\r
2182 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP)
\r
2184 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
2185 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2186 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2190 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2191 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2192 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2197 halbtc8723b1ant_ActionWifiNotConnected(
\r
2198 IN PBTC_COEXIST pBtCoexist
\r
2201 // power save state
\r
2202 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2204 // tdma and coex table
\r
2205 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2206 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2210 halbtc8723b1ant_ActionWifiNotConnectedScan(
\r
2211 IN PBTC_COEXIST pBtCoexist
\r
2214 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2216 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2218 // tdma and coex table
\r
2219 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2221 if(pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)
\r
2223 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
2224 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2226 else if(pBtLinkInfo->bPanOnly)
\r
2228 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2229 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2233 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2234 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2237 else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2238 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2240 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2241 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
2245 //halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2246 //halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2249 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2250 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2255 halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(
\r
2256 IN PBTC_COEXIST pBtCoexist
\r
2259 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2261 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2264 if( (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ||(pBtLinkInfo->bScoExist)
\r
2265 || (pBtLinkInfo->bHidOnly) || (pBtLinkInfo->bA2dpOnly) || (pBtLinkInfo->bPanOnly) )
\r
2267 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2268 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
2270 //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10);
\r
2271 //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10);
\r
2275 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2276 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2282 halbtc8723b1ant_ActionWifiConnectedScan(
\r
2283 IN PBTC_COEXIST pBtCoexist
\r
2286 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2288 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2290 // tdma and coex table
\r
2291 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2293 if(pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)
\r
2295 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
2296 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2298 else if(pBtLinkInfo->bPanOnly)
\r
2300 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2301 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2305 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2306 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2309 else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2310 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2312 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2313 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
2317 //halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2318 //halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2321 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2322 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2327 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(
\r
2328 IN PBTC_COEXIST pBtCoexist
\r
2331 BOOLEAN bHsConnecting=FALSE;
\r
2332 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2334 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_CONNECTING, &bHsConnecting);
\r
2337 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2339 // tdma and coex table
\r
2340 if( (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ||(pBtLinkInfo->bScoExist)
\r
2341 || (pBtLinkInfo->bHidOnly) || (pBtLinkInfo->bA2dpOnly) || (pBtLinkInfo->bPanOnly) )
\r
2343 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2344 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
2346 //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10);
\r
2347 //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10);
\r
2351 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2352 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2357 halbtc8723b1ant_ActionWifiConnected(
\r
2358 IN PBTC_COEXIST pBtCoexist
\r
2361 BOOLEAN bWifiBusy=FALSE;
\r
2362 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2363 BOOLEAN bUnder4way=FALSE, bApEnable=FALSE;
\r
2366 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect()===>\n"));
\r
2368 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
2371 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
2372 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));
\r
2376 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2377 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2378 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2379 if(bScan || bLink || bRoam)
\r
2382 halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist);
\r
2384 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
2385 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));
\r
2389 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
2390 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
2391 // power save state
\r
2392 if(!bApEnable && BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
\r
2394 if(!bWifiBusy && pBtCoexist->btLinkInfo.bA2dpOnly) //A2DP
\r
2395 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2397 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
2400 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2402 // tdma and coex table
\r
2405 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2407 halbtc8723b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2408 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
2410 else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2411 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2413 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2414 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
2418 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2419 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2424 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2426 halbtc8723b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2427 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
2429 else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2430 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2432 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2433 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
2437 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2438 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2444 halbtc8723b1ant_RunSwCoexistMechanism(
\r
2445 IN PBTC_COEXIST pBtCoexist
\r
2448 u1Byte algorithm=0;
\r
2450 algorithm = halbtc8723b1ant_ActionAlgorithm(pBtCoexist);
\r
2451 pCoexDm->curAlgorithm = algorithm;
\r
2453 if(halbtc8723b1ant_IsCommonAction(pBtCoexist))
\r
2459 switch(pCoexDm->curAlgorithm)
\r
2461 case BT_8723B_1ANT_COEX_ALGO_SCO:
\r
2462 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n"));
\r
2463 halbtc8723b1ant_ActionSco(pBtCoexist);
\r
2465 case BT_8723B_1ANT_COEX_ALGO_HID:
\r
2466 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n"));
\r
2467 halbtc8723b1ant_ActionHid(pBtCoexist);
\r
2469 case BT_8723B_1ANT_COEX_ALGO_A2DP:
\r
2470 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n"));
\r
2471 halbtc8723b1ant_ActionA2dp(pBtCoexist);
\r
2473 case BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS:
\r
2474 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
\r
2475 halbtc8723b1ant_ActionA2dpPanHs(pBtCoexist);
\r
2477 case BT_8723B_1ANT_COEX_ALGO_PANEDR:
\r
2478 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
\r
2479 halbtc8723b1ant_ActionPanEdr(pBtCoexist);
\r
2481 case BT_8723B_1ANT_COEX_ALGO_PANHS:
\r
2482 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n"));
\r
2483 halbtc8723b1ant_ActionPanHs(pBtCoexist);
\r
2485 case BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP:
\r
2486 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
\r
2487 halbtc8723b1ant_ActionPanEdrA2dp(pBtCoexist);
\r
2489 case BT_8723B_1ANT_COEX_ALGO_PANEDR_HID:
\r
2490 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
\r
2491 halbtc8723b1ant_ActionPanEdrHid(pBtCoexist);
\r
2493 case BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
\r
2494 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
\r
2495 halbtc8723b1ant_ActionHidA2dpPanEdr(pBtCoexist);
\r
2497 case BT_8723B_1ANT_COEX_ALGO_HID_A2DP:
\r
2498 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
\r
2499 halbtc8723b1ant_ActionHidA2dp(pBtCoexist);
\r
2502 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
\r
2503 //halbtc8723b1ant_CoexAllOff(pBtCoexist);
\r
2506 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
\r
2511 halbtc8723b1ant_RunCoexistMechanism(
\r
2512 IN PBTC_COEXIST pBtCoexist
\r
2515 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2516 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2517 BOOLEAN bIncreaseScanDevNum=FALSE;
\r
2518 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
2519 u1Byte aggBufSize=5;
\r
2520 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
\r
2521 u4Byte wifiLinkStatus=0;
\r
2522 u4Byte numOfWifiLink=0;
\r
2524 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n"));
\r
2526 if(pBtCoexist->bManualControl)
\r
2528 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
\r
2532 if(pBtCoexist->bStopCoexDm)
\r
2534 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
\r
2538 if(pCoexSta->bUnderIps)
\r
2540 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
\r
2544 if( (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
2545 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2546 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2548 bIncreaseScanDevNum = TRUE;
\r
2551 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum);
\r
2552 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2554 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
2555 numOfWifiLink = wifiLinkStatus>>16;
\r
2556 if(numOfWifiLink >= 2)
\r
2558 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2559 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
2560 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
\r
2564 if(!pBtLinkInfo->bScoExist && !pBtLinkInfo->bHidExist)
\r
2566 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2570 if(bWifiConnected)
\r
2572 wifiRssiState = halbtc8723b1ant_WifiRssiState(pBtCoexist, 1, 2, 30, 0);
\r
2573 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
2574 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
2576 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 1, 1);
\r
2580 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 1, 1);
\r
2585 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2590 if(pBtLinkInfo->bScoExist)
\r
2592 bBtCtrlAggBufSize = TRUE;
\r
2595 else if(pBtLinkInfo->bHidExist)
\r
2597 bBtCtrlAggBufSize = TRUE;
\r
2600 else if(pBtLinkInfo->bA2dpExist || pBtLinkInfo->bPanExist)
\r
2602 bBtCtrlAggBufSize = TRUE;
\r
2605 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
2607 halbtc8723b1ant_RunSwCoexistMechanism(pBtCoexist);
\r
2609 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2610 if(pCoexSta->bC2hBtInquiryPage)
\r
2612 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
\r
2617 halbtc8723b1ant_ActionHs(pBtCoexist);
\r
2622 if(!bWifiConnected)
\r
2624 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2626 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n"));
\r
2628 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2629 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2630 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2632 if(bScan || bLink || bRoam)
\r
2635 halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist);
\r
2637 halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
\r
2640 halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist);
\r
2642 else // wifi LPS/Busy
\r
2644 halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
\r
2649 halbtc8723b1ant_InitCoexDm(
\r
2650 IN PBTC_COEXIST pBtCoexist
\r
2653 // force to reset coex mechanism
\r
2656 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
2658 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
2659 halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
2663 halbtc8723b1ant_InitHwConfig(
\r
2664 IN PBTC_COEXIST pBtCoexist,
\r
2665 IN BOOLEAN bBackUp
\r
2668 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
2669 u4Byte u4Tmp=0;//, fwVer;
\r
2672 u1Byte H2C_Parameter[2] ={0};
\r
2673 u4Byte cntBtCalChk=0;
\r
2675 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
\r
2679 pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
\r
2680 pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
\r
2681 pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
\r
2682 pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
\r
2685 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); //WiFi goto standby while GNT_BT 0-->1
\r
2686 //pBtCoexist->fBtcSetBtReg(pBtCoexist, 0, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0
\r
2688 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff);
\r
2689 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3);
\r
2690 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77);
\r
2692 //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi
\r
2694 // BT calibration check
\r
2695 while(cntBtCalChk <= 20)
\r
2697 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x49d);
\r
2701 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ########### BT calibration(cnt=%d) ###########\n", cntBtCalChk));
\r
2706 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ********** BT NOT calibration (cnt=%d)**********\n", cntBtCalChk));
\r
2712 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
\r
2715 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
\r
2717 // Enable counter statistics
\r
2718 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); //0x76e[3] =1, WLAN_Act control by PTA
\r
2719 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1);
\r
2720 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
\r
2723 //halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, TRUE, FALSE);
\r
2724 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, TRUE, FALSE);
\r
2727 halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
2731 halbtc8723b1ant_WifiOffHwCfg(
\r
2732 IN PBTC_COEXIST pBtCoexist
\r
2735 // set wlan_act to low
\r
2736 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
2739 //============================================================
\r
2740 // work around function start with wa_halbtc8723b1ant_
\r
2741 //============================================================
\r
2742 //============================================================
\r
2743 // extern function start with EXhalbtc8723b1ant_
\r
2744 //============================================================
\r
2746 EXhalbtc8723b1ant_InitHwConfig(
\r
2747 IN PBTC_COEXIST pBtCoexist
\r
2750 halbtc8723b1ant_InitHwConfig(pBtCoexist, TRUE);
\r
2754 EXhalbtc8723b1ant_InitCoexDm(
\r
2755 IN PBTC_COEXIST pBtCoexist
\r
2758 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
2760 pBtCoexist->bStopCoexDm = FALSE;
\r
2762 halbtc8723b1ant_InitCoexDm(pBtCoexist);
\r
2764 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
2768 EXhalbtc8723b1ant_DisplayCoexInfo(
\r
2769 IN PBTC_COEXIST pBtCoexist
\r
2772 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
2773 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
2774 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2775 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
2776 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
2779 BOOLEAN bRoam=FALSE, bScan=FALSE, bLink=FALSE, bWifiUnder5G=FALSE;
\r
2780 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
2781 s4Byte wifiRssi=0, btHsRssi=0;
\r
2782 u4Byte wifiBw, wifiTrafficDir, faOfdm, faCck, wifiLinkStatus;
\r
2783 u1Byte wifiDot11Chnl, wifiHsChnl;
\r
2784 u4Byte fwVer=0, btPatchVer=0;
\r
2786 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
2787 CL_PRINTF(cliBuf);
\r
2789 if(pBtCoexist->bManualControl)
\r
2791 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
\r
2792 CL_PRINTF(cliBuf);
\r
2793 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
2794 CL_PRINTF(cliBuf);
\r
2796 if(pBtCoexist->bStopCoexDm)
\r
2798 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");
\r
2799 CL_PRINTF(cliBuf);
\r
2800 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
2801 CL_PRINTF(cliBuf);
\r
2804 if(!pBoardInfo->bBtExist)
\r
2806 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
\r
2807 CL_PRINTF(cliBuf);
\r
2811 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Ant Mech/ Ant Pos:", \
\r
2812 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos);
\r
2813 CL_PRINTF(cliBuf);
\r
2815 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
2816 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
2817 CL_PRINTF(cliBuf);
\r
2819 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
2820 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
2821 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
\r
2822 GLCoexVerDate8723b1Ant, GLCoexVer8723b1Ant, fwVer, btPatchVer, btPatchVer);
\r
2823 CL_PRINTF(cliBuf);
\r
2825 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2826 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
\r
2827 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
\r
2828 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
\r
2829 wifiDot11Chnl, wifiHsChnl, bBtHsOn);
\r
2830 CL_PRINTF(cliBuf);
\r
2832 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
\r
2833 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
\r
2834 pCoexDm->wifiChnlInfo[2]);
\r
2835 CL_PRINTF(cliBuf);
\r
2837 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
2838 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
\r
2839 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
\r
2840 wifiRssi, btHsRssi);
\r
2841 CL_PRINTF(cliBuf);
\r
2843 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2844 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2845 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2846 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
\r
2847 bLink, bRoam, bScan);
\r
2848 CL_PRINTF(cliBuf);
\r
2850 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
2851 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
2852 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
2853 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
2854 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
\r
2855 (bWifiUnder5G? "5G":"2.4G"),
\r
2856 ((BTC_WIFI_BW_LEGACY==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40==wifiBw)? "HT40":"HT20"))),
\r
2857 ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
\r
2858 CL_PRINTF(cliBuf);
\r
2860 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
2861 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "sta/vwifi/hs/p2pGo/p2pGc", \
\r
2862 ((wifiLinkStatus&WIFI_STA_CONNECTED)? 1:0), ((wifiLinkStatus&WIFI_AP_CONNECTED)? 1:0),
\r
2863 ((wifiLinkStatus&WIFI_HS_CONNECTED)? 1:0), ((wifiLinkStatus&WIFI_P2P_GO_CONNECTED)? 1:0),
\r
2864 ((wifiLinkStatus&WIFI_P2P_GC_CONNECTED)? 1:0) );
\r
2865 CL_PRINTF(cliBuf);
\r
2867 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
\r
2868 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
\r
2869 ( (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
\r
2870 pCoexSta->btRssi, pCoexSta->btRetryCnt);
\r
2871 CL_PRINTF(cliBuf);
\r
2874 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
2875 pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);
\r
2876 CL_PRINTF(cliBuf);
\r
2877 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
2879 btInfoExt = pCoexSta->btInfoExt;
\r
2880 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
\r
2881 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
\r
2882 CL_PRINTF(cliBuf);
\r
2884 for(i=0; i<BT_INFO_SRC_8723B_1ANT_MAX; i++)
\r
2886 if(pCoexSta->btInfoC2hCnt[i])
\r
2888 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b1Ant[i], \
\r
2889 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
\r
2890 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
\r
2891 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
\r
2892 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
\r
2893 CL_PRINTF(cliBuf);
\r
2896 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", \
\r
2897 ((pCoexSta->bUnderIps? "IPS ON":"IPS OFF")),
\r
2898 ((pCoexSta->bUnderLps? "LPS ON":"LPS OFF")),
\r
2899 pBtCoexist->btInfo.lpsVal,
\r
2900 pBtCoexist->btInfo.rpwmVal);
\r
2901 CL_PRINTF(cliBuf);
\r
2902 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
\r
2904 if(!pBtCoexist->bManualControl)
\r
2907 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
2908 CL_PRINTF(cliBuf);
\r
2910 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "SM[LowPenaltyRA]", \
\r
2911 pCoexDm->bCurLowPenaltyRa);
\r
2912 CL_PRINTF(cliBuf);
\r
2914 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \
\r
2915 (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"),
\r
2916 pBtCoexist->btInfo.aggBufSize);
\r
2917 CL_PRINTF(cliBuf);
\r
2918 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \
\r
2919 pBtCoexist->btInfo.raMask);
\r
2920 CL_PRINTF(cliBuf);
\r
2923 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
2924 CL_PRINTF(cliBuf);
\r
2926 psTdmaCase = pCoexDm->curPsTdma;
\r
2927 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
\r
2928 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
\r
2929 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
\r
2930 pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
\r
2931 CL_PRINTF(cliBuf);
\r
2933 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "IgnWlanAct", \
\r
2934 pCoexDm->bCurIgnoreWlanAct);
\r
2935 CL_PRINTF(cliBuf);
\r
2937 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
\r
2938 pCoexDm->errorCondition);
\r
2939 CL_PRINTF(cliBuf);
\r
2943 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
2944 CL_PRINTF(cliBuf);
\r
2946 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", \
\r
2947 pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime);
\r
2948 CL_PRINTF(cliBuf);
\r
2950 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
\r
2951 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
\r
2952 u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
\r
2953 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
\r
2954 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \
\r
2955 u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]);
\r
2956 CL_PRINTF(cliBuf);
\r
2958 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
\r
2959 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc);
\r
2960 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
\r
2961 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x6cc/0x880[29:25]", \
\r
2962 u1Tmp[0], u4Tmp[0], (u4Tmp[1]&0x3e000000) >> 25);
\r
2963 CL_PRINTF(cliBuf);
\r
2965 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
\r
2966 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
\r
2967 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
\r
2968 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \
\r
2969 u4Tmp[0], ((u1Tmp[0]&0x20)>> 5), u1Tmp[1]);
\r
2970 CL_PRINTF(cliBuf);
\r
2972 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c);
\r
2973 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
\r
2974 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944);
\r
2975 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \
\r
2976 u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3);
\r
2977 CL_PRINTF(cliBuf);
\r
2979 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39);
\r
2980 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
2981 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
2982 u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64);
\r
2983 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \
\r
2984 ((u1Tmp[0] & 0x8)>>3), u1Tmp[1], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[2]&0x1);
\r
2985 CL_PRINTF(cliBuf);
\r
2987 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
\r
2988 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
\r
2989 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
\r
2990 u4Tmp[0], u1Tmp[0]);
\r
2991 CL_PRINTF(cliBuf);
\r
2993 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
2994 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c);
\r
2995 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
\r
2996 u4Tmp[0]&0xff, u1Tmp[0]);
\r
2997 CL_PRINTF(cliBuf);
\r
2999 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
\r
3000 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
\r
3001 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
\r
3002 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0);
\r
3004 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b);
\r
3005 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
\r
3007 faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \
\r
3008 ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ;
\r
3009 faCck = (u1Tmp[0] << 8) + u1Tmp[1];
\r
3011 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
\r
3012 u4Tmp[0]&0xffff, faOfdm, faCck);
\r
3013 CL_PRINTF(cliBuf);
\r
3015 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
\r
3016 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
3017 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
3018 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", \
\r
3019 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
\r
3020 CL_PRINTF(cliBuf);
\r
3022 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \
\r
3023 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
\r
3024 CL_PRINTF(cliBuf);
\r
3025 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \
\r
3026 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
\r
3027 CL_PRINTF(cliBuf);
\r
3028 #if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 1)
\r
3029 halbtc8723b1ant_MonitorBtCtr(pBtCoexist);
\r
3031 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
3036 EXhalbtc8723b1ant_IpsNotify(
\r
3037 IN PBTC_COEXIST pBtCoexist,
\r
3043 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
3046 if(BTC_IPS_ENTER == type)
\r
3048 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
\r
3049 pCoexSta->bUnderIps = TRUE;
\r
3050 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
3051 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
3052 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
3053 halbtc8723b1ant_WifiOffHwCfg(pBtCoexist);
\r
3055 else if(BTC_IPS_LEAVE == type)
\r
3057 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
\r
3058 pCoexSta->bUnderIps = FALSE;
\r
3059 //halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, TRUE, FALSE);
\r
3060 //halbtc8723b1ant_RunCoexistMechanism(pBtCoexist);
\r
3062 halbtc8723b1ant_InitHwConfig(pBtCoexist, FALSE);
\r
3063 halbtc8723b1ant_InitCoexDm(pBtCoexist);
\r
3064 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
3069 EXhalbtc8723b1ant_LpsNotify(
\r
3070 IN PBTC_COEXIST pBtCoexist,
\r
3074 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
3077 if(BTC_LPS_ENABLE == type)
\r
3079 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
\r
3080 pCoexSta->bUnderLps = TRUE;
\r
3082 else if(BTC_LPS_DISABLE == type)
\r
3084 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
\r
3085 pCoexSta->bUnderLps = FALSE;
\r
3090 EXhalbtc8723b1ant_ScanNotify(
\r
3091 IN PBTC_COEXIST pBtCoexist,
\r
3095 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
3096 u4Byte wifiLinkStatus=0;
\r
3097 u4Byte numOfWifiLink=0;
\r
3098 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
3099 u1Byte aggBufSize=5;
\r
3101 if(pBtCoexist->bManualControl ||
\r
3102 pBtCoexist->bStopCoexDm ||
\r
3103 pBtCoexist->btInfo.bBtDisabled )
\r
3106 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
3107 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
3109 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
3111 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
3112 numOfWifiLink = wifiLinkStatus>>16;
\r
3113 if(numOfWifiLink >= 2)
\r
3115 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
3116 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
3117 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
\r
3121 if(pCoexSta->bC2hBtInquiryPage)
\r
3123 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
\r
3128 halbtc8723b1ant_ActionHs(pBtCoexist);
\r
3132 if(BTC_SCAN_START == type)
\r
3134 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
\r
3135 if(!bWifiConnected) // non-connected scan
\r
3137 halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist);
\r
3139 else // wifi is connected
\r
3141 halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist);
\r
3144 else if(BTC_SCAN_FINISH == type)
\r
3146 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
\r
3147 if(!bWifiConnected) // non-connected scan
\r
3149 halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist);
\r
3153 halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
\r
3159 EXhalbtc8723b1ant_ConnectNotify(
\r
3160 IN PBTC_COEXIST pBtCoexist,
\r
3164 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
3165 u4Byte wifiLinkStatus=0;
\r
3166 u4Byte numOfWifiLink=0;
\r
3167 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
3168 u1Byte aggBufSize=5;
\r
3170 if(pBtCoexist->bManualControl ||
\r
3171 pBtCoexist->bStopCoexDm ||
\r
3172 pBtCoexist->btInfo.bBtDisabled )
\r
3175 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
3176 numOfWifiLink = wifiLinkStatus>>16;
\r
3177 if(numOfWifiLink >= 2)
\r
3179 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
3180 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
3181 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
\r
3185 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
3186 if(pCoexSta->bC2hBtInquiryPage)
\r
3188 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
\r
3193 halbtc8723b1ant_ActionHs(pBtCoexist);
\r
3197 if(BTC_ASSOCIATE_START == type)
\r
3199 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
\r
3200 halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
\r
3202 else if(BTC_ASSOCIATE_FINISH == type)
\r
3204 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
\r
3206 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
3207 if(!bWifiConnected) // non-connected scan
\r
3209 halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist);
\r
3213 halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
\r
3219 EXhalbtc8723b1ant_MediaStatusNotify(
\r
3220 IN PBTC_COEXIST pBtCoexist,
\r
3224 u1Byte H2C_Parameter[3] ={0};
\r
3226 u1Byte wifiCentralChnl;
\r
3228 if(pBtCoexist->bManualControl ||
\r
3229 pBtCoexist->bStopCoexDm ||
\r
3230 pBtCoexist->btInfo.bBtDisabled )
\r
3233 if(BTC_MEDIA_CONNECT == type)
\r
3235 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
\r
3239 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
\r
3242 // only 2.4G we need to inform bt the chnl mask
\r
3243 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
\r
3244 if( (BTC_MEDIA_CONNECT == type) &&
\r
3245 (wifiCentralChnl <= 14) )
\r
3247 //H2C_Parameter[0] = 0x1;
\r
3248 H2C_Parameter[0] = 0x0;
\r
3249 H2C_Parameter[1] = wifiCentralChnl;
\r
3250 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3251 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3252 H2C_Parameter[2] = 0x30;
\r
3254 H2C_Parameter[2] = 0x20;
\r
3257 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
\r
3258 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
\r
3259 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
\r
3261 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x66=0x%x\n",
\r
3262 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
\r
3264 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
\r
3268 EXhalbtc8723b1ant_SpecialPacketNotify(
\r
3269 IN PBTC_COEXIST pBtCoexist,
\r
3273 BOOLEAN bBtHsOn=FALSE;
\r
3274 u4Byte wifiLinkStatus=0;
\r
3275 u4Byte numOfWifiLink=0;
\r
3276 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
3277 u1Byte aggBufSize=5;
\r
3279 if(pBtCoexist->bManualControl ||
\r
3280 pBtCoexist->bStopCoexDm ||
\r
3281 pBtCoexist->btInfo.bBtDisabled )
\r
3284 pCoexSta->specialPktPeriodCnt = 0;
\r
3286 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
3287 numOfWifiLink = wifiLinkStatus>>16;
\r
3288 if(numOfWifiLink >= 2)
\r
3290 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
3291 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
3292 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
\r
3296 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
3297 if(pCoexSta->bC2hBtInquiryPage)
\r
3299 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
\r
3304 halbtc8723b1ant_ActionHs(pBtCoexist);
\r
3308 if( BTC_PACKET_DHCP == type ||
\r
3309 BTC_PACKET_EAPOL == type )
\r
3311 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet(%d) notify\n", type));
\r
3312 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
3317 EXhalbtc8723b1ant_BtInfoNotify(
\r
3318 IN PBTC_COEXIST pBtCoexist,
\r
3319 IN pu1Byte tmpBuf,
\r
3323 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
3325 u1Byte i, rspSource=0;
\r
3326 BOOLEAN bWifiConnected=FALSE;
\r
3327 BOOLEAN bBtBusy=FALSE;
\r
3329 pCoexSta->bC2hBtInfoReqSent = FALSE;
\r
3331 rspSource = tmpBuf[0]&0xf;
\r
3332 if(rspSource >= BT_INFO_SRC_8723B_1ANT_MAX)
\r
3333 rspSource = BT_INFO_SRC_8723B_1ANT_WIFI_FW;
\r
3334 pCoexSta->btInfoC2hCnt[rspSource]++;
\r
3336 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
\r
3337 for(i=0; i<length; i++)
\r
3339 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
\r
3341 btInfo = tmpBuf[i];
\r
3344 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
\r
3348 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
\r
3352 if(BT_INFO_SRC_8723B_1ANT_WIFI_FW != rspSource)
\r
3354 pCoexSta->btRetryCnt = // [3:0]
\r
3355 pCoexSta->btInfoC2h[rspSource][2]&0xf;
\r
3357 pCoexSta->btRssi =
\r
3358 pCoexSta->btInfoC2h[rspSource][3]*2+10;
\r
3360 pCoexSta->btInfoExt =
\r
3361 pCoexSta->btInfoC2h[rspSource][4];
\r
3363 if (!(pCoexSta->btInfoC2h[rspSource][2] & 0x40))
\r
3365 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch GNT_BT */
\r
3366 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Switch GNT_BT since BT RF REG 0x3C != 0x15\n"));
\r
3367 pBtCoexist->fBtcSetBtReg(pBtCoexist, 0, 0x3c, 0x15);
\r
3370 // Here we need to resend some wifi info to BT
\r
3371 // because bt is reset and loss of the info.
\r
3372 if(pCoexSta->btInfoExt & BIT1)
\r
3374 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
\r
3375 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
3376 if(bWifiConnected)
\r
3378 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
\r
3382 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
3386 if(pCoexSta->btInfoExt & BIT3)
\r
3388 if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm)
\r
3390 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
\r
3391 halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
3396 // BT already NOT ignore Wlan active, do nothing here.
\r
3398 #if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0)
\r
3399 if( (pCoexSta->btInfoExt & BIT4) )
\r
3401 // BT auto report already enabled, do nothing
\r
3405 halbtc8723b1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);
\r
3410 // check BIT2 first ==> check if bt is under inquiry or page scan
\r
3411 if(btInfo & BT_INFO_8723B_1ANT_B_INQ_PAGE)
\r
3412 pCoexSta->bC2hBtInquiryPage = TRUE;
\r
3414 pCoexSta->bC2hBtInquiryPage = FALSE;
\r
3416 // set link exist status
\r
3417 if(!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION))
\r
3419 pCoexSta->bBtLinkExist = FALSE;
\r
3420 pCoexSta->bPanExist = FALSE;
\r
3421 pCoexSta->bA2dpExist = FALSE;
\r
3422 pCoexSta->bHidExist = FALSE;
\r
3423 pCoexSta->bScoExist = FALSE;
\r
3425 else // connection exists
\r
3427 pCoexSta->bBtLinkExist = TRUE;
\r
3428 if(btInfo & BT_INFO_8723B_1ANT_B_FTP)
\r
3429 pCoexSta->bPanExist = TRUE;
\r
3431 pCoexSta->bPanExist = FALSE;
\r
3432 if(btInfo & BT_INFO_8723B_1ANT_B_A2DP)
\r
3433 pCoexSta->bA2dpExist = TRUE;
\r
3435 pCoexSta->bA2dpExist = FALSE;
\r
3436 if(btInfo & BT_INFO_8723B_1ANT_B_HID)
\r
3437 pCoexSta->bHidExist = TRUE;
\r
3439 pCoexSta->bHidExist = FALSE;
\r
3440 if(btInfo & BT_INFO_8723B_1ANT_B_SCO_ESCO)
\r
3441 pCoexSta->bScoExist = TRUE;
\r
3443 pCoexSta->bScoExist = FALSE;
\r
3446 halbtc8723b1ant_UpdateBtLinkInfo(pBtCoexist);
\r
3448 if(!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION))
\r
3450 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
\r
3451 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
\r
3453 else if(btInfo == BT_INFO_8723B_1ANT_B_CONNECTION) // connection exists but no busy
\r
3455 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE;
\r
3456 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
\r
3458 else if((btInfo&BT_INFO_8723B_1ANT_B_SCO_ESCO) ||
\r
3459 (btInfo&BT_INFO_8723B_1ANT_B_SCO_BUSY))
\r
3461 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_SCO_BUSY;
\r
3462 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
\r
3464 else if(btInfo&BT_INFO_8723B_1ANT_B_ACL_BUSY)
\r
3466 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
\r
3467 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
3468 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_ACL_BUSY;
\r
3469 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
\r
3473 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_MAX;
\r
3474 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
\r
3477 if( (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
3478 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
3479 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
3483 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
3485 halbtc8723b1ant_RunCoexistMechanism(pBtCoexist);
\r
3489 EXhalbtc8723b1ant_HaltNotify(
\r
3490 IN PBTC_COEXIST pBtCoexist
\r
3495 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
\r
3497 pBtCoexist->bStopCoexDm = TRUE;
\r
3499 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
3500 halbtc8723b1ant_WifiOffHwCfg(pBtCoexist);
\r
3501 halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
3503 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3504 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
\r
3506 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
3510 EXhalbtc8723b1ant_PnpNotify(
\r
3511 IN PBTC_COEXIST pBtCoexist,
\r
3512 IN u1Byte pnpState
\r
3515 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
\r
3517 if(BTC_WIFI_PNP_SLEEP == pnpState)
\r
3519 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to SLEEP\n"));
\r
3520 pBtCoexist->bStopCoexDm = TRUE;
\r
3522 halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
3523 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3524 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
3527 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
3528 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3529 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
3530 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
3531 halbtc8723b1ant_WifiOffHwCfg(pBtCoexist);
\r
3533 else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
\r
3535 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to WAKE UP\n"));
\r
3536 pBtCoexist->bStopCoexDm = FALSE;
\r
3537 halbtc8723b1ant_InitHwConfig(pBtCoexist, FALSE);
\r
3538 halbtc8723b1ant_InitCoexDm(pBtCoexist);
\r
3539 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
3544 EXhalbtc8723b1ant_CoexDmReset(
\r
3545 IN PBTC_COEXIST pBtCoexist
\r
3548 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], *****************Coex DM Reset*****************\n"));
\r
3550 halbtc8723b1ant_InitHwConfig(pBtCoexist, FALSE);
\r
3551 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3552 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x2, 0xfffff, 0x0);
\r
3553 halbtc8723b1ant_InitCoexDm(pBtCoexist);
\r
3557 EXhalbtc8723b1ant_Periodical(
\r
3558 IN PBTC_COEXIST pBtCoexist
\r
3561 static u1Byte disVerInfoCnt=0;
\r
3562 u4Byte fwVer=0, btPatchVer=0;
\r
3563 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
3564 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
3566 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical===========================\n"));
\r
3568 if(disVerInfoCnt <= 5)
\r
3570 disVerInfoCnt += 1;
\r
3571 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
3572 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", \
\r
3573 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));
\r
3574 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", \
\r
3575 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
\r
3576 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
3577 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
3578 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
\r
3579 GLCoexVerDate8723b1Ant, GLCoexVer8723b1Ant, fwVer, btPatchVer, btPatchVer));
\r
3580 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
3583 #if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0)
\r
3584 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
3585 halbtc8723b1ant_MonitorBtCtr(pBtCoexist);
\r
3586 halbtc8723b1ant_MonitorBtEnableDisable(pBtCoexist);
\r
3588 if( halbtc8723b1ant_IsWifiStatusChanged(pBtCoexist) ||
\r
3589 pCoexDm->bAutoTdmaAdjust )
\r
3591 //if(pCoexSta->specialPktPeriodCnt > 2)
\r
3593 halbtc8723b1ant_RunCoexistMechanism(pBtCoexist);
\r
3597 pCoexSta->specialPktPeriodCnt++;
\r