1 //============================================================
\r
4 // This file is for 8192e1ant 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_8192E_1ANT GLCoexDm8192e1Ant;
\r
20 static PCOEX_DM_8192E_1ANT pCoexDm=&GLCoexDm8192e1Ant;
\r
21 static COEX_STA_8192E_1ANT GLCoexSta8192e1Ant;
\r
22 static PCOEX_STA_8192E_1ANT pCoexSta=&GLCoexSta8192e1Ant;
\r
24 const char *const GLBtInfoSrc8192e1Ant[]={
\r
27 "BT Info[bt auto report]",
\r
30 u4Byte GLCoexVerDate8192e1Ant=20130729;
\r
31 u4Byte GLCoexVer8192e1Ant=0x10;
\r
33 //============================================================
\r
34 // local function proto type if needed
\r
35 //============================================================
\r
36 //============================================================
\r
37 // local function start with halbtc8192e1ant_
\r
38 //============================================================
\r
40 halbtc8192e1ant_BtRssiState(
\r
47 u1Byte btRssiState=pCoexSta->preBtRssiState;
\r
49 btRssi = pCoexSta->btRssi;
\r
53 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
54 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
56 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
\r
58 btRssiState = BTC_RSSI_STATE_HIGH;
\r
59 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
\r
63 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
64 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
\r
69 if(btRssi < rssiThresh)
\r
71 btRssiState = BTC_RSSI_STATE_LOW;
\r
72 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
\r
76 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
77 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
\r
81 else if(levelNum == 3)
\r
83 if(rssiThresh > rssiThresh1)
\r
85 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
\r
86 return pCoexSta->preBtRssiState;
\r
89 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
90 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
92 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
\r
94 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
95 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
\r
99 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
100 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
\r
103 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
\r
104 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
\r
106 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
\r
108 btRssiState = BTC_RSSI_STATE_HIGH;
\r
109 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
\r
111 else if(btRssi < rssiThresh)
\r
113 btRssiState = BTC_RSSI_STATE_LOW;
\r
114 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
\r
118 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
119 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
\r
124 if(btRssi < rssiThresh1)
\r
126 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
127 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
\r
131 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
132 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
\r
137 pCoexSta->preBtRssiState = btRssiState;
\r
139 return btRssiState;
\r
143 halbtc8192e1ant_WifiRssiState(
\r
144 IN PBTC_COEXIST pBtCoexist,
\r
146 IN u1Byte levelNum,
\r
147 IN u1Byte rssiThresh,
\r
148 IN u1Byte rssiThresh1
\r
152 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
\r
154 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
158 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
159 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
161 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
\r
163 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
164 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
168 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
169 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
174 if(wifiRssi < rssiThresh)
\r
176 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
177 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
181 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
182 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
186 else if(levelNum == 3)
\r
188 if(rssiThresh > rssiThresh1)
\r
190 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
\r
191 return pCoexSta->preWifiRssiState[index];
\r
194 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
195 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
197 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
\r
199 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
200 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
204 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
205 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
208 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
\r
209 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
\r
211 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
\r
213 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
214 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
216 else if(wifiRssi < rssiThresh)
\r
218 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
219 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
223 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
224 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
\r
229 if(wifiRssi < rssiThresh1)
\r
231 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
232 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
236 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
237 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
242 pCoexSta->preWifiRssiState[index] = wifiRssiState;
\r
244 return wifiRssiState;
\r
248 halbtc8192e1ant_UpdateRaMask(
\r
249 IN PBTC_COEXIST pBtCoexist,
\r
250 IN BOOLEAN bForceExec,
\r
255 if(BTC_RATE_DISABLE == type)
\r
257 pCoexDm->curRaMask |= rateMask; // disable rate
\r
259 else if(BTC_RATE_ENABLE == type)
\r
261 pCoexDm->curRaMask &= ~rateMask; // enable rate
\r
264 if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask))
\r
266 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask);
\r
268 pCoexDm->preRaMask = pCoexDm->curRaMask;
\r
272 halbtc8192e1ant_MonitorBtCtr(
\r
273 IN PBTC_COEXIST pBtCoexist
\r
276 u4Byte regHPTxRx, regLPTxRx, u4Tmp;
\r
277 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
\r
283 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
\r
284 regHPTx = u4Tmp & bMaskLWord;
\r
285 regHPRx = (u4Tmp & bMaskHWord)>>16;
\r
287 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
\r
288 regLPTx = u4Tmp & bMaskLWord;
\r
289 regLPRx = (u4Tmp & bMaskHWord)>>16;
\r
291 pCoexSta->highPriorityTx = regHPTx;
\r
292 pCoexSta->highPriorityRx = regHPRx;
\r
293 pCoexSta->lowPriorityTx = regLPTx;
\r
294 pCoexSta->lowPriorityRx = regLPRx;
\r
296 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
297 regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
\r
298 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
299 regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
\r
302 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
306 halbtc8192e1ant_QueryBtInfo(
\r
307 IN PBTC_COEXIST pBtCoexist
\r
310 u1Byte H2C_Parameter[1] ={0};
\r
312 pCoexSta->bC2hBtInfoReqSent = TRUE;
\r
314 H2C_Parameter[0] |= BIT0; // trigger
\r
316 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
\r
317 H2C_Parameter[0]));
\r
319 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
\r
323 halbtc8192e1ant_IsWifiStatusChanged(
\r
324 IN PBTC_COEXIST pBtCoexist
\r
327 static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;
\r
328 BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;
\r
329 BOOLEAN bWifiConnected=FALSE;
\r
331 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
332 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
333 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
334 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
338 if(bWifiBusy != bPreWifiBusy)
\r
340 bPreWifiBusy = bWifiBusy;
\r
343 if(bUnder4way != bPreUnder4way)
\r
345 bPreUnder4way = bUnder4way;
\r
348 if(bBtHsOn != bPreBtHsOn)
\r
350 bPreBtHsOn = bBtHsOn;
\r
359 halbtc8192e1ant_UpdateBtLinkInfo(
\r
360 IN PBTC_COEXIST pBtCoexist
\r
363 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
365 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
\r
366 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
\r
367 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
\r
368 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
\r
369 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
\r
371 // check if Sco only
\r
372 if( pBtLinkInfo->bScoExist &&
\r
373 !pBtLinkInfo->bA2dpExist &&
\r
374 !pBtLinkInfo->bPanExist &&
\r
375 !pBtLinkInfo->bHidExist )
\r
376 pBtLinkInfo->bScoOnly = TRUE;
\r
378 pBtLinkInfo->bScoOnly = FALSE;
\r
380 // check if A2dp only
\r
381 if( !pBtLinkInfo->bScoExist &&
\r
382 pBtLinkInfo->bA2dpExist &&
\r
383 !pBtLinkInfo->bPanExist &&
\r
384 !pBtLinkInfo->bHidExist )
\r
385 pBtLinkInfo->bA2dpOnly = TRUE;
\r
387 pBtLinkInfo->bA2dpOnly = FALSE;
\r
389 // check if Pan only
\r
390 if( !pBtLinkInfo->bScoExist &&
\r
391 !pBtLinkInfo->bA2dpExist &&
\r
392 pBtLinkInfo->bPanExist &&
\r
393 !pBtLinkInfo->bHidExist )
\r
394 pBtLinkInfo->bPanOnly = TRUE;
\r
396 pBtLinkInfo->bPanOnly = FALSE;
\r
398 // check if Hid only
\r
399 if( !pBtLinkInfo->bScoExist &&
\r
400 !pBtLinkInfo->bA2dpExist &&
\r
401 !pBtLinkInfo->bPanExist &&
\r
402 pBtLinkInfo->bHidExist )
\r
403 pBtLinkInfo->bHidOnly = TRUE;
\r
405 pBtLinkInfo->bHidOnly = FALSE;
\r
409 halbtc8192e1ant_ActionAlgorithm(
\r
410 IN PBTC_COEXIST pBtCoexist
\r
413 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
414 BOOLEAN bBtHsOn=FALSE;
\r
415 u1Byte algorithm=BT_8192E_1ANT_COEX_ALGO_UNDEFINED;
\r
416 u1Byte numOfDiffProfile=0;
\r
418 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
420 if(!pBtLinkInfo->bBtLinkExist)
\r
422 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n"));
\r
426 if(pBtLinkInfo->bScoExist)
\r
427 numOfDiffProfile++;
\r
428 if(pBtLinkInfo->bHidExist)
\r
429 numOfDiffProfile++;
\r
430 if(pBtLinkInfo->bPanExist)
\r
431 numOfDiffProfile++;
\r
432 if(pBtLinkInfo->bA2dpExist)
\r
433 numOfDiffProfile++;
\r
435 if(numOfDiffProfile == 1)
\r
437 if(pBtLinkInfo->bScoExist)
\r
439 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n"));
\r
440 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
\r
444 if(pBtLinkInfo->bHidExist)
\r
446 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
\r
447 algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
\r
449 else if(pBtLinkInfo->bA2dpExist)
\r
451 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
\r
452 algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP;
\r
454 else if(pBtLinkInfo->bPanExist)
\r
458 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
\r
459 algorithm = BT_8192E_1ANT_COEX_ALGO_PANHS;
\r
463 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
\r
464 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR;
\r
469 else if(numOfDiffProfile == 2)
\r
471 if(pBtLinkInfo->bScoExist)
\r
473 if(pBtLinkInfo->bHidExist)
\r
475 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n"));
\r
476 algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
\r
478 else if(pBtLinkInfo->bA2dpExist)
\r
480 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n"));
\r
481 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
\r
483 else if(pBtLinkInfo->bPanExist)
\r
487 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
\r
488 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
\r
492 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
\r
493 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
\r
499 if( pBtLinkInfo->bHidExist &&
\r
500 pBtLinkInfo->bA2dpExist )
\r
502 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
\r
503 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
\r
505 else if( pBtLinkInfo->bHidExist &&
\r
506 pBtLinkInfo->bPanExist )
\r
510 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
\r
511 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
\r
515 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
\r
516 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
\r
519 else if( pBtLinkInfo->bPanExist &&
\r
520 pBtLinkInfo->bA2dpExist )
\r
524 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
\r
525 algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS;
\r
529 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
\r
530 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP;
\r
535 else if(numOfDiffProfile == 3)
\r
537 if(pBtLinkInfo->bScoExist)
\r
539 if( pBtLinkInfo->bHidExist &&
\r
540 pBtLinkInfo->bA2dpExist )
\r
542 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP ==> HID\n"));
\r
543 algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
\r
545 else if( pBtLinkInfo->bHidExist &&
\r
546 pBtLinkInfo->bPanExist )
\r
550 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(HS)\n"));
\r
551 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
\r
555 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
\r
556 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
\r
559 else if( pBtLinkInfo->bPanExist &&
\r
560 pBtLinkInfo->bA2dpExist )
\r
564 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
\r
565 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
\r
569 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
\r
570 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
\r
576 if( pBtLinkInfo->bHidExist &&
\r
577 pBtLinkInfo->bPanExist &&
\r
578 pBtLinkInfo->bA2dpExist )
\r
582 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
\r
583 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
\r
587 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
\r
588 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
\r
593 else if(numOfDiffProfile >= 3)
\r
595 if(pBtLinkInfo->bScoExist)
\r
597 if( pBtLinkInfo->bHidExist &&
\r
598 pBtLinkInfo->bPanExist &&
\r
599 pBtLinkInfo->bA2dpExist )
\r
603 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
\r
608 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
\r
609 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
\r
619 halbtc8192e1ant_SetFwDacSwingLevel(
\r
620 IN PBTC_COEXIST pBtCoexist,
\r
621 IN u1Byte dacSwingLvl
\r
624 u1Byte H2C_Parameter[1] ={0};
\r
626 // There are several type of dacswing
\r
627 // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
\r
628 H2C_Parameter[0] = dacSwingLvl;
\r
630 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl));
\r
631 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0]));
\r
633 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter);
\r
637 halbtc8192e1ant_SetFwDecBtPwr(
\r
638 IN PBTC_COEXIST pBtCoexist,
\r
639 IN u1Byte decBtPwrLvl
\r
642 u1Byte H2C_Parameter[1] ={0};
\r
644 H2C_Parameter[0] = decBtPwrLvl;
\r
646 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n",
\r
647 decBtPwrLvl, H2C_Parameter[0]));
\r
649 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter);
\r
653 halbtc8192e1ant_DecBtPwr(
\r
654 IN PBTC_COEXIST pBtCoexist,
\r
655 IN BOOLEAN bForceExec,
\r
656 IN u1Byte decBtPwrLvl
\r
659 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s Dec BT power level = %d\n",
\r
660 (bForceExec? "force to":""), decBtPwrLvl));
\r
661 pCoexDm->curBtDecPwrLvl = decBtPwrLvl;
\r
665 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], BtDecPwrLvl=%d, curBtDecPwrLvl=%d\n",
\r
666 pCoexDm->preBtDecPwrLvl, pCoexDm->curBtDecPwrLvl));
\r
668 if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl)
\r
671 halbtc8192e1ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
\r
673 pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
\r
677 halbtc8192e1ant_SetBtAutoReport(
\r
678 IN PBTC_COEXIST pBtCoexist,
\r
679 IN BOOLEAN bEnableAutoReport
\r
682 u1Byte H2C_Parameter[1] ={0};
\r
684 H2C_Parameter[0] = 0;
\r
686 if(bEnableAutoReport)
\r
688 H2C_Parameter[0] |= BIT0;
\r
691 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
\r
692 (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));
\r
694 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter);
\r
698 halbtc8192e1ant_BtAutoReport(
\r
699 IN PBTC_COEXIST pBtCoexist,
\r
700 IN BOOLEAN bForceExec,
\r
701 IN BOOLEAN bEnableAutoReport
\r
704 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Auto report = %s\n",
\r
705 (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
\r
706 pCoexDm->bCurBtAutoReport = bEnableAutoReport;
\r
710 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
\r
711 pCoexDm->bPreBtAutoReport, pCoexDm->bCurBtAutoReport));
\r
713 if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
\r
716 halbtc8192e1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
\r
718 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
\r
722 halbtc8192e1ant_FwDacSwingLvl(
\r
723 IN PBTC_COEXIST pBtCoexist,
\r
724 IN BOOLEAN bForceExec,
\r
725 IN u1Byte fwDacSwingLvl
\r
728 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set FW Dac Swing level = %d\n",
\r
729 (bForceExec? "force to":""), fwDacSwingLvl));
\r
730 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
\r
734 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preFwDacSwingLvl=%d, curFwDacSwingLvl=%d\n",
\r
735 pCoexDm->preFwDacSwingLvl, pCoexDm->curFwDacSwingLvl));
\r
737 if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
\r
741 halbtc8192e1ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
\r
743 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
\r
747 halbtc8192e1ant_SetSwPenaltyTxRateAdaptive(
\r
748 IN PBTC_COEXIST pBtCoexist,
\r
749 IN BOOLEAN bLowPenaltyRa
\r
754 tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd);
\r
758 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
\r
763 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
\r
767 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1);
\r
771 halbtc8192e1ant_LowPenaltyRa(
\r
772 IN PBTC_COEXIST pBtCoexist,
\r
773 IN BOOLEAN bForceExec,
\r
774 IN BOOLEAN bLowPenaltyRa
\r
778 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
\r
779 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
\r
780 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
784 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
\r
785 pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
\r
787 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
790 halbtc8192e1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
792 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
796 halbtc8192e1ant_SetDacSwingReg(
\r
797 IN PBTC_COEXIST pBtCoexist,
\r
801 u1Byte val=(u1Byte)level;
\r
803 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Write SwDacSwing = 0x%x\n", level));
\r
804 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val);
\r
808 halbtc8192e1ant_SetSwFullTimeDacSwing(
\r
809 IN PBTC_COEXIST pBtCoexist,
\r
810 IN BOOLEAN bSwDacSwingOn,
\r
811 IN u4Byte swDacSwingLvl
\r
816 halbtc8192e1ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
\r
820 halbtc8192e1ant_SetDacSwingReg(pBtCoexist, 0x18);
\r
825 halbtc8192e1ant_DacSwing(
\r
826 IN PBTC_COEXIST pBtCoexist,
\r
827 IN BOOLEAN bForceExec,
\r
828 IN BOOLEAN bDacSwingOn,
\r
829 IN u4Byte dacSwingLvl
\r
832 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
\r
833 (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
\r
834 pCoexDm->bCurDacSwingOn = bDacSwingOn;
\r
835 pCoexDm->curDacSwingLvl = dacSwingLvl;
\r
839 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
\r
840 pCoexDm->bPreDacSwingOn, pCoexDm->preDacSwingLvl,
\r
841 pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl));
\r
843 if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
\r
844 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
\r
848 halbtc8192e1ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
\r
850 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
\r
851 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
\r
855 halbtc8192e1ant_SetCoexTable(
\r
856 IN PBTC_COEXIST pBtCoexist,
\r
857 IN u4Byte val0x6c0,
\r
858 IN u4Byte val0x6c4,
\r
859 IN u4Byte val0x6c8,
\r
863 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
\r
864 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
\r
866 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
\r
867 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
\r
869 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
870 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
872 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
873 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
877 halbtc8192e1ant_CoexTable(
\r
878 IN PBTC_COEXIST pBtCoexist,
\r
879 IN BOOLEAN bForceExec,
\r
880 IN u4Byte val0x6c0,
\r
881 IN u4Byte val0x6c4,
\r
882 IN u4Byte val0x6c8,
\r
886 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
\r
887 (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc));
\r
888 pCoexDm->curVal0x6c0 = val0x6c0;
\r
889 pCoexDm->curVal0x6c4 = val0x6c4;
\r
890 pCoexDm->curVal0x6c8 = val0x6c8;
\r
891 pCoexDm->curVal0x6cc = val0x6cc;
\r
895 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c4=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
\r
896 pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
\r
897 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
\r
898 pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
\r
900 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
\r
901 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
\r
902 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
903 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
906 halbtc8192e1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
\r
908 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
\r
909 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
\r
910 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
911 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
915 halbtc8192e1ant_CoexTableWithType(
\r
916 IN PBTC_COEXIST pBtCoexist,
\r
917 IN BOOLEAN bForceExec,
\r
924 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);
\r
927 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
\r
930 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);
\r
933 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
\r
936 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffffff, 0x3);
\r
939 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3);
\r
942 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3);
\r
945 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xddffddff, 0xddffddff, 0xffffff, 0x3);
\r
948 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5afa5afa, 0xffffff, 0x3);
\r
951 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5f5f5f5f, 0x5f5f5f5f, 0xffffff, 0x3);
\r
959 halbtc8192e1ant_SetFwIgnoreWlanAct(
\r
960 IN PBTC_COEXIST pBtCoexist,
\r
964 u1Byte H2C_Parameter[1] ={0};
\r
968 H2C_Parameter[0] |= BIT0; // function enable
\r
971 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
\r
972 H2C_Parameter[0]));
\r
974 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
\r
978 halbtc8192e1ant_IgnoreWlanAct(
\r
979 IN PBTC_COEXIST pBtCoexist,
\r
980 IN BOOLEAN bForceExec,
\r
984 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
\r
985 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
\r
986 pCoexDm->bCurIgnoreWlanAct = bEnable;
\r
990 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
\r
991 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
\r
993 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
\r
996 halbtc8192e1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
\r
998 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
\r
1002 halbtc8192e1ant_SetFwPstdma(
\r
1003 IN PBTC_COEXIST pBtCoexist,
\r
1011 u1Byte H2C_Parameter[5] ={0};
\r
1013 H2C_Parameter[0] = byte1;
\r
1014 H2C_Parameter[1] = byte2;
\r
1015 H2C_Parameter[2] = byte3;
\r
1016 H2C_Parameter[3] = byte4;
\r
1017 H2C_Parameter[4] = byte5;
\r
1019 pCoexDm->psTdmaPara[0] = byte1;
\r
1020 pCoexDm->psTdmaPara[1] = byte2;
\r
1021 pCoexDm->psTdmaPara[2] = byte3;
\r
1022 pCoexDm->psTdmaPara[3] = byte4;
\r
1023 pCoexDm->psTdmaPara[4] = byte5;
\r
1025 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n",
\r
1026 H2C_Parameter[0],
\r
1027 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
\r
1029 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
\r
1033 halbtc8192e1ant_SetLpsRpwm(
\r
1034 IN PBTC_COEXIST pBtCoexist,
\r
1039 u1Byte lps=lpsVal;
\r
1040 u1Byte rpwm=rpwmVal;
\r
1042 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
\r
1043 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
\r
1047 halbtc8192e1ant_LpsRpwm(
\r
1048 IN PBTC_COEXIST pBtCoexist,
\r
1049 IN BOOLEAN bForceExec,
\r
1054 BOOLEAN bForceExecPwrCmd=FALSE;
\r
1056 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
\r
1057 (bForceExec? "force to":""), lpsVal, rpwmVal));
\r
1058 pCoexDm->curLps = lpsVal;
\r
1059 pCoexDm->curRpwm = rpwmVal;
\r
1063 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preLps/curLps=0x%x/0x%x, preRpwm/curRpwm=0x%x/0x%x!!\n",
\r
1064 pCoexDm->preLps, pCoexDm->curLps, pCoexDm->preRpwm, pCoexDm->curRpwm));
\r
1066 if( (pCoexDm->preLps == pCoexDm->curLps) &&
\r
1067 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
\r
1072 halbtc8192e1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
\r
1074 pCoexDm->preLps = pCoexDm->curLps;
\r
1075 pCoexDm->preRpwm = pCoexDm->curRpwm;
\r
1079 halbtc8192e1ant_SetAntPath(
\r
1080 IN PBTC_COEXIST pBtCoexist,
\r
1081 IN u1Byte antPosType,
\r
1082 IN BOOLEAN bInitHwCfg,
\r
1083 IN BOOLEAN bWifiOff
\r
1090 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x944, 0x24);
\r
1091 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x930, 0x700700);
\r
1092 if(pBtCoexist->chipInterface == BTC_INTF_USB)
\r
1093 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004);
\r
1095 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004);
\r
1097 // 0x4c[27][24]='00', Set Antenna to BB
\r
1098 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1101 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1105 if(pBtCoexist->chipInterface == BTC_INTF_USB)
\r
1106 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004);
\r
1108 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004);
\r
1110 // 0x4c[27][24]='11', Set Antenna to BT, 0x64[8:7]=0, 0x64[2]=1
\r
1111 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1114 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1117 // ext switch setting
\r
1118 switch(antPosType)
\r
1120 case BTC_ANT_PATH_WIFI:
\r
1121 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4);
\r
1123 case BTC_ANT_PATH_BT:
\r
1124 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x20);
\r
1127 case BTC_ANT_PATH_PTA:
\r
1128 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4);
\r
1134 halbtc8192e1ant_PsTdma(
\r
1135 IN PBTC_COEXIST pBtCoexist,
\r
1136 IN BOOLEAN bForceExec,
\r
1137 IN BOOLEAN bTurnOn,
\r
1141 BOOLEAN bTurnOnByCnt=FALSE;
\r
1142 u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0;
\r
1144 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
\r
1145 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
\r
1146 pCoexDm->bCurPsTdmaOn = bTurnOn;
\r
1147 pCoexDm->curPsTdma = type;
\r
1151 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
\r
1152 pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn));
\r
1153 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
\r
1154 pCoexDm->prePsTdma, pCoexDm->curPsTdma));
\r
1156 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
\r
1157 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
\r
1165 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x2c, 0x03, 0x10, 0x50);
\r
1168 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x2c, 0x03, 0x10, 0x50);
\r
1169 rssiAdjustVal = 11;
\r
1172 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x25, 0x03, 0x10, 0x50);
\r
1173 rssiAdjustVal = 14;
\r
1176 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x40);
\r
1179 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
\r
1180 rssiAdjustVal = 17;
\r
1183 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x31, 0x0);
\r
1186 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x0, 0x0);
\r
1189 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
\r
1192 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1195 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1e, 0x03, 0x10, 0x50);
\r
1196 rssiAdjustVal = 18;
\r
1199 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
\r
1202 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x12, 0x03, 0x10, 0x50);
\r
1203 rssiAdjustVal = 20;
\r
1206 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xeb, 0xa, 0x3, 0x31, 0x18);
\r
1210 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0);
\r
1213 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0);
\r
1214 rssiAdjustVal = 18;
\r
1218 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1219 rssiAdjustVal = 14;
\r
1223 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0x25, 0x25, 0x0, 0x0);
\r
1226 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x20, 0x3, 0x10, 0x40);
\r
1229 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0x8, 0x8, 0x0, 0x40);
\r
1232 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);
\r
1233 rssiAdjustVal = 22;
\r
1236 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);
\r
1237 rssiAdjustVal = 22;
\r
1240 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1241 rssiAdjustVal = 22;
\r
1244 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1245 rssiAdjustVal = 22;
\r
1248 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);
\r
1249 rssiAdjustVal = 22;
\r
1252 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0);
\r
1255 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10);
\r
1258 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
\r
1261 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);
\r
1264 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xab, 0xa, 0x3, 0x31, 0x90);
\r
1267 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90);
\r
1270 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x10);
\r
1273 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x0, 0x10);
\r
1276 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50);
\r
1279 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x25, 0x3, 0x10, 0x50);
\r
1282 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
\r
1288 // disable PS tdma
\r
1291 case 8: //0x778 = 1, ant2PTA
\r
1292 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
\r
1293 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE);
\r
1295 case 0: //0x778 = 1, ant2BT
\r
1297 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1299 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
\r
1301 case 9: //0x778 = 1, ant2WIFI
\r
1302 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1303 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE);
\r
1305 case 10: //0x778 = 3, ant2BT
\r
1306 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
\r
1308 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
\r
1313 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal);
\r
1315 // update pre state
\r
1316 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
\r
1317 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
\r
1321 halbtc8192e1ant_SetSwitchSsType(
\r
1322 IN PBTC_COEXIST pBtCoexist,
\r
1326 u1Byte mimoPs=BTC_MIMO_PS_DYNAMIC;
\r
1328 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], REAL set SS Type = %d\n", ssType));
\r
1332 halbtc8192e1ant_UpdateRaMask(pBtCoexist, FORCE_EXEC, BTC_RATE_DISABLE, 0xfff00000); // disable 2ss
\r
1333 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
\r
1334 // switch ofdm path
\r
1335 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xc04, 0x11);
\r
1336 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xd04, 0x1);
\r
1337 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x90c, 0x81111111);
\r
1338 // switch cck patch
\r
1339 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xe77, 0x4, 0x1);
\r
1340 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xa07, 0x81);
\r
1341 mimoPs=BTC_MIMO_PS_STATIC;
\r
1343 else if(ssType == 2)
\r
1345 halbtc8192e1ant_UpdateRaMask(pBtCoexist, FORCE_EXEC, BTC_RATE_ENABLE, 0xfff00000); // enable 2ss
\r
1346 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
1347 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xc04, 0x33);
\r
1348 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xd04, 0x3);
\r
1349 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x90c, 0x81121313);
\r
1350 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xe77, 0x4, 0x0);
\r
1351 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xa07, 0x41);
\r
1352 mimoPs=BTC_MIMO_PS_DYNAMIC;
\r
1355 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimoPs); // set rx 1ss or 2ss
\r
1359 halbtc8192e1ant_SwitchSsType(
\r
1360 IN PBTC_COEXIST pBtCoexist,
\r
1361 IN BOOLEAN bForceExec,
\r
1362 IN u1Byte newSsType
\r
1365 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], %s Switch SS Type = %d\n",
\r
1366 (bForceExec? "force to":""), newSsType));
\r
1367 pCoexDm->curSsType = newSsType;
\r
1371 if(pCoexDm->preSsType == pCoexDm->curSsType)
\r
1374 halbtc8192e1ant_SetSwitchSsType(pBtCoexist, pCoexDm->curSsType);
\r
1376 pCoexDm->preSsType = pCoexDm->curSsType;
\r
1380 halbtc8192e1ant_CoexAllOff(
\r
1381 IN PBTC_COEXIST pBtCoexist
\r
1384 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1387 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1391 halbtc8192e1ant_IsCommonAction(
\r
1392 IN PBTC_COEXIST pBtCoexist
\r
1395 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
1397 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1398 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1400 if(!bWifiConnected &&
\r
1401 BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
1403 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));
\r
1406 else if(bWifiConnected &&
\r
1407 (BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1409 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
\r
1413 else if(!bWifiConnected &&
\r
1414 (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1416 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));
\r
1420 else if(bWifiConnected &&
\r
1421 (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1423 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
\r
1427 else if(!bWifiConnected &&
\r
1428 (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) )
\r
1430 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
\r
1444 halbtc8192e1ant_TdmaDurationAdjustForAcl(
\r
1445 IN PBTC_COEXIST pBtCoexist,
\r
1446 IN u1Byte wifiStatus
\r
1449 static s4Byte up,dn,m,n,WaitCount;
\r
1450 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
\r
1451 u1Byte retryCount=0, btInfoExt;
\r
1453 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjustForAcl()\n"));
\r
1455 if( (BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
\r
1456 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
\r
1457 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
\r
1459 if( pCoexDm->curPsTdma != 1 &&
\r
1460 pCoexDm->curPsTdma != 2 &&
\r
1461 pCoexDm->curPsTdma != 3 &&
\r
1462 pCoexDm->curPsTdma != 9 )
\r
1464 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1465 pCoexDm->psTdmaDuAdjType = 9;
\r
1477 if(!pCoexDm->bAutoTdmaAdjust)
\r
1479 pCoexDm->bAutoTdmaAdjust = TRUE;
\r
1480 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
\r
1482 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1483 pCoexDm->psTdmaDuAdjType = 2;
\r
1494 //accquire the BT TRx retry count from BT_Info byte2
\r
1495 retryCount = pCoexSta->btRetryCnt;
\r
1496 btInfoExt = pCoexSta->btInfoExt;
\r
1497 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
\r
1498 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
\r
1499 up, dn, m, n, WaitCount));
\r
1503 if(retryCount == 0) // no retry in the last 2-second duration
\r
1511 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
\r
1518 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
\r
1521 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
\r
1529 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
\r
1531 if (WaitCount <= 2)
\r
1532 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1536 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1544 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
\r
1547 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
\r
1549 if (WaitCount == 1)
\r
1550 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1554 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1562 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
\r
1567 if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1568 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1570 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1571 pCoexDm->psTdmaDuAdjType = 9;
\r
1573 else if(pCoexDm->curPsTdma == 1)
\r
1575 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1576 pCoexDm->psTdmaDuAdjType = 2;
\r
1578 else if(pCoexDm->curPsTdma == 2)
\r
1580 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1581 pCoexDm->psTdmaDuAdjType = 9;
\r
1583 else if(pCoexDm->curPsTdma == 9)
\r
1585 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
1586 pCoexDm->psTdmaDuAdjType = 11;
\r
1589 else if(result == 1)
\r
1591 if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1592 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1594 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1595 pCoexDm->psTdmaDuAdjType = 9;
\r
1597 else if(pCoexDm->curPsTdma == 11)
\r
1599 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1600 pCoexDm->psTdmaDuAdjType = 9;
\r
1602 else if(pCoexDm->curPsTdma == 9)
\r
1604 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1605 pCoexDm->psTdmaDuAdjType = 2;
\r
1607 else if(pCoexDm->curPsTdma == 2)
\r
1609 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
1610 pCoexDm->psTdmaDuAdjType = 1;
\r
1614 if( pCoexDm->curPsTdma != 1 &&
\r
1615 pCoexDm->curPsTdma != 2 &&
\r
1616 pCoexDm->curPsTdma != 9 &&
\r
1617 pCoexDm->curPsTdma != 11 )
\r
1619 // recover to previous adjust type
\r
1620 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
\r
1626 halbtc8192e1ant_PsTdmaTypeByWifiRssi(
\r
1627 IN s4Byte wifiRssi,
\r
1628 IN s4Byte preWifiRssi,
\r
1629 IN u1Byte wifiRssiThresh
\r
1632 u1Byte psTdmaType=0;
\r
1634 if(wifiRssi > preWifiRssi)
\r
1636 if(wifiRssi > (wifiRssiThresh+5))
\r
1647 if(wifiRssi > wifiRssiThresh)
\r
1657 return psTdmaType;
\r
1661 halbtc8192e1ant_PsTdmaCheckForPowerSaveState(
\r
1662 IN PBTC_COEXIST pBtCoexist,
\r
1663 IN BOOLEAN bNewPsState
\r
1666 u1Byte lpsMode=0x0;
\r
1668 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
\r
1670 if(lpsMode) // already under LPS state
\r
1674 // keep state under LPS, do nothing.
\r
1678 // will leave LPS state, turn off psTdma first
\r
1679 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1682 else // NO PS state
\r
1686 // will enter LPS state, turn off psTdma first
\r
1687 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1691 // keep state under NO PS state, do nothing.
\r
1697 halbtc8192e1ant_PowerSaveState(
\r
1698 IN PBTC_COEXIST pBtCoexist,
\r
1704 BOOLEAN bLowPwrDisable=FALSE;
\r
1708 case BTC_PS_WIFI_NATIVE:
\r
1709 // recover to original 32k low power setting
\r
1710 bLowPwrDisable = FALSE;
\r
1711 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1712 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1714 case BTC_PS_LPS_ON:
\r
1715 halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);
\r
1716 halbtc8192e1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
\r
1717 // when coex force to enter LPS, do not enter 32k low power.
\r
1718 bLowPwrDisable = TRUE;
\r
1719 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1720 // power save must executed before psTdma.
\r
1721 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
\r
1723 case BTC_PS_LPS_OFF:
\r
1724 halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
\r
1725 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1734 halbtc8192e1ant_ActionWifiOnly(
\r
1735 IN PBTC_COEXIST pBtCoexist
\r
1738 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1739 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1743 halbtc8192e1ant_MonitorBtEnableDisable(
\r
1744 IN PBTC_COEXIST pBtCoexist
\r
1747 static BOOLEAN bPreBtDisabled=FALSE;
\r
1748 static u4Byte btDisableCnt=0;
\r
1749 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
\r
1751 // This function check if bt is disabled
\r
1753 if( pCoexSta->highPriorityTx == 0 &&
\r
1754 pCoexSta->highPriorityRx == 0 &&
\r
1755 pCoexSta->lowPriorityTx == 0 &&
\r
1756 pCoexSta->lowPriorityRx == 0)
\r
1758 bBtActive = FALSE;
\r
1760 if( pCoexSta->highPriorityTx == 0xffff &&
\r
1761 pCoexSta->highPriorityRx == 0xffff &&
\r
1762 pCoexSta->lowPriorityTx == 0xffff &&
\r
1763 pCoexSta->lowPriorityRx == 0xffff)
\r
1765 bBtActive = FALSE;
\r
1770 bBtDisabled = FALSE;
\r
1771 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
1772 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
\r
1777 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
\r
1779 if(btDisableCnt >= 2)
\r
1781 bBtDisabled = TRUE;
\r
1782 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
1783 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
\r
1784 halbtc8192e1ant_ActionWifiOnly(pBtCoexist);
\r
1787 if(bPreBtDisabled != bBtDisabled)
\r
1789 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
\r
1790 (bPreBtDisabled ? "disabled":"enabled"),
\r
1791 (bBtDisabled ? "disabled":"enabled")));
\r
1792 bPreBtDisabled = bBtDisabled;
\r
1798 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1799 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1804 //=============================================
\r
1806 // Software Coex Mechanism start
\r
1808 //=============================================
\r
1810 // SCO only or SCO+PAN(HS)
\r
1812 halbtc8192e1ant_ActionSco(
\r
1813 IN PBTC_COEXIST pBtCoexist
\r
1819 halbtc8192e1ant_ActionHid(
\r
1820 IN PBTC_COEXIST pBtCoexist
\r
1825 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
\r
1827 halbtc8192e1ant_ActionA2dp(
\r
1828 IN PBTC_COEXIST pBtCoexist
\r
1834 halbtc8192e1ant_ActionA2dpPanHs(
\r
1835 IN PBTC_COEXIST pBtCoexist
\r
1841 halbtc8192e1ant_ActionPanEdr(
\r
1842 IN PBTC_COEXIST pBtCoexist
\r
1849 halbtc8192e1ant_ActionPanHs(
\r
1850 IN PBTC_COEXIST pBtCoexist
\r
1857 halbtc8192e1ant_ActionPanEdrA2dp(
\r
1858 IN PBTC_COEXIST pBtCoexist
\r
1864 halbtc8192e1ant_ActionPanEdrHid(
\r
1865 IN PBTC_COEXIST pBtCoexist
\r
1870 // HID+A2DP+PAN(EDR)
\r
1872 halbtc8192e1ant_ActionHidA2dpPanEdr(
\r
1873 IN PBTC_COEXIST pBtCoexist
\r
1879 halbtc8192e1ant_ActionHidA2dp(
\r
1880 IN PBTC_COEXIST pBtCoexist
\r
1885 //=============================================
\r
1887 // Non-Software Coex Mechanism start
\r
1889 //=============================================
\r
1891 halbtc8192e1ant_ActionBtInquiry(
\r
1892 IN PBTC_COEXIST pBtCoexist
\r
1895 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
1896 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
1899 // Do not do DacSwing here, use original setting.
\r
1901 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1903 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1907 if(!bWifiConnected)
\r
1909 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1911 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1913 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1914 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1916 else if( (pBtLinkInfo->bScoExist) ||
\r
1917 (pBtLinkInfo->bHidOnly) )
\r
1919 // SCO/HID-only busy
\r
1920 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1922 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1924 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
1925 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
1929 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
\r
1931 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1933 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 30);
\r
1934 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1939 halbtc8192e1ant_ActionBtScoHidOnlyBusy(
\r
1940 IN PBTC_COEXIST pBtCoexist,
\r
1941 IN u1Byte wifiStatus
\r
1944 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
1945 u1Byte btRssiState=BTC_RSSI_STATE_HIGH;
\r
1947 if(BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus)
\r
1949 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1950 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1952 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1953 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1957 if(pBtLinkInfo->bHidOnly)
\r
1959 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1960 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1962 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1963 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1967 // dec bt power for diff level
\r
1968 btRssiState = halbtc8192e1ant_BtRssiState(3, 34, 42);
\r
1969 if( (btRssiState == BTC_RSSI_STATE_LOW) ||
\r
1970 (btRssiState == BTC_RSSI_STATE_STAY_LOW) )
\r
1972 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1974 else if( (btRssiState == BTC_RSSI_STATE_MEDIUM) ||
\r
1975 (btRssiState == BTC_RSSI_STATE_STAY_MEDIUM) )
\r
1977 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
1979 else if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1980 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1982 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 6);
\r
1986 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0xc);
\r
1988 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1989 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
1995 halbtc8192e1ant_ActionHs(
\r
1996 IN PBTC_COEXIST pBtCoexist
\r
1999 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2001 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action for HS!!!\n"));
\r
2003 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2005 if(BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
2007 // error, should not be here
\r
2008 pCoexDm->errorCondition = 1;
\r
2010 else if(BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
\r
2012 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2013 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2015 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 10);
\r
2016 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2018 else if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus &&
\r
2019 !pBtCoexist->btLinkInfo.bHidOnly)
\r
2021 if(pCoexDm->curSsType == 1)
\r
2023 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2024 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2025 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 10);
\r
2026 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2031 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2032 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
2037 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(
\r
2038 IN PBTC_COEXIST pBtCoexist,
\r
2039 IN u1Byte wifiStatus
\r
2042 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2044 if(pBtLinkInfo->bHidOnly)
\r
2046 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);
\r
2047 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2051 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2052 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2054 if( (pBtLinkInfo->bA2dpOnly) ||
\r
2055 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) )
\r
2057 halbtc8192e1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);
\r
2059 else if( (pBtLinkInfo->bPanOnly) ||
\r
2060 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) )
\r
2062 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2063 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2067 if( (BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
\r
2068 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
\r
2069 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
\r
2070 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
2072 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2073 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
2076 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
2081 halbtc8192e1ant_ActionWifiNotConnected(
\r
2082 IN PBTC_COEXIST pBtCoexist
\r
2085 // power save state
\r
2086 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2088 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2089 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2091 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2092 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2096 halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(
\r
2097 IN PBTC_COEXIST pBtCoexist
\r
2100 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2102 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2103 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2105 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2106 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2110 halbtc8192e1ant_ActionWifiConnectedScan(
\r
2111 IN PBTC_COEXIST pBtCoexist
\r
2114 // power save state
\r
2115 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
\r
2116 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
\r
2118 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2120 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2122 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2123 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
2125 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2126 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2128 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2129 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
2133 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2134 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2135 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2136 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2142 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(
\r
2143 IN PBTC_COEXIST pBtCoexist
\r
2146 // power save state
\r
2147 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
\r
2148 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
\r
2150 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2152 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2154 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2155 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT);
\r
2159 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2160 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2161 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2162 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2167 halbtc8192e1ant_ActionWifiConnected(
\r
2168 IN PBTC_COEXIST pBtCoexist
\r
2171 BOOLEAN bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
2172 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2173 BOOLEAN bUnder4way=FALSE;
\r
2176 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect()===>\n"));
\r
2178 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2179 if(!bWifiConnected)
\r
2181 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi not connected<===\n"));
\r
2185 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
2188 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
2189 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));
\r
2193 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2194 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2195 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2196 if(bScan || bLink || bRoam)
\r
2198 halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist);
\r
2199 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));
\r
2203 // power save state
\r
2204 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
\r
2205 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
\r
2207 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2209 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
2212 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2214 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2215 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
2217 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2218 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2220 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2221 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
2225 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2226 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2227 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2228 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2233 if(BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
2235 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2236 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2237 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2238 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2240 else if(BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
\r
2242 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2243 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2244 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2245 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2247 else if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
2249 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
2250 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
2252 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2253 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2255 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
2256 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
2260 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2261 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2262 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
2263 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2269 halbtc8192e1ant_RunSwCoexistMechanism(
\r
2270 IN PBTC_COEXIST pBtCoexist
\r
2273 BOOLEAN bWifiUnder5G=FALSE, bWifiBusy=FALSE, bWifiConnected=FALSE;
\r
2274 u1Byte btInfoOriginal=0, btRetryCnt=0;
\r
2275 u1Byte algorithm=0;
\r
2279 algorithm = halbtc8192e1ant_ActionAlgorithm(pBtCoexist);
\r
2280 pCoexDm->curAlgorithm = algorithm;
\r
2282 if(halbtc8192e1ant_IsCommonAction(pBtCoexist))
\r
2287 switch(pCoexDm->curAlgorithm)
\r
2289 case BT_8192E_1ANT_COEX_ALGO_SCO:
\r
2290 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n"));
\r
2291 halbtc8192e1ant_ActionSco(pBtCoexist);
\r
2293 case BT_8192E_1ANT_COEX_ALGO_HID:
\r
2294 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n"));
\r
2295 halbtc8192e1ant_ActionHid(pBtCoexist);
\r
2297 case BT_8192E_1ANT_COEX_ALGO_A2DP:
\r
2298 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n"));
\r
2299 halbtc8192e1ant_ActionA2dp(pBtCoexist);
\r
2301 case BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS:
\r
2302 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
\r
2303 halbtc8192e1ant_ActionA2dpPanHs(pBtCoexist);
\r
2305 case BT_8192E_1ANT_COEX_ALGO_PANEDR:
\r
2306 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
\r
2307 halbtc8192e1ant_ActionPanEdr(pBtCoexist);
\r
2309 case BT_8192E_1ANT_COEX_ALGO_PANHS:
\r
2310 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n"));
\r
2311 halbtc8192e1ant_ActionPanHs(pBtCoexist);
\r
2313 case BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP:
\r
2314 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
\r
2315 halbtc8192e1ant_ActionPanEdrA2dp(pBtCoexist);
\r
2317 case BT_8192E_1ANT_COEX_ALGO_PANEDR_HID:
\r
2318 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
\r
2319 halbtc8192e1ant_ActionPanEdrHid(pBtCoexist);
\r
2321 case BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
\r
2322 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
\r
2323 halbtc8192e1ant_ActionHidA2dpPanEdr(pBtCoexist);
\r
2325 case BT_8192E_1ANT_COEX_ALGO_HID_A2DP:
\r
2326 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
\r
2327 halbtc8192e1ant_ActionHidA2dp(pBtCoexist);
\r
2330 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
\r
2331 halbtc8192e1ant_CoexAllOff(pBtCoexist);
\r
2334 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
\r
2339 halbtc8192e1ant_RunCoexistMechanism(
\r
2340 IN PBTC_COEXIST pBtCoexist
\r
2343 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2344 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2346 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n"));
\r
2348 if(pBtCoexist->bManualControl)
\r
2350 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
\r
2354 if(pBtCoexist->bStopCoexDm)
\r
2356 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
\r
2360 if(pCoexSta->bUnderIps)
\r
2362 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
\r
2366 halbtc8192e1ant_RunSwCoexistMechanism(pBtCoexist);
\r
2368 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2369 if(pCoexSta->bC2hBtInquiryPage)
\r
2371 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
\r
2376 if(pBtLinkInfo->bScoExist)
\r
2378 halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
\r
2382 if(pBtLinkInfo->bHidOnly)
\r
2383 halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2);
\r
2385 halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
\r
2388 halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2);
\r
2392 halbtc8192e1ant_ActionHs(pBtCoexist);
\r
2396 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2397 if(!bWifiConnected)
\r
2399 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2401 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n"));
\r
2403 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2404 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2405 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2407 if(bScan || bLink || bRoam)
\r
2408 halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
\r
2410 halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
\r
2414 halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
\r
2419 halbtc8192e1ant_InitCoexDm(
\r
2420 IN PBTC_COEXIST pBtCoexist
\r
2423 // force to reset coex mechanism
\r
2424 halbtc8192e1ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
\r
2425 halbtc8192e1ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
\r
2427 halbtc8192e1ant_SwitchSsType(pBtCoexist, FORCE_EXEC, 2);
\r
2429 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
2430 halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
2433 //============================================================
\r
2434 // work around function start with wa_halbtc8192e1ant_
\r
2435 //============================================================
\r
2436 //============================================================
\r
2437 // extern function start with EXhalbtc8192e1ant_
\r
2438 //============================================================
\r
2440 EXhalbtc8192e1ant_PowerOnSetting(
\r
2441 IN PBTC_COEXIST pBtCoexist
\r
2447 EXhalbtc8192e1ant_InitHwConfig(
\r
2448 IN PBTC_COEXIST pBtCoexist,
\r
2449 IN BOOLEAN bWifiOnly
\r
2456 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
\r
2458 // antenna sw ctrl to bt
\r
2459 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, TRUE, FALSE);
\r
2461 halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
2463 // antenna switch control parameter
\r
2464 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x858, 0x55555555);
\r
2466 // coex parameters
\r
2467 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1);
\r
2469 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
\r
2472 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
\r
2474 // enable counter statistics
\r
2475 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
2478 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20);
\r
2479 // enable mailbox interface
\r
2480 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x40);
\r
2482 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x40, u2Tmp);
\r
2484 // enable PTA I2C mailbox
\r
2485 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x101);
\r
2487 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x101, u1Tmp);
\r
2489 // enable bt clock when wifi is disabled.
\r
2490 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x93);
\r
2492 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x93, u1Tmp);
\r
2493 // enable bt clock when suspend.
\r
2494 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7);
\r
2496 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x7, u1Tmp);
\r
2500 EXhalbtc8192e1ant_InitCoexDm(
\r
2501 IN PBTC_COEXIST pBtCoexist
\r
2504 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
2506 pBtCoexist->bStopCoexDm = FALSE;
\r
2508 halbtc8192e1ant_InitCoexDm(pBtCoexist);
\r
2512 EXhalbtc8192e1ant_DisplayCoexInfo(
\r
2513 IN PBTC_COEXIST pBtCoexist
\r
2516 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
2517 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
2518 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2519 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
2520 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
2522 BOOLEAN bRoam=FALSE, bScan=FALSE, bLink=FALSE, bWifiUnder5G=FALSE;
\r
2523 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
2524 s4Byte wifiRssi=0, btHsRssi=0;
\r
2525 u4Byte wifiBw, wifiTrafficDir;
\r
2526 u1Byte wifiDot11Chnl, wifiHsChnl;
\r
2527 u4Byte fwVer=0, btPatchVer=0;
\r
2529 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
2530 CL_PRINTF(cliBuf);
\r
2532 if(pBtCoexist->bManualControl)
\r
2534 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
\r
2535 CL_PRINTF(cliBuf);
\r
2536 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
2537 CL_PRINTF(cliBuf);
\r
2539 if(pBtCoexist->bStopCoexDm)
\r
2541 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");
\r
2542 CL_PRINTF(cliBuf);
\r
2543 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
2544 CL_PRINTF(cliBuf);
\r
2547 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
\r
2548 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
\r
2549 CL_PRINTF(cliBuf);
\r
2551 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
2552 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
2553 CL_PRINTF(cliBuf);
\r
2555 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
2556 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
2557 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
\r
2558 GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer);
\r
2559 CL_PRINTF(cliBuf);
\r
2561 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2562 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
\r
2563 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
\r
2564 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
\r
2565 wifiDot11Chnl, wifiHsChnl, bBtHsOn);
\r
2566 CL_PRINTF(cliBuf);
\r
2568 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
\r
2569 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
\r
2570 pCoexDm->wifiChnlInfo[2]);
\r
2571 CL_PRINTF(cliBuf);
\r
2573 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
2574 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
\r
2575 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
\r
2576 wifiRssi, btHsRssi);
\r
2577 CL_PRINTF(cliBuf);
\r
2579 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2580 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2581 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2582 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
\r
2583 bLink, bRoam, bScan);
\r
2584 CL_PRINTF(cliBuf);
\r
2586 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
2587 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
2588 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
2589 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
2590 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
\r
2591 (bWifiUnder5G? "5G":"2.4G"),
\r
2592 ((BTC_WIFI_BW_LEGACY==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40==wifiBw)? "HT40":"HT20"))),
\r
2593 ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
\r
2594 CL_PRINTF(cliBuf);
\r
2595 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
\r
2596 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
\r
2597 ( (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
\r
2598 pCoexSta->btRssi, pCoexSta->btRetryCnt);
\r
2599 CL_PRINTF(cliBuf);
\r
2601 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
2602 pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);
\r
2603 CL_PRINTF(cliBuf);
\r
2604 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
2606 btInfoExt = pCoexSta->btInfoExt;
\r
2607 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
\r
2608 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
\r
2609 CL_PRINTF(cliBuf);
\r
2611 for(i=0; i<BT_INFO_SRC_8192E_1ANT_MAX; i++)
\r
2613 if(pCoexSta->btInfoC2hCnt[i])
\r
2615 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8192e1Ant[i], \
\r
2616 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
\r
2617 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
\r
2618 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
\r
2619 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
\r
2620 CL_PRINTF(cliBuf);
\r
2623 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", \
\r
2624 ((pCoexSta->bUnderIps? "IPS ON":"IPS OFF")),
\r
2625 ((pCoexSta->bUnderLps? "LPS ON":"LPS OFF")),
\r
2626 pBtCoexist->btInfo.lpsVal,
\r
2627 pBtCoexist->btInfo.rpwmVal);
\r
2628 CL_PRINTF(cliBuf);
\r
2629 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
\r
2631 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "SS Type", \
\r
2632 pCoexDm->curSsType);
\r
2633 CL_PRINTF(cliBuf);
\r
2635 if(!pBtCoexist->bManualControl)
\r
2638 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
2639 CL_PRINTF(cliBuf);
\r
2641 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d(0x%x) ", "SM[SwDacSwing(lvl)]", \
\r
2642 pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
\r
2643 CL_PRINTF(cliBuf);
\r
2645 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \
\r
2646 (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"),
\r
2647 pBtCoexist->btInfo.aggBufSize);
\r
2648 CL_PRINTF(cliBuf);
\r
2649 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \
\r
2650 pBtCoexist->btInfo.raMask);
\r
2651 CL_PRINTF(cliBuf);
\r
2654 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
2655 CL_PRINTF(cliBuf);
\r
2657 psTdmaCase = pCoexDm->curPsTdma;
\r
2658 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
\r
2659 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
\r
2660 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
\r
2661 pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
\r
2662 CL_PRINTF(cliBuf);
\r
2664 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
\r
2665 pCoexDm->errorCondition);
\r
2666 CL_PRINTF(cliBuf);
\r
2668 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwrLvl/ IgnWlanAct", \
\r
2669 pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct);
\r
2670 CL_PRINTF(cliBuf);
\r
2674 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
2675 CL_PRINTF(cliBuf);
\r
2677 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc04);
\r
2678 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xd04);
\r
2679 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x90c);
\r
2680 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xc04/ 0xd04/ 0x90c", \
\r
2681 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
\r
2682 CL_PRINTF(cliBuf);
\r
2684 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
\r
2685 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \
\r
2687 CL_PRINTF(cliBuf);
\r
2689 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x92c);
\r
2690 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
\r
2691 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x92c/ 0x930", \
\r
2692 (u1Tmp[0]), u4Tmp[0]);
\r
2693 CL_PRINTF(cliBuf);
\r
2695 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
2696 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4f);
\r
2697 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x40/ 0x4f", \
\r
2698 u1Tmp[0], u1Tmp[1]);
\r
2699 CL_PRINTF(cliBuf);
\r
2701 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
\r
2702 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
\r
2703 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
\r
2704 u4Tmp[0], u1Tmp[0]);
\r
2705 CL_PRINTF(cliBuf);
\r
2707 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
2708 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
\r
2710 CL_PRINTF(cliBuf);
\r
2712 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
\r
2713 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
2714 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
2715 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
\r
2716 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
\r
2717 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
\r
2718 CL_PRINTF(cliBuf);
\r
2720 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \
\r
2721 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
\r
2722 CL_PRINTF(cliBuf);
\r
2723 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
\r
2724 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
\r
2725 CL_PRINTF(cliBuf);
\r
2726 #if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 1)
\r
2727 halbtc8192e1ant_MonitorBtCtr(pBtCoexist);
\r
2730 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
2735 EXhalbtc8192e1ant_IpsNotify(
\r
2736 IN PBTC_COEXIST pBtCoexist,
\r
2742 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
2745 if(BTC_IPS_ENTER == type)
\r
2747 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
\r
2748 pCoexSta->bUnderIps = TRUE;
\r
2749 halbtc8192e1ant_CoexAllOff(pBtCoexist);
\r
2750 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
2752 else if(BTC_IPS_LEAVE == type)
\r
2754 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
\r
2755 pCoexSta->bUnderIps = FALSE;
\r
2760 EXhalbtc8192e1ant_LpsNotify(
\r
2761 IN PBTC_COEXIST pBtCoexist,
\r
2765 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
2768 if(BTC_LPS_ENABLE == type)
\r
2770 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
\r
2771 pCoexSta->bUnderLps = TRUE;
\r
2773 else if(BTC_LPS_DISABLE == type)
\r
2775 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
\r
2776 pCoexSta->bUnderLps = FALSE;
\r
2781 EXhalbtc8192e1ant_ScanNotify(
\r
2782 IN PBTC_COEXIST pBtCoexist,
\r
2786 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2788 if(pBtCoexist->bManualControl ||
\r
2789 pBtCoexist->bStopCoexDm ||
\r
2790 pBtCoexist->btInfo.bBtDisabled )
\r
2793 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2794 if(pCoexSta->bC2hBtInquiryPage)
\r
2796 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
\r
2801 halbtc8192e1ant_ActionHs(pBtCoexist);
\r
2805 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2806 if(BTC_SCAN_START == type)
\r
2808 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
\r
2809 if(!bWifiConnected) // non-connected scan
\r
2811 halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
\r
2813 else // wifi is connected
\r
2815 halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist);
\r
2818 else if(BTC_SCAN_FINISH == type)
\r
2820 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
\r
2821 if(!bWifiConnected) // non-connected scan
\r
2823 halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
\r
2827 halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
\r
2833 EXhalbtc8192e1ant_ConnectNotify(
\r
2834 IN PBTC_COEXIST pBtCoexist,
\r
2838 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2840 if(pBtCoexist->bManualControl ||
\r
2841 pBtCoexist->bStopCoexDm ||
\r
2842 pBtCoexist->btInfo.bBtDisabled )
\r
2845 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2846 if(pCoexSta->bC2hBtInquiryPage)
\r
2848 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
\r
2853 halbtc8192e1ant_ActionHs(pBtCoexist);
\r
2857 if(BTC_ASSOCIATE_START == type)
\r
2859 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
\r
2860 halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
\r
2862 else if(BTC_ASSOCIATE_FINISH == type)
\r
2864 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
\r
2866 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2867 if(!bWifiConnected) // non-connected scan
\r
2869 halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
\r
2873 halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
\r
2879 EXhalbtc8192e1ant_MediaStatusNotify(
\r
2880 IN PBTC_COEXIST pBtCoexist,
\r
2884 u1Byte H2C_Parameter[3] ={0};
\r
2886 u1Byte wifiCentralChnl;
\r
2888 if(pBtCoexist->bManualControl ||
\r
2889 pBtCoexist->bStopCoexDm ||
\r
2890 pBtCoexist->btInfo.bBtDisabled )
\r
2893 if(BTC_MEDIA_CONNECT == type)
\r
2895 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
\r
2899 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
\r
2902 // only 2.4G we need to inform bt the chnl mask
\r
2903 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
\r
2904 if( (BTC_MEDIA_CONNECT == type) &&
\r
2905 (wifiCentralChnl <= 14) )
\r
2907 H2C_Parameter[0] = 0x1;
\r
2908 H2C_Parameter[1] = wifiCentralChnl;
\r
2909 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
2910 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
2911 H2C_Parameter[2] = 0x30;
\r
2913 H2C_Parameter[2] = 0x20;
\r
2916 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
\r
2917 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
\r
2918 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
\r
2920 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x66=0x%x\n",
\r
2921 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
\r
2923 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
\r
2927 EXhalbtc8192e1ant_SpecialPacketNotify(
\r
2928 IN PBTC_COEXIST pBtCoexist,
\r
2932 BOOLEAN bBtHsOn=FALSE;
\r
2934 if(pBtCoexist->bManualControl ||
\r
2935 pBtCoexist->bStopCoexDm ||
\r
2936 pBtCoexist->btInfo.bBtDisabled )
\r
2939 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2940 if(pCoexSta->bC2hBtInquiryPage)
\r
2942 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
\r
2947 halbtc8192e1ant_ActionHs(pBtCoexist);
\r
2951 if( BTC_PACKET_DHCP == type ||
\r
2952 BTC_PACKET_EAPOL == type )
\r
2954 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet(%d) notify\n", type));
\r
2955 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
2960 EXhalbtc8192e1ant_BtInfoNotify(
\r
2961 IN PBTC_COEXIST pBtCoexist,
\r
2962 IN pu1Byte tmpBuf,
\r
2966 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2968 u1Byte i, rspSource=0;
\r
2969 static u4Byte setBtPsdMode=0;
\r
2970 BOOLEAN bBtBusy=FALSE;
\r
2971 BOOLEAN bWifiConnected=FALSE;
\r
2972 BOOLEAN bBtCtrlAggBufSize=FALSE;
\r
2974 pCoexSta->bC2hBtInfoReqSent = FALSE;
\r
2976 rspSource = tmpBuf[0]&0xf;
\r
2977 if(rspSource >= BT_INFO_SRC_8192E_1ANT_MAX)
\r
2978 rspSource = BT_INFO_SRC_8192E_1ANT_WIFI_FW;
\r
2979 pCoexSta->btInfoC2hCnt[rspSource]++;
\r
2981 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
\r
2982 for(i=0; i<length; i++)
\r
2984 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
\r
2986 btInfo = tmpBuf[i];
\r
2989 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
\r
2993 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
\r
2997 if(pBtCoexist->btInfo.bBtDisabled)
\r
2999 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for BT is disabled <===\n"));
\r
3003 if(pBtCoexist->bManualControl)
\r
3005 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
\r
3008 if(pBtCoexist->bStopCoexDm)
\r
3010 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Coex STOPPED!!<===\n"));
\r
3014 if(BT_INFO_SRC_8192E_1ANT_WIFI_FW != rspSource)
\r
3016 pCoexSta->btRetryCnt = // [3:0]
\r
3017 pCoexSta->btInfoC2h[rspSource][2]&0xf;
\r
3019 pCoexSta->btRssi =
\r
3020 pCoexSta->btInfoC2h[rspSource][3]*2+10;
\r
3022 pCoexSta->btInfoExt =
\r
3023 pCoexSta->btInfoC2h[rspSource][4];
\r
3025 // Here we need to resend some wifi info to BT
\r
3026 // because bt is reset and loss of the info.
\r
3027 if( (pCoexSta->btInfoExt & BIT1) )
\r
3029 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
\r
3030 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
3031 if(bWifiConnected)
\r
3033 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
\r
3037 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
3043 // test-chip bt patch only rsp the status for BT_RSP,
\r
3044 // so temporary we consider the following only under BT_RSP
\r
3045 if(BT_INFO_SRC_8192E_1ANT_BT_RSP == rspSource)
\r
3047 if( (pCoexSta->btInfoExt & BIT3) )
\r
3049 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
\r
3050 halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
3054 // BT already NOT ignore Wlan active, do nothing here.
\r
3056 #if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0)
\r
3057 if( (pCoexSta->btInfoExt & BIT4) )
\r
3059 // BT auto report already enabled, do nothing
\r
3063 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit4 check, set BT to enable Auto Report!!\n"));
\r
3064 halbtc8192e1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);
\r
3070 // check BIT2 first ==> check if bt is under inquiry or page scan
\r
3071 if(btInfo & BT_INFO_8192E_1ANT_B_INQ_PAGE)
\r
3072 pCoexSta->bC2hBtInquiryPage = TRUE;
\r
3074 pCoexSta->bC2hBtInquiryPage = FALSE;
\r
3076 // set link exist status
\r
3077 if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION))
\r
3079 pCoexSta->bBtLinkExist = FALSE;
\r
3080 pCoexSta->bPanExist = FALSE;
\r
3081 pCoexSta->bA2dpExist = FALSE;
\r
3082 pCoexSta->bHidExist = FALSE;
\r
3083 pCoexSta->bScoExist = FALSE;
\r
3085 else // connection exists
\r
3087 pCoexSta->bBtLinkExist = TRUE;
\r
3088 if(btInfo & BT_INFO_8192E_1ANT_B_FTP)
\r
3089 pCoexSta->bPanExist = TRUE;
\r
3091 pCoexSta->bPanExist = FALSE;
\r
3092 if(btInfo & BT_INFO_8192E_1ANT_B_A2DP)
\r
3093 pCoexSta->bA2dpExist = TRUE;
\r
3095 pCoexSta->bA2dpExist = FALSE;
\r
3096 if(btInfo & BT_INFO_8192E_1ANT_B_HID)
\r
3097 pCoexSta->bHidExist = TRUE;
\r
3099 pCoexSta->bHidExist = FALSE;
\r
3100 if(btInfo & BT_INFO_8192E_1ANT_B_SCO_ESCO)
\r
3101 pCoexSta->bScoExist = TRUE;
\r
3103 pCoexSta->bScoExist = FALSE;
\r
3106 halbtc8192e1ant_UpdateBtLinkInfo(pBtCoexist);
\r
3108 if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION))
\r
3110 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
\r
3111 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-connected idle!!!\n"));
\r
3113 else if(btInfo == BT_INFO_8192E_1ANT_B_CONNECTION) // connection exists but no busy
\r
3115 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE;
\r
3116 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt connected-idle!!!\n"));
\r
3118 else if((btInfo&BT_INFO_8192E_1ANT_B_SCO_ESCO) ||
\r
3119 (btInfo&BT_INFO_8192E_1ANT_B_SCO_BUSY))
\r
3121 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_SCO_BUSY;
\r
3122 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt sco busy!!!\n"));
\r
3124 else if( (btInfo&BT_INFO_8192E_1ANT_B_ACL_BUSY) ||
\r
3125 (btInfo&BT_INFO_8192E_1ANT_B_A2DP) ||
\r
3126 (btInfo&BT_INFO_8192E_1ANT_B_FTP) )
\r
3128 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
\r
3129 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
3130 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_ACL_BUSY;
\r
3131 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt acl busy!!!\n"));
\r
3135 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_MAX;
\r
3136 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-defined state!!!\n"));
\r
3140 if(pBtLinkInfo->bScoExist || pBtLinkInfo->bHidExist)
\r
3142 halbtc8192e1ant_UpdateRaMask(pBtCoexist, NORMAL_EXEC, BTC_RATE_DISABLE, 0x00000003); // disable tx cck 1M/2M
\r
3146 halbtc8192e1ant_UpdateRaMask(pBtCoexist, NORMAL_EXEC, BTC_RATE_ENABLE, 0x00000003); // enable tx cck 1M/2M
\r
3149 if( (BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
3150 (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
3151 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
3154 if(pBtLinkInfo->bHidExist)
\r
3155 bBtCtrlAggBufSize = TRUE;
\r
3161 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
3163 //============================================
\r
3164 // Aggregation related setting
\r
3165 //============================================
\r
3166 // if sco, reject AddBA
\r
3167 //pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejApAggPkt);
\r
3169 // decide BT control aggregation buf size or not
\r
3170 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlAggBufSize);
\r
3171 // real update aggregation setting
\r
3172 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
\r
3173 //============================================
\r
3175 halbtc8192e1ant_RunCoexistMechanism(pBtCoexist);
\r
3179 EXhalbtc8192e1ant_HaltNotify(
\r
3180 IN PBTC_COEXIST pBtCoexist
\r
3183 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
\r
3185 pBtCoexist->bStopCoexDm = TRUE;
\r
3186 halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
3188 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3190 halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
3192 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
3196 EXhalbtc8192e1ant_PnpNotify(
\r
3197 IN PBTC_COEXIST pBtCoexist,
\r
3198 IN u1Byte pnpState
\r
3201 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
\r
3203 if(BTC_WIFI_PNP_SLEEP == pnpState)
\r
3205 pBtCoexist->bStopCoexDm = TRUE;
\r
3206 halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
3207 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3208 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
3210 else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
\r
3217 EXhalbtc8192e1ant_Periodical(
\r
3218 IN PBTC_COEXIST pBtCoexist
\r
3221 static u1Byte disVerInfoCnt=0;
\r
3222 u4Byte fwVer=0, btPatchVer=0;
\r
3223 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
3224 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
3226 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical===========================\n"));
\r
3228 if(disVerInfoCnt <= 5)
\r
3230 disVerInfoCnt += 1;
\r
3231 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
3232 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", \
\r
3233 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));
\r
3234 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", \
\r
3235 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
\r
3236 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
3237 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
3238 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
\r
3239 GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer));
\r
3240 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
3242 #if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0)
\r
3243 halbtc8192e1ant_QueryBtInfo(pBtCoexist);
\r
3244 halbtc8192e1ant_MonitorBtCtr(pBtCoexist);
\r
3245 halbtc8192e1ant_MonitorBtEnableDisable(pBtCoexist);
\r
3247 if( halbtc8192e1ant_IsWifiStatusChanged(pBtCoexist) ||
\r
3248 pCoexDm->bAutoTdmaAdjust)
\r
3250 halbtc8192e1ant_RunCoexistMechanism(pBtCoexist);
\r
3256 EXhalbtc8192e1ant_DbgControl(
\r
3257 IN PBTC_COEXIST pBtCoexist,
\r
3265 case BTC_DBG_SET_COEX_NORMAL:
\r
3266 pBtCoexist->bManualControl = FALSE;
\r
3267 halbtc8192e1ant_InitCoexDm(pBtCoexist);
\r
3269 case BTC_DBG_SET_COEX_WIFI_ONLY:
\r
3270 pBtCoexist->bManualControl = TRUE;
\r
3271 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3272 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
3274 case BTC_DBG_SET_COEX_BT_ONLY:
\r