1 //============================================================
\r
4 // This file is for 8812a1ant Co-exist mechanism
\r
7 // 2012/11/15 Cosa first check in.
\r
9 //============================================================
\r
11 //============================================================
\r
13 //============================================================
\r
14 #include "Mp_Precomp.h"
\r
15 #if(BT_30_SUPPORT == 1)
\r
16 //============================================================
\r
17 // Global variables, these are static variables
\r
18 //============================================================
\r
19 static COEX_DM_8812A_1ANT GLCoexDm8812a1Ant;
\r
20 static PCOEX_DM_8812A_1ANT pCoexDm=&GLCoexDm8812a1Ant;
\r
21 static COEX_STA_8812A_1ANT GLCoexSta8812a1Ant;
\r
22 static PCOEX_STA_8812A_1ANT pCoexSta=&GLCoexSta8812a1Ant;
\r
24 const char *const GLBtInfoSrc8812a1Ant[]={
\r
27 "BT Info[bt auto report]",
\r
30 u4Byte GLCoexVerDate8812a1Ant=20130729;
\r
31 u4Byte GLCoexVer8812a1Ant=0x10;
\r
33 //============================================================
\r
34 // local function proto type if needed
\r
35 //============================================================
\r
36 //============================================================
\r
37 // local function start with halbtc8812a1ant_
\r
38 //============================================================
\r
40 halbtc8812a1ant_BtRssiState(
\r
47 u1Byte btRssiState=pCoexSta->preBtRssiState;
\r
49 btRssi = pCoexSta->btRssi;
\r
53 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
54 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
56 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
\r
58 btRssiState = BTC_RSSI_STATE_HIGH;
\r
59 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
\r
63 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
64 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
\r
69 if(btRssi < rssiThresh)
\r
71 btRssiState = BTC_RSSI_STATE_LOW;
\r
72 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
\r
76 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
77 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
\r
81 else if(levelNum == 3)
\r
83 if(rssiThresh > rssiThresh1)
\r
85 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
\r
86 return pCoexSta->preBtRssiState;
\r
89 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
90 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
92 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
\r
94 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
95 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
\r
99 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
100 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
\r
103 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
\r
104 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
\r
106 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
\r
108 btRssiState = BTC_RSSI_STATE_HIGH;
\r
109 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
\r
111 else if(btRssi < rssiThresh)
\r
113 btRssiState = BTC_RSSI_STATE_LOW;
\r
114 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
\r
118 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
119 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
\r
124 if(btRssi < rssiThresh1)
\r
126 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
127 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
\r
131 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
132 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
\r
137 pCoexSta->preBtRssiState = btRssiState;
\r
139 return btRssiState;
\r
143 halbtc8812a1ant_WifiRssiState(
\r
144 IN PBTC_COEXIST pBtCoexist,
\r
146 IN u1Byte levelNum,
\r
147 IN u1Byte rssiThresh,
\r
148 IN u1Byte rssiThresh1
\r
152 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
\r
154 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
158 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
159 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
161 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
\r
163 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
164 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
168 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
169 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
174 if(wifiRssi < rssiThresh)
\r
176 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
177 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
181 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
182 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
186 else if(levelNum == 3)
\r
188 if(rssiThresh > rssiThresh1)
\r
190 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
\r
191 return pCoexSta->preWifiRssiState[index];
\r
194 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
195 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
197 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
\r
199 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
200 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
204 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
205 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
208 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
\r
209 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
\r
211 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
\r
213 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
214 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
216 else if(wifiRssi < rssiThresh)
\r
218 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
219 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
223 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
224 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
\r
229 if(wifiRssi < rssiThresh1)
\r
231 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
232 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
236 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
237 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
242 pCoexSta->preWifiRssiState[index] = wifiRssiState;
\r
244 return wifiRssiState;
\r
248 halbtc8812a1ant_UpdateRaMask(
\r
249 IN PBTC_COEXIST pBtCoexist,
\r
250 IN BOOLEAN bForceExec,
\r
255 if(BTC_RATE_DISABLE == type)
\r
257 pCoexDm->curRaMask |= rateMask; // disable rate
\r
259 else if(BTC_RATE_ENABLE == type)
\r
261 pCoexDm->curRaMask &= ~rateMask; // enable rate
\r
264 if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask))
\r
266 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask);
\r
268 pCoexDm->preRaMask = pCoexDm->curRaMask;
\r
272 halbtc8812a1ant_MonitorBtCtr(
\r
273 IN PBTC_COEXIST pBtCoexist
\r
276 u4Byte regHPTxRx, regLPTxRx, u4Tmp;
\r
277 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
\r
283 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
\r
284 regHPTx = u4Tmp & bMaskLWord;
\r
285 regHPRx = (u4Tmp & bMaskHWord)>>16;
\r
287 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
\r
288 regLPTx = u4Tmp & bMaskLWord;
\r
289 regLPRx = (u4Tmp & bMaskHWord)>>16;
\r
291 pCoexSta->highPriorityTx = regHPTx;
\r
292 pCoexSta->highPriorityRx = regHPRx;
\r
293 pCoexSta->lowPriorityTx = regLPTx;
\r
294 pCoexSta->lowPriorityRx = regLPRx;
\r
296 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
297 regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
\r
298 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
299 regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
\r
302 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
306 halbtc8812a1ant_QueryBtInfo(
\r
307 IN PBTC_COEXIST pBtCoexist
\r
311 u1Byte buf[5] = {0};
\r
313 if(!pBtCoexist->btInfo.bBtDisabled)
\r
315 if(!pCoexSta->btInfoQueryCnt ||
\r
316 (pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8812A_1ANT_BT_RSP]-pCoexSta->btInfoQueryCnt)>2)
\r
319 buf[1] = 0x1; // polling enable, 1=enable, 0=disable
\r
320 buf[2] = 0x2; // polling time in seconds
\r
321 buf[3] = 0x1; // auto report enable, 1=enable, 0=disable
\r
323 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_INFO, (PVOID)&buf[0]);
\r
326 pCoexSta->btInfoQueryCnt++;
\r
330 halbtc8812a1ant_UpdateBtLinkInfo(
\r
331 IN PBTC_COEXIST pBtCoexist
\r
334 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
336 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
\r
337 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
\r
338 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
\r
339 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
\r
340 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
\r
342 // check if Sco only
\r
343 if( pBtLinkInfo->bScoExist &&
\r
344 !pBtLinkInfo->bA2dpExist &&
\r
345 !pBtLinkInfo->bPanExist &&
\r
346 !pBtLinkInfo->bHidExist )
\r
347 pBtLinkInfo->bScoOnly = TRUE;
\r
349 pBtLinkInfo->bScoOnly = FALSE;
\r
351 // check if A2dp only
\r
352 if( !pBtLinkInfo->bScoExist &&
\r
353 pBtLinkInfo->bA2dpExist &&
\r
354 !pBtLinkInfo->bPanExist &&
\r
355 !pBtLinkInfo->bHidExist )
\r
356 pBtLinkInfo->bA2dpOnly = TRUE;
\r
358 pBtLinkInfo->bA2dpOnly = FALSE;
\r
360 // check if Pan only
\r
361 if( !pBtLinkInfo->bScoExist &&
\r
362 !pBtLinkInfo->bA2dpExist &&
\r
363 pBtLinkInfo->bPanExist &&
\r
364 !pBtLinkInfo->bHidExist )
\r
365 pBtLinkInfo->bPanOnly = TRUE;
\r
367 pBtLinkInfo->bPanOnly = FALSE;
\r
369 // check if Hid only
\r
370 if( !pBtLinkInfo->bScoExist &&
\r
371 !pBtLinkInfo->bA2dpExist &&
\r
372 !pBtLinkInfo->bPanExist &&
\r
373 pBtLinkInfo->bHidExist )
\r
374 pBtLinkInfo->bHidOnly = TRUE;
\r
376 pBtLinkInfo->bHidOnly = FALSE;
\r
380 halbtc8812a1ant_ActionAlgorithm(
\r
381 IN PBTC_COEXIST pBtCoexist
\r
384 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
385 BOOLEAN bBtHsOn=FALSE;
\r
386 u1Byte algorithm=BT_8812A_1ANT_COEX_ALGO_UNDEFINED;
\r
387 u1Byte numOfDiffProfile=0;
\r
389 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
391 if(!pBtLinkInfo->bBtLinkExist)
\r
393 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No profile exists!!!\n"));
\r
397 if(pBtLinkInfo->bScoExist)
\r
398 numOfDiffProfile++;
\r
399 if(pBtLinkInfo->bHidExist)
\r
400 numOfDiffProfile++;
\r
401 if(pBtLinkInfo->bPanExist)
\r
402 numOfDiffProfile++;
\r
403 if(pBtLinkInfo->bA2dpExist)
\r
404 numOfDiffProfile++;
\r
406 if(numOfDiffProfile == 1)
\r
408 if(pBtLinkInfo->bScoExist)
\r
410 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n"));
\r
411 algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;
\r
415 if(pBtLinkInfo->bHidExist)
\r
417 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
\r
418 algorithm = BT_8812A_1ANT_COEX_ALGO_HID;
\r
420 else if(pBtLinkInfo->bA2dpExist)
\r
422 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
\r
423 algorithm = BT_8812A_1ANT_COEX_ALGO_A2DP;
\r
425 else if(pBtLinkInfo->bPanExist)
\r
429 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
\r
430 algorithm = BT_8812A_1ANT_COEX_ALGO_PANHS;
\r
434 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
\r
435 algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR;
\r
440 else if(numOfDiffProfile == 2)
\r
442 if(pBtLinkInfo->bScoExist)
\r
444 if(pBtLinkInfo->bHidExist)
\r
446 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n"));
\r
447 algorithm = BT_8812A_1ANT_COEX_ALGO_HID;
\r
449 else if(pBtLinkInfo->bA2dpExist)
\r
451 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n"));
\r
452 algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;
\r
454 else if(pBtLinkInfo->bPanExist)
\r
458 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
\r
459 algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;
\r
463 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
\r
464 algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
\r
470 if( pBtLinkInfo->bHidExist &&
\r
471 pBtLinkInfo->bA2dpExist )
\r
473 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
\r
474 algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;
\r
476 else if( pBtLinkInfo->bHidExist &&
\r
477 pBtLinkInfo->bPanExist )
\r
481 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
\r
482 algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;
\r
486 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
\r
487 algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
\r
490 else if( pBtLinkInfo->bPanExist &&
\r
491 pBtLinkInfo->bA2dpExist )
\r
495 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
\r
496 algorithm = BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS;
\r
500 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
\r
501 algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_A2DP;
\r
506 else if(numOfDiffProfile == 3)
\r
508 if(pBtLinkInfo->bScoExist)
\r
510 if( pBtLinkInfo->bHidExist &&
\r
511 pBtLinkInfo->bA2dpExist )
\r
513 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP ==> HID\n"));
\r
514 algorithm = BT_8812A_1ANT_COEX_ALGO_HID;
\r
516 else if( pBtLinkInfo->bHidExist &&
\r
517 pBtLinkInfo->bPanExist )
\r
521 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(HS)\n"));
\r
522 algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;
\r
526 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
\r
527 algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
\r
530 else if( pBtLinkInfo->bPanExist &&
\r
531 pBtLinkInfo->bA2dpExist )
\r
535 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
\r
536 algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;
\r
540 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
\r
541 algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
\r
547 if( pBtLinkInfo->bHidExist &&
\r
548 pBtLinkInfo->bPanExist &&
\r
549 pBtLinkInfo->bA2dpExist )
\r
553 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
\r
554 algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;
\r
558 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
\r
559 algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
\r
564 else if(numOfDiffProfile >= 3)
\r
566 if(pBtLinkInfo->bScoExist)
\r
568 if( pBtLinkInfo->bHidExist &&
\r
569 pBtLinkInfo->bPanExist &&
\r
570 pBtLinkInfo->bA2dpExist )
\r
574 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
\r
579 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
\r
580 algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
\r
590 halbtc8812a1ant_SetBtAutoReport(
\r
591 IN PBTC_COEXIST pBtCoexist,
\r
592 IN BOOLEAN bEnableAutoReport
\r
598 halbtc8812a1ant_BtAutoReport(
\r
599 IN PBTC_COEXIST pBtCoexist,
\r
600 IN BOOLEAN bForceExec,
\r
601 IN BOOLEAN bEnableAutoReport
\r
604 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Auto report = %s\n",
\r
605 (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
\r
606 pCoexDm->bCurBtAutoReport = bEnableAutoReport;
\r
610 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
\r
611 pCoexDm->bPreBtAutoReport, pCoexDm->bCurBtAutoReport));
\r
613 if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
\r
616 halbtc8812a1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
\r
618 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
\r
622 halbtc8812a1ant_SetSwPenaltyTxRateAdaptive(
\r
623 IN PBTC_COEXIST pBtCoexist,
\r
624 IN BOOLEAN bLowPenaltyRa
\r
629 tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd);
\r
633 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
\r
638 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
\r
642 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1);
\r
646 halbtc8812a1ant_LowPenaltyRa(
\r
647 IN PBTC_COEXIST pBtCoexist,
\r
648 IN BOOLEAN bForceExec,
\r
649 IN BOOLEAN bLowPenaltyRa
\r
653 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
\r
654 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
\r
655 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
659 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
\r
660 pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
\r
662 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
665 halbtc8812a1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
667 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
671 halbtc8812a1ant_SetCoexTable(
\r
672 IN PBTC_COEXIST pBtCoexist,
\r
673 IN u4Byte val0x6c0,
\r
674 IN u4Byte val0x6c4,
\r
675 IN u4Byte val0x6c8,
\r
679 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
\r
680 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
\r
682 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
\r
683 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
\r
685 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
686 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
688 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
689 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
693 halbtc8812a1ant_CoexTable(
\r
694 IN PBTC_COEXIST pBtCoexist,
\r
695 IN BOOLEAN bForceExec,
\r
696 IN u4Byte val0x6c0,
\r
697 IN u4Byte val0x6c4,
\r
698 IN u4Byte val0x6c8,
\r
702 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
\r
703 (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc));
\r
704 pCoexDm->curVal0x6c0 = val0x6c0;
\r
705 pCoexDm->curVal0x6c4 = val0x6c4;
\r
706 pCoexDm->curVal0x6c8 = val0x6c8;
\r
707 pCoexDm->curVal0x6cc = val0x6cc;
\r
711 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c4=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
\r
712 pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
\r
713 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
\r
714 pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
\r
716 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
\r
717 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
\r
718 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
719 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
722 halbtc8812a1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
\r
724 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
\r
725 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
\r
726 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
727 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
731 halbtc8812a1ant_CoexTableWithType(
\r
732 IN PBTC_COEXIST pBtCoexist,
\r
733 IN BOOLEAN bForceExec,
\r
740 halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffff, 0x3);
\r
743 halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffff, 0x3);
\r
746 halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3);
\r
749 halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff, 0x3);
\r
752 halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffff, 0x3);
\r
755 halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffff, 0x3);
\r
758 halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3);
\r
761 halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x5afa5afa, 0x5afa5afa, 0xffff, 0x3);
\r
769 halbtc8812a1ant_SetFwIgnoreWlanAct(
\r
770 IN PBTC_COEXIST pBtCoexist,
\r
775 u1Byte buf[5] = {0};
\r
777 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], %s BT Ignore Wlan_Act\n",
\r
778 (bEnable? "Enable":"Disable")));
\r
781 buf[1] = 0x1; // OP_Code
\r
782 buf[2] = 0x1; // OP_Code_Length
\r
784 buf[3] = 0x1; // OP_Code_Content
\r
788 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
\r
792 halbtc8812a1ant_IgnoreWlanAct(
\r
793 IN PBTC_COEXIST pBtCoexist,
\r
794 IN BOOLEAN bForceExec,
\r
798 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
\r
799 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
\r
800 pCoexDm->bCurIgnoreWlanAct = bEnable;
\r
804 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
\r
805 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
\r
807 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
\r
810 halbtc8812a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
\r
812 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
\r
816 halbtc8812a1ant_SetFwPstdma(
\r
817 IN PBTC_COEXIST pBtCoexist,
\r
825 u1Byte H2C_Parameter[5] ={0};
\r
827 H2C_Parameter[0] = byte1;
\r
828 H2C_Parameter[1] = byte2;
\r
829 H2C_Parameter[2] = byte3;
\r
830 H2C_Parameter[3] = byte4;
\r
831 H2C_Parameter[4] = byte5;
\r
833 pCoexDm->psTdmaPara[0] = byte1;
\r
834 pCoexDm->psTdmaPara[1] = byte2;
\r
835 pCoexDm->psTdmaPara[2] = byte3;
\r
836 pCoexDm->psTdmaPara[3] = byte4;
\r
837 pCoexDm->psTdmaPara[4] = byte5;
\r
839 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n",
\r
841 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
\r
843 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
\r
847 halbtc8812a1ant_SetLpsRpwm(
\r
848 IN PBTC_COEXIST pBtCoexist,
\r
854 u1Byte rpwm=rpwmVal;
\r
856 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
\r
857 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
\r
861 halbtc8812a1ant_LpsRpwm(
\r
862 IN PBTC_COEXIST pBtCoexist,
\r
863 IN BOOLEAN bForceExec,
\r
868 BOOLEAN bForceExecPwrCmd=FALSE;
\r
870 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
\r
871 (bForceExec? "force to":""), lpsVal, rpwmVal));
\r
872 pCoexDm->curLps = lpsVal;
\r
873 pCoexDm->curRpwm = rpwmVal;
\r
877 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preLps/curLps=0x%x/0x%x, preRpwm/curRpwm=0x%x/0x%x!!\n",
\r
878 pCoexDm->preLps, pCoexDm->curLps, pCoexDm->preRpwm, pCoexDm->curRpwm));
\r
880 if( (pCoexDm->preLps == pCoexDm->curLps) &&
\r
881 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
\r
886 halbtc8812a1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
\r
888 pCoexDm->preLps = pCoexDm->curLps;
\r
889 pCoexDm->preRpwm = pCoexDm->curRpwm;
\r
893 halbtc8812a1ant_SetAntPath(
\r
894 IN PBTC_COEXIST pBtCoexist,
\r
895 IN u1Byte antPosType,
\r
896 IN BOOLEAN bInitHwCfg,
\r
897 IN BOOLEAN bWifiOff
\r
904 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb3, 0x77);
\r
906 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x900, 0x00000400);
\r
907 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76d, 0x1);
\r
914 // ext switch setting
\r
917 case BTC_ANT_PATH_WIFI:
\r
918 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7);
\r
921 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp);
\r
923 case BTC_ANT_PATH_BT:
\r
924 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7);
\r
927 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp);
\r
930 case BTC_ANT_PATH_PTA:
\r
931 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7);
\r
934 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp);
\r
940 halbtc8812a1ant_PsTdma(
\r
941 IN PBTC_COEXIST pBtCoexist,
\r
942 IN BOOLEAN bForceExec,
\r
943 IN BOOLEAN bTurnOn,
\r
947 BOOLEAN bTurnOnByCnt=FALSE;
\r
948 u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0;
\r
950 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
\r
951 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
\r
952 pCoexDm->bCurPsTdmaOn = bTurnOn;
\r
953 pCoexDm->curPsTdma = type;
\r
957 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
\r
958 pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn));
\r
959 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
\r
960 pCoexDm->prePsTdma, pCoexDm->curPsTdma));
\r
962 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
\r
963 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
\r
971 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x50);
\r
974 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x50);
\r
975 rssiAdjustVal = 11;
\r
978 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x12, 0x0, 0x50);
\r
979 rssiAdjustVal = 14;
\r
982 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x40);
\r
985 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
\r
986 rssiAdjustVal = 17;
\r
989 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x31, 0x0);
\r
992 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x0, 0x0);
\r
995 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
\r
998 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1001 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0xa, 0xa, 0x0, 0x50);
\r
1002 rssiAdjustVal = 18;
\r
1005 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
\r
1008 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x5, 0x5, 0x0, 0x50);
\r
1009 rssiAdjustVal = 20;
\r
1012 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xeb, 0xa, 0x3, 0x31, 0x18);
\r
1016 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0);
\r
1019 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0);
\r
1020 rssiAdjustVal = 18;
\r
1024 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
1025 rssiAdjustVal = 14;
\r
1029 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0x25, 0x25, 0x0, 0x0);
\r
1032 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x20, 0x3, 0x10, 0x40);
\r
1035 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0x8, 0x8, 0x0, 0x40);
\r
1038 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);
\r
1039 rssiAdjustVal = 22;
\r
1042 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);
\r
1043 rssiAdjustVal = 22;
\r
1046 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1047 rssiAdjustVal = 22;
\r
1050 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
\r
1051 rssiAdjustVal = 22;
\r
1054 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);
\r
1055 rssiAdjustVal = 22;
\r
1058 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0);
\r
1061 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10);
\r
1064 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
\r
1067 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);
\r
1070 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xab, 0xa, 0x3, 0x31, 0x90);
\r
1073 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90);
\r
1076 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x10);
\r
1079 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x0, 0x10);
\r
1082 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50);
\r
1085 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x53, 0x25, 0x3, 0x10, 0x50);
\r
1091 // disable PS tdma
\r
1095 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
\r
1096 halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE);
\r
1100 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1101 halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
\r
1104 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
1105 halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE);
\r
1108 halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
\r
1109 halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
\r
1114 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal);
\r
1116 // update pre state
\r
1117 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
\r
1118 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
\r
1122 halbtc8812a1ant_CoexAllOff(
\r
1123 IN PBTC_COEXIST pBtCoexist
\r
1127 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1131 halbtc8812a1ant_IsCommonAction(
\r
1132 IN PBTC_COEXIST pBtCoexist
\r
1135 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
1137 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1138 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1140 if(!bWifiConnected &&
\r
1141 BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
1143 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));
\r
1147 else if(bWifiConnected &&
\r
1148 (BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1150 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
\r
1154 else if(!bWifiConnected &&
\r
1155 (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1157 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));
\r
1161 else if(bWifiConnected &&
\r
1162 (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
\r
1164 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
\r
1168 else if(!bWifiConnected &&
\r
1169 (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) )
\r
1171 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
\r
1185 halbtc8812a1ant_TdmaDurationAdjustForAcl(
\r
1186 IN PBTC_COEXIST pBtCoexist,
\r
1187 IN u1Byte wifiStatus
\r
1190 static s4Byte up,dn,m,n,WaitCount;
\r
1191 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
\r
1192 u1Byte retryCount=0, btInfoExt;
\r
1194 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjustForAcl()\n"));
\r
1196 if( (BT_8812A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
\r
1197 (BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
\r
1198 (BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
\r
1200 if( pCoexDm->curPsTdma != 1 &&
\r
1201 pCoexDm->curPsTdma != 2 &&
\r
1202 pCoexDm->curPsTdma != 3 &&
\r
1203 pCoexDm->curPsTdma != 9 )
\r
1205 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1206 pCoexDm->psTdmaDuAdjType = 9;
\r
1218 if(pCoexDm->bResetTdmaAdjust)
\r
1220 pCoexDm->bResetTdmaAdjust = FALSE;
\r
1221 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
\r
1223 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1224 pCoexDm->psTdmaDuAdjType = 2;
\r
1235 //accquire the BT TRx retry count from BT_Info byte2
\r
1236 retryCount = pCoexSta->btRetryCnt;
\r
1237 btInfoExt = pCoexSta->btInfoExt;
\r
1238 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
\r
1239 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
\r
1240 up, dn, m, n, WaitCount));
\r
1244 if(retryCount == 0) // no retry in the last 2-second duration
\r
1252 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
\r
1259 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
\r
1262 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
\r
1270 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
\r
1272 if (WaitCount <= 2)
\r
1273 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1277 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1285 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
\r
1288 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
\r
1290 if (WaitCount == 1)
\r
1291 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
1295 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
1303 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
\r
1308 if( (BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1309 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1311 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1312 pCoexDm->psTdmaDuAdjType = 9;
\r
1314 else if(pCoexDm->curPsTdma == 1)
\r
1316 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1317 pCoexDm->psTdmaDuAdjType = 2;
\r
1319 else if(pCoexDm->curPsTdma == 2)
\r
1321 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1322 pCoexDm->psTdmaDuAdjType = 9;
\r
1324 else if(pCoexDm->curPsTdma == 9)
\r
1326 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
1327 pCoexDm->psTdmaDuAdjType = 11;
\r
1330 else if(result == 1)
\r
1332 if( (BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
\r
1333 ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
\r
1335 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1336 pCoexDm->psTdmaDuAdjType = 9;
\r
1338 else if(pCoexDm->curPsTdma == 11)
\r
1340 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1341 pCoexDm->psTdmaDuAdjType = 9;
\r
1343 else if(pCoexDm->curPsTdma == 9)
\r
1345 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
1346 pCoexDm->psTdmaDuAdjType = 2;
\r
1348 else if(pCoexDm->curPsTdma == 2)
\r
1350 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
1351 pCoexDm->psTdmaDuAdjType = 1;
\r
1355 if( pCoexDm->curPsTdma != 1 &&
\r
1356 pCoexDm->curPsTdma != 2 &&
\r
1357 pCoexDm->curPsTdma != 9 &&
\r
1358 pCoexDm->curPsTdma != 11 )
\r
1360 // recover to previous adjust type
\r
1361 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
\r
1367 halbtc8812a1ant_PsTdmaTypeByWifiRssi(
\r
1368 IN s4Byte wifiRssi,
\r
1369 IN s4Byte preWifiRssi,
\r
1370 IN u1Byte wifiRssiThresh
\r
1373 u1Byte psTdmaType=0;
\r
1375 if(wifiRssi > preWifiRssi)
\r
1377 if(wifiRssi > (wifiRssiThresh+5))
\r
1388 if(wifiRssi > wifiRssiThresh)
\r
1398 return psTdmaType;
\r
1402 halbtc8812a1ant_PsTdmaCheckForPowerSaveState(
\r
1403 IN PBTC_COEXIST pBtCoexist,
\r
1404 IN BOOLEAN bNewPsState
\r
1407 u1Byte lpsMode=0x0;
\r
1409 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
\r
1411 if(lpsMode) // already under LPS state
\r
1415 // keep state under LPS, do nothing.
\r
1419 // will leave LPS state, turn off psTdma first
\r
1420 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1423 else // NO PS state
\r
1427 // will enter LPS state, turn off psTdma first
\r
1428 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1432 // keep state under NO PS state, do nothing.
\r
1438 halbtc8812a1ant_PowerSaveState(
\r
1439 IN PBTC_COEXIST pBtCoexist,
\r
1445 BOOLEAN bLowPwrDisable=FALSE;
\r
1449 case BTC_PS_WIFI_NATIVE:
\r
1450 // recover to original 32k low power setting
\r
1451 bLowPwrDisable = FALSE;
\r
1452 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1453 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1455 case BTC_PS_LPS_ON:
\r
1456 halbtc8812a1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);
\r
1457 halbtc8812a1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
\r
1458 // when coex force to enter LPS, do not enter 32k low power.
\r
1459 bLowPwrDisable = TRUE;
\r
1460 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1461 // power save must executed before psTdma.
\r
1462 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
\r
1464 case BTC_PS_LPS_OFF:
\r
1465 halbtc8812a1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
\r
1466 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1475 halbtc8812a1ant_CoexUnder5G(
\r
1476 IN PBTC_COEXIST pBtCoexist
\r
1479 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1481 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 10);
\r
1483 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1487 halbtc8812a1ant_ActionWifiOnly(
\r
1488 IN PBTC_COEXIST pBtCoexist
\r
1491 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1492 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1496 halbtc8812a1ant_MonitorBtEnableDisable(
\r
1497 IN PBTC_COEXIST pBtCoexist
\r
1500 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
1501 static BOOLEAN bPreBtDisabled=FALSE;
\r
1502 static u4Byte btDisableCnt=0;
\r
1503 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
\r
1505 // only 8812a need to consider if core stack is installed.
\r
1506 if(!pStackInfo->hciVersion)
\r
1508 bBtActive = FALSE;
\r
1511 // This function check if bt is disabled
\r
1513 if( pCoexSta->highPriorityTx == 0 &&
\r
1514 pCoexSta->highPriorityRx == 0 &&
\r
1515 pCoexSta->lowPriorityTx == 0 &&
\r
1516 pCoexSta->lowPriorityRx == 0)
\r
1518 bBtActive = FALSE;
\r
1520 if( pCoexSta->highPriorityTx == 0xffff &&
\r
1521 pCoexSta->highPriorityRx == 0xffff &&
\r
1522 pCoexSta->lowPriorityTx == 0xffff &&
\r
1523 pCoexSta->lowPriorityRx == 0xffff)
\r
1525 bBtActive = FALSE;
\r
1530 bBtDisabled = FALSE;
\r
1531 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
1532 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
\r
1537 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
\r
1539 if(btDisableCnt >= 2)
\r
1541 bBtDisabled = TRUE;
\r
1542 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
1543 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
\r
1544 halbtc8812a1ant_ActionWifiOnly(pBtCoexist);
\r
1547 if(bPreBtDisabled != bBtDisabled)
\r
1549 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
\r
1550 (bPreBtDisabled ? "disabled":"enabled"),
\r
1551 (bBtDisabled ? "disabled":"enabled")));
\r
1552 bPreBtDisabled = bBtDisabled;
\r
1558 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1559 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1564 //=============================================
\r
1566 // Software Coex Mechanism start
\r
1568 //=============================================
\r
1570 // SCO only or SCO+PAN(HS)
\r
1572 halbtc8812a1ant_ActionSco(
\r
1573 IN PBTC_COEXIST pBtCoexist
\r
1579 halbtc8812a1ant_ActionHid(
\r
1580 IN PBTC_COEXIST pBtCoexist
\r
1585 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
\r
1587 halbtc8812a1ant_ActionA2dp(
\r
1588 IN PBTC_COEXIST pBtCoexist
\r
1594 halbtc8812a1ant_ActionA2dpPanHs(
\r
1595 IN PBTC_COEXIST pBtCoexist
\r
1601 halbtc8812a1ant_ActionPanEdr(
\r
1602 IN PBTC_COEXIST pBtCoexist
\r
1609 halbtc8812a1ant_ActionPanHs(
\r
1610 IN PBTC_COEXIST pBtCoexist
\r
1617 halbtc8812a1ant_ActionPanEdrA2dp(
\r
1618 IN PBTC_COEXIST pBtCoexist
\r
1624 halbtc8812a1ant_ActionPanEdrHid(
\r
1625 IN PBTC_COEXIST pBtCoexist
\r
1630 // HID+A2DP+PAN(EDR)
\r
1632 halbtc8812a1ant_ActionHidA2dpPanEdr(
\r
1633 IN PBTC_COEXIST pBtCoexist
\r
1639 halbtc8812a1ant_ActionHidA2dp(
\r
1640 IN PBTC_COEXIST pBtCoexist
\r
1645 //=============================================
\r
1647 // Non-Software Coex Mechanism start
\r
1649 //=============================================
\r
1652 halbtc8812a1ant_ActionHs(
\r
1653 IN PBTC_COEXIST pBtCoexist
\r
1656 BOOLEAN bHsConnecting=FALSE;
\r
1658 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_CONNECTING, &bHsConnecting);
\r
1660 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action for HS, bHsConnecting=%d!!!\n", bHsConnecting));
\r
1661 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1665 halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 3);
\r
1669 if((pCoexSta->highPriorityTx+pCoexSta->highPriorityRx+
\r
1670 pCoexSta->lowPriorityTx+pCoexSta->lowPriorityRx)<=1200)
\r
1671 halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 3);
\r
1673 halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4);
\r
1678 halbtc8812a1ant_ActionBtInquiry(
\r
1679 IN PBTC_COEXIST pBtCoexist
\r
1682 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
1683 BOOLEAN bWifiConnected=FALSE;
\r
1685 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1687 if(!bWifiConnected)
\r
1689 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1690 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1691 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1693 else if( (pBtLinkInfo->bScoExist) ||
\r
1694 (pBtLinkInfo->bHidOnly) )
\r
1696 // SCO/HID-only busy
\r
1697 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1698 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);
\r
1699 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
1703 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
\r
1704 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 30);
\r
1705 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1710 halbtc8812a1ant_ActionBtScoHidOnlyBusy(
\r
1711 IN PBTC_COEXIST pBtCoexist,
\r
1712 IN u1Byte wifiStatus
\r
1715 // tdma and coex table
\r
1716 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1718 if(BT_8812A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus)
\r
1719 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1721 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1725 halbtc8812a1ant_ActionWifiConnectedBtAclBusy(
\r
1726 IN PBTC_COEXIST pBtCoexist,
\r
1727 IN u1Byte wifiStatus
\r
1730 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
1732 if(pBtLinkInfo->bHidOnly)
\r
1734 halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);
\r
1735 pCoexDm->bResetTdmaAdjust = TRUE;
\r
1738 else if( (pBtLinkInfo->bA2dpOnly) ||
\r
1739 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) )
\r
1741 halbtc8812a1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);
\r
1743 else if( (pBtLinkInfo->bPanOnly) ||
\r
1744 (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) )
\r
1746 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
1747 pCoexDm->bResetTdmaAdjust = TRUE;
\r
1751 if( (BT_8812A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
\r
1752 (BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
\r
1753 (BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
\r
1754 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
1756 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
1757 pCoexDm->bResetTdmaAdjust = TRUE;
\r
1760 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
\r
1764 halbtc8812a1ant_ActionWifiNotConnected(
\r
1765 IN PBTC_COEXIST pBtCoexist
\r
1768 // power save state
\r
1769 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1771 // tdma and coex table
\r
1772 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1773 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1777 halbtc8812a1ant_ActionWifiNotConnectedAssoAuthScan(
\r
1778 IN PBTC_COEXIST pBtCoexist
\r
1781 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1783 // tdma and coex table
\r
1784 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1785 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1789 halbtc8812a1ant_ActionWifiConnectedScan(
\r
1790 IN PBTC_COEXIST pBtCoexist
\r
1793 // power save state
\r
1794 if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
\r
1795 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
\r
1797 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1799 // tdma and coex table
\r
1800 if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
1802 halbtc8812a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
1803 BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
1805 else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
1806 (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
1808 halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
1809 BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
\r
1813 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1814 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1819 halbtc8812a1ant_ActionWifiConnectedSpecialPacket(
\r
1820 IN PBTC_COEXIST pBtCoexist
\r
1823 // power save state
\r
1824 if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
\r
1825 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
\r
1827 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1829 // tdma and coex table
\r
1830 if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
1832 halbtc8812a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
1833 BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT);
\r
1837 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1838 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1843 halbtc8812a1ant_ActionWifiConnected(
\r
1844 IN PBTC_COEXIST pBtCoexist
\r
1847 BOOLEAN bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
1848 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
1849 BOOLEAN bUnder4way=FALSE;
\r
1852 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect()===>\n"));
\r
1854 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1855 if(!bWifiConnected)
\r
1857 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi not connected<===\n"));
\r
1861 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
1864 halbtc8812a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
1865 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));
\r
1869 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
1870 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
1871 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
1872 if(bScan || bLink || bRoam)
\r
1874 halbtc8812a1ant_ActionWifiConnectedScan(pBtCoexist);
\r
1875 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));
\r
1879 // power save state
\r
1880 if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)
\r
1881 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
\r
1883 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1885 // tdma and coex table
\r
1886 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1889 if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
1891 halbtc8812a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
1892 BT_8812A_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
1894 else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
1895 (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
1897 halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
1898 BT_8812A_1ANT_WIFI_STATUS_CONNECTED_IDLE);
\r
1902 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1903 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1908 if(BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
1910 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
1911 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1913 else if(BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
\r
1915 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
1916 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1918 else if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
\r
1920 halbtc8812a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
\r
1921 BT_8812A_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
1923 else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
1924 (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
1926 halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
\r
1927 BT_8812A_1ANT_WIFI_STATUS_CONNECTED_BUSY);
\r
1931 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1932 halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
1938 halbtc8812a1ant_RunSwCoexistMechanism(
\r
1939 IN PBTC_COEXIST pBtCoexist
\r
1942 BOOLEAN bWifiUnder5G=FALSE, bWifiBusy=FALSE, bWifiConnected=FALSE;
\r
1943 u1Byte btInfoOriginal=0, btRetryCnt=0;
\r
1944 u1Byte algorithm=0;
\r
1948 algorithm = halbtc8812a1ant_ActionAlgorithm(pBtCoexist);
\r
1949 pCoexDm->curAlgorithm = algorithm;
\r
1951 if(halbtc8812a1ant_IsCommonAction(pBtCoexist))
\r
1956 switch(pCoexDm->curAlgorithm)
\r
1958 case BT_8812A_1ANT_COEX_ALGO_SCO:
\r
1959 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n"));
\r
1960 halbtc8812a1ant_ActionSco(pBtCoexist);
\r
1962 case BT_8812A_1ANT_COEX_ALGO_HID:
\r
1963 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n"));
\r
1964 halbtc8812a1ant_ActionHid(pBtCoexist);
\r
1966 case BT_8812A_1ANT_COEX_ALGO_A2DP:
\r
1967 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n"));
\r
1968 halbtc8812a1ant_ActionA2dp(pBtCoexist);
\r
1970 case BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS:
\r
1971 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
\r
1972 halbtc8812a1ant_ActionA2dpPanHs(pBtCoexist);
\r
1974 case BT_8812A_1ANT_COEX_ALGO_PANEDR:
\r
1975 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
\r
1976 halbtc8812a1ant_ActionPanEdr(pBtCoexist);
\r
1978 case BT_8812A_1ANT_COEX_ALGO_PANHS:
\r
1979 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n"));
\r
1980 halbtc8812a1ant_ActionPanHs(pBtCoexist);
\r
1982 case BT_8812A_1ANT_COEX_ALGO_PANEDR_A2DP:
\r
1983 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
\r
1984 halbtc8812a1ant_ActionPanEdrA2dp(pBtCoexist);
\r
1986 case BT_8812A_1ANT_COEX_ALGO_PANEDR_HID:
\r
1987 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
\r
1988 halbtc8812a1ant_ActionPanEdrHid(pBtCoexist);
\r
1990 case BT_8812A_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
\r
1991 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
\r
1992 halbtc8812a1ant_ActionHidA2dpPanEdr(pBtCoexist);
\r
1994 case BT_8812A_1ANT_COEX_ALGO_HID_A2DP:
\r
1995 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
\r
1996 halbtc8812a1ant_ActionHidA2dp(pBtCoexist);
\r
1999 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
\r
2000 halbtc8812a1ant_CoexAllOff(pBtCoexist);
\r
2003 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
\r
2008 halbtc8812a1ant_RunCoexistMechanism(
\r
2009 IN PBTC_COEXIST pBtCoexist
\r
2012 BOOLEAN bWifiUnder5G=FALSE, bWifiBusy=FALSE, bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2014 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n"));
\r
2016 if(pBtCoexist->bManualControl)
\r
2018 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
\r
2022 if(pBtCoexist->bStopCoexDm)
\r
2024 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
\r
2028 if(pCoexSta->bUnderIps)
\r
2030 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
\r
2034 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
2037 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n"));
\r
2038 halbtc8812a1ant_CoexUnder5G(pBtCoexist);
\r
2042 halbtc8812a1ant_RunSwCoexistMechanism(pBtCoexist);
\r
2044 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2045 if(pCoexSta->bC2hBtInquiryPage)
\r
2047 halbtc8812a1ant_ActionBtInquiry(pBtCoexist);
\r
2052 halbtc8812a1ant_ActionHs(pBtCoexist);
\r
2056 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2057 if(!bWifiConnected)
\r
2059 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2061 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n"));
\r
2063 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2064 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2065 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2067 if(bScan || bLink || bRoam)
\r
2068 halbtc8812a1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
\r
2070 halbtc8812a1ant_ActionWifiNotConnected(pBtCoexist);
\r
2072 else // wifi LPS/Busy
\r
2074 halbtc8812a1ant_ActionWifiConnected(pBtCoexist);
\r
2079 halbtc8812a1ant_InitCoexDm(
\r
2080 IN PBTC_COEXIST pBtCoexist
\r
2083 // force to reset coex mechanism
\r
2084 halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
\r
2085 halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
2088 //============================================================
\r
2089 // work around function start with wa_halbtc8812a1ant_
\r
2090 //============================================================
\r
2091 //============================================================
\r
2092 // extern function start with EXhalbtc8812a1ant_
\r
2093 //============================================================
\r
2095 EXhalbtc8812a1ant_InitHwConfig(
\r
2096 IN PBTC_COEXIST pBtCoexist
\r
2103 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
\r
2105 //ant sw control to BT
\r
2106 halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, TRUE, FALSE);
\r
2109 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
\r
2112 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
\r
2115 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, 0x0);
\r
2116 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, 0xffff);
\r
2117 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, 0x55555555);
\r
2118 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, 0x55555555);
\r
2120 // coex parameters
\r
2121 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1);
\r
2123 // enable counter statistics
\r
2124 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
2127 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20);
\r
2129 // bt clock related
\r
2130 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4);
\r
2132 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4, u1Tmp);
\r
2134 // bt clock related
\r
2135 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7);
\r
2137 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x7, u1Tmp);
\r
2141 EXhalbtc8812a1ant_InitCoexDm(
\r
2142 IN PBTC_COEXIST pBtCoexist
\r
2145 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
2147 pBtCoexist->bStopCoexDm = FALSE;
\r
2149 halbtc8812a1ant_InitCoexDm(pBtCoexist);
\r
2153 EXhalbtc8812a1ant_DisplayCoexInfo(
\r
2154 IN PBTC_COEXIST pBtCoexist
\r
2157 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
2158 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
2159 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2160 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
2161 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
2163 BOOLEAN bRoam=FALSE, bScan=FALSE, bLink=FALSE, bWifiUnder5G=FALSE;
\r
2164 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
2165 s4Byte wifiRssi=0, btHsRssi=0;
\r
2166 u4Byte wifiBw, wifiTrafficDir;
\r
2167 u1Byte wifiDot11Chnl, wifiHsChnl;
\r
2168 u4Byte fwVer=0, btPatchVer=0;
\r
2170 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
2171 CL_PRINTF(cliBuf);
\r
2173 if(pBtCoexist->bManualControl)
\r
2175 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
\r
2176 CL_PRINTF(cliBuf);
\r
2177 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
2178 CL_PRINTF(cliBuf);
\r
2180 if(pBtCoexist->bStopCoexDm)
\r
2182 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");
\r
2183 CL_PRINTF(cliBuf);
\r
2184 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
2185 CL_PRINTF(cliBuf);
\r
2188 if(!pBoardInfo->bBtExist)
\r
2190 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
\r
2191 CL_PRINTF(cliBuf);
\r
2195 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
\r
2196 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
\r
2197 CL_PRINTF(cliBuf);
\r
2199 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
2200 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
2201 CL_PRINTF(cliBuf);
\r
2203 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
2204 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
2205 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
\r
2206 GLCoexVerDate8812a1Ant, GLCoexVer8812a1Ant, fwVer, btPatchVer, btPatchVer);
\r
2207 CL_PRINTF(cliBuf);
\r
2209 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2210 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
\r
2211 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
\r
2212 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
\r
2213 wifiDot11Chnl, wifiHsChnl, bBtHsOn);
\r
2214 CL_PRINTF(cliBuf);
\r
2216 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
\r
2217 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
\r
2218 pCoexDm->wifiChnlInfo[2]);
\r
2219 CL_PRINTF(cliBuf);
\r
2221 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
2222 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
\r
2223 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
\r
2224 wifiRssi, btHsRssi);
\r
2225 CL_PRINTF(cliBuf);
\r
2227 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2228 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2229 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2230 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
\r
2231 bLink, bRoam, bScan);
\r
2232 CL_PRINTF(cliBuf);
\r
2234 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
2235 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
2236 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
2237 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
2238 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
\r
2239 (bWifiUnder5G? "5G":"2.4G"),
\r
2240 ((BTC_WIFI_BW_LEGACY==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40==wifiBw)? "HT40":"HT20"))),
\r
2241 ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
\r
2242 CL_PRINTF(cliBuf);
\r
2243 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
\r
2244 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
\r
2245 ( (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
\r
2246 pCoexSta->btRssi, pCoexSta->btRetryCnt);
\r
2247 CL_PRINTF(cliBuf);
\r
2249 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
2250 pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);
\r
2251 CL_PRINTF(cliBuf);
\r
2252 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
2254 btInfoExt = pCoexSta->btInfoExt;
\r
2255 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
\r
2256 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
\r
2257 CL_PRINTF(cliBuf);
\r
2259 for(i=0; i<BT_INFO_SRC_8812A_1ANT_MAX; i++)
\r
2261 if(pCoexSta->btInfoC2hCnt[i])
\r
2263 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8812a1Ant[i], \
\r
2264 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
\r
2265 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
\r
2266 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
\r
2267 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
\r
2268 CL_PRINTF(cliBuf);
\r
2271 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", \
\r
2272 ((pCoexSta->bUnderIps? "IPS ON":"IPS OFF")),
\r
2273 ((pCoexSta->bUnderLps? "LPS ON":"LPS OFF")),
\r
2274 pBtCoexist->btInfo.lpsVal,
\r
2275 pBtCoexist->btInfo.rpwmVal);
\r
2276 CL_PRINTF(cliBuf);
\r
2277 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
\r
2279 if(!pBtCoexist->bManualControl)
\r
2282 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
2283 CL_PRINTF(cliBuf);
\r
2285 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \
\r
2286 (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"),
\r
2287 pBtCoexist->btInfo.aggBufSize);
\r
2288 CL_PRINTF(cliBuf);
\r
2289 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \
\r
2290 pBtCoexist->btInfo.raMask);
\r
2291 CL_PRINTF(cliBuf);
\r
2294 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
2295 CL_PRINTF(cliBuf);
\r
2297 psTdmaCase = pCoexDm->curPsTdma;
\r
2298 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \
\r
2299 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
\r
2300 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
\r
2301 pCoexDm->psTdmaPara[4], psTdmaCase);
\r
2302 CL_PRINTF(cliBuf);
\r
2304 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
\r
2305 pCoexDm->errorCondition);
\r
2306 CL_PRINTF(cliBuf);
\r
2308 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \
\r
2309 pCoexDm->bCurIgnoreWlanAct);
\r
2310 CL_PRINTF(cliBuf);
\r
2314 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
2315 CL_PRINTF(cliBuf);
\r
2317 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
\r
2318 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \
\r
2320 CL_PRINTF(cliBuf);
\r
2322 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb3);
\r
2323 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7);
\r
2324 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x900);
\r
2325 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xcb3/0xcb7/0x900", \
\r
2326 u1Tmp[0], u1Tmp[1], u4Tmp[0]);
\r
2327 CL_PRINTF(cliBuf);
\r
2329 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
2330 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \
\r
2332 CL_PRINTF(cliBuf);
\r
2334 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
\r
2335 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
\r
2336 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
\r
2337 u4Tmp[0], u1Tmp[0]);
\r
2338 CL_PRINTF(cliBuf);
\r
2340 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
2341 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
\r
2343 CL_PRINTF(cliBuf);
\r
2345 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
\r
2346 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
2347 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
2348 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
\r
2349 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
\r
2350 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
\r
2351 CL_PRINTF(cliBuf);
\r
2353 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \
\r
2354 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
\r
2355 CL_PRINTF(cliBuf);
\r
2356 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
\r
2357 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
\r
2358 CL_PRINTF(cliBuf);
\r
2360 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
2365 EXhalbtc8812a1ant_IpsNotify(
\r
2366 IN PBTC_COEXIST pBtCoexist,
\r
2372 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
2375 if(BTC_IPS_ENTER == type)
\r
2377 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
\r
2378 pCoexSta->bUnderIps = TRUE;
\r
2379 halbtc8812a1ant_CoexAllOff(pBtCoexist);
\r
2380 halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
2382 else if(BTC_IPS_LEAVE == type)
\r
2384 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
\r
2385 pCoexSta->bUnderIps = FALSE;
\r
2390 EXhalbtc8812a1ant_LpsNotify(
\r
2391 IN PBTC_COEXIST pBtCoexist,
\r
2395 if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
\r
2398 if(BTC_LPS_ENABLE == type)
\r
2400 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
\r
2401 pCoexSta->bUnderLps = TRUE;
\r
2403 else if(BTC_LPS_DISABLE == type)
\r
2405 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
\r
2406 pCoexSta->bUnderLps = FALSE;
\r
2411 EXhalbtc8812a1ant_ScanNotify(
\r
2412 IN PBTC_COEXIST pBtCoexist,
\r
2416 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2418 if(pBtCoexist->bManualControl ||
\r
2419 pBtCoexist->bStopCoexDm ||
\r
2420 pBtCoexist->btInfo.bBtDisabled )
\r
2423 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2424 if(pCoexSta->bC2hBtInquiryPage)
\r
2426 halbtc8812a1ant_ActionBtInquiry(pBtCoexist);
\r
2431 halbtc8812a1ant_ActionHs(pBtCoexist);
\r
2435 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2436 if(BTC_SCAN_START == type)
\r
2438 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
\r
2439 if(!bWifiConnected) // non-connected scan
\r
2441 halbtc8812a1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
\r
2443 else // wifi is connected
\r
2445 halbtc8812a1ant_ActionWifiConnectedScan(pBtCoexist);
\r
2448 else if(BTC_SCAN_FINISH == type)
\r
2450 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
\r
2451 if(!bWifiConnected) // non-connected scan
\r
2453 halbtc8812a1ant_ActionWifiNotConnected(pBtCoexist);
\r
2457 halbtc8812a1ant_ActionWifiConnected(pBtCoexist);
\r
2463 EXhalbtc8812a1ant_ConnectNotify(
\r
2464 IN PBTC_COEXIST pBtCoexist,
\r
2468 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
\r
2470 if(pBtCoexist->bManualControl ||
\r
2471 pBtCoexist->bStopCoexDm ||
\r
2472 pBtCoexist->btInfo.bBtDisabled )
\r
2475 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2476 if(pCoexSta->bC2hBtInquiryPage)
\r
2478 halbtc8812a1ant_ActionBtInquiry(pBtCoexist);
\r
2483 halbtc8812a1ant_ActionHs(pBtCoexist);
\r
2487 if(BTC_ASSOCIATE_START == type)
\r
2489 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
\r
2490 halbtc8812a1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
\r
2492 else if(BTC_ASSOCIATE_FINISH == type)
\r
2494 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
\r
2496 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2497 if(!bWifiConnected) // non-connected scan
\r
2499 halbtc8812a1ant_ActionWifiNotConnected(pBtCoexist);
\r
2503 halbtc8812a1ant_ActionWifiConnected(pBtCoexist);
\r
2509 EXhalbtc8812a1ant_MediaStatusNotify(
\r
2510 IN PBTC_COEXIST pBtCoexist,
\r
2515 u1Byte buf[6] = {0};
\r
2516 u1Byte H2C_Parameter[3] ={0};
\r
2518 u1Byte wifiCentralChnl;
\r
2520 if(pBtCoexist->bManualControl ||
\r
2521 pBtCoexist->bStopCoexDm ||
\r
2522 pBtCoexist->btInfo.bBtDisabled )
\r
2525 if(BTC_MEDIA_CONNECT == type)
\r
2527 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
\r
2531 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
\r
2534 // only 2.4G we need to inform bt the chnl mask
\r
2535 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
\r
2536 if( (BTC_MEDIA_CONNECT == type) &&
\r
2537 (wifiCentralChnl <= 14) )
\r
2539 H2C_Parameter[0] = 0x1;
\r
2540 H2C_Parameter[1] = wifiCentralChnl;
\r
2541 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
2542 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
2543 H2C_Parameter[2] = 0x30;
\r
2545 H2C_Parameter[2] = 0x20;
\r
2548 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
\r
2549 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
\r
2550 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
\r
2553 buf[1] = 0x5; // OP_Code
\r
2554 buf[2] = 0x3; // OP_Code_Length
\r
2555 buf[3] = H2C_Parameter[0]; // OP_Code_Content
\r
2556 buf[4] = H2C_Parameter[1];
\r
2557 buf[5] = H2C_Parameter[2];
\r
2559 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
\r
2563 EXhalbtc8812a1ant_SpecialPacketNotify(
\r
2564 IN PBTC_COEXIST pBtCoexist,
\r
2568 BOOLEAN bBtHsOn=FALSE;
\r
2570 if(pBtCoexist->bManualControl ||
\r
2571 pBtCoexist->bStopCoexDm ||
\r
2572 pBtCoexist->btInfo.bBtDisabled )
\r
2575 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2576 if(pCoexSta->bC2hBtInquiryPage)
\r
2578 halbtc8812a1ant_ActionBtInquiry(pBtCoexist);
\r
2583 halbtc8812a1ant_ActionHs(pBtCoexist);
\r
2587 if( BTC_PACKET_DHCP == type ||
\r
2588 BTC_PACKET_EAPOL == type )
\r
2590 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet(%d) notify\n", type));
\r
2591 halbtc8812a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
\r
2596 EXhalbtc8812a1ant_BtInfoNotify(
\r
2597 IN PBTC_COEXIST pBtCoexist,
\r
2598 IN pu1Byte tmpBuf,
\r
2602 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2604 u1Byte i, rspSource=0;
\r
2605 static u4Byte setBtPsdMode=0;
\r
2606 BOOLEAN bBtBusy=FALSE;
\r
2607 BOOLEAN bWifiConnected=FALSE;
\r
2608 BOOLEAN bBtCtrlAggBufSize=FALSE, bRejApAggPkt=FALSE;
\r
2610 rspSource = tmpBuf[0]&0xf;
\r
2611 if(rspSource >= BT_INFO_SRC_8812A_1ANT_MAX)
\r
2612 rspSource = BT_INFO_SRC_8812A_1ANT_WIFI_FW;
\r
2613 pCoexSta->btInfoC2hCnt[rspSource]++;
\r
2615 if(BT_INFO_SRC_8812A_1ANT_BT_RSP == rspSource)
\r
2616 pCoexSta->btInfoQueryCnt = pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8812A_1ANT_BT_RSP];
\r
2618 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
\r
2619 for(i=0; i<length; i++)
\r
2621 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
\r
2623 btInfo = tmpBuf[i];
\r
2626 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
\r
2630 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
\r
2634 if(pBtCoexist->btInfo.bBtDisabled)
\r
2636 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for BT is disabled <===\n"));
\r
2640 if(pBtCoexist->bManualControl)
\r
2642 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
\r
2645 if(pBtCoexist->bStopCoexDm)
\r
2647 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Coex STOPPED!!<===\n"));
\r
2651 if(BT_INFO_SRC_8812A_1ANT_WIFI_FW != rspSource)
\r
2653 pCoexSta->btRetryCnt = // [3:0]
\r
2654 pCoexSta->btInfoC2h[rspSource][2]&0xf;
\r
2656 pCoexSta->btRssi =
\r
2657 pCoexSta->btInfoC2h[rspSource][3]*2+10;
\r
2659 pCoexSta->btInfoExt =
\r
2660 pCoexSta->btInfoC2h[rspSource][4];
\r
2662 // Here we need to resend some wifi info to BT
\r
2663 // because bt is reset and loss of the info.
\r
2664 if( (pCoexSta->btInfoExt & BIT1) )
\r
2666 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
\r
2667 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2668 if(bWifiConnected)
\r
2670 EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
\r
2674 EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
2680 // test-chip bt patch only rsp the status for BT_RSP,
\r
2681 // so temporary we consider the following only under BT_RSP
\r
2682 if(BT_INFO_SRC_8812A_1ANT_BT_RSP == rspSource)
\r
2684 if( (pCoexSta->btInfoExt & BIT3) )
\r
2686 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
\r
2687 halbtc8812a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
2691 // BT already NOT ignore Wlan active, do nothing here.
\r
2694 if( (pCoexSta->btInfoExt & BIT4) )
\r
2696 // BT auto report already enabled, do nothing
\r
2700 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit4 check, set BT to enable Auto Report!!\n"));
\r
2701 halbtc8812a1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);
\r
2706 // check BIT2 first ==> check if bt is under inquiry or page scan
\r
2707 if(btInfo & BT_INFO_8812A_1ANT_B_INQ_PAGE)
\r
2708 pCoexSta->bC2hBtInquiryPage = TRUE;
\r
2710 pCoexSta->bC2hBtInquiryPage = FALSE;
\r
2712 // set link exist status
\r
2713 if(!(btInfo&BT_INFO_8812A_1ANT_B_CONNECTION))
\r
2715 pCoexSta->bBtLinkExist = FALSE;
\r
2716 pCoexSta->bPanExist = FALSE;
\r
2717 pCoexSta->bA2dpExist = FALSE;
\r
2718 pCoexSta->bHidExist = FALSE;
\r
2719 pCoexSta->bScoExist = FALSE;
\r
2721 else // connection exists
\r
2723 pCoexSta->bBtLinkExist = TRUE;
\r
2724 if(btInfo & BT_INFO_8812A_1ANT_B_FTP)
\r
2725 pCoexSta->bPanExist = TRUE;
\r
2727 pCoexSta->bPanExist = FALSE;
\r
2728 if(btInfo & BT_INFO_8812A_1ANT_B_A2DP)
\r
2729 pCoexSta->bA2dpExist = TRUE;
\r
2731 pCoexSta->bA2dpExist = FALSE;
\r
2732 if(btInfo & BT_INFO_8812A_1ANT_B_HID)
\r
2733 pCoexSta->bHidExist = TRUE;
\r
2735 pCoexSta->bHidExist = FALSE;
\r
2736 if(btInfo & BT_INFO_8812A_1ANT_B_SCO_ESCO)
\r
2737 pCoexSta->bScoExist = TRUE;
\r
2739 pCoexSta->bScoExist = FALSE;
\r
2742 halbtc8812a1ant_UpdateBtLinkInfo(pBtCoexist);
\r
2744 if(!(btInfo&BT_INFO_8812A_1ANT_B_CONNECTION))
\r
2746 pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
\r
2747 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-connected idle!!!\n"));
\r
2749 else if(btInfo == BT_INFO_8812A_1ANT_B_CONNECTION) // connection exists but no busy
\r
2751 pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE;
\r
2752 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt connected-idle!!!\n"));
\r
2754 else if((btInfo&BT_INFO_8812A_1ANT_B_SCO_ESCO) ||
\r
2755 (btInfo&BT_INFO_8812A_1ANT_B_SCO_BUSY))
\r
2757 pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_SCO_BUSY;
\r
2758 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt sco busy!!!\n"));
\r
2760 else if(btInfo&BT_INFO_8812A_1ANT_B_ACL_BUSY)
\r
2762 if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
\r
2763 pCoexDm->bResetTdmaAdjust = TRUE;
\r
2764 pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_ACL_BUSY;
\r
2765 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt acl busy!!!\n"));
\r
2769 pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_MAX;
\r
2770 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-defined state!!!\n"));
\r
2773 if(pBtLinkInfo->bScoExist)
\r
2775 bRejApAggPkt = TRUE;
\r
2776 halbtc8812a1ant_UpdateRaMask(pBtCoexist, NORMAL_EXEC, BTC_RATE_DISABLE, 0x00000003); // disable cck 1M2M.
\r
2780 halbtc8812a1ant_UpdateRaMask(pBtCoexist, NORMAL_EXEC, BTC_RATE_ENABLE, 0x00000003); // enable cck 1M2M.
\r
2783 if( (BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
2784 (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
2785 (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
2788 if(pBtLinkInfo->bHidExist)
\r
2789 bBtCtrlAggBufSize = TRUE;
\r
2795 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
2797 //============================================
\r
2798 // Aggregation related setting
\r
2799 //============================================
\r
2800 // if sco, reject AddBA
\r
2801 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejApAggPkt);
\r
2802 // decide BT control aggregation buf size or not
\r
2803 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlAggBufSize);
\r
2804 // real update aggregation setting
\r
2805 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
\r
2806 //============================================
\r
2808 halbtc8812a1ant_RunCoexistMechanism(pBtCoexist);
\r
2812 EXhalbtc8812a1ant_HaltNotify(
\r
2813 IN PBTC_COEXIST pBtCoexist
\r
2816 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
\r
2818 halbtc8812a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
2819 halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
\r
2820 halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
\r
2821 EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
2825 EXhalbtc8812a1ant_PnpNotify(
\r
2826 IN PBTC_COEXIST pBtCoexist,
\r
2827 IN u1Byte pnpState
\r
2830 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
\r
2832 if(BTC_WIFI_PNP_SLEEP == pnpState)
\r
2834 pBtCoexist->bStopCoexDm = TRUE;
\r
2835 halbtc8812a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
2836 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2837 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
2839 else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
\r
2846 EXhalbtc8812a1ant_Periodical(
\r
2847 IN PBTC_COEXIST pBtCoexist
\r
2850 static u1Byte disVerInfoCnt=0;
\r
2851 u4Byte fwVer=0, btPatchVer=0;
\r
2852 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
2853 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
2855 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical===========================\n"));
\r
2857 if(disVerInfoCnt <= 5)
\r
2859 disVerInfoCnt += 1;
\r
2860 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
2861 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", \
\r
2862 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));
\r
2863 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", \
\r
2864 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
\r
2865 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
2866 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
2867 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
\r
2868 GLCoexVerDate8812a1Ant, GLCoexVer8812a1Ant, fwVer, btPatchVer, btPatchVer));
\r
2869 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
\r
2872 halbtc8812a1ant_QueryBtInfo(pBtCoexist);
\r
2873 halbtc8812a1ant_MonitorBtCtr(pBtCoexist);
\r
2874 halbtc8812a1ant_MonitorBtEnableDisable(pBtCoexist);
\r
2878 EXhalbtc8812a1ant_DbgControl(
\r
2879 IN PBTC_COEXIST pBtCoexist,
\r
2887 case BTC_DBG_SET_COEX_NORMAL:
\r
2888 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Set CoexMode to Normal\n"));
\r
2889 pBtCoexist->bManualControl = FALSE;
\r
2890 halbtc8812a1ant_InitCoexDm(pBtCoexist);
\r
2892 case BTC_DBG_SET_COEX_WIFI_ONLY:
\r
2893 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Set CoexMode to Wifi Only\n"));
\r
2894 pBtCoexist->bManualControl = TRUE;
\r
2895 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2896 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
2898 case BTC_DBG_SET_COEX_BT_ONLY:
\r
2899 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Set CoexMode to BT only\n"));
\r
2900 pBtCoexist->bManualControl = TRUE;
\r
2901 halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2902 halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
2904 case BTC_DBG_SET_COEX_DEC_BT_PWR:
\r
2905 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Set Dec BT power\n"));
\r
2908 u1Byte buf[6] = {0};
\r
2909 u1Byte decBtPwr=0, pwrLevel=0;
\r
2912 decBtPwr = pData[0];
\r
2913 pwrLevel = pData[1];
\r
2916 buf[1] = 0x3; // OP_Code
\r
2917 buf[2] = 0x2; // OP_Code_Length
\r
2919 buf[3] = decBtPwr; // OP_Code_Content
\r
2920 buf[4] = pwrLevel;
\r
2921 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Set Dec BT power=%d, pwrLevel=%d\n", decBtPwr, pwrLevel));
\r
2922 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
\r
2927 case BTC_DBG_SET_COEX_BT_AFH_MAP:
\r
2928 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Set BT AFH Map\n"));
\r
2931 u1Byte buf[6] = {0};
\r
2935 buf[1] = 0x5; // OP_Code
\r
2936 buf[2] = 0x3; // OP_Code_Length
\r
2938 buf[3] = pData[0]; // OP_Code_Content
\r
2939 buf[4] = pData[1];
\r
2940 buf[5] = pData[2];
\r
2942 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Set BT AFH Map = %02x %02x %02x\n",
\r
2943 pData[0], pData[1], pData[2]));
\r
2944 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
\r
2949 case BTC_DBG_SET_COEX_BT_IGNORE_WLAN_ACT:
\r
2950 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Set BT Ignore Wlan Active\n"));
\r
2953 u1Byte buf[6] = {0};
\r
2957 buf[1] = 0x1; // OP_Code
\r
2958 buf[2] = 0x1; // OP_Code_Length
\r
2960 buf[3] = pData[0]; // OP_Code_Content
\r
2961 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Set BT Ignore Wlan Active = 0x%x\n",
\r
2964 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
\r