1 //============================================================
\r
4 // This file is for 92CE/92CU BT 1 Antenna Co-exist mechanism
\r
6 // By cosa 02/11/2011
\r
8 //============================================================
\r
10 //============================================================
\r
12 //============================================================
\r
13 #include "Mp_Precomp.h"
\r
15 #if WPP_SOFTWARE_TRACE
\r
16 #include "HalBtc8188c2Ant.tmh"
\r
19 #if(BT_30_SUPPORT == 1)
\r
20 //============================================================
\r
21 // Global variables, these are static variables
\r
22 //============================================================
\r
23 static COEX_DM_8188C_2ANT GLCoexDm8188c2Ant;
\r
24 static PCOEX_DM_8188C_2ANT pCoexDm=&GLCoexDm8188c2Ant;
\r
25 static COEX_STA_8188C_2ANT GLCoexSta8188c2Ant;
\r
26 static PCOEX_STA_8188C_2ANT pCoexSta=&GLCoexSta8188c2Ant;
\r
28 //============================================================
\r
29 // local function start with btdm_
\r
30 //============================================================
\r
32 halbtc8188c2ant_WifiRssiState(
\r
33 IN PBTC_COEXIST pBtCoexist,
\r
36 IN u1Byte rssiThresh,
\r
37 IN u1Byte rssiThresh1
\r
41 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
\r
43 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
47 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
48 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
50 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT))
\r
52 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
56 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
61 if(wifiRssi < rssiThresh)
\r
63 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
67 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
71 else if(levelNum == 3)
\r
73 if(rssiThresh > rssiThresh1)
\r
75 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n"));
\r
76 return pCoexSta->preWifiRssiState[index];
\r
79 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
80 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
82 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT))
\r
84 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
88 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
91 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
\r
92 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
\r
94 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT))
\r
96 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
98 else if(wifiRssi < rssiThresh)
\r
100 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
104 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
109 if(wifiRssi < rssiThresh1)
\r
111 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
115 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
120 pCoexSta->preWifiRssiState[index] = wifiRssiState;
\r
122 return wifiRssiState;
\r
126 halbtc8188c2ant_ActionAlgorithm(
\r
127 IN PBTC_COEXIST pBtCoexist
\r
130 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
131 u1Byte algorithm=BT_8188C_2ANT_COEX_ALGO_UNDEFINED;
\r
132 u1Byte numOfDiffProfile=0;
\r
134 if(!pStackInfo->bBtLinkExist)
\r
136 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No profile exists!!!\n"));
\r
140 if(pStackInfo->bScoExist)
\r
141 numOfDiffProfile++;
\r
142 if(pStackInfo->bHidExist)
\r
143 numOfDiffProfile++;
\r
144 if(pStackInfo->bPanExist)
\r
145 numOfDiffProfile++;
\r
146 if(pStackInfo->bA2dpExist)
\r
147 numOfDiffProfile++;
\r
149 if(pStackInfo->bScoExist)
\r
151 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO algorithm\n"));
\r
152 algorithm = BT_8188C_2ANT_COEX_ALGO_SCO;
\r
156 if(numOfDiffProfile == 1)
\r
158 if(pStackInfo->bHidExist)
\r
160 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n"));
\r
161 algorithm = BT_8188C_2ANT_COEX_ALGO_HID;
\r
163 else if(pStackInfo->bA2dpExist)
\r
165 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n"));
\r
166 algorithm = BT_8188C_2ANT_COEX_ALGO_A2DP;
\r
168 else if(pStackInfo->bPanExist)
\r
170 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN only\n"));
\r
171 algorithm = BT_8188C_2ANT_COEX_ALGO_PAN;
\r
176 if( pStackInfo->bHidExist &&
\r
177 pStackInfo->bA2dpExist )
\r
179 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n"));
\r
180 algorithm = BT_8188C_2ANT_COEX_ALGO_HID_A2DP;
\r
182 else if( pStackInfo->bHidExist &&
\r
183 pStackInfo->bPanExist )
\r
185 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN\n"));
\r
186 algorithm = BT_8188C_2ANT_COEX_ALGO_HID_PAN;
\r
188 else if( pStackInfo->bPanExist &&
\r
189 pStackInfo->bA2dpExist )
\r
191 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN + A2DP\n"));
\r
192 algorithm = BT_8188C_2ANT_COEX_ALGO_PAN_A2DP;
\r
200 halbtc8188c2ant_SetFwBalance(
\r
201 IN PBTC_COEXIST pBtCoexist,
\r
202 IN BOOLEAN bBalanceOn,
\r
207 u1Byte H2C_Parameter[3] ={0};
\r
211 H2C_Parameter[2] = 1;
\r
212 H2C_Parameter[1] = ms1;
\r
213 H2C_Parameter[0] = ms0;
\r
217 H2C_Parameter[2] = 0;
\r
218 H2C_Parameter[1] = 0;
\r
219 H2C_Parameter[0] = 0;
\r
222 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Balance=[%s:%dms:%dms], write 0xc=0x%x\n",
\r
223 bBalanceOn?"ON":"OFF", ms0, ms1,
\r
224 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
\r
226 pBtCoexist->fBtcFillH2c(pBtCoexist, 0xc, 3, H2C_Parameter);
\r
230 halbtc8188c2ant_Balance(
\r
231 IN PBTC_COEXIST pBtCoexist,
\r
232 IN BOOLEAN bForceExec,
\r
233 IN BOOLEAN bBalanceOn,
\r
238 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Balance %s\n",
\r
239 (bForceExec? "force to":""), (bBalanceOn? "ON":"OFF")));
\r
240 pCoexDm->bCurBalanceOn = bBalanceOn;
\r
244 if(pCoexDm->bPreBalanceOn == pCoexDm->bCurBalanceOn)
\r
247 halbtc8188c2ant_SetFwBalance(pBtCoexist, bBalanceOn, ms0, ms1);
\r
249 pCoexDm->bPreBalanceOn = pCoexDm->bCurBalanceOn;
\r
253 halbtc8188c2ant_SetFwDiminishWifi(
\r
254 IN PBTC_COEXIST pBtCoexist,
\r
256 IN BOOLEAN bInterruptOn,
\r
257 IN u1Byte fwDacSwingLvl,
\r
261 u1Byte H2C_Parameter[3] ={0};
\r
263 if((pBtCoexist->stackInfo.minBtRssi <= -5) && (fwDacSwingLvl == 0x20))
\r
265 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], DiminishWiFi 0x20 original, but set 0x18 for Low RSSI!\n"));
\r
266 fwDacSwingLvl = 0x18;
\r
269 H2C_Parameter[2] = 0;
\r
270 H2C_Parameter[1] = fwDacSwingLvl;
\r
271 H2C_Parameter[0] = 0;
\r
274 H2C_Parameter[2] |= 0x01; //BIT0
\r
277 H2C_Parameter[2] |= 0x02; //BIT1
\r
282 H2C_Parameter[2] |= 0x08; //BIT3
\r
285 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bDacOn=%s, bInterruptOn=%s, bNavOn=%s, write 0xe=0x%x\n",
\r
286 (bDacOn?"ON":"OFF"), (bInterruptOn?"ON":"OFF"), (bNavOn?"ON":"OFF"),
\r
287 (H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])));
\r
288 pBtCoexist->fBtcFillH2c(pBtCoexist, 0xe, 3, H2C_Parameter);
\r
292 halbtc8188c2ant_DiminishWifi(
\r
293 IN PBTC_COEXIST pBtCoexist,
\r
294 IN BOOLEAN bForceExec,
\r
296 IN BOOLEAN bInterruptOn,
\r
297 IN u1Byte fwDacSwingLvl,
\r
301 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set Diminish Wifi, bDacOn=%s, bInterruptOn=%s, fwDacSwingLvl=%d, bNavOn=%s\n",
\r
302 (bForceExec? "force to":""), (bDacOn? "ON":"OFF"), (bInterruptOn? "ON":"OFF"), fwDacSwingLvl, (bNavOn? "ON":"OFF")));
\r
304 pCoexDm->bCurDacOn = bDacOn;
\r
305 pCoexDm->bCurInterruptOn = bInterruptOn;
\r
306 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
\r
307 pCoexDm->bCurNavOn = bNavOn;
\r
311 if( (pCoexDm->bPreDacOn==pCoexDm->bCurDacOn) &&
\r
312 (pCoexDm->bPreInterruptOn==pCoexDm->bCurInterruptOn) &&
\r
313 (pCoexDm->preFwDacSwingLvl==pCoexDm->curFwDacSwingLvl) &&
\r
314 (pCoexDm->bPreNavOn==pCoexDm->bCurNavOn) )
\r
317 halbtc8188c2ant_SetFwDiminishWifi(pBtCoexist, bDacOn, bInterruptOn, fwDacSwingLvl, bNavOn);
\r
319 pCoexDm->bPreDacOn = pCoexDm->bCurDacOn;
\r
320 pCoexDm->bPreInterruptOn = pCoexDm->bCurInterruptOn;
\r
321 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
\r
322 pCoexDm->bPreNavOn = pCoexDm->bCurNavOn;
\r
326 halbtc8188c2ant_SetSwRfRxLpfCorner(
\r
327 IN PBTC_COEXIST pBtCoexist,
\r
328 IN BOOLEAN bRxRfShrinkOn
\r
333 //Shrink RF Rx LPF corner
\r
334 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
\r
335 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0, 0xf);
\r
339 //Resume RF Rx LPF corner
\r
340 // After initialized, we can use pCoexDm->btRf0x1eBackup
\r
341 if(pBtCoexist->bInitilized)
\r
343 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
\r
344 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0, pCoexDm->btRf0x1eBackup);
\r
350 halbtc8188c2ant_RfShrink(
\r
351 IN PBTC_COEXIST pBtCoexist,
\r
352 IN BOOLEAN bForceExec,
\r
353 IN BOOLEAN bRxRfShrinkOn
\r
356 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
\r
357 (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
\r
358 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
\r
362 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
\r
365 halbtc8188c2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
\r
367 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
\r
371 halbtc8188c2ant_SetSwPenaltyTxRateAdaptive(
\r
372 IN PBTC_COEXIST pBtCoexist,
\r
373 IN BOOLEAN bLowPenaltyRa
\r
378 tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd);
\r
381 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
\r
386 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
\r
389 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1);
\r
393 halbtc8188c2ant_LowPenaltyRa(
\r
394 IN PBTC_COEXIST pBtCoexist,
\r
395 IN BOOLEAN bForceExec,
\r
396 IN BOOLEAN bLowPenaltyRa
\r
399 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
\r
400 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
\r
401 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
405 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
408 halbtc8188c2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
410 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
414 halbtc8188c2ant_SetSwFullTimeDacSwing(
\r
415 IN PBTC_COEXIST pBtCoexist,
\r
416 IN BOOLEAN bSwDacSwingOn,
\r
417 IN u4Byte swDacSwingLvl
\r
420 u4Byte dacSwingLvl;
\r
424 if((pBtCoexist->stackInfo.minBtRssi <= -5) && (swDacSwingLvl == 0x20))
\r
426 dacSwingLvl = 0x18;
\r
430 dacSwingLvl = swDacSwingLvl;
\r
432 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, dacSwingLvl);
\r
436 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, 0x30);
\r
441 halbtc8188c2ant_DacSwing(
\r
442 IN PBTC_COEXIST pBtCoexist,
\r
443 IN BOOLEAN bForceExec,
\r
444 IN BOOLEAN bDacSwingOn,
\r
445 IN u4Byte dacSwingLvl
\r
448 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
\r
449 (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
\r
450 pCoexDm->bCurDacSwingOn = bDacSwingOn;
\r
451 pCoexDm->curDacSwingLvl = dacSwingLvl;
\r
455 if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
\r
456 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
\r
460 halbtc8188c2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
\r
462 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
\r
463 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
\r
467 halbtc8188c2ant_SetAdcBackOff(
\r
468 IN PBTC_COEXIST pBtCoexist,
\r
469 IN BOOLEAN bAdcBackOff
\r
474 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n"));
\r
475 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a07611);
\r
479 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n"));
\r
480 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a05611);
\r
485 halbtc8188c2ant_AdcBackOff(
\r
486 IN PBTC_COEXIST pBtCoexist,
\r
487 IN BOOLEAN bForceExec,
\r
488 IN BOOLEAN bAdcBackOff
\r
491 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n",
\r
492 (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));
\r
493 pCoexDm->bCurAdcBackOff = bAdcBackOff;
\r
497 if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff)
\r
500 halbtc8188c2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
\r
502 pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
\r
506 halbtc8188c2ant_SetAgcTable(
\r
507 IN PBTC_COEXIST pBtCoexist,
\r
508 IN BOOLEAN bAgcTableEn
\r
511 u1Byte rssiAdjustVal=0;
\r
515 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n"));
\r
516 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4e1c0001);
\r
517 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4d1d0001);
\r
518 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4c1e0001);
\r
519 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4b1f0001);
\r
520 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4a200001);
\r
522 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xdc000);
\r
523 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x90000);
\r
524 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x51000);
\r
525 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x12000);
\r
526 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x00255);
\r
530 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n"));
\r
531 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x641c0001);
\r
532 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x631d0001);
\r
533 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x621e0001);
\r
534 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x611f0001);
\r
535 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x60200001);
\r
537 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x32000);
\r
538 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x71000);
\r
539 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xb0000);
\r
540 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xfc000);
\r
541 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x10255);
\r
544 // set rssiAdjustVal for wifi module.
\r
545 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
\r
550 halbtc8188c2ant_AgcTable(
\r
551 IN PBTC_COEXIST pBtCoexist,
\r
552 IN BOOLEAN bForceExec,
\r
553 IN BOOLEAN bAgcTableEn
\r
556 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n",
\r
557 (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));
\r
558 pCoexDm->bCurAgcTableEn = bAgcTableEn;
\r
562 if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
\r
565 halbtc8188c2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
\r
567 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
\r
571 halbtc8188c2ant_SetCoexTable(
\r
572 IN PBTC_COEXIST pBtCoexist,
\r
573 IN u4Byte val0x6c4,
\r
574 IN u4Byte val0x6c8,
\r
578 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
\r
579 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
\r
581 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
582 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
584 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
585 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
589 halbtc8188c2ant_CoexTable(
\r
590 IN PBTC_COEXIST pBtCoexist,
\r
591 IN BOOLEAN bForceExec,
\r
592 IN u4Byte val0x6c4,
\r
593 IN u4Byte val0x6c8,
\r
597 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
\r
598 (bForceExec? "force to":""), val0x6c4, val0x6c8, val0x6cc));
\r
599 pCoexDm->curVal0x6c4 = val0x6c4;
\r
600 pCoexDm->curVal0x6c8 = val0x6c8;
\r
601 pCoexDm->curVal0x6cc = val0x6cc;
\r
605 if( (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
\r
606 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
607 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
610 halbtc8188c2ant_SetCoexTable(pBtCoexist, val0x6c4, val0x6c8, val0x6cc);
\r
612 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
\r
613 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
614 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
618 halbtc8188c2ant_CoexAllOff(
\r
619 IN PBTC_COEXIST pBtCoexist
\r
623 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
624 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
627 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
628 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
629 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
632 halbtc8188c2ant_InitCoexDm(
\r
633 IN PBTC_COEXIST pBtCoexist
\r
640 halbtc8188c2ant_MonitorBtState(
\r
641 IN PBTC_COEXIST pBtCoexist
\r
644 BOOLEAN stateChange=FALSE;
\r
645 u4Byte BT_Polling, Ratio_Act, Ratio_STA;
\r
646 u4Byte BT_Active, BT_State;
\r
647 u4Byte regBTActive=0, regBTState=0, regBTPolling=0;
\r
648 u4Byte btBusyThresh=0;
\r
650 static BOOLEAN bBtBusyTraffic=FALSE;
\r
651 BOOLEAN bRejApAggPkt=FALSE;
\r
653 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
654 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FirmwareVersion = 0x%x(%d)\n", fwVer, fwVer));
\r
657 regBTActive = 0x488;
\r
658 regBTState = 0x48c;
\r
659 regBTPolling = 0x490;
\r
663 regBTActive = 0x444;
\r
664 regBTState = 0x448;
\r
666 regBTPolling = 0x44c;
\r
668 regBTPolling = 0x700;
\r
672 BT_Active = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTActive);
\r
673 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT_Active(0x%x)=0x%x\n", regBTActive, BT_Active));
\r
674 BT_Active = BT_Active & 0x00ffffff;
\r
676 BT_State = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTState);
\r
677 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT_State(0x%x)=0x%x\n", regBTState, BT_State));
\r
678 BT_State = BT_State & 0x00ffffff;
\r
680 BT_Polling = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTPolling);
\r
681 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT_Polling(0x%x)=0x%x\n", regBTPolling, BT_Polling));
\r
683 if(BT_Active==0xffffffff && BT_State==0xffffffff && BT_Polling==0xffffffff )
\r
686 // 2011/05/04 MH For Slim combo test meet a problem. Surprise remove and WLAN is running
\r
687 // DHCP process. At the same time, the register read value might be zero. And cause BSOD 0x7f
\r
688 // EXCEPTION_DIVIDED_BY_ZERO. In This case, the stack content may always be wrong due to
\r
693 Ratio_Act = BT_Active*1000/BT_Polling;
\r
694 Ratio_STA = BT_State*1000/BT_Polling;
\r
696 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ratio_Act=%d\n", Ratio_Act));
\r
697 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ratio_STA=%d\n", Ratio_STA));
\r
699 if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
701 if(Ratio_STA < 60) // BT PAN idle
\r
706 // Check if BT PAN (under BT 2.1) is uplink or downlink
\r
707 if((Ratio_Act/Ratio_STA) < 2)
\r
709 pCoexSta->bBtUplink = TRUE;
\r
712 { // BT PAN downlink
\r
713 pCoexSta->bBtUplink = FALSE;
\r
718 // Check BT is idle or not
\r
719 if(!pBtCoexist->stackInfo.bBtLinkExist)
\r
721 pCoexSta->bBtBusy = FALSE;
\r
725 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
729 pCoexSta->bBtBusy = FALSE;
\r
733 pCoexSta->bBtBusy = TRUE;
\r
736 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
738 if(Ratio_STA < btBusyThresh)
\r
740 pCoexSta->bBtBusy = FALSE;
\r
744 pCoexSta->bBtBusy = TRUE;
\r
747 if( (Ratio_STA < btBusyThresh) ||
\r
748 (Ratio_Act<180 && Ratio_STA<130) )
\r
750 pCoexSta->bA2dpBusy = FALSE;
\r
754 pCoexSta->bA2dpBusy = TRUE;
\r
759 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &pCoexSta->bBtBusy);
\r
760 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &pCoexSta->bBtBusy);
\r
762 if(bBtBusyTraffic != pCoexSta->bBtBusy)
\r
763 { // BT idle or BT non-idle
\r
764 bBtBusyTraffic = pCoexSta->bBtBusy;
\r
765 stateChange = TRUE;
\r
770 if(!pCoexSta->bBtBusy)
\r
772 halbtc8188c2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
\r
773 halbtc8188c2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r
774 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
775 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
779 halbtc8188c2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
\r
780 halbtc8188c2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE);
\r
786 bRejApAggPkt = pCoexSta->bBtBusy;
\r
787 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejApAggPkt);
\r
788 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
\r
793 halbtc8188c2ant_ActionA2dpBc4(
\r
794 IN PBTC_COEXIST pBtCoexist
\r
797 u1Byte wifiRssiState;
\r
798 u4Byte wifiBw, wifiTrafficDir;
\r
800 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
801 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
802 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
804 if(pCoexSta->bBtBusy)
\r
806 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
808 // fw mechanism first
\r
809 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
811 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18);
\r
812 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);
\r
814 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
816 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
817 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
821 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
822 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
823 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
827 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
829 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
831 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18);
\r
832 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);
\r
834 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
836 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
837 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
841 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
842 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
844 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
845 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
846 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
850 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
851 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
852 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
858 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
863 halbtc8188c2ant_ActionA2dpBc8(
\r
864 IN PBTC_COEXIST pBtCoexist
\r
867 u1Byte wifiRssiState;
\r
868 u4Byte wifiBw, wifiTrafficDir;
\r
869 BOOLEAN bWifiBusy=FALSE;
\r
871 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
872 if(pCoexSta->bA2dpBusy && bWifiBusy)
\r
874 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
875 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
876 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
878 // fw mechanism first
\r
879 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
881 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18);
\r
882 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
884 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
886 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x18);
\r
887 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
891 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
893 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
894 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
895 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
899 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
900 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
902 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
903 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
904 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
908 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
909 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
910 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
914 else if(pCoexSta->bA2dpBusy)
\r
916 // fw mechanism first
\r
917 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
918 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, TRUE, 0x18, FALSE);
\r
921 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
922 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
923 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
927 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
932 halbtc8188c2ant_ActionA2dp(
\r
933 IN PBTC_COEXIST pBtCoexist
\r
936 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
938 halbtc8188c2ant_ActionA2dpBc4(pBtCoexist);
\r
940 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
942 halbtc8188c2ant_ActionA2dpBc8(pBtCoexist);
\r
947 halbtc8188c2ant_ActionPanBc4(
\r
948 IN PBTC_COEXIST pBtCoexist
\r
951 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
953 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
954 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
955 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
958 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
959 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
963 if(pCoexSta->bBtBusy && bWifiBusy)
\r
965 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10);
\r
966 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
970 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
971 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
975 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
976 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
977 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
981 halbtc8188c2ant_ActionPanBc8(
\r
982 IN PBTC_COEXIST pBtCoexist
\r
985 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
986 u1Byte wifiRssiState;
\r
987 u4Byte wifiBw, wifiTrafficDir;
\r
990 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
991 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
992 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
993 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
994 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
998 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1002 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 3, 25, 50);
\r
1004 if(pCoexSta->bBtBusy && bWifiBusy)
\r
1006 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1007 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1009 // fw mechanism first
\r
1010 if(pCoexSta->bBtUplink)
\r
1012 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20);
\r
1013 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1017 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1018 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1021 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1023 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1027 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1029 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1030 if(pCoexSta->bBtUplink)
\r
1032 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1036 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
1039 else if( (wifiRssiState == BTC_RSSI_STATE_MEDIUM) ||
\r
1040 (wifiRssiState == BTC_RSSI_STATE_STAY_MEDIUM) )
\r
1042 // fw mechanism first
\r
1043 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20);
\r
1045 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1047 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1049 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1051 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1052 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON);
\r
1054 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1057 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1059 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1063 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1065 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1066 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1070 // fw mechanism first
\r
1071 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20);
\r
1073 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1075 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1077 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1079 if(pCoexSta->bBtUplink)
\r
1081 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1083 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON);
\r
1087 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1092 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1096 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1097 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1098 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1101 else if(pCoexSta->bBtBusy && !bWifiBusy && (wifiRssi < 30))
\r
1103 // fw mechanism first
\r
1104 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x0a, 0x20);
\r
1105 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1107 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1108 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1109 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1113 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1119 halbtc8188c2ant_ActionPan(
\r
1120 IN PBTC_COEXIST pBtCoexist
\r
1123 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1125 halbtc8188c2ant_ActionPanBc4(pBtCoexist);
\r
1127 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1129 halbtc8188c2ant_ActionPanBc8(pBtCoexist);
\r
1134 halbtc8188c2ant_ActionHid(
\r
1135 IN PBTC_COEXIST pBtCoexist
\r
1138 u4Byte wifiBw, wifiTrafficDir;
\r
1139 BOOLEAN bWifiBusy=FALSE;
\r
1141 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1142 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1143 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1144 if(BTC_WIFI_BW_LEGACY == wifiBw)
\r
1146 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1147 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1149 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1150 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1152 else if(!bWifiBusy)
\r
1154 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1155 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1156 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1158 else if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1160 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1161 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1163 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1164 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1166 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1168 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1169 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1170 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1173 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1174 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1175 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1180 halbtc8188c2ant_ActionSco(
\r
1181 IN PBTC_COEXIST pBtCoexist
\r
1184 u1Byte wifiRssiState;
\r
1187 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1189 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1192 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1193 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1196 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1197 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1198 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1200 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1202 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1203 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1205 // fw mechanism first
\r
1206 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1207 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1210 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1211 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1212 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1216 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
1217 // fw mechanism first
\r
1218 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1219 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1222 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1223 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1225 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1226 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1227 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1231 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1232 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1233 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1240 halbtc8188c2ant_ActionHidA2dpBc4(
\r
1241 IN PBTC_COEXIST pBtCoexist
\r
1244 u1Byte wifiRssiState;
\r
1245 u4Byte wifiBw, wifiTrafficDir;
\r
1247 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1248 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1250 if(pCoexSta->bBtBusy)
\r
1252 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1254 // fw mechanism first
\r
1255 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1257 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x7, 0x20);
\r
1258 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);
\r
1260 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1262 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1263 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1267 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1268 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1269 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1273 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
1274 // fw mechanism first
\r
1275 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1277 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x7, 0x20);
\r
1278 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);
\r
1280 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1282 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1283 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1287 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1288 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1290 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1291 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1292 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1296 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1297 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1298 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1304 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1308 halbtc8188c2ant_ActionHidA2dpBc8(
\r
1309 IN PBTC_COEXIST pBtCoexist
\r
1312 u1Byte wifiRssiState;
\r
1315 if(pCoexSta->bBtBusy)
\r
1317 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1318 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1320 // fw mechanism first
\r
1321 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1322 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1325 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1326 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1327 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1331 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
1333 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1334 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1337 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1338 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1340 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1341 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1342 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1346 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1347 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1348 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1354 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1359 halbtc8188c2ant_ActionHidA2dp(
\r
1360 IN PBTC_COEXIST pBtCoexist
\r
1363 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1365 halbtc8188c2ant_ActionHidA2dpBc4(pBtCoexist);
\r
1367 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1369 halbtc8188c2ant_ActionHidA2dpBc8(pBtCoexist);
\r
1374 halbtc8188c2ant_ActionHidPanBc4(
\r
1375 IN PBTC_COEXIST pBtCoexist
\r
1378 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1379 u4Byte wifiBw, wifiTrafficDir;
\r
1381 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1385 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1386 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1388 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1389 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1393 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1394 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1395 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1396 if(BTC_WIFI_BW_LEGACY == wifiBw)
\r
1398 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1399 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1401 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1402 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1404 else if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1406 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1407 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1409 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1410 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1412 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1414 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1415 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10);
\r
1416 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1418 else if(!bWifiBusy)
\r
1420 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1421 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1422 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1425 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1426 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1427 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1430 halbtc8188c2ant_ActionHidPanBc8(
\r
1431 IN PBTC_COEXIST pBtCoexist
\r
1434 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1435 u1Byte wifiRssiState;
\r
1436 u4Byte wifiBw, wifiTrafficDir;
\r
1438 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1442 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1443 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
\r
1444 if((pCoexSta->bBtBusy && bWifiBusy))
\r
1446 // fw mechanism first
\r
1447 if(pCoexSta->bBtUplink)
\r
1449 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20);
\r
1453 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20);
\r
1455 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1458 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1459 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1461 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1462 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1464 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1465 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1466 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1470 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1471 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1472 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1477 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1478 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1479 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1484 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1489 if(BTC_INTF_USB == pBtCoexist->chipInterface)
\r
1491 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1492 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1494 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1495 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1497 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1498 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1499 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1501 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1503 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1508 if(pCoexSta->bBtBusy)
\r
1511 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1512 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1515 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1516 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1517 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
1521 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1528 halbtc8188c2ant_ActionHidPan(
\r
1529 IN PBTC_COEXIST pBtCoexist
\r
1532 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1534 halbtc8188c2ant_ActionHidPanBc4(pBtCoexist);
\r
1536 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1538 halbtc8188c2ant_ActionHidPanBc8(pBtCoexist);
\r
1543 halbtc8188c2ant_ActionPanA2dpBc4(
\r
1544 IN PBTC_COEXIST pBtCoexist
\r
1547 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1548 u1Byte wifiRssiState;
\r
1550 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1552 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1555 if(pCoexSta->bBtBusy)
\r
1558 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1559 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1562 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1563 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1564 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
1568 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1573 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1574 if(pCoexSta->bBtBusy && bWifiBusy)
\r
1576 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10);
\r
1577 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1581 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1582 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1585 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1586 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1587 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1591 halbtc8188c2ant_ActionPanA2dpBc8(
\r
1592 IN PBTC_COEXIST pBtCoexist
\r
1595 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1596 u1Byte wifiRssiState;
\r
1599 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1603 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1604 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
\r
1605 if((pCoexSta->bBtBusy && bWifiBusy))
\r
1607 // fw mechanism first
\r
1608 if(pCoexSta->bBtUplink)
\r
1610 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20);
\r
1614 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20);
\r
1616 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1619 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1620 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1622 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1623 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1625 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1626 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1627 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1631 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1632 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1633 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1638 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1639 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1640 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1645 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1650 if(pCoexSta->bBtBusy)
\r
1653 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1654 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1657 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1658 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1659 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
1663 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1669 halbtc8188c2ant_ActionPanA2dp(
\r
1670 IN PBTC_COEXIST pBtCoexist
\r
1673 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1675 halbtc8188c2ant_ActionPanA2dpBc4(pBtCoexist);
\r
1677 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1679 halbtc8188c2ant_ActionPanA2dpBc8(pBtCoexist);
\r
1683 //============================================================
\r
1684 // extern function start with EXhalbtc8188c2ant_
\r
1685 //============================================================
\r
1687 EXhalbtc8188c2ant_PowerOnSetting(
\r
1688 IN PBTC_COEXIST pBtCoexist
\r
1694 EXhalbtc8188c2ant_InitHwConfig(
\r
1695 IN PBTC_COEXIST pBtCoexist,
\r
1696 IN BOOLEAN bWifiOnly
\r
1701 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n"));
\r
1703 // backup rf 0x1e value
\r
1704 pCoexDm->btRf0x1eBackup =
\r
1705 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0);
\r
1707 if( (BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) ||
\r
1708 (BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) )
\r
1710 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd) & BIT0;
\r
1711 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, u1Tmp);
\r
1713 halbtc8188c2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0xaaaa9aaa, 0xffbd0040, 0x40000010);
\r
1718 EXhalbtc8188c2ant_InitCoexDm(
\r
1719 IN PBTC_COEXIST pBtCoexist
\r
1722 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
1724 halbtc8188c2ant_InitCoexDm(pBtCoexist);
\r
1728 EXhalbtc8188c2ant_DisplayCoexInfo(
\r
1729 IN PBTC_COEXIST pBtCoexist
\r
1732 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1733 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
1734 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
1735 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
1738 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
1739 CL_PRINTF(cliBuf);
\r
1741 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
\r
1742 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
\r
1743 CL_PRINTF(cliBuf);
\r
1745 if(pBtCoexist->bManualControl)
\r
1747 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!");
\r
1748 CL_PRINTF(cliBuf);
\r
1751 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
1752 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
1753 CL_PRINTF(cliBuf);
\r
1756 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
\r
1757 CL_PRINTF(cliBuf);
\r
1758 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
\r
1760 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
\r
1761 CL_PRINTF(cliBuf);
\r
1763 if(pStackInfo->bProfileNotified)
\r
1765 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
1766 pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist);
\r
1767 CL_PRINTF(cliBuf);
\r
1769 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
1773 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
1774 CL_PRINTF(cliBuf);
\r
1775 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
\r
1776 pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
\r
1777 CL_PRINTF(cliBuf);
\r
1780 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
1781 CL_PRINTF(cliBuf);
\r
1784 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
1785 CL_PRINTF(cliBuf);
\r
1787 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
\r
1788 pCoexDm->btRf0x1eBackup);
\r
1789 CL_PRINTF(cliBuf);
\r
1791 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
1792 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \
\r
1794 CL_PRINTF(cliBuf);
\r
1796 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
1797 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
\r
1799 CL_PRINTF(cliBuf);
\r
1801 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
1802 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
1803 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc);
\r
1804 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c4/0x6c8/0x6cc(coexTable)", \
\r
1805 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
\r
1806 CL_PRINTF(cliBuf);
\r
1808 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
1813 EXhalbtc8188c2ant_IpsNotify(
\r
1814 IN PBTC_COEXIST pBtCoexist,
\r
1818 if(BTC_IPS_ENTER == type)
\r
1820 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n"));
\r
1821 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1823 else if(BTC_IPS_LEAVE == type)
\r
1825 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n"));
\r
1826 //halbtc8188c2ant_InitCoexDm(pBtCoexist);
\r
1831 EXhalbtc8188c2ant_LpsNotify(
\r
1832 IN PBTC_COEXIST pBtCoexist,
\r
1836 if(BTC_LPS_ENABLE == type)
\r
1838 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n"));
\r
1839 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1841 else if(BTC_LPS_DISABLE == type)
\r
1843 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n"));
\r
1844 halbtc8188c2ant_InitCoexDm(pBtCoexist);
\r
1849 EXhalbtc8188c2ant_ScanNotify(
\r
1850 IN PBTC_COEXIST pBtCoexist,
\r
1854 if(BTC_SCAN_START == type)
\r
1856 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));
\r
1858 else if(BTC_SCAN_FINISH == type)
\r
1860 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));
\r
1865 EXhalbtc8188c2ant_ConnectNotify(
\r
1866 IN PBTC_COEXIST pBtCoexist,
\r
1870 if(BTC_ASSOCIATE_START == type)
\r
1872 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));
\r
1874 else if(BTC_ASSOCIATE_FINISH == type)
\r
1876 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));
\r
1881 EXhalbtc8188c2ant_MediaStatusNotify(
\r
1882 IN PBTC_COEXIST pBtCoexist,
\r
1886 if(BTC_MEDIA_CONNECT == type)
\r
1888 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n"));
\r
1892 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n"));
\r
1898 EXhalbtc8188c2ant_SpecialPacketNotify(
\r
1899 IN PBTC_COEXIST pBtCoexist,
\r
1903 if(type == BTC_PACKET_DHCP)
\r
1905 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n"));
\r
1910 EXhalbtc8188c2ant_BtInfoNotify(
\r
1911 IN PBTC_COEXIST pBtCoexist,
\r
1912 IN pu1Byte tmpBuf,
\r
1919 EXhalbtc8188c2ant_HaltNotify(
\r
1920 IN PBTC_COEXIST pBtCoexist
\r
1923 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n"));
\r
1925 EXhalbtc8188c2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
1929 EXhalbtc8188c2ant_Periodical(
\r
1930 IN PBTC_COEXIST pBtCoexist
\r
1935 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Periodical!!\n"));
\r
1938 // sw mechanism must be done after fw mechanism
\r
1941 if((BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) ||
\r
1942 (BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) )
\r
1944 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_GET_BT_RSSI, NULL);
\r
1946 halbtc8188c2ant_MonitorBtState(pBtCoexist);
\r
1947 algorithm = halbtc8188c2ant_ActionAlgorithm(pBtCoexist);
\r
1948 pCoexDm->curAlgorithm = algorithm;
\r
1949 switch(pCoexDm->curAlgorithm)
\r
1951 case BT_8188C_2ANT_COEX_ALGO_SCO:
\r
1952 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO\n"));
\r
1953 halbtc8188c2ant_ActionSco(pBtCoexist);
\r
1955 case BT_8188C_2ANT_COEX_ALGO_HID:
\r
1956 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID\n"));
\r
1957 halbtc8188c2ant_ActionHid(pBtCoexist);
\r
1959 case BT_8188C_2ANT_COEX_ALGO_A2DP:
\r
1960 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP\n"));
\r
1961 halbtc8188c2ant_ActionA2dp(pBtCoexist);
\r
1963 case BT_8188C_2ANT_COEX_ALGO_PAN:
\r
1964 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN\n"));
\r
1965 halbtc8188c2ant_ActionPan(pBtCoexist);
\r
1967 case BT_8188C_2ANT_COEX_ALGO_HID_A2DP:
\r
1968 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP\n"));
\r
1969 halbtc8188c2ant_ActionHidA2dp(pBtCoexist);
\r
1971 case BT_8188C_2ANT_COEX_ALGO_HID_PAN:
\r
1972 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+HID\n"));
\r
1973 halbtc8188c2ant_ActionHidPan(pBtCoexist);
\r
1975 case BT_8188C_2ANT_COEX_ALGO_PAN_A2DP:
\r
1976 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP\n"));
\r
1977 halbtc8188c2ant_ActionPanA2dp(pBtCoexist);
\r