phy: rockchip-inno-usb2: add SDP detect retry
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8188eu / hal / OUTSRC-BTCoexist / HalBtc8188c2Ant.c
1 //============================================================\r
2 // Description:\r
3 //\r
4 // This file is for 92CE/92CU BT 1 Antenna Co-exist mechanism\r
5 //\r
6 // By cosa 02/11/2011\r
7 //\r
8 //============================================================\r
9 \r
10 //============================================================\r
11 // include files\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
22 \r
23 //============================================================\r
24 // local function start with btdm_\r
25 //============================================================\r
26 u1Byte\r
27 halbtc8188c2ant_WifiRssiState(\r
28         IN      PBTC_COEXIST            pBtCoexist,\r
29         IN      u1Byte                  index,\r
30         IN      u1Byte                  levelNum,\r
31         IN      u1Byte                  rssiThresh,\r
32         IN      u1Byte                  rssiThresh1\r
33         )\r
34 {\r
35         s4Byte                  wifiRssi=0;\r
36         u1Byte                  wifiRssiState=pCoexSta->preWifiRssiState[index];\r
37 \r
38         pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);\r
39         \r
40         if(levelNum == 2)\r
41         {\r
42                 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||\r
43                         (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))\r
44                 {\r
45                         if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT))\r
46                         {\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
49                         }\r
50                         else\r
51                         {\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
54                         }\r
55                 }\r
56                 else\r
57                 {\r
58                         if(wifiRssi < rssiThresh)\r
59                         {\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
62                         }\r
63                         else\r
64                         {\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
67                         }\r
68                 }\r
69         }\r
70         else if(levelNum == 3)\r
71         {\r
72                 if(rssiThresh > rssiThresh1)\r
73                 {\r
74                         BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));\r
75                         return pCoexSta->preWifiRssiState[index];\r
76                 }\r
77                 \r
78                 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||\r
79                         (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))\r
80                 {\r
81                         if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT))\r
82                         {\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
85                         }\r
86                         else\r
87                         {\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
90                         }\r
91                 }\r
92                 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||\r
93                         (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))\r
94                 {\r
95                         if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT))\r
96                         {\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
99                         }\r
100                         else if(wifiRssi < rssiThresh)\r
101                         {\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
104                         }\r
105                         else\r
106                         {\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
109                         }\r
110                 }\r
111                 else\r
112                 {\r
113                         if(wifiRssi < rssiThresh1)\r
114                         {\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
117                         }\r
118                         else\r
119                         {\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
122                         }\r
123                 }\r
124         }\r
125                 \r
126         pCoexSta->preWifiRssiState[index] = wifiRssiState;\r
127 \r
128         return wifiRssiState;\r
129 }\r
130 \r
131 u1Byte\r
132 halbtc8188c2ant_ActionAlgorithm(\r
133         IN      PBTC_COEXIST            pBtCoexist\r
134         )\r
135 {\r
136         PBTC_STACK_INFO         pStackInfo=&pBtCoexist->stackInfo;\r
137         u1Byte                          algorithm=BT_8188C_2ANT_COEX_ALGO_UNDEFINED;\r
138         u1Byte                          numOfDiffProfile=0;\r
139         \r
140         if(!pStackInfo->bBtLinkExist)\r
141         {\r
142                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No profile exists!!!\n"));\r
143                 return algorithm;\r
144         }\r
145 \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
154 \r
155         if(pStackInfo->bScoExist)\r
156         {\r
157                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO algorithm\n"));\r
158                 algorithm = BT_8188C_2ANT_COEX_ALGO_SCO;\r
159         }\r
160         else\r
161         {\r
162                 if(numOfDiffProfile == 1)\r
163                 {\r
164                         if(pStackInfo->bHidExist)\r
165                         {\r
166                                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));\r
167                                 algorithm = BT_8188C_2ANT_COEX_ALGO_HID;\r
168                         }\r
169                         else if(pStackInfo->bA2dpExist)\r
170                         {\r
171                                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));\r
172                                 algorithm = BT_8188C_2ANT_COEX_ALGO_A2DP;\r
173                         }\r
174                         else if(pStackInfo->bPanExist)\r
175                         {\r
176                                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN only\n"));\r
177                                 algorithm = BT_8188C_2ANT_COEX_ALGO_PAN;\r
178                         }\r
179                 }\r
180                 else\r
181                 {\r
182                         if( pStackInfo->bHidExist &&\r
183                                 pStackInfo->bA2dpExist )\r
184                         {\r
185                                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));\r
186                                 algorithm = BT_8188C_2ANT_COEX_ALGO_HID_A2DP;\r
187                         }\r
188                         else if( pStackInfo->bHidExist &&\r
189                                 pStackInfo->bPanExist )\r
190                         {                               \r
191                                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN\n"));\r
192                                 algorithm = BT_8188C_2ANT_COEX_ALGO_HID_PAN;\r
193                         }\r
194                         else if( pStackInfo->bPanExist &&\r
195                                 pStackInfo->bA2dpExist )\r
196                         {                               \r
197                                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN + A2DP\n"));\r
198                                 algorithm = BT_8188C_2ANT_COEX_ALGO_PAN_A2DP;\r
199                         }\r
200                 }               \r
201         }\r
202         return algorithm;\r
203 }\r
204 \r
205 VOID\r
206 halbtc8188c2ant_SetFwBalance(\r
207         IN      PBTC_COEXIST            pBtCoexist,\r
208         IN      BOOLEAN                 bBalanceOn,\r
209         IN      u1Byte                  ms0,\r
210         IN      u1Byte                  ms1\r
211         )\r
212 {\r
213         u1Byte  H2C_Parameter[3] ={0};\r
214 \r
215         if(bBalanceOn)\r
216         {\r
217                 H2C_Parameter[2] = 1;\r
218                 H2C_Parameter[1] = ms1;\r
219                 H2C_Parameter[0] = ms0;\r
220         }\r
221         else\r
222         {\r
223                 H2C_Parameter[2] = 0;\r
224                 H2C_Parameter[1] = 0;\r
225                 H2C_Parameter[0] = 0;\r
226         }\r
227         \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
231 \r
232         pBtCoexist->fBtcFillH2c(pBtCoexist, 0xc, 3, H2C_Parameter);     \r
233 }\r
234 \r
235 VOID\r
236 halbtc8188c2ant_Balance(\r
237         IN      PBTC_COEXIST            pBtCoexist,\r
238         IN      BOOLEAN                 bForceExec,\r
239         IN      BOOLEAN                 bBalanceOn,\r
240         IN      u1Byte                  ms0,\r
241         IN      u1Byte                  ms1\r
242         )\r
243 {\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
247 \r
248         if(!bForceExec)\r
249         {\r
250                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBalanceOn = %d, bCurBalanceOn = %d!!\n", \r
251                         pCoexDm->bPreBalanceOn, pCoexDm->bCurBalanceOn));\r
252 \r
253                 if(pCoexDm->bPreBalanceOn == pCoexDm->bCurBalanceOn)\r
254                         return;\r
255         }\r
256         halbtc8188c2ant_SetFwBalance(pBtCoexist, bBalanceOn, ms0, ms1);\r
257 \r
258         pCoexDm->bPreBalanceOn = pCoexDm->bCurBalanceOn;\r
259 }\r
260 \r
261 VOID\r
262 halbtc8188c2ant_SetFwDiminishWifi(\r
263         IN      PBTC_COEXIST            pBtCoexist,\r
264         IN      BOOLEAN                 bDacOn,\r
265         IN      BOOLEAN                 bInterruptOn,\r
266         IN      u1Byte                  fwDacSwingLvl,\r
267         IN      BOOLEAN                 bNavOn\r
268         )\r
269 {\r
270         u1Byte                  H2C_Parameter[3] ={0};\r
271 \r
272         if((pBtCoexist->stackInfo.minBtRssi <= -5) && (fwDacSwingLvl == 0x20))\r
273         {\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
276         }\r
277 \r
278         H2C_Parameter[2] = 0;\r
279         H2C_Parameter[1] = fwDacSwingLvl;\r
280         H2C_Parameter[0] = 0;\r
281         if(bDacOn)\r
282         {\r
283                 H2C_Parameter[2] |= 0x01;       //BIT0\r
284                 if(bInterruptOn)\r
285                 {\r
286                         H2C_Parameter[2] |= 0x02;       //BIT1\r
287                 }\r
288         }\r
289         if(bNavOn)\r
290         {\r
291                 H2C_Parameter[2] |= 0x08;       //BIT3\r
292         }\r
293 \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
298 }\r
299 \r
300 VOID\r
301 halbtc8188c2ant_DiminishWifi(\r
302         IN      PBTC_COEXIST            pBtCoexist,\r
303         IN      BOOLEAN                 bForceExec,\r
304         IN      BOOLEAN                 bDacOn,\r
305         IN      BOOLEAN                 bInterruptOn,\r
306         IN      u1Byte                  fwDacSwingLvl,\r
307         IN      BOOLEAN                 bNavOn\r
308         )\r
309 {\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
312 \r
313         pCoexDm->bCurDacOn = bDacOn;\r
314         pCoexDm->bCurInterruptOn = bInterruptOn;\r
315         pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;\r
316         pCoexDm->bCurNavOn = bNavOn;\r
317 \r
318         if(!bForceExec)\r
319         {\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
328 \r
329 \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
334                         return;\r
335         }\r
336         halbtc8188c2ant_SetFwDiminishWifi(pBtCoexist, bDacOn, bInterruptOn, fwDacSwingLvl, bNavOn);\r
337 \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
342 }\r
343 \r
344 VOID\r
345 halbtc8188c2ant_SetSwRfRxLpfCorner(\r
346         IN      PBTC_COEXIST            pBtCoexist,\r
347         IN      BOOLEAN                 bRxRfShrinkOn\r
348         )\r
349 {\r
350         if(bRxRfShrinkOn)\r
351         {\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
355         }\r
356         else\r
357         {\r
358                 //Resume RF Rx LPF corner\r
359                 // After initialized, we can use pCoexDm->btRf0x1eBackup\r
360                 if(pBtCoexist->bInitilized)\r
361                 {\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
364                 }\r
365         }\r
366 }\r
367 \r
368 VOID\r
369 halbtc8188c2ant_RfShrink(\r
370         IN      PBTC_COEXIST            pBtCoexist,\r
371         IN      BOOLEAN                 bForceExec,\r
372         IN      BOOLEAN                 bRxRfShrinkOn\r
373         )\r
374 {\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
378 \r
379         if(!bForceExec)\r
380         {\r
381                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n", \r
382                         pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink));\r
383 \r
384                 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) \r
385                         return;\r
386         }\r
387         halbtc8188c2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);\r
388 \r
389         pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;\r
390 }\r
391 \r
392 VOID\r
393 halbtc8188c2ant_SetSwPenaltyTxRateAdaptive(\r
394         IN      PBTC_COEXIST            pBtCoexist,\r
395         IN      BOOLEAN                 bLowPenaltyRa\r
396         )\r
397 {\r
398         u1Byte  tmpU1;\r
399 \r
400         tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd);\r
401         if(bLowPenaltyRa)\r
402         {\r
403                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));\r
404                 tmpU1 &= ~BIT2;\r
405         }\r
406         else\r
407         {\r
408                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));\r
409                 tmpU1 |= BIT2;\r
410         }\r
411         pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1);\r
412 }\r
413 \r
414 VOID\r
415 halbtc8188c2ant_LowPenaltyRa(\r
416         IN      PBTC_COEXIST            pBtCoexist,\r
417         IN      BOOLEAN                 bForceExec,\r
418         IN      BOOLEAN                 bLowPenaltyRa\r
419         )\r
420 {\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
424 \r
425         if(!bForceExec)\r
426         {\r
427                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n", \r
428                         pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));\r
429 \r
430                 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) \r
431                         return;\r
432         }\r
433         halbtc8188c2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);\r
434 \r
435         pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;\r
436 }\r
437 \r
438 VOID\r
439 halbtc8188c2ant_SetSwFullTimeDacSwing(\r
440         IN      PBTC_COEXIST            pBtCoexist,\r
441         IN      BOOLEAN                 bSwDacSwingOn,\r
442         IN      u4Byte                  swDacSwingLvl\r
443         )\r
444 {\r
445         u4Byte  dacSwingLvl;\r
446 \r
447         if(bSwDacSwingOn)\r
448         {               \r
449                 if((pBtCoexist->stackInfo.minBtRssi <= -5) && (swDacSwingLvl == 0x20))\r
450                 {\r
451                         dacSwingLvl = 0x18;\r
452                 }\r
453                 else\r
454                 {\r
455                         dacSwingLvl = swDacSwingLvl;\r
456                 }\r
457                 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, dacSwingLvl);\r
458         }\r
459         else\r
460         {\r
461                 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, 0x30);\r
462         }\r
463 }\r
464 \r
465 VOID\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
471         )\r
472 {\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
477 \r
478         if(!bForceExec)\r
479         {\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
483 \r
484                 if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&\r
485                         (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )\r
486                         return;\r
487         }\r
488         delay_ms(30);\r
489         halbtc8188c2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);\r
490 \r
491         pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;\r
492         pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;\r
493 }\r
494 \r
495 VOID\r
496 halbtc8188c2ant_SetAdcBackOff(\r
497         IN      PBTC_COEXIST            pBtCoexist,\r
498         IN      BOOLEAN                 bAdcBackOff\r
499         )\r
500 {\r
501         if(bAdcBackOff)\r
502         {\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
505         }\r
506         else\r
507         {\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
510         }\r
511 }\r
512 \r
513 VOID\r
514 halbtc8188c2ant_AdcBackOff(\r
515         IN      PBTC_COEXIST            pBtCoexist,\r
516         IN      BOOLEAN                 bForceExec,\r
517         IN      BOOLEAN                 bAdcBackOff\r
518         )\r
519 {\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
523 \r
524         if(!bForceExec)\r
525         {\r
526                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n", \r
527                         pCoexDm->bPreAdcBackOff, pCoexDm->bCurAdcBackOff));\r
528 \r
529                 if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) \r
530                         return;\r
531         }\r
532         halbtc8188c2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);\r
533 \r
534         pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;\r
535 }\r
536 \r
537 VOID\r
538 halbtc8188c2ant_SetAgcTable(\r
539         IN      PBTC_COEXIST            pBtCoexist,\r
540         IN      BOOLEAN                 bAgcTableEn\r
541         )\r
542 {\r
543         u1Byte          rssiAdjustVal=0;\r
544 \r
545         if(bAgcTableEn)\r
546         {\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
553 \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
559         }\r
560         else\r
561         {\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
568 \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
574         }\r
575 \r
576         // set rssiAdjustVal for wifi module.\r
577         pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);\r
578 }\r
579 \r
580 \r
581 VOID\r
582 halbtc8188c2ant_AgcTable(\r
583         IN      PBTC_COEXIST            pBtCoexist,\r
584         IN      BOOLEAN                 bForceExec,\r
585         IN      BOOLEAN                 bAgcTableEn\r
586         )\r
587 {\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
591 \r
592         if(!bForceExec)\r
593         {\r
594                 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n", \r
595                         pCoexDm->bPreAgcTableEn, pCoexDm->bCurAgcTableEn));\r
596 \r
597                 if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) \r
598                         return;\r
599         }\r
600         halbtc8188c2ant_SetAgcTable(pBtCoexist, bAgcTableEn);\r
601 \r
602         pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;\r
603 }\r
604 \r
605 VOID\r
606 halbtc8188c2ant_SetCoexTable(\r
607         IN      PBTC_COEXIST    pBtCoexist,\r
608         IN      u4Byte          val0x6c4,\r
609         IN      u4Byte          val0x6c8,\r
610         IN      u4Byte          val0x6cc\r
611         )\r
612 {\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
615 \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
618 \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
621 }\r
622 \r
623 VOID\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
629         IN      u4Byte                  val0x6cc\r
630         )\r
631 {\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
637 \r
638         if(!bForceExec)\r
639         {\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
644         \r
645                 if( (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&\r
646                         (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&\r
647                         (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )\r
648                         return;\r
649         }\r
650         halbtc8188c2ant_SetCoexTable(pBtCoexist, val0x6c4, val0x6c8, val0x6cc);\r
651 \r
652         pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;\r
653         pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;\r
654         pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;\r
655 }\r
656 \r
657 VOID\r
658 halbtc8188c2ant_CoexAllOff(\r
659         IN      PBTC_COEXIST            pBtCoexist\r
660         )\r
661 {\r
662         // fw mechanism\r
663         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
664         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
665 \r
666         // sw mechanism\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
670 }\r
671 VOID\r
672 halbtc8188c2ant_InitCoexDm(\r
673         IN      PBTC_COEXIST            pBtCoexist\r
674         )\r
675 {\r
676 }\r
677 \r
678 \r
679 VOID\r
680 halbtc8188c2ant_MonitorBtState(\r
681         IN      PBTC_COEXIST                    pBtCoexist\r
682         )\r
683 {\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
689         u4Byte                  fwVer=0;\r
690         static BOOLEAN  bBtBusyTraffic=FALSE;\r
691         BOOLEAN                 bRejApAggPkt=FALSE;\r
692 \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
695         if(fwVer < 62)\r
696         {\r
697                 regBTActive = 0x488;\r
698                 regBTState = 0x48c;\r
699                 regBTPolling = 0x490;\r
700         }\r
701         else\r
702         {\r
703                 regBTActive = 0x444;\r
704                 regBTState = 0x448;\r
705                 if(fwVer >= 74)\r
706                         regBTPolling = 0x44c;\r
707                 else\r
708                         regBTPolling = 0x700;\r
709         }\r
710         btBusyThresh = 60;\r
711         \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
715 \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
719 \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
722 \r
723         if(BT_Active==0xffffffff && BT_State==0xffffffff && BT_Polling==0xffffffff )\r
724                 return;\r
725 \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
729         // HW divide trap.\r
730         if (BT_Polling==0)\r
731                 return;\r
732         \r
733         Ratio_Act = BT_Active*1000/BT_Polling;\r
734         Ratio_STA = BT_State*1000/BT_Polling;\r
735                 \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
738 \r
739         if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)\r
740         {\r
741                 if(Ratio_STA < 60)      // BT PAN idle\r
742                 {\r
743                 }\r
744                 else\r
745                 {\r
746                         // Check if BT PAN (under BT 2.1) is uplink or downlink\r
747                         if((Ratio_Act/Ratio_STA) < 2)\r
748                         {       // BT PAN Uplink\r
749                                 pCoexSta->bBtUplink = TRUE;\r
750                         }\r
751                         else\r
752                         {       // BT PAN downlink\r
753                                 pCoexSta->bBtUplink = FALSE;\r
754                         }\r
755                 }\r
756         }       \r
757         \r
758         // Check BT is idle or not\r
759         if(!pBtCoexist->stackInfo.bBtLinkExist)\r
760         {\r
761                 pCoexSta->bBtBusy = FALSE;\r
762         }\r
763         else\r
764         {\r
765                 if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)\r
766                 {\r
767                         if(Ratio_Act<20)\r
768                         {\r
769                                 pCoexSta->bBtBusy = FALSE;\r
770                         }\r
771                         else\r
772                         {\r
773                                 pCoexSta->bBtBusy = TRUE;\r
774                         }\r
775                 }\r
776                 else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)\r
777                 {\r
778                         if(Ratio_STA < btBusyThresh)\r
779                         {\r
780                                 pCoexSta->bBtBusy = FALSE;\r
781                         }\r
782                         else\r
783                         {\r
784                                 pCoexSta->bBtBusy = TRUE;\r
785                         }\r
786 \r
787                         if( (Ratio_STA < btBusyThresh) ||\r
788                                 (Ratio_Act<180 && Ratio_STA<130) )\r
789                         {\r
790                                 pCoexSta->bA2dpBusy = FALSE;\r
791                         }\r
792                         else\r
793                         {\r
794                                 pCoexSta->bA2dpBusy = TRUE;\r
795                         }\r
796                 }\r
797         }\r
798 \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
801         \r
802         if(bBtBusyTraffic != pCoexSta->bBtBusy)\r
803         {       // BT idle or BT non-idle\r
804                 bBtBusyTraffic = pCoexSta->bBtBusy;\r
805                 stateChange = TRUE;\r
806         }\r
807 \r
808         if(stateChange)\r
809         {\r
810                 if(!pCoexSta->bBtBusy)\r
811                 {\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
816                 }\r
817                 else\r
818                 {\r
819                         halbtc8188c2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);\r
820                         halbtc8188c2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE);\r
821                 }\r
822         }\r
823 \r
824         if(stateChange)\r
825         {\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
829         }\r
830 }\r
831 \r
832 VOID\r
833 halbtc8188c2ant_ActionA2dpBc4(\r
834         IN      PBTC_COEXIST            pBtCoexist\r
835         )\r
836 {\r
837         u1Byte                  wifiRssiState;\r
838         u4Byte                  wifiBw, wifiTrafficDir;\r
839 \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
843         \r
844         if(pCoexSta->bBtBusy)\r
845         {\r
846                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
847                 {\r
848                         // fw mechanism first\r
849                         if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
850                         {\r
851                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18);\r
852                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);\r
853                         }\r
854                         else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
855                         {\r
856                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
857                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
858                         }\r
859 \r
860                         // sw mechanism \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
864                 }\r
865                 else\r
866                 {\r
867                         wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);\r
868 \r
869                         if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
870                         {\r
871                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18);\r
872                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);\r
873                         }\r
874                         else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
875                         {\r
876                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
877                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
878                         }\r
879 \r
880                         // sw mechanism \r
881                         if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
882                                 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
883                         {\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
887                         }\r
888                         else\r
889                         {\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
893                         }\r
894                 }\r
895         }\r
896         else\r
897         {\r
898                 halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
899         }\r
900 }\r
901 \r
902 VOID\r
903 halbtc8188c2ant_ActionA2dpBc8(\r
904         IN      PBTC_COEXIST            pBtCoexist\r
905         )\r
906 {\r
907         u1Byte                  wifiRssiState;\r
908         u4Byte                  wifiBw, wifiTrafficDir;\r
909         BOOLEAN                 bWifiBusy=FALSE;\r
910 \r
911         pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);\r
912         if(pCoexSta->bA2dpBusy && bWifiBusy)\r
913         {\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
917 \r
918                 // fw mechanism first\r
919                 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
920                 {\r
921                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18);\r
922                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
923                 }\r
924                 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
925                 {\r
926                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x18);\r
927                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
928                 }\r
929 \r
930                 // sw mechanism \r
931                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
932                 {\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
936                 }\r
937                 else\r
938                 {\r
939                         if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
940                                 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
941                         {\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
945                         }\r
946                         else\r
947                         {\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
951                         }\r
952                 }\r
953         }\r
954         else if(pCoexSta->bA2dpBusy)\r
955         {\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
959 \r
960                 // sw mechanism \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
964         }\r
965         else\r
966         {\r
967                 halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
968         }\r
969 }\r
970 \r
971 VOID\r
972 halbtc8188c2ant_ActionA2dp(\r
973         IN      PBTC_COEXIST            pBtCoexist\r
974         )\r
975 {\r
976         if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)\r
977         {\r
978                 halbtc8188c2ant_ActionA2dpBc4(pBtCoexist);\r
979         }\r
980         else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)\r
981         {\r
982                 halbtc8188c2ant_ActionA2dpBc8(pBtCoexist);\r
983         }\r
984 }\r
985 \r
986 VOID\r
987 halbtc8188c2ant_ActionPanBc4(\r
988         IN      PBTC_COEXIST            pBtCoexist\r
989         )\r
990 {\r
991         BOOLEAN         bBtHsOn=FALSE, bWifiBusy=FALSE;\r
992 \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
996         if(bBtHsOn)\r
997         {\r
998                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
999                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1000         }\r
1001         else\r
1002         {\r
1003                 if(pCoexSta->bBtBusy && bWifiBusy)\r
1004                 {\r
1005                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10);\r
1006                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1007                 }\r
1008                 else\r
1009                 {\r
1010                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1011                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1012                 }\r
1013         }\r
1014         // sw mechanism\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
1018 }\r
1019 \r
1020 VOID\r
1021 halbtc8188c2ant_ActionPanBc8(\r
1022         IN      PBTC_COEXIST            pBtCoexist\r
1023         )\r
1024 {\r
1025         BOOLEAN         bBtHsOn=FALSE, bWifiBusy=FALSE;\r
1026         u1Byte          wifiRssiState;\r
1027         u4Byte          wifiBw, wifiTrafficDir;\r
1028         s4Byte          wifiRssi;\r
1029 \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
1035         \r
1036         if(bBtHsOn)\r
1037         {\r
1038                 halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
1039         }\r
1040         else\r
1041         {\r
1042                 wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 3, 25, 50);\r
1043 \r
1044                 if(pCoexSta->bBtBusy && bWifiBusy)\r
1045                 {\r
1046                         if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
1047                                 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
1048                         {\r
1049                                 // fw mechanism first\r
1050                                 if(pCoexSta->bBtUplink)\r
1051                                 {\r
1052                                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20);\r
1053                                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1054                                 }\r
1055                                 else\r
1056                                 {\r
1057                                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1058                                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
1059                                 }\r
1060                                 // sw mechanism \r
1061                                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
1062                                 {\r
1063                                         halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);\r
1064                                 }\r
1065                                 else\r
1066                                 {\r
1067                                         halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);\r
1068                                 }\r
1069                                 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);\r
1070                                 if(pCoexSta->bBtUplink)\r
1071                                 {\r
1072                                         halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);\r
1073                                 }\r
1074                                 else\r
1075                                 {\r
1076                                         halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20);\r
1077                                 }\r
1078                         }\r
1079                         else if( (wifiRssiState == BTC_RSSI_STATE_MEDIUM) ||\r
1080                                 (wifiRssiState == BTC_RSSI_STATE_STAY_MEDIUM) )\r
1081                         {\r
1082                                 // fw mechanism first\r
1083                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20);\r
1084 \r
1085                                 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
1086                                 {\r
1087                                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1088                                 }\r
1089                                 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
1090                                 {\r
1091                                         if(BTC_WIFI_BW_HT40 == wifiBw)\r
1092                                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON);\r
1093                                         else\r
1094                                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1095                                 }\r
1096                                 // sw mechanism \r
1097                                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
1098                                 {\r
1099                                         halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);\r
1100                                 }\r
1101                                 else\r
1102                                 {\r
1103                                         halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);\r
1104                                 }\r
1105                                 halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);\r
1106                                 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);\r
1107                         }\r
1108                         else\r
1109                         {\r
1110                                 // fw mechanism first\r
1111                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20);\r
1112                                 \r
1113                                 if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
1114                                 {\r
1115                                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1116                                 }\r
1117                                 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
1118                                 {\r
1119                                         if(pCoexSta->bBtUplink)\r
1120                                         {\r
1121                                                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
1122                                                 {\r
1123                                                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON);\r
1124                                                 }\r
1125                                                 else\r
1126                                                 {\r
1127                                                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1128                                                 }                                               \r
1129                                         }\r
1130                                         else\r
1131                                         {\r
1132                                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1133                                         }\r
1134                                 }\r
1135                                 // sw mechanism \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
1139                         }\r
1140                 }\r
1141                 else if(pCoexSta->bBtBusy && !bWifiBusy && (wifiRssi < 30))\r
1142                 {\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
1146                         // sw mechanism \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
1150                 }\r
1151                 else\r
1152                 {\r
1153                         halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
1154                 }\r
1155         }\r
1156 }\r
1157 \r
1158 VOID\r
1159 halbtc8188c2ant_ActionPan(\r
1160         IN      PBTC_COEXIST            pBtCoexist\r
1161         )\r
1162 {\r
1163         if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)\r
1164         {\r
1165                 halbtc8188c2ant_ActionPanBc4(pBtCoexist);\r
1166         }\r
1167         else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)\r
1168         {\r
1169                 halbtc8188c2ant_ActionPanBc8(pBtCoexist);\r
1170         }\r
1171 }\r
1172 \r
1173 VOID\r
1174 halbtc8188c2ant_ActionHid(\r
1175         IN      PBTC_COEXIST            pBtCoexist\r
1176         )\r
1177 {\r
1178         u4Byte          wifiBw, wifiTrafficDir;\r
1179         BOOLEAN         bWifiBusy=FALSE;\r
1180 \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
1185         {\r
1186                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1187                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1188 \r
1189                 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);\r
1190                 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);\r
1191         }\r
1192         else if(!bWifiBusy)\r
1193         {\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
1197         }\r
1198         else if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
1199         {\r
1200                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1201                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1202 \r
1203                 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);\r
1204                 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);\r
1205         }\r
1206         else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
1207         {\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
1211         }\r
1212         // sw mechanism\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
1216 }\r
1217 \r
1218 \r
1219 VOID\r
1220 halbtc8188c2ant_ActionSco(\r
1221         IN      PBTC_COEXIST            pBtCoexist\r
1222         )\r
1223 {\r
1224         u1Byte  wifiRssiState;\r
1225         u4Byte  wifiBw;\r
1226 \r
1227         if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)\r
1228         {\r
1229                 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);\r
1230                 \r
1231                 // fw mechanism\r
1232                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1233                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1234 \r
1235                 // sw mechanism\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
1239         }\r
1240         else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)\r
1241         {\r
1242                 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
1243                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
1244                 {\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
1248 \r
1249                         // sw mechanism \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
1253                 }\r
1254                 else\r
1255                 {\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
1260 \r
1261                         // sw mechanism \r
1262                         if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
1263                                 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
1264                         {\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
1268                         }\r
1269                         else\r
1270                         {                       \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
1274                         }\r
1275                 }\r
1276         }\r
1277 }\r
1278 \r
1279 VOID\r
1280 halbtc8188c2ant_ActionHidA2dpBc4(\r
1281         IN      PBTC_COEXIST            pBtCoexist\r
1282         )\r
1283 {\r
1284         u1Byte          wifiRssiState;\r
1285         u4Byte          wifiBw, wifiTrafficDir;\r
1286 \r
1287         pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
1288         pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);\r
1289 \r
1290         if(pCoexSta->bBtBusy)\r
1291         {\r
1292                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
1293                 {\r
1294                         // fw mechanism first\r
1295                         if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
1296                         {\r
1297                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x7, 0x20);\r
1298                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);\r
1299                         }\r
1300                         else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
1301                         {\r
1302                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1303                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
1304                         }\r
1305 \r
1306                         // sw mechanism \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
1310                 }\r
1311                 else\r
1312                 {\r
1313                         wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);\r
1314                         // fw mechanism first\r
1315                         if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
1316                         {\r
1317                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x7, 0x20);\r
1318                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE);\r
1319                         }\r
1320                         else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
1321                         {\r
1322                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1323                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
1324                         }\r
1325 \r
1326                         // sw mechanism \r
1327                         if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
1328                                 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
1329                         {\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
1333                         }\r
1334                         else\r
1335                         {\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
1339                         }\r
1340                 }\r
1341         }\r
1342         else\r
1343         {\r
1344                 halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
1345         }\r
1346 }\r
1347 VOID\r
1348 halbtc8188c2ant_ActionHidA2dpBc8(\r
1349         IN      PBTC_COEXIST            pBtCoexist\r
1350         )\r
1351 {\r
1352         u1Byte          wifiRssiState;\r
1353         u4Byte          wifiBw;\r
1354         \r
1355         if(pCoexSta->bBtBusy)\r
1356         {\r
1357                 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
1358                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
1359                 {\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
1363 \r
1364                         // sw mechanism \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
1368                 }\r
1369                 else\r
1370                 {\r
1371                         wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);\r
1372                         // fw mechanism\r
1373                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1374                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
1375 \r
1376                         // sw mechanism \r
1377                         if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
1378                                 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
1379                         {\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
1383                         }\r
1384                         else\r
1385                         {\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
1389                         }\r
1390                 }\r
1391         }\r
1392         else\r
1393         {\r
1394                 halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
1395         }\r
1396 }\r
1397 \r
1398 VOID\r
1399 halbtc8188c2ant_ActionHidA2dp(\r
1400         IN      PBTC_COEXIST            pBtCoexist\r
1401         )\r
1402 {\r
1403         if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)\r
1404         {\r
1405                 halbtc8188c2ant_ActionHidA2dpBc4(pBtCoexist);\r
1406         }\r
1407         else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)\r
1408         {\r
1409                 halbtc8188c2ant_ActionHidA2dpBc8(pBtCoexist);\r
1410         }\r
1411 }\r
1412 \r
1413 VOID\r
1414 halbtc8188c2ant_ActionHidPanBc4(\r
1415         IN      PBTC_COEXIST            pBtCoexist\r
1416         )\r
1417 {\r
1418         BOOLEAN         bBtHsOn=FALSE, bWifiBusy=FALSE;\r
1419         u4Byte          wifiBw, wifiTrafficDir;\r
1420 \r
1421         pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
1422         \r
1423         if(bBtHsOn)\r
1424         {       \r
1425                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1426                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1427 \r
1428                 halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);\r
1429                 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);\r
1430         }\r
1431         else\r
1432         {\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
1437                 {\r
1438                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1439                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1440 \r
1441                         halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);\r
1442                         pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);\r
1443                 }\r
1444                 else if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
1445                 {\r
1446                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1447                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1448                         \r
1449                         halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010);\r
1450                         pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0);\r
1451                 }\r
1452                 else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
1453                 {\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
1457                 }\r
1458                 else if(!bWifiBusy)\r
1459                 {\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
1463                 }                       \r
1464         }\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
1468 }\r
1469 VOID\r
1470 halbtc8188c2ant_ActionHidPanBc8(        \r
1471         IN      PBTC_COEXIST            pBtCoexist\r
1472         )\r
1473 {\r
1474         BOOLEAN         bBtHsOn=FALSE, bWifiBusy=FALSE;\r
1475         u1Byte          wifiRssiState;\r
1476         u4Byte          wifiBw, wifiTrafficDir;\r
1477 \r
1478         pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
1479 \r
1480         if(!bBtHsOn)\r
1481         {\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
1485                 {\r
1486                         // fw mechanism first\r
1487                         if(pCoexSta->bBtUplink)\r
1488                         {\r
1489                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20);\r
1490                         }\r
1491                         else\r
1492                         {\r
1493                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20);\r
1494                         }\r
1495                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1496 \r
1497                         // sw mechanism \r
1498                         if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
1499                                 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
1500                         {\r
1501                                 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
1502                                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
1503                                 {\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
1507                                 }\r
1508                                 else\r
1509                                 {\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
1513                                 }\r
1514                         }\r
1515                         else\r
1516                         {\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
1520                         }\r
1521                 }\r
1522                 else\r
1523                 {\r
1524                         halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
1525                 }\r
1526         }\r
1527         else\r
1528         {\r
1529                 if(BTC_INTF_USB == pBtCoexist->chipInterface)\r
1530                 {       \r
1531                         pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);\r
1532                         if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir)\r
1533                         {\r
1534                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1535                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1536 \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
1540                         }\r
1541                         else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir)\r
1542                         {\r
1543                                 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);\r
1544                         }\r
1545                 }\r
1546                 else \r
1547                 {\r
1548                         if(pCoexSta->bBtBusy)\r
1549                         {\r
1550                                 // fw mechanism\r
1551                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1552                                 halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
1553 \r
1554                                 // sw mechanism\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
1558                         }\r
1559                         else\r
1560                         {\r
1561                                 halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);\r
1562                         }\r
1563                 }\r
1564         }\r
1565 }\r
1566 \r
1567 VOID\r
1568 halbtc8188c2ant_ActionHidPan(\r
1569         IN      PBTC_COEXIST            pBtCoexist\r
1570         )\r
1571 {               \r
1572         if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)\r
1573         {\r
1574                 halbtc8188c2ant_ActionHidPanBc4(pBtCoexist);\r
1575         }\r
1576         else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)\r
1577         {\r
1578                 halbtc8188c2ant_ActionHidPanBc8(pBtCoexist);\r
1579         }\r
1580 }\r
1581 \r
1582 VOID\r
1583 halbtc8188c2ant_ActionPanA2dpBc4(\r
1584         IN      PBTC_COEXIST            pBtCoexist\r
1585         )\r
1586 {\r
1587         BOOLEAN         bBtHsOn=FALSE, bWifiBusy=FALSE;\r
1588         u1Byte          wifiRssiState;\r
1589 \r
1590         pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
1591 \r
1592         pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0);\r
1593         if(bBtHsOn)\r
1594         {\r
1595                 if(pCoexSta->bBtBusy)\r
1596                 {\r
1597                         // fw mechanism\r
1598                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1599                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
1600 \r
1601                         // sw mechanism\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
1605                 }\r
1606                 else\r
1607                 {\r
1608                         halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
1609                 }\r
1610         }\r
1611         else\r
1612         {\r
1613                 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);\r
1614                 if(pCoexSta->bBtBusy && bWifiBusy)\r
1615                 {\r
1616                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10);\r
1617                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1618                 }\r
1619                 else\r
1620                 {\r
1621                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1622                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE);\r
1623                 }                       \r
1624                 // sw mechanism\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
1628         }\r
1629 }\r
1630 VOID\r
1631 halbtc8188c2ant_ActionPanA2dpBc8(       \r
1632         IN      PBTC_COEXIST            pBtCoexist\r
1633         )\r
1634 {\r
1635         BOOLEAN         bBtHsOn=FALSE, bWifiBusy=FALSE;\r
1636         u1Byte          wifiRssiState;\r
1637         u4Byte          wifiBw;\r
1638 \r
1639         pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
1640 \r
1641         if(!bBtHsOn)\r
1642         {\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
1646                 {\r
1647                         // fw mechanism first\r
1648                         if(pCoexSta->bBtUplink)\r
1649                         {\r
1650                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20);\r
1651                         }\r
1652                         else\r
1653                         {\r
1654                                 halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20);\r
1655                         }\r
1656                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);\r
1657 \r
1658                         // sw mechanism \r
1659                         if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
1660                                 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
1661                         {\r
1662                                 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
1663                                 if(BTC_WIFI_BW_HT40 == wifiBw)\r
1664                                 {\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
1668                                 }\r
1669                                 else    \r
1670                                 {\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
1674                                 }\r
1675                         }\r
1676                         else\r
1677                         {\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
1681                         }\r
1682                 }\r
1683                 else\r
1684                 {\r
1685                         halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
1686                 }\r
1687         }\r
1688         else\r
1689         {\r
1690                 if(pCoexSta->bBtBusy)\r
1691                 {\r
1692                         // fw mechanism\r
1693                         halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0);\r
1694                         halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE);\r
1695 \r
1696                         // sw mechanism                 \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
1700                 }\r
1701                 else\r
1702                 {\r
1703                         halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30);\r
1704                 }\r
1705         }\r
1706 }\r
1707 \r
1708 VOID\r
1709 halbtc8188c2ant_ActionPanA2dp(\r
1710         IN      PBTC_COEXIST            pBtCoexist\r
1711         )\r
1712 {\r
1713         if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType)\r
1714         {\r
1715                 halbtc8188c2ant_ActionPanA2dpBc4(pBtCoexist);\r
1716         }\r
1717         else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType)\r
1718         {\r
1719                 halbtc8188c2ant_ActionPanA2dpBc8(pBtCoexist);\r
1720         }\r
1721 }\r
1722 \r
1723 //============================================================\r
1724 // extern function start with EXhalbtc8188c2ant_\r
1725 //============================================================\r
1726 VOID\r
1727 EXhalbtc8188c2ant_InitHwConfig(\r
1728         IN      PBTC_COEXIST            pBtCoexist\r
1729         )\r
1730 {\r
1731         u1Byte  u1Tmp=0;\r
1732 \r
1733         BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 2Ant Init HW Config!!\n"));\r
1734 \r
1735         // backup rf 0x1e value\r
1736         pCoexDm->btRf0x1eBackup = \r
1737                 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0);\r
1738 \r
1739         if( (BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) ||\r
1740                 (BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) )\r
1741         {\r
1742                 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd) & BIT0;\r
1743                 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, u1Tmp);\r
1744                 \r
1745                 halbtc8188c2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0xaaaa9aaa, 0xffbd0040, 0x40000010);\r
1746         }\r
1747 }\r
1748 \r
1749 VOID\r
1750 EXhalbtc8188c2ant_InitCoexDm(\r
1751         IN      PBTC_COEXIST            pBtCoexist\r
1752         )\r
1753 {\r
1754         BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));\r
1755         \r
1756         halbtc8188c2ant_InitCoexDm(pBtCoexist);\r
1757 }\r
1758 \r
1759 VOID\r
1760 EXhalbtc8188c2ant_DisplayCoexInfo(\r
1761         IN      PBTC_COEXIST            pBtCoexist\r
1762         )\r
1763 {\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
1768         u4Byte                          u4Tmp[4];\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
1774 \r
1775         CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");\r
1776         CL_PRINTF(cliBuf);\r
1777 \r
1778         if(!pBoardInfo->bBtExist)\r
1779         {\r
1780                 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");\r
1781                 CL_PRINTF(cliBuf);\r
1782                 return;\r
1783         }\r
1784 \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
1788         \r
1789         if(pBtCoexist->bManualControl)\r
1790         {\r
1791                 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!");\r
1792                 CL_PRINTF(cliBuf);\r
1793         }\r
1794         \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
1798 \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
1805 \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
1811 \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
1818 \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
1828         \r
1829         if(pStackInfo->bProfileNotified)\r
1830         {                       \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
1834 \r
1835                 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);\r
1836         }\r
1837         \r
1838         // Sw mechanism \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
1844 \r
1845         // Fw mechanism         \r
1846         CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");\r
1847         CL_PRINTF(cliBuf);\r
1848 \r
1849         // Hw setting           \r
1850         CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");\r
1851         CL_PRINTF(cliBuf);      \r
1852 \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
1856 \r
1857         u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);\r
1858         CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \\r
1859                 u1Tmp[0]);\r
1860         CL_PRINTF(cliBuf);\r
1861 \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
1864                 u4Tmp[0]);\r
1865         CL_PRINTF(cliBuf);\r
1866 \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
1873 \r
1874         pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);\r
1875 }\r
1876 \r
1877 \r
1878 VOID\r
1879 EXhalbtc8188c2ant_IpsNotify(\r
1880         IN      PBTC_COEXIST            pBtCoexist,\r
1881         IN      u1Byte                  type\r
1882         )\r
1883 {\r
1884         if(BTC_IPS_ENTER == type)\r
1885         {\r
1886                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));\r
1887                 halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
1888         }\r
1889         else if(BTC_IPS_LEAVE == type)\r
1890         {\r
1891                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));\r
1892                 //halbtc8188c2ant_InitCoexDm(pBtCoexist);\r
1893         }\r
1894 }\r
1895 \r
1896 VOID\r
1897 EXhalbtc8188c2ant_LpsNotify(\r
1898         IN      PBTC_COEXIST            pBtCoexist,\r
1899         IN      u1Byte                  type\r
1900         )\r
1901 {\r
1902         if(BTC_LPS_ENABLE == type)\r
1903         {\r
1904                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));\r
1905                 halbtc8188c2ant_CoexAllOff(pBtCoexist);\r
1906         }\r
1907         else if(BTC_LPS_DISABLE == type)\r
1908         {\r
1909                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));\r
1910                 halbtc8188c2ant_InitCoexDm(pBtCoexist);\r
1911         }\r
1912 }\r
1913 \r
1914 VOID\r
1915 EXhalbtc8188c2ant_ScanNotify(\r
1916         IN      PBTC_COEXIST            pBtCoexist,\r
1917         IN      u1Byte                  type\r
1918         )\r
1919 {\r
1920         if(BTC_SCAN_START == type)\r
1921         {\r
1922                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));\r
1923         }\r
1924         else if(BTC_SCAN_FINISH == type)\r
1925         {\r
1926                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));\r
1927         }\r
1928 }\r
1929 \r
1930 VOID\r
1931 EXhalbtc8188c2ant_ConnectNotify(\r
1932         IN      PBTC_COEXIST            pBtCoexist,\r
1933         IN      u1Byte                  type\r
1934         )\r
1935 {\r
1936         if(BTC_ASSOCIATE_START == type)\r
1937         {\r
1938                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));\r
1939         }\r
1940         else if(BTC_ASSOCIATE_FINISH == type)\r
1941         {\r
1942                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));\r
1943         }\r
1944 }\r
1945 \r
1946 VOID\r
1947 EXhalbtc8188c2ant_MediaStatusNotify(\r
1948         IN      PBTC_COEXIST                    pBtCoexist,\r
1949         IN      u1Byte                          type\r
1950         )\r
1951 {       \r
1952         if(BTC_MEDIA_CONNECT == type)\r
1953         {\r
1954                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));\r
1955         }\r
1956         else\r
1957         {\r
1958                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));\r
1959         }\r
1960         \r
1961 }\r
1962 \r
1963 VOID\r
1964 EXhalbtc8188c2ant_SpecialPacketNotify(\r
1965         IN      PBTC_COEXIST                    pBtCoexist,\r
1966         IN      u1Byte                          type\r
1967         )\r
1968 {\r
1969         if(type == BTC_PACKET_DHCP)\r
1970         {\r
1971                 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));\r
1972         }\r
1973 }\r
1974 \r
1975 VOID\r
1976 EXhalbtc8188c2ant_BtInfoNotify(\r
1977         IN      PBTC_COEXIST            pBtCoexist,\r
1978         IN      pu1Byte                 tmpBuf,\r
1979         IN      u1Byte                  length\r
1980         )\r
1981 {\r
1982 }\r
1983 \r
1984 VOID\r
1985 EXhalbtc8188c2ant_HaltNotify(\r
1986         IN      PBTC_COEXIST                    pBtCoexist\r
1987         )\r
1988 {\r
1989         BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));\r
1990 \r
1991         EXhalbtc8188c2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);\r
1992 }\r
1993 \r
1994 VOID\r
1995 EXhalbtc8188c2ant_Periodical(\r
1996         IN      PBTC_COEXIST                    pBtCoexist\r
1997         )\r
1998 {\r
1999         u1Byte  algorithm;\r
2000 \r
2001         BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], 2Ant Periodical!!\n"));\r
2002 \r
2003         // NOTE:\r
2004         // sw mechanism must be done after fw mechanism\r
2005         // \r
2006 \r
2007         if((BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) ||\r
2008                 (BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) )\r
2009         {\r
2010                 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_GET_BT_RSSI, NULL);\r
2011 \r
2012                 halbtc8188c2ant_MonitorBtState(pBtCoexist);\r
2013                 algorithm = halbtc8188c2ant_ActionAlgorithm(pBtCoexist);        \r
2014                 pCoexDm->curAlgorithm = algorithm;\r
2015                 switch(pCoexDm->curAlgorithm)\r
2016                 {\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
2020                                 break;\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
2024                                 break;\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
2028                                 break;\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
2032                                 break;\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
2036                                 break;\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
2040                                 break;\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
2044                                 break;\r
2045                         default:\r
2046                                 break;\r
2047                 }\r
2048         }\r
2049 }\r
2050 \r
2051 \r
2052 #endif\r
2053 \r