1 //============================================================
4 // This file is for 8192e1ant Co-exist mechanism
7 // 2012/11/15 Cosa first check in.
9 //============================================================
11 //============================================================
13 //============================================================
14 #include "Mp_Precomp.h"
15 #if(BT_30_SUPPORT == 1)
16 //============================================================
17 // Global variables, these are static variables
18 //============================================================
19 static COEX_DM_8192E_1ANT GLCoexDm8192e1Ant;
20 static PCOEX_DM_8192E_1ANT pCoexDm=&GLCoexDm8192e1Ant;
21 static COEX_STA_8192E_1ANT GLCoexSta8192e1Ant;
22 static PCOEX_STA_8192E_1ANT pCoexSta=&GLCoexSta8192e1Ant;
24 const char *const GLBtInfoSrc8192e1Ant[]={
27 "BT Info[bt auto report]",
30 u4Byte GLCoexVerDate8192e1Ant=20130729;
31 u4Byte GLCoexVer8192e1Ant=0x10;
33 //============================================================
34 // local function proto type if needed
35 //============================================================
36 //============================================================
37 // local function start with halbtc8192e1ant_
38 //============================================================
40 halbtc8192e1ant_BtRssiState(
47 u1Byte btRssiState=pCoexSta->preBtRssiState;
49 btRssi = pCoexSta->btRssi;
53 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
54 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
56 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
58 btRssiState = BTC_RSSI_STATE_HIGH;
59 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
63 btRssiState = BTC_RSSI_STATE_STAY_LOW;
64 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
69 if(btRssi < rssiThresh)
71 btRssiState = BTC_RSSI_STATE_LOW;
72 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
76 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
77 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
81 else if(levelNum == 3)
83 if(rssiThresh > rssiThresh1)
85 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
86 return pCoexSta->preBtRssiState;
89 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
90 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
92 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
94 btRssiState = BTC_RSSI_STATE_MEDIUM;
95 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
99 btRssiState = BTC_RSSI_STATE_STAY_LOW;
100 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
103 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
104 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
106 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
108 btRssiState = BTC_RSSI_STATE_HIGH;
109 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
111 else if(btRssi < rssiThresh)
113 btRssiState = BTC_RSSI_STATE_LOW;
114 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
118 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
119 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
124 if(btRssi < rssiThresh1)
126 btRssiState = BTC_RSSI_STATE_MEDIUM;
127 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
131 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
132 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
137 pCoexSta->preBtRssiState = btRssiState;
143 halbtc8192e1ant_WifiRssiState(
144 IN PBTC_COEXIST pBtCoexist,
147 IN u1Byte rssiThresh,
148 IN u1Byte rssiThresh1
152 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
154 pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
158 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
159 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
161 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
163 wifiRssiState = BTC_RSSI_STATE_HIGH;
164 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
168 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
169 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
174 if(wifiRssi < rssiThresh)
176 wifiRssiState = BTC_RSSI_STATE_LOW;
177 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
181 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
182 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
186 else if(levelNum == 3)
188 if(rssiThresh > rssiThresh1)
190 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
191 return pCoexSta->preWifiRssiState[index];
194 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
195 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
197 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
199 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
200 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
204 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
205 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
208 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
209 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
211 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
213 wifiRssiState = BTC_RSSI_STATE_HIGH;
214 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
216 else if(wifiRssi < rssiThresh)
218 wifiRssiState = BTC_RSSI_STATE_LOW;
219 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
223 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
224 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
229 if(wifiRssi < rssiThresh1)
231 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
232 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
236 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
237 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
242 pCoexSta->preWifiRssiState[index] = wifiRssiState;
244 return wifiRssiState;
248 halbtc8192e1ant_Updatera_mask(
249 IN PBTC_COEXIST pBtCoexist,
250 IN BOOLEAN bForceExec,
255 if(BTC_RATE_DISABLE == type)
257 pCoexDm->curra_mask |= rateMask; // disable rate
259 else if(BTC_RATE_ENABLE == type)
261 pCoexDm->curra_mask &= ~rateMask; // enable rate
264 if( bForceExec || (pCoexDm->prera_mask != pCoexDm->curra_mask))
266 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_UPDATE_ra_mask, &pCoexDm->curra_mask);
268 pCoexDm->prera_mask = pCoexDm->curra_mask;
272 halbtc8192e1ant_MonitorBtCtr(
273 IN PBTC_COEXIST pBtCoexist
276 u4Byte regHPTxRx, regLPTxRx, u4Tmp;
277 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
283 u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regHPTxRx);
284 regHPTx = u4Tmp & MASKLWORD;
285 regHPRx = (u4Tmp & MASKHWORD)>>16;
287 u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regLPTxRx);
288 regLPTx = u4Tmp & MASKLWORD;
289 regLPRx = (u4Tmp & MASKHWORD)>>16;
291 pCoexSta->highPriorityTx = regHPTx;
292 pCoexSta->highPriorityRx = regHPRx;
293 pCoexSta->lowPriorityTx = regLPTx;
294 pCoexSta->lowPriorityRx = regLPRx;
296 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
297 regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
298 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
299 regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
302 pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0xc);
306 halbtc8192e1ant_QueryBtInfo(
307 IN PBTC_COEXIST pBtCoexist
310 u1Byte H2C_Parameter[1] ={0};
312 pCoexSta->bC2hBtInfoReqSent = true;
314 H2C_Parameter[0] |= BIT0; // trigger
316 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
319 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x61, 1, H2C_Parameter);
323 halbtc8192e1ant_IsWifiStatusChanged(
324 IN PBTC_COEXIST pBtCoexist
327 static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;
328 BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;
329 BOOLEAN bWifiConnected=FALSE;
331 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
332 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
333 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
334 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
338 if(bWifiBusy != bPreWifiBusy)
340 bPreWifiBusy = bWifiBusy;
343 if(bUnder4way != bPreUnder4way)
345 bPreUnder4way = bUnder4way;
348 if(bBtHsOn != bPreBtHsOn)
350 bPreBtHsOn = bBtHsOn;
359 halbtc8192e1ant_UpdateBtLinkInfo(
360 IN PBTC_COEXIST pBtCoexist
363 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
365 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
366 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
367 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
368 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
369 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
372 if( pBtLinkInfo->bScoExist &&
373 !pBtLinkInfo->bA2dpExist &&
374 !pBtLinkInfo->bPanExist &&
375 !pBtLinkInfo->bHidExist )
376 pBtLinkInfo->bScoOnly = true;
378 pBtLinkInfo->bScoOnly = FALSE;
380 // check if A2dp only
381 if( !pBtLinkInfo->bScoExist &&
382 pBtLinkInfo->bA2dpExist &&
383 !pBtLinkInfo->bPanExist &&
384 !pBtLinkInfo->bHidExist )
385 pBtLinkInfo->bA2dpOnly = true;
387 pBtLinkInfo->bA2dpOnly = FALSE;
390 if( !pBtLinkInfo->bScoExist &&
391 !pBtLinkInfo->bA2dpExist &&
392 pBtLinkInfo->bPanExist &&
393 !pBtLinkInfo->bHidExist )
394 pBtLinkInfo->bPanOnly = true;
396 pBtLinkInfo->bPanOnly = FALSE;
399 if( !pBtLinkInfo->bScoExist &&
400 !pBtLinkInfo->bA2dpExist &&
401 !pBtLinkInfo->bPanExist &&
402 pBtLinkInfo->bHidExist )
403 pBtLinkInfo->bHidOnly = true;
405 pBtLinkInfo->bHidOnly = FALSE;
409 halbtc8192e1ant_ActionAlgorithm(
410 IN PBTC_COEXIST pBtCoexist
413 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
414 BOOLEAN bBtHsOn=FALSE;
415 u1Byte algorithm=BT_8192E_1ANT_COEX_ALGO_UNDEFINED;
416 u1Byte numOfDiffProfile=0;
418 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
420 if(!pBtLinkInfo->bBtLinkExist)
422 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n"));
426 if(pBtLinkInfo->bScoExist)
428 if(pBtLinkInfo->bHidExist)
430 if(pBtLinkInfo->bPanExist)
432 if(pBtLinkInfo->bA2dpExist)
435 if(numOfDiffProfile == 1)
437 if(pBtLinkInfo->bScoExist)
439 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n"));
440 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
444 if(pBtLinkInfo->bHidExist)
446 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
447 algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
449 else if(pBtLinkInfo->bA2dpExist)
451 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
452 algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP;
454 else if(pBtLinkInfo->bPanExist)
458 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
459 algorithm = BT_8192E_1ANT_COEX_ALGO_PANHS;
463 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
464 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR;
469 else if(numOfDiffProfile == 2)
471 if(pBtLinkInfo->bScoExist)
473 if(pBtLinkInfo->bHidExist)
475 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n"));
476 algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
478 else if(pBtLinkInfo->bA2dpExist)
480 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n"));
481 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
483 else if(pBtLinkInfo->bPanExist)
487 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
488 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
492 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
493 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
499 if( pBtLinkInfo->bHidExist &&
500 pBtLinkInfo->bA2dpExist )
502 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
503 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
505 else if( pBtLinkInfo->bHidExist &&
506 pBtLinkInfo->bPanExist )
510 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
511 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
515 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
516 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
519 else if( pBtLinkInfo->bPanExist &&
520 pBtLinkInfo->bA2dpExist )
524 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
525 algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS;
529 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
530 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP;
535 else if(numOfDiffProfile == 3)
537 if(pBtLinkInfo->bScoExist)
539 if( pBtLinkInfo->bHidExist &&
540 pBtLinkInfo->bA2dpExist )
542 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP ==> HID\n"));
543 algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
545 else if( pBtLinkInfo->bHidExist &&
546 pBtLinkInfo->bPanExist )
550 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(HS)\n"));
551 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
555 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
556 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
559 else if( pBtLinkInfo->bPanExist &&
560 pBtLinkInfo->bA2dpExist )
564 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
565 algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
569 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
570 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
576 if( pBtLinkInfo->bHidExist &&
577 pBtLinkInfo->bPanExist &&
578 pBtLinkInfo->bA2dpExist )
582 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
583 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
587 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
588 algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
593 else if(numOfDiffProfile >= 3)
595 if(pBtLinkInfo->bScoExist)
597 if( pBtLinkInfo->bHidExist &&
598 pBtLinkInfo->bPanExist &&
599 pBtLinkInfo->bA2dpExist )
603 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
608 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
609 algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
619 halbtc8192e1ant_SetFwDacSwingLevel(
620 IN PBTC_COEXIST pBtCoexist,
621 IN u1Byte dacSwingLvl
624 u1Byte H2C_Parameter[1] ={0};
626 // There are several type of dacswing
627 // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
628 H2C_Parameter[0] = dacSwingLvl;
630 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl));
631 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0]));
633 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x64, 1, H2C_Parameter);
637 halbtc8192e1ant_SetFwDecBtPwr(
638 IN PBTC_COEXIST pBtCoexist,
639 IN u1Byte decBtPwrLvl
642 u1Byte H2C_Parameter[1] ={0};
644 H2C_Parameter[0] = decBtPwrLvl;
646 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n",
647 decBtPwrLvl, H2C_Parameter[0]));
649 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x62, 1, H2C_Parameter);
653 halbtc8192e1ant_DecBtPwr(
654 IN PBTC_COEXIST pBtCoexist,
655 IN BOOLEAN bForceExec,
656 IN u1Byte decBtPwrLvl
659 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s Dec BT power level = %d\n",
660 (bForceExec? "force to":""), decBtPwrLvl));
661 pCoexDm->curBtDecPwrLvl = decBtPwrLvl;
665 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], BtDecPwrLvl=%d, curBtDecPwrLvl=%d\n",
666 pCoexDm->preBtDecPwrLvl, pCoexDm->curBtDecPwrLvl));
668 if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl)
671 halbtc8192e1ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
673 pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
677 halbtc8192e1ant_SetFwBtLnaConstrain(
678 IN PBTC_COEXIST pBtCoexist,
679 IN BOOLEAN bBtLnaConsOn
682 u1Byte H2C_Parameter[2] ={0};
684 H2C_Parameter[0] = 0x3; // opCode, 0x3=BT_SET_LNA_CONSTRAIN
688 H2C_Parameter[1] |= BIT0;
691 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set BT LNA Constrain: %s, FW write 0x69=0x%x\n",
692 (bBtLnaConsOn? "ON!!":"OFF!!"),
693 H2C_Parameter[0]<<8|H2C_Parameter[1]));
695 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x69, 2, H2C_Parameter);
699 halbtc8192e1ant_SetBtLnaConstrain(
700 IN PBTC_COEXIST pBtCoexist,
701 IN BOOLEAN bForceExec,
702 IN BOOLEAN bBtLnaConsOn
705 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Constrain = %s\n",
706 (bForceExec? "force":""), ((bBtLnaConsOn)? "ON":"OFF")));
707 pCoexDm->bCurBtLnaConstrain = bBtLnaConsOn;
711 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtLnaConstrain=%d, bCurBtLnaConstrain=%d\n",
712 pCoexDm->bPreBtLnaConstrain, pCoexDm->bCurBtLnaConstrain));
714 if(pCoexDm->bPreBtLnaConstrain == pCoexDm->bCurBtLnaConstrain)
717 halbtc8192e1ant_SetFwBtLnaConstrain(pBtCoexist, pCoexDm->bCurBtLnaConstrain);
719 pCoexDm->bPreBtLnaConstrain = pCoexDm->bCurBtLnaConstrain;
723 halbtc8192e1ant_SetFwBtPsdMode(
724 IN PBTC_COEXIST pBtCoexist,
728 u1Byte H2C_Parameter[2] ={0};
730 H2C_Parameter[0] = 0x2; // opCode, 0x2=BT_SET_PSD_MODE
732 H2C_Parameter[1] = btPsdMode;
734 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set BT PSD mode=0x%x, FW write 0x69=0x%x\n",
736 H2C_Parameter[0]<<8|H2C_Parameter[1]));
738 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x69, 2, H2C_Parameter);
743 halbtc8192e1ant_SetBtPsdMode(
744 IN PBTC_COEXIST pBtCoexist,
745 IN BOOLEAN bForceExec,
749 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT PSD mode = 0x%x\n",
750 (bForceExec? "force":""), btPsdMode));
751 pCoexDm->bCurBtPsdMode = btPsdMode;
755 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtPsdMode=0x%x, bCurBtPsdMode=0x%x\n",
756 pCoexDm->bPreBtPsdMode, pCoexDm->bCurBtPsdMode));
758 if(pCoexDm->bPreBtPsdMode == pCoexDm->bCurBtPsdMode)
761 halbtc8192e1ant_SetFwBtPsdMode(pBtCoexist, pCoexDm->bCurBtPsdMode);
763 pCoexDm->bPreBtPsdMode = pCoexDm->bCurBtPsdMode;
768 halbtc8192e1ant_SetBtAutoReport(
769 IN PBTC_COEXIST pBtCoexist,
770 IN BOOLEAN bEnableAutoReport
773 u1Byte H2C_Parameter[1] ={0};
775 H2C_Parameter[0] = 0;
777 if(bEnableAutoReport)
779 H2C_Parameter[0] |= BIT0;
782 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
783 (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));
785 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x68, 1, H2C_Parameter);
789 halbtc8192e1ant_BtAutoReport(
790 IN PBTC_COEXIST pBtCoexist,
791 IN BOOLEAN bForceExec,
792 IN BOOLEAN bEnableAutoReport
795 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Auto report = %s\n",
796 (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
797 pCoexDm->bCurBtAutoReport = bEnableAutoReport;
801 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
802 pCoexDm->bPreBtAutoReport, pCoexDm->bCurBtAutoReport));
804 if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
807 halbtc8192e1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
809 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
813 halbtc8192e1ant_FwDacSwingLvl(
814 IN PBTC_COEXIST pBtCoexist,
815 IN BOOLEAN bForceExec,
816 IN u1Byte fwDacSwingLvl
819 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set FW Dac Swing level = %d\n",
820 (bForceExec? "force to":""), fwDacSwingLvl));
821 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
825 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preFwDacSwingLvl=%d, curFwDacSwingLvl=%d\n",
826 pCoexDm->preFwDacSwingLvl, pCoexDm->curFwDacSwingLvl));
828 if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
832 halbtc8192e1ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
834 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
838 halbtc8192e1ant_SetSwRfRxLpfCorner(
839 IN PBTC_COEXIST pBtCoexist,
840 IN BOOLEAN bRxRfShrinkOn
845 //Shrink RF Rx LPF corner
846 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
847 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7);
851 //Resume RF Rx LPF corner
852 // After initialized, we can use pCoexDm->btRf0x1eBackup
853 if(pBtCoexist->initilized)
855 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
856 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
862 halbtc8192e1ant_RfShrink(
863 IN PBTC_COEXIST pBtCoexist,
864 IN BOOLEAN bForceExec,
865 IN BOOLEAN bRxRfShrinkOn
868 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
869 (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
870 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
874 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n",
875 pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink));
877 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
880 halbtc8192e1ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
882 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
886 halbtc8192e1ant_SetSwPenaltyTxRateAdaptive(
887 IN PBTC_COEXIST pBtCoexist,
888 IN BOOLEAN bLowPenaltyRa
893 tmpU1 = pBtCoexist->btc_read_1byte(pBtCoexist, 0x4fd);
897 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
902 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
906 pBtCoexist->btc_write_1byte(pBtCoexist, 0x4fd, tmpU1);
910 halbtc8192e1ant_LowPenaltyRa(
911 IN PBTC_COEXIST pBtCoexist,
912 IN BOOLEAN bForceExec,
913 IN BOOLEAN bLowPenaltyRa
917 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
918 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
919 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
923 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
924 pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
926 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
929 halbtc8192e1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
931 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
935 halbtc8192e1ant_SetDacSwingReg(
936 IN PBTC_COEXIST pBtCoexist,
940 u1Byte val=(u1Byte)level;
942 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Write SwDacSwing = 0x%x\n", level));
943 pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0x883, 0x3e, val);
947 halbtc8192e1ant_SetSwFullTimeDacSwing(
948 IN PBTC_COEXIST pBtCoexist,
949 IN BOOLEAN bSwDacSwingOn,
950 IN u4Byte swDacSwingLvl
955 halbtc8192e1ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
959 halbtc8192e1ant_SetDacSwingReg(pBtCoexist, 0x18);
965 halbtc8192e1ant_DacSwing(
966 IN PBTC_COEXIST pBtCoexist,
967 IN BOOLEAN bForceExec,
968 IN BOOLEAN bDacSwingOn,
969 IN u4Byte dacSwingLvl
972 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
973 (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
974 pCoexDm->bCurDacSwingOn = bDacSwingOn;
975 pCoexDm->curDacSwingLvl = dacSwingLvl;
979 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
980 pCoexDm->bPreDacSwingOn, pCoexDm->preDacSwingLvl,
981 pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl));
983 if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
984 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
988 halbtc8192e1ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
990 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
991 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
995 halbtc8192e1ant_SetAdcBackOff(
996 IN PBTC_COEXIST pBtCoexist,
997 IN BOOLEAN bAdcBackOff
1002 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level On!\n"));
1003 pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0x8db, 0x60, 0x3);
1007 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level Off!\n"));
1008 pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0x8db, 0x60, 0x1);
1013 halbtc8192e1ant_AdcBackOff(
1014 IN PBTC_COEXIST pBtCoexist,
1015 IN BOOLEAN bForceExec,
1016 IN BOOLEAN bAdcBackOff
1019 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn AdcBackOff = %s\n",
1020 (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));
1021 pCoexDm->bCurAdcBackOff = bAdcBackOff;
1025 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n",
1026 pCoexDm->bPreAdcBackOff, pCoexDm->bCurAdcBackOff));
1028 if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff)
1031 halbtc8192e1ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
1033 pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
1037 halbtc8192e1ant_SetAgcTable(
1038 IN PBTC_COEXIST pBtCoexist,
1039 IN BOOLEAN bAgcTableEn
1042 u1Byte rssiAdjustVal=0;
1044 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
1047 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
1048 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x3fa58);
1049 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x37a58);
1050 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x2fa58);
1055 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
1056 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x39258);
1057 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x31258);
1058 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x29258);
1060 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
1062 // set rssiAdjustVal for wifi module.
1063 pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
1068 halbtc8192e1ant_AgcTable(
1069 IN PBTC_COEXIST pBtCoexist,
1070 IN BOOLEAN bForceExec,
1071 IN BOOLEAN bAgcTableEn
1074 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s %s Agc Table\n",
1075 (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));
1076 pCoexDm->bCurAgcTableEn = bAgcTableEn;
1080 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
1081 pCoexDm->bPreAgcTableEn, pCoexDm->bCurAgcTableEn));
1083 if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
1086 halbtc8192e1ant_SetAgcTable(pBtCoexist, bAgcTableEn);
1088 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
1092 halbtc8192e1ant_SetCoexTable(
1093 IN PBTC_COEXIST pBtCoexist,
1100 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
1101 pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c0, val0x6c0);
1103 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
1104 pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c4, val0x6c4);
1106 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
1107 pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c8, val0x6c8);
1109 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
1110 pBtCoexist->btc_write_1byte(pBtCoexist, 0x6cc, val0x6cc);
1114 halbtc8192e1ant_CoexTable(
1115 IN PBTC_COEXIST pBtCoexist,
1116 IN BOOLEAN bForceExec,
1123 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",
1124 (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc));
1125 pCoexDm->curVal0x6c0 = val0x6c0;
1126 pCoexDm->curVal0x6c4 = val0x6c4;
1127 pCoexDm->curVal0x6c8 = val0x6c8;
1128 pCoexDm->curVal0x6cc = val0x6cc;
1132 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c4=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
1133 pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
1134 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
1135 pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
1137 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
1138 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
1139 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
1140 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
1143 halbtc8192e1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
1145 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
1146 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
1147 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
1148 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
1152 halbtc8192e1ant_CoexTableWithType(
1153 IN PBTC_COEXIST pBtCoexist,
1154 IN BOOLEAN bForceExec,
1161 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);
1164 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
1167 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);
1170 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
1173 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffffff, 0x3);
1176 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3);
1179 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3);
1182 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xddffddff, 0xddffddff, 0xffffff, 0x3);
1185 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5afa5afa, 0xffffff, 0x3);
1188 halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5f5f5f5f, 0x5f5f5f5f, 0xffffff, 0x3);
1196 halbtc8192e1ant_SetFwIgnoreWlanAct(
1197 IN PBTC_COEXIST pBtCoexist,
1201 u1Byte H2C_Parameter[1] ={0};
1205 H2C_Parameter[0] |= BIT0; // function enable
1208 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
1211 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x63, 1, H2C_Parameter);
1215 halbtc8192e1ant_IgnoreWlanAct(
1216 IN PBTC_COEXIST pBtCoexist,
1217 IN BOOLEAN bForceExec,
1221 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
1222 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
1223 pCoexDm->bCurIgnoreWlanAct = bEnable;
1227 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
1228 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
1230 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
1233 halbtc8192e1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
1235 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
1239 halbtc8192e1ant_SetFwPstdma(
1240 IN PBTC_COEXIST pBtCoexist,
1248 u1Byte H2C_Parameter[5] ={0};
1250 H2C_Parameter[0] = byte1;
1251 H2C_Parameter[1] = byte2;
1252 H2C_Parameter[2] = byte3;
1253 H2C_Parameter[3] = byte4;
1254 H2C_Parameter[4] = byte5;
1256 pCoexDm->psTdmaPara[0] = byte1;
1257 pCoexDm->psTdmaPara[1] = byte2;
1258 pCoexDm->psTdmaPara[2] = byte3;
1259 pCoexDm->psTdmaPara[3] = byte4;
1260 pCoexDm->psTdmaPara[4] = byte5;
1262 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n",
1264 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
1266 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x60, 5, H2C_Parameter);
1270 halbtc8192e1ant_SetLpsRpwm(
1271 IN PBTC_COEXIST pBtCoexist,
1277 u1Byte rpwm=rpwmVal;
1279 pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_1ANT_LPS, &lps);
1280 pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_1ANT_RPWM, &rpwm);
1284 halbtc8192e1ant_LpsRpwm(
1285 IN PBTC_COEXIST pBtCoexist,
1286 IN BOOLEAN bForceExec,
1291 BOOLEAN bForceExecPwrCmd=FALSE;
1293 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
1294 (bForceExec? "force to":""), lpsVal, rpwmVal));
1295 pCoexDm->curLps = lpsVal;
1296 pCoexDm->curRpwm = rpwmVal;
1300 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preLps/curLps=0x%x/0x%x, preRpwm/curRpwm=0x%x/0x%x!!\n",
1301 pCoexDm->preLps, pCoexDm->curLps, pCoexDm->preRpwm, pCoexDm->curRpwm));
1303 if( (pCoexDm->preLps == pCoexDm->curLps) &&
1304 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
1309 halbtc8192e1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
1311 pCoexDm->preLps = pCoexDm->curLps;
1312 pCoexDm->preRpwm = pCoexDm->curRpwm;
1316 halbtc8192e1ant_SwMechanism1(
1317 IN PBTC_COEXIST pBtCoexist,
1318 IN BOOLEAN bShrinkRxLPF,
1319 IN BOOLEAN bLowPenaltyRA,
1320 IN BOOLEAN limited_dig,
1321 IN BOOLEAN bBTLNAConstrain
1324 //halbtc8192e1ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);
1325 //halbtc8192e1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
1328 //halbtc8192e1ant_SetBtLnaConstrain(pBtCoexist, NORMAL_EXEC, bBTLNAConstrain);
1332 halbtc8192e1ant_SwMechanism2(
1333 IN PBTC_COEXIST pBtCoexist,
1334 IN BOOLEAN bAGCTableShift,
1335 IN BOOLEAN bADCBackOff,
1336 IN BOOLEAN bSWDACSwing,
1337 IN u4Byte dacSwingLvl
1340 //halbtc8192e1ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);
1341 //halbtc8192e1ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff);
1342 //halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);
1346 halbtc8192e1ant_PsTdma(
1347 IN PBTC_COEXIST pBtCoexist,
1348 IN BOOLEAN bForceExec,
1353 BOOLEAN bTurnOnByCnt=FALSE;
1354 u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0;
1356 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
1357 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
1358 pCoexDm->bCurPsTdmaOn = bTurnOn;
1359 pCoexDm->curPsTdma = type;
1363 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
1364 pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn));
1365 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
1366 pCoexDm->prePsTdma, pCoexDm->curPsTdma));
1368 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
1369 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
1377 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x2c, 0x03, 0x10, 0x50);
1380 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x2c, 0x03, 0x10, 0x50);
1384 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x25, 0x03, 0x10, 0x50);
1388 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x40);
1391 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
1395 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x31, 0x0);
1398 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x0, 0x0);
1401 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
1404 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
1407 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1e, 0x03, 0x10, 0x50);
1411 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
1414 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x12, 0x03, 0x10, 0x50);
1418 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xeb, 0xa, 0x3, 0x31, 0x18);
1422 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0);
1425 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0);
1430 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
1435 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0x25, 0x25, 0x0, 0x0);
1438 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x20, 0x3, 0x10, 0x40);
1441 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0x8, 0x8, 0x0, 0x40);
1444 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);
1448 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);
1452 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
1456 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
1460 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);
1464 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0);
1467 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10);
1470 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
1473 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);
1476 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xab, 0xa, 0x3, 0x31, 0x90);
1479 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90);
1482 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x10);
1485 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x0, 0x10);
1488 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50);
1491 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x25, 0x3, 0x10, 0x50);
1494 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
1503 case 8: //0x778 = 1, ant2PTA
1504 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
1505 pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x4);
1507 case 0: //0x778 = 1, ant2BT
1509 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
1511 pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x20);
1513 case 9: //0x778 = 1, ant2WIFI
1514 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
1515 pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x4);
1517 case 10: //0x778 = 3, ant2BT
1518 halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
1520 pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x20);
1525 pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal);
1528 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1529 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1533 halbtc8192e1ant_SetSwitchSsType(
1534 IN PBTC_COEXIST pBtCoexist,
1538 u1Byte mimoPs=BTC_MIMO_PS_DYNAMIC;
1540 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], REAL set SS Type = %d\n", ssType));
1544 halbtc8192e1ant_Updatera_mask(pBtCoexist, FORCE_EXEC, BTC_RATE_DISABLE, 0xfff00000); // disable 2ss
1545 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
1547 pBtCoexist->btc_write_1byte(pBtCoexist, 0xc04, 0x11);
1548 pBtCoexist->btc_write_1byte(pBtCoexist, 0xd04, 0x1);
1549 pBtCoexist->btc_write_4byte(pBtCoexist, 0x90c, 0x81111111);
1551 pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0xe77, 0x4, 0x1);
1552 pBtCoexist->btc_write_1byte(pBtCoexist, 0xa07, 0x81);
1553 mimoPs=BTC_MIMO_PS_STATIC;
1555 else if(ssType == 2)
1557 halbtc8192e1ant_Updatera_mask(pBtCoexist, FORCE_EXEC, BTC_RATE_ENABLE, 0xfff00000); // enable 2ss
1558 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
1559 pBtCoexist->btc_write_1byte(pBtCoexist, 0xc04, 0x33);
1560 pBtCoexist->btc_write_1byte(pBtCoexist, 0xd04, 0x3);
1561 pBtCoexist->btc_write_4byte(pBtCoexist, 0x90c, 0x81121313);
1562 pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0xe77, 0x4, 0x0);
1563 pBtCoexist->btc_write_1byte(pBtCoexist, 0xa07, 0x41);
1564 mimoPs=BTC_MIMO_PS_DYNAMIC;
1567 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimoPs); // set rx 1ss or 2ss
1571 halbtc8192e1ant_SwitchSsType(
1572 IN PBTC_COEXIST pBtCoexist,
1573 IN BOOLEAN bForceExec,
1577 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], %s Switch SS Type = %d\n",
1578 (bForceExec? "force to":""), newSsType));
1579 pCoexDm->curSsType = newSsType;
1583 if(pCoexDm->preSsType == pCoexDm->curSsType)
1586 halbtc8192e1ant_SetSwitchSsType(pBtCoexist, pCoexDm->curSsType);
1588 pCoexDm->preSsType = pCoexDm->curSsType;
1592 halbtc8192e1ant_CoexAllOff(
1593 IN PBTC_COEXIST pBtCoexist
1596 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1599 halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
1600 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
1604 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1608 halbtc8192e1ant_IsCommonAction(
1609 IN PBTC_COEXIST pBtCoexist
1612 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
1614 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1615 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
1617 if(!bWifiConnected &&
1618 BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
1620 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));
1621 halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
1622 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
1626 else if(bWifiConnected &&
1627 (BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) )
1629 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
1630 halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
1631 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
1635 else if(!bWifiConnected &&
1636 (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
1638 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));
1639 halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
1640 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
1644 else if(bWifiConnected &&
1645 (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
1647 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
1648 halbtc8192e1ant_SwMechanism1(pBtCoexist,true,true,true,true);
1649 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
1653 else if(!bWifiConnected &&
1654 (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) )
1656 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
1657 halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
1658 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
1664 halbtc8192e1ant_SwMechanism1(pBtCoexist,true,true,true,true);
1674 halbtc8192e1ant_TdmaDurationAdjustForAcl(
1675 IN PBTC_COEXIST pBtCoexist,
1676 IN u1Byte wifiStatus
1679 static s4Byte up,dn,m,n,WaitCount;
1680 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
1681 u1Byte retryCount=0, btInfoExt;
1683 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjustForAcl()\n"));
1685 if( (BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
1686 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
1687 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
1689 if( pCoexDm->curPsTdma != 1 &&
1690 pCoexDm->curPsTdma != 2 &&
1691 pCoexDm->curPsTdma != 3 &&
1692 pCoexDm->curPsTdma != 9 )
1694 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1695 pCoexDm->psTdmaDuAdjType = 9;
1707 if(!pCoexDm->bAutoTdmaAdjust)
1709 pCoexDm->bAutoTdmaAdjust = true;
1710 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
1712 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1713 pCoexDm->psTdmaDuAdjType = 2;
1724 //accquire the BT TRx retry count from BT_Info byte2
1725 retryCount = pCoexSta->btRetryCnt;
1726 btInfoExt = pCoexSta->btInfoExt;
1727 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
1728 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
1729 up, dn, m, n, WaitCount));
1733 if(retryCount == 0) // no retry in the last 2-second duration
1741 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
1748 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
1751 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
1759 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
1762 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
1766 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
1774 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
1777 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
1780 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
1784 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
1792 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
1797 if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
1798 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
1800 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1801 pCoexDm->psTdmaDuAdjType = 9;
1803 else if(pCoexDm->curPsTdma == 1)
1805 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1806 pCoexDm->psTdmaDuAdjType = 2;
1808 else if(pCoexDm->curPsTdma == 2)
1810 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1811 pCoexDm->psTdmaDuAdjType = 9;
1813 else if(pCoexDm->curPsTdma == 9)
1815 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1816 pCoexDm->psTdmaDuAdjType = 11;
1819 else if(result == 1)
1821 if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
1822 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
1824 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1825 pCoexDm->psTdmaDuAdjType = 9;
1827 else if(pCoexDm->curPsTdma == 11)
1829 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1830 pCoexDm->psTdmaDuAdjType = 9;
1832 else if(pCoexDm->curPsTdma == 9)
1834 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1835 pCoexDm->psTdmaDuAdjType = 2;
1837 else if(pCoexDm->curPsTdma == 2)
1839 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1840 pCoexDm->psTdmaDuAdjType = 1;
1844 if( pCoexDm->curPsTdma != 1 &&
1845 pCoexDm->curPsTdma != 2 &&
1846 pCoexDm->curPsTdma != 9 &&
1847 pCoexDm->curPsTdma != 11 )
1849 // recover to previous adjust type
1850 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType);
1856 halbtc8192e1ant_PsTdmaTypeByWifiRssi(
1858 IN s4Byte preWifiRssi,
1859 IN u1Byte wifiRssiThresh
1862 u1Byte psTdmaType=0;
1864 if(wifiRssi > preWifiRssi)
1866 if(wifiRssi > (wifiRssiThresh+5))
1877 if(wifiRssi > wifiRssiThresh)
1891 halbtc8192e1ant_PsTdmaCheckForPowerSaveState(
1892 IN PBTC_COEXIST pBtCoexist,
1893 IN BOOLEAN bNewPsState
1898 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
1900 if(lpsMode) // already under LPS state
1904 // keep state under LPS, do nothing.
1908 // will leave LPS state, turn off psTdma first
1909 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1916 // will enter LPS state, turn off psTdma first
1917 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1921 // keep state under NO PS state, do nothing.
1927 halbtc8192e1ant_PowerSaveState(
1928 IN PBTC_COEXIST pBtCoexist,
1934 BOOLEAN bLowPwrDisable=FALSE;
1938 case BTC_PS_WIFI_NATIVE:
1939 // recover to original 32k low power setting
1940 bLowPwrDisable = FALSE;
1941 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1942 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
1945 halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, true);
1946 halbtc8192e1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
1947 // when coex force to enter LPS, do not enter 32k low power.
1948 bLowPwrDisable = true;
1949 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1950 // power save must executed before psTdma.
1951 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
1953 case BTC_PS_LPS_OFF:
1954 halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
1955 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
1964 halbtc8192e1ant_ActionWifiOnly(
1965 IN PBTC_COEXIST pBtCoexist
1968 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1969 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
1973 halbtc8192e1ant_MonitorBtEnableDisable(
1974 IN PBTC_COEXIST pBtCoexist
1977 static BOOLEAN bPreBtDisabled=FALSE;
1978 static u4Byte btDisableCnt=0;
1979 BOOLEAN bBtActive=true, bBtDisabled=FALSE;
1981 // This function check if bt is disabled
1983 if( pCoexSta->highPriorityTx == 0 &&
1984 pCoexSta->highPriorityRx == 0 &&
1985 pCoexSta->lowPriorityTx == 0 &&
1986 pCoexSta->lowPriorityRx == 0)
1990 if( pCoexSta->highPriorityTx == 0xffff &&
1991 pCoexSta->highPriorityRx == 0xffff &&
1992 pCoexSta->lowPriorityTx == 0xffff &&
1993 pCoexSta->lowPriorityRx == 0xffff)
2000 bBtDisabled = FALSE;
2001 pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
2002 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
2007 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
2009 if(btDisableCnt >= 2)
2012 pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
2013 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
2014 halbtc8192e1ant_ActionWifiOnly(pBtCoexist);
2017 if(bPreBtDisabled != bBtDisabled)
2019 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
2020 (bPreBtDisabled ? "disabled":"enabled"),
2021 (bBtDisabled ? "disabled":"enabled")));
2022 bPreBtDisabled = bBtDisabled;
2028 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
2029 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
2034 //=============================================
2036 // Software Coex Mechanism start
2038 //=============================================
2040 // SCO only or SCO+PAN(HS)
2042 halbtc8192e1ant_ActionSco(
2043 IN PBTC_COEXIST pBtCoexist
2046 u1Byte wifiRssiState;
2049 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2051 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2053 if(BTC_WIFI_BW_HT40 == wifiBw)
2056 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2057 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2059 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2063 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
2069 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2070 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2072 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2076 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2083 halbtc8192e1ant_ActionHid(
2084 IN PBTC_COEXIST pBtCoexist
2087 u1Byte wifiRssiState;
2090 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2092 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2094 if(BTC_WIFI_BW_HT40 == wifiBw)
2097 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2098 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2100 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,FALSE,FALSE,0x18);
2104 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2110 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2111 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2113 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2117 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2122 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
2124 halbtc8192e1ant_ActionA2dp(
2125 IN PBTC_COEXIST pBtCoexist
2128 u1Byte wifiRssiState;
2131 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2133 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2135 if(BTC_WIFI_BW_HT40 == wifiBw)
2138 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2139 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2141 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2145 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
2151 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2152 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2154 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2158 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2164 halbtc8192e1ant_ActionA2dpPanHs(
2165 IN PBTC_COEXIST pBtCoexist
2168 u1Byte wifiRssiState, btInfoExt;
2171 btInfoExt = pCoexSta->btInfoExt;
2172 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2174 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2176 if(BTC_WIFI_BW_HT40 == wifiBw)
2179 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2180 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2182 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2186 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
2192 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2193 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2195 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2199 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2205 halbtc8192e1ant_ActionPanEdr(
2206 IN PBTC_COEXIST pBtCoexist
2209 u1Byte wifiRssiState;
2212 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2214 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2216 if(BTC_WIFI_BW_HT40 == wifiBw)
2219 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2220 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2222 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2226 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
2232 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2233 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2235 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2239 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2247 halbtc8192e1ant_ActionPanHs(
2248 IN PBTC_COEXIST pBtCoexist
2251 u1Byte wifiRssiState;
2254 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2256 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2258 if(BTC_WIFI_BW_HT40 == wifiBw)
2261 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2262 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2264 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2268 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
2274 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2275 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2277 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2281 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2288 halbtc8192e1ant_ActionPanEdrA2dp(
2289 IN PBTC_COEXIST pBtCoexist
2292 u1Byte wifiRssiState, btInfoExt;
2295 btInfoExt = pCoexSta->btInfoExt;
2296 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2298 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2300 if(BTC_WIFI_BW_HT40 == wifiBw)
2303 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2304 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2306 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2310 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
2316 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2317 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2319 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2323 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2329 halbtc8192e1ant_ActionPanEdrHid(
2330 IN PBTC_COEXIST pBtCoexist
2333 u1Byte wifiRssiState;
2336 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2338 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2340 if(BTC_WIFI_BW_HT40 == wifiBw)
2343 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2344 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2346 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2350 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
2356 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2357 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2359 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2363 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2368 // HID+A2DP+PAN(EDR)
2370 halbtc8192e1ant_ActionHidA2dpPanEdr(
2371 IN PBTC_COEXIST pBtCoexist
2374 u1Byte wifiRssiState, btInfoExt;
2377 btInfoExt = pCoexSta->btInfoExt;
2378 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2380 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2382 if(BTC_WIFI_BW_HT40 == wifiBw)
2385 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2386 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2388 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2392 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
2398 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2399 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2401 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2405 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2411 halbtc8192e1ant_ActionHidA2dp(
2412 IN PBTC_COEXIST pBtCoexist
2415 u1Byte wifiRssiState, btInfoExt;
2418 btInfoExt = pCoexSta->btInfoExt;
2419 wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
2421 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2423 if(BTC_WIFI_BW_HT40 == wifiBw)
2426 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2427 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2429 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2433 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
2439 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2440 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2442 halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
2446 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2451 //=============================================
2453 // Non-Software Coex Mechanism start
2455 //=============================================
2457 halbtc8192e1ant_ActionBtInquiry(
2458 IN PBTC_COEXIST pBtCoexist
2461 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
2462 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
2465 // Do not do DacSwing here, use original setting.
2467 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2469 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
2475 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2477 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2479 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2480 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2482 else if( (pBtLinkInfo->bScoExist) ||
2483 (pBtLinkInfo->bHidOnly) )
2485 // SCO/HID-only busy
2486 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2488 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2490 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32);
2491 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
2495 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
2497 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2499 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 30);
2500 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2505 halbtc8192e1ant_ActionBtScoHidOnlyBusy(
2506 IN PBTC_COEXIST pBtCoexist,
2507 IN u1Byte wifiStatus
2510 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
2511 u1Byte btRssiState=BTC_RSSI_STATE_HIGH;
2513 if(BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus)
2515 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2516 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2518 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2519 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2523 if(pBtLinkInfo->bHidOnly)
2525 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2526 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2528 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2529 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2533 // dec bt power for diff level
2534 btRssiState = halbtc8192e1ant_BtRssiState(3, 34, 42);
2535 if( (btRssiState == BTC_RSSI_STATE_LOW) ||
2536 (btRssiState == BTC_RSSI_STATE_STAY_LOW) )
2538 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2540 else if( (btRssiState == BTC_RSSI_STATE_MEDIUM) ||
2541 (btRssiState == BTC_RSSI_STATE_STAY_MEDIUM) )
2543 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2545 else if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
2546 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2548 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 6);
2552 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, true, 0xc);
2554 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2555 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2561 halbtc8192e1ant_ActionHs(
2562 IN PBTC_COEXIST pBtCoexist
2565 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
2567 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action for HS!!!\n"));
2569 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2571 if(BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
2573 // error, should not be here
2574 pCoexDm->errorCondition = 1;
2576 else if(BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
2578 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2579 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, true, 6);
2581 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 10);
2582 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2584 else if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus &&
2585 !pBtCoexist->bt_link_info.bHidOnly)
2587 if(pCoexDm->curSsType == 1)
2589 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2590 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, true, 6);
2591 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 10);
2592 //halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 38);
2593 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2598 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
2599 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
2604 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(
2605 IN PBTC_COEXIST pBtCoexist,
2606 IN u1Byte wifiStatus
2609 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
2611 if(pBtLinkInfo->bHidOnly)
2613 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);
2614 pCoexDm->bAutoTdmaAdjust = FALSE;
2618 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2619 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2621 if( (pBtLinkInfo->bA2dpOnly) ||
2622 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) )
2624 halbtc8192e1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);
2626 else if( (pBtLinkInfo->bPanOnly) ||
2627 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) )
2629 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2630 pCoexDm->bAutoTdmaAdjust = FALSE;
2634 if( (BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
2635 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
2636 (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
2637 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
2639 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2640 pCoexDm->bAutoTdmaAdjust = FALSE;
2643 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
2648 halbtc8192e1ant_ActionWifiNotConnected(
2649 IN PBTC_COEXIST pBtCoexist
2653 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2655 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2656 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2658 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2659 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2663 halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(
2664 IN PBTC_COEXIST pBtCoexist
2667 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2669 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2670 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2672 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2673 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2677 halbtc8192e1ant_ActionWifiConnectedScan(
2678 IN PBTC_COEXIST pBtCoexist
2682 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->bt_link_info.bHidOnly)
2683 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
2685 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2687 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
2689 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
2690 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN);
2692 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2693 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
2695 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
2696 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN);
2700 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2701 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2702 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2703 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2709 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(
2710 IN PBTC_COEXIST pBtCoexist
2714 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->bt_link_info.bHidOnly)
2715 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
2717 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2719 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
2721 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
2722 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT);
2726 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2727 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2728 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2729 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2734 halbtc8192e1ant_ActionWifiConnected(
2735 IN PBTC_COEXIST pBtCoexist
2738 BOOLEAN bWifiConnected=FALSE, bWifiBusy=FALSE;
2739 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
2740 BOOLEAN bUnder4way=FALSE;
2743 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect()===>\n"));
2745 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2748 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi not connected<===\n"));
2752 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
2755 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
2756 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));
2760 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2761 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2762 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2763 if(bScan || bLink || bRoam)
2765 halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist);
2766 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));
2771 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->bt_link_info.bHidOnly)
2772 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
2774 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2776 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
2779 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
2781 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
2782 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE);
2784 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2785 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
2787 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
2788 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE);
2792 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2793 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2794 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2795 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2800 if(BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
2802 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2803 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2804 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
2805 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2807 else if(BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
2809 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2810 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2811 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
2812 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2814 else if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
2816 halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
2817 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
2819 else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
2820 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
2822 halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
2823 BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
2827 halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2828 halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2829 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
2830 halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2836 halbtc8192e1ant_RunSwCoexistMechanism(
2837 IN PBTC_COEXIST pBtCoexist
2840 BOOLEAN bWifiUnder5G=FALSE, bWifiBusy=FALSE, bWifiConnected=FALSE;
2841 u1Byte btInfoOriginal=0, btRetryCnt=0;
2846 algorithm = halbtc8192e1ant_ActionAlgorithm(pBtCoexist);
2847 pCoexDm->curAlgorithm = algorithm;
2849 if(halbtc8192e1ant_IsCommonAction(pBtCoexist))
2854 switch(pCoexDm->curAlgorithm)
2856 case BT_8192E_1ANT_COEX_ALGO_SCO:
2857 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n"));
2858 halbtc8192e1ant_ActionSco(pBtCoexist);
2860 case BT_8192E_1ANT_COEX_ALGO_HID:
2861 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n"));
2862 halbtc8192e1ant_ActionHid(pBtCoexist);
2864 case BT_8192E_1ANT_COEX_ALGO_A2DP:
2865 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n"));
2866 halbtc8192e1ant_ActionA2dp(pBtCoexist);
2868 case BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS:
2869 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
2870 halbtc8192e1ant_ActionA2dpPanHs(pBtCoexist);
2872 case BT_8192E_1ANT_COEX_ALGO_PANEDR:
2873 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
2874 halbtc8192e1ant_ActionPanEdr(pBtCoexist);
2876 case BT_8192E_1ANT_COEX_ALGO_PANHS:
2877 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n"));
2878 halbtc8192e1ant_ActionPanHs(pBtCoexist);
2880 case BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP:
2881 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
2882 halbtc8192e1ant_ActionPanEdrA2dp(pBtCoexist);
2884 case BT_8192E_1ANT_COEX_ALGO_PANEDR_HID:
2885 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
2886 halbtc8192e1ant_ActionPanEdrHid(pBtCoexist);
2888 case BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
2889 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
2890 halbtc8192e1ant_ActionHidA2dpPanEdr(pBtCoexist);
2892 case BT_8192E_1ANT_COEX_ALGO_HID_A2DP:
2893 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
2894 halbtc8192e1ant_ActionHidA2dp(pBtCoexist);
2897 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
2898 halbtc8192e1ant_CoexAllOff(pBtCoexist);
2901 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
2906 halbtc8192e1ant_RunCoexistMechanism(
2907 IN PBTC_COEXIST pBtCoexist
2910 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
2911 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
2913 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n"));
2915 if(pBtCoexist->manual_control)
2917 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
2921 if(pBtCoexist->bStopCoexDm)
2923 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
2927 if(pCoexSta->bUnderIps)
2929 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
2933 halbtc8192e1ant_RunSwCoexistMechanism(pBtCoexist);
2935 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
2936 if(pCoexSta->bC2hBtInquiryPage)
2938 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
2943 if(pBtLinkInfo->bScoExist)
2945 halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
2949 if(pBtLinkInfo->bHidOnly)
2950 halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2);
2952 halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
2955 halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2);
2959 halbtc8192e1ant_ActionHs(pBtCoexist);
2963 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2966 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
2968 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n"));
2970 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2971 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2972 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2974 if(bScan || bLink || bRoam)
2975 halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
2977 halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
2981 halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
2986 halbtc8192e1ant_InitCoexDm(
2987 IN PBTC_COEXIST pBtCoexist
2990 // force to reset coex mechanism
2991 halbtc8192e1ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
2992 halbtc8192e1ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
2995 halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
2996 halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2998 halbtc8192e1ant_SwitchSsType(pBtCoexist, FORCE_EXEC, 2);
3000 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
3001 halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
3004 //============================================================
3005 // work around function start with wa_halbtc8192e1ant_
3006 //============================================================
3007 //============================================================
3008 // extern function start with EXhalbtc8192e1ant_
3009 //============================================================
3011 EXhalbtc8192e1ant_InitHwConfig(
3012 IN PBTC_COEXIST pBtCoexist
3019 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
3021 // backup rf 0x1e value
3022 pCoexDm->btRf0x1eBackup =
3023 pBtCoexist->btc_get_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
3025 // antenna sw ctrl to bt
3026 pBtCoexist->btc_write_1byte(pBtCoexist, 0x4f, 0x6);
3027 pBtCoexist->btc_write_1byte(pBtCoexist, 0x944, 0x24);
3028 pBtCoexist->btc_write_4byte(pBtCoexist, 0x930, 0x700700);
3029 pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x20);
3030 if(pBtCoexist->chipInterface == BTC_INTF_USB)
3031 pBtCoexist->btc_write_4byte(pBtCoexist, 0x64, 0x30430004);
3033 pBtCoexist->btc_write_4byte(pBtCoexist, 0x64, 0x30030004);
3035 halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
3037 // antenna switch control parameter
3038 pBtCoexist->btc_write_4byte(pBtCoexist, 0x858, 0x55555555);
3041 pBtCoexist->btc_write_1byte(pBtCoexist, 0x778, 0x1);
3043 u1Tmp = pBtCoexist->btc_read_1byte(pBtCoexist, 0x790);
3046 pBtCoexist->btc_write_1byte(pBtCoexist, 0x790, u1Tmp);
3048 // enable counter statistics
3049 pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0x4);
3052 pBtCoexist->btc_write_1byte(pBtCoexist, 0x40, 0x20);
3053 // enable mailbox interface
3054 u2Tmp = pBtCoexist->btc_read_2byte(pBtCoexist, 0x40);
3056 pBtCoexist->btc_write_2byte(pBtCoexist, 0x40, u2Tmp);
3058 // enable PTA I2C mailbox
3059 u1Tmp = pBtCoexist->btc_read_1byte(pBtCoexist, 0x101);
3061 pBtCoexist->btc_write_1byte(pBtCoexist, 0x101, u1Tmp);
3063 // enable bt clock when wifi is disabled.
3064 u1Tmp = pBtCoexist->btc_read_1byte(pBtCoexist, 0x93);
3066 pBtCoexist->btc_write_1byte(pBtCoexist, 0x93, u1Tmp);
3067 // enable bt clock when suspend.
3068 u1Tmp = pBtCoexist->btc_read_1byte(pBtCoexist, 0x7);
3070 pBtCoexist->btc_write_1byte(pBtCoexist, 0x7, u1Tmp);
3074 EXhalbtc8192e1ant_InitCoexDm(
3075 IN PBTC_COEXIST pBtCoexist
3078 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
3080 pBtCoexist->bStopCoexDm = FALSE;
3082 halbtc8192e1ant_InitCoexDm(pBtCoexist);
3086 EXhalbtc8192e1ant_DisplayCoexInfo(
3087 IN PBTC_COEXIST pBtCoexist
3090 struct btc_board_info * pBoardInfo=&pBtCoexist->board_info;
3091 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
3092 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
3093 pu1Byte cliBuf=pBtCoexist->cli_buf;
3094 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
3096 BOOLEAN bRoam=FALSE, bScan=FALSE, bLink=FALSE, bWifiUnder5G=FALSE;
3097 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
3098 s4Byte wifiRssi=0, btHsRssi=0;
3099 u4Byte wifiBw, wifiTrafficDir;
3100 u1Byte wifiDot11Chnl, wifiHsChnl;
3101 u4Byte fwVer=0, btPatchVer=0;
3103 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
3106 if(pBtCoexist->manual_control)
3108 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
3110 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
3113 if(pBtCoexist->bStopCoexDm)
3115 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");
3117 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
3121 if(!pBoardInfo->bt_exist)
3123 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
3128 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
3129 pBoardInfo->pg_ant_num, pBoardInfo->btdm_ant_num);
3132 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
3133 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
3136 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
3137 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
3138 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
3139 GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer);
3142 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3143 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
3144 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
3145 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
3146 wifiDot11Chnl, wifiHsChnl, bBtHsOn);
3149 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
3150 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
3151 pCoexDm->wifiChnlInfo[2]);
3154 pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
3155 pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
3156 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
3157 wifiRssi, btHsRssi);
3160 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
3161 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
3162 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
3163 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
3164 bLink, bRoam, bScan);
3167 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
3168 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3169 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
3170 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
3171 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
3172 (bWifiUnder5G? "5G":"2.4G"),
3173 ((BTC_WIFI_BW_LEGACY==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40==wifiBw)? "HT40":"HT20"))),
3174 ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
3176 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
3177 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
3178 ( (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
3179 pCoexSta->btRssi, pCoexSta->btRetryCnt);
3182 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
3183 pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);
3185 pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
3187 btInfoExt = pCoexSta->btInfoExt;
3188 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
3189 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
3192 for(i=0; i<BT_INFO_SRC_8192E_1ANT_MAX; i++)
3194 if(pCoexSta->btInfoC2hCnt[i])
3196 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8192e1Ant[i], \
3197 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
3198 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
3199 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
3200 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
3204 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", \
3205 ((pCoexSta->bUnderIps? "IPS ON":"IPS OFF")),
3206 ((pCoexSta->bUnderLps? "LPS ON":"LPS OFF")),
3207 pBtCoexist->btInfo.lps1Ant,
3208 pBtCoexist->btInfo.rpwm_1ant);
3210 pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
3212 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "SS Type", \
3213 pCoexDm->curSsType);
3216 if(!pBtCoexist->manual_control)
3219 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
3222 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig/ btLna]", \
3223 pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->limited_dig, pCoexDm->bCurBtLnaConstrain);
3225 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
3226 pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
3229 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \
3230 (pBtCoexist->btInfo.reject_agg_pkt? "Yes":"No"), (pBtCoexist->btInfo.b_bt_ctrl_agg_buf_size? "Yes":"No"),
3231 pBtCoexist->btInfo.aggBufSize);
3233 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \
3234 pBtCoexist->btInfo.ra_mask);
3238 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
3241 psTdmaCase = pCoexDm->curPsTdma;
3242 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
3243 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
3244 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
3245 pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
3248 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
3249 pCoexDm->errorCondition);
3252 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwrLvl/ IgnWlanAct", \
3253 pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct);
3258 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
3261 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
3262 pCoexDm->btRf0x1eBackup);
3265 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xc04);
3266 u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xd04);
3267 u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x90c);
3268 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xc04/ 0xd04/ 0x90c", \
3269 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
3272 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x778);
3273 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \
3277 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x92c);
3278 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x930);
3279 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x92c/ 0x930", \
3280 (u1Tmp[0]), u4Tmp[0]);
3283 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x40);
3284 u1Tmp[1] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x4f);
3285 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x40/ 0x4f", \
3286 u1Tmp[0], u1Tmp[1]);
3289 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x550);
3290 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x522);
3291 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
3292 u4Tmp[0], u1Tmp[0]);
3295 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xc50);
3296 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
3300 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c0);
3301 u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c4);
3302 u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c8);
3303 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x6cc);
3304 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
3305 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
3308 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \
3309 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
3311 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
3312 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
3314 #if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 1)
3315 halbtc8192e1ant_MonitorBtCtr(pBtCoexist);
3318 pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
3323 EXhalbtc8192e1ant_IpsNotify(
3324 IN PBTC_COEXIST pBtCoexist,
3330 if(pBtCoexist->manual_control || pBtCoexist->bStopCoexDm)
3333 if(BTC_IPS_ENTER == type)
3335 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
3336 pCoexSta->bUnderIps = true;
3337 halbtc8192e1ant_CoexAllOff(pBtCoexist);
3339 else if(BTC_IPS_LEAVE == type)
3341 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
3342 pCoexSta->bUnderIps = FALSE;
3347 EXhalbtc8192e1ant_LpsNotify(
3348 IN PBTC_COEXIST pBtCoexist,
3352 if(pBtCoexist->manual_control || pBtCoexist->bStopCoexDm)
3355 if(BTC_LPS_ENABLE == type)
3357 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
3358 pCoexSta->bUnderLps = true;
3360 else if(BTC_LPS_DISABLE == type)
3362 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
3363 pCoexSta->bUnderLps = FALSE;
3368 EXhalbtc8192e1ant_ScanNotify(
3369 IN PBTC_COEXIST pBtCoexist,
3373 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
3375 if(pBtCoexist->manual_control ||
3376 pBtCoexist->bStopCoexDm ||
3377 pBtCoexist->btInfo.bBtDisabled )
3380 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3381 if(pCoexSta->bC2hBtInquiryPage)
3383 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
3388 halbtc8192e1ant_ActionHs(pBtCoexist);
3392 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3393 if(BTC_SCAN_START == type)
3395 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
3396 if(!bWifiConnected) // non-connected scan
3398 halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
3400 else // wifi is connected
3402 halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist);
3405 else if(BTC_SCAN_FINISH == type)
3407 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
3408 if(!bWifiConnected) // non-connected scan
3410 halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
3414 halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
3420 EXhalbtc8192e1ant_ConnectNotify(
3421 IN PBTC_COEXIST pBtCoexist,
3425 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
3427 if(pBtCoexist->manual_control ||
3428 pBtCoexist->bStopCoexDm ||
3429 pBtCoexist->btInfo.bBtDisabled )
3432 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3433 if(pCoexSta->bC2hBtInquiryPage)
3435 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
3440 halbtc8192e1ant_ActionHs(pBtCoexist);
3444 if(BTC_ASSOCIATE_START == type)
3446 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
3447 halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
3449 else if(BTC_ASSOCIATE_FINISH == type)
3451 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
3453 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3454 if(!bWifiConnected) // non-connected scan
3456 halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
3460 halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
3466 EXhalbtc8192e1ant_MediaStatusNotify(
3467 IN PBTC_COEXIST pBtCoexist,
3471 u1Byte H2C_Parameter[3] ={0};
3473 u1Byte wifiCentralChnl;
3475 if(pBtCoexist->manual_control ||
3476 pBtCoexist->bStopCoexDm ||
3477 pBtCoexist->btInfo.bBtDisabled )
3480 if(BTC_MEDIA_CONNECT == type)
3482 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
3486 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
3489 // only 2.4G we need to inform bt the chnl mask
3490 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
3491 if( (BTC_MEDIA_CONNECT == type) &&
3492 (wifiCentralChnl <= 14) )
3494 H2C_Parameter[0] = 0x1;
3495 H2C_Parameter[1] = wifiCentralChnl;
3496 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3497 if(BTC_WIFI_BW_HT40 == wifiBw)
3498 H2C_Parameter[2] = 0x30;
3500 H2C_Parameter[2] = 0x20;
3503 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
3504 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
3505 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
3507 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x66=0x%x\n",
3508 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
3510 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x66, 3, H2C_Parameter);
3514 EXhalbtc8192e1ant_SpecialPacketNotify(
3515 IN PBTC_COEXIST pBtCoexist,
3519 BOOLEAN bBtHsOn=FALSE;
3521 if(pBtCoexist->manual_control ||
3522 pBtCoexist->bStopCoexDm ||
3523 pBtCoexist->btInfo.bBtDisabled )
3526 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3527 if(pCoexSta->bC2hBtInquiryPage)
3529 halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
3534 halbtc8192e1ant_ActionHs(pBtCoexist);
3538 if( BTC_PACKET_DHCP == type ||
3539 BTC_PACKET_EAPOL == type )
3541 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet(%d) notify\n", type));
3542 halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
3547 EXhalbtc8192e1ant_BtInfoNotify(
3548 IN PBTC_COEXIST pBtCoexist,
3553 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
3555 u1Byte i, rspSource=0;
3556 static u4Byte setBtPsdMode=0;
3557 BOOLEAN bBtBusy=FALSE, limited_dig=FALSE;
3558 BOOLEAN bWifiConnected=FALSE;
3559 BOOLEAN b_bt_ctrl_agg_buf_size=FALSE;
3561 pCoexSta->bC2hBtInfoReqSent = FALSE;
3563 rspSource = tmpBuf[0]&0xf;
3564 if(rspSource >= BT_INFO_SRC_8192E_1ANT_MAX)
3565 rspSource = BT_INFO_SRC_8192E_1ANT_WIFI_FW;
3566 pCoexSta->btInfoC2hCnt[rspSource]++;
3568 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
3569 for(i=0; i<length; i++)
3571 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
3576 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
3580 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
3584 if(pBtCoexist->btInfo.bBtDisabled)
3586 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for BT is disabled <===\n"));
3590 if(pBtCoexist->manual_control)
3592 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
3595 if(pBtCoexist->bStopCoexDm)
3597 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Coex STOPPED!!<===\n"));
3601 if(BT_INFO_SRC_8192E_1ANT_WIFI_FW != rspSource)
3603 pCoexSta->btRetryCnt = // [3:0]
3604 pCoexSta->btInfoC2h[rspSource][2]&0xf;
3607 pCoexSta->btInfoC2h[rspSource][3]*2+10;
3609 pCoexSta->btInfoExt =
3610 pCoexSta->btInfoC2h[rspSource][4];
3612 // Here we need to resend some wifi info to BT
3613 // because bt is reset and loss of the info.
3614 if( (pCoexSta->btInfoExt & BIT1) )
3616 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
3617 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3620 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
3624 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3630 // test-chip bt patch only rsp the status for BT_RSP,
3631 // so temporary we consider the following only under BT_RSP
3632 if(BT_INFO_SRC_8192E_1ANT_BT_RSP == rspSource)
3634 if( (pCoexSta->btInfoExt & BIT3) )
3636 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
3637 halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
3641 // BT already NOT ignore Wlan active, do nothing here.
3643 #if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0)
3644 if( (pCoexSta->btInfoExt & BIT4) )
3646 // BT auto report already enabled, do nothing
3650 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit4 check, set BT to enable Auto Report!!\n"));
3651 halbtc8192e1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, true);
3657 // check BIT2 first ==> check if bt is under inquiry or page scan
3658 if(btInfo & BT_INFO_8192E_1ANT_B_INQ_PAGE)
3659 pCoexSta->bC2hBtInquiryPage = true;
3661 pCoexSta->bC2hBtInquiryPage = FALSE;
3663 // set link exist status
3664 if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION))
3666 pCoexSta->bBtLinkExist = FALSE;
3667 pCoexSta->bPanExist = FALSE;
3668 pCoexSta->bA2dpExist = FALSE;
3669 pCoexSta->bHidExist = FALSE;
3670 pCoexSta->bScoExist = FALSE;
3672 else // connection exists
3674 pCoexSta->bBtLinkExist = true;
3675 if(btInfo & BT_INFO_8192E_1ANT_B_FTP)
3676 pCoexSta->bPanExist = true;
3678 pCoexSta->bPanExist = FALSE;
3679 if(btInfo & BT_INFO_8192E_1ANT_B_A2DP)
3680 pCoexSta->bA2dpExist = true;
3682 pCoexSta->bA2dpExist = FALSE;
3683 if(btInfo & BT_INFO_8192E_1ANT_B_HID)
3684 pCoexSta->bHidExist = true;
3686 pCoexSta->bHidExist = FALSE;
3687 if(btInfo & BT_INFO_8192E_1ANT_B_SCO_ESCO)
3688 pCoexSta->bScoExist = true;
3690 pCoexSta->bScoExist = FALSE;
3693 halbtc8192e1ant_UpdateBtLinkInfo(pBtCoexist);
3695 if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION))
3697 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
3698 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-connected idle!!!\n"));
3700 else if(btInfo == BT_INFO_8192E_1ANT_B_CONNECTION) // connection exists but no busy
3702 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE;
3703 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt connected-idle!!!\n"));
3705 else if((btInfo&BT_INFO_8192E_1ANT_B_SCO_ESCO) ||
3706 (btInfo&BT_INFO_8192E_1ANT_B_SCO_BUSY))
3708 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_SCO_BUSY;
3709 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt sco busy!!!\n"));
3711 else if( (btInfo&BT_INFO_8192E_1ANT_B_ACL_BUSY) ||
3712 (btInfo&BT_INFO_8192E_1ANT_B_A2DP) ||
3713 (btInfo&BT_INFO_8192E_1ANT_B_FTP) )
3715 if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
3716 pCoexDm->bAutoTdmaAdjust = FALSE;
3717 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_ACL_BUSY;
3718 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt acl busy!!!\n"));
3722 pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_MAX;
3723 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-defined state!!!\n"));
3727 if(pBtLinkInfo->bScoExist || pBtLinkInfo->bHidExist)
3729 halbtc8192e1ant_Updatera_mask(pBtCoexist, NORMAL_EXEC, BTC_RATE_DISABLE, 0x00000003); // disable tx cck 1M/2M
3733 halbtc8192e1ant_Updatera_mask(pBtCoexist, NORMAL_EXEC, BTC_RATE_ENABLE, 0x00000003); // enable tx cck 1M/2M
3736 if( (BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
3737 (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
3738 (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
3742 if(pBtLinkInfo->bHidExist)
3743 b_bt_ctrl_agg_buf_size = true;
3748 limited_dig = FALSE;
3750 pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
3752 //============================================
3753 // Aggregation related setting
3754 //============================================
3755 // if sco, reject AddBA
3756 //pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejApAggPkt);
3758 // decide BT control aggregation buf size or not
3759 pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &b_bt_ctrl_agg_buf_size);
3760 // real update aggregation setting
3761 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
3762 //============================================
3764 pCoexDm->limited_dig = limited_dig;
3765 pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
3767 halbtc8192e1ant_RunCoexistMechanism(pBtCoexist);
3771 EXhalbtc8192e1ant_StackOperationNotify(
3772 IN PBTC_COEXIST pBtCoexist,
3776 if(BTC_STACK_OP_INQ_PAGE_PAIR_START == type)
3778 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair start notify\n"));
3780 else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
3782 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair finish notify\n"));
3787 EXhalbtc8192e1ant_HaltNotify(
3788 IN PBTC_COEXIST pBtCoexist
3791 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
3793 pBtCoexist->bStopCoexDm = true;
3794 halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
3796 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3798 halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
3799 pBtCoexist->btc_write_1byte(pBtCoexist, 0x4f, 0xf);
3801 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3805 EXhalbtc8192e1ant_PnpNotify(
3806 IN PBTC_COEXIST pBtCoexist,
3810 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
3812 if(BTC_WIFI_PNP_SLEEP == pnpState)
3814 pBtCoexist->bStopCoexDm = true;
3815 halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
3816 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3817 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
3819 else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
3826 EXhalbtc8192e1ant_Periodical(
3827 IN PBTC_COEXIST pBtCoexist
3830 static u1Byte disVerInfoCnt=0;
3831 u4Byte fwVer=0, btPatchVer=0;
3832 struct btc_board_info * pBoardInfo=&pBtCoexist->board_info;
3833 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
3835 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical===========================\n"));
3837 if(disVerInfoCnt <= 5)
3840 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
3841 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", \
3842 pBoardInfo->pg_ant_num, pBoardInfo->btdm_ant_num, pBoardInfo->btdm_ant_pos));
3843 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", \
3844 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
3845 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
3846 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
3847 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
3848 GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer));
3849 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
3851 #if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0)
3852 halbtc8192e1ant_QueryBtInfo(pBtCoexist);
3853 halbtc8192e1ant_MonitorBtCtr(pBtCoexist);
3854 halbtc8192e1ant_MonitorBtEnableDisable(pBtCoexist);
3856 if( halbtc8192e1ant_IsWifiStatusChanged(pBtCoexist) ||
3857 pCoexDm->bAutoTdmaAdjust)
3859 halbtc8192e1ant_RunCoexistMechanism(pBtCoexist);
3865 EXhalbtc8192e1ant_DbgControl(
3866 IN PBTC_COEXIST pBtCoexist,
3874 case BTC_DBG_SET_COEX_NORMAL:
3875 pBtCoexist->manual_control = FALSE;
3876 halbtc8192e1ant_InitCoexDm(pBtCoexist);
3878 case BTC_DBG_SET_COEX_WIFI_ONLY:
3879 pBtCoexist->manual_control = true;
3880 halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3881 halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
3883 case BTC_DBG_SET_COEX_BT_ONLY: