1 //============================================================
\r
4 // This file is for RTL8723A Co-exist mechanism
\r
7 // 2012/08/22 Cosa first check in.
\r
8 // 2012/11/14 Cosa Revise for 8723A 1Ant out sourcing.
\r
10 //============================================================
\r
12 //============================================================
\r
14 //============================================================
\r
15 #include "Mp_Precomp.h"
\r
17 #if WPP_SOFTWARE_TRACE
\r
18 #include "HalBtc8723a1Ant.tmh"
\r
21 #if(BT_30_SUPPORT == 1)
\r
22 //============================================================
\r
23 // Global variables, these are static variables
\r
24 //============================================================
\r
25 static COEX_DM_8723A_1ANT GLCoexDm8723a1Ant;
\r
26 static PCOEX_DM_8723A_1ANT pCoexDm=&GLCoexDm8723a1Ant;
\r
27 static COEX_STA_8723A_1ANT GLCoexSta8723a1Ant;
\r
28 static PCOEX_STA_8723A_1ANT pCoexSta=&GLCoexSta8723a1Ant;
\r
30 const char *const GLBtInfoSrc8723a1Ant[]={
\r
33 "BT Info[bt auto report]",
\r
36 //============================================================
\r
37 // local function proto type if needed
\r
38 //============================================================
\r
39 //============================================================
\r
40 // local function start with halbtc8723a1ant_
\r
41 //============================================================
\r
43 halbtc8723a1ant_Reg0x550Bit3(
\r
44 IN PBTC_COEXIST pBtCoexist,
\r
50 u1tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x550);
\r
59 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x550, u1tmp);
\r
60 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set 0x550[3]=%d\n", (bSet? 1:0)));
\r
64 halbtc8723a1ant_NotifyFwScan(
\r
65 IN PBTC_COEXIST pBtCoexist,
\r
69 u1Byte H2C_Parameter[1] ={0};
\r
71 if(BTC_SCAN_START == scanType)
\r
72 H2C_Parameter[0] = 0x1;
\r
74 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Notify FW for wifi scan, write 0x3b=0x%x\n",
\r
77 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x3b, 1, H2C_Parameter);
\r
81 halbtc8723a1ant_QueryBtInfo(
\r
82 IN PBTC_COEXIST pBtCoexist
\r
85 u1Byte H2C_Parameter[1] ={0};
\r
87 pCoexSta->bC2hBtInfoReqSent = TRUE;
\r
89 H2C_Parameter[0] |= BIT0; // trigger
\r
91 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x38=0x%x\n",
\r
94 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x38, 1, H2C_Parameter);
\r
98 halbtc8723a1ant_SetSwRfRxLpfCorner(
\r
99 IN PBTC_COEXIST pBtCoexist,
\r
100 IN BOOLEAN bRxRfShrinkOn
\r
105 //Shrink RF Rx LPF corner
\r
106 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
\r
107 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7);
\r
111 //Resume RF Rx LPF corner
\r
112 // After initialized, we can use pCoexDm->btRf0x1eBackup
\r
113 if(pBtCoexist->bInitilized)
\r
115 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
\r
116 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
\r
122 halbtc8723a1ant_RfShrink(
\r
123 IN PBTC_COEXIST pBtCoexist,
\r
124 IN BOOLEAN bForceExec,
\r
125 IN BOOLEAN bRxRfShrinkOn
\r
128 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
\r
129 (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
\r
130 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
\r
134 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
\r
137 halbtc8723a1ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
\r
139 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
\r
143 halbtc8723a1ant_SetSwPenaltyTxRateAdaptive(
\r
144 IN PBTC_COEXIST pBtCoexist,
\r
145 IN BOOLEAN bLowPenaltyRa
\r
150 tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd);
\r
154 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
\r
159 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
\r
163 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1);
\r
167 halbtc8723a1ant_LowPenaltyRa(
\r
168 IN PBTC_COEXIST pBtCoexist,
\r
169 IN BOOLEAN bForceExec,
\r
170 IN BOOLEAN bLowPenaltyRa
\r
174 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
\r
175 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
\r
176 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
180 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
183 halbtc8723a1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
185 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
189 halbtc8723a1ant_SetCoexTable(
\r
190 IN PBTC_COEXIST pBtCoexist,
\r
191 IN u4Byte val0x6c0,
\r
192 IN u4Byte val0x6c8,
\r
196 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
\r
197 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
\r
199 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
200 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
202 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
203 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
207 halbtc8723a1ant_CoexTable(
\r
208 IN PBTC_COEXIST pBtCoexist,
\r
209 IN BOOLEAN bForceExec,
\r
210 IN u4Byte val0x6c0,
\r
211 IN u4Byte val0x6c8,
\r
215 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
\r
216 (bForceExec? "force to":""), val0x6c0, val0x6c8, val0x6cc));
\r
217 pCoexDm->curVal0x6c0 = val0x6c0;
\r
218 pCoexDm->curVal0x6c8 = val0x6c8;
\r
219 pCoexDm->curVal0x6cc = val0x6cc;
\r
223 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
\r
224 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
225 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
228 halbtc8723a1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c8, val0x6cc);
\r
230 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
\r
231 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
232 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
236 halbtc8723a1ant_SetFwIgnoreWlanAct(
\r
237 IN PBTC_COEXIST pBtCoexist,
\r
241 u1Byte H2C_Parameter[1] ={0};
\r
245 H2C_Parameter[0] |= BIT0; // function enable
\r
248 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x25=0x%x\n",
\r
249 H2C_Parameter[0]));
\r
251 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x25, 1, H2C_Parameter);
\r
255 halbtc8723a1ant_IgnoreWlanAct(
\r
256 IN PBTC_COEXIST pBtCoexist,
\r
257 IN BOOLEAN bForceExec,
\r
261 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n",
\r
262 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
\r
263 pCoexDm->bCurIgnoreWlanAct = bEnable;
\r
267 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
\r
270 halbtc8723a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
\r
272 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
\r
276 halbtc8723a1ant_SetFwPstdma(
\r
277 IN PBTC_COEXIST pBtCoexist,
\r
286 u1Byte H2C_Parameter[5] ={0};
\r
287 u1Byte realByte1=byte1, realByte5=byte5;
\r
288 BOOLEAN bApEnable=FALSE;
\r
290 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
292 // byte1[1:0] != 0 means enable pstdma
\r
293 // for 2Ant bt coexist, if byte1 != 0 means enable pstdma
\r
298 if(type != 5 && type != 12)
\r
300 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n"));
\r
301 realByte1 &= ~BIT4;
\r
305 realByte5 &= ~BIT6;
\r
309 H2C_Parameter[0] = realByte1;
\r
310 H2C_Parameter[1] = byte2;
\r
311 H2C_Parameter[2] = byte3;
\r
312 H2C_Parameter[3] = byte4;
\r
313 H2C_Parameter[4] = realByte5;
\r
315 pCoexDm->psTdmaPara[0] = realByte1;
\r
316 pCoexDm->psTdmaPara[1] = byte2;
\r
317 pCoexDm->psTdmaPara[2] = byte3;
\r
318 pCoexDm->psTdmaPara[3] = byte4;
\r
319 pCoexDm->psTdmaPara[4] = realByte5;
\r
321 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x3a(5bytes)=0x%x%08x\n",
\r
323 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
\r
325 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x3a, 5, H2C_Parameter);
\r
329 halbtc8723a1ant_PsTdma(
\r
330 IN PBTC_COEXIST pBtCoexist,
\r
331 IN BOOLEAN bForceExec,
\r
332 IN BOOLEAN bTurnOn,
\r
336 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
\r
337 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
\r
338 pCoexDm->bCurPsTdmaOn = bTurnOn;
\r
339 pCoexDm->curPsTdma = type;
\r
343 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
\r
344 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
\r
347 if(pCoexDm->bCurPsTdmaOn)
\r
349 switch(pCoexDm->curPsTdma)
\r
353 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x1a, 0x1a, 0x0, 0x40);
\r
356 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x12, 0x12, 0x0, 0x40);
\r
359 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x3f, 0x3, 0x10, 0x40);
\r
362 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x15, 0x3, 0x10, 0x0);
\r
365 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0xa9, 0x15, 0x3, 0x35, 0xc0);
\r
369 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
372 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x0, 0x40);
\r
375 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x0, 0x40);
\r
378 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x0, 0x40);
\r
381 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0xa9, 0xa, 0x3, 0x15, 0xc0);
\r
385 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
389 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x2a, 0x2a, 0x0, 0x0);
\r
392 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x20, 0x3, 0x10, 0x40);
\r
395 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x1a, 0x1a, 0x2, 0x40);
\r
398 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x12, 0x12, 0x2, 0x40);
\r
401 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x2, 0x40);
\r
404 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x2, 0x40);
\r
407 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
410 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x2, 0x40);
\r
413 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x3, 0x2f, 0x2f, 0x0, 0x0);
\r
421 switch(pCoexDm->curPsTdma)
\r
424 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x8, 0x0, 0x0, 0x0, 0x0);
\r
428 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
429 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x210);
\r
432 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
433 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x110);
\r
439 // update pre state
\r
440 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
\r
441 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
\r
446 halbtc8723a1ant_CoexAllOff(
\r
447 IN PBTC_COEXIST pBtCoexist
\r
451 halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
\r
452 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
455 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
\r
456 halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r
459 halbtc8723a1ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
\r
463 halbtc8723a1ant_InitCoexDm(
\r
464 IN PBTC_COEXIST pBtCoexist
\r
467 // force to reset coex mechanism
\r
468 halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
472 halbtc8723a1ant_BtEnableAction(
\r
473 IN PBTC_COEXIST pBtCoexist
\r
476 halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
480 halbtc8723a1ant_MonitorBtCtr(
\r
481 IN PBTC_COEXIST pBtCoexist
\r
484 u4Byte regHPTxRx, regLPTxRx, u4Tmp;
\r
485 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
\r
491 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
\r
492 regHPTx = u4Tmp & bMaskLWord;
\r
493 regHPRx = (u4Tmp & bMaskHWord)>>16;
\r
495 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
\r
496 regLPTx = u4Tmp & bMaskLWord;
\r
497 regLPRx = (u4Tmp & bMaskHWord)>>16;
\r
499 pCoexSta->highPriorityTx = regHPTx;
\r
500 pCoexSta->highPriorityRx = regHPRx;
\r
501 pCoexSta->lowPriorityTx = regLPTx;
\r
502 pCoexSta->lowPriorityRx = regLPRx;
\r
504 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
505 regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
\r
506 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
507 regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
\r
510 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
514 halbtc8723a1ant_MonitorBtEnableDisable(
\r
515 IN PBTC_COEXIST pBtCoexist
\r
518 static BOOLEAN bPreBtDisabled=FALSE;
\r
519 static u4Byte btDisableCnt=0;
\r
520 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
\r
522 // This function check if bt is disabled
\r
524 if( pCoexSta->highPriorityTx == 0 &&
\r
525 pCoexSta->highPriorityRx == 0 &&
\r
526 pCoexSta->lowPriorityTx == 0 &&
\r
527 pCoexSta->lowPriorityRx == 0)
\r
531 if( pCoexSta->highPriorityTx == 0xffff &&
\r
532 pCoexSta->highPriorityRx == 0xffff &&
\r
533 pCoexSta->lowPriorityTx == 0xffff &&
\r
534 pCoexSta->lowPriorityRx == 0xffff)
\r
541 bBtDisabled = FALSE;
\r
542 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
543 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n"));
\r
548 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n",
\r
550 if(btDisableCnt >= 2)
\r
552 bBtDisabled = TRUE;
\r
553 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
554 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n"));
\r
557 if(bPreBtDisabled != bBtDisabled)
\r
559 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n",
\r
560 (bPreBtDisabled ? "disabled":"enabled"),
\r
561 (bBtDisabled ? "disabled":"enabled")));
\r
562 bPreBtDisabled = bBtDisabled;
\r
565 halbtc8723a1ant_BtEnableAction(pBtCoexist);
\r
569 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
575 halbtc8723a1ant_TdmaDurationAdjust(
\r
576 IN PBTC_COEXIST pBtCoexist
\r
579 static s4Byte up,dn,m,n,WaitCount;
\r
580 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
\r
581 u1Byte retryCount=0;
\r
583 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
586 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
587 btState = pCoexDm->btStatus;
\r
589 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], TdmaDurationAdjust()\n"));
\r
590 if(pCoexDm->psTdmaGlobalCnt != pCoexDm->psTdmaMonitorCnt)
\r
592 pCoexDm->psTdmaMonitorCnt = 0;
\r
593 pCoexDm->psTdmaGlobalCnt = 0;
\r
595 if(pCoexDm->psTdmaMonitorCnt == 0)
\r
597 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], first run BT A2DP + WiFi busy state!!\n"));
\r
598 if(btState == BT_STATE_8723A_1ANT_ACL_ONLY_BUSY)
\r
600 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
601 pCoexDm->psTdmaDuAdjType = 1;
\r
605 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
606 pCoexDm->psTdmaDuAdjType = 22;
\r
618 //accquire the BT TRx retry count from BT_Info byte2
\r
619 retryCount = pCoexSta->btRetryCnt;
\r
620 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], retryCount = %d\n", retryCount));
\r
624 if(retryCount == 0) // no retry in the last 2-second duration
\r
632 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
\r
639 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Increase wifi duration!!\n"));
\r
642 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
\r
650 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
\r
652 if (WaitCount <= 2)
\r
653 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
657 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
665 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
\r
668 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
\r
670 if (WaitCount == 1)
\r
671 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
675 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
683 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
\r
687 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT TxRx counter H+L <= 1200\n"));
\r
688 if(btState != BT_STATE_8723A_1ANT_ACL_ONLY_BUSY)
\r
690 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], NOT ACL only busy!\n"));
\r
691 if(BTC_WIFI_BW_HT40 != wifiBw)
\r
693 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 20MHz\n"));
\r
696 if(pCoexDm->curPsTdma == 22)
\r
698 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
699 pCoexDm->psTdmaDuAdjType = 23;
\r
701 else if(pCoexDm->curPsTdma == 23)
\r
703 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
704 pCoexDm->psTdmaDuAdjType = 24;
\r
706 else if(pCoexDm->curPsTdma == 24)
\r
708 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 25);
\r
709 pCoexDm->psTdmaDuAdjType = 25;
\r
712 else if (result == 1)
\r
714 if(pCoexDm->curPsTdma == 25)
\r
716 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
717 pCoexDm->psTdmaDuAdjType = 24;
\r
719 else if(pCoexDm->curPsTdma == 24)
\r
721 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
722 pCoexDm->psTdmaDuAdjType = 23;
\r
724 else if(pCoexDm->curPsTdma == 23)
\r
726 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
727 pCoexDm->psTdmaDuAdjType = 22;
\r
730 // error handle, if not in the following state,
\r
731 // set psTdma again.
\r
732 if( (pCoexDm->psTdmaDuAdjType != 22) &&
\r
733 (pCoexDm->psTdmaDuAdjType != 23) &&
\r
734 (pCoexDm->psTdmaDuAdjType != 24) &&
\r
735 (pCoexDm->psTdmaDuAdjType != 25) )
\r
737 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], duration case out of handle!!\n"));
\r
738 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
739 pCoexDm->psTdmaDuAdjType = 23;
\r
744 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 40MHz\n"));
\r
747 if(pCoexDm->curPsTdma == 23)
\r
749 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
750 pCoexDm->psTdmaDuAdjType = 24;
\r
752 else if(pCoexDm->curPsTdma == 24)
\r
754 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 25);
\r
755 pCoexDm->psTdmaDuAdjType = 25;
\r
757 else if(pCoexDm->curPsTdma == 25)
\r
759 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 27);
\r
760 pCoexDm->psTdmaDuAdjType = 27;
\r
763 else if (result == 1)
\r
765 if(pCoexDm->curPsTdma == 27)
\r
767 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 25);
\r
768 pCoexDm->psTdmaDuAdjType = 25;
\r
770 else if(pCoexDm->curPsTdma == 25)
\r
772 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
773 pCoexDm->psTdmaDuAdjType = 24;
\r
775 else if(pCoexDm->curPsTdma == 24)
\r
777 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
778 pCoexDm->psTdmaDuAdjType = 23;
\r
781 // error handle, if not in the following state,
\r
782 // set psTdma again.
\r
783 if( (pCoexDm->psTdmaDuAdjType != 23) &&
\r
784 (pCoexDm->psTdmaDuAdjType != 24) &&
\r
785 (pCoexDm->psTdmaDuAdjType != 25) &&
\r
786 (pCoexDm->psTdmaDuAdjType != 27) )
\r
788 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], duration case out of handle!!\n"));
\r
789 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
790 pCoexDm->psTdmaDuAdjType = 24;
\r
796 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ACL only busy\n"));
\r
799 if(pCoexDm->curPsTdma == 1)
\r
801 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
802 pCoexDm->psTdmaDuAdjType = 2;
\r
804 else if(pCoexDm->curPsTdma == 2)
\r
806 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
807 pCoexDm->psTdmaDuAdjType = 9;
\r
809 else if(pCoexDm->curPsTdma == 9)
\r
811 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
812 pCoexDm->psTdmaDuAdjType = 11;
\r
815 else if (result == 1)
\r
817 if(pCoexDm->curPsTdma == 11)
\r
819 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
820 pCoexDm->psTdmaDuAdjType = 9;
\r
822 else if(pCoexDm->curPsTdma == 9)
\r
824 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
825 pCoexDm->psTdmaDuAdjType = 2;
\r
827 else if(pCoexDm->curPsTdma == 2)
\r
829 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
830 pCoexDm->psTdmaDuAdjType = 1;
\r
834 // error handle, if not in the following state,
\r
835 // set psTdma again.
\r
836 if( (pCoexDm->psTdmaDuAdjType != 1) &&
\r
837 (pCoexDm->psTdmaDuAdjType != 2) &&
\r
838 (pCoexDm->psTdmaDuAdjType != 9) &&
\r
839 (pCoexDm->psTdmaDuAdjType != 11) )
\r
841 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], duration case out of handle!!\n"));
\r
842 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
843 pCoexDm->psTdmaDuAdjType = 2;
\r
849 // if current PsTdma not match with the recorded one (when scan, dhcp...),
\r
850 // then we have to adjust it back to the previous record one.
\r
851 if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)
\r
853 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n",
\r
854 pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));
\r
856 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
857 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
858 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
860 if( !bScan && !bLink && !bRoam)
\r
862 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
\r
866 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
\r
869 pCoexDm->psTdmaMonitorCnt++;
\r
874 halbtc8723a1ant_CoexForWifiConnect(
\r
875 IN PBTC_COEXIST pBtCoexist
\r
878 BOOLEAN bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
879 u1Byte btState, btInfoOriginal=0;
\r
881 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
883 btState = pCoexDm->btStatus;
\r
884 btInfoOriginal = pCoexSta->btInfoC2h[BT_INFO_SRC_8723A_1ANT_BT_RSP][0];
\r
888 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi connected!!\n"));
\r
889 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
892 ((BT_STATE_8723A_1ANT_NO_CONNECTION == btState) ||
\r
893 (BT_STATE_8723A_1ANT_CONNECT_IDLE == btState)) )
\r
895 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], [Wifi is idle] or [Bt is non connected idle or Bt is connected idle]!!\n"));
\r
897 if(BT_STATE_8723A_1ANT_NO_CONNECTION == btState)
\r
898 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
899 else if(BT_STATE_8723A_1ANT_CONNECT_IDLE == btState)
\r
900 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
902 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0);
\r
906 if( (BT_STATE_8723A_1ANT_SCO_ONLY_BUSY == btState) ||
\r
907 (BT_STATE_8723A_1ANT_ACL_SCO_BUSY == btState) ||
\r
908 (BT_STATE_8723A_1ANT_HID_BUSY == btState) ||
\r
909 (BT_STATE_8723A_1ANT_HID_SCO_BUSY == btState) )
\r
911 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0x60);
\r
915 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0);
\r
919 case BT_STATE_8723A_1ANT_NO_CONNECTION:
\r
920 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
922 case BT_STATE_8723A_1ANT_CONNECT_IDLE:
\r
923 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
925 case BT_STATE_8723A_1ANT_INQ_OR_PAG:
\r
926 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
928 case BT_STATE_8723A_1ANT_SCO_ONLY_BUSY:
\r
929 case BT_STATE_8723A_1ANT_ACL_SCO_BUSY:
\r
930 case BT_STATE_8723A_1ANT_HID_BUSY:
\r
931 case BT_STATE_8723A_1ANT_HID_SCO_BUSY:
\r
932 halbtc8723a1ant_TdmaDurationAdjust(pBtCoexist);
\r
934 case BT_STATE_8723A_1ANT_ACL_ONLY_BUSY:
\r
935 if (btInfoOriginal&BT_INFO_8723A_1ANT_B_A2DP)
\r
937 halbtc8723a1ant_TdmaDurationAdjust(pBtCoexist);
\r
939 else if(btInfoOriginal&BT_INFO_8723A_1ANT_B_FTP)
\r
941 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
943 else if( (btInfoOriginal&BT_INFO_8723A_1ANT_B_A2DP) &&
\r
944 (btInfoOriginal&BT_INFO_8723A_1ANT_B_FTP) )
\r
946 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
950 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
954 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], error!!!, undefined case in halbtc8723a1ant_CoexForWifiConnect()!!\n"));
\r
961 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is disconnected!!\n"));
\r
964 pCoexDm->psTdmaGlobalCnt++;
\r
967 //============================================================
\r
968 // work around function start with wa_halbtc8723a1ant_
\r
969 //============================================================
\r
971 wa_halbtc8723a1ant_MonitorC2h(
\r
972 IN PBTC_COEXIST pBtCoexist
\r
976 u4Byte curC2hTotalCnt=0x0;
\r
977 static u4Byte preC2hTotalCnt=0x0, sameCntPollingTime=0x0;
\r
979 curC2hTotalCnt+=pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8723A_1ANT_BT_RSP];
\r
981 if(curC2hTotalCnt == preC2hTotalCnt)
\r
983 sameCntPollingTime++;
\r
987 preC2hTotalCnt = curC2hTotalCnt;
\r
988 sameCntPollingTime = 0;
\r
991 if(sameCntPollingTime >= 2)
\r
993 tmp1b = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x1af);
\r
996 pCoexSta->c2hHangDetectCnt++;
\r
997 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x1af, 0x0);
\r
1002 //============================================================
\r
1003 // extern function start with EXhalbtc8723a1ant_
\r
1004 //============================================================
\r
1006 EXhalbtc8723a1ant_InitHwConfig(
\r
1007 IN PBTC_COEXIST pBtCoexist
\r
1010 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Init HW Config!!\n"));
\r
1012 // backup rf 0x1e value
\r
1013 pCoexDm->btRf0x1eBackup =
\r
1014 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
\r
1016 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20);
\r
1018 // enable counter statistics
\r
1019 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
1022 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, 0x0); // 1-Ant coex
\r
1023 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, 0xffff); // wifi break table
\r
1024 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, 0x55555555); //coex table
\r
1026 // antenna switch control parameter
\r
1027 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x858, 0xaaaaaaaa);
\r
1029 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x210); //set antenna at wifi side if ANTSW is software control
\r
1030 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x870, 0x300); //SPDT(connected with TRSW) control by hardware PTA
\r
1031 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x874, 0x22804000); //ANTSW keep by GNT_BT
\r
1033 // coexistence parameters
\r
1034 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1); // enable RTK mode PTA
\r
1038 EXhalbtc8723a1ant_InitCoexDm(
\r
1039 IN PBTC_COEXIST pBtCoexist
\r
1042 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
1044 halbtc8723a1ant_InitCoexDm(pBtCoexist);
\r
1048 EXhalbtc8723a1ant_DisplayCoexInfo(
\r
1049 IN PBTC_COEXIST pBtCoexist
\r
1052 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1053 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
1054 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
1055 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
1058 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
1059 CL_PRINTF(cliBuf);
\r
1061 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
\r
1062 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
\r
1063 CL_PRINTF(cliBuf);
\r
1065 if(pBtCoexist->bManualControl)
\r
1067 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!");
\r
1068 CL_PRINTF(cliBuf);
\r
1071 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
1072 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
1073 CL_PRINTF(cliBuf);
\r
1075 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \
\r
1076 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
\r
1077 pCoexDm->wifiChnlInfo[2]);
\r
1078 CL_PRINTF(cliBuf);
\r
1081 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
\r
1082 CL_PRINTF(cliBuf);
\r
1083 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
\r
1085 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
\r
1086 CL_PRINTF(cliBuf);
\r
1088 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
\r
1089 ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723A_1ANT_BT_STATUS_IDLE == pCoexDm->btStatus)? "idle":( (BT_8723A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy"))),
\r
1090 pCoexSta->btRssi, pCoexSta->btRetryCnt);
\r
1091 CL_PRINTF(cliBuf);
\r
1093 if(pStackInfo->bProfileNotified)
\r
1095 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
1096 pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist);
\r
1097 CL_PRINTF(cliBuf);
\r
1099 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
1102 btInfoExt = pCoexSta->btInfoExt;
\r
1103 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
\r
1104 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
\r
1105 CL_PRINTF(cliBuf);
\r
1107 for(i=0; i<BT_INFO_SRC_8723A_1ANT_MAX; i++)
\r
1109 if(pCoexSta->btInfoC2hCnt[i])
\r
1111 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723a1Ant[i], \
\r
1112 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
\r
1113 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
\r
1114 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
\r
1115 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
\r
1116 CL_PRINTF(cliBuf);
\r
1120 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "write 0x1af=0x0 num", \
\r
1121 pCoexSta->c2hHangDetectCnt);
\r
1122 CL_PRINTF(cliBuf);
\r
1125 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
1126 CL_PRINTF(cliBuf);
\r
1127 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "SM1[ShRf/ LpRA/ LimDig]", \
\r
1128 pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig);
\r
1129 CL_PRINTF(cliBuf);
\r
1132 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
1133 CL_PRINTF(cliBuf);
\r
1135 if(!pBtCoexist->bManualControl)
\r
1137 psTdmaCase = pCoexDm->curPsTdma;
\r
1138 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \
\r
1139 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
\r
1140 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
\r
1141 pCoexDm->psTdmaPara[4], psTdmaCase);
\r
1142 CL_PRINTF(cliBuf);
\r
1144 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \
\r
1145 pCoexDm->bCurIgnoreWlanAct);
\r
1146 CL_PRINTF(cliBuf);
\r
1150 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
1151 CL_PRINTF(cliBuf);
\r
1153 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
\r
1154 pCoexDm->btRf0x1eBackup);
\r
1155 CL_PRINTF(cliBuf);
\r
1157 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
\r
1158 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x783);
\r
1159 u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x796);
\r
1160 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \
\r
1161 u1Tmp[0], u1Tmp[1], u1Tmp[2]);
\r
1162 CL_PRINTF(cliBuf);
\r
1164 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
\r
1165 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x880", \
\r
1167 CL_PRINTF(cliBuf);
\r
1169 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
1170 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \
\r
1172 CL_PRINTF(cliBuf);
\r
1174 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
\r
1175 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
\r
1176 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
\r
1177 u4Tmp[0], u1Tmp[0]);
\r
1178 CL_PRINTF(cliBuf);
\r
1180 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x484);
\r
1181 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \
\r
1183 CL_PRINTF(cliBuf);
\r
1185 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
1186 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
\r
1188 CL_PRINTF(cliBuf);
\r
1190 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
\r
1191 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
\r
1192 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
\r
1193 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xdac);
\r
1194 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xda0/0xda4/0xda8/0xdac(FA cnt)", \
\r
1195 u4Tmp[0], u4Tmp[1], u4Tmp[2], u4Tmp[3]);
\r
1196 CL_PRINTF(cliBuf);
\r
1198 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
\r
1199 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
1200 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
1201 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
\r
1202 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
\r
1203 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
\r
1204 CL_PRINTF(cliBuf);
\r
1206 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770 (hp rx[31:16]/tx[15:0])", \
\r
1207 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
\r
1208 CL_PRINTF(cliBuf);
\r
1209 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
\r
1210 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
\r
1211 CL_PRINTF(cliBuf);
\r
1213 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
1218 EXhalbtc8723a1ant_IpsNotify(
\r
1219 IN PBTC_COEXIST pBtCoexist,
\r
1223 if(BTC_IPS_ENTER == type)
\r
1225 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n"));
\r
1226 halbtc8723a1ant_CoexAllOff(pBtCoexist);
\r
1228 else if(BTC_IPS_LEAVE == type)
\r
1230 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n"));
\r
1231 //halbtc8723a1ant_InitCoexDm(pBtCoexist);
\r
1236 EXhalbtc8723a1ant_LpsNotify(
\r
1237 IN PBTC_COEXIST pBtCoexist,
\r
1241 if(BTC_LPS_ENABLE == type)
\r
1243 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n"));
\r
1245 else if(BTC_LPS_DISABLE == type)
\r
1247 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n"));
\r
1248 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1253 EXhalbtc8723a1ant_ScanNotify(
\r
1254 IN PBTC_COEXIST pBtCoexist,
\r
1258 BOOLEAN bWifiConnected=FALSE;
\r
1260 halbtc8723a1ant_NotifyFwScan(pBtCoexist, type);
\r
1262 if(pBtCoexist->btInfo.bBtDisabled)
\r
1264 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1268 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1269 if(BTC_SCAN_START == type)
\r
1271 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));
\r
1272 if(!bWifiConnected) // non-connected scan
\r
1274 //set 0x550[3]=1 before PsTdma
\r
1275 halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, TRUE);
\r
1278 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
1280 else if(BTC_SCAN_FINISH == type)
\r
1282 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));
\r
1283 if(!bWifiConnected) // non-connected scan
\r
1285 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1289 halbtc8723a1ant_CoexForWifiConnect(pBtCoexist);
\r
1296 EXhalbtc8723a1ant_ConnectNotify(
\r
1297 IN PBTC_COEXIST pBtCoexist,
\r
1301 BOOLEAN bWifiConnected=FALSE;
\r
1303 if(pBtCoexist->btInfo.bBtDisabled)
\r
1305 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1309 if(BTC_ASSOCIATE_START == type)
\r
1311 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));
\r
1312 //set 0x550[3]=1 before PsTdma
\r
1313 halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, TRUE);
\r
1314 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); // extend wifi slot
\r
1316 else if(BTC_ASSOCIATE_FINISH == type)
\r
1318 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));
\r
1319 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1320 if(!bWifiConnected) // non-connected scan
\r
1322 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1326 halbtc8723a1ant_CoexForWifiConnect(pBtCoexist);
\r
1333 EXhalbtc8723a1ant_MediaStatusNotify(
\r
1334 IN PBTC_COEXIST pBtCoexist,
\r
1338 if(BTC_MEDIA_CONNECT == type)
\r
1340 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n"));
\r
1344 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n"));
\r
1349 EXhalbtc8723a1ant_SpecialPacketNotify(
\r
1350 IN PBTC_COEXIST pBtCoexist,
\r
1354 if(type == BTC_PACKET_DHCP)
\r
1356 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n"));
\r
1357 if(pBtCoexist->btInfo.bBtDisabled)
\r
1359 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1363 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 18);
\r
1369 EXhalbtc8723a1ant_BtInfoNotify(
\r
1370 IN PBTC_COEXIST pBtCoexist,
\r
1371 IN pu1Byte tmpBuf,
\r
1376 u1Byte i, rspSource=0;
\r
1377 BOOLEAN bBtHsOn=FALSE, bBtBusy=FALSE, bForceLps=FALSE;
\r
1379 pCoexSta->bC2hBtInfoReqSent = FALSE;
\r
1381 rspSource = BT_INFO_SRC_8723A_1ANT_BT_RSP;
\r
1382 pCoexSta->btInfoC2hCnt[rspSource]++;
\r
1384 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
\r
1385 for(i=0; i<length; i++)
\r
1387 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
\r
1389 btInfo = tmpBuf[i];
\r
1392 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i]));
\r
1396 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i]));
\r
1400 if(BT_INFO_SRC_8723A_1ANT_WIFI_FW != rspSource)
\r
1402 pCoexSta->btRetryCnt =
\r
1403 pCoexSta->btInfoC2h[rspSource][1];
\r
1405 pCoexSta->btRssi =
\r
1406 pCoexSta->btInfoC2h[rspSource][2]*2+10;
\r
1408 pCoexSta->btInfoExt =
\r
1409 pCoexSta->btInfoC2h[rspSource][3];
\r
1412 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1413 // check BIT2 first ==> check if bt is under inquiry or page scan
\r
1414 if(btInfo & BT_INFO_8723A_1ANT_B_INQ_PAGE)
\r
1416 pCoexSta->bC2hBtInquiryPage = TRUE;
\r
1420 pCoexSta->bC2hBtInquiryPage = FALSE;
\r
1423 if(!(btInfo & BIT0))
\r
1425 pCoexDm->btStatus = BT_STATE_8723A_1ANT_NO_CONNECTION;
\r
1426 bForceLps = FALSE;
\r
1433 pCoexDm->btStatus = BT_STATE_8723A_1ANT_CONNECT_IDLE;
\r
1435 else if(btInfo == 0x9)
\r
1437 pCoexDm->btStatus = BT_STATE_8723A_1ANT_ACL_ONLY_BUSY;
\r
1440 else if(btInfo == 0x13)
\r
1442 pCoexDm->btStatus = BT_STATE_8723A_1ANT_SCO_ONLY_BUSY;
\r
1445 else if(btInfo == 0x1b)
\r
1447 pCoexDm->btStatus = BT_STATE_8723A_1ANT_ACL_SCO_BUSY;
\r
1450 else if(btInfo == 0x29)
\r
1452 pCoexDm->btStatus = BT_STATE_8723A_1ANT_HID_BUSY;
\r
1455 else if(btInfo == 0x3b)
\r
1457 pCoexDm->btStatus = BT_STATE_8723A_1ANT_HID_SCO_BUSY;
\r
1461 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
1462 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bBtBusy);
\r
1464 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
\r
1466 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1468 if( (BT_STATE_8723A_1ANT_NO_CONNECTION == pCoexDm->btStatus) ||
\r
1469 (BT_STATE_8723A_1ANT_CONNECT_IDLE == pCoexDm->btStatus) )
\r
1471 if(pCoexSta->bC2hBtInquiryPage)
\r
1472 pCoexDm->btStatus = BT_STATE_8723A_1ANT_INQ_OR_PAG;
\r
1477 EXhalbtc8723a1ant_HaltNotify(
\r
1478 IN PBTC_COEXIST pBtCoexist
\r
1481 halbtc8723a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
\r
1483 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, FORCE_EXEC, FALSE);
\r
1484 halbtc8723a1ant_RfShrink(pBtCoexist, FORCE_EXEC, FALSE);
\r
1486 halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
1487 EXhalbtc8723a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
1491 EXhalbtc8723a1ant_Periodical(
\r
1492 IN PBTC_COEXIST pBtCoexist
\r
1495 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE, bWifiConnected=FALSE;
\r
1497 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Periodical!!\n"));
\r
1499 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
1500 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
1501 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
1502 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1504 // work around for c2h hang
\r
1505 wa_halbtc8723a1ant_MonitorC2h(pBtCoexist);
\r
1507 halbtc8723a1ant_QueryBtInfo(pBtCoexist);
\r
1508 halbtc8723a1ant_MonitorBtCtr(pBtCoexist);
\r
1509 halbtc8723a1ant_MonitorBtEnableDisable(pBtCoexist);
\r
1517 if(bWifiConnected)
\r
1519 if(pBtCoexist->btInfo.bBtDisabled)
\r
1521 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1523 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1524 halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1528 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1529 halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1530 halbtc8723a1ant_CoexForWifiConnect(pBtCoexist);
\r
1535 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1537 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1538 halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r