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
16 #if(BT_30_SUPPORT == 1)
\r
17 //============================================================
\r
18 // Global variables, these are static variables
\r
19 //============================================================
\r
20 static COEX_DM_8723A_1ANT GLCoexDm8723a1Ant;
\r
21 static PCOEX_DM_8723A_1ANT pCoexDm=&GLCoexDm8723a1Ant;
\r
22 static COEX_STA_8723A_1ANT GLCoexSta8723a1Ant;
\r
23 static PCOEX_STA_8723A_1ANT pCoexSta=&GLCoexSta8723a1Ant;
\r
25 const char *const GLBtInfoSrc8723a1Ant[]={
\r
28 "BT Info[bt auto report]",
\r
31 //============================================================
\r
32 // local function proto type if needed
\r
33 //============================================================
\r
34 //============================================================
\r
35 // local function start with halbtc8723a1ant_
\r
36 //============================================================
\r
38 halbtc8723a1ant_Reg0x550Bit3(
\r
39 IN PBTC_COEXIST pBtCoexist,
\r
45 u1tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x550);
\r
54 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x550, u1tmp);
\r
55 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], set 0x550[3]=%d\n", (bSet? 1:0)));
\r
59 halbtc8723a1ant_NotifyFwScan(
\r
60 IN PBTC_COEXIST pBtCoexist,
\r
64 u1Byte H2C_Parameter[1] ={0};
\r
66 if(BTC_SCAN_START == scanType)
\r
67 H2C_Parameter[0] = 0x1;
\r
69 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Notify FW for wifi scan, write 0x3b=0x%x\n",
\r
72 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x3b, 1, H2C_Parameter);
\r
76 halbtc8723a1ant_QueryBtInfo(
\r
77 IN PBTC_COEXIST pBtCoexist
\r
80 u1Byte H2C_Parameter[1] ={0};
\r
82 pCoexSta->bC2hBtInfoReqSent = TRUE;
\r
84 H2C_Parameter[0] |= BIT0; // trigger
\r
86 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x38=0x%x\n",
\r
89 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x38, 1, H2C_Parameter);
\r
93 halbtc8723a1ant_SetSwRfRxLpfCorner(
\r
94 IN PBTC_COEXIST pBtCoexist,
\r
95 IN BOOLEAN bRxRfShrinkOn
\r
100 //Shrink RF Rx LPF corner
\r
101 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
\r
102 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7);
\r
106 //Resume RF Rx LPF corner
\r
107 // After initialized, we can use pCoexDm->btRf0x1eBackup
\r
108 if(pBtCoexist->bInitilized)
\r
110 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
\r
111 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
\r
117 halbtc8723a1ant_RfShrink(
\r
118 IN PBTC_COEXIST pBtCoexist,
\r
119 IN BOOLEAN bForceExec,
\r
120 IN BOOLEAN bRxRfShrinkOn
\r
123 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
\r
124 (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
\r
125 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
\r
129 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n",
\r
130 pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink));
\r
132 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
\r
135 halbtc8723a1ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
\r
137 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
\r
141 halbtc8723a1ant_SetSwPenaltyTxRateAdaptive(
\r
142 IN PBTC_COEXIST pBtCoexist,
\r
143 IN BOOLEAN bLowPenaltyRa
\r
148 tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd);
\r
152 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
\r
157 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
\r
161 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1);
\r
165 halbtc8723a1ant_LowPenaltyRa(
\r
166 IN PBTC_COEXIST pBtCoexist,
\r
167 IN BOOLEAN bForceExec,
\r
168 IN BOOLEAN bLowPenaltyRa
\r
172 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
\r
173 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
\r
174 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
178 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
\r
179 pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
\r
181 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
184 halbtc8723a1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
186 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
190 halbtc8723a1ant_SetCoexTable(
\r
191 IN PBTC_COEXIST pBtCoexist,
\r
192 IN u4Byte val0x6c0,
\r
193 IN u4Byte val0x6c8,
\r
197 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
\r
198 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
\r
200 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
201 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
203 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
204 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
208 halbtc8723a1ant_CoexTable(
\r
209 IN PBTC_COEXIST pBtCoexist,
\r
210 IN BOOLEAN bForceExec,
\r
211 IN u4Byte val0x6c0,
\r
212 IN u4Byte val0x6c8,
\r
216 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
\r
217 (bForceExec? "force to":""), val0x6c0, val0x6c8, val0x6cc));
\r
218 pCoexDm->curVal0x6c0 = val0x6c0;
\r
219 pCoexDm->curVal0x6c8 = val0x6c8;
\r
220 pCoexDm->curVal0x6cc = val0x6cc;
\r
224 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
\r
225 pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
\r
226 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
\r
227 pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
\r
229 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
\r
230 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
231 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
234 halbtc8723a1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c8, val0x6cc);
\r
236 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
\r
237 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
238 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
242 halbtc8723a1ant_SetFwIgnoreWlanAct(
\r
243 IN PBTC_COEXIST pBtCoexist,
\r
247 u1Byte H2C_Parameter[1] ={0};
\r
251 H2C_Parameter[0] |= BIT0; // function enable
\r
254 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x25=0x%x\n",
\r
255 H2C_Parameter[0]));
\r
257 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x25, 1, H2C_Parameter);
\r
261 halbtc8723a1ant_IgnoreWlanAct(
\r
262 IN PBTC_COEXIST pBtCoexist,
\r
263 IN BOOLEAN bForceExec,
\r
267 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
\r
268 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
\r
269 pCoexDm->bCurIgnoreWlanAct = bEnable;
\r
273 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
\r
274 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
\r
276 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
\r
279 halbtc8723a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
\r
281 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
\r
285 halbtc8723a1ant_SetFwPstdma(
\r
286 IN PBTC_COEXIST pBtCoexist,
\r
295 u1Byte H2C_Parameter[5] ={0};
\r
296 u1Byte realByte1=byte1, realByte5=byte5;
\r
297 BOOLEAN bApEnable=FALSE;
\r
299 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
\r
301 // byte1[1:0] != 0 means enable pstdma
\r
302 // for 2Ant bt coexist, if byte1 != 0 means enable pstdma
\r
307 if(type != 5 && type != 12)
\r
309 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], FW for 1Ant AP mode\n"));
\r
310 realByte1 &= ~BIT4;
\r
314 realByte5 &= ~BIT6;
\r
318 H2C_Parameter[0] = realByte1;
\r
319 H2C_Parameter[1] = byte2;
\r
320 H2C_Parameter[2] = byte3;
\r
321 H2C_Parameter[3] = byte4;
\r
322 H2C_Parameter[4] = realByte5;
\r
324 pCoexDm->psTdmaPara[0] = realByte1;
\r
325 pCoexDm->psTdmaPara[1] = byte2;
\r
326 pCoexDm->psTdmaPara[2] = byte3;
\r
327 pCoexDm->psTdmaPara[3] = byte4;
\r
328 pCoexDm->psTdmaPara[4] = realByte5;
\r
330 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x3a(5bytes)=0x%x%08x\n",
\r
332 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
\r
334 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x3a, 5, H2C_Parameter);
\r
338 halbtc8723a1ant_PsTdma(
\r
339 IN PBTC_COEXIST pBtCoexist,
\r
340 IN BOOLEAN bForceExec,
\r
341 IN BOOLEAN bTurnOn,
\r
345 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
\r
346 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
\r
347 pCoexDm->bCurPsTdmaOn = bTurnOn;
\r
348 pCoexDm->curPsTdma = type;
\r
352 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
\r
353 pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn));
\r
354 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
\r
355 pCoexDm->prePsTdma, pCoexDm->curPsTdma));
\r
357 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
\r
358 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
\r
361 if(pCoexDm->bCurPsTdmaOn)
\r
363 switch(pCoexDm->curPsTdma)
\r
367 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x1a, 0x1a, 0x0, 0x40);
\r
370 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x12, 0x12, 0x0, 0x40);
\r
373 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x3f, 0x3, 0x10, 0x40);
\r
376 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x15, 0x3, 0x10, 0x0);
\r
379 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0xa9, 0x15, 0x3, 0x35, 0xc0);
\r
383 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
386 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x0, 0x40);
\r
389 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x0, 0x40);
\r
392 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x0, 0x40);
\r
395 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0xa9, 0xa, 0x3, 0x15, 0xc0);
\r
399 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
403 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x2a, 0x2a, 0x0, 0x0);
\r
406 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x20, 0x3, 0x10, 0x40);
\r
409 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x1a, 0x1a, 0x2, 0x40);
\r
412 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x12, 0x12, 0x2, 0x40);
\r
415 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x2, 0x40);
\r
418 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x2, 0x40);
\r
421 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0);
\r
424 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x2, 0x40);
\r
427 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x3, 0x2f, 0x2f, 0x0, 0x0);
\r
435 switch(pCoexDm->curPsTdma)
\r
438 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x8, 0x0, 0x0, 0x0, 0x0);
\r
442 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
443 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x210);
\r
446 halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x0, 0x0, 0x0, 0x0, 0x0);
\r
447 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x110);
\r
453 // update pre state
\r
454 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
\r
455 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
\r
460 halbtc8723a1ant_CoexAllOff(
\r
461 IN PBTC_COEXIST pBtCoexist
\r
465 halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
\r
466 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
469 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
\r
470 halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r
473 halbtc8723a1ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
\r
477 halbtc8723a1ant_InitCoexDm(
\r
478 IN PBTC_COEXIST pBtCoexist
\r
481 // force to reset coex mechanism
\r
482 halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
486 halbtc8723a1ant_BtEnableAction(
\r
487 IN PBTC_COEXIST pBtCoexist
\r
490 halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
\r
494 halbtc8723a1ant_MonitorBtCtr(
\r
495 IN PBTC_COEXIST pBtCoexist
\r
498 u4Byte regHPTxRx, regLPTxRx, u4Tmp;
\r
499 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
\r
505 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
\r
506 regHPTx = u4Tmp & bMaskLWord;
\r
507 regHPRx = (u4Tmp & bMaskHWord)>>16;
\r
509 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
\r
510 regLPTx = u4Tmp & bMaskLWord;
\r
511 regLPRx = (u4Tmp & bMaskHWord)>>16;
\r
513 pCoexSta->highPriorityTx = regHPTx;
\r
514 pCoexSta->highPriorityRx = regHPRx;
\r
515 pCoexSta->lowPriorityTx = regLPTx;
\r
516 pCoexSta->lowPriorityRx = regLPRx;
\r
518 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
519 regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
\r
520 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
\r
521 regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
\r
524 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
\r
528 halbtc8723a1ant_MonitorBtEnableDisable(
\r
529 IN PBTC_COEXIST pBtCoexist
\r
532 static BOOLEAN bPreBtDisabled=FALSE;
\r
533 static u4Byte btDisableCnt=0;
\r
534 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
\r
536 // This function check if bt is disabled
\r
538 if( pCoexSta->highPriorityTx == 0 &&
\r
539 pCoexSta->highPriorityRx == 0 &&
\r
540 pCoexSta->lowPriorityTx == 0 &&
\r
541 pCoexSta->lowPriorityRx == 0)
\r
545 if( pCoexSta->highPriorityTx == 0xffff &&
\r
546 pCoexSta->highPriorityRx == 0xffff &&
\r
547 pCoexSta->lowPriorityTx == 0xffff &&
\r
548 pCoexSta->lowPriorityRx == 0xffff)
\r
555 bBtDisabled = FALSE;
\r
556 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
557 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
\r
562 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
\r
564 if(btDisableCnt >= 2)
\r
566 bBtDisabled = TRUE;
\r
567 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
\r
568 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
\r
571 if(bPreBtDisabled != bBtDisabled)
\r
573 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
\r
574 (bPreBtDisabled ? "disabled":"enabled"),
\r
575 (bBtDisabled ? "disabled":"enabled")));
\r
576 bPreBtDisabled = bBtDisabled;
\r
579 halbtc8723a1ant_BtEnableAction(pBtCoexist);
\r
583 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
589 halbtc8723a1ant_TdmaDurationAdjust(
\r
590 IN PBTC_COEXIST pBtCoexist
\r
593 static s4Byte up,dn,m,n,WaitCount;
\r
594 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
\r
595 u1Byte retryCount=0;
\r
597 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
\r
600 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
601 btState = pCoexDm->btStatus;
\r
603 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], TdmaDurationAdjust()\n"));
\r
604 if(pCoexDm->psTdmaGlobalCnt != pCoexDm->psTdmaMonitorCnt)
\r
606 pCoexDm->psTdmaMonitorCnt = 0;
\r
607 pCoexDm->psTdmaGlobalCnt = 0;
\r
609 if(pCoexDm->psTdmaMonitorCnt == 0)
\r
611 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], first run BT A2DP + WiFi busy state!!\n"));
\r
612 if(btState == BT_STATE_8723A_1ANT_ACL_ONLY_BUSY)
\r
614 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
615 pCoexDm->psTdmaDuAdjType = 1;
\r
619 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
620 pCoexDm->psTdmaDuAdjType = 22;
\r
632 //accquire the BT TRx retry count from BT_Info byte2
\r
633 retryCount = pCoexSta->btRetryCnt;
\r
634 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], retryCount = %d\n", retryCount));
\r
638 if(retryCount == 0) // no retry in the last 2-second duration
\r
646 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
\r
653 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Increase wifi duration!!\n"));
\r
656 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
\r
664 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
\r
666 if (WaitCount <= 2)
\r
667 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
671 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
679 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
\r
682 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
\r
684 if (WaitCount == 1)
\r
685 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
\r
689 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
\r
697 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
\r
701 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT TxRx counter H+L <= 1200\n"));
\r
702 if(btState != BT_STATE_8723A_1ANT_ACL_ONLY_BUSY)
\r
704 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], NOT ACL only busy!\n"));
\r
705 if(BTC_WIFI_BW_HT40 != wifiBw)
\r
707 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], 20MHz\n"));
\r
710 if(pCoexDm->curPsTdma == 22)
\r
712 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
713 pCoexDm->psTdmaDuAdjType = 23;
\r
715 else if(pCoexDm->curPsTdma == 23)
\r
717 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
718 pCoexDm->psTdmaDuAdjType = 24;
\r
720 else if(pCoexDm->curPsTdma == 24)
\r
722 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 25);
\r
723 pCoexDm->psTdmaDuAdjType = 25;
\r
726 else if (result == 1)
\r
728 if(pCoexDm->curPsTdma == 25)
\r
730 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
731 pCoexDm->psTdmaDuAdjType = 24;
\r
733 else if(pCoexDm->curPsTdma == 24)
\r
735 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
736 pCoexDm->psTdmaDuAdjType = 23;
\r
738 else if(pCoexDm->curPsTdma == 23)
\r
740 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);
\r
741 pCoexDm->psTdmaDuAdjType = 22;
\r
744 // error handle, if not in the following state,
\r
745 // set psTdma again.
\r
746 if( (pCoexDm->psTdmaDuAdjType != 22) &&
\r
747 (pCoexDm->psTdmaDuAdjType != 23) &&
\r
748 (pCoexDm->psTdmaDuAdjType != 24) &&
\r
749 (pCoexDm->psTdmaDuAdjType != 25) )
\r
751 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], duration case out of handle!!\n"));
\r
752 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
753 pCoexDm->psTdmaDuAdjType = 23;
\r
758 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], 40MHz\n"));
\r
761 if(pCoexDm->curPsTdma == 23)
\r
763 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
764 pCoexDm->psTdmaDuAdjType = 24;
\r
766 else if(pCoexDm->curPsTdma == 24)
\r
768 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 25);
\r
769 pCoexDm->psTdmaDuAdjType = 25;
\r
771 else if(pCoexDm->curPsTdma == 25)
\r
773 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 27);
\r
774 pCoexDm->psTdmaDuAdjType = 27;
\r
777 else if (result == 1)
\r
779 if(pCoexDm->curPsTdma == 27)
\r
781 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 25);
\r
782 pCoexDm->psTdmaDuAdjType = 25;
\r
784 else if(pCoexDm->curPsTdma == 25)
\r
786 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
787 pCoexDm->psTdmaDuAdjType = 24;
\r
789 else if(pCoexDm->curPsTdma == 24)
\r
791 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);
\r
792 pCoexDm->psTdmaDuAdjType = 23;
\r
795 // error handle, if not in the following state,
\r
796 // set psTdma again.
\r
797 if( (pCoexDm->psTdmaDuAdjType != 23) &&
\r
798 (pCoexDm->psTdmaDuAdjType != 24) &&
\r
799 (pCoexDm->psTdmaDuAdjType != 25) &&
\r
800 (pCoexDm->psTdmaDuAdjType != 27) )
\r
802 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], duration case out of handle!!\n"));
\r
803 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);
\r
804 pCoexDm->psTdmaDuAdjType = 24;
\r
810 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ACL only busy\n"));
\r
813 if(pCoexDm->curPsTdma == 1)
\r
815 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
816 pCoexDm->psTdmaDuAdjType = 2;
\r
818 else if(pCoexDm->curPsTdma == 2)
\r
820 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
821 pCoexDm->psTdmaDuAdjType = 9;
\r
823 else if(pCoexDm->curPsTdma == 9)
\r
825 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
\r
826 pCoexDm->psTdmaDuAdjType = 11;
\r
829 else if (result == 1)
\r
831 if(pCoexDm->curPsTdma == 11)
\r
833 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
\r
834 pCoexDm->psTdmaDuAdjType = 9;
\r
836 else if(pCoexDm->curPsTdma == 9)
\r
838 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
839 pCoexDm->psTdmaDuAdjType = 2;
\r
841 else if(pCoexDm->curPsTdma == 2)
\r
843 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
844 pCoexDm->psTdmaDuAdjType = 1;
\r
848 // error handle, if not in the following state,
\r
849 // set psTdma again.
\r
850 if( (pCoexDm->psTdmaDuAdjType != 1) &&
\r
851 (pCoexDm->psTdmaDuAdjType != 2) &&
\r
852 (pCoexDm->psTdmaDuAdjType != 9) &&
\r
853 (pCoexDm->psTdmaDuAdjType != 11) )
\r
855 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], duration case out of handle!!\n"));
\r
856 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
\r
857 pCoexDm->psTdmaDuAdjType = 2;
\r
863 // if current PsTdma not match with the recorded one (when scan, dhcp...),
\r
864 // then we have to adjust it back to the previous record one.
\r
865 if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)
\r
867 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n",
\r
868 pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));
\r
870 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
871 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
872 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
874 if( !bScan && !bLink && !bRoam)
\r
876 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
\r
880 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
\r
883 pCoexDm->psTdmaMonitorCnt++;
\r
888 halbtc8723a1ant_CoexForWifiConnect(
\r
889 IN PBTC_COEXIST pBtCoexist
\r
892 BOOLEAN bWifiConnected=FALSE, bWifiBusy=FALSE;
\r
893 u1Byte btState, btInfoOriginal=0;
\r
895 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
897 btState = pCoexDm->btStatus;
\r
898 btInfoOriginal = pCoexSta->btInfoC2h[BT_INFO_SRC_8723A_1ANT_BT_RSP][0];
\r
902 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi connected!!\n"));
\r
903 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
906 ((BT_STATE_8723A_1ANT_NO_CONNECTION == btState) ||
\r
907 (BT_STATE_8723A_1ANT_CONNECT_IDLE == btState)) )
\r
909 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], [Wifi is idle] or [Bt is non connected idle or Bt is connected idle]!!\n"));
\r
911 if(BT_STATE_8723A_1ANT_NO_CONNECTION == btState)
\r
912 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
913 else if(BT_STATE_8723A_1ANT_CONNECT_IDLE == btState)
\r
914 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
916 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0);
\r
920 if( (BT_STATE_8723A_1ANT_SCO_ONLY_BUSY == btState) ||
\r
921 (BT_STATE_8723A_1ANT_ACL_SCO_BUSY == btState) ||
\r
922 (BT_STATE_8723A_1ANT_HID_BUSY == btState) ||
\r
923 (BT_STATE_8723A_1ANT_HID_SCO_BUSY == btState) )
\r
925 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0x60);
\r
929 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0);
\r
933 case BT_STATE_8723A_1ANT_NO_CONNECTION:
\r
934 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
\r
936 case BT_STATE_8723A_1ANT_CONNECT_IDLE:
\r
937 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
\r
939 case BT_STATE_8723A_1ANT_INQ_OR_PAG:
\r
940 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
\r
942 case BT_STATE_8723A_1ANT_SCO_ONLY_BUSY:
\r
943 case BT_STATE_8723A_1ANT_ACL_SCO_BUSY:
\r
944 case BT_STATE_8723A_1ANT_HID_BUSY:
\r
945 case BT_STATE_8723A_1ANT_HID_SCO_BUSY:
\r
946 halbtc8723a1ant_TdmaDurationAdjust(pBtCoexist);
\r
948 case BT_STATE_8723A_1ANT_ACL_ONLY_BUSY:
\r
949 if (btInfoOriginal&BT_INFO_8723A_1ANT_B_A2DP)
\r
951 halbtc8723a1ant_TdmaDurationAdjust(pBtCoexist);
\r
953 else if(btInfoOriginal&BT_INFO_8723A_1ANT_B_FTP)
\r
955 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
957 else if( (btInfoOriginal&BT_INFO_8723A_1ANT_B_A2DP) &&
\r
958 (btInfoOriginal&BT_INFO_8723A_1ANT_B_FTP) )
\r
960 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
\r
964 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
\r
968 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], error!!!, undefined case in halbtc8723a1ant_CoexForWifiConnect()!!\n"));
\r
975 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is disconnected!!\n"));
\r
978 pCoexDm->psTdmaGlobalCnt++;
\r
981 //============================================================
\r
982 // work around function start with wa_halbtc8723a1ant_
\r
983 //============================================================
\r
985 wa_halbtc8723a1ant_MonitorC2h(
\r
986 IN PBTC_COEXIST pBtCoexist
\r
990 u4Byte curC2hTotalCnt=0x0;
\r
991 static u4Byte preC2hTotalCnt=0x0, sameCntPollingTime=0x0;
\r
993 curC2hTotalCnt+=pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8723A_1ANT_BT_RSP];
\r
995 if(curC2hTotalCnt == preC2hTotalCnt)
\r
997 sameCntPollingTime++;
\r
1001 preC2hTotalCnt = curC2hTotalCnt;
\r
1002 sameCntPollingTime = 0;
\r
1005 if(sameCntPollingTime >= 2)
\r
1007 tmp1b = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x1af);
\r
1010 pCoexSta->c2hHangDetectCnt++;
\r
1011 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x1af, 0x0);
\r
1016 //============================================================
\r
1017 // extern function start with EXhalbtc8723a1ant_
\r
1018 //============================================================
\r
1020 EXhalbtc8723a1ant_InitHwConfig(
\r
1021 IN PBTC_COEXIST pBtCoexist
\r
1024 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
\r
1026 // backup rf 0x1e value
\r
1027 pCoexDm->btRf0x1eBackup =
\r
1028 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
\r
1030 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20);
\r
1032 // enable counter statistics
\r
1033 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
\r
1036 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, 0x0); // 1-Ant coex
\r
1037 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, 0xffff); // wifi break table
\r
1038 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, 0x55555555); //coex table
\r
1040 // antenna switch control parameter
\r
1041 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x858, 0xaaaaaaaa);
\r
1043 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x210); //set antenna at wifi side if ANTSW is software control
\r
1044 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x870, 0x300); //SPDT(connected with TRSW) control by hardware PTA
\r
1045 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x874, 0x22804000); //ANTSW keep by GNT_BT
\r
1047 // coexistence parameters
\r
1048 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1); // enable RTK mode PTA
\r
1052 EXhalbtc8723a1ant_InitCoexDm(
\r
1053 IN PBTC_COEXIST pBtCoexist
\r
1056 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
1058 halbtc8723a1ant_InitCoexDm(pBtCoexist);
\r
1062 EXhalbtc8723a1ant_DisplayCoexInfo(
\r
1063 IN PBTC_COEXIST pBtCoexist
\r
1066 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1067 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
1068 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
1069 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
1072 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
1073 CL_PRINTF(cliBuf);
\r
1075 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
\r
1076 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
\r
1077 CL_PRINTF(cliBuf);
\r
1079 if(pBtCoexist->bManualControl)
\r
1081 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!");
\r
1082 CL_PRINTF(cliBuf);
\r
1085 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
1086 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
1087 CL_PRINTF(cliBuf);
\r
1089 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \
\r
1090 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
\r
1091 pCoexDm->wifiChnlInfo[2]);
\r
1092 CL_PRINTF(cliBuf);
\r
1095 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
\r
1096 CL_PRINTF(cliBuf);
\r
1097 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
\r
1099 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
\r
1100 CL_PRINTF(cliBuf);
\r
1102 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
\r
1103 ((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
1104 pCoexSta->btRssi, pCoexSta->btRetryCnt);
\r
1105 CL_PRINTF(cliBuf);
\r
1107 if(pStackInfo->bProfileNotified)
\r
1109 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
1110 pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist);
\r
1111 CL_PRINTF(cliBuf);
\r
1113 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
1116 btInfoExt = pCoexSta->btInfoExt;
\r
1117 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
\r
1118 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
\r
1119 CL_PRINTF(cliBuf);
\r
1121 for(i=0; i<BT_INFO_SRC_8723A_1ANT_MAX; i++)
\r
1123 if(pCoexSta->btInfoC2hCnt[i])
\r
1125 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723a1Ant[i], \
\r
1126 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
\r
1127 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
\r
1128 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
\r
1129 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
\r
1130 CL_PRINTF(cliBuf);
\r
1134 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "write 0x1af=0x0 num", \
\r
1135 pCoexSta->c2hHangDetectCnt);
\r
1136 CL_PRINTF(cliBuf);
\r
1139 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
1140 CL_PRINTF(cliBuf);
\r
1141 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "SM1[ShRf/ LpRA/ LimDig]", \
\r
1142 pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig);
\r
1143 CL_PRINTF(cliBuf);
\r
1146 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
1147 CL_PRINTF(cliBuf);
\r
1149 if(!pBtCoexist->bManualControl)
\r
1151 psTdmaCase = pCoexDm->curPsTdma;
\r
1152 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \
\r
1153 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
\r
1154 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
\r
1155 pCoexDm->psTdmaPara[4], psTdmaCase);
\r
1156 CL_PRINTF(cliBuf);
\r
1158 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \
\r
1159 pCoexDm->bCurIgnoreWlanAct);
\r
1160 CL_PRINTF(cliBuf);
\r
1164 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
1165 CL_PRINTF(cliBuf);
\r
1167 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
\r
1168 pCoexDm->btRf0x1eBackup);
\r
1169 CL_PRINTF(cliBuf);
\r
1171 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
\r
1172 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x783);
\r
1173 u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x796);
\r
1174 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \
\r
1175 u1Tmp[0], u1Tmp[1], u1Tmp[2]);
\r
1176 CL_PRINTF(cliBuf);
\r
1178 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
\r
1179 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x880", \
\r
1181 CL_PRINTF(cliBuf);
\r
1183 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
1184 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \
\r
1186 CL_PRINTF(cliBuf);
\r
1188 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
\r
1189 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
\r
1190 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
\r
1191 u4Tmp[0], u1Tmp[0]);
\r
1192 CL_PRINTF(cliBuf);
\r
1194 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x484);
\r
1195 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \
\r
1197 CL_PRINTF(cliBuf);
\r
1199 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
1200 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
\r
1202 CL_PRINTF(cliBuf);
\r
1204 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
\r
1205 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
\r
1206 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
\r
1207 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xdac);
\r
1208 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
1209 u4Tmp[0], u4Tmp[1], u4Tmp[2], u4Tmp[3]);
\r
1210 CL_PRINTF(cliBuf);
\r
1212 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
\r
1213 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
1214 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
1215 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
\r
1216 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
\r
1217 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
\r
1218 CL_PRINTF(cliBuf);
\r
1220 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770 (hp rx[31:16]/tx[15:0])", \
\r
1221 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
\r
1222 CL_PRINTF(cliBuf);
\r
1223 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
\r
1224 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
\r
1225 CL_PRINTF(cliBuf);
\r
1227 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
1232 EXhalbtc8723a1ant_IpsNotify(
\r
1233 IN PBTC_COEXIST pBtCoexist,
\r
1237 if(BTC_IPS_ENTER == type)
\r
1239 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
\r
1240 halbtc8723a1ant_CoexAllOff(pBtCoexist);
\r
1242 else if(BTC_IPS_LEAVE == type)
\r
1244 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
\r
1245 //halbtc8723a1ant_InitCoexDm(pBtCoexist);
\r
1250 EXhalbtc8723a1ant_LpsNotify(
\r
1251 IN PBTC_COEXIST pBtCoexist,
\r
1255 if(BTC_LPS_ENABLE == type)
\r
1257 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
\r
1259 else if(BTC_LPS_DISABLE == type)
\r
1261 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
\r
1262 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
\r
1267 EXhalbtc8723a1ant_ScanNotify(
\r
1268 IN PBTC_COEXIST pBtCoexist,
\r
1272 BOOLEAN bWifiConnected=FALSE;
\r
1274 halbtc8723a1ant_NotifyFwScan(pBtCoexist, type);
\r
1276 if(pBtCoexist->btInfo.bBtDisabled)
\r
1278 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1282 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1283 if(BTC_SCAN_START == type)
\r
1285 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
\r
1286 if(!bWifiConnected) // non-connected scan
\r
1288 //set 0x550[3]=1 before PsTdma
\r
1289 halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, TRUE);
\r
1292 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
\r
1294 else if(BTC_SCAN_FINISH == type)
\r
1296 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
\r
1297 if(!bWifiConnected) // non-connected scan
\r
1299 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1303 halbtc8723a1ant_CoexForWifiConnect(pBtCoexist);
\r
1310 EXhalbtc8723a1ant_ConnectNotify(
\r
1311 IN PBTC_COEXIST pBtCoexist,
\r
1315 BOOLEAN bWifiConnected=FALSE;
\r
1317 if(pBtCoexist->btInfo.bBtDisabled)
\r
1319 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1323 if(BTC_ASSOCIATE_START == type)
\r
1325 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
\r
1326 //set 0x550[3]=1 before PsTdma
\r
1327 halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, TRUE);
\r
1328 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); // extend wifi slot
\r
1330 else if(BTC_ASSOCIATE_FINISH == type)
\r
1332 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
\r
1333 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1334 if(!bWifiConnected) // non-connected scan
\r
1336 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1340 halbtc8723a1ant_CoexForWifiConnect(pBtCoexist);
\r
1347 EXhalbtc8723a1ant_MediaStatusNotify(
\r
1348 IN PBTC_COEXIST pBtCoexist,
\r
1352 if(BTC_MEDIA_CONNECT == type)
\r
1354 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
\r
1358 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
\r
1363 EXhalbtc8723a1ant_SpecialPacketNotify(
\r
1364 IN PBTC_COEXIST pBtCoexist,
\r
1368 if(type == BTC_PACKET_DHCP)
\r
1370 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
\r
1371 if(pBtCoexist->btInfo.bBtDisabled)
\r
1373 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1377 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 18);
\r
1383 EXhalbtc8723a1ant_BtInfoNotify(
\r
1384 IN PBTC_COEXIST pBtCoexist,
\r
1385 IN pu1Byte tmpBuf,
\r
1390 u1Byte i, rspSource=0;
\r
1391 BOOLEAN bBtHsOn=FALSE, bBtBusy=FALSE, bForceLps=FALSE;
\r
1393 pCoexSta->bC2hBtInfoReqSent = FALSE;
\r
1395 rspSource = BT_INFO_SRC_8723A_1ANT_BT_RSP;
\r
1396 pCoexSta->btInfoC2hCnt[rspSource]++;
\r
1398 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
\r
1399 for(i=0; i<length; i++)
\r
1401 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
\r
1403 btInfo = tmpBuf[i];
\r
1406 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
\r
1410 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
\r
1414 if(BT_INFO_SRC_8723A_1ANT_WIFI_FW != rspSource)
\r
1416 pCoexSta->btRetryCnt =
\r
1417 pCoexSta->btInfoC2h[rspSource][1];
\r
1419 pCoexSta->btRssi =
\r
1420 pCoexSta->btInfoC2h[rspSource][2]*2+10;
\r
1422 pCoexSta->btInfoExt =
\r
1423 pCoexSta->btInfoC2h[rspSource][3];
\r
1426 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1427 // check BIT2 first ==> check if bt is under inquiry or page scan
\r
1428 if(btInfo & BT_INFO_8723A_1ANT_B_INQ_PAGE)
\r
1430 pCoexSta->bC2hBtInquiryPage = TRUE;
\r
1434 pCoexSta->bC2hBtInquiryPage = FALSE;
\r
1437 if(!(btInfo & BIT0))
\r
1439 pCoexDm->btStatus = BT_STATE_8723A_1ANT_NO_CONNECTION;
\r
1440 bForceLps = FALSE;
\r
1447 pCoexDm->btStatus = BT_STATE_8723A_1ANT_CONNECT_IDLE;
\r
1449 else if(btInfo == 0x9)
\r
1451 pCoexDm->btStatus = BT_STATE_8723A_1ANT_ACL_ONLY_BUSY;
\r
1454 else if(btInfo == 0x13)
\r
1456 pCoexDm->btStatus = BT_STATE_8723A_1ANT_SCO_ONLY_BUSY;
\r
1459 else if(btInfo == 0x1b)
\r
1461 pCoexDm->btStatus = BT_STATE_8723A_1ANT_ACL_SCO_BUSY;
\r
1464 else if(btInfo == 0x29)
\r
1466 pCoexDm->btStatus = BT_STATE_8723A_1ANT_HID_BUSY;
\r
1469 else if(btInfo == 0x3b)
\r
1471 pCoexDm->btStatus = BT_STATE_8723A_1ANT_HID_SCO_BUSY;
\r
1475 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
\r
1476 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bBtBusy);
\r
1478 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
\r
1480 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
\r
1482 if( (BT_STATE_8723A_1ANT_NO_CONNECTION == pCoexDm->btStatus) ||
\r
1483 (BT_STATE_8723A_1ANT_CONNECT_IDLE == pCoexDm->btStatus) )
\r
1485 if(pCoexSta->bC2hBtInquiryPage)
\r
1486 pCoexDm->btStatus = BT_STATE_8723A_1ANT_INQ_OR_PAG;
\r
1491 EXhalbtc8723a1ant_HaltNotify(
\r
1492 IN PBTC_COEXIST pBtCoexist
\r
1495 halbtc8723a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
\r
1497 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, FORCE_EXEC, FALSE);
\r
1498 halbtc8723a1ant_RfShrink(pBtCoexist, FORCE_EXEC, FALSE);
\r
1500 halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
\r
1501 EXhalbtc8723a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
1505 EXhalbtc8723a1ant_Periodical(
\r
1506 IN PBTC_COEXIST pBtCoexist
\r
1509 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE, bWifiConnected=FALSE;
\r
1511 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], 1Ant Periodical!!\n"));
\r
1513 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
1514 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
1515 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
1516 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
\r
1518 // work around for c2h hang
\r
1519 wa_halbtc8723a1ant_MonitorC2h(pBtCoexist);
\r
1521 halbtc8723a1ant_QueryBtInfo(pBtCoexist);
\r
1522 halbtc8723a1ant_MonitorBtCtr(pBtCoexist);
\r
1523 halbtc8723a1ant_MonitorBtEnableDisable(pBtCoexist);
\r
1531 if(bWifiConnected)
\r
1533 if(pBtCoexist->btInfo.bBtDisabled)
\r
1535 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
\r
1537 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1538 halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1542 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1543 halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1544 halbtc8723a1ant_CoexForWifiConnect(pBtCoexist);
\r
1549 halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
\r
1551 halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1552 halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r