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
14 #if(BT_30_SUPPORT == 1)
\r
15 //============================================================
\r
16 // Global variables, these are static variables
\r
17 //============================================================
\r
18 static COEX_DM_8188C_2ANT GLCoexDm8188c2Ant;
\r
19 static PCOEX_DM_8188C_2ANT pCoexDm=&GLCoexDm8188c2Ant;
\r
20 static COEX_STA_8188C_2ANT GLCoexSta8188c2Ant;
\r
21 static PCOEX_STA_8188C_2ANT pCoexSta=&GLCoexSta8188c2Ant;
\r
23 //============================================================
\r
24 // local function start with btdm_
\r
25 //============================================================
\r
27 halbtc8188c2ant_WifiRssiState(
\r
28 IN PBTC_COEXIST pBtCoexist,
\r
31 IN u1Byte rssiThresh,
\r
32 IN u1Byte rssiThresh1
\r
36 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
\r
38 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
42 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
43 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
45 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT))
\r
47 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
48 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
52 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
53 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
58 if(wifiRssi < rssiThresh)
\r
60 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
61 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
65 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
66 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
70 else if(levelNum == 3)
\r
72 if(rssiThresh > rssiThresh1)
\r
74 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
\r
75 return pCoexSta->preWifiRssiState[index];
\r
78 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
\r
79 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
\r
81 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT))
\r
83 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
84 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
88 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
\r
89 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
\r
92 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
\r
93 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
\r
95 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT))
\r
97 wifiRssiState = BTC_RSSI_STATE_HIGH;
\r
98 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
\r
100 else if(wifiRssi < rssiThresh)
\r
102 wifiRssiState = BTC_RSSI_STATE_LOW;
\r
103 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
\r
107 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
\r
108 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
\r
113 if(wifiRssi < rssiThresh1)
\r
115 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
\r
116 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
\r
120 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
\r
121 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
\r
126 pCoexSta->preWifiRssiState[index] = wifiRssiState;
\r
128 return wifiRssiState;
\r
132 halbtc8188c2ant_ActionAlgorithm(
\r
133 IN PBTC_COEXIST pBtCoexist
\r
136 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
137 u1Byte algorithm=BT_8188C_2ANT_COEX_ALGO_UNDEFINED;
\r
138 u1Byte numOfDiffProfile=0;
\r
140 if(!pStackInfo->bBtLinkExist)
\r
142 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No profile exists!!!\n"));
\r
146 if(pStackInfo->bScoExist)
\r
147 numOfDiffProfile++;
\r
148 if(pStackInfo->bHidExist)
\r
149 numOfDiffProfile++;
\r
150 if(pStackInfo->bPanExist)
\r
151 numOfDiffProfile++;
\r
152 if(pStackInfo->bA2dpExist)
\r
153 numOfDiffProfile++;
\r
155 if(pStackInfo->bScoExist)
\r
157 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO algorithm\n"));
\r
158 algorithm = BT_8188C_2ANT_COEX_ALGO_SCO;
\r
162 if(numOfDiffProfile == 1)
\r
164 if(pStackInfo->bHidExist)
\r
166 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
\r
167 algorithm = BT_8188C_2ANT_COEX_ALGO_HID;
\r
169 else if(pStackInfo->bA2dpExist)
\r
171 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
\r
172 algorithm = BT_8188C_2ANT_COEX_ALGO_A2DP;
\r
174 else if(pStackInfo->bPanExist)
\r
176 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN only\n"));
\r
177 algorithm = BT_8188C_2ANT_COEX_ALGO_PAN;
\r
182 if( pStackInfo->bHidExist &&
\r
183 pStackInfo->bA2dpExist )
\r
185 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
\r
186 algorithm = BT_8188C_2ANT_COEX_ALGO_HID_A2DP;
\r
188 else if( pStackInfo->bHidExist &&
\r
189 pStackInfo->bPanExist )
\r
191 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN\n"));
\r
192 algorithm = BT_8188C_2ANT_COEX_ALGO_HID_PAN;
\r
194 else if( pStackInfo->bPanExist &&
\r
195 pStackInfo->bA2dpExist )
\r
197 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN + A2DP\n"));
\r
198 algorithm = BT_8188C_2ANT_COEX_ALGO_PAN_A2DP;
\r
206 halbtc8188c2ant_SetFwBalance(
\r
207 IN PBTC_COEXIST pBtCoexist,
\r
208 IN BOOLEAN bBalanceOn,
\r
213 u1Byte H2C_Parameter[3] ={0};
\r
217 H2C_Parameter[2] = 1;
\r
218 H2C_Parameter[1] = ms1;
\r
219 H2C_Parameter[0] = ms0;
\r
223 H2C_Parameter[2] = 0;
\r
224 H2C_Parameter[1] = 0;
\r
225 H2C_Parameter[0] = 0;
\r
228 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Balance=[%s:%dms:%dms], write 0xc=0x%x\n",
\r
229 bBalanceOn?"ON":"OFF", ms0, ms1,
\r
230 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
\r
232 pBtCoexist->fBtcFillH2c(pBtCoexist, 0xc, 3, H2C_Parameter);
\r
236 halbtc8188c2ant_Balance(
\r
237 IN PBTC_COEXIST pBtCoexist,
\r
238 IN BOOLEAN bForceExec,
\r
239 IN BOOLEAN bBalanceOn,
\r
244 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Balance %s\n",
\r
245 (bForceExec? "force to":""), (bBalanceOn? "ON":"OFF")));
\r
246 pCoexDm->bCurBalanceOn = bBalanceOn;
\r
250 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBalanceOn = %d, bCurBalanceOn = %d!!\n",
\r
251 pCoexDm->bPreBalanceOn, pCoexDm->bCurBalanceOn));
\r
253 if(pCoexDm->bPreBalanceOn == pCoexDm->bCurBalanceOn)
\r
256 halbtc8188c2ant_SetFwBalance(pBtCoexist, bBalanceOn, ms0, ms1);
\r
258 pCoexDm->bPreBalanceOn = pCoexDm->bCurBalanceOn;
\r
262 halbtc8188c2ant_SetFwDiminishWifi(
\r
263 IN PBTC_COEXIST pBtCoexist,
\r
265 IN BOOLEAN bInterruptOn,
\r
266 IN u1Byte fwDacSwingLvl,
\r
270 u1Byte H2C_Parameter[3] ={0};
\r
272 if((pBtCoexist->stackInfo.minBtRssi <= -5) && (fwDacSwingLvl == 0x20))
\r
274 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], DiminishWiFi 0x20 original, but set 0x18 for Low RSSI!\n"));
\r
275 fwDacSwingLvl = 0x18;
\r
278 H2C_Parameter[2] = 0;
\r
279 H2C_Parameter[1] = fwDacSwingLvl;
\r
280 H2C_Parameter[0] = 0;
\r
283 H2C_Parameter[2] |= 0x01; //BIT0
\r
286 H2C_Parameter[2] |= 0x02; //BIT1
\r
291 H2C_Parameter[2] |= 0x08; //BIT3
\r
294 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], bDacOn=%s, bInterruptOn=%s, bNavOn=%s, write 0xe=0x%x\n",
\r
295 (bDacOn?"ON":"OFF"), (bInterruptOn?"ON":"OFF"), (bNavOn?"ON":"OFF"),
\r
296 (H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])));
\r
297 pBtCoexist->fBtcFillH2c(pBtCoexist, 0xe, 3, H2C_Parameter);
\r
301 halbtc8188c2ant_DiminishWifi(
\r
302 IN PBTC_COEXIST pBtCoexist,
\r
303 IN BOOLEAN bForceExec,
\r
305 IN BOOLEAN bInterruptOn,
\r
306 IN u1Byte fwDacSwingLvl,
\r
310 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set Diminish Wifi, bDacOn=%s, bInterruptOn=%s, fwDacSwingLvl=%d, bNavOn=%s\n",
\r
311 (bForceExec? "force to":""), (bDacOn? "ON":"OFF"), (bInterruptOn? "ON":"OFF"), fwDacSwingLvl, (bNavOn? "ON":"OFF")));
\r
313 pCoexDm->bCurDacOn = bDacOn;
\r
314 pCoexDm->bCurInterruptOn = bInterruptOn;
\r
315 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
\r
316 pCoexDm->bCurNavOn = bNavOn;
\r
320 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreDacOn=%d, bCurDacOn=%d!!\n",
\r
321 pCoexDm->bPreDacOn, pCoexDm->bCurDacOn));
\r
322 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreInterruptOn=%d, bCurInterruptOn=%d!!\n",
\r
323 pCoexDm->bPreInterruptOn, pCoexDm->bCurInterruptOn));
\r
324 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preFwDacSwingLvl=%d, curFwDacSwingLvl=%d!!\n",
\r
325 pCoexDm->preFwDacSwingLvl, pCoexDm->curFwDacSwingLvl));
\r
326 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreNavOn=%d, bCurNavOn=%d!!\n",
\r
327 pCoexDm->bPreNavOn, pCoexDm->bCurNavOn));
\r
330 if( (pCoexDm->bPreDacOn==pCoexDm->bCurDacOn) &&
\r
331 (pCoexDm->bPreInterruptOn==pCoexDm->bCurInterruptOn) &&
\r
332 (pCoexDm->preFwDacSwingLvl==pCoexDm->curFwDacSwingLvl) &&
\r
333 (pCoexDm->bPreNavOn==pCoexDm->bCurNavOn) )
\r
336 halbtc8188c2ant_SetFwDiminishWifi(pBtCoexist, bDacOn, bInterruptOn, fwDacSwingLvl, bNavOn);
\r
338 pCoexDm->bPreDacOn = pCoexDm->bCurDacOn;
\r
339 pCoexDm->bPreInterruptOn = pCoexDm->bCurInterruptOn;
\r
340 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
\r
341 pCoexDm->bPreNavOn = pCoexDm->bCurNavOn;
\r
345 halbtc8188c2ant_SetSwRfRxLpfCorner(
\r
346 IN PBTC_COEXIST pBtCoexist,
\r
347 IN BOOLEAN bRxRfShrinkOn
\r
352 //Shrink RF Rx LPF corner
\r
353 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
\r
354 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0, 0xf);
\r
358 //Resume RF Rx LPF corner
\r
359 // After initialized, we can use pCoexDm->btRf0x1eBackup
\r
360 if(pBtCoexist->bInitilized)
\r
362 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
\r
363 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0, pCoexDm->btRf0x1eBackup);
\r
369 halbtc8188c2ant_RfShrink(
\r
370 IN PBTC_COEXIST pBtCoexist,
\r
371 IN BOOLEAN bForceExec,
\r
372 IN BOOLEAN bRxRfShrinkOn
\r
375 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
\r
376 (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
\r
377 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
\r
381 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n",
\r
382 pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink));
\r
384 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
\r
387 halbtc8188c2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
\r
389 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
\r
393 halbtc8188c2ant_SetSwPenaltyTxRateAdaptive(
\r
394 IN PBTC_COEXIST pBtCoexist,
\r
395 IN BOOLEAN bLowPenaltyRa
\r
400 tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd);
\r
403 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
\r
408 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
\r
411 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1);
\r
415 halbtc8188c2ant_LowPenaltyRa(
\r
416 IN PBTC_COEXIST pBtCoexist,
\r
417 IN BOOLEAN bForceExec,
\r
418 IN BOOLEAN bLowPenaltyRa
\r
421 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
\r
422 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
\r
423 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
\r
427 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
\r
428 pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
\r
430 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
\r
433 halbtc8188c2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
\r
435 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
\r
439 halbtc8188c2ant_SetSwFullTimeDacSwing(
\r
440 IN PBTC_COEXIST pBtCoexist,
\r
441 IN BOOLEAN bSwDacSwingOn,
\r
442 IN u4Byte swDacSwingLvl
\r
445 u4Byte dacSwingLvl;
\r
449 if((pBtCoexist->stackInfo.minBtRssi <= -5) && (swDacSwingLvl == 0x20))
\r
451 dacSwingLvl = 0x18;
\r
455 dacSwingLvl = swDacSwingLvl;
\r
457 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, dacSwingLvl);
\r
461 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, 0x30);
\r
466 halbtc8188c2ant_DacSwing(
\r
467 IN PBTC_COEXIST pBtCoexist,
\r
468 IN BOOLEAN bForceExec,
\r
469 IN BOOLEAN bDacSwingOn,
\r
470 IN u4Byte dacSwingLvl
\r
473 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
\r
474 (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
\r
475 pCoexDm->bCurDacSwingOn = bDacSwingOn;
\r
476 pCoexDm->curDacSwingLvl = dacSwingLvl;
\r
480 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
\r
481 pCoexDm->bPreDacSwingOn, pCoexDm->preDacSwingLvl,
\r
482 pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl));
\r
484 if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
\r
485 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
\r
489 halbtc8188c2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
\r
491 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
\r
492 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
\r
496 halbtc8188c2ant_SetAdcBackOff(
\r
497 IN PBTC_COEXIST pBtCoexist,
\r
498 IN BOOLEAN bAdcBackOff
\r
503 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level On!\n"));
\r
504 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a07611);
\r
508 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level Off!\n"));
\r
509 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a05611);
\r
514 halbtc8188c2ant_AdcBackOff(
\r
515 IN PBTC_COEXIST pBtCoexist,
\r
516 IN BOOLEAN bForceExec,
\r
517 IN BOOLEAN bAdcBackOff
\r
520 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn AdcBackOff = %s\n",
\r
521 (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));
\r
522 pCoexDm->bCurAdcBackOff = bAdcBackOff;
\r
526 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n",
\r
527 pCoexDm->bPreAdcBackOff, pCoexDm->bCurAdcBackOff));
\r
529 if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff)
\r
532 halbtc8188c2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
\r
534 pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
\r
538 halbtc8188c2ant_SetAgcTable(
\r
539 IN PBTC_COEXIST pBtCoexist,
\r
540 IN BOOLEAN bAgcTableEn
\r
543 u1Byte rssiAdjustVal=0;
\r
547 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
\r
548 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4e1c0001);
\r
549 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4d1d0001);
\r
550 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4c1e0001);
\r
551 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4b1f0001);
\r
552 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4a200001);
\r
554 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xdc000);
\r
555 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x90000);
\r
556 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x51000);
\r
557 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x12000);
\r
558 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x00255);
\r
562 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
\r
563 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x641c0001);
\r
564 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x631d0001);
\r
565 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x621e0001);
\r
566 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x611f0001);
\r
567 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x60200001);
\r
569 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x32000);
\r
570 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x71000);
\r
571 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xb0000);
\r
572 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xfc000);
\r
573 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x10255);
\r
576 // set rssiAdjustVal for wifi module.
\r
577 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
\r
582 halbtc8188c2ant_AgcTable(
\r
583 IN PBTC_COEXIST pBtCoexist,
\r
584 IN BOOLEAN bForceExec,
\r
585 IN BOOLEAN bAgcTableEn
\r
588 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s %s Agc Table\n",
\r
589 (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));
\r
590 pCoexDm->bCurAgcTableEn = bAgcTableEn;
\r
594 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
\r
595 pCoexDm->bPreAgcTableEn, pCoexDm->bCurAgcTableEn));
\r
597 if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
\r
600 halbtc8188c2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
\r
602 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
\r
606 halbtc8188c2ant_SetCoexTable(
\r
607 IN PBTC_COEXIST pBtCoexist,
\r
608 IN u4Byte val0x6c4,
\r
609 IN u4Byte val0x6c8,
\r
613 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
\r
614 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
\r
616 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
\r
617 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
\r
619 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
\r
620 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6cc, val0x6cc);
\r
624 halbtc8188c2ant_CoexTable(
\r
625 IN PBTC_COEXIST pBtCoexist,
\r
626 IN BOOLEAN bForceExec,
\r
627 IN u4Byte val0x6c4,
\r
628 IN u4Byte val0x6c8,
\r
632 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
\r
633 (bForceExec? "force to":""), val0x6c4, val0x6c8, val0x6cc));
\r
634 pCoexDm->curVal0x6c4 = val0x6c4;
\r
635 pCoexDm->curVal0x6c8 = val0x6c8;
\r
636 pCoexDm->curVal0x6cc = val0x6cc;
\r
640 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c4=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
\r
641 pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
\r
642 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c4=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
\r
643 pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
\r
645 if( (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
\r
646 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
\r
647 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
\r
650 halbtc8188c2ant_SetCoexTable(pBtCoexist, val0x6c4, val0x6c8, val0x6cc);
\r
652 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
\r
653 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
\r
654 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
\r
658 halbtc8188c2ant_CoexAllOff(
\r
659 IN PBTC_COEXIST pBtCoexist
\r
663 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
664 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
667 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
668 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
669 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
672 halbtc8188c2ant_InitCoexDm(
\r
673 IN PBTC_COEXIST pBtCoexist
\r
680 halbtc8188c2ant_MonitorBtState(
\r
681 IN PBTC_COEXIST pBtCoexist
\r
684 BOOLEAN stateChange=FALSE;
\r
685 u4Byte BT_Polling, Ratio_Act, Ratio_STA;
\r
686 u4Byte BT_Active, BT_State;
\r
687 u4Byte regBTActive=0, regBTState=0, regBTPolling=0;
\r
688 u4Byte btBusyThresh=0;
\r
690 static BOOLEAN bBtBusyTraffic=FALSE;
\r
691 BOOLEAN bRejApAggPkt=FALSE;
\r
693 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
\r
694 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], FirmwareVersion = 0x%x(%d)\n", fwVer, fwVer));
\r
697 regBTActive = 0x488;
\r
698 regBTState = 0x48c;
\r
699 regBTPolling = 0x490;
\r
703 regBTActive = 0x444;
\r
704 regBTState = 0x448;
\r
706 regBTPolling = 0x44c;
\r
708 regBTPolling = 0x700;
\r
712 BT_Active = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTActive);
\r
713 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT_Active(0x%x)=0x%x\n", regBTActive, BT_Active));
\r
714 BT_Active = BT_Active & 0x00ffffff;
\r
716 BT_State = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTState);
\r
717 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT_State(0x%x)=0x%x\n", regBTState, BT_State));
\r
718 BT_State = BT_State & 0x00ffffff;
\r
720 BT_Polling = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTPolling);
\r
721 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT_Polling(0x%x)=0x%x\n", regBTPolling, BT_Polling));
\r
723 if(BT_Active==0xffffffff && BT_State==0xffffffff && BT_Polling==0xffffffff )
\r
726 // 2011/05/04 MH For Slim combo test meet a problem. Surprise remove and WLAN is running
\r
727 // DHCP process. At the same time, the register read value might be zero. And cause BSOD 0x7f
\r
728 // EXCEPTION_DIVIDED_BY_ZERO. In This case, the stack content may always be wrong due to
\r
733 Ratio_Act = BT_Active*1000/BT_Polling;
\r
734 Ratio_STA = BT_State*1000/BT_Polling;
\r
736 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Ratio_Act=%d\n", Ratio_Act));
\r
737 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Ratio_STA=%d\n", Ratio_STA));
\r
739 if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
741 if(Ratio_STA < 60) // BT PAN idle
\r
746 // Check if BT PAN (under BT 2.1) is uplink or downlink
\r
747 if((Ratio_Act/Ratio_STA) < 2)
\r
749 pCoexSta->bBtUplink = TRUE;
\r
752 { // BT PAN downlink
\r
753 pCoexSta->bBtUplink = FALSE;
\r
758 // Check BT is idle or not
\r
759 if(!pBtCoexist->stackInfo.bBtLinkExist)
\r
761 pCoexSta->bBtBusy = FALSE;
\r
765 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
769 pCoexSta->bBtBusy = FALSE;
\r
773 pCoexSta->bBtBusy = TRUE;
\r
776 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
778 if(Ratio_STA < btBusyThresh)
\r
780 pCoexSta->bBtBusy = FALSE;
\r
784 pCoexSta->bBtBusy = TRUE;
\r
787 if( (Ratio_STA < btBusyThresh) ||
\r
788 (Ratio_Act<180 && Ratio_STA<130) )
\r
790 pCoexSta->bA2dpBusy = FALSE;
\r
794 pCoexSta->bA2dpBusy = TRUE;
\r
799 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &pCoexSta->bBtBusy);
\r
800 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &pCoexSta->bBtBusy);
\r
802 if(bBtBusyTraffic != pCoexSta->bBtBusy)
\r
803 { // BT idle or BT non-idle
\r
804 bBtBusyTraffic = pCoexSta->bBtBusy;
\r
805 stateChange = TRUE;
\r
810 if(!pCoexSta->bBtBusy)
\r
812 halbtc8188c2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
\r
813 halbtc8188c2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
\r
814 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
815 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
819 halbtc8188c2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
\r
820 halbtc8188c2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE);
\r
826 bRejApAggPkt = pCoexSta->bBtBusy;
\r
827 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejApAggPkt);
\r
828 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
\r
833 halbtc8188c2ant_ActionA2dpBc4(
\r
834 IN PBTC_COEXIST pBtCoexist
\r
837 u1Byte wifiRssiState;
\r
838 u4Byte wifiBw, wifiTrafficDir;
\r
840 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
841 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
842 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
844 if(pCoexSta->bBtBusy)
\r
846 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
848 // fw mechanism first
\r
849 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
851 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18);
\r
852 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);
\r
854 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
856 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
857 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
861 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
862 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
863 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
867 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
869 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
871 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18);
\r
872 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);
\r
874 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
876 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
877 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
881 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
882 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
884 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
885 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
886 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
890 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
891 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
892 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
898 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
903 halbtc8188c2ant_ActionA2dpBc8(
\r
904 IN PBTC_COEXIST pBtCoexist
\r
907 u1Byte wifiRssiState;
\r
908 u4Byte wifiBw, wifiTrafficDir;
\r
909 BOOLEAN bWifiBusy=FALSE;
\r
911 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
912 if(pCoexSta->bA2dpBusy && bWifiBusy)
\r
914 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
915 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
916 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
918 // fw mechanism first
\r
919 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
921 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18);
\r
922 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
924 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
926 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x18);
\r
927 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
931 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
933 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
934 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
935 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
939 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
940 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
942 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
943 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
944 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
948 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
949 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
950 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
954 else if(pCoexSta->bA2dpBusy)
\r
956 // fw mechanism first
\r
957 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
958 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, TRUE, 0x18, FALSE);
\r
961 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
962 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
963 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
967 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
972 halbtc8188c2ant_ActionA2dp(
\r
973 IN PBTC_COEXIST pBtCoexist
\r
976 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
978 halbtc8188c2ant_ActionA2dpBc4(pBtCoexist);
\r
980 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
982 halbtc8188c2ant_ActionA2dpBc8(pBtCoexist);
\r
987 halbtc8188c2ant_ActionPanBc4(
\r
988 IN PBTC_COEXIST pBtCoexist
\r
991 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
993 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
994 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
995 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
998 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
999 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1003 if(pCoexSta->bBtBusy && bWifiBusy)
\r
1005 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10);
\r
1006 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1010 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1011 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1015 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1016 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1017 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1021 halbtc8188c2ant_ActionPanBc8(
\r
1022 IN PBTC_COEXIST pBtCoexist
\r
1025 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1026 u1Byte wifiRssiState;
\r
1027 u4Byte wifiBw, wifiTrafficDir;
\r
1030 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1031 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1032 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1033 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1034 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
1038 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1042 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 3, 25, 50);
\r
1044 if(pCoexSta->bBtBusy && bWifiBusy)
\r
1046 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1047 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1049 // fw mechanism first
\r
1050 if(pCoexSta->bBtUplink)
\r
1052 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20);
\r
1053 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1057 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1058 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1061 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1063 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1067 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1069 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1070 if(pCoexSta->bBtUplink)
\r
1072 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1076 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
1079 else if( (wifiRssiState == BTC_RSSI_STATE_MEDIUM) ||
\r
1080 (wifiRssiState == BTC_RSSI_STATE_STAY_MEDIUM) )
\r
1082 // fw mechanism first
\r
1083 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20);
\r
1085 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1087 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1089 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1091 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1092 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON);
\r
1094 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1097 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1099 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1103 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1105 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1106 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1110 // fw mechanism first
\r
1111 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20);
\r
1113 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1115 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1117 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1119 if(pCoexSta->bBtUplink)
\r
1121 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1123 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON);
\r
1127 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1132 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1136 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1137 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1138 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1141 else if(pCoexSta->bBtBusy && !bWifiBusy && (wifiRssi < 30))
\r
1143 // fw mechanism first
\r
1144 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x0a, 0x20);
\r
1145 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1147 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1148 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1149 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1153 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1159 halbtc8188c2ant_ActionPan(
\r
1160 IN PBTC_COEXIST pBtCoexist
\r
1163 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1165 halbtc8188c2ant_ActionPanBc4(pBtCoexist);
\r
1167 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1169 halbtc8188c2ant_ActionPanBc8(pBtCoexist);
\r
1174 halbtc8188c2ant_ActionHid(
\r
1175 IN PBTC_COEXIST pBtCoexist
\r
1178 u4Byte wifiBw, wifiTrafficDir;
\r
1179 BOOLEAN bWifiBusy=FALSE;
\r
1181 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1182 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1183 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1184 if(BTC_WIFI_BW_LEGACY == wifiBw)
\r
1186 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1187 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1189 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1190 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1192 else if(!bWifiBusy)
\r
1194 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1195 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1196 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1198 else if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1200 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1201 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1203 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1204 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1206 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1208 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1209 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1210 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1213 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1214 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1215 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1220 halbtc8188c2ant_ActionSco(
\r
1221 IN PBTC_COEXIST pBtCoexist
\r
1224 u1Byte wifiRssiState;
\r
1227 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1229 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1232 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1233 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1236 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1237 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1238 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1240 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1242 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1243 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1245 // fw mechanism first
\r
1246 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1247 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1250 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1251 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1252 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1256 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
1257 // fw mechanism first
\r
1258 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1259 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1262 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1263 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1265 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1266 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1267 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1271 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1272 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1273 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1280 halbtc8188c2ant_ActionHidA2dpBc4(
\r
1281 IN PBTC_COEXIST pBtCoexist
\r
1284 u1Byte wifiRssiState;
\r
1285 u4Byte wifiBw, wifiTrafficDir;
\r
1287 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1288 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1290 if(pCoexSta->bBtBusy)
\r
1292 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1294 // fw mechanism first
\r
1295 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1297 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x7, 0x20);
\r
1298 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);
\r
1300 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1302 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1303 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1307 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1308 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1309 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1313 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
1314 // fw mechanism first
\r
1315 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1317 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x7, 0x20);
\r
1318 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);
\r
1320 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1322 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1323 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1327 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1328 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1330 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1331 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1332 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1336 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1337 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1338 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1344 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1348 halbtc8188c2ant_ActionHidA2dpBc8(
\r
1349 IN PBTC_COEXIST pBtCoexist
\r
1352 u1Byte wifiRssiState;
\r
1355 if(pCoexSta->bBtBusy)
\r
1357 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1358 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1360 // fw mechanism first
\r
1361 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1362 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1365 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1366 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1367 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1371 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
\r
1373 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1374 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1377 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1378 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1380 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1381 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1382 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1386 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1387 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1388 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1394 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1399 halbtc8188c2ant_ActionHidA2dp(
\r
1400 IN PBTC_COEXIST pBtCoexist
\r
1403 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1405 halbtc8188c2ant_ActionHidA2dpBc4(pBtCoexist);
\r
1407 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1409 halbtc8188c2ant_ActionHidA2dpBc8(pBtCoexist);
\r
1414 halbtc8188c2ant_ActionHidPanBc4(
\r
1415 IN PBTC_COEXIST pBtCoexist
\r
1418 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1419 u4Byte wifiBw, wifiTrafficDir;
\r
1421 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1425 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1426 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1428 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1429 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1433 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1434 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1435 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1436 if(BTC_WIFI_BW_LEGACY == wifiBw)
\r
1438 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1439 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1441 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1442 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1444 else if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1446 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1447 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1449 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1450 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1452 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1454 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1455 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10);
\r
1456 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1458 else if(!bWifiBusy)
\r
1460 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1461 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1462 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1465 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1466 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1467 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1470 halbtc8188c2ant_ActionHidPanBc8(
\r
1471 IN PBTC_COEXIST pBtCoexist
\r
1474 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1475 u1Byte wifiRssiState;
\r
1476 u4Byte wifiBw, wifiTrafficDir;
\r
1478 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1482 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1483 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
\r
1484 if((pCoexSta->bBtBusy && bWifiBusy))
\r
1486 // fw mechanism first
\r
1487 if(pCoexSta->bBtUplink)
\r
1489 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20);
\r
1493 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20);
\r
1495 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1498 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1499 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1501 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1502 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1504 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1505 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1506 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1510 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1511 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1512 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1517 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1518 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1519 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1524 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1529 if(BTC_INTF_USB == pBtCoexist->chipInterface)
\r
1531 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1532 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)
\r
1534 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1535 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1537 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);
\r
1538 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);
\r
1539 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1541 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)
\r
1543 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);
\r
1548 if(pCoexSta->bBtBusy)
\r
1551 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1552 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1555 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1556 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1557 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
1561 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1568 halbtc8188c2ant_ActionHidPan(
\r
1569 IN PBTC_COEXIST pBtCoexist
\r
1572 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1574 halbtc8188c2ant_ActionHidPanBc4(pBtCoexist);
\r
1576 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1578 halbtc8188c2ant_ActionHidPanBc8(pBtCoexist);
\r
1583 halbtc8188c2ant_ActionPanA2dpBc4(
\r
1584 IN PBTC_COEXIST pBtCoexist
\r
1587 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1588 u1Byte wifiRssiState;
\r
1590 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1592 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);
\r
1595 if(pCoexSta->bBtBusy)
\r
1598 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1599 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1602 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1603 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1604 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
1608 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1613 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1614 if(pCoexSta->bBtBusy && bWifiBusy)
\r
1616 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10);
\r
1617 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1621 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1622 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);
\r
1625 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1626 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1627 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1631 halbtc8188c2ant_ActionPanA2dpBc8(
\r
1632 IN PBTC_COEXIST pBtCoexist
\r
1635 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1636 u1Byte wifiRssiState;
\r
1639 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1643 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1644 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
\r
1645 if((pCoexSta->bBtBusy && bWifiBusy))
\r
1647 // fw mechanism first
\r
1648 if(pCoexSta->bBtUplink)
\r
1650 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20);
\r
1654 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20);
\r
1656 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);
\r
1659 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
\r
1660 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
\r
1662 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1663 if(BTC_WIFI_BW_HT40 == wifiBw)
\r
1665 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1666 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1667 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1671 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1672 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
\r
1673 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1678 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1679 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1680 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1685 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1690 if(pCoexSta->bBtBusy)
\r
1693 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);
\r
1694 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);
\r
1697 halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1698 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
\r
1699 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);
\r
1703 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);
\r
1709 halbtc8188c2ant_ActionPanA2dp(
\r
1710 IN PBTC_COEXIST pBtCoexist
\r
1713 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)
\r
1715 halbtc8188c2ant_ActionPanA2dpBc4(pBtCoexist);
\r
1717 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)
\r
1719 halbtc8188c2ant_ActionPanA2dpBc8(pBtCoexist);
\r
1723 //============================================================
\r
1724 // extern function start with EXhalbtc8188c2ant_
\r
1725 //============================================================
\r
1727 EXhalbtc8188c2ant_InitHwConfig(
\r
1728 IN PBTC_COEXIST pBtCoexist
\r
1733 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 2Ant Init HW Config!!\n"));
\r
1735 // backup rf 0x1e value
\r
1736 pCoexDm->btRf0x1eBackup =
\r
1737 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0);
\r
1739 if( (BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) ||
\r
1740 (BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) )
\r
1742 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd) & BIT0;
\r
1743 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, u1Tmp);
\r
1745 halbtc8188c2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0xaaaa9aaa, 0xffbd0040, 0x40000010);
\r
1750 EXhalbtc8188c2ant_InitCoexDm(
\r
1751 IN PBTC_COEXIST pBtCoexist
\r
1754 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
\r
1756 halbtc8188c2ant_InitCoexDm(pBtCoexist);
\r
1760 EXhalbtc8188c2ant_DisplayCoexInfo(
\r
1761 IN PBTC_COEXIST pBtCoexist
\r
1764 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
\r
1765 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
\r
1766 pu1Byte cliBuf=pBtCoexist->cliBuf;
\r
1767 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
\r
1769 BOOLEAN bRoam=FALSE, bScan=FALSE, bLink=FALSE, bWifiUnder5G=FALSE;
\r
1770 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
\r
1771 s4Byte wifiRssi=0, btHsRssi=0;
\r
1772 u4Byte wifiBw, wifiTrafficDir;
\r
1773 u1Byte wifiDot11Chnl, wifiHsChnl;
\r
1775 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
\r
1776 CL_PRINTF(cliBuf);
\r
1778 if(!pBoardInfo->bBtExist)
\r
1780 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
\r
1781 CL_PRINTF(cliBuf);
\r
1785 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
\r
1786 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
\r
1787 CL_PRINTF(cliBuf);
\r
1789 if(pBtCoexist->bManualControl)
\r
1791 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!");
\r
1792 CL_PRINTF(cliBuf);
\r
1795 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
\r
1796 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
\r
1797 CL_PRINTF(cliBuf);
\r
1799 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
\r
1800 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
\r
1801 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
\r
1802 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
\r
1803 wifiDot11Chnl, wifiHsChnl, bBtHsOn);
\r
1804 CL_PRINTF(cliBuf);
\r
1806 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
\r
1807 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
\r
1808 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
\r
1809 wifiRssi, btHsRssi);
\r
1810 CL_PRINTF(cliBuf);
\r
1812 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
\r
1813 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
\r
1814 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
\r
1815 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
\r
1816 bLink, bRoam, bScan);
\r
1817 CL_PRINTF(cliBuf);
\r
1819 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
\r
1820 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
\r
1821 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
\r
1822 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
\r
1823 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
\r
1824 (bWifiUnder5G? "5G":"2.4G"),
\r
1825 ((BTC_WIFI_BW_LEGACY==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40==wifiBw)? "HT40":"HT20"))),
\r
1826 ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
\r
1827 CL_PRINTF(cliBuf);
\r
1829 if(pStackInfo->bProfileNotified)
\r
1831 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
\r
1832 pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist);
\r
1833 CL_PRINTF(cliBuf);
\r
1835 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
\r
1839 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
\r
1840 CL_PRINTF(cliBuf);
\r
1841 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
\r
1842 pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
\r
1843 CL_PRINTF(cliBuf);
\r
1846 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
\r
1847 CL_PRINTF(cliBuf);
\r
1850 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
\r
1851 CL_PRINTF(cliBuf);
\r
1853 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
\r
1854 pCoexDm->btRf0x1eBackup);
\r
1855 CL_PRINTF(cliBuf);
\r
1857 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
\r
1858 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \
\r
1860 CL_PRINTF(cliBuf);
\r
1862 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
\r
1863 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
\r
1865 CL_PRINTF(cliBuf);
\r
1867 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
\r
1868 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
\r
1869 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc);
\r
1870 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c4/0x6c8/0x6cc(coexTable)", \
\r
1871 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
\r
1872 CL_PRINTF(cliBuf);
\r
1874 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
\r
1879 EXhalbtc8188c2ant_IpsNotify(
\r
1880 IN PBTC_COEXIST pBtCoexist,
\r
1884 if(BTC_IPS_ENTER == type)
\r
1886 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
\r
1887 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1889 else if(BTC_IPS_LEAVE == type)
\r
1891 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
\r
1892 //halbtc8188c2ant_InitCoexDm(pBtCoexist);
\r
1897 EXhalbtc8188c2ant_LpsNotify(
\r
1898 IN PBTC_COEXIST pBtCoexist,
\r
1902 if(BTC_LPS_ENABLE == type)
\r
1904 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
\r
1905 halbtc8188c2ant_CoexAllOff(pBtCoexist);
\r
1907 else if(BTC_LPS_DISABLE == type)
\r
1909 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
\r
1910 halbtc8188c2ant_InitCoexDm(pBtCoexist);
\r
1915 EXhalbtc8188c2ant_ScanNotify(
\r
1916 IN PBTC_COEXIST pBtCoexist,
\r
1920 if(BTC_SCAN_START == type)
\r
1922 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
\r
1924 else if(BTC_SCAN_FINISH == type)
\r
1926 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
\r
1931 EXhalbtc8188c2ant_ConnectNotify(
\r
1932 IN PBTC_COEXIST pBtCoexist,
\r
1936 if(BTC_ASSOCIATE_START == type)
\r
1938 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
\r
1940 else if(BTC_ASSOCIATE_FINISH == type)
\r
1942 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
\r
1947 EXhalbtc8188c2ant_MediaStatusNotify(
\r
1948 IN PBTC_COEXIST pBtCoexist,
\r
1952 if(BTC_MEDIA_CONNECT == type)
\r
1954 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
\r
1958 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
\r
1964 EXhalbtc8188c2ant_SpecialPacketNotify(
\r
1965 IN PBTC_COEXIST pBtCoexist,
\r
1969 if(type == BTC_PACKET_DHCP)
\r
1971 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
\r
1976 EXhalbtc8188c2ant_BtInfoNotify(
\r
1977 IN PBTC_COEXIST pBtCoexist,
\r
1978 IN pu1Byte tmpBuf,
\r
1985 EXhalbtc8188c2ant_HaltNotify(
\r
1986 IN PBTC_COEXIST pBtCoexist
\r
1989 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
\r
1991 EXhalbtc8188c2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
\r
1995 EXhalbtc8188c2ant_Periodical(
\r
1996 IN PBTC_COEXIST pBtCoexist
\r
2001 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], 2Ant Periodical!!\n"));
\r
2004 // sw mechanism must be done after fw mechanism
\r
2007 if((BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) ||
\r
2008 (BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) )
\r
2010 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_GET_BT_RSSI, NULL);
\r
2012 halbtc8188c2ant_MonitorBtState(pBtCoexist);
\r
2013 algorithm = halbtc8188c2ant_ActionAlgorithm(pBtCoexist);
\r
2014 pCoexDm->curAlgorithm = algorithm;
\r
2015 switch(pCoexDm->curAlgorithm)
\r
2017 case BT_8188C_2ANT_COEX_ALGO_SCO:
\r
2018 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = SCO\n"));
\r
2019 halbtc8188c2ant_ActionSco(pBtCoexist);
\r
2021 case BT_8188C_2ANT_COEX_ALGO_HID:
\r
2022 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID\n"));
\r
2023 halbtc8188c2ant_ActionHid(pBtCoexist);
\r
2025 case BT_8188C_2ANT_COEX_ALGO_A2DP:
\r
2026 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP\n"));
\r
2027 halbtc8188c2ant_ActionA2dp(pBtCoexist);
\r
2029 case BT_8188C_2ANT_COEX_ALGO_PAN:
\r
2030 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN\n"));
\r
2031 halbtc8188c2ant_ActionPan(pBtCoexist);
\r
2033 case BT_8188C_2ANT_COEX_ALGO_HID_A2DP:
\r
2034 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP\n"));
\r
2035 halbtc8188c2ant_ActionHidA2dp(pBtCoexist);
\r
2037 case BT_8188C_2ANT_COEX_ALGO_HID_PAN:
\r
2038 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN+HID\n"));
\r
2039 halbtc8188c2ant_ActionHidPan(pBtCoexist);
\r
2041 case BT_8188C_2ANT_COEX_ALGO_PAN_A2DP:
\r
2042 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP\n"));
\r
2043 halbtc8188c2ant_ActionPanA2dp(pBtCoexist);
\r