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
23 static PSDSCAN_STA_8723B_1ANT GLPsdScan8723b1Ant;
\r
24 static PPSDSCAN_STA_8723B_1ANT pPsdScan = &GLPsdScan8723b1Ant;
\r
27 const char *const GLBtInfoSrc8723b1Ant[]={
\r
30 "BT Info[bt auto report]",
\r
33 u4Byte GLCoexVerDate8723b1Ant=20140929;
\r
34 u4Byte GLCoexVer8723b1Ant=0x54;
\r
36 //============================================================
\r
37 // local function proto type if needed
\r
38 //============================================================
\r
39 //============================================================
\r
40 // local function start with halbtc8723b1ant_
\r
41 //============================================================
\r
43 halbtc8723b1ant_BtRssiState(
\r
50 u1Byte btRssiState=pCoexSta->preBtRssiState;
\r
52 btRssi = pCoexSta->btRssi;
\r
56 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
57 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
59 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT))
\r
61 btRssiState = BTC_RSSI_STATE_HIGH;
\r
62 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
\r
66 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
67 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
\r
72 if(btRssi < rssiThresh)
\r
74 btRssiState = BTC_RSSI_STATE_LOW;
\r
75 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
\r
79 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
80 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
\r
84 else if(levelNum == 3)
\r
86 if(rssiThresh > rssiThresh1)
\r
88 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
\r
89 return pCoexSta->preBtRssiState;
\r
92 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
93 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
95 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT))
\r
97 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
98 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
\r
102 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
103 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
\r
106 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
\r
107 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
\r
109 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT))
\r
111 btRssiState = BTC_RSSI_STATE_HIGH;
\r
112 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
\r
114 else if(btRssi < rssiThresh)
\r
116 btRssiState = BTC_RSSI_STATE_LOW;
\r
117 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
\r
121 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
122 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
\r
127 if(btRssi < rssiThresh1)
\r
129 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
130 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
\r
134 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
135 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
\r
140 pCoexSta->preBtRssiState = btRssiState;
\r
142 return btRssiState;
\r
146 halbtc8723b1ant_WifiRssiState(
\r
147 IN PBTC_COEXIST pBtCoexist,
\r
149 IN u1Byte levelNum,
\r
150 IN u1Byte rssiThresh,
\r
151 IN u1Byte rssiThresh1
\r
155 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
\r
157 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
161 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
162 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
164 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT))
\r
166 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
167 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
171 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
172 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
177 if(wifiRssi < rssiThresh)
\r
179 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
180 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
184 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
185 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
189 else if(levelNum == 3)
\r
191 if(rssiThresh > rssiThresh1)
\r
193 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
\r
194 return pCoexSta->preWifiRssiState[index];
\r
197 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
198 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
200 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT))
\r
202 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
203 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
207 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
208 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
211 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
\r
212 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
\r
214 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT))
\r
216 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
217 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
219 else if(wifiRssi < rssiThresh)
\r
221 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
222 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
226 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
227 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
\r
232 if(wifiRssi < rssiThresh1)
\r
234 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
235 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
239 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
240 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
245 pCoexSta->preWifiRssiState[index] = wifiRssiState;
\r
247 return wifiRssiState;
\r
251 halbtc8723b1ant_UpdateRaMask(
\r
252 IN PBTC_COEXIST pBtCoexist,
\r
253 IN BOOLEAN bForceExec,
\r
254 IN u4Byte disRateMask
\r
257 pCoexDm->curRaMask = disRateMask;
\r
259 if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask))
\r
261 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask);
\r
263 pCoexDm->preRaMask = pCoexDm->curRaMask;
\r
267 halbtc8723b1ant_AutoRateFallbackRetry(
\r
268 IN PBTC_COEXIST pBtCoexist,
\r
269 IN BOOLEAN bForceExec,
\r
273 BOOLEAN bWifiUnderBMode=FALSE;
\r
275 pCoexDm->curArfrType = type;
\r
277 if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType))
\r
279 switch(pCoexDm->curArfrType)
\r
281 case 0: // normal mode
\r
282 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1);
\r
283 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2);
\r
286 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
\r
287 if(bWifiUnderBMode)
\r
289 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
\r
290 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101);
\r
294 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
\r
295 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201);
\r
303 pCoexDm->preArfrType = pCoexDm->curArfrType;
\r
307 halbtc8723b1ant_RetryLimit(
\r
308 IN PBTC_COEXIST pBtCoexist,
\r
309 IN BOOLEAN bForceExec,
\r
313 pCoexDm->curRetryLimitType = type;
\r
315 if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType))
\r
317 switch(pCoexDm->curRetryLimitType)
\r
319 case 0: // normal mode
\r
320 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit);
\r
322 case 1: // retry limit=8
\r
323 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808);
\r
330 pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType;
\r
334 halbtc8723b1ant_AmpduMaxTime(
\r
335 IN PBTC_COEXIST pBtCoexist,
\r
336 IN BOOLEAN bForceExec,
\r
340 pCoexDm->curAmpduTimeType = type;
\r
342 if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType))
\r
344 switch(pCoexDm->curAmpduTimeType)
\r
346 case 0: // normal mode
\r
347 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime);
\r
349 case 1: // AMPDU timw = 0x38 * 32us
\r
350 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38);
\r
357 pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType;
\r
361 halbtc8723b1ant_LimitedTx(
\r
362 IN PBTC_COEXIST pBtCoexist,
\r
363 IN BOOLEAN bForceExec,
\r
364 IN u1Byte raMaskType,
\r
365 IN u1Byte arfrType,
\r
366 IN u1Byte retryLimitType,
\r
367 IN u1Byte ampduTimeType
\r
372 case 0: // normal mode
\r
373 halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0);
\r
375 case 1: // disable cck 1/2
\r
376 halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003);
\r
378 case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4
\r
379 halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7);
\r
385 halbtc8723b1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType);
\r
386 halbtc8723b1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType);
\r
387 halbtc8723b1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType);
\r
391 halbtc8723b1ant_LimitedRx(
\r
392 IN PBTC_COEXIST pBtCoexist,
\r
393 IN BOOLEAN bForceExec,
\r
394 IN BOOLEAN bRejApAggPkt,
\r
395 IN BOOLEAN bBtCtrlAggBufSize,
\r
396 IN u1Byte aggBufSize
\r
399 BOOLEAN bRejectRxAgg=bRejApAggPkt;
\r
400 BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize;
\r
401 u1Byte rxAggSize=aggBufSize;
\r
403 //============================================
\r
404 // Rx Aggregation related setting
\r
405 //============================================
\r
406 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);
\r
407 // decide BT control aggregation buf size or not
\r
408 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);
\r
409 // aggregation buf size, only work when BT control Rx aggregation size.
\r
410 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
\r
411 // real update aggregation setting
\r
412 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
\r
418 halbtc8723b1ant_QueryBtInfo(
\r
419 IN PBTC_COEXIST pBtCoexist
\r
422 u1Byte H2C_Parameter[1] ={0};
\r
424 pCoexSta->bC2hBtInfoReqSent = TRUE;
\r
426 H2C_Parameter[0] |= BIT0; // trigger
\r
428 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
\r
429 H2C_Parameter[0]));
\r
431 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
\r
435 halbtc8723b1ant_MonitorBtCtr(
\r
436 IN PBTC_COEXIST pBtCoexist
\r
439 u4Byte regHPTxRx, regLPTxRx, u4Tmp, u4Tmp1;
\r
440 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
\r
441 u1Byte u1Tmp, u1Tmp1;
\r
443 static u1Byte NumOfBtCounterChk = 0;
\r
445 //to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS
\r
446 //if (! (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) & 0x8) )
\r
448 if (pCoexSta->bUnderIps)
\r
450 //pCoexSta->highPriorityTx = 65535;
\r
451 //pCoexSta->highPriorityRx = 65535;
\r
452 //pCoexSta->lowPriorityTx = 65535;
\r
453 //pCoexSta->lowPriorityRx = 65535;
\r
460 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
\r
461 regHPTx = u4Tmp & bMaskLWord;
\r
462 regHPRx = (u4Tmp & bMaskHWord)>>16;
\r
464 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
\r
465 regLPTx = u4Tmp & bMaskLWord;
\r
466 regLPRx = (u4Tmp & bMaskHWord)>>16;
\r
468 pCoexSta->highPriorityTx = regHPTx;
\r
469 pCoexSta->highPriorityRx = regHPRx;
\r
470 pCoexSta->lowPriorityTx = regLPTx;
\r
471 pCoexSta->lowPriorityRx = regLPRx;
\r
473 if( (pCoexSta->lowPriorityTx > 1150) && (!pCoexSta->bC2hBtInquiryPage))
\r
474 pCoexSta->popEventCnt++;
\r
476 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n",
\r
477 regHPRx, regHPTx, regLPRx, regLPTx));
\r
480 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
482 if ((regHPTx == 0) && (regHPRx ==0) && (regLPTx == 0) && (regLPRx == 0))
\r
484 NumOfBtCounterChk++;
\r
485 if (NumOfBtCounterChk >= 3)
\r
487 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
488 NumOfBtCounterChk = 0;
\r
495 halbtc8723b1ant_MonitorWiFiCtr(
\r
496 IN PBTC_COEXIST pBtCoexist
\r
502 BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE;
\r
503 static u1Byte nCCKLockCounter = 0;
\r
505 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
506 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
507 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
\r
509 if (pCoexSta->bUnderIps)
\r
511 pCoexSta->nCRCOK_CCK = 0;
\r
512 pCoexSta->nCRCOK_11g = 0;
\r
513 pCoexSta->nCRCOK_11n = 0;
\r
514 pCoexSta->nCRCOK_11nAgg = 0;
\r
516 pCoexSta->nCRCErr_CCK = 0;
\r
517 pCoexSta->nCRCErr_11g = 0;
\r
518 pCoexSta->nCRCErr_11n = 0;
\r
519 pCoexSta->nCRCErr_11nAgg = 0;
\r
523 pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88);
\r
524 pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94);
\r
525 pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90);
\r
526 pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8);
\r
528 pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84);
\r
529 pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96);
\r
530 pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92);
\r
531 pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba);
\r
536 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1);
\r
537 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0);
\r
539 if ( (bWifiBusy) && (wifiRssi >= 30) && (!bWifiUnderBMode))
\r
541 if ( (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) ||
\r
542 (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY) ||
\r
543 (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_SCO_BUSY) )
\r
545 if (pCoexSta->nCRCOK_CCK >(pCoexSta->nCRCOK_11g + pCoexSta->nCRCOK_11n +
\r
546 pCoexSta->nCRCOK_11nAgg) )
\r
548 if (nCCKLockCounter < 5)
\r
553 if (nCCKLockCounter > 0)
\r
560 if (nCCKLockCounter > 0)
\r
566 if (nCCKLockCounter > 0)
\r
570 if (!pCoexSta->bPreCCKLock)
\r
573 if (nCCKLockCounter >= 5)
\r
574 pCoexSta->bCCKLock = TRUE;
\r
576 pCoexSta->bCCKLock = FALSE;
\r
580 if (nCCKLockCounter == 0)
\r
581 pCoexSta->bCCKLock = FALSE;
\r
583 pCoexSta->bCCKLock = TRUE;
\r
586 if (pCoexSta->bCCKLock)
\r
587 pCoexSta->bCCKEverLock = TRUE;
\r
589 pCoexSta->bPreCCKLock = pCoexSta->bCCKLock;
\r
595 halbtc8723b1ant_IsWifiStatusChanged(
\r
596 IN PBTC_COEXIST pBtCoexist
\r
599 static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;
\r
600 BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;
\r
601 BOOLEAN bWifiConnected=FALSE;
\r
603 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
604 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
605 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
606 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
610 if(bWifiBusy != bPreWifiBusy)
\r
612 bPreWifiBusy = bWifiBusy;
\r
615 if(bUnder4way != bPreUnder4way)
\r
617 bPreUnder4way = bUnder4way;
\r
620 if(bBtHsOn != bPreBtHsOn)
\r
622 bPreBtHsOn = bBtHsOn;
\r
631 halbtc8723b1ant_UpdateBtLinkInfo(
\r
632 IN PBTC_COEXIST pBtCoexist
\r
635 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
636 BOOLEAN bBtHsOn=FALSE;
\r
638 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
640 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
\r
641 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
\r
642 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
\r
643 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
\r
644 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
\r
645 pBtLinkInfo->bBtHiPriLinkExist = pCoexSta->bBtHiPriLinkExist;
\r
647 // work around for HS mode.
\r
650 pBtLinkInfo->bPanExist = TRUE;
\r
651 pBtLinkInfo->bBtLinkExist = TRUE;
\r
654 // check if Sco only
\r
655 if( pBtLinkInfo->bScoExist &&
\r
656 !pBtLinkInfo->bA2dpExist &&
\r
657 !pBtLinkInfo->bPanExist &&
\r
658 !pBtLinkInfo->bHidExist )
\r
659 pBtLinkInfo->bScoOnly = TRUE;
\r
661 pBtLinkInfo->bScoOnly = FALSE;
\r
663 // check if A2dp only
\r
664 if( !pBtLinkInfo->bScoExist &&
\r
665 pBtLinkInfo->bA2dpExist &&
\r
666 !pBtLinkInfo->bPanExist &&
\r
667 !pBtLinkInfo->bHidExist )
\r
668 pBtLinkInfo->bA2dpOnly = TRUE;
\r
670 pBtLinkInfo->bA2dpOnly = FALSE;
\r
672 // check if Pan only
\r
673 if( !pBtLinkInfo->bScoExist &&
\r
674 !pBtLinkInfo->bA2dpExist &&
\r
675 pBtLinkInfo->bPanExist &&
\r
676 !pBtLinkInfo->bHidExist )
\r
677 pBtLinkInfo->bPanOnly = TRUE;
\r
679 pBtLinkInfo->bPanOnly = FALSE;
\r
681 // check if Hid only
\r
682 if( !pBtLinkInfo->bScoExist &&
\r
683 !pBtLinkInfo->bA2dpExist &&
\r
684 !pBtLinkInfo->bPanExist &&
\r
685 pBtLinkInfo->bHidExist )
\r
686 pBtLinkInfo->bHidOnly = TRUE;
\r
688 pBtLinkInfo->bHidOnly = FALSE;
\r
692 halbtc8723b1ant_ActionAlgorithm(
\r
693 IN PBTC_COEXIST pBtCoexist
\r
696 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
697 BOOLEAN bBtHsOn=FALSE;
\r
698 u1Byte algorithm=BT_8723B_1ANT_COEX_ALGO_UNDEFINED;
\r
699 u1Byte numOfDiffProfile=0;
\r
701 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
703 if(!pBtLinkInfo->bBtLinkExist)
\r
705 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n"));
\r
709 if(pBtLinkInfo->bScoExist)
\r
710 numOfDiffProfile++;
\r
711 if(pBtLinkInfo->bHidExist)
\r
712 numOfDiffProfile++;
\r
713 if(pBtLinkInfo->bPanExist)
\r
714 numOfDiffProfile++;
\r
715 if(pBtLinkInfo->bA2dpExist)
\r
716 numOfDiffProfile++;
\r
718 if(numOfDiffProfile == 1)
\r
720 if(pBtLinkInfo->bScoExist)
\r
722 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO only\n"));
\r
723 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
\r
727 if(pBtLinkInfo->bHidExist)
\r
729 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID only\n"));
\r
730 algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
\r
732 else if(pBtLinkInfo->bA2dpExist)
\r
734 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP only\n"));
\r
735 algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP;
\r
737 else if(pBtLinkInfo->bPanExist)
\r
741 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = PAN(HS) only\n"));
\r
742 algorithm = BT_8723B_1ANT_COEX_ALGO_PANHS;
\r
746 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = PAN(EDR) only\n"));
\r
747 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR;
\r
752 else if(numOfDiffProfile == 2)
\r
754 if(pBtLinkInfo->bScoExist)
\r
756 if(pBtLinkInfo->bHidExist)
\r
758 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID\n"));
\r
759 algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
\r
761 else if(pBtLinkInfo->bA2dpExist)
\r
763 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n"));
\r
764 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
\r
766 else if(pBtLinkInfo->bPanExist)
\r
770 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + PAN(HS)\n"));
\r
771 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
\r
775 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n"));
\r
776 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
782 if( pBtLinkInfo->bHidExist &&
\r
783 pBtLinkInfo->bA2dpExist )
\r
785 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP\n"));
\r
786 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
\r
788 else if( pBtLinkInfo->bHidExist &&
\r
789 pBtLinkInfo->bPanExist )
\r
793 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + PAN(HS)\n"));
\r
794 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
\r
798 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + PAN(EDR)\n"));
\r
799 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
802 else if( pBtLinkInfo->bPanExist &&
\r
803 pBtLinkInfo->bA2dpExist )
\r
807 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n"));
\r
808 algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS;
\r
812 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n"));
\r
813 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP;
\r
818 else if(numOfDiffProfile == 3)
\r
820 if(pBtLinkInfo->bScoExist)
\r
822 if( pBtLinkInfo->bHidExist &&
\r
823 pBtLinkInfo->bA2dpExist )
\r
825 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n"));
\r
826 algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
\r
828 else if( pBtLinkInfo->bHidExist &&
\r
829 pBtLinkInfo->bPanExist )
\r
833 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n"));
\r
834 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
\r
838 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n"));
\r
839 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
842 else if( pBtLinkInfo->bPanExist &&
\r
843 pBtLinkInfo->bA2dpExist )
\r
847 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n"));
\r
848 algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
\r
852 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n"));
\r
853 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
859 if( pBtLinkInfo->bHidExist &&
\r
860 pBtLinkInfo->bPanExist &&
\r
861 pBtLinkInfo->bA2dpExist )
\r
865 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n"));
\r
866 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
\r
870 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n"));
\r
871 algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
\r
876 else if(numOfDiffProfile >= 3)
\r
878 if(pBtLinkInfo->bScoExist)
\r
880 if( pBtLinkInfo->bHidExist &&
\r
881 pBtLinkInfo->bPanExist &&
\r
882 pBtLinkInfo->bA2dpExist )
\r
886 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n"));
\r
891 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
\r
892 algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
\r
902 halbtc8723b1ant_SetBtAutoReport(
\r
903 IN PBTC_COEXIST pBtCoexist,
\r
904 IN BOOLEAN bEnableAutoReport
\r
907 u1Byte H2C_Parameter[1] ={0};
\r
909 H2C_Parameter[0] = 0;
\r
911 if(bEnableAutoReport)
\r
913 H2C_Parameter[0] |= BIT0;
\r
916 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
\r
917 (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));
\r
919 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter);
\r
923 halbtc8723b1ant_BtAutoReport(
\r
924 IN PBTC_COEXIST pBtCoexist,
\r
925 IN BOOLEAN bForceExec,
\r
926 IN BOOLEAN bEnableAutoReport
\r
929 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Auto report = %s\n",
\r
930 (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
\r
931 pCoexDm->bCurBtAutoReport = bEnableAutoReport;
\r
935 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
\r
936 pCoexDm->bPreBtAutoReport, pCoexDm->bCurBtAutoReport));
\r
938 if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
\r
941 halbtc8723b1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
\r
943 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
\r
947 halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(
\r
948 IN PBTC_COEXIST pBtCoexist,
\r
949 IN BOOLEAN bLowPenaltyRa
\r
952 u1Byte H2C_Parameter[6] ={0};
\r
954 H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty
\r
958 H2C_Parameter[1] |= BIT0;
\r
959 H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36
\r
960 H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54
\r
961 H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48
\r
962 H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36
\r
965 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set WiFi Low-Penalty Retry: %s",
\r
966 (bLowPenaltyRa? "ON!!":"OFF!!") ));
\r
968 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
\r
972 halbtc8723b1ant_LowPenaltyRa(
\r
973 IN PBTC_COEXIST pBtCoexist,
\r
974 IN BOOLEAN bForceExec,
\r
975 IN BOOLEAN bLowPenaltyRa
\r
978 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
982 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
985 halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
987 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
991 halbtc8723b1ant_SetCoexTable(
\r
992 IN PBTC_COEXIST pBtCoexist,
\r
993 IN u4Byte val0x6c0,
\r
994 IN u4Byte val0x6c4,
\r
995 IN u4Byte val0x6c8,
\r
999 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
\r
1000 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
\r
1002 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
\r
1003 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
\r
1005 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
1006 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
1008 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
1009 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
1013 halbtc8723b1ant_CoexTable(
\r
1014 IN PBTC_COEXIST pBtCoexist,
\r
1015 IN BOOLEAN bForceExec,
\r
1016 IN u4Byte val0x6c0,
\r
1017 IN u4Byte val0x6c4,
\r
1018 IN u4Byte val0x6c8,
\r
1019 IN u1Byte val0x6cc
\r
1022 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6cc=0x%x\n",
\r
1023 (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6cc));
\r
1024 pCoexDm->curVal0x6c0 = val0x6c0;
\r
1025 pCoexDm->curVal0x6c4 = val0x6c4;
\r
1026 pCoexDm->curVal0x6c8 = val0x6c8;
\r
1027 pCoexDm->curVal0x6cc = val0x6cc;
\r
1031 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c4=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
\r
1032 // pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
\r
1033 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
\r
1034 // pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
\r
1036 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
\r
1037 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
\r
1038 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
1039 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
1042 halbtc8723b1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
\r
1044 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
\r
1045 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
\r
1046 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
1047 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
1051 halbtc8723b1ant_CoexTableWithType(
\r
1052 IN PBTC_COEXIST pBtCoexist,
\r
1053 IN BOOLEAN bForceExec,
\r
1057 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ********** CoexTable(%d) **********\n", type));
\r
1059 pCoexSta->nCoexTableType = type;
\r
1064 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);
\r
1067 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
\r
1070 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);
\r
1073 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
\r
1076 if ((pCoexSta->nScanAPNum <= 5) || ( pCoexSta->bCCKEverLock) )
\r
1077 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3);
\r
1079 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3);
\r
1082 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaa5a5a, 0xffffff, 0x3);
\r
1085 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3);
\r
1088 halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
\r
1096 halbtc8723b1ant_SetFwIgnoreWlanAct(
\r
1097 IN PBTC_COEXIST pBtCoexist,
\r
1098 IN BOOLEAN bEnable
\r
1101 u1Byte H2C_Parameter[1] ={0};
\r
1105 H2C_Parameter[0] |= BIT0; // function enable
\r
1108 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
\r
1109 H2C_Parameter[0]));
\r
1111 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
\r
1115 halbtc8723b1ant_IgnoreWlanAct(
\r
1116 IN PBTC_COEXIST pBtCoexist,
\r
1117 IN BOOLEAN bForceExec,
\r
1118 IN BOOLEAN bEnable
\r
1121 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
\r
1122 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
\r
1123 pCoexDm->bCurIgnoreWlanAct = bEnable;
\r
1127 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
\r
1128 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
\r
1130 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
\r
1133 halbtc8723b1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
\r
1135 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
\r
1139 halbtc8723b1ant_SetLpsRpwm(
\r
1140 IN PBTC_COEXIST pBtCoexist,
\r
1145 u1Byte lps=lpsVal;
\r
1146 u1Byte rpwm=rpwmVal;
\r
1148 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
\r
1149 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
\r
1153 halbtc8723b1ant_LpsRpwm(
\r
1154 IN PBTC_COEXIST pBtCoexist,
\r
1155 IN BOOLEAN bForceExec,
\r
1160 BOOLEAN bForceExecPwrCmd=FALSE;
\r
1162 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
\r
1163 (bForceExec? "force to":""), lpsVal, rpwmVal));
\r
1164 pCoexDm->curLps = lpsVal;
\r
1165 pCoexDm->curRpwm = rpwmVal;
\r
1169 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], LPS-RxBeaconMode=0x%x , LPS-RPWM=0x%x!!\n",
\r
1170 pCoexDm->curLps, pCoexDm->curRpwm));
\r
1172 if( (pCoexDm->preLps == pCoexDm->curLps) &&
\r
1173 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
\r
1175 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], LPS-RPWM_Last=0x%x , LPS-RPWM_Now=0x%x!!\n",
\r
1176 pCoexDm->preRpwm, pCoexDm->curRpwm));
\r
1181 halbtc8723b1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
\r
1183 pCoexDm->preLps = pCoexDm->curLps;
\r
1184 pCoexDm->preRpwm = pCoexDm->curRpwm;
\r
1188 halbtc8723b1ant_SwMechanism(
\r
1189 IN PBTC_COEXIST pBtCoexist,
\r
1190 IN BOOLEAN bLowPenaltyRA
\r
1193 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], SM[LpRA] = %d\n",
\r
1196 halbtc8723b1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
\r
1200 halbtc8723b1ant_SetAntPath(
\r
1201 IN PBTC_COEXIST pBtCoexist,
\r
1202 IN u1Byte antPosType,
\r
1203 IN BOOLEAN bForceExec,
\r
1204 IN BOOLEAN bInitHwCfg,
\r
1205 IN BOOLEAN bWifiOff
\r
1208 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1209 u4Byte fwVer=0, u4Tmp=0, cntBtCalChk=0;
\r
1210 BOOLEAN bPgExtSwitch=FALSE;
\r
1211 BOOLEAN bUseExtSwitch=FALSE;
\r
1212 BOOLEAN bIsInMpMode = FALSE;
\r
1213 u1Byte H2C_Parameter[2] ={0}, u1Tmp = 0;
\r
1215 pCoexDm->curAntPosType = antPosType;
\r
1217 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch);
\r
1218 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); // [31:16]=fw ver, [15:0]=fw sub ver
\r
1220 if((fwVer>0 && fwVer<0xc0000) || bPgExtSwitch)
\r
1221 bUseExtSwitch = TRUE;
\r
1225 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); //WiFi TRx Mask on
\r
1226 //remove due to interrupt is disabled that polling c2h will fail and delay 100ms.
\r
1227 //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); //BT TRx Mask on
\r
1229 if(fwVer >= 0x180000)
\r
1231 /* Use H2C to set GNT_BT to HIGH */
\r
1232 H2C_Parameter[0] = 1;
\r
1233 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
\r
1237 // set grant_bt to high
\r
1238 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
\r
1240 //set wlan_act control by PTA
\r
1241 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
1243 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); //BT select s0/s1 is controlled by BT
\r
1245 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1);
\r
1246 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff);
\r
1247 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3);
\r
1248 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77);
\r
1252 if(fwVer >= 0x180000)
\r
1254 /* Use H2C to set GNT_BT to HIGH */
\r
1255 H2C_Parameter[0] = 1;
\r
1256 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
\r
1260 // set grant_bt to high
\r
1261 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
\r
1263 //set wlan_act to always low
\r
1264 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
1266 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode);
\r
1268 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); //BT select s0/s1 is controlled by BT
\r
1270 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi
\r
1272 // 0x4c[24:23]=00, Set Antenna control by BT_RFE_CTRL BT Vendor 0xac=0xf002
\r
1273 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1276 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1280 /* Use H2C to set GNT_BT to LOW */
\r
1281 if(fwVer >= 0x180000)
\r
1283 if (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765) != 0)
\r
1285 H2C_Parameter[0] = 0;
\r
1286 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
\r
1291 // BT calibration check
\r
1292 while(cntBtCalChk <= 20)
\r
1294 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49d);
\r
1298 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ########### BT is calibrating (wait cnt=%d) ###########\n", cntBtCalChk));
\r
1303 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ********** BT is NOT calibrating (wait cnt=%d)**********\n", cntBtCalChk));
\r
1308 // set grant_bt to PTA
\r
1309 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0);
\r
1312 if (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) != 0xc)
\r
1314 //set wlan_act control by PTA
\r
1315 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
1318 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi
\r
1325 // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT
\r
1326 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1329 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1331 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); // fixed internal switch S1->WiFi, S0->BT
\r
1333 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1335 //tell firmware "no antenna inverse"
\r
1336 H2C_Parameter[0] = 0;
\r
1337 H2C_Parameter[1] = 1; //ext switch type
\r
1338 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1342 //tell firmware "antenna inverse"
\r
1343 H2C_Parameter[0] = 1;
\r
1344 H2C_Parameter[1] = 1; //ext switch type
\r
1345 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1349 if(bForceExec || (pCoexDm->curAntPosType != pCoexDm->preAntPosType))
\r
1351 // ext switch setting
\r
1352 switch(antPosType)
\r
1354 case BTC_ANT_PATH_WIFI:
\r
1355 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1356 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
\r
1358 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
\r
1360 case BTC_ANT_PATH_BT:
\r
1361 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1362 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
\r
1364 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
\r
1367 case BTC_ANT_PATH_PTA:
\r
1368 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1369 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
\r
1371 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
\r
1380 // 0x4c[23]=1, 0x4c[24]=0 Antenna control by 0x64
\r
1381 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1384 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1386 //Fix Ext switch Main->S1, Aux->S0
\r
1387 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0);
\r
1389 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1392 //tell firmware "no antenna inverse"
\r
1393 H2C_Parameter[0] = 0;
\r
1394 H2C_Parameter[1] = 0; //internal switch type
\r
1395 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1400 //tell firmware "antenna inverse"
\r
1401 H2C_Parameter[0] = 1;
\r
1402 H2C_Parameter[1] = 0; //internal switch type
\r
1403 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1407 if(bForceExec || (pCoexDm->curAntPosType != pCoexDm->preAntPosType))
\r
1409 // internal switch setting
\r
1410 switch(antPosType)
\r
1412 case BTC_ANT_PATH_WIFI:
\r
1413 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1414 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
\r
1416 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
\r
1418 case BTC_ANT_PATH_BT:
\r
1419 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1420 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
\r
1422 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
\r
1425 case BTC_ANT_PATH_PTA:
\r
1426 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1427 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x200);
\r
1429 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x80);
\r
1435 pCoexDm->preAntPosType = pCoexDm->curAntPosType;
\r
1439 halbtc8723b1ant_SetAntPathDCut(
\r
1440 IN PBTC_COEXIST pBtCoexist,
\r
1441 IN BOOLEAN bAntennaAux, //For 1-Ant--> 1: Antenna at S0, 0: Antenna at S1. Set 0 for 2-Ant
\r
1442 IN BOOLEAN bExtSwitch, // 1: Ext Switch (SPDT) exist on module, 0: no Ext Switch (SPDT) exist on module
\r
1443 IN BOOLEAN bTwoAntenna, // 1: 2-Antenna, 0:1-Antenna
\r
1444 IN u1Byte antennaPos, //Set Antenna Pos, For 1-Ant: BTC_ANT_PATH_WIFI, BTC_ANT_PATH_BT, BTC_ANT_PATH_PTA, For 2-Ant:BTC_ANT_WIFI_AT_MAIN, BTC_ANT_WIFI_AT_Aux
\r
1445 IN u1Byte wifiState //BTC_WIFI_STAT_INIT, BTC_WIFI_STAT_IQK, BTC_WIFI_STAT_NORMAL_OFF, BTC_WIFI_STAT_MP_OFF, BTC_WIFI_STAT_NORMAL, BTC_WIFI_STAT_ANT_DIV
\r
1449 u1Byte buf[6] = {0};
\r
1451 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set BT Ant, bAntennaAux/bExtSwitch/bTwoAntenna/antennaPos/wifiState=%d/%d/%d/%d/%d\n",
\r
1452 bAntennaAux, bExtSwitch, bTwoAntenna, antennaPos, wifiState));
\r
1454 buf[0] = dataLen;
\r
1465 buf[4] = antennaPos;
\r
1467 buf[5] = wifiState;
\r
1469 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_8723B_ANT, (PVOID)&buf[0]);
\r
1473 halbtc8723b1ant_SetFwPstdma(
\r
1474 IN PBTC_COEXIST pBtCoexist,
\r
1482 u1Byte H2C_Parameter[5] ={0};
\r
1483 u1Byte realByte1=byte1, realByte5=byte5;
\r
1484 BOOLEAN bApEnable=FALSE;
\r
1486 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
1490 if(byte1&BIT4 && !(byte1&BIT5))
\r
1492 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], FW for 1Ant AP mode\n"));
\r
1493 realByte1 &= ~BIT4;
\r
1494 realByte1 |= BIT5;
\r
1496 realByte5 |= BIT5;
\r
1497 realByte5 &= ~BIT6;
\r
1501 H2C_Parameter[0] = realByte1;
\r
1502 H2C_Parameter[1] = byte2;
\r
1503 H2C_Parameter[2] = byte3;
\r
1504 H2C_Parameter[3] = byte4;
\r
1505 H2C_Parameter[4] = realByte5;
\r
1507 pCoexDm->psTdmaPara[0] = realByte1;
\r
1508 pCoexDm->psTdmaPara[1] = byte2;
\r
1509 pCoexDm->psTdmaPara[2] = byte3;
\r
1510 pCoexDm->psTdmaPara[3] = byte4;
\r
1511 pCoexDm->psTdmaPara[4] = realByte5;
\r
1513 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n",
\r
1514 H2C_Parameter[0],
\r
1515 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
\r
1517 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
\r
1522 halbtc8723b1ant_PsTdma(
\r
1523 IN PBTC_COEXIST pBtCoexist,
\r
1524 IN BOOLEAN bForceExec,
\r
1525 IN BOOLEAN bTurnOn,
\r
1529 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1530 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
1531 BOOLEAN bTurnOnByCnt=FALSE, bWifiBusy=FALSE, bWiFiNoisy=FALSE;
\r
1532 u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0;
\r
1533 u1Byte psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10;
\r
1534 s1Byte nWiFiDurationAdjust = 0x0;
\r
1535 static BOOLEAN bPreWifiBusy=FALSE;
\r
1537 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
\r
1538 // (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
\r
1539 pCoexDm->bCurPsTdmaOn = bTurnOn;
\r
1540 pCoexDm->curPsTdma = type;
\r
1542 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1544 if (bWifiBusy != bPreWifiBusy)
\r
1546 bForceExec = TRUE;
\r
1547 bPreWifiBusy = bWifiBusy;
\r
1550 if (pCoexDm->bCurPsTdmaOn)
\r
1552 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ********** TDMA(on, %d) **********\n",
\r
1553 pCoexDm->curPsTdma));
\r
1557 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ********** TDMA(off, %d) **********\n",
\r
1558 pCoexDm->curPsTdma));
\r
1563 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
\r
1564 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
\r
1568 if (pCoexSta->nScanAPNum <= 5)
\r
1569 nWiFiDurationAdjust = 5;
\r
1570 //nWiFiDurationAdjust = 2;
\r
1571 else if (pCoexSta->nScanAPNum >= 40)
\r
1572 nWiFiDurationAdjust = -15;
\r
1573 else if (pCoexSta->nScanAPNum >= 20)
\r
1574 nWiFiDurationAdjust = -10;
\r
1576 if (!pCoexSta->bForceLpsOn) //only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30
\r
1578 psTdmaByte0Val = 0x61; //no null-pkt
\r
1579 psTdmaByte3Val = 0x11; // no tx-pause at BT-slot
\r
1580 psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle
\r
1583 if ( (type == 3) || (type == 13) || (type == 14) )
\r
1585 psTdmaByte4Val = psTdmaByte4Val & 0xbf; //no dynamic slot for multi-profile
\r
1588 psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts)
\r
1591 if (pBtLinkInfo->bSlaveRole == TRUE)
\r
1592 psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts)
\r
1599 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val);
\r
1602 halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val);
\r
1605 halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val);
\r
1608 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, psTdmaByte4Val);
\r
1611 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
\r
1614 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x11);
\r
1617 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x11);
\r
1620 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
\r
1623 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1626 halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val);
\r
1629 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
\r
1632 halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val);
\r
1635 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50);
\r
1638 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, psTdmaByte4Val);
\r
1641 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, psTdmaByte4Val);
\r
1644 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0);
\r
1647 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0);
\r
1650 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1653 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x3f, 0x03, 0x11, 0x10);
\r
1656 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11);
\r
1659 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10);
\r
1662 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);
\r
1665 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);
\r
1668 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1671 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1674 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);
\r
1677 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0);
\r
1680 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10);
\r
1683 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10);
\r
1686 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);
\r
1689 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11);
\r
1692 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90);
\r
1695 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10);
\r
1698 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10);
\r
1701 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50);
\r
1703 case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving
\r
1704 /* here softap mode screen off will cost 70-80mA for phone */
\r
1705 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24);
\r
1712 // disable PS tdma
\r
1715 case 8: //PTA Control
\r
1716 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
\r
1717 //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_PTA, BTC_WIFI_STAT_NORMAL);
\r
1718 //halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE);
\r
1721 default: //Software control, Antenna at BT side
\r
1722 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1723 //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL);
\r
1724 //halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
\r
1727 case 9: //Software control, Antenna at WiFi side
\r
1728 halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1729 //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_WIFI, BTC_WIFI_STAT_NORMAL);
\r
1730 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE);
\r
1736 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal);
\r
1739 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n",
\r
1740 pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67)));
\r
1742 // update pre state
\r
1743 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
\r
1744 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
\r
1748 halbtc8723b1ant_IsCommonAction(
\r
1749 IN PBTC_COEXIST pBtCoexist
\r
1752 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
1754 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1755 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1757 if(!bWifiConnected &&
\r
1758 BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
1760 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));
\r
1762 //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1766 else if(bWifiConnected &&
\r
1767 (BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1769 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
\r
1771 //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1775 else if(!bWifiConnected &&
\r
1776 (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1778 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));
\r
1780 //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1784 else if(bWifiConnected &&
\r
1785 (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1787 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
\r
1789 //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1793 else if(!bWifiConnected &&
\r
1794 (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) )
\r
1796 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
\r
1798 //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
1806 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
\r
1810 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));
\r
1821 halbtc8723b1ant_TdmaDurationAdjustForAcl(
\r
1822 IN PBTC_COEXIST pBtCoexist,
\r
1823 IN u1Byte wifiStatus
\r
1826 static s4Byte up,dn,m,n,WaitCount;
\r
1827 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
\r
1828 u1Byte retryCount=0, btInfoExt;
\r
1829 static BOOLEAN bPreWifiBusy=FALSE;
\r
1830 BOOLEAN bWifiBusy = FALSE;
\r
1832 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjustForAcl()\n"));
\r
1834 if(BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus)
\r
1837 bWifiBusy = FALSE;
\r
1839 if( (BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
\r
1840 (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
\r
1841 (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
\r
1843 if( pCoexDm->curPsTdma != 1 &&
\r
1844 pCoexDm->curPsTdma != 2 &&
\r
1845 pCoexDm->curPsTdma != 3 &&
\r
1846 pCoexDm->curPsTdma != 9 )
\r
1848 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1849 pCoexDm->psTdmaDuAdjType = 9;
\r
1861 if(!pCoexDm->bAutoTdmaAdjust)
\r
1863 pCoexDm->bAutoTdmaAdjust = TRUE;
\r
1864 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
\r
1866 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1867 pCoexDm->psTdmaDuAdjType = 2;
\r
1878 //accquire the BT TRx retry count from BT_Info byte2
\r
1879 retryCount = pCoexSta->btRetryCnt;
\r
1880 btInfoExt = pCoexSta->btInfoExt;
\r
1881 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
\r
1882 //BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
\r
1883 // up, dn, m, n, WaitCount));
\r
1885 if ( (pCoexSta->lowPriorityTx) > 1150 || (pCoexSta->lowPriorityRx) > 1250 )
\r
1891 if(retryCount == 0) // no retry in the last 2-second duration
\r
1899 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
\r
1906 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
\r
1909 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
\r
1917 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
\r
1919 if (WaitCount <= 2)
\r
1920 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1924 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1932 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
\r
1935 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
\r
1937 if (WaitCount == 1)
\r
1938 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1942 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1950 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
\r
1955 if( (BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1956 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1958 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1959 pCoexDm->psTdmaDuAdjType = 9;
\r
1961 else if(pCoexDm->curPsTdma == 1)
\r
1963 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1964 pCoexDm->psTdmaDuAdjType = 2;
\r
1966 else if(pCoexDm->curPsTdma == 2)
\r
1968 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1969 pCoexDm->psTdmaDuAdjType = 9;
\r
1971 else if(pCoexDm->curPsTdma == 9)
\r
1973 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
1974 pCoexDm->psTdmaDuAdjType = 11;
\r
1977 else if(result == 1)
\r
1979 if( (BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1980 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1982 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1983 pCoexDm->psTdmaDuAdjType = 9;
\r
1985 else if(pCoexDm->curPsTdma == 11)
\r
1987 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1988 pCoexDm->psTdmaDuAdjType = 9;
\r
1990 else if(pCoexDm->curPsTdma == 9)
\r
1992 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1993 pCoexDm->psTdmaDuAdjType = 2;
\r
1995 else if(pCoexDm->curPsTdma == 2)
\r
1997 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
1998 pCoexDm->psTdmaDuAdjType = 1;
\r
2004 if(bWifiBusy != bPreWifiBusy) //if busy / idle change
\r
2006 bPreWifiBusy = bWifiBusy;
\r
2007 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, pCoexDm->curPsTdma);
\r
2011 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], ********** TDMA(on, %d) **********\n",
\r
2012 pCoexDm->curPsTdma));
\r
2015 if( pCoexDm->curPsTdma != 1 &&
\r
2016 pCoexDm->curPsTdma != 2 &&
\r
2017 pCoexDm->curPsTdma != 9 &&
\r
2018 pCoexDm->curPsTdma != 11 )
\r
2020 // recover to previous adjust type
\r
2021 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
\r
2027 halbtc8723b1ant_PsTdmaCheckForPowerSaveState(
\r
2028 IN PBTC_COEXIST pBtCoexist,
\r
2029 IN BOOLEAN bNewPsState
\r
2032 u1Byte lpsMode=0x0;
\r
2034 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
\r
2036 if(lpsMode) // already under LPS state
\r
2040 // keep state under LPS, do nothing.
\r
2044 // will leave LPS state, turn off psTdma first
\r
2045 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2048 else // NO PS state
\r
2052 // will enter LPS state, turn off psTdma first
\r
2053 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2057 // keep state under NO PS state, do nothing.
\r
2063 halbtc8723b1ant_PowerSaveState(
\r
2064 IN PBTC_COEXIST pBtCoexist,
\r
2070 BOOLEAN bLowPwrDisable=FALSE;
\r
2074 case BTC_PS_WIFI_NATIVE:
\r
2075 // recover to original 32k low power setting
\r
2076 bLowPwrDisable = FALSE;
\r
2077 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
2078 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
2079 pCoexSta->bForceLpsOn = FALSE;
\r
2081 case BTC_PS_LPS_ON:
\r
2082 halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);
\r
2083 halbtc8723b1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
\r
2084 // when coex force to enter LPS, do not enter 32k low power.
\r
2085 bLowPwrDisable = TRUE;
\r
2086 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
2087 // power save must executed before psTdma.
\r
2088 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
\r
2089 pCoexSta->bForceLpsOn = TRUE;
\r
2091 case BTC_PS_LPS_OFF:
\r
2092 halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
\r
2093 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
2094 pCoexSta->bForceLpsOn = FALSE;
\r
2102 halbtc8723b1ant_ActionWifiOnly(
\r
2103 IN PBTC_COEXIST pBtCoexist
\r
2106 halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
2107 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
2108 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE);
\r
2112 halbtc8723b1ant_MonitorBtEnableDisable(
\r
2113 IN PBTC_COEXIST pBtCoexist
\r
2116 static BOOLEAN bPreBtDisabled=FALSE;
\r
2117 static u4Byte btDisableCnt=0;
\r
2118 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
\r
2120 // This function check if bt is disabled
\r
2122 if( pCoexSta->highPriorityTx == 0 &&
\r
2123 pCoexSta->highPriorityRx == 0 &&
\r
2124 pCoexSta->lowPriorityTx == 0 &&
\r
2125 pCoexSta->lowPriorityRx == 0)
\r
2127 bBtActive = FALSE;
\r
2129 if( pCoexSta->highPriorityTx == 0xffff &&
\r
2130 pCoexSta->highPriorityRx == 0xffff &&
\r
2131 pCoexSta->lowPriorityTx == 0xffff &&
\r
2132 pCoexSta->lowPriorityRx == 0xffff)
\r
2134 bBtActive = FALSE;
\r
2139 bBtDisabled = FALSE;
\r
2140 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
2141 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
\r
2146 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
\r
2148 if(btDisableCnt >= 2)
\r
2150 bBtDisabled = TRUE;
\r
2151 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
2152 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
\r
2153 halbtc8723b1ant_ActionWifiOnly(pBtCoexist);
\r
2156 if(bPreBtDisabled != bBtDisabled)
\r
2158 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
\r
2159 (bPreBtDisabled ? "disabled":"enabled"),
\r
2160 (bBtDisabled ? "disabled":"enabled")));
\r
2161 bPreBtDisabled = bBtDisabled;
\r
2167 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
2168 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
2173 //=============================================
\r
2175 // Software Coex Mechanism start
\r
2177 //=============================================
\r
2179 // SCO only or SCO+PAN(HS)
\r
2183 halbtc8723b1ant_ActionSco(
\r
2184 IN PBTC_COEXIST pBtCoexist
\r
2187 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
2192 halbtc8723b1ant_ActionHid(
\r
2193 IN PBTC_COEXIST pBtCoexist
\r
2196 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
2199 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
\r
2201 halbtc8723b1ant_ActionA2dp(
\r
2202 IN PBTC_COEXIST pBtCoexist
\r
2205 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
2209 halbtc8723b1ant_ActionA2dpPanHs(
\r
2210 IN PBTC_COEXIST pBtCoexist
\r
2213 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
2217 halbtc8723b1ant_ActionPanEdr(
\r
2218 IN PBTC_COEXIST pBtCoexist
\r
2221 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
2226 halbtc8723b1ant_ActionPanHs(
\r
2227 IN PBTC_COEXIST pBtCoexist
\r
2230 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
2235 halbtc8723b1ant_ActionPanEdrA2dp(
\r
2236 IN PBTC_COEXIST pBtCoexist
\r
2239 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
2243 halbtc8723b1ant_ActionPanEdrHid(
\r
2244 IN PBTC_COEXIST pBtCoexist
\r
2247 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
2250 // HID+A2DP+PAN(EDR)
\r
2252 halbtc8723b1ant_ActionHidA2dpPanEdr(
\r
2253 IN PBTC_COEXIST pBtCoexist
\r
2256 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
2260 halbtc8723b1ant_ActionHidA2dp(
\r
2261 IN PBTC_COEXIST pBtCoexist
\r
2264 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
2269 //=============================================
\r
2271 // Non-Software Coex Mechanism start
\r
2273 //=============================================
\r
2275 halbtc8723b1ant_ActionBtWhckTest(
\r
2276 IN PBTC_COEXIST pBtCoexist
\r
2279 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2281 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2282 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2283 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2287 halbtc8723b1ant_ActionWifiMultiPort(
\r
2288 IN PBTC_COEXIST pBtCoexist
\r
2291 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2293 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2294 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2295 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2299 halbtc8723b1ant_ActionHs(
\r
2300 IN PBTC_COEXIST pBtCoexist
\r
2303 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2304 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2308 halbtc8723b1ant_ActionBtInquiry(
\r
2309 IN PBTC_COEXIST pBtCoexist
\r
2312 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2313 BOOLEAN bWifiConnected=FALSE, bApEnable=FALSE, bWifiBusy=FALSE, bBtBusy=FALSE;
\r
2315 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
2316 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2317 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
2318 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
2320 if ( (!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask) )
\r
2322 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2323 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2324 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2325 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2327 else if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) )
\r
2329 // SCO/HID/A2DP busy
\r
2330 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2331 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2333 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2335 else if ( (pBtLinkInfo->bPanExist) || (bWifiBusy) )
\r
2337 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2339 //for BT inquiry/page fail after S4 resume
\r
2340 //halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2341 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2343 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2347 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2349 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2350 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2351 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
2354 //halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2355 //halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2360 halbtc8723b1ant_ActionBtScoHidOnlyBusy(
\r
2361 IN PBTC_COEXIST pBtCoexist,
\r
2362 IN u1Byte wifiStatus
\r
2365 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2366 BOOLEAN bWifiConnected=FALSE;
\r
2367 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
\r
2369 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2371 // tdma and coex table
\r
2373 if(pBtLinkInfo->bScoExist)
\r
2375 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2376 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);
\r
2380 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2381 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);
\r
2386 halbtc8723b1ant_ActionWifiConnectedBtAclBusy(
\r
2387 IN PBTC_COEXIST pBtCoexist,
\r
2388 IN u1Byte wifiStatus
\r
2391 u1Byte btRssiState;
\r
2393 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2394 btRssiState = halbtc8723b1ant_BtRssiState(2, 28, 0);
\r
2396 if ( (pCoexSta->lowPriorityRx >= 950) && (!pCoexSta->bUnderIps) )
\r
2398 pBtLinkInfo->bSlaveRole = TRUE;
\r
2402 pBtLinkInfo->bSlaveRole = FALSE;
\r
2405 if(pBtLinkInfo->bHidOnly) //HID
\r
2407 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);
\r
2408 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2411 else if(pBtLinkInfo->bA2dpOnly) //A2DP
\r
2413 if(BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus)
\r
2415 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2416 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2417 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2421 halbtc8723b1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);
\r
2422 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2423 pCoexDm->bAutoTdmaAdjust = TRUE;
\r
2426 else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) ||
\r
2427 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP)
\r
2429 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
2430 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2431 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2433 else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) //HID+A2DP
\r
2435 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2436 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2438 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3);
\r
2440 else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP)
\r
2442 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2443 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2444 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2448 //BT no-profile busy (0x9)
\r
2449 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2450 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2451 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2456 halbtc8723b1ant_ActionWifiNotConnected(
\r
2457 IN PBTC_COEXIST pBtCoexist
\r
2460 // power save state
\r
2461 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2463 // tdma and coex table
\r
2464 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
2465 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2466 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2470 halbtc8723b1ant_ActionWifiNotConnectedScan(
\r
2471 IN PBTC_COEXIST pBtCoexist
\r
2474 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2476 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2478 // tdma and coex table
\r
2479 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2481 if (pBtLinkInfo->bA2dpExist)
\r
2483 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2484 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2486 else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)
\r
2488 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
2489 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2493 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2494 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2497 else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2498 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2500 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2501 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
2506 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2507 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2508 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2513 halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(
\r
2514 IN PBTC_COEXIST pBtCoexist
\r
2517 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2519 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2521 // tdma and coex table
\r
2522 if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) )
\r
2524 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2525 halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4);
\r
2527 else if (pBtLinkInfo->bPanExist)
\r
2529 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2530 halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4);
\r
2534 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2535 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2536 halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 2);
\r
2541 halbtc8723b1ant_ActionWifiConnectedScan(
\r
2542 IN PBTC_COEXIST pBtCoexist
\r
2545 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2547 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2549 // tdma and coex table
\r
2550 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2552 if (pBtLinkInfo->bA2dpExist)
\r
2554 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2555 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2557 else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)
\r
2559 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
2560 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2564 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2565 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2568 else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2569 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2571 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2572 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
2577 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2578 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2579 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2584 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(
\r
2585 IN PBTC_COEXIST pBtCoexist
\r
2588 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2590 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2592 // tdma and coex table
\r
2593 if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) )
\r
2595 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
2596 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2598 else if(pBtLinkInfo->bPanExist)
\r
2600 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);
\r
2601 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
\r
2605 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2606 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2607 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2612 halbtc8723b1ant_ActionWifiConnected(
\r
2613 IN PBTC_COEXIST pBtCoexist
\r
2616 BOOLEAN bWifiBusy=FALSE;
\r
2617 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2618 BOOLEAN bUnder4way=FALSE, bApEnable=FALSE;
\r
2621 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect()===>\n"));
\r
2623 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
2626 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
2627 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));
\r
2631 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2632 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2633 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2634 if(bScan || bLink || bRoam)
\r
2637 halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist);
\r
2639 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
2640 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));
\r
2644 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
2645 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
2647 // power save state
\r
2648 if(!bApEnable && BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
\r
2650 if(pBtCoexist->btLinkInfo.bA2dpOnly) //A2DP
\r
2653 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2656 if (pCoexSta->nScanAPNum >= BT_8723B_1ANT_WIFI_NOISY_THRESH) //no force LPS, no PS-TDMA, use pure TDMA
\r
2658 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2662 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
2666 else if ((pCoexSta->bPanExist == FALSE) && (pCoexSta->bA2dpExist == FALSE) && (pCoexSta->bHidExist == FALSE))
\r
2667 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2669 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
2672 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2674 // tdma and coex table
\r
2677 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2679 halbtc8723b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2680 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
2682 else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2683 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2685 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2686 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
2690 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2691 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2692 if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 )
\r
2693 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2695 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
2700 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2702 halbtc8723b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2703 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
2705 else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2706 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2708 halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2709 BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
2713 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2714 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);
\r
2715 if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 )
\r
2716 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2718 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
2724 halbtc8723b1ant_RunSwCoexistMechanism(
\r
2725 IN PBTC_COEXIST pBtCoexist
\r
2728 u1Byte algorithm=0;
\r
2730 algorithm = halbtc8723b1ant_ActionAlgorithm(pBtCoexist);
\r
2731 pCoexDm->curAlgorithm = algorithm;
\r
2733 if(halbtc8723b1ant_IsCommonAction(pBtCoexist))
\r
2739 switch(pCoexDm->curAlgorithm)
\r
2741 case BT_8723B_1ANT_COEX_ALGO_SCO:
\r
2742 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n"));
\r
2743 //halbtc8723b1ant_ActionSco(pBtCoexist);
\r
2745 case BT_8723B_1ANT_COEX_ALGO_HID:
\r
2746 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n"));
\r
2747 //halbtc8723b1ant_ActionHid(pBtCoexist);
\r
2749 case BT_8723B_1ANT_COEX_ALGO_A2DP:
\r
2750 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n"));
\r
2751 //halbtc8723b1ant_ActionA2dp(pBtCoexist);
\r
2753 case BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS:
\r
2754 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
\r
2755 //halbtc8723b1ant_ActionA2dpPanHs(pBtCoexist);
\r
2757 case BT_8723B_1ANT_COEX_ALGO_PANEDR:
\r
2758 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
\r
2759 //halbtc8723b1ant_ActionPanEdr(pBtCoexist);
\r
2761 case BT_8723B_1ANT_COEX_ALGO_PANHS:
\r
2762 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n"));
\r
2763 //halbtc8723b1ant_ActionPanHs(pBtCoexist);
\r
2765 case BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP:
\r
2766 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
\r
2767 //halbtc8723b1ant_ActionPanEdrA2dp(pBtCoexist);
\r
2769 case BT_8723B_1ANT_COEX_ALGO_PANEDR_HID:
\r
2770 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
\r
2771 //halbtc8723b1ant_ActionPanEdrHid(pBtCoexist);
\r
2773 case BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
\r
2774 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
\r
2775 //halbtc8723b1ant_ActionHidA2dpPanEdr(pBtCoexist);
\r
2777 case BT_8723B_1ANT_COEX_ALGO_HID_A2DP:
\r
2778 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
\r
2779 //halbtc8723b1ant_ActionHidA2dp(pBtCoexist);
\r
2782 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
\r
2783 //halbtc8723b1ant_CoexAllOff(pBtCoexist);
\r
2786 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
\r
2791 halbtc8723b1ant_RunCoexistMechanism(
\r
2792 IN PBTC_COEXIST pBtCoexist
\r
2795 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2796 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2797 BOOLEAN bIncreaseScanDevNum=FALSE;
\r
2798 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
2799 BOOLEAN bMiracastPlusBt=FALSE;
\r
2800 u1Byte aggBufSize=5;
\r
2801 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
\r
2802 u4Byte wifiLinkStatus=0;
\r
2803 u4Byte numOfWifiLink=0, wifiBw;
\r
2805 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n"));
\r
2807 if(pBtCoexist->bManualControl)
\r
2809 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
\r
2813 if(pBtCoexist->bStopCoexDm)
\r
2815 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
\r
2819 if(pCoexSta->bUnderIps)
\r
2821 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
\r
2825 if(pCoexSta->bBtWhckTest)
\r
2827 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT is under WHCK TEST!!!\n"));
\r
2828 halbtc8723b1ant_ActionBtWhckTest(pBtCoexist);
\r
2832 if( (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
2833 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2834 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2836 bIncreaseScanDevNum = TRUE;
\r
2839 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum);
\r
2840 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2842 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
2843 numOfWifiLink = wifiLinkStatus>>16;
\r
2845 if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED))
\r
2847 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) );
\r
2849 if(pBtLinkInfo->bBtLinkExist)
\r
2851 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1);
\r
2852 bMiracastPlusBt = TRUE;
\r
2856 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2857 bMiracastPlusBt = FALSE;
\r
2859 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);
\r
2860 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
2862 if ( (pBtLinkInfo->bA2dpExist) && (pCoexSta->bC2hBtInquiryPage) )
\r
2864 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], BT Is Inquirying \n") );
\r
2865 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
\r
2868 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
\r
2874 bMiracastPlusBt = FALSE;
\r
2875 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);
\r
2878 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
2880 if ( (pBtLinkInfo->bBtLinkExist) && (bWifiConnected) )
\r
2882 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1);
\r
2884 if(pBtLinkInfo->bScoExist)//if (pBtLinkInfo->bBtHiPriLinkExist)
\r
2885 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x5);
\r
2887 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5);
\r
2889 if(pBtLinkInfo->bScoExist)
\r
2890 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x5);
\r
2893 if (BTC_WIFI_BW_HT40==wifiBw)
\r
2894 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x10);
\r
2896 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8);
\r
2900 halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE);
\r
2901 halbtc8723b1ant_RunSwCoexistMechanism(pBtCoexist); //just print debug message
\r
2905 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
2907 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5);
\r
2909 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
2910 halbtc8723b1ant_RunSwCoexistMechanism(pBtCoexist); ////just print debug message
\r
2913 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2914 if(pCoexSta->bC2hBtInquiryPage)
\r
2916 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], BT Is Inquirying \n") );
\r
2917 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
\r
2922 halbtc8723b1ant_ActionHs(pBtCoexist);
\r
2927 if(!bWifiConnected)
\r
2929 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2931 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n"));
\r
2933 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2934 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2935 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2937 if(bScan || bLink || bRoam)
\r
2940 halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist);
\r
2942 halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
\r
2945 halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist);
\r
2947 else // wifi LPS/Busy
\r
2949 halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
\r
2954 halbtc8723b1ant_Log2Base(
\r
2955 IN PBTC_COEXIST pBtCoexist,
\r
2961 u4Byte tmp, tmp2, val_integerdB=0, tindex, shiftcount=0;
\r
2962 u4Byte result,val_fractiondB=0,Table_fraction[21]= {0,432, 332, 274, 232, 200,
\r
2963 174, 151,132,115,100,86,74,62,51,42,
\r
2983 val_integerdB = shiftcount+1;
\r
2986 for (j=1; j<= val_integerdB;j++)
\r
2989 tmp = (val*100) /tmp2;
\r
2995 val_fractiondB = Table_fraction[tindex];
\r
2997 result = val_integerdB*100 - val_fractiondB;
\r
3007 halbtc8723b1ant_InitCoexDm(
\r
3008 IN PBTC_COEXIST pBtCoexist
\r
3011 // force to reset coex mechanism
\r
3014 halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE);
\r
3016 //halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
3017 //halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
3019 pCoexSta->popEventCnt = 0;
\r
3023 halbtc8723b1ant_InitHwConfig(
\r
3024 IN PBTC_COEXIST pBtCoexist,
\r
3025 IN BOOLEAN bBackUp,
\r
3026 IN BOOLEAN bWifiOnly
\r
3029 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
3030 u4Byte u4Tmp=0;//, fwVer;
\r
3032 u1Byte u1Tmp=0, u1Tmpa=0, u1Tmpb=0;
\r
3033 u1Byte H2C_Parameter[2] ={0};
\r
3035 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
\r
3037 pPsdScan->bIsAntDetEnable = FALSE;
\r
3038 #if 0//move to BTC_MEDIA_CONNECT
\r
3041 pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
\r
3042 pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
\r
3043 pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
\r
3044 pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
\r
3047 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x550, 0x8, 0x1); //enable TBTT nterrupt
\r
3049 // 0x790[5:0]=0x5
\r
3050 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, 0x5);
\r
3052 // Enable counter statistics
\r
3053 //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); //0x76e[3] =1, WLAN_Act control by PTA
\r
3054 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1);
\r
3055 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
\r
3058 //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi
\r
3060 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
3064 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FORCE_EXEC, TRUE, FALSE);
\r
3066 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, TRUE, FALSE);
\r
3071 halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_WIFI, BTC_WIFI_STAT_INIT);
\r
3072 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
3075 halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_INIT);
\r
3081 halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
3083 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
\r
3084 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
\r
3085 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
\r
3087 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n",
\r
3088 u4Tmp, u1Tmpa, u1Tmpb));
\r
3092 halbtc8723b1ant_ShowPSDData(
\r
3093 IN PBTC_COEXIST pBtCoexist
\r
3096 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
3097 u4Byte nDeltaFreqPerPoint;
\r
3098 u4Byte freq,freq1,freq2,n=0,i=0, j=0, m=0, PsdRep1, PsdRep2;
\r
3100 DbgPrint("xxxxxxxxxxxxxxxx DisplayAntIsolation()\n");
\r
3102 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n============[Antenna Detection info] (%d/%d)============\n",
\r
3103 pPsdScan->nPSDGenCount, pPsdScan->nPSDGenTotalCount);
\r
3104 CL_PRINTF(cliBuf);
\r
3106 if (pPsdScan->nPSDGenTotalCount == 0)
\r
3108 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n No Data !!\n");
\r
3109 CL_PRINTF(cliBuf);
\r
3113 if (pPsdScan->nPSDPoint == 0)
\r
3114 nDeltaFreqPerPoint = 0;
\r
3116 nDeltaFreqPerPoint = pPsdScan->nPSDBandWidth/pPsdScan->nPSDPoint;
\r
3118 if (pPsdScan->bIsPSDShowMaxOnly)
\r
3120 PsdRep1 = pPsdScan->nPSDMaxValue/100;
\r
3121 PsdRep2 = pPsdScan->nPSDMaxValue - PsdRep1 * 100;
\r
3123 freq = ((pPsdScan->realcentFreq-20) * 1000000 + pPsdScan->nPSDMaxValuePoint * nDeltaFreqPerPoint);
\r
3124 freq1 = freq/1000000;
\r
3125 freq2 = freq/1000 - freq1 * 1000;
\r
3128 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq = %d.0%d MHz",
\r
3131 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq = %d.%d MHz",
\r
3134 if (PsdRep2 < 10)
\r
3135 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, ", Value = %d.0%d dB, (%d/%d) \n",
\r
3136 PsdRep1, PsdRep2, pPsdScan->nPSDGenCount, pPsdScan->nPSDGenTotalCount);
\r
3138 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, ", Value = %d.%d dB, %d, (%d/%d)\n",
\r
3139 PsdRep1, PsdRep2, pPsdScan->nPSDMaxValue, pPsdScan->nPSDGenCount, pPsdScan->nPSDGenTotalCount);
\r
3141 CL_PRINTF(cliBuf);
\r
3145 m = pPsdScan->nPSDStartPoint;
\r
3146 n = pPsdScan->nPSDStartPoint;
\r
3154 freq = ((pPsdScan->realcentFreq-20) * 1000000 + m * nDeltaFreqPerPoint);
\r
3155 freq1 = freq/1000000;
\r
3156 freq2 = freq/1000 - freq1 * 1000;
\r
3161 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq%6d.000", freq1);
\r
3162 else if (freq2 < 100)
\r
3163 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq%6d.0%2d", freq1,freq2);
\r
3165 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq%6d.%3d", freq1,freq2);
\r
3167 else if ( (i%8 == 0) || (m == pPsdScan->nPSDStopPoint) )
\r
3170 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.000\n", freq1);
\r
3171 else if (freq2 < 100)
\r
3172 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.0%2d\n", freq1,freq2);
\r
3174 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.%3d\n", freq1,freq2);
\r
3179 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.000", freq1);
\r
3180 else if (freq2 < 100)
\r
3181 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.0%2d", freq1,freq2);
\r
3183 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.%3d", freq1,freq2);
\r
3188 CL_PRINTF(cliBuf);
\r
3190 }while( (i <= 8) && (m <= pPsdScan->nPSDStopPoint));
\r
3195 PsdRep1 = pPsdScan->nPSDReport_MaxHold[n]/100;
\r
3196 PsdRep2 = pPsdScan->nPSDReport_MaxHold[n] - PsdRep1 * 100;
\r
3201 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Val %7d.0%d", PsdRep1,PsdRep2);
\r
3203 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Val %7d.%d", PsdRep1,PsdRep2);
\r
3205 else if ( (j%8 == 0) || (n == pPsdScan->nPSDStopPoint) )
\r
3208 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.0%d\n", PsdRep1,PsdRep2);
\r
3210 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.%d\n", PsdRep1,PsdRep2);
\r
3215 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.0%d", PsdRep1,PsdRep2);
\r
3217 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.%d", PsdRep1,PsdRep2);
\r
3222 CL_PRINTF(cliBuf);
\r
3224 } while( (j <= 8) && (n <= pPsdScan->nPSDStopPoint));
\r
3226 if ( (m > pPsdScan->nPSDStopPoint) || (n > pPsdScan->nPSDStopPoint) )
\r
3241 halbtc8723b1ant_GetPSDData(
\r
3242 IN PBTC_COEXIST pBtCoexist,
\r
3246 //reg 0x808[9:0]: FFT data x
\r
3247 //reg 0x808[22]: 0-->1 to get 1 FFT data y
\r
3248 //reg 0x8b4[15:0]: FFT data y report
\r
3250 u4Byte val = 0, psd_report =0;
\r
3252 val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x808);
\r
3254 val &= 0xffbffc00;
\r
3257 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x808, val);
\r
3259 val |= 0x00400000;
\r
3260 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x808, val);
\r
3263 val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x8b4);
\r
3265 psd_report = val & 0x0000ffff;
\r
3267 return psd_report;
\r
3272 halbtc8723b1ant_SweepPSDPoint(
\r
3273 IN PBTC_COEXIST pBtCoexist,
\r
3274 IN u4Byte centFreq,
\r
3281 u4Byte i,val,n,k=0;
\r
3282 u4Byte nPoints=0, psd_report=0;
\r
3283 u4Byte nStartP=0, nStopP=0, nDeltaFreqPerPoint=156250;
\r
3284 u4Byte nPSDCenterFreq=20*10^6, freq,freq1,freq2;
\r
3285 BOOLEAN outloop = FALSE;
\r
3287 u4Byte tmp, PsdRep1, PsdRep2;
\r
3289 pPsdScan->bIsPSDRunning = TRUE;
\r
3295 case 0: //Get PSD parameters
\r
3297 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), centFreq=0x%x, offset=0x%x, span=0x%x\n",
\r
3298 centFreq, offset, span);
\r
3300 pPsdScan->nPSDBandWidth = 40*1000000;
\r
3301 pPsdScan->nPSDPoint = points;
\r
3302 pPsdScan->nPSDStartBase = points/2;
\r
3303 pPsdScan->nPSDAvgNum = avgnum;
\r
3305 nPoints = pPsdScan->nPSDPoint;
\r
3306 nDeltaFreqPerPoint = pPsdScan->nPSDBandWidth/pPsdScan->nPSDPoint;
\r
3309 val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x808);
\r
3310 val &= 0xffff0fff;
\r
3312 switch(pPsdScan->nPSDPoint)
\r
3322 val |= 0x00008000;
\r
3325 val |= 0x0000c000;
\r
3329 switch(pPsdScan->nPSDAvgNum)
\r
3338 val |= 0x00002000;
\r
3342 val |= 0x00003000;
\r
3345 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x808, val);
\r
3347 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), PSD BW= %d, DeltaFreq=%d\n"
\r
3348 , pPsdScan->nPSDBandWidth, nDeltaFreqPerPoint);
\r
3351 case 1: //calculate the PSD point index from freq/offset/span
\r
3352 nPSDCenterFreq = pPsdScan->nPSDBandWidth /2 +offset*(1000000);
\r
3353 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), PSD Center Freq = %d\n", (centFreq + offset));
\r
3355 nStartP = pPsdScan->nPSDStartBase + (nPSDCenterFreq - span *(1000000)/2) /nDeltaFreqPerPoint;
\r
3356 pPsdScan->nPSDStartPoint = nStartP - pPsdScan->nPSDStartBase;
\r
3357 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), Start PSD Poin Matrix Index = %d\n", pPsdScan->nPSDStartPoint);
\r
3359 nStopP = pPsdScan->nPSDStartBase + (nPSDCenterFreq + span *(1000000)/2) /nDeltaFreqPerPoint;
\r
3360 pPsdScan->nPSDStopPoint = nStopP - pPsdScan->nPSDStartBase-1;
\r
3361 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), Stop PSD Poin Matrix Index = %d\n",pPsdScan->nPSDStopPoint);
\r
3365 case 2: //set RF channel/BW/Mode
\r
3368 val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x88c);
\r
3369 val |= 0x00300000;
\r
3370 pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x88c,val);
\r
3373 val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x800);
\r
3374 val &= 0xfeffffff;
\r
3375 pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x800,val);
\r
3378 if (centFreq == 2484)
\r
3379 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff, 0xe); //WiFi TRx Mask on
\r
3381 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff, (centFreq-2412)/5 + 1); //WiFi TRx Mask on
\r
3383 //Set RF mode = Rx, RF Gain = 0x8a0
\r
3384 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x0, 0xfffff, 0x308a0);
\r
3386 //Set TRx mask off
\r
3387 //un-lock TRx Mask setup
\r
3388 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdd, 0x80, 0x1);
\r
3389 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdf, 0x1, 0x1);
\r
3391 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3396 memset(pPsdScan->nPSDReport,0, pPsdScan->nPSDPoint*sizeof(u4Byte));
\r
3397 nStartP = pPsdScan->nPSDStartPoint + pPsdScan->nPSDStartBase;
\r
3398 nStopP = pPsdScan->nPSDStopPoint + pPsdScan->nPSDStartBase + 1;
\r
3402 while (i < nStopP)
\r
3406 psd_report = halbtc8723b1ant_GetPSDData(pBtCoexist,i-nPoints);
\r
3410 psd_report = halbtc8723b1ant_GetPSDData(pBtCoexist,i);
\r
3413 if (psd_report == 0)
\r
3416 //tmp = 20*log10((double)psd_report);
\r
3417 //20*log2(x)/log2(10), log2Base return theresult of the psd_report*100
\r
3418 tmp = 6 * halbtc8723b1ant_Log2Base(pBtCoexist, psd_report);
\r
3421 n = i-pPsdScan->nPSDStartBase;
\r
3422 pPsdScan->nPSDReport[n] = tmp;
\r
3423 PsdRep1 = pPsdScan->nPSDReport[n] /100;
\r
3424 PsdRep2 = pPsdScan->nPSDReport[n] - PsdRep1 * 100;
\r
3426 freq = ((centFreq-20) * 1000000 + n * nDeltaFreqPerPoint);
\r
3427 freq1 = freq/1000000;
\r
3428 freq2 = freq/1000 - freq1 * 1000;
\r
3431 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), i = %d (%d.0%d MHz)", n, freq1, freq2);
\r
3433 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), i = %d (%d.%d MHz)", n, freq1, freq2);
\r
3436 DbgPrint(", PSDReport = %d (%d.0%d dB)\n",psd_report, PsdRep1, PsdRep2);
\r
3438 DbgPrint(", PSDReport = %d (%d.%d dB)\n",psd_report, PsdRep1,PsdRep2);
\r
3444 //Add Delay between PSD point
\r
3451 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint()==============\n");
\r
3460 case 100: //recovery
\r
3463 val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x88c);
\r
3465 pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x88c,val);
\r
3468 val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x800);
\r
3469 val |= 0x01000000;
\r
3470 pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x800,val);
\r
3473 val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x808);
\r
3475 pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x808,val);
\r
3478 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdd, 0x80, 0x0);
\r
3479 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdf, 0x1, 0x0);
\r
3481 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780);
\r
3488 }while (!outloop);
\r
3492 pPsdScan->bIsPSDRunning = FALSE;
\r
3498 halbtc8723b1ant_AntennaDetection(
\r
3499 IN PBTC_COEXIST pBtCoexist,
\r
3500 IN u4Byte centFreq,
\r
3506 u4Byte realseconds = 0, i=0, i_max=0, val_max=0, j;
\r
3509 pBtCoexist->bStopCoexDm = TRUE;
\r
3511 //Set Antenna path, switch WiFi to un-certain antenna port
\r
3512 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, FALSE);
\r
3514 //Mailbox handshake
\r
3515 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, 0x0);
\r
3516 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), Set BT LE Tx\n");
\r
3519 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), \n");
\r
3520 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), \n");
\r
3521 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), \n");
\r
3528 halbtc8723b1ant_SweepPSDPoint(pBtCoexist, centFreq, offset,span, BT_8723B_1ANT_ANTDET_PSD_POINTS, BT_8723B_1ANT_ANTDET_PSD_AVGNUM);
\r
3530 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), PSDGenCount = %d\n ", pPsdScan->nPSDGenCount);
\r
3532 if (pPsdScan->nPSDGenCount == 0)
\r
3534 memcpy(pPsdScan->nPSDReport_MaxHold, pPsdScan->nPSDReport, BT_8723B_1ANT_ANTDET_PSD_POINTS*sizeof(u4Byte));
\r
3536 for (i= pPsdScan->nPSDStartPoint; i<=pPsdScan->nPSDStopPoint; i++)
\r
3538 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), Max_Hold i = %d, PSDReport = %d dB\n", i, pPsdScan->nPSDReport_MaxHold[i]);
\r
3543 for (i= pPsdScan->nPSDStartPoint; i<=pPsdScan->nPSDStopPoint; i++)
\r
3545 if (pPsdScan->nPSDReport[i] > pPsdScan->nPSDReport_MaxHold[i])
\r
3546 pPsdScan->nPSDReport_MaxHold[i] = pPsdScan->nPSDReport[i];
\r
3548 //search Max Value
\r
3549 if (i ==pPsdScan->nPSDStartPoint )
\r
3552 val_max = pPsdScan->nPSDReport_MaxHold[i];
\r
3556 if (pPsdScan->nPSDReport_MaxHold[i] > val_max)
\r
3559 val_max = pPsdScan->nPSDReport_MaxHold[i];
\r
3563 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), Max_Hold i = %d, PSDReport = %d dB\n", i, pPsdScan->nPSDReport_MaxHold[i]);
\r
3567 pPsdScan->nPSDMaxValuePoint = i_max;
\r
3568 pPsdScan->nPSDMaxValue = val_max;
\r
3570 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), Max_Hold i_Max = %d, PSDReport_Max = %d dB, TotalCnt = %d\n", pPsdScan->nPSDMaxValuePoint
\r
3571 ,pPsdScan->nPSDMaxValue, pPsdScan->nPSDGenTotalCount);
\r
3574 if (pPsdScan->nPSDGenCount+1 <= pPsdScan->realseconds)
\r
3576 pPsdScan->nPSDGenCount++;
\r
3577 pPsdScan->nPSDGenTotalCount++;
\r
3585 //Set Antenna Path
\r
3586 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE);
\r
3589 pBtCoexist->bStopCoexDm = FALSE;
\r
3594 //============================================================
\r
3595 // work around function start with wa_halbtc8723b1ant_
\r
3596 //============================================================
\r
3597 //============================================================
\r
3598 // extern function start with EXhalbtc8723b1ant_
\r
3599 //============================================================
\r
3601 EXhalbtc8723b1ant_PowerOnSetting(
\r
3602 IN PBTC_COEXIST pBtCoexist
\r
3605 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
3609 pBtCoexist->bStopCoexDm = TRUE;
\r
3611 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20);
\r
3613 // enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly.
\r
3614 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
\r
3615 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1);
\r
3617 // set GRAN_BT = 1
\r
3618 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
\r
3619 // set WLAN_ACT = 0
\r
3620 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
3623 // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info)
\r
3624 // Local setting bit define
\r
3625 // BIT0: "0" for no antenna inverse; "1" for antenna inverse
\r
3626 // BIT1: "0" for internal switch; "1" for external switch
\r
3627 // BIT2: "0" for one antenna; "1" for two antenna
\r
3628 // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0
\r
3629 if(pBtCoexist->chipInterface == BTC_INTF_USB)
\r
3631 // fixed at S0 for USB interface
\r
3632 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
\r
3634 u1Tmp |= 0x1; // antenna inverse
\r
3635 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);
\r
3637 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
\r
3641 // for PCIE and SDIO interface, we check efuse 0xc3[6]
\r
3642 if(pBoardInfo->singleAntPath == 0)
\r
3645 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
\r
3646 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
\r
3648 else if(pBoardInfo->singleAntPath == 1)
\r
3651 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
\r
3652 u1Tmp |= 0x1; // antenna inverse
\r
3653 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
\r
3656 if(pBtCoexist->chipInterface == BTC_INTF_PCI)
\r
3658 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp);
\r
3660 else if(pBtCoexist->chipInterface == BTC_INTF_SDIO)
\r
3662 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp);
\r
3668 EXhalbtc8723b1ant_PreLoadFirmware(
\r
3669 IN PBTC_COEXIST pBtCoexist
\r
3675 EXhalbtc8723b1ant_InitHwConfig(
\r
3676 IN PBTC_COEXIST pBtCoexist,
\r
3677 IN BOOLEAN bWifiOnly
\r
3680 halbtc8723b1ant_InitHwConfig(pBtCoexist, TRUE, bWifiOnly);
\r
3681 pBtCoexist->bStopCoexDm = FALSE;
\r
3685 EXhalbtc8723b1ant_InitCoexDm(
\r
3686 IN PBTC_COEXIST pBtCoexist
\r
3689 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
3691 pBtCoexist->bStopCoexDm = FALSE;
\r
3693 halbtc8723b1ant_InitCoexDm(pBtCoexist);
\r
3695 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
3699 EXhalbtc8723b1ant_DisplayCoexInfo(
\r
3700 IN PBTC_COEXIST pBtCoexist
\r
3703 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
3704 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
3705 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
3706 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
3707 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
3710 u4Byte faOfdm, faCck;
\r
3711 u4Byte fwVer=0, btPatchVer=0;
\r
3712 static u1Byte PopReportIn10s = 0;
\r
3714 if (pPsdScan->bIsAntDetEnable == TRUE)
\r
3716 halbtc8723b1ant_ShowPSDData(pBtCoexist);
\r
3720 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
3721 CL_PRINTF(cliBuf);
\r
3723 if(pBtCoexist->bManualControl)
\r
3725 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
\r
3726 CL_PRINTF(cliBuf);
\r
3727 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
3728 CL_PRINTF(cliBuf);
\r
3730 if(pBtCoexist->bStopCoexDm)
\r
3732 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");
\r
3733 CL_PRINTF(cliBuf);
\r
3734 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
3735 CL_PRINTF(cliBuf);
\r
3738 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Ant Mech/ Ant Pos:", \
\r
3739 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos);
\r
3740 CL_PRINTF(cliBuf);
\r
3742 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
3743 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
3744 CL_PRINTF(cliBuf);
\r
3746 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
3747 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
3748 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
\r
3749 GLCoexVerDate8723b1Ant, GLCoexVer8723b1Ant, fwVer, btPatchVer, btPatchVer);
\r
3750 CL_PRINTF(cliBuf);
\r
3752 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \
\r
3753 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
\r
3754 pCoexDm->wifiChnlInfo[2]);
\r
3755 CL_PRINTF(cliBuf);
\r
3756 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s", "Wifi bHi-Pri/ CCK lock/ CCK ever-lock", \
\r
3757 (pCoexSta->bWiFiIsHighPriTask? "Yes":"No"),
\r
3758 (pCoexSta->bCCKLock? "Yes":"No"),
\r
3759 (pCoexSta->bCCKEverLock? "Yes":"No"));
\r
3760 CL_PRINTF(cliBuf);
\r
3763 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
\r
3764 CL_PRINTF(cliBuf);
\r
3765 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
\r
3767 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
\r
3768 CL_PRINTF(cliBuf);
\r
3771 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d/ %d] ", "BT [status/ rssi/ retryCnt/ popCnt]", \
\r
3772 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
\r
3773 ( (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
\r
3774 pCoexSta->btRssi, pCoexSta->btRetryCnt, pCoexSta->popEventCnt);
\r
3775 CL_PRINTF(cliBuf);
\r
3777 if (PopReportIn10s >= 5)
\r
3779 pCoexSta->popEventCnt = 0;
\r
3780 PopReportIn10s = 0;
\r
3783 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d / %d", "SCO/HID/PAN/A2DP/Hi-Pri", \
\r
3784 pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist, pBtLinkInfo->bBtHiPriLinkExist);
\r
3785 CL_PRINTF(cliBuf);
\r
3787 if (pStackInfo->bProfileNotified)
\r
3789 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
3793 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \
\r
3794 (pBtLinkInfo->bSlaveRole )? "Slave":"Master");
\r
3795 CL_PRINTF(cliBuf);
\r
3798 btInfoExt = pCoexSta->btInfoExt;
\r
3799 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
\r
3800 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
\r
3801 CL_PRINTF(cliBuf);
\r
3803 for(i=0; i<BT_INFO_SRC_8723B_1ANT_MAX; i++)
\r
3805 if(pCoexSta->btInfoC2hCnt[i])
\r
3807 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b1Ant[i], \
\r
3808 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
\r
3809 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
\r
3810 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
\r
3811 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
\r
3812 CL_PRINTF(cliBuf);
\r
3816 if(!pBtCoexist->bManualControl)
\r
3819 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
3820 CL_PRINTF(cliBuf);
\r
3822 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "SM[LowPenaltyRA]", \
\r
3823 pCoexDm->bCurLowPenaltyRa);
\r
3824 CL_PRINTF(cliBuf);
\r
3826 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \
\r
3827 (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"),
\r
3828 pBtCoexist->btInfo.aggBufSize);
\r
3829 CL_PRINTF(cliBuf);
\r
3830 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \
\r
3831 pBtCoexist->btInfo.raMask);
\r
3832 CL_PRINTF(cliBuf);
\r
3835 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
3836 CL_PRINTF(cliBuf);
\r
3838 psTdmaCase = pCoexDm->curPsTdma;
\r
3839 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
\r
3840 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
\r
3841 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
\r
3842 pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
\r
3843 CL_PRINTF(cliBuf);
\r
3845 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", \
\r
3846 pCoexSta->nCoexTableType);
\r
3847 CL_PRINTF(cliBuf);
\r
3849 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "IgnWlanAct", \
\r
3850 pCoexDm->bCurIgnoreWlanAct);
\r
3851 CL_PRINTF(cliBuf);
\r
3854 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
\r
3855 pCoexDm->errorCondition);
\r
3856 CL_PRINTF(cliBuf);
\r
3861 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
3862 CL_PRINTF(cliBuf);
\r
3864 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", \
\r
3865 pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime);
\r
3866 CL_PRINTF(cliBuf);
\r
3868 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
\r
3869 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
\r
3870 u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
\r
3871 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
\r
3872 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \
\r
3873 u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]);
\r
3874 CL_PRINTF(cliBuf);
\r
3876 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
\r
3877 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc);
\r
3878 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
\r
3879 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x6cc/0x880[29:25]", \
\r
3880 u1Tmp[0], u4Tmp[0], (u4Tmp[1]&0x3e000000) >> 25);
\r
3881 CL_PRINTF(cliBuf);
\r
3883 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
\r
3884 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
\r
3885 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x764);
\r
3886 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);
\r
3887 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x764 / 0x76e", \
\r
3888 u4Tmp[0], ((u1Tmp[0]&0x20)>> 5), (u4Tmp[1] & 0xffff), u1Tmp[1]);
\r
3889 CL_PRINTF(cliBuf);
\r
3891 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c);
\r
3892 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
\r
3893 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944);
\r
3894 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
3895 u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3);
\r
3896 CL_PRINTF(cliBuf);
\r
3898 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39);
\r
3899 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
3900 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
3901 u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64);
\r
3902 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
3903 ((u1Tmp[0] & 0x8)>>3), u1Tmp[1], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[2]&0x1);
\r
3904 CL_PRINTF(cliBuf);
\r
3906 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
\r
3907 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
\r
3908 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
\r
3909 u4Tmp[0], u1Tmp[0]);
\r
3910 CL_PRINTF(cliBuf);
\r
3912 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
3913 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c);
\r
3914 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
\r
3915 u4Tmp[0]&0xff, u1Tmp[0]);
\r
3916 CL_PRINTF(cliBuf);
\r
3918 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
\r
3919 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
\r
3920 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
\r
3921 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0);
\r
3923 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b);
\r
3924 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
\r
3926 faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \
\r
3927 ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ;
\r
3928 faCck = (u1Tmp[0] << 8) + u1Tmp[1];
\r
3930 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
\r
3931 u4Tmp[0]&0xffff, faOfdm, faCck);
\r
3932 CL_PRINTF(cliBuf);
\r
3935 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \
\r
3936 pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg);
\r
3937 CL_PRINTF(cliBuf);
\r
3939 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \
\r
3940 pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg);
\r
3941 CL_PRINTF(cliBuf);
\r
3943 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
\r
3944 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
3945 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
3946 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", \
\r
3947 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
\r
3948 CL_PRINTF(cliBuf);
\r
3950 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \
\r
3951 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
\r
3952 CL_PRINTF(cliBuf);
\r
3953 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \
\r
3954 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
\r
3955 CL_PRINTF(cliBuf);
\r
3956 #if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 1)
\r
3957 //halbtc8723b1ant_MonitorBtCtr(pBtCoexist);
\r
3959 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
3964 EXhalbtc8723b1ant_IpsNotify(
\r
3965 IN PBTC_COEXIST pBtCoexist,
\r
3971 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
3974 if(BTC_IPS_ENTER == type)
\r
3976 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
\r
3977 pCoexSta->bUnderIps = TRUE;
\r
3979 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
3980 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE);
\r
3981 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
3982 //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF);
\r
3984 else if(BTC_IPS_LEAVE == type)
\r
3986 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
\r
3988 halbtc8723b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE);
\r
3989 halbtc8723b1ant_InitCoexDm(pBtCoexist);
\r
3990 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
3992 pCoexSta->bUnderIps = FALSE;
\r
3997 EXhalbtc8723b1ant_LpsNotify(
\r
3998 IN PBTC_COEXIST pBtCoexist,
\r
4002 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
4005 if(BTC_LPS_ENABLE == type)
\r
4007 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
\r
4008 pCoexSta->bUnderLps = TRUE;
\r
4010 else if(BTC_LPS_DISABLE == type)
\r
4012 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
\r
4013 pCoexSta->bUnderLps = FALSE;
\r
4018 EXhalbtc8723b1ant_ScanNotify(
\r
4019 IN PBTC_COEXIST pBtCoexist,
\r
4023 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
4024 u4Byte wifiLinkStatus=0;
\r
4025 u4Byte numOfWifiLink=0;
\r
4026 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
4027 u1Byte aggBufSize=5;
\r
4029 u1Byte u1Tmpa, u1Tmpb;
\r
4032 if(pBtCoexist->bManualControl ||
\r
4033 pBtCoexist->bStopCoexDm )
\r
4036 if(BTC_SCAN_START == type)
\r
4038 pCoexSta->bWiFiIsHighPriTask = TRUE;
\r
4039 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
\r
4041 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue
\r
4042 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE);
\r
4043 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
\r
4044 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
\r
4045 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
\r
4048 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n",
\r
4049 u4Tmp, u1Tmpa, u1Tmpb));
\r
4053 pCoexSta->bWiFiIsHighPriTask = FALSE;
\r
4054 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
\r
4056 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum);
\r
4059 if(pBtCoexist->btInfo.bBtDisabled)
\r
4062 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
4063 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
4065 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
4067 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
4068 numOfWifiLink = wifiLinkStatus>>16;
\r
4069 if(numOfWifiLink >= 2)
\r
4071 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
4072 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
4073 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
\r
4077 if(pCoexSta->bC2hBtInquiryPage)
\r
4079 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
\r
4084 halbtc8723b1ant_ActionHs(pBtCoexist);
\r
4088 if(BTC_SCAN_START == type)
\r
4090 //BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
\r
4091 if(!bWifiConnected) // non-connected scan
\r
4093 halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist);
\r
4095 else // wifi is connected
\r
4097 halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist);
\r
4100 else if(BTC_SCAN_FINISH == type)
\r
4102 //BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
\r
4103 if(!bWifiConnected) // non-connected scan
\r
4105 halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist);
\r
4109 halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
\r
4115 EXhalbtc8723b1ant_ConnectNotify(
\r
4116 IN PBTC_COEXIST pBtCoexist,
\r
4120 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
4121 u4Byte wifiLinkStatus=0;
\r
4122 u4Byte numOfWifiLink=0;
\r
4123 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
4124 u1Byte aggBufSize=5;
\r
4126 if(pBtCoexist->bManualControl ||
\r
4127 pBtCoexist->bStopCoexDm ||
\r
4128 pBtCoexist->btInfo.bBtDisabled )
\r
4131 if(BTC_ASSOCIATE_START == type)
\r
4133 pCoexSta->bWiFiIsHighPriTask = TRUE;
\r
4134 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue
\r
4135 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE);
\r
4136 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
\r
4137 pCoexDm->nArpCnt = 0;
\r
4141 pCoexSta->bWiFiIsHighPriTask = FALSE;
\r
4142 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
\r
4143 //pCoexDm->nArpCnt = 0;
\r
4146 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
4147 numOfWifiLink = wifiLinkStatus>>16;
\r
4148 if(numOfWifiLink >= 2)
\r
4150 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
4151 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
4152 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
\r
4156 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
4157 if(pCoexSta->bC2hBtInquiryPage)
\r
4159 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
\r
4164 halbtc8723b1ant_ActionHs(pBtCoexist);
\r
4168 if(BTC_ASSOCIATE_START == type)
\r
4170 //BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
\r
4171 halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);
\r
4173 else if(BTC_ASSOCIATE_FINISH == type)
\r
4175 //BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
\r
4177 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
4178 if(!bWifiConnected) // non-connected scan
\r
4180 halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist);
\r
4184 halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
\r
4190 EXhalbtc8723b1ant_MediaStatusNotify(
\r
4191 IN PBTC_COEXIST pBtCoexist,
\r
4195 u1Byte H2C_Parameter[3] ={0};
\r
4197 u1Byte wifiCentralChnl;
\r
4198 BOOLEAN bWifiUnderBMode = FALSE;
\r
4200 if(pBtCoexist->bManualControl ||
\r
4201 pBtCoexist->bStopCoexDm ||
\r
4202 pBtCoexist->btInfo.bBtDisabled )
\r
4205 if(BTC_MEDIA_CONNECT == type)
\r
4207 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
\r
4208 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue
\r
4209 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE);
\r
4210 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
\r
4212 //Set CCK Tx/Rx high Pri except 11b mode
\r
4213 if (bWifiUnderBMode)
\r
4215 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); //CCK Tx
\r
4216 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x00); //CCK Rx
\r
4220 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10); //CCK Tx
\r
4221 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); //CCK Rx
\r
4224 pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
\r
4225 pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
\r
4226 pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
\r
4227 pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
\r
4231 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
\r
4232 pCoexDm->nArpCnt = 0;
\r
4234 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x0); //CCK Tx
\r
4235 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x0); //CCK Rx
\r
4237 pCoexSta->bCCKEverLock = FALSE;
\r
4240 // only 2.4G we need to inform bt the chnl mask
\r
4241 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
\r
4242 if( (BTC_MEDIA_CONNECT == type) &&
\r
4243 (wifiCentralChnl <= 14) )
\r
4245 //H2C_Parameter[0] = 0x1;
\r
4246 H2C_Parameter[0] = 0x0;
\r
4247 H2C_Parameter[1] = wifiCentralChnl;
\r
4248 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
4249 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
4250 H2C_Parameter[2] = 0x30;
\r
4252 H2C_Parameter[2] = 0x20;
\r
4255 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
\r
4256 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
\r
4257 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
\r
4259 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x66=0x%x\n",
\r
4260 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
\r
4262 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
\r
4266 EXhalbtc8723b1ant_SpecialPacketNotify(
\r
4267 IN PBTC_COEXIST pBtCoexist,
\r
4271 BOOLEAN bBtHsOn=FALSE;
\r
4272 u4Byte wifiLinkStatus=0;
\r
4273 u4Byte numOfWifiLink=0;
\r
4274 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
4275 u1Byte aggBufSize=5;
\r
4277 if(pBtCoexist->bManualControl ||
\r
4278 pBtCoexist->bStopCoexDm ||
\r
4279 pBtCoexist->btInfo.bBtDisabled )
\r
4282 if( BTC_PACKET_DHCP == type ||
\r
4283 BTC_PACKET_EAPOL == type ||
\r
4284 BTC_PACKET_ARP == type )
\r
4286 if (BTC_PACKET_ARP == type)
\r
4288 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet ARP notify\n"));
\r
4290 pCoexDm->nArpCnt++;
\r
4291 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt));
\r
4293 if(pCoexDm->nArpCnt >= 10) // if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist)
\r
4295 pCoexSta->bWiFiIsHighPriTask = FALSE;
\r
4299 pCoexSta->bWiFiIsHighPriTask = TRUE;
\r
4304 pCoexSta->bWiFiIsHighPriTask = TRUE;
\r
4305 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet DHCP or EAPOL notify\n"));
\r
4310 pCoexSta->bWiFiIsHighPriTask = FALSE;
\r
4311 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet [Type = %d] notify\n", type));
\r
4314 pCoexSta->specialPktPeriodCnt = 0;
\r
4316 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
4317 numOfWifiLink = wifiLinkStatus>>16;
\r
4318 if(numOfWifiLink >= 2)
\r
4320 halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
\r
4321 halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);
\r
4322 halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist);
\r
4326 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
4327 if(pCoexSta->bC2hBtInquiryPage)
\r
4329 halbtc8723b1ant_ActionBtInquiry(pBtCoexist);
\r
4334 halbtc8723b1ant_ActionHs(pBtCoexist);
\r
4338 if( BTC_PACKET_DHCP == type ||
\r
4339 BTC_PACKET_EAPOL == type ||
\r
4340 ( (BTC_PACKET_ARP == type ) && (pCoexSta->bWiFiIsHighPriTask) ) )
\r
4342 halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
4347 EXhalbtc8723b1ant_BtInfoNotify(
\r
4348 IN PBTC_COEXIST pBtCoexist,
\r
4349 IN pu1Byte tmpBuf,
\r
4353 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
4355 u1Byte i, rspSource=0;
\r
4356 BOOLEAN bWifiConnected=FALSE;
\r
4357 BOOLEAN bBtBusy=FALSE;
\r
4359 pCoexSta->bC2hBtInfoReqSent = FALSE;
\r
4361 rspSource = tmpBuf[0]&0xf;
\r
4362 if(rspSource >= BT_INFO_SRC_8723B_1ANT_MAX)
\r
4363 rspSource = BT_INFO_SRC_8723B_1ANT_WIFI_FW;
\r
4364 pCoexSta->btInfoC2hCnt[rspSource]++;
\r
4366 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
\r
4367 for(i=0; i<length; i++)
\r
4369 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
\r
4371 btInfo = tmpBuf[i];
\r
4374 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
\r
4378 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
\r
4382 // if 0xff, it means BT is under WHCK test
\r
4383 if (btInfo == 0xff)
\r
4384 pCoexSta->bBtWhckTest = TRUE;
\r
4386 pCoexSta->bBtWhckTest = FALSE;
\r
4388 if(BT_INFO_SRC_8723B_1ANT_WIFI_FW != rspSource)
\r
4390 pCoexSta->btRetryCnt = // [3:0]
\r
4391 pCoexSta->btInfoC2h[rspSource][2]&0xf;
\r
4393 if (pCoexSta->btRetryCnt >= 1)
\r
4394 pCoexSta->popEventCnt++;
\r
4396 if (pCoexSta->btInfoC2h[rspSource][2]&0x20)
\r
4397 pCoexSta->bC2hBtPage = TRUE;
\r
4399 pCoexSta->bC2hBtPage = FALSE;
\r
4401 pCoexSta->btRssi =
\r
4402 pCoexSta->btInfoC2h[rspSource][3]*2-90;
\r
4403 //pCoexSta->btInfoC2h[rspSource][3]*2+10;
\r
4405 pCoexSta->btInfoExt =
\r
4406 pCoexSta->btInfoC2h[rspSource][4];
\r
4408 pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
\r
4409 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
\r
4410 if(!pCoexSta->bBtTxRxMask)
\r
4412 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */
\r
4413 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n"));
\r
4414 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15);
\r
4417 // Here we need to resend some wifi info to BT
\r
4418 // because bt is reset and loss of the info.
\r
4419 if(pCoexSta->btInfoExt & BIT1)
\r
4421 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
\r
4422 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
4423 if(bWifiConnected)
\r
4425 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
\r
4429 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
4433 if(pCoexSta->btInfoExt & BIT3)
\r
4435 if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm)
\r
4437 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
\r
4438 halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
4443 // BT already NOT ignore Wlan active, do nothing here.
\r
4445 #if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0)
\r
4446 if( (pCoexSta->btInfoExt & BIT4) )
\r
4448 // BT auto report already enabled, do nothing
\r
4452 halbtc8723b1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);
\r
4457 // check BIT2 first ==> check if bt is under inquiry or page scan
\r
4458 if(btInfo & BT_INFO_8723B_1ANT_B_INQ_PAGE)
\r
4459 pCoexSta->bC2hBtInquiryPage = TRUE;
\r
4461 pCoexSta->bC2hBtInquiryPage = FALSE;
\r
4463 // set link exist status
\r
4464 if(!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION))
\r
4466 pCoexSta->bBtLinkExist = FALSE;
\r
4467 pCoexSta->bPanExist = FALSE;
\r
4468 pCoexSta->bA2dpExist = FALSE;
\r
4469 pCoexSta->bHidExist = FALSE;
\r
4470 pCoexSta->bScoExist = FALSE;
\r
4472 pCoexSta->bBtHiPriLinkExist = FALSE;
\r
4474 else // connection exists
\r
4476 pCoexSta->bBtLinkExist = TRUE;
\r
4477 if(btInfo & BT_INFO_8723B_1ANT_B_FTP)
\r
4478 pCoexSta->bPanExist = TRUE;
\r
4480 pCoexSta->bPanExist = FALSE;
\r
4481 if(btInfo & BT_INFO_8723B_1ANT_B_A2DP)
\r
4482 pCoexSta->bA2dpExist = TRUE;
\r
4484 pCoexSta->bA2dpExist = FALSE;
\r
4485 if(btInfo & BT_INFO_8723B_1ANT_B_HID)
\r
4486 pCoexSta->bHidExist = TRUE;
\r
4488 pCoexSta->bHidExist = FALSE;
\r
4489 if(btInfo & BT_INFO_8723B_1ANT_B_SCO_ESCO)
\r
4490 pCoexSta->bScoExist = TRUE;
\r
4492 pCoexSta->bScoExist = FALSE;
\r
4494 if ( (pCoexSta->bHidExist == FALSE) && (pCoexSta->bC2hBtInquiryPage == FALSE) )
\r
4496 if (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160)
\r
4497 pCoexSta->bHidExist = TRUE;
\r
4500 //Add Hi-Pri Tx/Rx counter to avoid false detection
\r
4501 if ( ( (pCoexSta->bHidExist) || (pCoexSta->bScoExist) ) && (pCoexSta->highPriorityTx > 60) && (pCoexSta->highPriorityRx > 60)
\r
4502 && (!pCoexSta->bC2hBtInquiryPage))
\r
4503 pCoexSta->bBtHiPriLinkExist = TRUE;
\r
4506 halbtc8723b1ant_UpdateBtLinkInfo(pBtCoexist);
\r
4508 btInfo = btInfo & 0x1f; //mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41)
\r
4510 if(!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION))
\r
4512 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
\r
4513 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
\r
4515 else if(btInfo == BT_INFO_8723B_1ANT_B_CONNECTION) // connection exists but no busy
\r
4517 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE;
\r
4518 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
\r
4520 else if((btInfo&BT_INFO_8723B_1ANT_B_SCO_ESCO) ||
\r
4521 (btInfo&BT_INFO_8723B_1ANT_B_SCO_BUSY))
\r
4523 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_SCO_BUSY;
\r
4524 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
\r
4526 else if(btInfo&BT_INFO_8723B_1ANT_B_ACL_BUSY)
\r
4528 if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
\r
4529 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
4530 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_ACL_BUSY;
\r
4531 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
\r
4535 pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_MAX;
\r
4536 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
\r
4539 if( (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
4540 (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
4541 (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
4545 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
4547 halbtc8723b1ant_RunCoexistMechanism(pBtCoexist);
\r
4551 EXhalbtc8723b1ant_RfStatusNotify(
\r
4552 IN PBTC_COEXIST pBtCoexist,
\r
4557 u1Byte u1Tmpa,u1Tmpb, u1Tmpc;
\r
4559 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], RF Status notify\n"));
\r
4561 if(BTC_RF_ON == type)
\r
4563 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], RF is turned ON!!\n"));
\r
4564 pBtCoexist->bStopCoexDm = FALSE;
\r
4566 else if(BTC_RF_OFF == type)
\r
4568 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], RF is turned OFF!!\n"));
\r
4570 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
4571 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
\r
4572 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE);
\r
4573 //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF);
\r
4575 halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
4576 pBtCoexist->bStopCoexDm = TRUE;
\r
4578 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
\r
4579 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
\r
4580 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
\r
4581 u1Tmpc = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);
\r
4584 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x, 0x76e=0x%x\n",
\r
4585 u4Tmp, u1Tmpa, u1Tmpb, u1Tmpc));
\r
4591 EXhalbtc8723b1ant_HaltNotify(
\r
4592 IN PBTC_COEXIST pBtCoexist
\r
4597 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
\r
4599 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
4600 halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
\r
4601 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE);
\r
4602 //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF);
\r
4604 halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
4606 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
4608 pBtCoexist->bStopCoexDm = TRUE;
\r
4612 EXhalbtc8723b1ant_PnpNotify(
\r
4613 IN PBTC_COEXIST pBtCoexist,
\r
4614 IN u1Byte pnpState
\r
4617 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
\r
4619 if(BTC_WIFI_PNP_SLEEP == pnpState)
\r
4621 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to SLEEP\n"));
\r
4623 halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
4624 halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
4625 halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE);
\r
4626 halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
4627 //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF);
\r
4629 pBtCoexist->bStopCoexDm = TRUE;
\r
4631 else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
\r
4633 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to WAKE UP\n"));
\r
4634 pBtCoexist->bStopCoexDm = FALSE;
\r
4635 halbtc8723b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE);
\r
4636 halbtc8723b1ant_InitCoexDm(pBtCoexist);
\r
4637 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
4642 EXhalbtc8723b1ant_CoexDmReset(
\r
4643 IN PBTC_COEXIST pBtCoexist
\r
4646 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], *****************Coex DM Reset*****************\n"));
\r
4648 halbtc8723b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE);
\r
4649 //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
4650 //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x2, 0xfffff, 0x0);
\r
4651 halbtc8723b1ant_InitCoexDm(pBtCoexist);
\r
4655 EXhalbtc8723b1ant_Periodical(
\r
4656 IN PBTC_COEXIST pBtCoexist
\r
4659 static u1Byte disVerInfoCnt=0;
\r
4660 u4Byte fwVer=0, btPatchVer=0;
\r
4661 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
4662 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
4664 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical===========================\n"));
\r
4666 if(disVerInfoCnt <= 5)
\r
4668 disVerInfoCnt += 1;
\r
4669 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
4670 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", \
\r
4671 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));
\r
4672 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", \
\r
4673 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
\r
4674 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
4675 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
4676 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
\r
4677 GLCoexVerDate8723b1Ant, GLCoexVer8723b1Ant, fwVer, btPatchVer, btPatchVer));
\r
4678 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
4681 #if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0)
\r
4682 halbtc8723b1ant_QueryBtInfo(pBtCoexist);
\r
4683 halbtc8723b1ant_MonitorBtEnableDisable(pBtCoexist);
\r
4685 halbtc8723b1ant_MonitorBtCtr(pBtCoexist);
\r
4686 halbtc8723b1ant_MonitorWiFiCtr(pBtCoexist);
\r
4688 if( halbtc8723b1ant_IsWifiStatusChanged(pBtCoexist) ||
\r
4689 pCoexDm->bAutoTdmaAdjust )
\r
4692 halbtc8723b1ant_RunCoexistMechanism(pBtCoexist);
\r
4695 pCoexSta->specialPktPeriodCnt++;
\r
4698 if (pPsdScan->bIsAntDetEnable)
\r
4700 if (pPsdScan->nPSDGenCount > pPsdScan->realseconds)
\r
4701 pPsdScan->nPSDGenCount = 0;
\r
4703 halbtc8723b1ant_AntennaDetection(pBtCoexist, pPsdScan->realcentFreq, pPsdScan->realoffset, pPsdScan->realspan, pPsdScan->realseconds);
\r
4704 pPsdScan->nPSDGenTotalCount +=2;
\r
4705 pPsdScan->nPSDGenCount += 2;
\r
4712 EXhalbtc8723b1ant_AntennaDetection(
\r
4713 IN PBTC_COEXIST pBtCoexist,
\r
4714 IN u4Byte centFreq,
\r
4720 pPsdScan->bIsAntDetEnable = FALSE;
\r
4722 //do antenna detection periodically (every 2 seconds)
\r
4723 if (centFreq == 0)
\r
4730 pPsdScan->realcentFreq = ((centFreq & 0xf000) >> 12) * 1000 + ((centFreq & 0xf00) >> 8) * 100 +
\r
4731 ((centFreq & 0xf0) >> 4) * 10 + (centFreq & 0xf);
\r
4732 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), real freq = %d\n", pPsdScan->realcentFreq);
\r
4735 pPsdScan->realoffset =( (offset & 0x70) >> 4) * 10 + (offset & 0xf);
\r
4736 if (offset & 0x80)
\r
4737 pPsdScan->realoffset = 0 - pPsdScan->realoffset;
\r
4738 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), real offst = %d\n", pPsdScan->realoffset);
\r
4741 pPsdScan->bIsPSDShowMaxOnly = TRUE;
\r
4743 pPsdScan->bIsPSDShowMaxOnly = FALSE;
\r
4744 pPsdScan->realspan = ((span & 0x70) >> 4) * 10 + (span & 0xf);
\r
4745 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), real span = %d\n", pPsdScan->realspan);
\r
4747 if ( (pPsdScan->realcentFreq < 2412) || ( (pPsdScan->realcentFreq > 2472) && (pPsdScan->realcentFreq != 2484) ) )
\r
4749 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), center freq is not valid!!\n");
\r
4753 else if ( ( (pPsdScan->realcentFreq - 2412) % 5 != 0 ) && (pPsdScan->realcentFreq != 2484) )
\r
4755 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), center freq is not valid!!\n");
\r
4759 if ( (pPsdScan->realoffset > 20) || (pPsdScan->realoffset < -20) )
\r
4761 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), freq offset is not valid!!\n");
\r
4765 if (pPsdScan->realspan > 40)
\r
4767 DbgPrint("xxxxxxxxxxxxxxxx SweepPSDPoint(), freq span is not valid!!\n");
\r
4771 pPsdScan->realseconds =( (seconds & 0xf0) >> 4) * 10 + (seconds & 0xf);
\r
4772 pPsdScan->nPSDGenCount = 0;
\r
4773 pPsdScan->nPSDGenTotalCount= 0;
\r
4777 pPsdScan->bIsAntDetEnable = TRUE;
\r
4780 halbtc8723b1ant_AntennaDetection(pBtCoexist, pPsdScan->realcentFreq, pPsdScan->realoffset, pPsdScan->realspan, pPsdScan->realseconds);
\r
4787 EXhalbtc8723b1ant_AntennaIsolation(
\r
4788 IN PBTC_COEXIST pBtCoexist,
\r
4789 IN u4Byte centFreq,
\r
4800 EXhalbtc8723b1ant_PSDScan(
\r
4801 IN PBTC_COEXIST pBtCoexist,
\r
4802 IN u4Byte centFreq,
\r
4813 EXhalbtc8723b1ant_DisplayAntIsolation(
\r
4814 IN PBTC_COEXIST pBtCoexist
\r
4818 //halbtc8723b1ant_ShowPSDData(pBtCoexist);
\r