1 //============================================================
\r
4 // This file is for RTL8703B 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 "HalBtc8703b2Ant.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_8703B_2ANT GLCoexDm8703b2Ant;
\r
25 static PCOEX_DM_8703B_2ANT pCoexDm=&GLCoexDm8703b2Ant;
\r
26 static COEX_STA_8703B_2ANT GLCoexSta8703b2Ant;
\r
27 static PCOEX_STA_8703B_2ANT pCoexSta=&GLCoexSta8703b2Ant;
\r
29 const char *const GLBtInfoSrc8703b2Ant[]={
\r
32 "BT Info[bt auto report]",
\r
35 u4Byte GLCoexVerDate8703b2Ant=20140903;
\r
36 u4Byte GLCoexVer8703b2Ant=0x43;
\r
38 //============================================================
\r
39 // local function proto type if needed
\r
40 //============================================================
\r
41 //============================================================
\r
42 // local function start with halbtc8703b2ant_
\r
43 //============================================================
\r
45 halbtc8703b2ant_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_8703B_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_8703B_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_8703B_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 halbtc8703b2ant_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_8703B_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_8703B_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_8703B_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 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_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 = halbtc8703b2ant_WifiRssiState(pBtCoexist,3, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
455 if ( (BTC_RSSI_STATE_HIGH ==wifiRssiState ) || (BTC_RSSI_STATE_LOW ==wifiRssiState ))
\r
466 halbtc8703b2ant_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_8703B_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 halbtc8703b2ant_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_8703B_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_8703B_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_8703B_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_8703B_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_8703B_2ANT_COEX_ALGO_PANHS;
\r
595 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n"));
\r
596 algorithm = BT_8703B_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_8703B_2ANT_COEX_ALGO_PANEDR_HID;
\r
610 else if(pBtLinkInfo->bA2dpExist)
\r
612 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n"));
\r
613 algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID;
\r
615 else if(pBtLinkInfo->bPanExist)
\r
619 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n"));
\r
620 algorithm = BT_8703B_2ANT_COEX_ALGO_SCO;
\r
624 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n"));
\r
625 algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID;
\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_8703B_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
\r
643 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n"));
\r
644 algorithm = BT_8703B_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_8703B_2ANT_COEX_ALGO_HID;
\r
657 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n"));
\r
658 algorithm = BT_8703B_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_8703B_2ANT_COEX_ALGO_A2DP_PANHS;
\r
671 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n"));
\r
672 algorithm = BT_8703B_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 ==> HID\n"));
\r
685 algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID;
\r
687 else if( pBtLinkInfo->bHidExist &&
\r
688 pBtLinkInfo->bPanExist )
\r
692 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS)\n"));
\r
693 algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID;
\r
697 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
\r
698 algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID;
\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_8703B_2ANT_COEX_ALGO_PANEDR_HID;
\r
711 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
\r
712 algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID;
\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_8703B_2ANT_COEX_ALGO_HID_A2DP;
\r
729 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
\r
730 algorithm = BT_8703B_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_8703B_2ANT_COEX_ALGO_PANEDR_HID;
\r
761 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
\r
812 pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
\r
816 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
\r
854 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
\r
858 halbtc8703b2ant_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 halbtc8703b2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
\r
876 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
\r
880 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
\r
921 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
\r
925 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
968 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
972 halbtc8703b2ant_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, 0x883, 0x3e, val);
\r
984 halbtc8703b2ant_SetSwFullTimeDacSwing(
\r
985 IN PBTC_COEXIST pBtCoexist,
\r
986 IN BOOLEAN bSwDacSwingOn,
\r
987 IN u4Byte swDacSwingLvl
\r
992 halbtc8703b2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
\r
996 halbtc8703b2ant_SetDacSwingReg(pBtCoexist, 0x18);
\r
1002 halbtc8703b2ant_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 halbtc8703b2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
\r
1023 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
\r
1024 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
\r
1028 halbtc8703b2ant_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, 0xc05, 0x30, 0x3);
\r
1040 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n"));
\r
1041 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc05, 0x30, 0x1);
\r
1046 halbtc8703b2ant_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 halbtc8703b2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
\r
1063 pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
\r
1067 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
\r
1156 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
\r
1160 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_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 halbtc8703b2ant_CoexTableWithType(
\r
1216 IN PBTC_COEXIST pBtCoexist,
\r
1217 IN BOOLEAN bForceExec,
\r
1221 pCoexSta->nCoexTableType = type;
\r
1226 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);
\r
1229 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffffff, 0x3);
\r
1232 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x5ada5ada, 0x5ada5ada, 0xffffff, 0x3);
\r
1235 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
\r
1238 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffffff, 0x3);
\r
1241 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3);
\r
1244 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3);
\r
1247 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1250 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1253 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1256 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1259 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1262 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);
\r
1265 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0xaaaaaaaa, 0xffffff, 0x3);
\r
1268 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5ada5ada, 0xffffff, 0x3);
\r
1271 halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0xaaaaaaaa, 0xffffff, 0x3);
\r
1279 halbtc8703b2ant_SetFwIgnoreWlanAct(
\r
1280 IN PBTC_COEXIST pBtCoexist,
\r
1281 IN BOOLEAN bEnable
\r
1284 u1Byte H2C_Parameter[1] ={0};
\r
1288 H2C_Parameter[0] |= BIT0; // function enable
\r
1291 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
\r
1292 H2C_Parameter[0]));
\r
1294 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
\r
1298 halbtc8703b2ant_SetLpsRpwm(
\r
1299 IN PBTC_COEXIST pBtCoexist,
\r
1304 u1Byte lps=lpsVal;
\r
1305 u1Byte rpwm=rpwmVal;
\r
1307 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
\r
1308 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
\r
1312 halbtc8703b2ant_LpsRpwm(
\r
1313 IN PBTC_COEXIST pBtCoexist,
\r
1314 IN BOOLEAN bForceExec,
\r
1319 BOOLEAN bForceExecPwrCmd=FALSE;
\r
1321 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
\r
1322 (bForceExec? "force to":""), lpsVal, rpwmVal));
\r
1323 pCoexDm->curLps = lpsVal;
\r
1324 pCoexDm->curRpwm = rpwmVal;
\r
1328 if( (pCoexDm->preLps == pCoexDm->curLps) &&
\r
1329 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
\r
1334 halbtc8703b2ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
\r
1336 pCoexDm->preLps = pCoexDm->curLps;
\r
1337 pCoexDm->preRpwm = pCoexDm->curRpwm;
\r
1341 halbtc8703b2ant_IgnoreWlanAct(
\r
1342 IN PBTC_COEXIST pBtCoexist,
\r
1343 IN BOOLEAN bForceExec,
\r
1344 IN BOOLEAN bEnable
\r
1347 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n",
\r
1348 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
\r
1349 pCoexDm->bCurIgnoreWlanAct = bEnable;
\r
1353 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
\r
1356 halbtc8703b2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
\r
1358 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
\r
1362 halbtc8703b2ant_SetFwPstdma(
\r
1363 IN PBTC_COEXIST pBtCoexist,
\r
1371 u1Byte H2C_Parameter[5] ={0};
\r
1374 if ( (pCoexSta->bA2dpExist) && (pCoexSta->bHidExist) )
\r
1376 byte5 = byte5 | 0x1;
\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 halbtc8703b2ant_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 //halbtc8703b2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);
\r
1420 halbtc8703b2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
\r
1424 halbtc8703b2ant_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 //halbtc8703b2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);
\r
1433 //halbtc8703b2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff);
\r
1434 //halbtc8703b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);
\r
1438 halbtc8703b2ant_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
1446 u4Byte fwVer=0, u4Tmp=0;
\r
1447 BOOLEAN bPgExtSwitch=FALSE;
\r
1448 BOOLEAN bUseExtSwitch=FALSE;
\r
1449 u1Byte H2C_Parameter[2] ={0};
\r
1451 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch);
\r
1452 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); // [31:16]=fw ver, [15:0]=fw sub ver
\r
1454 if((fwVer>0 && fwVer<0xc0000) || bPgExtSwitch)
\r
1455 bUseExtSwitch = TRUE;
\r
1459 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1);
\r
1460 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff);
\r
1461 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3);
\r
1462 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77);
\r
1463 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1);
\r
1465 if(fwVer >= 0x180000)
\r
1467 /* Use H2C to set GNT_BT to High to avoid A2DP click */
\r
1468 H2C_Parameter[0] = 1;
\r
1469 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
\r
1473 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
\r
1476 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
\r
1478 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); //WiFi TRx Mask off
\r
1479 //remove due to interrupt is disabled that polling c2h will fail and delay 100ms.
\r
1480 //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); //BT TRx Mask off
\r
1482 if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT)
\r
1484 //tell firmware "no antenna inverse"
\r
1485 H2C_Parameter[0] = 0;
\r
1489 //tell firmware "antenna inverse"
\r
1490 H2C_Parameter[0] = 1;
\r
1493 if (bUseExtSwitch)
\r
1496 H2C_Parameter[1] = 1;
\r
1501 H2C_Parameter[1] = 0;
\r
1503 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
\r
1507 if(fwVer >= 0x180000)
\r
1509 /* Use H2C to set GNT_BT to "Control by PTA"*/
\r
1510 H2C_Parameter[0] = 0;
\r
1511 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
\r
1515 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0);
\r
1519 // ext switch setting
\r
1524 // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT
\r
1525 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1528 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1531 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); // fixed internal switch S1->WiFi, S0->BT
\r
1532 switch(antPosType)
\r
1534 case BTC_ANT_WIFI_AT_MAIN:
\r
1535 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); // ext switch main at wifi
\r
1537 case BTC_ANT_WIFI_AT_AUX:
\r
1538 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); // ext switch aux at wifi
\r
1542 else // internal switch
\r
1546 // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT
\r
1547 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
1550 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
\r
1553 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); //fixed external switch S1->Main, S0->Aux
\r
1554 switch(antPosType)
\r
1556 case BTC_ANT_WIFI_AT_MAIN:
\r
1557 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); // fixed internal switch S1->WiFi, S0->BT
\r
1559 case BTC_ANT_WIFI_AT_AUX:
\r
1560 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); // fixed internal switch S0->WiFi, S1->BT
\r
1567 halbtc8703b2ant_PsTdma(
\r
1568 IN PBTC_COEXIST pBtCoexist,
\r
1569 IN BOOLEAN bForceExec,
\r
1570 IN BOOLEAN bTurnOn,
\r
1574 BOOLEAN bTurnOnByCnt=FALSE;
\r
1575 u1Byte psTdmaTypeByCnt=0;
\r
1576 u1Byte wifiRssiState1, btRssiState;
\r
1579 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
1580 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
1582 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
\r
1583 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
\r
1584 pCoexDm->bCurPsTdmaOn = bTurnOn;
\r
1585 pCoexDm->curPsTdma = type;
\r
1587 if (!(BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) && bTurnOn)
\r
1589 type = type +100; //for WiFi RSSI low or BT RSSI low
\r
1590 pCoexDm->bIsSwitchTo1dot5Ant = TRUE;
\r
1594 pCoexDm->bIsSwitchTo1dot5Ant = FALSE;
\r
1600 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
\r
1601 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
\r
1610 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
\r
1611 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);
\r
1614 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
\r
1615 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90);
\r
1618 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);
\r
1621 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90);
\r
1624 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
\r
1625 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90);
\r
1628 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
\r
1629 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90);
\r
1632 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);
\r
1635 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90);
\r
1638 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
\r
1639 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);
\r
1642 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
\r
1643 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90);
\r
1646 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90);
\r
1647 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);
\r
1650 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
\r
1651 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0xf1, 0x90);
\r
1654 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
\r
1655 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90);
\r
1658 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
\r
1659 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90);
\r
1662 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90);
\r
1663 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);
\r
1666 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90);
\r
1667 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0x70, 0x90);
\r
1670 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90);
\r
1673 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
\r
1676 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90);
\r
1679 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90);
\r
1682 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);
\r
1685 //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
\r
1687 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);
\r
1692 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x3a, 0x03, 0x70, 0x50);
\r
1698 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x2d, 0x03, 0x70, 0x50);
\r
1704 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1c, 0x03, 0x70, 0x50);
\r
1710 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x10, 0x03, 0x70, 0x50);
\r
1713 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);
\r
1716 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x70, 0x90);
\r
1719 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);
\r
1723 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x35, 0x03, 0x71, 0x11);
\r
1729 // disable PS tdma
\r
1733 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
\r
1736 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0);
\r
1739 halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
\r
1744 // update pre state
\r
1745 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
\r
1746 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
\r
1750 halbtc8703b2ant_PsTdmaCheckForPowerSaveState(
\r
1751 IN PBTC_COEXIST pBtCoexist,
\r
1752 IN BOOLEAN bNewPsState
\r
1755 u1Byte lpsMode=0x0;
\r
1757 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
\r
1759 if(lpsMode) // already under LPS state
\r
1763 // keep state under LPS, do nothing.
\r
1767 // will leave LPS state, turn off psTdma first
\r
1768 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1771 else // NO PS state
\r
1775 // will enter LPS state, turn off psTdma first
\r
1776 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1780 // keep state under NO PS state, do nothing.
\r
1786 halbtc8703b2ant_PowerSaveState(
\r
1787 IN PBTC_COEXIST pBtCoexist,
\r
1793 BOOLEAN bLowPwrDisable=FALSE;
\r
1797 case BTC_PS_WIFI_NATIVE:
\r
1798 // recover to original 32k low power setting
\r
1799 bLowPwrDisable = FALSE;
\r
1800 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1801 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1802 pCoexSta->bForceLpsOn = FALSE;
\r
1804 case BTC_PS_LPS_ON:
\r
1805 halbtc8703b2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);
\r
1806 halbtc8703b2ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
\r
1807 // when coex force to enter LPS, do not enter 32k low power.
\r
1808 bLowPwrDisable = TRUE;
\r
1809 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1810 // power save must executed before psTdma.
\r
1811 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
\r
1812 pCoexSta->bForceLpsOn = TRUE;
\r
1814 case BTC_PS_LPS_OFF:
\r
1815 halbtc8703b2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
\r
1816 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
\r
1817 pCoexSta->bForceLpsOn = FALSE;
\r
1826 halbtc8703b2ant_CoexAllOff(
\r
1827 IN PBTC_COEXIST pBtCoexist
\r
1831 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1832 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1833 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
1834 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1837 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1838 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1841 //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
1842 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1846 halbtc8703b2ant_InitCoexDm(
\r
1847 IN PBTC_COEXIST pBtCoexist
\r
1850 // force to reset coex mechanism
\r
1851 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1853 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1854 halbtc8703b2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
\r
1855 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
\r
1856 halbtc8703b2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
\r
1858 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1859 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1863 halbtc8703b2ant_ActionBtInquiry(
\r
1864 IN PBTC_COEXIST pBtCoexist
\r
1867 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
1868 BOOLEAN bWifiConnected=FALSE;
\r
1869 BOOLEAN bLowPwrDisable=TRUE;
\r
1870 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
1873 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
1874 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
1875 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
1877 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
1878 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1880 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
1881 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
1882 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
1885 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1887 if(bScan || bLink || bRoam)
\r
1889 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi link process + BT Inq/Page!!\n"));
\r
1890 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15);
\r
1891 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
1893 else if(bWifiConnected)
\r
1895 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT Inq/Page!!\n"));
\r
1896 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15);
\r
1897 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
1901 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi no-link + BT Inq/Page!!\n"));
\r
1902 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1903 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1906 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
\r
1907 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1909 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1910 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1912 pCoexDm->bNeedRecover0x948 = TRUE;
\r
1913 pCoexDm->backup0x948 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
\r
1915 halbtc8703b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, FALSE, FALSE);
\r
1921 halbtc8703b2ant_ActionWiFiLinkProcess(
\r
1922 IN PBTC_COEXIST pBtCoexist
\r
1926 u1Byte u1Tmpa, u1Tmpb;
\r
1928 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15);
\r
1929 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
1931 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1932 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1935 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
\r
1936 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
\r
1937 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);
\r
1939 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x76e=0x%x\n",
\r
1940 u4Tmp, u1Tmpa, u1Tmpb));
\r
1944 halbtc8703b2ant_ActionWifiIdleProcess(
\r
1945 IN PBTC_COEXIST pBtCoexist
\r
1948 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
1952 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
1953 //wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
1954 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES-20, 0);
\r
1955 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
1957 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
\r
1959 // define the office environment
\r
1960 if(BTC_RSSI_HIGH(wifiRssiState1) &&
\r
1961 (pCoexSta->bHidExist == TRUE) && (pCoexSta->bA2dpExist == TRUE))
\r
1964 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle process for BT HID+A2DP exist!!\n"));
\r
1966 halbtc8703b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x6);
\r
1967 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
1970 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
1971 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
1973 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
1975 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
1976 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
1982 halbtc8703b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1992 halbtc8703b2ant_IsCommonAction(
\r
1993 IN PBTC_COEXIST pBtCoexist
\r
1996 u1Byte btRssiState=BTC_RSSI_STATE_HIGH;
\r
1997 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
1998 BOOLEAN bBtHsOn=FALSE, bLowPwrDisable=FALSE;
\r
1999 BOOLEAN bAsus8703b=FALSE;
\r
2001 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
2002 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
2003 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
2005 if(!bWifiConnected)
\r
2007 bLowPwrDisable = FALSE;
\r
2008 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
2009 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
2011 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-connected idle!!\n"));
\r
2013 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
2014 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2016 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2017 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
2018 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
2019 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2021 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
2022 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
2028 if(BT_8703B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
\r
2030 bLowPwrDisable = FALSE;
\r
2031 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
2032 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
2034 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
\r
2036 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
2037 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2039 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2040 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
2041 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
\r
2042 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2044 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
2045 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
2049 else if(BT_8703B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
\r
2051 bLowPwrDisable = TRUE;
\r
2052 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
2056 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
\r
2057 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
2059 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
2060 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
2062 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
2063 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
2064 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
\r
2065 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
2067 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
2068 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
2074 bLowPwrDisable = TRUE;
\r
2075 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
\r
2079 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
\r
2081 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_IS_ASUS_8703B, &bAsus8703b);
\r
2085 bCommon = halbtc8703b2ant_ActionWifiIdleProcess(pBtCoexist);
\r
2092 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));
\r
2093 //bCommon = FALSE;
\r
2094 bCommon = halbtc8703b2ant_ActionWifiIdleProcess(pBtCoexist);
\r
2102 halbtc8703b2ant_TdmaDurationAdjust(
\r
2103 IN PBTC_COEXIST pBtCoexist,
\r
2104 IN BOOLEAN bScoHid,
\r
2105 IN BOOLEAN bTxPause,
\r
2106 IN u1Byte maxInterval
\r
2109 static s4Byte up,dn,m,n,WaitCount;
\r
2110 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
\r
2111 u1Byte retryCount=0;
\r
2113 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n"));
\r
2115 if(!pCoexDm->bAutoTdmaAdjust)
\r
2117 pCoexDm->bAutoTdmaAdjust = TRUE;
\r
2118 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
\r
2124 if(maxInterval == 1)
\r
2126 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
2127 pCoexDm->psTdmaDuAdjType = 13;
\r
2129 else if(maxInterval == 2)
\r
2131 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2132 pCoexDm->psTdmaDuAdjType = 14;
\r
2134 else if(maxInterval == 3)
\r
2136 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2137 pCoexDm->psTdmaDuAdjType = 15;
\r
2141 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2142 pCoexDm->psTdmaDuAdjType = 15;
\r
2147 if(maxInterval == 1)
\r
2149 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
2150 pCoexDm->psTdmaDuAdjType = 9;
\r
2152 else if(maxInterval == 2)
\r
2154 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2155 pCoexDm->psTdmaDuAdjType = 10;
\r
2157 else if(maxInterval == 3)
\r
2159 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2160 pCoexDm->psTdmaDuAdjType = 11;
\r
2164 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2165 pCoexDm->psTdmaDuAdjType = 11;
\r
2173 if(maxInterval == 1)
\r
2175 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2176 pCoexDm->psTdmaDuAdjType = 5;
\r
2178 else if(maxInterval == 2)
\r
2180 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2181 pCoexDm->psTdmaDuAdjType = 6;
\r
2183 else if(maxInterval == 3)
\r
2185 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2186 pCoexDm->psTdmaDuAdjType = 7;
\r
2190 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2191 pCoexDm->psTdmaDuAdjType = 7;
\r
2196 if(maxInterval == 1)
\r
2198 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
2199 pCoexDm->psTdmaDuAdjType = 1;
\r
2201 else if(maxInterval == 2)
\r
2203 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2204 pCoexDm->psTdmaDuAdjType = 2;
\r
2206 else if(maxInterval == 3)
\r
2208 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2209 pCoexDm->psTdmaDuAdjType = 3;
\r
2213 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2214 pCoexDm->psTdmaDuAdjType = 3;
\r
2229 //accquire the BT TRx retry count from BT_Info byte2
\r
2230 retryCount = pCoexSta->btRetryCnt;
\r
2231 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount));
\r
2232 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
\r
2233 up, dn, m, n, WaitCount));
\r
2237 if(retryCount == 0) // no retry in the last 2-second duration
\r
2245 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
\r
2252 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n"));
\r
2255 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
\r
2263 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
\r
2265 if (WaitCount <= 2)
\r
2266 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
2270 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
2278 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
\r
2281 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
\r
2283 if (WaitCount == 1)
\r
2284 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
2288 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
2296 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
\r
2299 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval));
\r
2300 if(maxInterval == 1)
\r
2304 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
\r
2306 if(pCoexDm->curPsTdma == 71)
\r
2308 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2309 pCoexDm->psTdmaDuAdjType = 5;
\r
2311 else if(pCoexDm->curPsTdma == 1)
\r
2313 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2314 pCoexDm->psTdmaDuAdjType = 5;
\r
2316 else if(pCoexDm->curPsTdma == 2)
\r
2318 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2319 pCoexDm->psTdmaDuAdjType = 6;
\r
2321 else if(pCoexDm->curPsTdma == 3)
\r
2323 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2324 pCoexDm->psTdmaDuAdjType = 7;
\r
2326 else if(pCoexDm->curPsTdma == 4)
\r
2328 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2329 pCoexDm->psTdmaDuAdjType = 8;
\r
2331 if(pCoexDm->curPsTdma == 9)
\r
2333 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
2334 pCoexDm->psTdmaDuAdjType = 13;
\r
2336 else if(pCoexDm->curPsTdma == 10)
\r
2338 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2339 pCoexDm->psTdmaDuAdjType = 14;
\r
2341 else if(pCoexDm->curPsTdma == 11)
\r
2343 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2344 pCoexDm->psTdmaDuAdjType = 15;
\r
2346 else if(pCoexDm->curPsTdma == 12)
\r
2348 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2349 pCoexDm->psTdmaDuAdjType = 16;
\r
2354 if(pCoexDm->curPsTdma == 5)
\r
2356 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2357 pCoexDm->psTdmaDuAdjType = 6;
\r
2359 else if(pCoexDm->curPsTdma == 6)
\r
2361 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2362 pCoexDm->psTdmaDuAdjType = 7;
\r
2364 else if(pCoexDm->curPsTdma == 7)
\r
2366 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2367 pCoexDm->psTdmaDuAdjType = 8;
\r
2369 else if(pCoexDm->curPsTdma == 13)
\r
2371 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2372 pCoexDm->psTdmaDuAdjType = 14;
\r
2374 else if(pCoexDm->curPsTdma == 14)
\r
2376 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2377 pCoexDm->psTdmaDuAdjType = 15;
\r
2379 else if(pCoexDm->curPsTdma == 15)
\r
2381 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2382 pCoexDm->psTdmaDuAdjType = 16;
\r
2385 else if (result == 1)
\r
2387 if(pCoexDm->curPsTdma == 8)
\r
2389 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2390 pCoexDm->psTdmaDuAdjType = 7;
\r
2392 else if(pCoexDm->curPsTdma == 7)
\r
2394 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2395 pCoexDm->psTdmaDuAdjType = 6;
\r
2397 else if(pCoexDm->curPsTdma == 6)
\r
2399 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
2400 pCoexDm->psTdmaDuAdjType = 5;
\r
2402 else if(pCoexDm->curPsTdma == 16)
\r
2404 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2405 pCoexDm->psTdmaDuAdjType = 15;
\r
2407 else if(pCoexDm->curPsTdma == 15)
\r
2409 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2410 pCoexDm->psTdmaDuAdjType = 14;
\r
2412 else if(pCoexDm->curPsTdma == 14)
\r
2414 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
2415 pCoexDm->psTdmaDuAdjType = 13;
\r
2421 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
\r
2422 if(pCoexDm->curPsTdma == 5)
\r
2424 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71);
\r
2425 pCoexDm->psTdmaDuAdjType = 71;
\r
2427 else if(pCoexDm->curPsTdma == 6)
\r
2429 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2430 pCoexDm->psTdmaDuAdjType = 2;
\r
2432 else if(pCoexDm->curPsTdma == 7)
\r
2434 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2435 pCoexDm->psTdmaDuAdjType = 3;
\r
2437 else if(pCoexDm->curPsTdma == 8)
\r
2439 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2440 pCoexDm->psTdmaDuAdjType = 4;
\r
2442 if(pCoexDm->curPsTdma == 13)
\r
2444 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
2445 pCoexDm->psTdmaDuAdjType = 9;
\r
2447 else if(pCoexDm->curPsTdma == 14)
\r
2449 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2450 pCoexDm->psTdmaDuAdjType = 10;
\r
2452 else if(pCoexDm->curPsTdma == 15)
\r
2454 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2455 pCoexDm->psTdmaDuAdjType = 11;
\r
2457 else if(pCoexDm->curPsTdma == 16)
\r
2459 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2460 pCoexDm->psTdmaDuAdjType = 12;
\r
2465 if(pCoexDm->curPsTdma == 71)
\r
2467 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
2468 pCoexDm->psTdmaDuAdjType = 1;
\r
2470 else if(pCoexDm->curPsTdma == 1)
\r
2472 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2473 pCoexDm->psTdmaDuAdjType = 2;
\r
2475 else if(pCoexDm->curPsTdma == 2)
\r
2477 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2478 pCoexDm->psTdmaDuAdjType = 3;
\r
2480 else if(pCoexDm->curPsTdma == 3)
\r
2482 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2483 pCoexDm->psTdmaDuAdjType = 4;
\r
2485 else if(pCoexDm->curPsTdma == 9)
\r
2487 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2488 pCoexDm->psTdmaDuAdjType = 10;
\r
2490 else if(pCoexDm->curPsTdma == 10)
\r
2492 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2493 pCoexDm->psTdmaDuAdjType = 11;
\r
2495 else if(pCoexDm->curPsTdma == 11)
\r
2497 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2498 pCoexDm->psTdmaDuAdjType = 12;
\r
2501 else if (result == 1)
\r
2503 if(pCoexDm->curPsTdma == 4)
\r
2505 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2506 pCoexDm->psTdmaDuAdjType = 3;
\r
2508 else if(pCoexDm->curPsTdma == 3)
\r
2510 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2511 pCoexDm->psTdmaDuAdjType = 2;
\r
2513 else if(pCoexDm->curPsTdma == 2)
\r
2515 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
2516 pCoexDm->psTdmaDuAdjType = 1;
\r
2518 else if(pCoexDm->curPsTdma == 1)
\r
2520 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71);
\r
2521 pCoexDm->psTdmaDuAdjType = 71;
\r
2523 else if(pCoexDm->curPsTdma == 12)
\r
2525 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2526 pCoexDm->psTdmaDuAdjType = 11;
\r
2528 else if(pCoexDm->curPsTdma == 11)
\r
2530 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2531 pCoexDm->psTdmaDuAdjType = 10;
\r
2533 else if(pCoexDm->curPsTdma == 10)
\r
2535 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
2536 pCoexDm->psTdmaDuAdjType = 9;
\r
2541 else if(maxInterval == 2)
\r
2545 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
\r
2546 if(pCoexDm->curPsTdma == 1)
\r
2548 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2549 pCoexDm->psTdmaDuAdjType = 6;
\r
2551 else if(pCoexDm->curPsTdma == 2)
\r
2553 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2554 pCoexDm->psTdmaDuAdjType = 6;
\r
2556 else if(pCoexDm->curPsTdma == 3)
\r
2558 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2559 pCoexDm->psTdmaDuAdjType = 7;
\r
2561 else if(pCoexDm->curPsTdma == 4)
\r
2563 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2564 pCoexDm->psTdmaDuAdjType = 8;
\r
2566 if(pCoexDm->curPsTdma == 9)
\r
2568 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2569 pCoexDm->psTdmaDuAdjType = 14;
\r
2571 else if(pCoexDm->curPsTdma == 10)
\r
2573 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2574 pCoexDm->psTdmaDuAdjType = 14;
\r
2576 else if(pCoexDm->curPsTdma == 11)
\r
2578 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2579 pCoexDm->psTdmaDuAdjType = 15;
\r
2581 else if(pCoexDm->curPsTdma == 12)
\r
2583 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2584 pCoexDm->psTdmaDuAdjType = 16;
\r
2588 if(pCoexDm->curPsTdma == 5)
\r
2590 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2591 pCoexDm->psTdmaDuAdjType = 6;
\r
2593 else if(pCoexDm->curPsTdma == 6)
\r
2595 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2596 pCoexDm->psTdmaDuAdjType = 7;
\r
2598 else if(pCoexDm->curPsTdma == 7)
\r
2600 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2601 pCoexDm->psTdmaDuAdjType = 8;
\r
2603 else if(pCoexDm->curPsTdma == 13)
\r
2605 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2606 pCoexDm->psTdmaDuAdjType = 14;
\r
2608 else if(pCoexDm->curPsTdma == 14)
\r
2610 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2611 pCoexDm->psTdmaDuAdjType = 15;
\r
2613 else if(pCoexDm->curPsTdma == 15)
\r
2615 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2616 pCoexDm->psTdmaDuAdjType = 16;
\r
2619 else if (result == 1)
\r
2621 if(pCoexDm->curPsTdma == 8)
\r
2623 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2624 pCoexDm->psTdmaDuAdjType = 7;
\r
2626 else if(pCoexDm->curPsTdma == 7)
\r
2628 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2629 pCoexDm->psTdmaDuAdjType = 6;
\r
2631 else if(pCoexDm->curPsTdma == 6)
\r
2633 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
2634 pCoexDm->psTdmaDuAdjType = 6;
\r
2636 else if(pCoexDm->curPsTdma == 16)
\r
2638 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2639 pCoexDm->psTdmaDuAdjType = 15;
\r
2641 else if(pCoexDm->curPsTdma == 15)
\r
2643 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2644 pCoexDm->psTdmaDuAdjType = 14;
\r
2646 else if(pCoexDm->curPsTdma == 14)
\r
2648 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
\r
2649 pCoexDm->psTdmaDuAdjType = 14;
\r
2655 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
\r
2656 if(pCoexDm->curPsTdma == 5)
\r
2658 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2659 pCoexDm->psTdmaDuAdjType = 2;
\r
2661 else if(pCoexDm->curPsTdma == 6)
\r
2663 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2664 pCoexDm->psTdmaDuAdjType = 2;
\r
2666 else if(pCoexDm->curPsTdma == 7)
\r
2668 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2669 pCoexDm->psTdmaDuAdjType = 3;
\r
2671 else if(pCoexDm->curPsTdma == 8)
\r
2673 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2674 pCoexDm->psTdmaDuAdjType = 4;
\r
2676 if(pCoexDm->curPsTdma == 13)
\r
2678 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2679 pCoexDm->psTdmaDuAdjType = 10;
\r
2681 else if(pCoexDm->curPsTdma == 14)
\r
2683 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2684 pCoexDm->psTdmaDuAdjType = 10;
\r
2686 else if(pCoexDm->curPsTdma == 15)
\r
2688 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2689 pCoexDm->psTdmaDuAdjType = 11;
\r
2691 else if(pCoexDm->curPsTdma == 16)
\r
2693 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2694 pCoexDm->psTdmaDuAdjType = 12;
\r
2698 if(pCoexDm->curPsTdma == 1)
\r
2700 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2701 pCoexDm->psTdmaDuAdjType = 2;
\r
2703 else if(pCoexDm->curPsTdma == 2)
\r
2705 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2706 pCoexDm->psTdmaDuAdjType = 3;
\r
2708 else if(pCoexDm->curPsTdma == 3)
\r
2710 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2711 pCoexDm->psTdmaDuAdjType = 4;
\r
2713 else if(pCoexDm->curPsTdma == 9)
\r
2715 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2716 pCoexDm->psTdmaDuAdjType = 10;
\r
2718 else if(pCoexDm->curPsTdma == 10)
\r
2720 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2721 pCoexDm->psTdmaDuAdjType = 11;
\r
2723 else if(pCoexDm->curPsTdma == 11)
\r
2725 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2726 pCoexDm->psTdmaDuAdjType = 12;
\r
2729 else if (result == 1)
\r
2731 if(pCoexDm->curPsTdma == 4)
\r
2733 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2734 pCoexDm->psTdmaDuAdjType = 3;
\r
2736 else if(pCoexDm->curPsTdma == 3)
\r
2738 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2739 pCoexDm->psTdmaDuAdjType = 2;
\r
2741 else if(pCoexDm->curPsTdma == 2)
\r
2743 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
2744 pCoexDm->psTdmaDuAdjType = 2;
\r
2746 else if(pCoexDm->curPsTdma == 12)
\r
2748 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2749 pCoexDm->psTdmaDuAdjType = 11;
\r
2751 else if(pCoexDm->curPsTdma == 11)
\r
2753 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2754 pCoexDm->psTdmaDuAdjType = 10;
\r
2756 else if(pCoexDm->curPsTdma == 10)
\r
2758 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
2759 pCoexDm->psTdmaDuAdjType = 10;
\r
2764 else if(maxInterval == 3)
\r
2768 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
\r
2769 if(pCoexDm->curPsTdma == 1)
\r
2771 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2772 pCoexDm->psTdmaDuAdjType = 7;
\r
2774 else if(pCoexDm->curPsTdma == 2)
\r
2776 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2777 pCoexDm->psTdmaDuAdjType = 7;
\r
2779 else if(pCoexDm->curPsTdma == 3)
\r
2781 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2782 pCoexDm->psTdmaDuAdjType = 7;
\r
2784 else if(pCoexDm->curPsTdma == 4)
\r
2786 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2787 pCoexDm->psTdmaDuAdjType = 8;
\r
2789 if(pCoexDm->curPsTdma == 9)
\r
2791 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2792 pCoexDm->psTdmaDuAdjType = 15;
\r
2794 else if(pCoexDm->curPsTdma == 10)
\r
2796 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2797 pCoexDm->psTdmaDuAdjType = 15;
\r
2799 else if(pCoexDm->curPsTdma == 11)
\r
2801 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2802 pCoexDm->psTdmaDuAdjType = 15;
\r
2804 else if(pCoexDm->curPsTdma == 12)
\r
2806 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2807 pCoexDm->psTdmaDuAdjType = 16;
\r
2811 if(pCoexDm->curPsTdma == 5)
\r
2813 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2814 pCoexDm->psTdmaDuAdjType = 7;
\r
2816 else if(pCoexDm->curPsTdma == 6)
\r
2818 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2819 pCoexDm->psTdmaDuAdjType = 7;
\r
2821 else if(pCoexDm->curPsTdma == 7)
\r
2823 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
\r
2824 pCoexDm->psTdmaDuAdjType = 8;
\r
2826 else if(pCoexDm->curPsTdma == 13)
\r
2828 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2829 pCoexDm->psTdmaDuAdjType = 15;
\r
2831 else if(pCoexDm->curPsTdma == 14)
\r
2833 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2834 pCoexDm->psTdmaDuAdjType = 15;
\r
2836 else if(pCoexDm->curPsTdma == 15)
\r
2838 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
\r
2839 pCoexDm->psTdmaDuAdjType = 16;
\r
2842 else if (result == 1)
\r
2844 if(pCoexDm->curPsTdma == 8)
\r
2846 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2847 pCoexDm->psTdmaDuAdjType = 7;
\r
2849 else if(pCoexDm->curPsTdma == 7)
\r
2851 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2852 pCoexDm->psTdmaDuAdjType = 7;
\r
2854 else if(pCoexDm->curPsTdma == 6)
\r
2856 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
\r
2857 pCoexDm->psTdmaDuAdjType = 7;
\r
2859 else if(pCoexDm->curPsTdma == 16)
\r
2861 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2862 pCoexDm->psTdmaDuAdjType = 15;
\r
2864 else if(pCoexDm->curPsTdma == 15)
\r
2866 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2867 pCoexDm->psTdmaDuAdjType = 15;
\r
2869 else if(pCoexDm->curPsTdma == 14)
\r
2871 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
\r
2872 pCoexDm->psTdmaDuAdjType = 15;
\r
2878 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
\r
2879 if(pCoexDm->curPsTdma == 5)
\r
2881 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2882 pCoexDm->psTdmaDuAdjType = 3;
\r
2884 else if(pCoexDm->curPsTdma == 6)
\r
2886 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2887 pCoexDm->psTdmaDuAdjType = 3;
\r
2889 else if(pCoexDm->curPsTdma == 7)
\r
2891 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2892 pCoexDm->psTdmaDuAdjType = 3;
\r
2894 else if(pCoexDm->curPsTdma == 8)
\r
2896 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2897 pCoexDm->psTdmaDuAdjType = 4;
\r
2899 if(pCoexDm->curPsTdma == 13)
\r
2901 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2902 pCoexDm->psTdmaDuAdjType = 11;
\r
2904 else if(pCoexDm->curPsTdma == 14)
\r
2906 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2907 pCoexDm->psTdmaDuAdjType = 11;
\r
2909 else if(pCoexDm->curPsTdma == 15)
\r
2911 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2912 pCoexDm->psTdmaDuAdjType = 11;
\r
2914 else if(pCoexDm->curPsTdma == 16)
\r
2916 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2917 pCoexDm->psTdmaDuAdjType = 12;
\r
2921 if(pCoexDm->curPsTdma == 1)
\r
2923 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2924 pCoexDm->psTdmaDuAdjType = 3;
\r
2926 else if(pCoexDm->curPsTdma == 2)
\r
2928 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2929 pCoexDm->psTdmaDuAdjType = 3;
\r
2931 else if(pCoexDm->curPsTdma == 3)
\r
2933 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
2934 pCoexDm->psTdmaDuAdjType = 4;
\r
2936 else if(pCoexDm->curPsTdma == 9)
\r
2938 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2939 pCoexDm->psTdmaDuAdjType = 11;
\r
2941 else if(pCoexDm->curPsTdma == 10)
\r
2943 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2944 pCoexDm->psTdmaDuAdjType = 11;
\r
2946 else if(pCoexDm->curPsTdma == 11)
\r
2948 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
2949 pCoexDm->psTdmaDuAdjType = 12;
\r
2952 else if (result == 1)
\r
2954 if(pCoexDm->curPsTdma == 4)
\r
2956 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2957 pCoexDm->psTdmaDuAdjType = 3;
\r
2959 else if(pCoexDm->curPsTdma == 3)
\r
2961 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2962 pCoexDm->psTdmaDuAdjType = 3;
\r
2964 else if(pCoexDm->curPsTdma == 2)
\r
2966 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
\r
2967 pCoexDm->psTdmaDuAdjType = 3;
\r
2969 else if(pCoexDm->curPsTdma == 12)
\r
2971 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2972 pCoexDm->psTdmaDuAdjType = 11;
\r
2974 else if(pCoexDm->curPsTdma == 11)
\r
2976 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2977 pCoexDm->psTdmaDuAdjType = 11;
\r
2979 else if(pCoexDm->curPsTdma == 10)
\r
2981 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
2982 pCoexDm->psTdmaDuAdjType = 11;
\r
2989 // if current PsTdma not match with the recorded one (when scan, dhcp...),
\r
2990 // then we have to adjust it back to the previous record one.
\r
2991 if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)
\r
2993 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
2994 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n",
\r
2995 pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));
\r
2997 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
2998 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
2999 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
3001 if( !bScan && !bLink && !bRoam)
\r
3003 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
\r
3007 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
\r
3012 // SCO only or SCO+PAN(HS)
\r
3014 halbtc8703b2ant_ActionSco(
\r
3015 IN PBTC_COEXIST pBtCoexist
\r
3018 u1Byte wifiRssiState, btRssiState;
\r
3021 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3022 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3024 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3026 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3028 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4);
\r
3030 if(BTC_RSSI_HIGH(btRssiState))
\r
3031 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3033 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3035 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3037 if (BTC_WIFI_BW_LEGACY == wifiBw) //for SCO quality at 11b/g mode
\r
3039 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
\r
3041 else //for SCO quality & wifi performance balance at 11n mode
\r
3043 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
\r
3046 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3047 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality
\r
3050 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3052 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3053 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3055 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3056 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x4);
\r
3060 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3061 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x4);
\r
3066 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3067 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3069 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3070 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x4);
\r
3074 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3075 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x4);
\r
3082 halbtc8703b2ant_ActionHid(
\r
3083 IN PBTC_COEXIST pBtCoexist
\r
3086 u1Byte wifiRssiState, btRssiState;
\r
3089 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3090 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3092 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3094 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3096 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3098 if(BTC_RSSI_HIGH(btRssiState))
\r
3099 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3101 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3103 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3105 if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode
\r
3107 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3109 else //for HID quality & wifi performance balance at 11n mode
\r
3111 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 9);
\r
3114 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3116 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3117 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3119 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
3123 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
\r
3127 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3129 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3130 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3132 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3133 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3137 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3138 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3143 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3144 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3146 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3147 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3151 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3152 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3157 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
\r
3159 halbtc8703b2ant_ActionA2dp(
\r
3160 IN PBTC_COEXIST pBtCoexist
\r
3163 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3167 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3168 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3169 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3171 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
\r
3173 // define the office environment
\r
3174 if( (apNum >= 10) && BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3176 //DbgPrint(" AP#>10(%d)\n", apNum);
\r
3177 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3179 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3180 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3181 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3182 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3184 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
3186 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3187 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
3190 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3191 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3193 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3194 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18);
\r
3198 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3199 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18);
\r
3205 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3206 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3208 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3210 if(BTC_RSSI_HIGH(btRssiState))
\r
3211 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3213 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3216 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3218 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3219 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3223 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);
\r
3224 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3228 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3229 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3231 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);
\r
3235 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1);
\r
3239 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3240 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3242 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3243 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3245 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3246 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3250 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3251 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3256 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3257 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3259 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3260 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3264 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3265 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3271 halbtc8703b2ant_ActionA2dpPanHs(
\r
3272 IN PBTC_COEXIST pBtCoexist
\r
3275 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3278 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3279 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3280 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3282 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3284 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3286 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3288 if(BTC_RSSI_HIGH(btRssiState))
\r
3289 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3291 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3293 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3295 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3296 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3300 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);
\r
3301 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3304 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2);
\r
3307 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3308 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3310 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3311 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3313 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3314 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3318 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3319 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3324 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3325 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3327 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3328 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3332 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3333 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3339 halbtc8703b2ant_ActionPanEdr(
\r
3340 IN PBTC_COEXIST pBtCoexist
\r
3343 u1Byte wifiRssiState,wifiRssiState1, btRssiState;
\r
3346 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3347 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3348 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3350 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3352 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3354 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3356 if(BTC_RSSI_HIGH(btRssiState))
\r
3357 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3359 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3361 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3363 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10);
\r
3364 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3368 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);
\r
3369 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3372 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3373 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3375 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
3379 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
3383 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3384 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3386 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3387 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3389 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3390 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3394 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3395 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3400 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3401 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3403 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3404 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3408 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3409 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3417 halbtc8703b2ant_ActionPanHs(
\r
3418 IN PBTC_COEXIST pBtCoexist
\r
3421 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3424 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3425 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3426 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3428 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3430 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3432 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3434 if(BTC_RSSI_HIGH(btRssiState))
\r
3435 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3437 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3439 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3441 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3442 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
3444 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\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 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3451 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3455 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3456 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3461 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3462 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3464 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3465 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3469 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3470 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3477 halbtc8703b2ant_ActionPanEdrA2dp(
\r
3478 IN PBTC_COEXIST pBtCoexist
\r
3481 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3484 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3485 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3486 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3488 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3490 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3492 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3494 if(BTC_RSSI_HIGH(btRssiState))
\r
3495 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3497 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3499 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3500 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3502 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3504 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3506 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3507 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3509 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12);
\r
3511 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3512 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3);
\r
3514 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3);
\r
3518 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);
\r
3519 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3);
\r
3523 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3525 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3526 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3528 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3529 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3533 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
\r
3534 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3539 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3540 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3542 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3543 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3547 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3548 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3554 halbtc8703b2ant_ActionPanEdrHid(
\r
3555 IN PBTC_COEXIST pBtCoexist
\r
3558 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3561 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3562 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3563 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3564 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3566 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3568 if(BTC_RSSI_HIGH(btRssiState))
\r
3569 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3571 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3573 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3575 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3576 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3580 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);
\r
3581 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3584 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3585 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3587 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3589 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3);
\r
3590 //halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11);
\r
3591 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780);
\r
3595 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3596 //halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3597 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3599 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 2);
\r
3603 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3604 //halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);
\r
3605 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3606 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2);
\r
3610 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3612 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3613 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3615 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3616 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3620 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3621 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3626 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3627 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3629 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3630 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3634 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3635 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3640 // HID+A2DP+PAN(EDR)
\r
3642 halbtc8703b2ant_ActionHidA2dpPanEdr(
\r
3643 IN PBTC_COEXIST pBtCoexist
\r
3646 u1Byte wifiRssiState,wifiRssiState1, btRssiState;
\r
3649 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3650 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3651 btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
\r
3653 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3655 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
\r
3657 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3659 if(BTC_RSSI_HIGH(btRssiState))
\r
3660 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3662 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3664 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3666 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3667 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3671 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);
\r
3672 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3675 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3677 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3678 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3680 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3681 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);
\r
3683 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3);
\r
3687 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);
\r
3691 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3693 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3694 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3696 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3697 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3701 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3702 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3707 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3708 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3710 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3711 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3715 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3716 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3722 halbtc8703b2ant_ActionHidA2dp(
\r
3723 IN PBTC_COEXIST pBtCoexist
\r
3726 u1Byte wifiRssiState, wifiRssiState1, btRssiState;
\r
3730 wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
\r
3731 //btRssiState = halbtc8703b2ant_BtRssiState(2, 29, 0);
\r
3732 wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
\r
3733 btRssiState = halbtc8703b2ant_BtRssiState(3, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 37);
\r
3735 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3737 halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x5);
\r
3739 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3741 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
3742 if(BTC_WIFI_BW_LEGACY == wifiBw)
\r
3744 if(BTC_RSSI_HIGH(btRssiState))
\r
3745 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3746 else if(BTC_RSSI_MEDIUM(btRssiState))
\r
3747 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3749 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3752 { // only 802.11N mode we have to dec bt power to 4 degree
\r
3753 if(BTC_RSSI_HIGH(btRssiState))
\r
3755 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
\r
3756 // need to check ap Number of Not
\r
3758 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
\r
3760 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3762 else if(BTC_RSSI_MEDIUM(btRssiState))
\r
3763 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
\r
3765 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3768 if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))
\r
3770 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
\r
3771 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3775 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);
\r
3776 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
\r
3779 if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3780 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3782 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3);
\r
3786 halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);
\r
3790 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
3792 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3793 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3795 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3796 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3800 halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);
\r
3801 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3806 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
3807 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
3809 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3810 halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);
\r
3814 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);
\r
3815 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3821 halbtc8703b2ant_ActionBtWhckTest(
\r
3822 IN PBTC_COEXIST pBtCoexist
\r
3825 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3828 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3829 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3831 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3833 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
3834 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
3838 halbtc8703b2ant_ActionWifiMultiPort(
\r
3839 IN PBTC_COEXIST pBtCoexist
\r
3842 halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
\r
3843 halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
\r
3846 halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
\r
3847 halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
\r
3850 //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
\r
3851 halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
\r
3853 halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
\r
3854 halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
\r
3858 halbtc8703b2ant_RunCoexistMechanism(
\r
3859 IN PBTC_COEXIST pBtCoexist
\r
3862 BOOLEAN bWifiUnder5G=FALSE, bBtHsOn=FALSE;
\r
3863 u1Byte btInfoOriginal=0, btRetryCnt=0;
\r
3864 u1Byte algorithm=0;
\r
3865 u4Byte numOfWifiLink=0;
\r
3866 u4Byte wifiLinkStatus=0;
\r
3867 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
3868 BOOLEAN bMiracastPlusBt=FALSE;
\r
3869 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
3871 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n"));
\r
3873 if(pBtCoexist->bManualControl)
\r
3875 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
\r
3879 if(pCoexSta->bUnderIps)
\r
3881 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n"));
\r
3885 if(pCoexSta->bBtWhckTest)
\r
3887 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under WHCK TEST!!!\n"));
\r
3888 halbtc8703b2ant_ActionBtWhckTest(pBtCoexist);
\r
3892 algorithm = halbtc8703b2ant_ActionAlgorithm(pBtCoexist);
\r
3893 if(pCoexSta->bC2hBtInquiryPage && (BT_8703B_2ANT_COEX_ALGO_PANHS!=algorithm))
\r
3895 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n"));
\r
3896 halbtc8703b2ant_ActionBtInquiry(pBtCoexist);
\r
3902 if(pCoexDm->bNeedRecover0x948)
\r
3904 pCoexDm->bNeedRecover0x948 = FALSE;
\r
3905 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, pCoexDm->backup0x948);
\r
3910 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
3911 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
3912 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
3914 if(bScan || bLink || bRoam)
\r
3916 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], WiFi is under Link Process !!\n"));
\r
3917 halbtc8703b2ant_ActionWiFiLinkProcess(pBtCoexist);
\r
3923 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
\r
3924 numOfWifiLink = wifiLinkStatus>>16;
\r
3926 if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED))
\r
3928 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) );
\r
3930 if(pBtLinkInfo->bBtLinkExist)
\r
3932 bMiracastPlusBt = TRUE;
\r
3936 bMiracastPlusBt = FALSE;
\r
3939 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);
\r
3940 halbtc8703b2ant_ActionWifiMultiPort(pBtCoexist);
\r
3946 bMiracastPlusBt = FALSE;
\r
3947 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);
\r
3950 pCoexDm->curAlgorithm = algorithm;
\r
3951 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm));
\r
3953 if(halbtc8703b2ant_IsCommonAction(pBtCoexist))
\r
3955 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n"));
\r
3956 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
3960 if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm)
\r
3962 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n",
\r
3963 pCoexDm->preAlgorithm, pCoexDm->curAlgorithm));
\r
3964 pCoexDm->bAutoTdmaAdjust = FALSE;
\r
3966 switch(pCoexDm->curAlgorithm)
\r
3968 case BT_8703B_2ANT_COEX_ALGO_SCO:
\r
3969 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n"));
\r
3970 halbtc8703b2ant_ActionSco(pBtCoexist);
\r
3972 case BT_8703B_2ANT_COEX_ALGO_HID:
\r
3973 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n"));
\r
3974 halbtc8703b2ant_ActionHid(pBtCoexist);
\r
3976 case BT_8703B_2ANT_COEX_ALGO_A2DP:
\r
3977 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n"));
\r
3978 halbtc8703b2ant_ActionA2dp(pBtCoexist);
\r
3980 case BT_8703B_2ANT_COEX_ALGO_A2DP_PANHS:
\r
3981 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n"));
\r
3982 halbtc8703b2ant_ActionA2dpPanHs(pBtCoexist);
\r
3984 case BT_8703B_2ANT_COEX_ALGO_PANEDR:
\r
3985 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"));
\r
3986 halbtc8703b2ant_ActionPanEdr(pBtCoexist);
\r
3988 case BT_8703B_2ANT_COEX_ALGO_PANHS:
\r
3989 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n"));
\r
3990 halbtc8703b2ant_ActionPanHs(pBtCoexist);
\r
3992 case BT_8703B_2ANT_COEX_ALGO_PANEDR_A2DP:
\r
3993 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"));
\r
3994 halbtc8703b2ant_ActionPanEdrA2dp(pBtCoexist);
\r
3996 case BT_8703B_2ANT_COEX_ALGO_PANEDR_HID:
\r
3997 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
\r
3998 halbtc8703b2ant_ActionPanEdrHid(pBtCoexist);
\r
4000 case BT_8703B_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
\r
4001 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
\r
4002 halbtc8703b2ant_ActionHidA2dpPanEdr(pBtCoexist);
\r
4004 case BT_8703B_2ANT_COEX_ALGO_HID_A2DP:
\r
4005 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"));
\r
4006 halbtc8703b2ant_ActionHidA2dp(pBtCoexist);
\r
4009 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"));
\r
4010 halbtc8703b2ant_CoexAllOff(pBtCoexist);
\r
4013 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
\r
4018 halbtc8703b2ant_WifiOffHwCfg(
\r
4019 IN PBTC_COEXIST pBtCoexist
\r
4022 BOOLEAN bIsInMpMode = FALSE;
\r
4023 u1Byte H2C_Parameter[2] ={0};
\r
4026 // set wlan_act to low
\r
4027 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
4029 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); //WiFi goto standby while GNT_BT 0-->1
\r
4030 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
4031 if(fwVer >= 0x180000)
\r
4033 /* Use H2C to set GNT_BT to HIGH */
\r
4034 H2C_Parameter[0] = 1;
\r
4035 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
\r
4039 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
\r
4042 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode);
\r
4044 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); //BT select s0/s1 is controlled by BT
\r
4046 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi
\r
4050 halbtc8703b2ant_InitHwConfig(
\r
4051 IN PBTC_COEXIST pBtCoexist,
\r
4052 IN BOOLEAN bBackUp
\r
4055 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
4056 u4Byte u4Tmp=0, fwVer;
\r
4059 u1Byte H2C_Parameter[2] ={0};
\r
4062 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n"));
\r
4064 // backup rf 0x1e value
\r
4065 pCoexDm->btRf0x1eBackup =
\r
4066 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
\r
4069 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
\r
4072 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
\r
4075 halbtc8703b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, TRUE, FALSE);
\r
4076 pCoexSta->disVerInfoCnt = 0;
\r
4079 halbtc8703b2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
\r
4081 // Enable counter statistics
\r
4082 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); //0x76e[3] =1, WLAN_Act control by PTA
\r
4083 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);
\r
4084 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
\r
4087 //============================================================
\r
4088 // work around function start with wa_halbtc8703b2ant_
\r
4089 //============================================================
\r
4090 //============================================================
\r
4091 // extern function start with EXhalbtc8703b2ant_
\r
4092 //============================================================
\r
4094 EXhalbtc8703b2ant_PowerOnSetting(
\r
4095 IN PBTC_COEXIST pBtCoexist
\r
4098 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
4101 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20);
\r
4103 // enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly.
\r
4104 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
\r
4105 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1);
\r
4107 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
\r
4109 if(pBtCoexist->chipInterface == BTC_INTF_USB)
\r
4111 // fixed at S0 for USB interface
\r
4112 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
\r
4116 // for PCIE and SDIO interface, we check efuse 0xc3[6]
\r
4117 if(pBoardInfo->singleAntPath == 0)
\r
4120 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
\r
4122 else if(pBoardInfo->singleAntPath == 1)
\r
4125 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
\r
4131 EXhalbtc8703b2ant_PreLoadFirmware(
\r
4132 IN PBTC_COEXIST pBtCoexist
\r
4135 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
4136 u1Byte u1Tmp=0x4; /* Set BIT2 by default since it's 2ant case */
\r
4139 // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info)
\r
4140 // Local setting bit define
\r
4141 // BIT0: "0" for no antenna inverse; "1" for antenna inverse
\r
4142 // BIT1: "0" for internal switch; "1" for external switch
\r
4143 // BIT2: "0" for one antenna; "1" for two antenna
\r
4144 // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0
\r
4145 if(pBtCoexist->chipInterface == BTC_INTF_USB)
\r
4147 // fixed at S0 for USB interface
\r
4148 u1Tmp |= 0x1; // antenna inverse
\r
4149 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);
\r
4153 // for PCIE and SDIO interface, we check efuse 0xc3[6]
\r
4154 if(pBoardInfo->singleAntPath == 0)
\r
4157 else if(pBoardInfo->singleAntPath == 1)
\r
4160 u1Tmp |= 0x1; // antenna inverse
\r
4163 if(pBtCoexist->chipInterface == BTC_INTF_PCI)
\r
4165 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp);
\r
4167 else if(pBtCoexist->chipInterface == BTC_INTF_SDIO)
\r
4169 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp);
\r
4175 EXhalbtc8703b2ant_InitHwConfig(
\r
4176 IN PBTC_COEXIST pBtCoexist,
\r
4177 IN BOOLEAN bWifiOnly
\r
4180 halbtc8703b2ant_InitHwConfig(pBtCoexist, TRUE);
\r
4184 EXhalbtc8703b2ant_InitCoexDm(
\r
4185 IN PBTC_COEXIST pBtCoexist
\r
4188 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
4190 halbtc8703b2ant_InitCoexDm(pBtCoexist);
\r
4194 EXhalbtc8703b2ant_DisplayCoexInfo(
\r
4195 IN PBTC_COEXIST pBtCoexist
\r
4198 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
4199 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
4200 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
4201 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
4202 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
4204 u4Byte faOfdm, faCck;
\r
4205 u4Byte fwVer=0, btPatchVer=0;
\r
4207 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
4208 CL_PRINTF(cliBuf);
\r
4210 if(pBtCoexist->bManualControl)
\r
4212 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
\r
4213 CL_PRINTF(cliBuf);
\r
4214 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
\r
4215 CL_PRINTF(cliBuf);
\r
4218 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
\r
4219 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
\r
4220 CL_PRINTF(cliBuf);
\r
4222 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
4223 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
4224 CL_PRINTF(cliBuf);
\r
4226 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
4227 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
4228 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
\r
4229 GLCoexVerDate8703b2Ant, GLCoexVer8703b2Ant, fwVer, btPatchVer, btPatchVer);
\r
4230 CL_PRINTF(cliBuf);
\r
4232 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \
\r
4233 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
\r
4234 pCoexDm->wifiChnlInfo[2]);
\r
4235 CL_PRINTF(cliBuf);
\r
4238 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
\r
4239 CL_PRINTF(cliBuf);
\r
4240 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
\r
4242 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
\r
4243 CL_PRINTF(cliBuf);
\r
4245 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %ddBm/ %d] ", "BT [status/ rssi/ retryCnt]", \
\r
4246 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8703B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
\r
4247 ( (BT_8703B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
\r
4248 pCoexSta->btRssi-100, pCoexSta->btRetryCnt);
\r
4249 CL_PRINTF(cliBuf);
\r
4251 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
4252 pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);
\r
4253 CL_PRINTF(cliBuf);
\r
4255 if (pStackInfo->bProfileNotified)
\r
4257 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
4261 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \
\r
4262 (pBtLinkInfo->bSlaveRole )? "Slave":"Master");
\r
4263 CL_PRINTF(cliBuf);
\r
4266 btInfoExt = pCoexSta->btInfoExt;
\r
4267 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
\r
4268 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
\r
4269 CL_PRINTF(cliBuf);
\r
4271 for(i=0; i<BT_INFO_SRC_8703B_2ANT_MAX; i++)
\r
4273 if(pCoexSta->btInfoC2hCnt[i])
\r
4275 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8703b2Ant[i], \
\r
4276 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
\r
4277 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
\r
4278 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
\r
4279 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
\r
4280 CL_PRINTF(cliBuf);
\r
4285 if(pBtCoexist->bManualControl)
\r
4287 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism] (before Manual)============");
\r
4291 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
4294 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \
\r
4295 pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig);
\r
4296 CL_PRINTF(cliBuf);
\r
4297 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
\r
4298 pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
\r
4299 CL_PRINTF(cliBuf);
\r
4302 if(pBtCoexist->bManualControl)
\r
4304 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism] (before Manual) ============");
\r
4308 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
4311 psTdmaCase = pCoexDm->curPsTdma;
\r
4313 if (pCoexDm->bIsSwitchTo1dot5Ant)
\r
4314 psTdmaCase = psTdmaCase + 100;
\r
4316 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (%s,%s)", "PS TDMA", \
\r
4317 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
\r
4318 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
\r
4319 pCoexDm->psTdmaPara[4], psTdmaCase,
\r
4320 (pCoexDm->bCurPsTdmaOn? "On":"Off"),
\r
4321 (pCoexDm->bAutoTdmaAdjust? "Adj":"Fix") );
\r
4322 CL_PRINTF(cliBuf);
\r
4324 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", \
\r
4325 pCoexSta->nCoexTableType);
\r
4326 CL_PRINTF(cliBuf);
\r
4328 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
\r
4329 pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct);
\r
4330 CL_PRINTF(cliBuf);
\r
4333 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
4334 CL_PRINTF(cliBuf);
\r
4336 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
\r
4337 pCoexDm->btRf0x1eBackup);
\r
4338 CL_PRINTF(cliBuf);
\r
4340 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
\r
4341 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
\r
4342 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \
\r
4343 u1Tmp[0], (u4Tmp[0]&0x3e000000) >> 25);
\r
4344 CL_PRINTF(cliBuf);
\r
4347 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
\r
4348 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
\r
4349 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
\r
4350 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \
\r
4351 u4Tmp[0], ((u1Tmp[0]&0x20)>> 5), u1Tmp[1]);
\r
4352 CL_PRINTF(cliBuf);
\r
4354 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c);
\r
4355 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
\r
4356 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944);
\r
4357 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \
\r
4358 u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3);
\r
4359 CL_PRINTF(cliBuf);
\r
4362 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39);
\r
4363 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
4364 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
\r
4365 u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64);
\r
4366 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \
\r
4367 ((u1Tmp[0] & 0x8)>>3), u1Tmp[1], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[2]&0x1);
\r
4368 CL_PRINTF(cliBuf);
\r
4370 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
\r
4371 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
\r
4372 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
\r
4373 u4Tmp[0], u1Tmp[0]);
\r
4374 CL_PRINTF(cliBuf);
\r
4376 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
4377 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c);
\r
4378 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
\r
4379 u4Tmp[0]&0xff, u1Tmp[0]);
\r
4380 CL_PRINTF(cliBuf);
\r
4382 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
\r
4383 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
\r
4384 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
\r
4385 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0);
\r
4387 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b);
\r
4388 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
\r
4390 faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \
\r
4391 ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ;
\r
4392 faCck = (u1Tmp[0] << 8) + u1Tmp[1];
\r
4394 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
\r
4395 u4Tmp[0]&0xffff, faOfdm, faCck);
\r
4396 CL_PRINTF(cliBuf);
\r
4398 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \
\r
4399 pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg);
\r
4400 CL_PRINTF(cliBuf);
\r
4402 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \
\r
4403 pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg);
\r
4404 CL_PRINTF(cliBuf);
\r
4406 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
\r
4407 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
4408 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
4409 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
\r
4410 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
\r
4411 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
\r
4412 CL_PRINTF(cliBuf);
\r
4414 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \
\r
4415 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
\r
4416 CL_PRINTF(cliBuf);
\r
4417 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \
\r
4418 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
\r
4419 CL_PRINTF(cliBuf);
\r
4420 #if(BT_AUTO_REPORT_ONLY_8703B_2ANT == 1)
\r
4421 //halbtc8703b2ant_MonitorBtCtr(pBtCoexist);
\r
4423 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
4428 EXhalbtc8703b2ant_IpsNotify(
\r
4429 IN PBTC_COEXIST pBtCoexist,
\r
4433 if(BTC_IPS_ENTER == type)
\r
4435 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n"));
\r
4436 pCoexSta->bUnderIps = TRUE;
\r
4437 halbtc8703b2ant_WifiOffHwCfg(pBtCoexist);
\r
4438 halbtc8703b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
4439 halbtc8703b2ant_CoexAllOff(pBtCoexist);
\r
4441 else if(BTC_IPS_LEAVE == type)
\r
4443 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n"));
\r
4444 pCoexSta->bUnderIps = FALSE;
\r
4445 halbtc8703b2ant_InitHwConfig(pBtCoexist, FALSE);
\r
4446 halbtc8703b2ant_InitCoexDm(pBtCoexist);
\r
4447 halbtc8703b2ant_QueryBtInfo(pBtCoexist);
\r
4452 EXhalbtc8703b2ant_LpsNotify(
\r
4453 IN PBTC_COEXIST pBtCoexist,
\r
4457 if(BTC_LPS_ENABLE == type)
\r
4459 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n"));
\r
4460 pCoexSta->bUnderLps = TRUE;
\r
4462 else if(BTC_LPS_DISABLE == type)
\r
4464 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n"));
\r
4465 pCoexSta->bUnderLps = FALSE;
\r
4470 EXhalbtc8703b2ant_ScanNotify(
\r
4471 IN PBTC_COEXIST pBtCoexist,
\r
4476 u1Byte u1Tmpa, u1Tmpb;
\r
4480 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
\r
4481 u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
\r
4482 u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);
\r
4484 if(BTC_SCAN_START == type)
\r
4486 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));
\r
4488 else if(BTC_SCAN_FINISH == type)
\r
4490 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));
\r
4493 RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x76e=0x%x\n",
\r
4494 u4Tmp, u1Tmpa, u1Tmpb));
\r
4498 EXhalbtc8703b2ant_ConnectNotify(
\r
4499 IN PBTC_COEXIST pBtCoexist,
\r
4503 if(BTC_ASSOCIATE_START == type)
\r
4505 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));
\r
4507 else if(BTC_ASSOCIATE_FINISH == type)
\r
4509 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));
\r
4514 EXhalbtc8703b2ant_MediaStatusNotify(
\r
4515 IN PBTC_COEXIST pBtCoexist,
\r
4519 u1Byte H2C_Parameter[3] ={0};
\r
4521 u1Byte wifiCentralChnl;
\r
4524 if(BTC_MEDIA_CONNECT == type)
\r
4526 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n"));
\r
4530 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n"));
\r
4533 // only 2.4G we need to inform bt the chnl mask
\r
4534 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
\r
4535 if( (BTC_MEDIA_CONNECT == type) &&
\r
4536 (wifiCentralChnl <= 14) )
\r
4538 H2C_Parameter[0] = 0x1;
\r
4539 H2C_Parameter[1] = wifiCentralChnl;
\r
4540 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
4541 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
4542 H2C_Parameter[2] = 0x30;
\r
4545 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
\r
4547 H2C_Parameter[2] = 0x30;
\r
4549 H2C_Parameter[2] = 0x20;
\r
4553 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
\r
4554 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
\r
4555 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
\r
4557 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n",
\r
4558 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
\r
4560 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
\r
4564 EXhalbtc8703b2ant_SpecialPacketNotify(
\r
4565 IN PBTC_COEXIST pBtCoexist,
\r
4569 if(type == BTC_PACKET_DHCP)
\r
4571 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n"));
\r
4576 EXhalbtc8703b2ant_BtInfoNotify(
\r
4577 IN PBTC_COEXIST pBtCoexist,
\r
4578 IN pu1Byte tmpBuf,
\r
4582 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
\r
4584 u1Byte i, rspSource=0;
\r
4585 BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE;
\r
4586 BOOLEAN bWifiConnected=FALSE;
\r
4587 static BOOLEAN bPreScoExist=FALSE;
\r
4588 u4Byte raMask=0x0;
\r
4590 pCoexSta->bC2hBtInfoReqSent = FALSE;
\r
4592 rspSource = tmpBuf[0]&0xf;
\r
4593 if(rspSource >= BT_INFO_SRC_8703B_2ANT_MAX)
\r
4594 rspSource = BT_INFO_SRC_8703B_2ANT_WIFI_FW;
\r
4595 pCoexSta->btInfoC2hCnt[rspSource]++;
\r
4597 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
\r
4598 for(i=0; i<length; i++)
\r
4600 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
\r
4602 btInfo = tmpBuf[i];
\r
4605 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i]));
\r
4609 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i]));
\r
4613 if(pBtCoexist->bManualControl)
\r
4615 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
\r
4619 // if 0xff, it means BT is under WHCK test
\r
4620 if (btInfo == 0xff)
\r
4621 pCoexSta->bBtWhckTest = TRUE;
\r
4623 pCoexSta->bBtWhckTest = FALSE;
\r
4625 if(BT_INFO_SRC_8703B_2ANT_WIFI_FW != rspSource)
\r
4627 pCoexSta->btRetryCnt = // [3:0]
\r
4628 pCoexSta->btInfoC2h[rspSource][2]&0xf;
\r
4630 pCoexSta->btRssi =
\r
4631 pCoexSta->btInfoC2h[rspSource][3]*2+10;
\r
4633 pCoexSta->btInfoExt =
\r
4634 pCoexSta->btInfoC2h[rspSource][4];
\r
4636 pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
\r
4637 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
\r
4638 if (pCoexSta->bBtTxRxMask)
\r
4640 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */
\r
4641 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n"));
\r
4642 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01);
\r
4645 // Here we need to resend some wifi info to BT
\r
4646 // because bt is reset and loss of the info.
\r
4647 if( (pCoexSta->btInfoExt & BIT1) )
\r
4649 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
\r
4650 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
4651 if(bWifiConnected)
\r
4653 EXhalbtc8703b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
\r
4657 EXhalbtc8703b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
4661 if( (pCoexSta->btInfoExt & BIT3) )
\r
4663 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
\r
4664 halbtc8703b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
4668 // BT already NOT ignore Wlan active, do nothing here.
\r
4670 #if(BT_AUTO_REPORT_ONLY_8703B_2ANT == 0)
\r
4671 if( (pCoexSta->btInfoExt & BIT4) )
\r
4673 // BT auto report already enabled, do nothing
\r
4677 halbtc8703b2ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);
\r
4682 // check BIT2 first ==> check if bt is under inquiry or page scan
\r
4683 if(btInfo & BT_INFO_8703B_2ANT_B_INQ_PAGE)
\r
4684 pCoexSta->bC2hBtInquiryPage = TRUE;
\r
4686 pCoexSta->bC2hBtInquiryPage = FALSE;
\r
4688 // set link exist status
\r
4689 if(!(btInfo&BT_INFO_8703B_2ANT_B_CONNECTION))
\r
4691 pCoexSta->bBtLinkExist = FALSE;
\r
4692 pCoexSta->bPanExist = FALSE;
\r
4693 pCoexSta->bA2dpExist = FALSE;
\r
4694 pCoexSta->bHidExist = FALSE;
\r
4695 pCoexSta->bScoExist = FALSE;
\r
4697 else // connection exists
\r
4699 pCoexSta->bBtLinkExist = TRUE;
\r
4700 if(btInfo & BT_INFO_8703B_2ANT_B_FTP)
\r
4701 pCoexSta->bPanExist = TRUE;
\r
4703 pCoexSta->bPanExist = FALSE;
\r
4704 if(btInfo & BT_INFO_8703B_2ANT_B_A2DP)
\r
4705 pCoexSta->bA2dpExist = TRUE;
\r
4707 pCoexSta->bA2dpExist = FALSE;
\r
4708 if(btInfo & BT_INFO_8703B_2ANT_B_HID)
\r
4709 pCoexSta->bHidExist = TRUE;
\r
4711 pCoexSta->bHidExist = FALSE;
\r
4712 if(btInfo & BT_INFO_8703B_2ANT_B_SCO_ESCO)
\r
4713 pCoexSta->bScoExist = TRUE;
\r
4715 pCoexSta->bScoExist = FALSE;
\r
4717 if ( (pCoexSta->bHidExist == FALSE) && (pCoexSta->bC2hBtInquiryPage == FALSE) && (pCoexSta->bScoExist == FALSE))
\r
4719 if (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160)
\r
4721 pCoexSta->bHidExist = TRUE;
\r
4722 btInfo = btInfo | 0x20;
\r
4727 halbtc8703b2ant_UpdateBtLinkInfo(pBtCoexist);
\r
4729 if(!(btInfo&BT_INFO_8703B_2ANT_B_CONNECTION))
\r
4731 pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
\r
4732 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
\r
4734 else if(btInfo == BT_INFO_8703B_2ANT_B_CONNECTION) // connection exists but no busy
\r
4736 pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_CONNECTED_IDLE;
\r
4737 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
\r
4739 else if((btInfo&BT_INFO_8703B_2ANT_B_SCO_ESCO) ||
\r
4740 (btInfo&BT_INFO_8703B_2ANT_B_SCO_BUSY))
\r
4742 pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_SCO_BUSY;
\r
4743 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
\r
4745 else if(btInfo&BT_INFO_8703B_2ANT_B_ACL_BUSY)
\r
4747 pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_ACL_BUSY;
\r
4748 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
\r
4752 pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_MAX;
\r
4753 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
\r
4756 if( (BT_8703B_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
\r
4757 (BT_8703B_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
\r
4758 (BT_8703B_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
\r
4761 bLimitedDig = TRUE;
\r
4766 bLimitedDig = FALSE;
\r
4769 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
4771 pCoexDm->bLimitedDig = bLimitedDig;
\r
4772 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig);
\r
4774 halbtc8703b2ant_RunCoexistMechanism(pBtCoexist);
\r
4778 EXhalbtc8703b2ant_HaltNotify(
\r
4779 IN PBTC_COEXIST pBtCoexist
\r
4782 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n"));
\r
4784 halbtc8703b2ant_WifiOffHwCfg(pBtCoexist);
\r
4785 //remove due to interrupt is disabled that polling c2h will fail and delay 100ms.
\r
4786 //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0
\r
4787 halbtc8703b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
4789 EXhalbtc8703b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
4793 EXhalbtc8703b2ant_PnpNotify(
\r
4794 IN PBTC_COEXIST pBtCoexist,
\r
4795 IN u1Byte pnpState
\r
4798 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n"));
\r
4800 if(BTC_WIFI_PNP_SLEEP == pnpState)
\r
4802 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n"));
\r
4804 else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
\r
4806 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n"));
\r
4807 halbtc8703b2ant_InitHwConfig(pBtCoexist, FALSE);
\r
4808 halbtc8703b2ant_InitCoexDm(pBtCoexist);
\r
4809 halbtc8703b2ant_QueryBtInfo(pBtCoexist);
\r
4814 EXhalbtc8703b2ant_Periodical(
\r
4815 IN PBTC_COEXIST pBtCoexist
\r
4818 //static u1Byte disVerInfoCnt=0;
\r
4819 u4Byte fwVer=0, btPatchVer=0;
\r
4820 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
4821 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
4823 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n"));
\r
4825 if(pCoexSta->disVerInfoCnt <= 5)
\r
4827 pCoexSta->disVerInfoCnt += 1;
\r
4828 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));
\r
4829 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n",
\r
4830 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));
\r
4831 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n",
\r
4832 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
\r
4833 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
\r
4834 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
4835 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",
\r
4836 GLCoexVerDate8703b2Ant, GLCoexVer8703b2Ant, fwVer, btPatchVer, btPatchVer));
\r
4837 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));
\r
4839 if (pCoexSta->disVerInfoCnt == 3)
\r
4841 //Antenna config to set 0x765 = 0x0 (GNT_BT control by PTA) after initial
\r
4842 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set GNT_BT control by PTA\n"));
\r
4843 halbtc8703b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, FALSE, FALSE);
\r
4847 #if(BT_AUTO_REPORT_ONLY_8703B_2ANT == 0)
\r
4848 halbtc8703b2ant_QueryBtInfo(pBtCoexist);
\r
4849 halbtc8703b2ant_MonitorBtEnableDisable(pBtCoexist);
\r
4851 halbtc8703b2ant_MonitorBtCtr(pBtCoexist);
\r
4852 halbtc8703b2ant_MonitorWiFiCtr(pBtCoexist);
\r
4854 if( halbtc8703b2ant_IsWifiStatusChanged(pBtCoexist) ||
\r
4855 pCoexDm->bAutoTdmaAdjust)
\r
4857 halbtc8703b2ant_RunCoexistMechanism(pBtCoexist);
\r