1 //============================================================
\r
4 // This file is for RTL8821A 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
16 #if WPP_SOFTWARE_TRACE
\r
17 #include "HalBtc8821a2Ant.tmh"
\r
20 #if(BT_30_SUPPORT == 1)
\r
21 //============================================================
\r
22 // Global variables, these are static variables
\r
23 //============================================================
\r
24 static COEX_DM_8821A_2ANT GLCoexDm8821a2Ant;
\r
25 static PCOEX_DM_8821A_2ANT pCoexDm=&GLCoexDm8821a2Ant;
\r
26 static COEX_STA_8821A_2ANT GLCoexSta8821a2Ant;
\r
27 static PCOEX_STA_8821A_2ANT pCoexSta=&GLCoexSta8821a2Ant;
\r
29 const char *const GLBtInfoSrc8821a2Ant[]={
\r
32 "BT Info[bt auto report]",
\r
35 u4Byte GLCoexVerDate8821a2Ant=20150128;
\r
36 u4Byte GLCoexVer8821a2Ant=0x51;
\r
38 //============================================================
\r
39 // local function proto type if needed
\r
40 //============================================================
\r
41 //============================================================
\r
42 // local function start with halbtc8821a2ant_
\r
43 //============================================================
\r
45 halbtc8821a2ant_BtRssiState(
\r
52 u1Byte btRssiState=pCoexSta->preBtRssiState;
\r
54 btRssi = pCoexSta->btRssi;
\r
58 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
59 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
61 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
\r
63 btRssiState = BTC_RSSI_STATE_HIGH;
\r
67 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
72 if(btRssi < rssiThresh)
\r
74 btRssiState = BTC_RSSI_STATE_LOW;
\r
78 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
82 else if(levelNum == 3)
\r
84 if(rssiThresh > rssiThresh1)
\r
86 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n"));
\r
87 return pCoexSta->preBtRssiState;
\r
90 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
\r
91 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
\r
93 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
\r
95 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
99 btRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
102 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
\r
103 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
\r
105 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
\r
107 btRssiState = BTC_RSSI_STATE_HIGH;
\r
109 else if(btRssi < rssiThresh)
\r
111 btRssiState = BTC_RSSI_STATE_LOW;
\r
115 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
120 if(btRssi < rssiThresh1)
\r
122 btRssiState = BTC_RSSI_STATE_MEDIUM;
\r
126 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
131 pCoexSta->preBtRssiState = btRssiState;
\r
133 return btRssiState;
\r
137 halbtc8821a2ant_WifiRssiState(
\r
138 IN PBTC_COEXIST pBtCoexist,
\r
140 IN u1Byte levelNum,
\r
141 IN u1Byte rssiThresh,
\r
142 IN u1Byte rssiThresh1
\r
146 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
\r
148 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
152 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
153 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
155 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
\r
157 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
161 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
166 if(wifiRssi < rssiThresh)
\r
168 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
172 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
176 else if(levelNum == 3)
\r
178 if(rssiThresh > rssiThresh1)
\r
180 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n"));
\r
181 return pCoexSta->preWifiRssiState[index];
\r
184 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
185 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
187 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
\r
189 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
193 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
196 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
\r
197 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
\r
199 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))
\r
201 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
203 else if(wifiRssi < rssiThresh)
\r
205 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
209 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
214 if(wifiRssi < rssiThresh1)
\r
216 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
220 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
225 pCoexSta->preWifiRssiState[index] = wifiRssiState;
\r
227 return wifiRssiState;
\r
231 halbtc8821a2ant_MonitorBtEnableDisable(
\r
232 IN PBTC_COEXIST pBtCoexist
\r
235 static BOOLEAN bPreBtDisabled=FALSE;
\r
236 static u4Byte btDisableCnt=0;
\r
237 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
\r
239 // This function check if bt is disabled
\r
241 if( pCoexSta->highPriorityTx == 0 &&
\r
242 pCoexSta->highPriorityRx == 0 &&
\r
243 pCoexSta->lowPriorityTx == 0 &&
\r
244 pCoexSta->lowPriorityRx == 0)
\r
248 if( pCoexSta->highPriorityTx == 0xffff &&
\r
249 pCoexSta->highPriorityRx == 0xffff &&
\r
250 pCoexSta->lowPriorityTx == 0xffff &&
\r
251 pCoexSta->lowPriorityRx == 0xffff)
\r
258 bBtDisabled = FALSE;
\r
259 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
260 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n"));
\r
265 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n",
\r
267 if(btDisableCnt >= 2)
\r
269 bBtDisabled = TRUE;
\r
270 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
271 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n"));
\r
274 if(bPreBtDisabled != bBtDisabled)
\r
276 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n",
\r
277 (bPreBtDisabled ? "disabled":"enabled"),
\r
278 (bBtDisabled ? "disabled":"enabled")));
\r
279 bPreBtDisabled = bBtDisabled;
\r
290 halbtc8821a2ant_LimitedRx(
\r
291 IN PBTC_COEXIST pBtCoexist,
\r
292 IN BOOLEAN bForceExec,
\r
293 IN BOOLEAN bRejApAggPkt,
\r
294 IN BOOLEAN bBtCtrlAggBufSize,
\r
295 IN u1Byte aggBufSize
\r
298 BOOLEAN bRejectRxAgg=bRejApAggPkt;
\r
299 BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize;
\r
300 u1Byte rxAggSize=aggBufSize;
\r
302 //============================================
\r
303 // Rx Aggregation related setting
\r
304 //============================================
\r
305 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);
\r
306 // decide BT control aggregation buf size or not
\r
307 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);
\r
308 // aggregation buf size, only work when BT control Rx aggregation size.
\r
309 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
\r
310 // real update aggregation setting
\r
311 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
\r
315 halbtc8821a2ant_MonitorBtCtr(
\r
316 IN PBTC_COEXIST pBtCoexist
\r
319 u4Byte regHPTxRx, regLPTxRx, u4Tmp;
\r
320 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
\r
323 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
328 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
\r
329 regHPTx = u4Tmp & bMaskLWord;
\r
330 regHPRx = (u4Tmp & bMaskHWord)>>16;
\r
332 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
\r
333 regLPTx = u4Tmp & bMaskLWord;
\r
334 regLPRx = (u4Tmp & bMaskHWord)>>16;
\r
336 pCoexSta->highPriorityTx = regHPTx;
\r
337 pCoexSta->highPriorityRx = regHPRx;
\r
338 pCoexSta->lowPriorityTx = regLPTx;
\r
339 pCoexSta->lowPriorityRx = regLPRx;
\r
341 if ( (pCoexSta->lowPriorityRx >= 950) && (pCoexSta->lowPriorityRx >= pCoexSta->lowPriorityTx) && (!pCoexSta->bUnderIps) )
\r
343 pBtLinkInfo->bSlaveRole = TRUE;
\r
347 pBtLinkInfo->bSlaveRole = FALSE;
\r
350 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
351 regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
\r
352 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
353 regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
\r
356 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
360 halbtc8821a2ant_MonitorWiFiCtr(
\r
361 IN PBTC_COEXIST pBtCoexist
\r
367 BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE;
\r
368 static u1Byte nCCKLockCounter = 0;
\r
371 if (pCoexSta->bUnderIps)
\r
373 pCoexSta->nCRCOK_CCK = 0;
\r
374 pCoexSta->nCRCOK_11g = 0;
\r
375 pCoexSta->nCRCOK_11n = 0;
\r
376 pCoexSta->nCRCOK_11nAgg = 0;
\r
378 pCoexSta->nCRCErr_CCK = 0;
\r
379 pCoexSta->nCRCErr_11g = 0;
\r
380 pCoexSta->nCRCErr_11n = 0;
\r
381 pCoexSta->nCRCErr_11nAgg = 0;
\r
385 pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88);
\r
386 pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94);
\r
387 pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90);
\r
388 pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8);
\r
390 pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84);
\r
391 pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96);
\r
392 pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92);
\r
393 pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba);
\r
397 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1);
\r
398 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0);
\r
402 halbtc8821a2ant_QueryBtInfo(
\r
403 IN PBTC_COEXIST pBtCoexist
\r
406 u1Byte H2C_Parameter[1] ={0};
\r
408 pCoexSta->bC2hBtInfoReqSent = TRUE;
\r
410 H2C_Parameter[0] |= BIT0; // trigger
\r
412 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
\r
413 H2C_Parameter[0]));
\r
415 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
\r
419 halbtc8821a2ant_IsWifiStatusChanged(
\r
420 IN PBTC_COEXIST pBtCoexist
\r
423 static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;
\r
424 BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;
\r
425 BOOLEAN bWifiConnected=FALSE;
\r
426 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
\r
429 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
430 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
431 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
432 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
\r
436 if(bWifiBusy != bPreWifiBusy)
\r
438 bPreWifiBusy = bWifiBusy;
\r
441 if(bUnder4way != bPreUnder4way)
\r
443 bPreUnder4way = bUnder4way;
\r
446 if(bBtHsOn != bPreBtHsOn)
\r
448 bPreBtHsOn = bBtHsOn;
\r
453 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist,3, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
455 if ( (BTC_RSSI_STATE_HIGH ==wifiRssiState ) || (BTC_RSSI_STATE_LOW ==wifiRssiState ))
\r
466 halbtc8821a2ant_UpdateBtLinkInfo(
\r
467 IN PBTC_COEXIST pBtCoexist
\r
470 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
471 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
472 BOOLEAN bBtHsOn=FALSE;
\r
474 #if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 1) // profile from bt patch
\r
475 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
477 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
\r
478 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
\r
479 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
\r
480 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
\r
481 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
\r
483 // work around for HS mode.
\r
486 pBtLinkInfo->bPanExist = TRUE;
\r
487 pBtLinkInfo->bBtLinkExist = TRUE;
\r
489 #else // profile from bt stack
\r
490 pBtLinkInfo->bBtLinkExist = pStackInfo->bBtLinkExist;
\r
491 pBtLinkInfo->bScoExist = pStackInfo->bScoExist;
\r
492 pBtLinkInfo->bA2dpExist = pStackInfo->bA2dpExist;
\r
493 pBtLinkInfo->bPanExist = pStackInfo->bPanExist;
\r
494 pBtLinkInfo->bHidExist = pStackInfo->bHidExist;
\r
496 //for win-8 stack HID report error
\r
497 if(!pStackInfo->bHidExist)
\r
498 pStackInfo->bHidExist = pCoexSta->bHidExist; //sync BTInfo with BT firmware and stack
\r
499 // when stack HID report error, here we use the info from bt fw.
\r
500 if(!pStackInfo->bBtLinkExist)
\r
501 pStackInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
\r
503 // check if Sco only
\r
504 if( pBtLinkInfo->bScoExist &&
\r
505 !pBtLinkInfo->bA2dpExist &&
\r
506 !pBtLinkInfo->bPanExist &&
\r
507 !pBtLinkInfo->bHidExist )
\r
508 pBtLinkInfo->bScoOnly = TRUE;
\r
510 pBtLinkInfo->bScoOnly = FALSE;
\r
512 // check if A2dp only
\r
513 if( !pBtLinkInfo->bScoExist &&
\r
514 pBtLinkInfo->bA2dpExist &&
\r
515 !pBtLinkInfo->bPanExist &&
\r
516 !pBtLinkInfo->bHidExist )
\r
517 pBtLinkInfo->bA2dpOnly = TRUE;
\r
519 pBtLinkInfo->bA2dpOnly = FALSE;
\r
521 // check if Pan only
\r
522 if( !pBtLinkInfo->bScoExist &&
\r
523 !pBtLinkInfo->bA2dpExist &&
\r
524 pBtLinkInfo->bPanExist &&
\r
525 !pBtLinkInfo->bHidExist )
\r
526 pBtLinkInfo->bPanOnly = TRUE;
\r
528 pBtLinkInfo->bPanOnly = FALSE;
\r
530 // check if Hid only
\r
531 if( !pBtLinkInfo->bScoExist &&
\r
532 !pBtLinkInfo->bA2dpExist &&
\r
533 !pBtLinkInfo->bPanExist &&
\r
534 pBtLinkInfo->bHidExist )
\r
535 pBtLinkInfo->bHidOnly = TRUE;
\r
537 pBtLinkInfo->bHidOnly = FALSE;
\r
541 halbtc8821a2ant_ActionAlgorithm(
\r
542 IN PBTC_COEXIST pBtCoexist
\r
545 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
546 BOOLEAN bBtHsOn=FALSE;
\r
547 u1Byte algorithm=BT_8821A_2ANT_COEX_ALGO_UNDEFINED;
\r
548 u1Byte numOfDiffProfile=0;
\r
550 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
552 if(!pBtLinkInfo->bBtLinkExist)
\r
554 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n"));
\r
558 if(pBtLinkInfo->bScoExist)
\r
559 numOfDiffProfile++;
\r
560 if(pBtLinkInfo->bHidExist)
\r
561 numOfDiffProfile++;
\r
562 if(pBtLinkInfo->bPanExist)
\r
563 numOfDiffProfile++;
\r
564 if(pBtLinkInfo->bA2dpExist)
\r
565 numOfDiffProfile++;
\r
567 if(numOfDiffProfile == 1)
\r
569 if(pBtLinkInfo->bScoExist)
\r
571 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n"));
\r
572 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
576 if(pBtLinkInfo->bHidExist)
\r
578 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n"));
\r
579 algorithm = BT_8821A_2ANT_COEX_ALGO_HID;
\r
581 else if(pBtLinkInfo->bA2dpExist)
\r
583 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n"));
\r
584 algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP;
\r
586 else if(pBtLinkInfo->bPanExist)
\r
590 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n"));
\r
591 algorithm = BT_8821A_2ANT_COEX_ALGO_PANHS;
\r
595 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n"));
\r
596 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR;
\r
601 else if(numOfDiffProfile == 2)
\r
603 if(pBtLinkInfo->bScoExist)
\r
605 if(pBtLinkInfo->bHidExist)
\r
607 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n"));
\r
608 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
610 else if(pBtLinkInfo->bA2dpExist)
\r
612 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n"));
\r
613 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
615 else if(pBtLinkInfo->bPanExist)
\r
619 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n"));
\r
620 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
624 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n"));
\r
625 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
631 if( pBtLinkInfo->bHidExist &&
\r
632 pBtLinkInfo->bA2dpExist )
\r
635 if(pStackInfo->numOfHid >= 2)
\r
637 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID*2 + A2DP\n"));
\r
638 algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
\r
643 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n"));
\r
644 algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP;
\r
647 else if( pBtLinkInfo->bHidExist &&
\r
648 pBtLinkInfo->bPanExist )
\r
652 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n"));
\r
653 algorithm = BT_8821A_2ANT_COEX_ALGO_HID;
\r
657 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n"));
\r
658 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
\r
661 else if( pBtLinkInfo->bPanExist &&
\r
662 pBtLinkInfo->bA2dpExist )
\r
666 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n"));
\r
667 algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS;
\r
671 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n"));
\r
672 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP;
\r
677 else if(numOfDiffProfile == 3)
\r
679 if(pBtLinkInfo->bScoExist)
\r
681 if( pBtLinkInfo->bHidExist &&
\r
682 pBtLinkInfo->bA2dpExist )
\r
684 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> SCO\n"));
\r
685 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
687 else if( pBtLinkInfo->bHidExist &&
\r
688 pBtLinkInfo->bPanExist )
\r
692 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS) ==> SCO\n"));
\r
693 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
697 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR) ==> SCO\n"));
\r
698 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
701 else if( pBtLinkInfo->bPanExist &&
\r
702 pBtLinkInfo->bA2dpExist )
\r
706 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
\r
707 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
711 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
\r
712 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
718 if( pBtLinkInfo->bHidExist &&
\r
719 pBtLinkInfo->bPanExist &&
\r
720 pBtLinkInfo->bA2dpExist )
\r
724 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
\r
725 algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP;
\r
729 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
\r
730 algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
\r
735 else if(numOfDiffProfile >= 3)
\r
737 if(pBtLinkInfo->bScoExist)
\r
739 if( pBtLinkInfo->bHidExist &&
\r
740 pBtLinkInfo->bPanExist &&
\r
741 pBtLinkInfo->bA2dpExist )
\r
745 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
\r
750 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
\r
751 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
\r
761 halbtc8821a2ant_SetFwDacSwingLevel(
\r
762 IN PBTC_COEXIST pBtCoexist,
\r
763 IN u1Byte dacSwingLvl
\r
766 u1Byte H2C_Parameter[1] ={0};
\r
768 // There are several type of dacswing
\r
769 // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
\r
770 H2C_Parameter[0] = dacSwingLvl;
\r
772 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl));
\r
773 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0]));
\r
775 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter);
\r
779 halbtc8821a2ant_SetFwDecBtPwr(
\r
780 IN PBTC_COEXIST pBtCoexist,
\r
781 IN u1Byte decBtPwrLvl
\r
784 u1Byte H2C_Parameter[1] ={0};
\r
786 H2C_Parameter[0] = decBtPwrLvl;
\r
788 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n",
\r
789 decBtPwrLvl, H2C_Parameter[0]));
\r
791 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter);
\r
795 halbtc8821a2ant_DecBtPwr(
\r
796 IN PBTC_COEXIST pBtCoexist,
\r
797 IN BOOLEAN bForceExec,
\r
798 IN u1Byte decBtPwrLvl
\r
801 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power level = %d\n",
\r
802 (bForceExec? "force to":""), decBtPwrLvl));
\r
803 pCoexDm->curBtDecPwrLvl = decBtPwrLvl;
\r
807 if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl)
\r
810 halbtc8821a2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
\r
812 pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
\r
816 halbtc8821a2ant_SetBtAutoReport(
\r
817 IN PBTC_COEXIST pBtCoexist,
\r
818 IN BOOLEAN bEnableAutoReport
\r
821 u1Byte H2C_Parameter[1] ={0};
\r
823 H2C_Parameter[0] = 0;
\r
825 if(bEnableAutoReport)
\r
827 H2C_Parameter[0] |= BIT0;
\r
830 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
\r
831 (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));
\r
833 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter);
\r
837 halbtc8821a2ant_BtAutoReport(
\r
838 IN PBTC_COEXIST pBtCoexist,
\r
839 IN BOOLEAN bForceExec,
\r
840 IN BOOLEAN bEnableAutoReport
\r
843 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n",
\r
844 (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
\r
845 pCoexDm->bCurBtAutoReport = bEnableAutoReport;
\r
849 if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
\r
852 halbtc8821a2ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
\r
854 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
\r
858 halbtc8821a2ant_FwDacSwingLvl(
\r
859 IN PBTC_COEXIST pBtCoexist,
\r
860 IN BOOLEAN bForceExec,
\r
861 IN u1Byte fwDacSwingLvl
\r
864 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n",
\r
865 (bForceExec? "force to":""), fwDacSwingLvl));
\r
866 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
\r
870 if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
\r
874 halbtc8821a2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
\r
876 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
\r
880 halbtc8821a2ant_SetSwRfRxLpfCorner(
\r
881 IN PBTC_COEXIST pBtCoexist,
\r
882 IN BOOLEAN bRxRfShrinkOn
\r
887 //Shrink RF Rx LPF corner
\r
888 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
\r
889 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc);
\r
893 //Resume RF Rx LPF corner
\r
894 // After initialized, we can use pCoexDm->btRf0x1eBackup
\r
895 if(pBtCoexist->bInitilized)
\r
897 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
\r
898 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
\r
904 halbtc8821a2ant_RfShrink(
\r
905 IN PBTC_COEXIST pBtCoexist,
\r
906 IN BOOLEAN bForceExec,
\r
907 IN BOOLEAN bRxRfShrinkOn
\r
910 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
\r
911 (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
\r
912 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
\r
916 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
\r
919 halbtc8821a2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
\r
921 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
\r
925 halbtc8821a2ant_SetSwPenaltyTxRateAdaptive(
\r
926 IN PBTC_COEXIST pBtCoexist,
\r
927 IN BOOLEAN bLowPenaltyRa
\r
930 u1Byte H2C_Parameter[6] ={0};
\r
932 H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty
\r
936 H2C_Parameter[1] |= BIT0;
\r
937 H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36
\r
938 H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54
\r
939 H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48
\r
940 H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36
\r
943 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s",
\r
944 (bLowPenaltyRa? "ON!!":"OFF!!")) );
\r
946 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
\r
950 halbtc8821a2ant_LowPenaltyRa(
\r
951 IN PBTC_COEXIST pBtCoexist,
\r
952 IN BOOLEAN bForceExec,
\r
953 IN BOOLEAN bLowPenaltyRa
\r
957 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
\r
958 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
\r
959 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
963 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
966 halbtc8821a2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
968 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
972 halbtc8821a2ant_SetDacSwingReg(
\r
973 IN PBTC_COEXIST pBtCoexist,
\r
977 u1Byte val=(u1Byte)level;
\r
979 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Write SwDacSwing = 0x%x\n", level));
\r
980 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc5b, 0x3e, val);
\r
984 halbtc8821a2ant_SetSwFullTimeDacSwing(
\r
985 IN PBTC_COEXIST pBtCoexist,
\r
986 IN BOOLEAN bSwDacSwingOn,
\r
987 IN u4Byte swDacSwingLvl
\r
992 halbtc8821a2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
\r
996 halbtc8821a2ant_SetDacSwingReg(pBtCoexist, 0x18);
\r
1002 halbtc8821a2ant_DacSwing(
\r
1003 IN PBTC_COEXIST pBtCoexist,
\r
1004 IN BOOLEAN bForceExec,
\r
1005 IN BOOLEAN bDacSwingOn,
\r
1006 IN u4Byte dacSwingLvl
\r
1009 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
\r
1010 (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
\r
1011 pCoexDm->bCurDacSwingOn = bDacSwingOn;
\r
1012 pCoexDm->curDacSwingLvl = dacSwingLvl;
\r
1016 if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
\r
1017 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
\r
1021 halbtc8821a2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
\r
1023 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
\r
1024 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
\r
1028 halbtc8821a2ant_SetAdcBackOff(
\r
1029 IN PBTC_COEXIST pBtCoexist,
\r
1030 IN BOOLEAN bAdcBackOff
\r
1035 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n"));
\r
1036 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x3);
\r
1040 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n"));
\r
1041 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x1);
\r
1046 halbtc8821a2ant_AdcBackOff(
\r
1047 IN PBTC_COEXIST pBtCoexist,
\r
1048 IN BOOLEAN bForceExec,
\r
1049 IN BOOLEAN bAdcBackOff
\r
1052 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n",
\r
1053 (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));
\r
1054 pCoexDm->bCurAdcBackOff = bAdcBackOff;
\r
1058 if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff)
\r
1061 halbtc8821a2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
\r
1063 pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
\r
1067 halbtc8821a2ant_SetAgcTable(
\r
1068 IN PBTC_COEXIST pBtCoexist,
\r
1069 IN BOOLEAN bAgcTableEn
\r
1072 u1Byte rssiAdjustVal=0;
\r
1074 //=================BB AGC Gain Table
\r
1077 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table On!\n"));
\r
1078 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e1A0001);
\r
1079 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d1B0001);
\r
1080 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6c1C0001);
\r
1081 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6b1D0001);
\r
1082 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1E0001);
\r
1083 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691F0001);
\r
1084 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68200001);
\r
1088 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table Off!\n"));
\r
1089 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001);
\r
1090 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001);
\r
1091 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001);
\r
1092 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001);
\r
1093 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001);
\r
1094 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001);
\r
1095 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa4200001);
\r
1099 //=================RF Gain
\r
1100 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
\r
1103 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n"));
\r
1104 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff);
\r
1105 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe);
\r
1109 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n"));
\r
1110 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3);
\r
1111 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6);
\r
1113 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
\r
1115 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1);
\r
1118 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n"));
\r
1119 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff);
\r
1120 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe);
\r
1124 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n"));
\r
1125 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3);
\r
1126 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6);
\r
1128 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0);
\r
1130 // set rssiAdjustVal for wifi module.
\r
1133 rssiAdjustVal = 8;
\r
1135 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
\r
1139 halbtc8821a2ant_AgcTable(
\r
1140 IN PBTC_COEXIST pBtCoexist,
\r
1141 IN BOOLEAN bForceExec,
\r
1142 IN BOOLEAN bAgcTableEn
\r
1145 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n",
\r
1146 (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));
\r
1147 pCoexDm->bCurAgcTableEn = bAgcTableEn;
\r
1151 if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
\r
1154 halbtc8821a2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
\r
1156 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
\r
1160 halbtc8821a2ant_SetCoexTable(
\r
1161 IN PBTC_COEXIST pBtCoexist,
\r
1162 IN u4Byte val0x6c0,
\r
1163 IN u4Byte val0x6c4,
\r
1164 IN u4Byte val0x6c8,
\r
1165 IN u1Byte val0x6cc
\r
1168 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
\r
1169 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
\r
1171 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
\r
1172 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
\r
1174 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
1175 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
1177 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
1178 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
1182 halbtc8821a2ant_CoexTable(
\r
1183 IN PBTC_COEXIST pBtCoexist,
\r
1184 IN BOOLEAN bForceExec,
\r
1185 IN u4Byte val0x6c0,
\r
1186 IN u4Byte val0x6c4,
\r
1187 IN u4Byte val0x6c8,
\r
1188 IN u1Byte val0x6cc
\r
1191 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
\r
1192 (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc));
\r
1193 pCoexDm->curVal0x6c0 = val0x6c0;
\r
1194 pCoexDm->curVal0x6c4 = val0x6c4;
\r
1195 pCoexDm->curVal0x6c8 = val0x6c8;
\r
1196 pCoexDm->curVal0x6cc = val0x6cc;
\r
1200 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
\r
1201 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
\r
1202 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
1203 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
1206 halbtc8821a2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
\r
1208 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
\r
1209 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
\r
1210 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
1211 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
1215 halbtc8821a2ant_CoexTableWithType(
\r
1216 IN PBTC_COEXIST pBtCoexist,
\r
1217 IN BOOLEAN bForceExec,
\r
1221 pCoexSta->nCoexTableType = type;
\r
1226 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);
\r
1229 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffffff, 0x3);
\r
1232 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5ada5ada, 0x5ada5ada, 0xffffff, 0x3);
\r
1235 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
\r
1238 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffffff, 0x3);
\r
1241 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3);
\r
1244 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3);
\r
1247 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1250 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1253 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1256 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1259 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1262 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1265 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0xaaaaaaaa, 0xffffff, 0x3);
\r
1268 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5ada5ada, 0xffffff, 0x3);
\r
1271 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0xaaaaaaaa, 0xffffff, 0x3);
\r
1274 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fdf5fdf, 0x5fdb5fdb, 0xffffff, 0x3);
\r
1277 halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0xfafafafa, 0xfafafafa, 0xffffff, 0x3);
\r
1285 halbtc8821a2ant_SetFwIgnoreWlanAct(
\r
1286 IN PBTC_COEXIST pBtCoexist,
\r
1287 IN BOOLEAN bEnable
\r
1290 u1Byte H2C_Parameter[1] ={0};
\r
1294 H2C_Parameter[0] |= BIT0; // function enable
\r
1297 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
\r
1298 H2C_Parameter[0]));
\r
1300 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
\r
1304 halbtc8821a2ant_SetLpsRpwm(
\r
1305 IN PBTC_COEXIST pBtCoexist,
\r
1310 u1Byte lps=lpsVal;
\r
1311 u1Byte rpwm=rpwmVal;
\r
1313 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
\r
1314 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
\r
1318 halbtc8821a2ant_LpsRpwm(
\r
1319 IN PBTC_COEXIST pBtCoexist,
\r
1320 IN BOOLEAN bForceExec,
\r
1325 BOOLEAN bForceExecPwrCmd=FALSE;
\r
1327 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
\r
1328 (bForceExec? "force to":""), lpsVal, rpwmVal));
\r
1329 pCoexDm->curLps = lpsVal;
\r
1330 pCoexDm->curRpwm = rpwmVal;
\r
1334 if( (pCoexDm->preLps == pCoexDm->curLps) &&
\r
1335 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
\r
1340 halbtc8821a2ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
\r
1342 pCoexDm->preLps = pCoexDm->curLps;
\r
1343 pCoexDm->preRpwm = pCoexDm->curRpwm;
\r
1347 halbtc8821a2ant_IgnoreWlanAct(
\r
1348 IN PBTC_COEXIST pBtCoexist,
\r
1349 IN BOOLEAN bForceExec,
\r
1350 IN BOOLEAN bEnable
\r
1353 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n",
\r
1354 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
\r
1355 pCoexDm->bCurIgnoreWlanAct = bEnable;
\r
1359 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
\r
1362 halbtc8821a2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
\r
1364 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
\r
1368 halbtc8821a2ant_SetFwPstdma(
\r
1369 IN PBTC_COEXIST pBtCoexist,
\r
1377 u1Byte H2C_Parameter[5] ={0};
\r
1379 H2C_Parameter[0] = byte1;
\r
1380 H2C_Parameter[1] = byte2;
\r
1381 H2C_Parameter[2] = byte3;
\r
1382 H2C_Parameter[3] = byte4;
\r
1383 H2C_Parameter[4] = byte5;
\r
1385 pCoexDm->psTdmaPara[0] = byte1;
\r
1386 pCoexDm->psTdmaPara[1] = byte2;
\r
1387 pCoexDm->psTdmaPara[2] = byte3;
\r
1388 pCoexDm->psTdmaPara[3] = byte4;
\r
1389 pCoexDm->psTdmaPara[4] = byte5;
\r
1391 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n",
\r
1392 H2C_Parameter[0],
\r
1393 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
\r
1395 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
\r
1399 halbtc8821a2ant_SwMechanism1(
\r
1400 IN PBTC_COEXIST pBtCoexist,
\r
1401 IN BOOLEAN bShrinkRxLPF,
\r
1402 IN BOOLEAN bLowPenaltyRA,
\r
1403 IN BOOLEAN bLimitedDIG,
\r
1404 IN BOOLEAN bBTLNAConstrain
\r
1410 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1412 if(BTC_WIFI_BW_HT40 != wifiBw) //only shrink RF Rx LPF for HT40
\r
1415 bShrinkRxLPF = FALSE;
\r
1419 //halbtc8821a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);
\r
1420 halbtc8821a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
\r
1424 halbtc8821a2ant_SwMechanism2(
\r
1425 IN PBTC_COEXIST pBtCoexist,
\r
1426 IN BOOLEAN bAGCTableShift,
\r
1427 IN BOOLEAN bADCBackOff,
\r
1428 IN BOOLEAN bSWDACSwing,
\r
1429 IN u4Byte dacSwingLvl
\r
1432 //halbtc8821a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);
\r
1433 //halbtc8821a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff);
\r
1434 halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);
\r
1438 halbtc8821a2ant_SetAntPath(
\r
1439 IN PBTC_COEXIST pBtCoexist,
\r
1440 IN u1Byte antPosType,
\r
1441 IN BOOLEAN bInitHwCfg,
\r
1442 IN BOOLEAN bWifiOff
\r
1445 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1447 u1Byte H2C_Parameter[2] ={0};
\r
1451 // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT
\r
1452 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1455 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1457 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x974, 0x3ff);
\r
1458 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x77);
\r
1460 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1462 //tell firmware "antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix
\r
1463 H2C_Parameter[0] = 1;
\r
1464 H2C_Parameter[1] = 1;
\r
1465 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1469 //tell firmware "no antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix
\r
1470 H2C_Parameter[0] = 0;
\r
1471 H2C_Parameter[1] = 1;
\r
1472 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1476 // ext switch setting
\r
1477 switch(antPosType)
\r
1479 case BTC_ANT_WIFI_AT_MAIN:
\r
1480 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1);
\r
1482 case BTC_ANT_WIFI_AT_AUX:
\r
1483 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2);
\r
1489 halbtc8821a2ant_PsTdma(
\r
1490 IN PBTC_COEXIST pBtCoexist,
\r
1491 IN BOOLEAN bForceExec,
\r
1492 IN BOOLEAN bTurnOn,
\r
1496 BOOLEAN bTurnOnByCnt=FALSE;
\r
1497 u1Byte psTdmaTypeByCnt=0;
\r
1498 u1Byte wifiRssiState1, btRssiState;
\r
1501 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
1502 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
1504 if (!(BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) && bTurnOn)
\r
1506 type = type +100; //for WiFi RSSI low or BT RSSI low
\r
1509 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
\r
1510 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
\r
1511 pCoexDm->bCurPsTdmaOn = bTurnOn;
\r
1512 pCoexDm->curPsTdma = type;
\r
1516 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
\r
1517 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
\r
1526 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
\r
1527 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);
\r
1530 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
\r
1531 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90);
\r
1534 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);
\r
1537 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90);
\r
1540 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
\r
1541 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90);
\r
1544 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
\r
1545 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90);
\r
1548 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);
\r
1551 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90);
\r
1554 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
\r
1555 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);
\r
1558 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
\r
1559 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90);
\r
1562 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90);
\r
1563 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);
\r
1566 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
\r
1567 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0xf1, 0x90);
\r
1570 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
\r
1571 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90);
\r
1574 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
\r
1575 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90);
\r
1578 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90);
\r
1579 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);
\r
1582 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90);
\r
1583 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0x70, 0x90);
\r
1586 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90);
\r
1589 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
\r
1592 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90);
\r
1595 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90);
\r
1598 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);
\r
1601 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x03, 0xf1, 0x10);
\r
1605 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x3c, 0x03, 0x70, 0x50);
\r
1608 //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
\r
1610 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);
\r
1615 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x3a, 0x03, 0x70, 0x50);
\r
1621 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x2d, 0x03, 0x70, 0x50);
\r
1627 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1c, 0x03, 0x70, 0x50);
\r
1633 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x10, 0x03, 0x70, 0x50);
\r
1636 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);
\r
1639 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x70, 0x90);
\r
1642 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);
\r
1646 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x35, 0x03, 0x71, 0x11);
\r
1649 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1c, 0x03, 0x70, 0x50);
\r
1655 // disable PS tdma
\r
1659 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
\r
1662 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0);
\r
1665 halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
\r
1670 // update pre state
\r
1671 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
\r
1672 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
\r
1676 halbtc8821a2ant_PsTdmaCheckForPowerSaveState(
\r
1677 IN PBTC_COEXIST pBtCoexist,
\r
1678 IN BOOLEAN bNewPsState
\r
1681 u1Byte lpsMode=0x0;
\r
1683 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
\r
1685 if(lpsMode) // already under LPS state
\r
1689 // keep state under LPS, do nothing.
\r
1693 // will leave LPS state, turn off psTdma first
\r
1694 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1697 else // NO PS state
\r
1701 // will enter LPS state, turn off psTdma first
\r
1702 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1706 // keep state under NO PS state, do nothing.
\r
1712 halbtc8821a2ant_PowerSaveState(
\r
1713 IN PBTC_COEXIST pBtCoexist,
\r
1719 BOOLEAN bLowPwrDisable=FALSE;
\r
1723 case BTC_PS_WIFI_NATIVE:
\r
1724 // recover to original 32k low power setting
\r
1725 bLowPwrDisable = FALSE;
\r
1726 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1727 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1728 pCoexSta->bForceLpsOn = FALSE;
\r
1730 case BTC_PS_LPS_ON:
\r
1731 halbtc8821a2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);
\r
1732 halbtc8821a2ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
\r
1733 // when coex force to enter LPS, do not enter 32k low power.
\r
1734 bLowPwrDisable = TRUE;
\r
1735 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1736 // power save must executed before psTdma.
\r
1737 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
\r
1738 pCoexSta->bForceLpsOn = TRUE;
\r
1740 case BTC_PS_LPS_OFF:
\r
1741 halbtc8821a2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
\r
1742 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1743 pCoexSta->bForceLpsOn = FALSE;
\r
1752 halbtc8821a2ant_CoexAllOff(
\r
1753 IN PBTC_COEXIST pBtCoexist
\r
1757 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1758 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1759 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
1760 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1763 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1764 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1767 //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
1768 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1772 halbtc8821a2ant_CoexUnder5G(
\r
1773 IN PBTC_COEXIST pBtCoexist
\r
1776 halbtc8821a2ant_CoexAllOff(pBtCoexist);
\r
1778 halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1782 halbtc8821a2ant_InitCoexDm(
\r
1783 IN PBTC_COEXIST pBtCoexist
\r
1786 // force to reset coex mechanism
\r
1787 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1789 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1790 halbtc8821a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
\r
1791 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
\r
1792 halbtc8821a2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
\r
1794 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1795 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1799 halbtc8821a2ant_ActionBtInquiry(
\r
1800 IN PBTC_COEXIST pBtCoexist
\r
1803 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
1804 BOOLEAN bWifiConnected=FALSE;
\r
1805 BOOLEAN bLowPwrDisable=TRUE;
\r
1806 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
1809 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
1810 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
1811 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
1813 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1814 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1816 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
1817 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
1818 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
1821 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1823 if(bScan || bLink || bRoam)
\r
1825 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi link process + BT Inq/Page!!\n"));
\r
1826 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15);
\r
1827 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
1829 else if(bWifiConnected)
\r
1831 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT Inq/Page!!\n"));
\r
1832 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15);
\r
1833 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
1837 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi no-link + BT Inq/Page!!\n"));
\r
1838 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1839 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1842 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
\r
1843 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1845 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1846 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1852 halbtc8821a2ant_ActionWiFiLinkProcess(
\r
1853 IN PBTC_COEXIST pBtCoexist
\r
1856 u1Byte u1Tmpa, u1Tmpb;
\r
1858 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15);
\r
1859 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
1861 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1862 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1866 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
\r
1867 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);
\r
1869 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u1Tmpa, u1Tmpb));
\r
1873 halbtc8821a2ant_ActionWifiIdleProcess(
\r
1874 IN PBTC_COEXIST pBtCoexist
\r
1877 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
1881 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
1882 //wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
1883 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES-20, 0);
\r
1884 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
1886 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
\r
1888 // define the office environment
\r
1889 if(BTC_RSSI_HIGH(wifiRssiState1) &&
\r
1890 (pCoexSta->bHidExist == TRUE) && (pCoexSta->bA2dpExist == TRUE))
\r
1893 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle process for BT HID+A2DP exist!!\n"));
\r
1895 halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x6);
\r
1896 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1899 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1900 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1902 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1904 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1905 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1911 halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1921 halbtc8821a2ant_IsCommonAction(
\r
1922 IN PBTC_COEXIST pBtCoexist
\r
1925 u1Byte btRssiState=BTC_RSSI_STATE_HIGH;
\r
1926 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
1927 BOOLEAN bBtHsOn=FALSE, bLowPwrDisable=FALSE;
\r
1929 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1930 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1931 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1933 if(!bWifiConnected)
\r
1935 bLowPwrDisable = FALSE;
\r
1936 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1937 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
1939 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-connected idle!!\n"));
\r
1941 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
1942 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1944 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1945 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1946 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
1947 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1949 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1950 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1956 if(BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
1958 bLowPwrDisable = FALSE;
\r
1959 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1960 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
1962 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
\r
1964 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
1965 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1967 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1968 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1969 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
\r
1970 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1972 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1973 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1977 else if(BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
\r
1979 bLowPwrDisable = TRUE;
\r
1980 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1984 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
\r
1985 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
1987 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
1988 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1990 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1991 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1992 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
\r
1993 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1995 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
1996 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
2002 bLowPwrDisable = TRUE;
\r
2003 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
2007 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
\r
2009 //bCommon = halbtc8821a2ant_ActionWifiIdleProcess(pBtCoexist);
\r
2013 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));
\r
2014 //bCommon = FALSE;
\r
2015 bCommon = halbtc8821a2ant_ActionWifiIdleProcess(pBtCoexist);
\r
2023 halbtc8821a2ant_TdmaDurationAdjust(
\r
2024 IN PBTC_COEXIST pBtCoexist,
\r
2025 IN BOOLEAN bScoHid,
\r
2026 IN BOOLEAN bTxPause,
\r
2027 IN u1Byte maxInterval
\r
2030 static s4Byte up,dn,m,n,WaitCount;
\r
2031 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
\r
2032 u1Byte retryCount=0;
\r
2034 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n"));
\r
2036 if(!pCoexDm->bAutoTdmaAdjust)
\r
2038 pCoexDm->bAutoTdmaAdjust = TRUE;
\r
2039 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
\r
2045 if(maxInterval == 1)
\r
2047 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
2048 pCoexDm->psTdmaDuAdjType = 13;
\r
2050 else if(maxInterval == 2)
\r
2052 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2053 pCoexDm->psTdmaDuAdjType = 14;
\r
2055 else if(maxInterval == 3)
\r
2057 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2058 pCoexDm->psTdmaDuAdjType = 15;
\r
2062 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2063 pCoexDm->psTdmaDuAdjType = 15;
\r
2068 if(maxInterval == 1)
\r
2070 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
2071 pCoexDm->psTdmaDuAdjType = 9;
\r
2073 else if(maxInterval == 2)
\r
2075 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2076 pCoexDm->psTdmaDuAdjType = 10;
\r
2078 else if(maxInterval == 3)
\r
2080 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2081 pCoexDm->psTdmaDuAdjType = 11;
\r
2085 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2086 pCoexDm->psTdmaDuAdjType = 11;
\r
2094 if(maxInterval == 1)
\r
2096 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2097 pCoexDm->psTdmaDuAdjType = 5;
\r
2099 else if(maxInterval == 2)
\r
2101 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2102 pCoexDm->psTdmaDuAdjType = 6;
\r
2104 else if(maxInterval == 3)
\r
2106 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2107 pCoexDm->psTdmaDuAdjType = 7;
\r
2111 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2112 pCoexDm->psTdmaDuAdjType = 7;
\r
2117 if(maxInterval == 1)
\r
2119 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
2120 pCoexDm->psTdmaDuAdjType = 1;
\r
2122 else if(maxInterval == 2)
\r
2124 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2125 pCoexDm->psTdmaDuAdjType = 2;
\r
2127 else if(maxInterval == 3)
\r
2129 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2130 pCoexDm->psTdmaDuAdjType = 3;
\r
2134 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2135 pCoexDm->psTdmaDuAdjType = 3;
\r
2150 //accquire the BT TRx retry count from BT_Info byte2
\r
2151 retryCount = pCoexSta->btRetryCnt;
\r
2152 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount));
\r
2153 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
\r
2154 up, dn, m, n, WaitCount));
\r
2158 if(retryCount == 0) // no retry in the last 2-second duration
\r
2166 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
\r
2173 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n"));
\r
2176 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
\r
2184 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
\r
2186 if (WaitCount <= 2)
\r
2187 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
2191 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
2199 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
\r
2202 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
\r
2204 if (WaitCount == 1)
\r
2205 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
2209 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
2217 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
\r
2220 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval));
\r
2221 if(maxInterval == 1)
\r
2225 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
\r
2227 if(pCoexDm->curPsTdma == 71)
\r
2229 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2230 pCoexDm->psTdmaDuAdjType = 5;
\r
2232 else if(pCoexDm->curPsTdma == 1)
\r
2234 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2235 pCoexDm->psTdmaDuAdjType = 5;
\r
2237 else if(pCoexDm->curPsTdma == 2)
\r
2239 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2240 pCoexDm->psTdmaDuAdjType = 6;
\r
2242 else if(pCoexDm->curPsTdma == 3)
\r
2244 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2245 pCoexDm->psTdmaDuAdjType = 7;
\r
2247 else if(pCoexDm->curPsTdma == 4)
\r
2249 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2250 pCoexDm->psTdmaDuAdjType = 8;
\r
2252 if(pCoexDm->curPsTdma == 9)
\r
2254 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
2255 pCoexDm->psTdmaDuAdjType = 13;
\r
2257 else if(pCoexDm->curPsTdma == 10)
\r
2259 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2260 pCoexDm->psTdmaDuAdjType = 14;
\r
2262 else if(pCoexDm->curPsTdma == 11)
\r
2264 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2265 pCoexDm->psTdmaDuAdjType = 15;
\r
2267 else if(pCoexDm->curPsTdma == 12)
\r
2269 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2270 pCoexDm->psTdmaDuAdjType = 16;
\r
2275 if(pCoexDm->curPsTdma == 5)
\r
2277 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2278 pCoexDm->psTdmaDuAdjType = 6;
\r
2280 else if(pCoexDm->curPsTdma == 6)
\r
2282 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2283 pCoexDm->psTdmaDuAdjType = 7;
\r
2285 else if(pCoexDm->curPsTdma == 7)
\r
2287 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2288 pCoexDm->psTdmaDuAdjType = 8;
\r
2290 else if(pCoexDm->curPsTdma == 13)
\r
2292 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2293 pCoexDm->psTdmaDuAdjType = 14;
\r
2295 else if(pCoexDm->curPsTdma == 14)
\r
2297 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2298 pCoexDm->psTdmaDuAdjType = 15;
\r
2300 else if(pCoexDm->curPsTdma == 15)
\r
2302 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2303 pCoexDm->psTdmaDuAdjType = 16;
\r
2306 else if (result == 1)
\r
2308 if(pCoexDm->curPsTdma == 8)
\r
2310 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2311 pCoexDm->psTdmaDuAdjType = 7;
\r
2313 else if(pCoexDm->curPsTdma == 7)
\r
2315 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2316 pCoexDm->psTdmaDuAdjType = 6;
\r
2318 else if(pCoexDm->curPsTdma == 6)
\r
2320 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2321 pCoexDm->psTdmaDuAdjType = 5;
\r
2323 else if(pCoexDm->curPsTdma == 16)
\r
2325 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2326 pCoexDm->psTdmaDuAdjType = 15;
\r
2328 else if(pCoexDm->curPsTdma == 15)
\r
2330 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2331 pCoexDm->psTdmaDuAdjType = 14;
\r
2333 else if(pCoexDm->curPsTdma == 14)
\r
2335 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
2336 pCoexDm->psTdmaDuAdjType = 13;
\r
2342 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
\r
2343 if(pCoexDm->curPsTdma == 5)
\r
2345 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71);
\r
2346 pCoexDm->psTdmaDuAdjType = 71;
\r
2348 else if(pCoexDm->curPsTdma == 6)
\r
2350 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2351 pCoexDm->psTdmaDuAdjType = 2;
\r
2353 else if(pCoexDm->curPsTdma == 7)
\r
2355 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2356 pCoexDm->psTdmaDuAdjType = 3;
\r
2358 else if(pCoexDm->curPsTdma == 8)
\r
2360 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2361 pCoexDm->psTdmaDuAdjType = 4;
\r
2363 if(pCoexDm->curPsTdma == 13)
\r
2365 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
2366 pCoexDm->psTdmaDuAdjType = 9;
\r
2368 else if(pCoexDm->curPsTdma == 14)
\r
2370 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2371 pCoexDm->psTdmaDuAdjType = 10;
\r
2373 else if(pCoexDm->curPsTdma == 15)
\r
2375 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2376 pCoexDm->psTdmaDuAdjType = 11;
\r
2378 else if(pCoexDm->curPsTdma == 16)
\r
2380 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2381 pCoexDm->psTdmaDuAdjType = 12;
\r
2386 if(pCoexDm->curPsTdma == 71)
\r
2388 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
2389 pCoexDm->psTdmaDuAdjType = 1;
\r
2391 else if(pCoexDm->curPsTdma == 1)
\r
2393 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2394 pCoexDm->psTdmaDuAdjType = 2;
\r
2396 else if(pCoexDm->curPsTdma == 2)
\r
2398 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2399 pCoexDm->psTdmaDuAdjType = 3;
\r
2401 else if(pCoexDm->curPsTdma == 3)
\r
2403 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2404 pCoexDm->psTdmaDuAdjType = 4;
\r
2406 else if(pCoexDm->curPsTdma == 9)
\r
2408 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2409 pCoexDm->psTdmaDuAdjType = 10;
\r
2411 else if(pCoexDm->curPsTdma == 10)
\r
2413 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2414 pCoexDm->psTdmaDuAdjType = 11;
\r
2416 else if(pCoexDm->curPsTdma == 11)
\r
2418 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2419 pCoexDm->psTdmaDuAdjType = 12;
\r
2422 else if (result == 1)
\r
2424 if(pCoexDm->curPsTdma == 4)
\r
2426 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2427 pCoexDm->psTdmaDuAdjType = 3;
\r
2429 else if(pCoexDm->curPsTdma == 3)
\r
2431 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2432 pCoexDm->psTdmaDuAdjType = 2;
\r
2434 else if(pCoexDm->curPsTdma == 2)
\r
2436 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
2437 pCoexDm->psTdmaDuAdjType = 1;
\r
2439 else if(pCoexDm->curPsTdma == 1)
\r
2441 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71);
\r
2442 pCoexDm->psTdmaDuAdjType = 71;
\r
2444 else if(pCoexDm->curPsTdma == 12)
\r
2446 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2447 pCoexDm->psTdmaDuAdjType = 11;
\r
2449 else if(pCoexDm->curPsTdma == 11)
\r
2451 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2452 pCoexDm->psTdmaDuAdjType = 10;
\r
2454 else if(pCoexDm->curPsTdma == 10)
\r
2456 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
2457 pCoexDm->psTdmaDuAdjType = 9;
\r
2462 else if(maxInterval == 2)
\r
2466 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
\r
2467 if(pCoexDm->curPsTdma == 1)
\r
2469 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2470 pCoexDm->psTdmaDuAdjType = 6;
\r
2472 else if(pCoexDm->curPsTdma == 2)
\r
2474 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2475 pCoexDm->psTdmaDuAdjType = 6;
\r
2477 else if(pCoexDm->curPsTdma == 3)
\r
2479 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2480 pCoexDm->psTdmaDuAdjType = 7;
\r
2482 else if(pCoexDm->curPsTdma == 4)
\r
2484 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2485 pCoexDm->psTdmaDuAdjType = 8;
\r
2487 if(pCoexDm->curPsTdma == 9)
\r
2489 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2490 pCoexDm->psTdmaDuAdjType = 14;
\r
2492 else if(pCoexDm->curPsTdma == 10)
\r
2494 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2495 pCoexDm->psTdmaDuAdjType = 14;
\r
2497 else if(pCoexDm->curPsTdma == 11)
\r
2499 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2500 pCoexDm->psTdmaDuAdjType = 15;
\r
2502 else if(pCoexDm->curPsTdma == 12)
\r
2504 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2505 pCoexDm->psTdmaDuAdjType = 16;
\r
2509 if(pCoexDm->curPsTdma == 5)
\r
2511 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2512 pCoexDm->psTdmaDuAdjType = 6;
\r
2514 else if(pCoexDm->curPsTdma == 6)
\r
2516 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2517 pCoexDm->psTdmaDuAdjType = 7;
\r
2519 else if(pCoexDm->curPsTdma == 7)
\r
2521 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2522 pCoexDm->psTdmaDuAdjType = 8;
\r
2524 else if(pCoexDm->curPsTdma == 13)
\r
2526 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2527 pCoexDm->psTdmaDuAdjType = 14;
\r
2529 else if(pCoexDm->curPsTdma == 14)
\r
2531 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2532 pCoexDm->psTdmaDuAdjType = 15;
\r
2534 else if(pCoexDm->curPsTdma == 15)
\r
2536 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2537 pCoexDm->psTdmaDuAdjType = 16;
\r
2540 else if (result == 1)
\r
2542 if(pCoexDm->curPsTdma == 8)
\r
2544 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2545 pCoexDm->psTdmaDuAdjType = 7;
\r
2547 else if(pCoexDm->curPsTdma == 7)
\r
2549 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2550 pCoexDm->psTdmaDuAdjType = 6;
\r
2552 else if(pCoexDm->curPsTdma == 6)
\r
2554 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2555 pCoexDm->psTdmaDuAdjType = 6;
\r
2557 else if(pCoexDm->curPsTdma == 16)
\r
2559 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2560 pCoexDm->psTdmaDuAdjType = 15;
\r
2562 else if(pCoexDm->curPsTdma == 15)
\r
2564 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2565 pCoexDm->psTdmaDuAdjType = 14;
\r
2567 else if(pCoexDm->curPsTdma == 14)
\r
2569 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2570 pCoexDm->psTdmaDuAdjType = 14;
\r
2576 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
\r
2577 if(pCoexDm->curPsTdma == 5)
\r
2579 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2580 pCoexDm->psTdmaDuAdjType = 2;
\r
2582 else if(pCoexDm->curPsTdma == 6)
\r
2584 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2585 pCoexDm->psTdmaDuAdjType = 2;
\r
2587 else if(pCoexDm->curPsTdma == 7)
\r
2589 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2590 pCoexDm->psTdmaDuAdjType = 3;
\r
2592 else if(pCoexDm->curPsTdma == 8)
\r
2594 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2595 pCoexDm->psTdmaDuAdjType = 4;
\r
2597 if(pCoexDm->curPsTdma == 13)
\r
2599 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2600 pCoexDm->psTdmaDuAdjType = 10;
\r
2602 else if(pCoexDm->curPsTdma == 14)
\r
2604 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2605 pCoexDm->psTdmaDuAdjType = 10;
\r
2607 else if(pCoexDm->curPsTdma == 15)
\r
2609 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2610 pCoexDm->psTdmaDuAdjType = 11;
\r
2612 else if(pCoexDm->curPsTdma == 16)
\r
2614 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2615 pCoexDm->psTdmaDuAdjType = 12;
\r
2619 if(pCoexDm->curPsTdma == 1)
\r
2621 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2622 pCoexDm->psTdmaDuAdjType = 2;
\r
2624 else if(pCoexDm->curPsTdma == 2)
\r
2626 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2627 pCoexDm->psTdmaDuAdjType = 3;
\r
2629 else if(pCoexDm->curPsTdma == 3)
\r
2631 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2632 pCoexDm->psTdmaDuAdjType = 4;
\r
2634 else if(pCoexDm->curPsTdma == 9)
\r
2636 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2637 pCoexDm->psTdmaDuAdjType = 10;
\r
2639 else if(pCoexDm->curPsTdma == 10)
\r
2641 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2642 pCoexDm->psTdmaDuAdjType = 11;
\r
2644 else if(pCoexDm->curPsTdma == 11)
\r
2646 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2647 pCoexDm->psTdmaDuAdjType = 12;
\r
2650 else if (result == 1)
\r
2652 if(pCoexDm->curPsTdma == 4)
\r
2654 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2655 pCoexDm->psTdmaDuAdjType = 3;
\r
2657 else if(pCoexDm->curPsTdma == 3)
\r
2659 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2660 pCoexDm->psTdmaDuAdjType = 2;
\r
2662 else if(pCoexDm->curPsTdma == 2)
\r
2664 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2665 pCoexDm->psTdmaDuAdjType = 2;
\r
2667 else if(pCoexDm->curPsTdma == 12)
\r
2669 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2670 pCoexDm->psTdmaDuAdjType = 11;
\r
2672 else if(pCoexDm->curPsTdma == 11)
\r
2674 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2675 pCoexDm->psTdmaDuAdjType = 10;
\r
2677 else if(pCoexDm->curPsTdma == 10)
\r
2679 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2680 pCoexDm->psTdmaDuAdjType = 10;
\r
2685 else if(maxInterval == 3)
\r
2689 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
\r
2690 if(pCoexDm->curPsTdma == 1)
\r
2692 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2693 pCoexDm->psTdmaDuAdjType = 7;
\r
2695 else if(pCoexDm->curPsTdma == 2)
\r
2697 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2698 pCoexDm->psTdmaDuAdjType = 7;
\r
2700 else if(pCoexDm->curPsTdma == 3)
\r
2702 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2703 pCoexDm->psTdmaDuAdjType = 7;
\r
2705 else if(pCoexDm->curPsTdma == 4)
\r
2707 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2708 pCoexDm->psTdmaDuAdjType = 8;
\r
2710 if(pCoexDm->curPsTdma == 9)
\r
2712 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2713 pCoexDm->psTdmaDuAdjType = 15;
\r
2715 else if(pCoexDm->curPsTdma == 10)
\r
2717 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2718 pCoexDm->psTdmaDuAdjType = 15;
\r
2720 else if(pCoexDm->curPsTdma == 11)
\r
2722 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2723 pCoexDm->psTdmaDuAdjType = 15;
\r
2725 else if(pCoexDm->curPsTdma == 12)
\r
2727 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2728 pCoexDm->psTdmaDuAdjType = 16;
\r
2732 if(pCoexDm->curPsTdma == 5)
\r
2734 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2735 pCoexDm->psTdmaDuAdjType = 7;
\r
2737 else if(pCoexDm->curPsTdma == 6)
\r
2739 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2740 pCoexDm->psTdmaDuAdjType = 7;
\r
2742 else if(pCoexDm->curPsTdma == 7)
\r
2744 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2745 pCoexDm->psTdmaDuAdjType = 8;
\r
2747 else if(pCoexDm->curPsTdma == 13)
\r
2749 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2750 pCoexDm->psTdmaDuAdjType = 15;
\r
2752 else if(pCoexDm->curPsTdma == 14)
\r
2754 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2755 pCoexDm->psTdmaDuAdjType = 15;
\r
2757 else if(pCoexDm->curPsTdma == 15)
\r
2759 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2760 pCoexDm->psTdmaDuAdjType = 16;
\r
2763 else if (result == 1)
\r
2765 if(pCoexDm->curPsTdma == 8)
\r
2767 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2768 pCoexDm->psTdmaDuAdjType = 7;
\r
2770 else if(pCoexDm->curPsTdma == 7)
\r
2772 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2773 pCoexDm->psTdmaDuAdjType = 7;
\r
2775 else if(pCoexDm->curPsTdma == 6)
\r
2777 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2778 pCoexDm->psTdmaDuAdjType = 7;
\r
2780 else if(pCoexDm->curPsTdma == 16)
\r
2782 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2783 pCoexDm->psTdmaDuAdjType = 15;
\r
2785 else if(pCoexDm->curPsTdma == 15)
\r
2787 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2788 pCoexDm->psTdmaDuAdjType = 15;
\r
2790 else if(pCoexDm->curPsTdma == 14)
\r
2792 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2793 pCoexDm->psTdmaDuAdjType = 15;
\r
2799 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
\r
2800 if(pCoexDm->curPsTdma == 5)
\r
2802 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2803 pCoexDm->psTdmaDuAdjType = 3;
\r
2805 else if(pCoexDm->curPsTdma == 6)
\r
2807 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2808 pCoexDm->psTdmaDuAdjType = 3;
\r
2810 else if(pCoexDm->curPsTdma == 7)
\r
2812 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2813 pCoexDm->psTdmaDuAdjType = 3;
\r
2815 else if(pCoexDm->curPsTdma == 8)
\r
2817 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2818 pCoexDm->psTdmaDuAdjType = 4;
\r
2820 if(pCoexDm->curPsTdma == 13)
\r
2822 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2823 pCoexDm->psTdmaDuAdjType = 11;
\r
2825 else if(pCoexDm->curPsTdma == 14)
\r
2827 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2828 pCoexDm->psTdmaDuAdjType = 11;
\r
2830 else if(pCoexDm->curPsTdma == 15)
\r
2832 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2833 pCoexDm->psTdmaDuAdjType = 11;
\r
2835 else if(pCoexDm->curPsTdma == 16)
\r
2837 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2838 pCoexDm->psTdmaDuAdjType = 12;
\r
2842 if(pCoexDm->curPsTdma == 1)
\r
2844 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2845 pCoexDm->psTdmaDuAdjType = 3;
\r
2847 else if(pCoexDm->curPsTdma == 2)
\r
2849 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2850 pCoexDm->psTdmaDuAdjType = 3;
\r
2852 else if(pCoexDm->curPsTdma == 3)
\r
2854 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2855 pCoexDm->psTdmaDuAdjType = 4;
\r
2857 else if(pCoexDm->curPsTdma == 9)
\r
2859 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2860 pCoexDm->psTdmaDuAdjType = 11;
\r
2862 else if(pCoexDm->curPsTdma == 10)
\r
2864 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2865 pCoexDm->psTdmaDuAdjType = 11;
\r
2867 else if(pCoexDm->curPsTdma == 11)
\r
2869 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2870 pCoexDm->psTdmaDuAdjType = 12;
\r
2873 else if (result == 1)
\r
2875 if(pCoexDm->curPsTdma == 4)
\r
2877 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2878 pCoexDm->psTdmaDuAdjType = 3;
\r
2880 else if(pCoexDm->curPsTdma == 3)
\r
2882 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2883 pCoexDm->psTdmaDuAdjType = 3;
\r
2885 else if(pCoexDm->curPsTdma == 2)
\r
2887 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2888 pCoexDm->psTdmaDuAdjType = 3;
\r
2890 else if(pCoexDm->curPsTdma == 12)
\r
2892 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2893 pCoexDm->psTdmaDuAdjType = 11;
\r
2895 else if(pCoexDm->curPsTdma == 11)
\r
2897 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2898 pCoexDm->psTdmaDuAdjType = 11;
\r
2900 else if(pCoexDm->curPsTdma == 10)
\r
2902 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2903 pCoexDm->psTdmaDuAdjType = 11;
\r
2910 // if current PsTdma not match with the recorded one (when scan, dhcp...),
\r
2911 // then we have to adjust it back to the previous record one.
\r
2912 if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)
\r
2914 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2915 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n",
\r
2916 pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));
\r
2918 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2919 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2920 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
2922 if( !bScan && !bLink && !bRoam)
\r
2924 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
\r
2928 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
\r
2933 // SCO only or SCO+PAN(HS)
\r
2935 halbtc8821a2ant_ActionSco(
\r
2936 IN PBTC_COEXIST pBtCoexist
\r
2939 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
2940 u1Byte wifiRssiState, btRssiState;
\r
2943 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
2944 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
2946 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
2948 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
2950 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4);
\r
2952 if(BTC_RSSI_HIGH(btRssiState))
\r
2953 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
2955 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2957 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
2959 if (BTC_WIFI_BW_LEGACY == wifiBw) //for SCO quality at 11b/g mode
\r
2961 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
2963 else //for SCO quality & wifi performance balance at 11n mode
\r
2965 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
2966 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
\r
2969 if(pBtLinkInfo->bScoOnly)
\r
2970 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 17);
\r
2972 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12);
\r
2976 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2977 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality
\r
2980 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
2982 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
2983 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
2985 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
2986 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18);
\r
2990 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
2991 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x18);
\r
2996 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
2997 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
2999 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3000 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18);
\r
3004 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3005 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x18);
\r
3012 halbtc8821a2ant_ActionHid(
\r
3013 IN PBTC_COEXIST pBtCoexist
\r
3016 u1Byte wifiRssiState, btRssiState;
\r
3019 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3020 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3022 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3024 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3026 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3028 if(BTC_RSSI_HIGH(btRssiState))
\r
3029 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3031 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3033 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3035 if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode
\r
3037 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3039 else //for HID quality & wifi performance balance at 11n mode
\r
3041 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
3044 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3046 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
3049 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3051 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3052 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3054 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3055 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3059 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3060 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3065 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3066 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3068 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3069 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3073 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3074 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3079 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
\r
3081 halbtc8821a2ant_ActionA2dp(
\r
3082 IN PBTC_COEXIST pBtCoexist
\r
3085 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3089 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3090 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3091 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3093 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
\r
3095 // define the office environment
\r
3096 if( (apNum >= 10) && BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3098 //DbgPrint(" AP#>10(%d)\n", apNum);
\r
3099 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3101 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3102 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3103 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3104 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3106 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
3108 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3109 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
3112 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3113 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3115 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3116 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6);
\r
3120 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3121 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6);
\r
3127 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3128 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3130 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3132 if(BTC_RSSI_HIGH(btRssiState))
\r
3133 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3135 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3138 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3140 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3141 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3145 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);
\r
3146 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3150 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3151 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3153 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);
\r
3157 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1);
\r
3161 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3162 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3164 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3165 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3167 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3168 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3172 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3173 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3178 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3179 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3181 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3182 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3186 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3187 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3193 halbtc8821a2ant_ActionA2dpPanHs(
\r
3194 IN PBTC_COEXIST pBtCoexist
\r
3197 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3200 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3201 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3202 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3204 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3206 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3208 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3210 if(BTC_RSSI_HIGH(btRssiState))
\r
3211 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3213 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3215 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3217 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3218 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3222 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);
\r
3223 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3226 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2);
\r
3229 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3230 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3232 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3233 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3235 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3236 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3240 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3241 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3246 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3247 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3249 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3250 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3254 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3255 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3261 halbtc8821a2ant_ActionPanEdr(
\r
3262 IN PBTC_COEXIST pBtCoexist
\r
3265 u1Byte wifiRssiState,wifiRssiState1, btRssiState;
\r
3268 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3269 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3270 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3272 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3274 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3276 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3278 if(BTC_RSSI_HIGH(btRssiState))
\r
3279 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3281 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3283 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3285 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10);
\r
3286 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3290 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);
\r
3291 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3294 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3295 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3297 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); //1->3 for TENCENT spp profile delay time
\r
3301 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
3305 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3306 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3308 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3309 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3311 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3312 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3316 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3317 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3322 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3323 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3325 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3326 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3330 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3331 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3339 halbtc8821a2ant_ActionPanHs(
\r
3340 IN PBTC_COEXIST pBtCoexist
\r
3343 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3346 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3347 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3348 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3350 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3352 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3354 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3356 if(BTC_RSSI_HIGH(btRssiState))
\r
3357 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3359 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3361 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3363 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3364 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
3366 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3367 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3369 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3370 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3372 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3373 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3377 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3378 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3383 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3384 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3386 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3387 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3391 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3392 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3399 halbtc8821a2ant_ActionPanEdrA2dp(
\r
3400 IN PBTC_COEXIST pBtCoexist
\r
3403 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3406 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3407 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3408 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3410 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3412 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3414 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3416 if(BTC_RSSI_HIGH(btRssiState))
\r
3417 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3419 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3421 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3422 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3424 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3426 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3428 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3429 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3431 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12);
\r
3433 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3434 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3);
\r
3436 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3);
\r
3440 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);
\r
3441 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3);
\r
3445 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3447 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3448 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3450 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3451 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3455 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3456 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3461 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3462 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3464 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3465 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3469 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3470 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3476 halbtc8821a2ant_ActionPanEdrHid(
\r
3477 IN PBTC_COEXIST pBtCoexist
\r
3480 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3483 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3484 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3485 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3486 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3488 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3490 if(BTC_RSSI_HIGH(btRssiState))
\r
3491 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3493 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3495 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3497 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3498 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3502 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);
\r
3503 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3506 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3507 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3509 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3511 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3);
\r
3512 //halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11);
\r
3513 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780);
\r
3517 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3518 //halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3519 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3521 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 2);
\r
3525 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3526 //halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);
\r
3527 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3528 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2);
\r
3532 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3534 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3535 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3537 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3538 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3542 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3543 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3548 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3549 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3551 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3552 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3556 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3557 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3562 // HID+A2DP+PAN(EDR)
\r
3564 halbtc8821a2ant_ActionHidA2dpPanEdr(
\r
3565 IN PBTC_COEXIST pBtCoexist
\r
3568 u1Byte wifiRssiState,wifiRssiState1, btRssiState;
\r
3571 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3572 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3573 btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3575 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3577 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3579 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3581 if(BTC_RSSI_HIGH(btRssiState))
\r
3582 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3584 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3586 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3588 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3589 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3593 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);
\r
3594 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3597 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3599 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3600 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3602 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3603 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);
\r
3605 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3);
\r
3609 halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);
\r
3613 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3615 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3616 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3618 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3619 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3623 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3624 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3629 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3630 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3632 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3633 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3637 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3638 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3644 halbtc8821a2ant_ActionHidA2dp(
\r
3645 IN PBTC_COEXIST pBtCoexist
\r
3648 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3652 wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3653 //btRssiState = halbtc8821a2ant_BtRssiState(2, 29, 0);
\r
3654 wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3655 btRssiState = halbtc8821a2ant_BtRssiState(3, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 37);
\r
3657 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3659 halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x5);
\r
3661 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3663 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3664 if(BTC_WIFI_BW_LEGACY == wifiBw)
\r
3666 if(BTC_RSSI_HIGH(btRssiState))
\r
3667 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3668 else if(BTC_RSSI_MEDIUM(btRssiState))
\r
3669 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3671 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3674 { // only 802.11N mode we have to dec bt power to 4 degree
\r
3675 if(BTC_RSSI_HIGH(btRssiState))
\r
3677 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
\r
3678 // need to check ap Number of Not
\r
3680 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
\r
3682 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3684 else if(BTC_RSSI_MEDIUM(btRssiState))
\r
3685 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3687 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3690 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3692 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3693 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3697 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);
\r
3698 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3701 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3702 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3704 //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3);
\r
3705 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
3709 //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);
\r
3710 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
3714 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3716 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3717 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3719 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3720 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3724 halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3725 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3730 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3731 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3733 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3734 halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3738 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3739 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3745 halbtc8821a2ant_ActionBtWhckTest(
\r
3746 IN PBTC_COEXIST pBtCoexist
\r
3749 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3752 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3753 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3755 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3757 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
3758 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
3762 halbtc8821a2ant_ActionWifiMultiPort(
\r
3763 IN PBTC_COEXIST pBtCoexist
\r
3766 halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3767 halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3770 halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3771 halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3774 //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3775 halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
3777 halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3778 halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
3782 halbtc8821a2ant_RunCoexistMechanism(
\r
3783 IN PBTC_COEXIST pBtCoexist
\r
3786 BOOLEAN bWifiUnder5G=FALSE, bBtHsOn=FALSE;
\r
3787 u1Byte btInfoOriginal=0, btRetryCnt=0;
\r
3788 u1Byte algorithm=0;
\r
3789 u4Byte numOfWifiLink=0;
\r
3790 u4Byte wifiLinkStatus=0;
\r
3791 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
3792 BOOLEAN bMiracastPlusBt=FALSE;
\r
3793 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
3795 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n"));
\r
3797 if(pBtCoexist->bManualControl)
\r
3799 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
\r
3803 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
3806 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n"));
\r
3807 halbtc8821a2ant_CoexUnder5G(pBtCoexist);
\r
3811 if(pCoexSta->bUnderIps)
\r
3813 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n"));
\r
3817 if(pCoexSta->bBtWhckTest)
\r
3819 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under WHCK TEST!!!\n"));
\r
3820 halbtc8821a2ant_ActionBtWhckTest(pBtCoexist);
\r
3824 algorithm = halbtc8821a2ant_ActionAlgorithm(pBtCoexist);
\r
3825 if(pCoexSta->bC2hBtInquiryPage && (BT_8821A_2ANT_COEX_ALGO_PANHS!=algorithm))
\r
3827 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n"));
\r
3828 halbtc8821a2ant_ActionBtInquiry(pBtCoexist);
\r
3836 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
3837 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
3838 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
3840 if(bScan || bLink || bRoam)
\r
3842 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], WiFi is under Link Process !!\n"));
\r
3843 halbtc8821a2ant_ActionWiFiLinkProcess(pBtCoexist);
\r
3849 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
3850 numOfWifiLink = wifiLinkStatus>>16;
\r
3852 if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED))
\r
3854 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) );
\r
3856 if(pBtLinkInfo->bBtLinkExist)
\r
3858 bMiracastPlusBt = TRUE;
\r
3862 bMiracastPlusBt = FALSE;
\r
3865 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);
\r
3866 halbtc8821a2ant_ActionWifiMultiPort(pBtCoexist);
\r
3872 bMiracastPlusBt = FALSE;
\r
3873 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);
\r
3876 pCoexDm->curAlgorithm = algorithm;
\r
3877 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm));
\r
3879 if(halbtc8821a2ant_IsCommonAction(pBtCoexist))
\r
3881 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n"));
\r
3882 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
3886 if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm)
\r
3888 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n",
\r
3889 pCoexDm->preAlgorithm, pCoexDm->curAlgorithm));
\r
3890 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
3892 switch(pCoexDm->curAlgorithm)
\r
3894 case BT_8821A_2ANT_COEX_ALGO_SCO:
\r
3895 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n"));
\r
3896 halbtc8821a2ant_ActionSco(pBtCoexist);
\r
3898 case BT_8821A_2ANT_COEX_ALGO_HID:
\r
3899 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n"));
\r
3900 halbtc8821a2ant_ActionHid(pBtCoexist);
\r
3902 case BT_8821A_2ANT_COEX_ALGO_A2DP:
\r
3903 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n"));
\r
3904 halbtc8821a2ant_ActionA2dp(pBtCoexist);
\r
3906 case BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS:
\r
3907 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n"));
\r
3908 halbtc8821a2ant_ActionA2dpPanHs(pBtCoexist);
\r
3910 case BT_8821A_2ANT_COEX_ALGO_PANEDR:
\r
3911 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"));
\r
3912 halbtc8821a2ant_ActionPanEdr(pBtCoexist);
\r
3914 case BT_8821A_2ANT_COEX_ALGO_PANHS:
\r
3915 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n"));
\r
3916 halbtc8821a2ant_ActionPanHs(pBtCoexist);
\r
3918 case BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP:
\r
3919 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"));
\r
3920 halbtc8821a2ant_ActionPanEdrA2dp(pBtCoexist);
\r
3922 case BT_8821A_2ANT_COEX_ALGO_PANEDR_HID:
\r
3923 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
\r
3924 halbtc8821a2ant_ActionPanEdrHid(pBtCoexist);
\r
3926 case BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
\r
3927 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
\r
3928 halbtc8821a2ant_ActionHidA2dpPanEdr(pBtCoexist);
\r
3930 case BT_8821A_2ANT_COEX_ALGO_HID_A2DP:
\r
3931 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"));
\r
3932 halbtc8821a2ant_ActionHidA2dp(pBtCoexist);
\r
3935 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"));
\r
3936 halbtc8821a2ant_CoexAllOff(pBtCoexist);
\r
3939 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
\r
3944 halbtc8821a2ant_WifiOffHwCfg(
\r
3945 IN PBTC_COEXIST pBtCoexist
\r
3948 BOOLEAN bIsInMpMode = FALSE;
\r
3949 u1Byte H2C_Parameter[2] ={0};
\r
3952 // set wlan_act to low
\r
3953 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
3955 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); //WiFi goto standby while GNT_BT 0-->1
\r
3956 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
3957 if(fwVer >= 0x180000)
\r
3959 /* Use H2C to set GNT_BT to HIGH */
\r
3960 H2C_Parameter[0] = 1;
\r
3961 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
\r
3965 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
\r
3970 halbtc8821a2ant_InitHwConfig(
\r
3971 IN PBTC_COEXIST pBtCoexist,
\r
3972 IN BOOLEAN bBackUp
\r
3975 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
3976 u4Byte u4Tmp=0, fwVer;
\r
3979 u1Byte H2C_Parameter[2] ={0};
\r
3982 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n"));
\r
3984 // backup rf 0x1e value
\r
3985 pCoexDm->btRf0x1eBackup =
\r
3986 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
\r
3989 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
\r
3992 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
\r
3995 halbtc8821a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, TRUE, FALSE);
\r
3996 pCoexSta->disVerInfoCnt = 0;
\r
3999 halbtc8821a2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
4001 // Enable counter statistics
\r
4002 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); //0x76e[3] =1, WLAN_Act control by PTA
\r
4003 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);
\r
4004 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
\r
4007 //============================================================
\r
4008 // work around function start with wa_halbtc8821a2ant_
\r
4009 //============================================================
\r
4010 //============================================================
\r
4011 // extern function start with EXhalbtc8821a2ant_
\r
4012 //============================================================
\r
4014 EXhalbtc8821a2ant_PowerOnSetting(
\r
4015 IN PBTC_COEXIST pBtCoexist
\r
4022 EXhalbtc8821a2ant_PreLoadFirmware(
\r
4023 IN PBTC_COEXIST pBtCoexist
\r
4026 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
4027 u1Byte u1Tmp=0x4; /* Set BIT2 by default since it's 2ant case */
\r
4030 // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info)
\r
4031 // Local setting bit define
\r
4032 // BIT0: "0" for no antenna inverse; "1" for antenna inverse
\r
4033 // BIT1: "0" for internal switch; "1" for external switch
\r
4034 // BIT2: "0" for one antenna; "1" for two antenna
\r
4035 // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0
\r
4036 if(pBtCoexist->chipInterface == BTC_INTF_USB)
\r
4038 // fixed at S0 for USB interface
\r
4039 u1Tmp |= 0x1; // antenna inverse
\r
4040 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);
\r
4044 // for PCIE and SDIO interface, we check efuse 0xc3[6]
\r
4045 if(pBoardInfo->singleAntPath == 0)
\r
4048 else if(pBoardInfo->singleAntPath == 1)
\r
4051 u1Tmp |= 0x1; // antenna inverse
\r
4054 if(pBtCoexist->chipInterface == BTC_INTF_PCI)
\r
4056 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp);
\r
4058 else if(pBtCoexist->chipInterface == BTC_INTF_SDIO)
\r
4060 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp);
\r
4066 EXhalbtc8821a2ant_InitHwConfig(
\r
4067 IN PBTC_COEXIST pBtCoexist,
\r
4068 IN BOOLEAN bWifiOnly
\r
4071 halbtc8821a2ant_InitHwConfig(pBtCoexist, TRUE);
\r
4075 EXhalbtc8821a2ant_InitCoexDm(
\r
4076 IN PBTC_COEXIST pBtCoexist
\r
4079 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
4081 halbtc8821a2ant_InitCoexDm(pBtCoexist);
\r
4085 EXhalbtc8821a2ant_DisplayCoexInfo(
\r
4086 IN PBTC_COEXIST pBtCoexist
\r
4089 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
4090 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
4091 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
4092 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
4093 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
4095 u4Byte faOfdm, faCck;
\r
4096 u4Byte fwVer=0, btPatchVer=0;
\r
4098 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
4099 CL_PRINTF(cliBuf);
\r
4101 if(pBtCoexist->bManualControl)
\r
4103 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
\r
4104 CL_PRINTF(cliBuf);
\r
4105 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
4106 CL_PRINTF(cliBuf);
\r
4109 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
\r
4110 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
\r
4111 CL_PRINTF(cliBuf);
\r
4113 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
4114 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
4115 CL_PRINTF(cliBuf);
\r
4117 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
4118 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
4119 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
\r
4120 GLCoexVerDate8821a2Ant, GLCoexVer8821a2Ant, fwVer, btPatchVer, btPatchVer);
\r
4121 CL_PRINTF(cliBuf);
\r
4123 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \
\r
4124 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
\r
4125 pCoexDm->wifiChnlInfo[2]);
\r
4126 CL_PRINTF(cliBuf);
\r
4129 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
\r
4130 CL_PRINTF(cliBuf);
\r
4131 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
\r
4133 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
\r
4134 CL_PRINTF(cliBuf);
\r
4136 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %ddBm/ %d] ", "BT [status/ rssi/ retryCnt]", \
\r
4137 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
\r
4138 ( (BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
\r
4139 pCoexSta->btRssi-100, pCoexSta->btRetryCnt);
\r
4140 CL_PRINTF(cliBuf);
\r
4142 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
4143 pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);
\r
4144 CL_PRINTF(cliBuf);
\r
4146 if (pStackInfo->bProfileNotified)
\r
4148 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
4152 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \
\r
4153 (pBtLinkInfo->bSlaveRole )? "Slave":"Master");
\r
4154 CL_PRINTF(cliBuf);
\r
4157 btInfoExt = pCoexSta->btInfoExt;
\r
4158 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
\r
4159 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
\r
4160 CL_PRINTF(cliBuf);
\r
4162 for(i=0; i<BT_INFO_SRC_8821A_2ANT_MAX; i++)
\r
4164 if(pCoexSta->btInfoC2hCnt[i])
\r
4166 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8821a2Ant[i], \
\r
4167 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
\r
4168 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
\r
4169 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
\r
4170 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
\r
4171 CL_PRINTF(cliBuf);
\r
4176 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
4177 CL_PRINTF(cliBuf);
\r
4178 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \
\r
4179 pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig);
\r
4180 CL_PRINTF(cliBuf);
\r
4181 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
\r
4182 pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
\r
4183 CL_PRINTF(cliBuf);
\r
4186 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
4187 CL_PRINTF(cliBuf);
\r
4189 psTdmaCase = pCoexDm->curPsTdma;
\r
4190 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
\r
4191 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
\r
4192 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
\r
4193 pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
\r
4194 CL_PRINTF(cliBuf);
\r
4196 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", \
\r
4197 pCoexSta->nCoexTableType);
\r
4198 CL_PRINTF(cliBuf);
\r
4200 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
\r
4201 pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct);
\r
4202 CL_PRINTF(cliBuf);
\r
4205 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
4206 CL_PRINTF(cliBuf);
\r
4208 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
\r
4209 pCoexDm->btRf0x1eBackup);
\r
4210 CL_PRINTF(cliBuf);
\r
4212 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
\r
4213 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xc5b);
\r
4214 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
\r
4215 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x880[29:25]/0xc58[29:25]", \
\r
4216 u1Tmp[0], (u4Tmp[0]&0x3e000000) >> 25, ((u1Tmp[1]&0x3e)>>1));
\r
4217 CL_PRINTF(cliBuf);
\r
4219 u4Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x764);
\r
4220 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);
\r
4221 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x764/ 0x765/ 0x76e", \
\r
4222 (u4Tmp[0]&0xff), (u4Tmp[0]&0xff00)>>8, u1Tmp[0]);
\r
4223 CL_PRINTF(cliBuf);
\r
4225 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcb4);
\r
4226 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xcb4[7:0](ctrl)/ 0xcb4[29:28](val)", \
\r
4227 u4Tmp[0]&0xff, ((u4Tmp[0]&0x30000000)>>28));
\r
4228 CL_PRINTF(cliBuf);
\r
4230 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
4231 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
4232 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x974);
\r
4233 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x40/ 0x4c[24:23]/ 0x974", \
\r
4234 u1Tmp[0], ((u4Tmp[0]&0x01800000)>>23), u4Tmp[1]);
\r
4235 CL_PRINTF(cliBuf);
\r
4237 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
\r
4238 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
\r
4239 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
\r
4240 u4Tmp[0], u1Tmp[0]);
\r
4241 CL_PRINTF(cliBuf);
\r
4243 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
4244 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c);
\r
4245 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
\r
4246 u4Tmp[0]&0xff, u1Tmp[0]);
\r
4247 CL_PRINTF(cliBuf);
\r
4249 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
\r
4250 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
\r
4251 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
\r
4252 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0);
\r
4254 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b);
\r
4255 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
\r
4257 faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \
\r
4258 ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ;
\r
4259 faCck = (u1Tmp[0] << 8) + u1Tmp[1];
\r
4261 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
\r
4262 u4Tmp[0]&0xffff, faOfdm, faCck);
\r
4263 CL_PRINTF(cliBuf);
\r
4265 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \
\r
4266 pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg);
\r
4267 CL_PRINTF(cliBuf);
\r
4269 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \
\r
4270 pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg);
\r
4271 CL_PRINTF(cliBuf);
\r
4273 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
\r
4274 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
4275 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
4276 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
\r
4277 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
\r
4278 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
\r
4279 CL_PRINTF(cliBuf);
\r
4281 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \
\r
4282 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
\r
4283 CL_PRINTF(cliBuf);
\r
4284 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \
\r
4285 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
\r
4286 CL_PRINTF(cliBuf);
\r
4287 #if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 1)
\r
4288 //halbtc8821a2ant_MonitorBtCtr(pBtCoexist);
\r
4290 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
4295 EXhalbtc8821a2ant_IpsNotify(
\r
4296 IN PBTC_COEXIST pBtCoexist,
\r
4300 if(BTC_IPS_ENTER == type)
\r
4302 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n"));
\r
4303 pCoexSta->bUnderIps = TRUE;
\r
4304 halbtc8821a2ant_WifiOffHwCfg(pBtCoexist);
\r
4305 halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
4306 halbtc8821a2ant_CoexAllOff(pBtCoexist);
\r
4308 else if(BTC_IPS_LEAVE == type)
\r
4310 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n"));
\r
4311 pCoexSta->bUnderIps = FALSE;
\r
4312 halbtc8821a2ant_InitHwConfig(pBtCoexist, FALSE);
\r
4313 halbtc8821a2ant_InitCoexDm(pBtCoexist);
\r
4314 halbtc8821a2ant_QueryBtInfo(pBtCoexist);
\r
4319 EXhalbtc8821a2ant_LpsNotify(
\r
4320 IN PBTC_COEXIST pBtCoexist,
\r
4324 if(BTC_LPS_ENABLE == type)
\r
4326 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n"));
\r
4327 pCoexSta->bUnderLps = TRUE;
\r
4329 else if(BTC_LPS_DISABLE == type)
\r
4331 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n"));
\r
4332 pCoexSta->bUnderLps = FALSE;
\r
4337 EXhalbtc8821a2ant_ScanNotify(
\r
4338 IN PBTC_COEXIST pBtCoexist,
\r
4342 u1Byte u1Tmpa, u1Tmpb;
\r
4344 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
\r
4345 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);
\r
4347 if(BTC_SCAN_START == type)
\r
4349 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));
\r
4351 else if(BTC_SCAN_FINISH == type)
\r
4353 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));
\r
4356 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u1Tmpa, u1Tmpb));
\r
4360 EXhalbtc8821a2ant_ConnectNotify(
\r
4361 IN PBTC_COEXIST pBtCoexist,
\r
4365 if(BTC_ASSOCIATE_START == type)
\r
4367 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));
\r
4369 else if(BTC_ASSOCIATE_FINISH == type)
\r
4371 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));
\r
4376 EXhalbtc8821a2ant_MediaStatusNotify(
\r
4377 IN PBTC_COEXIST pBtCoexist,
\r
4381 u1Byte H2C_Parameter[3] ={0};
\r
4383 u1Byte wifiCentralChnl;
\r
4386 if(BTC_MEDIA_CONNECT == type)
\r
4388 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n"));
\r
4392 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n"));
\r
4395 // only 2.4G we need to inform bt the chnl mask
\r
4396 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
\r
4397 if( (BTC_MEDIA_CONNECT == type) &&
\r
4398 (wifiCentralChnl <= 14) )
\r
4400 H2C_Parameter[0] = 0x1;
\r
4401 H2C_Parameter[1] = wifiCentralChnl;
\r
4402 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
4403 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
4404 H2C_Parameter[2] = 0x30;
\r
4407 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
\r
4409 H2C_Parameter[2] = 0x30;
\r
4411 H2C_Parameter[2] = 0x20;
\r
4415 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
\r
4416 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
\r
4417 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
\r
4419 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n",
\r
4420 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
\r
4422 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
\r
4426 EXhalbtc8821a2ant_SpecialPacketNotify(
\r
4427 IN PBTC_COEXIST pBtCoexist,
\r
4431 if(type == BTC_PACKET_DHCP)
\r
4433 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n"));
\r
4438 EXhalbtc8821a2ant_BtInfoNotify(
\r
4439 IN PBTC_COEXIST pBtCoexist,
\r
4440 IN pu1Byte tmpBuf,
\r
4444 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
4446 u1Byte i, rspSource=0;
\r
4447 BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE;
\r
4448 BOOLEAN bWifiConnected=FALSE, bWifiUnder5G=FALSE;
\r
4449 static BOOLEAN bPreScoExist=FALSE;
\r
4450 u4Byte raMask=0x0;
\r
4452 pCoexSta->bC2hBtInfoReqSent = FALSE;
\r
4453 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
4454 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
4456 rspSource = tmpBuf[0]&0xf;
\r
4457 if(rspSource >= BT_INFO_SRC_8821A_2ANT_MAX)
\r
4458 rspSource = BT_INFO_SRC_8821A_2ANT_WIFI_FW;
\r
4459 pCoexSta->btInfoC2hCnt[rspSource]++;
\r
4461 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
\r
4462 for(i=0; i<length; i++)
\r
4464 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
\r
4466 btInfo = tmpBuf[i];
\r
4469 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i]));
\r
4473 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i]));
\r
4477 if(pBtCoexist->bManualControl)
\r
4479 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
\r
4483 // if 0xff, it means BT is under WHCK test
\r
4484 if (btInfo == 0xff)
\r
4485 pCoexSta->bBtWhckTest = TRUE;
\r
4487 pCoexSta->bBtWhckTest = FALSE;
\r
4489 if(BT_INFO_SRC_8821A_2ANT_WIFI_FW != rspSource)
\r
4491 pCoexSta->btRetryCnt = // [3:0]
\r
4492 pCoexSta->btInfoC2h[rspSource][2]&0xf;
\r
4494 pCoexSta->btRssi =
\r
4495 pCoexSta->btInfoC2h[rspSource][3]*2+10;
\r
4497 pCoexSta->btInfoExt =
\r
4498 pCoexSta->btInfoC2h[rspSource][4];
\r
4500 pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
\r
4501 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
\r
4502 if(pCoexSta->bBtTxRxMask)
\r
4504 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */
\r
4505 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n"));
\r
4506 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01);
\r
4509 // Here we need to resend some wifi info to BT
\r
4510 // because bt is reset and loss of the info.
\r
4511 if( (pCoexSta->btInfoExt & BIT1) )
\r
4513 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
\r
4514 if(bWifiConnected)
\r
4516 EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
\r
4520 EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
4525 if(!pBtCoexist->bManualControl && !bWifiUnder5G)
\r
4527 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info = 0x%x!!\n", pCoexSta->btInfoExt));
\r
4528 if( (pCoexSta->btInfoExt&BIT3) )
\r
4530 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3=1, bWifiConnected=%d\n", bWifiConnected));
\r
4531 if(bWifiConnected)
\r
4533 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
\r
4534 halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
4539 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3=0, bWifiConnected=%d\n", bWifiConnected));
\r
4540 // BT already NOT ignore Wlan active, do nothing here.
\r
4541 if(!bWifiConnected)
\r
4543 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT to ignore Wlan active!!\n"));
\r
4544 halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
4549 #if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 0)
\r
4550 if( (pCoexSta->btInfoExt & BIT4) )
\r
4552 // BT auto report already enabled, do nothing
\r
4556 halbtc8821a2ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);
\r
4561 // check BIT2 first ==> check if bt is under inquiry or page scan
\r
4562 if(btInfo & BT_INFO_8821A_2ANT_B_INQ_PAGE)
\r
4563 pCoexSta->bC2hBtInquiryPage = TRUE;
\r
4565 pCoexSta->bC2hBtInquiryPage = FALSE;
\r
4567 // set link exist status
\r
4568 if(!(btInfo&BT_INFO_8821A_2ANT_B_CONNECTION))
\r
4570 pCoexSta->bBtLinkExist = FALSE;
\r
4571 pCoexSta->bPanExist = FALSE;
\r
4572 pCoexSta->bA2dpExist = FALSE;
\r
4573 pCoexSta->bHidExist = FALSE;
\r
4574 pCoexSta->bScoExist = FALSE;
\r
4576 else // connection exists
\r
4578 pCoexSta->bBtLinkExist = TRUE;
\r
4579 if(btInfo & BT_INFO_8821A_2ANT_B_FTP)
\r
4580 pCoexSta->bPanExist = TRUE;
\r
4582 pCoexSta->bPanExist = FALSE;
\r
4583 if(btInfo & BT_INFO_8821A_2ANT_B_A2DP)
\r
4584 pCoexSta->bA2dpExist = TRUE;
\r
4586 pCoexSta->bA2dpExist = FALSE;
\r
4587 if(btInfo & BT_INFO_8821A_2ANT_B_HID)
\r
4588 pCoexSta->bHidExist = TRUE;
\r
4590 pCoexSta->bHidExist = FALSE;
\r
4591 if(btInfo & BT_INFO_8821A_2ANT_B_SCO_ESCO)
\r
4592 pCoexSta->bScoExist = TRUE;
\r
4594 pCoexSta->bScoExist = FALSE;
\r
4596 if ( (pCoexSta->bHidExist == FALSE) && (pCoexSta->bC2hBtInquiryPage == FALSE) && (pCoexSta->bScoExist == FALSE))
\r
4598 if (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160)
\r
4599 pCoexSta->bHidExist = TRUE;
\r
4603 halbtc8821a2ant_UpdateBtLinkInfo(pBtCoexist);
\r
4605 if(!(btInfo&BT_INFO_8821A_2ANT_B_CONNECTION))
\r
4607 pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
\r
4608 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
\r
4610 else if(btInfo == BT_INFO_8821A_2ANT_B_CONNECTION) // connection exists but no busy
\r
4612 pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE;
\r
4613 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
\r
4615 else if((btInfo&BT_INFO_8821A_2ANT_B_SCO_ESCO) ||
\r
4616 (btInfo&BT_INFO_8821A_2ANT_B_SCO_BUSY))
\r
4618 pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_SCO_BUSY;
\r
4619 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
\r
4621 else if(btInfo&BT_INFO_8821A_2ANT_B_ACL_BUSY)
\r
4623 pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_ACL_BUSY;
\r
4624 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
\r
4628 pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_MAX;
\r
4629 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
\r
4632 if( (BT_8821A_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
4633 (BT_8821A_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
4634 (BT_8821A_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
4637 bLimitedDig = TRUE;
\r
4642 bLimitedDig = FALSE;
\r
4645 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
4647 pCoexDm->bLimitedDig = bLimitedDig;
\r
4648 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig);
\r
4650 halbtc8821a2ant_RunCoexistMechanism(pBtCoexist);
\r
4654 EXhalbtc8821a2ant_HaltNotify(
\r
4655 IN PBTC_COEXIST pBtCoexist
\r
4658 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n"));
\r
4660 halbtc8821a2ant_WifiOffHwCfg(pBtCoexist);
\r
4661 //remove due to interrupt is disabled that polling c2h will fail and delay 100ms.
\r
4662 //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0
\r
4663 halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
4665 EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
4669 EXhalbtc8821a2ant_PnpNotify(
\r
4670 IN PBTC_COEXIST pBtCoexist,
\r
4671 IN u1Byte pnpState
\r
4674 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n"));
\r
4676 if(BTC_WIFI_PNP_SLEEP == pnpState)
\r
4678 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n"));
\r
4680 else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
\r
4682 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n"));
\r
4683 halbtc8821a2ant_InitHwConfig(pBtCoexist, FALSE);
\r
4684 halbtc8821a2ant_InitCoexDm(pBtCoexist);
\r
4685 halbtc8821a2ant_QueryBtInfo(pBtCoexist);
\r
4690 EXhalbtc8821a2ant_Periodical(
\r
4691 IN PBTC_COEXIST pBtCoexist
\r
4694 //static u1Byte disVerInfoCnt=0;
\r
4695 u4Byte fwVer=0, btPatchVer=0;
\r
4696 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
4697 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
4699 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n"));
\r
4701 if(pCoexSta->disVerInfoCnt <= 5)
\r
4703 pCoexSta->disVerInfoCnt += 1;
\r
4704 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));
\r
4705 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n",
\r
4706 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));
\r
4707 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n",
\r
4708 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
\r
4709 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
4710 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
4711 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",
\r
4712 GLCoexVerDate8821a2Ant, GLCoexVer8821a2Ant, fwVer, btPatchVer, btPatchVer));
\r
4713 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));
\r
4715 if (pCoexSta->disVerInfoCnt == 3)
\r
4717 //Antenna config to set 0x765 = 0x0 (GNT_BT control by PTA) after initial
\r
4718 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set GNT_BT control by PTA\n"));
\r
4719 halbtc8821a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, FALSE, FALSE);
\r
4723 #if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 0)
\r
4724 halbtc8821a2ant_QueryBtInfo(pBtCoexist);
\r
4725 halbtc8821a2ant_MonitorBtEnableDisable(pBtCoexist);
\r
4727 halbtc8821a2ant_MonitorBtCtr(pBtCoexist);
\r
4728 halbtc8821a2ant_MonitorWiFiCtr(pBtCoexist);
\r
4730 if( halbtc8821a2ant_IsWifiStatusChanged(pBtCoexist) ||
\r
4731 pCoexDm->bAutoTdmaAdjust)
\r
4733 halbtc8821a2ant_RunCoexistMechanism(pBtCoexist);
\r