1 /* SPDX-License-Identifier: GPL-2.0 */
2 //============================================================
3 // Description:
4 //
5 // This file is for RTL8723A Co-exist mechanism
6 //
7 // History
8 // 2012/08/22 Cosa first check in.
9 // 2012/11/14 Cosa Revise for 8723A 2Ant out sourcing.
10 //
11 //============================================================
12
13 //============================================================
14 // include files
15 //============================================================
16 #include "Mp_Precomp.h"
17
18 #if WPP_SOFTWARE_TRACE
19 #include "HalBtc8723a2Ant.tmh"
20 #endif
21
22 #if(BT_30_SUPPORT == 1)
23 //============================================================
24 // Global variables, these are static variables
25 //============================================================
26 static COEX_DM_8723A_2ANT GLCoexDm8723a2Ant;
27 static PCOEX_DM_8723A_2ANT pCoexDm=&GLCoexDm8723a2Ant;
28 static COEX_STA_8723A_2ANT GLCoexSta8723a2Ant;
29 static PCOEX_STA_8723A_2ANT pCoexSta=&GLCoexSta8723a2Ant;
30
31 const char *const GLBtInfoSrc8723a2Ant[]={
32 "BT Info[wifi fw]",
33 "BT Info[bt rsp]",
34 "BT Info[bt auto report]",
35 };
36
37 //============================================================
38 // local function proto type if needed
39 //============================================================
40 //============================================================
41 // local function start with halbtc8723a2ant_
42 //============================================================
43 BOOLEAN
halbtc8723a2ant_IsWifiIdle(IN PBTC_COEXIST pBtCoexist)44 halbtc8723a2ant_IsWifiIdle(
45 IN PBTC_COEXIST pBtCoexist
46 )
47 {
48 BOOLEAN bWifiConnected=FALSE, bScan=FALSE, bLink=FALSE, bRoam=FALSE;
49
50 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
51 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
52 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
53 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
54
55 if(bWifiConnected)
56 return FALSE;
57 if(bScan)
58 return FALSE;
59 if(bLink)
60 return FALSE;
61 if(bRoam)
62 return FALSE;
63
64 return TRUE;
65 }
66
67 BOOLEAN
halbtc8723a2ant_IsWifiConnectedIdle(IN PBTC_COEXIST pBtCoexist)68 halbtc8723a2ant_IsWifiConnectedIdle(
69 IN PBTC_COEXIST pBtCoexist
70 )
71 {
72 BOOLEAN bWifiConnected=FALSE, bScan=FALSE, bLink=FALSE, bRoam=FALSE, bWifiBusy=FALSE;
73
74 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
75 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
76 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
77 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
78 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
79
80 if(bScan)
81 return FALSE;
82 if(bLink)
83 return FALSE;
84 if(bRoam)
85 return FALSE;
86 if(bWifiConnected && !bWifiBusy)
87 return TRUE;
88 else
89 return FALSE;
90 }
91
92 u1Byte
halbtc8723a2ant_BtRssiState(u1Byte levelNum,u1Byte rssiThresh,u1Byte rssiThresh1)93 halbtc8723a2ant_BtRssiState(
94 u1Byte levelNum,
95 u1Byte rssiThresh,
96 u1Byte rssiThresh1
97 )
98 {
99 s4Byte btRssi=0;
100 u1Byte btRssiState=pCoexSta->preBtRssiState;
101
102 btRssi = pCoexSta->btRssi;
103
104 if(levelNum == 2)
105 {
106 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
107 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
108 {
109 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
110 {
111 btRssiState = BTC_RSSI_STATE_HIGH;
112 }
113 else
114 {
115 btRssiState = BTC_RSSI_STATE_STAY_LOW;
116 }
117 }
118 else
119 {
120 if(btRssi < rssiThresh)
121 {
122 btRssiState = BTC_RSSI_STATE_LOW;
123 }
124 else
125 {
126 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
127 }
128 }
129 }
130 else if(levelNum == 3)
131 {
132 if(rssiThresh > rssiThresh1)
133 {
134 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n"));
135 return pCoexSta->preBtRssiState;
136 }
137
138 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
139 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
140 {
141 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
142 {
143 btRssiState = BTC_RSSI_STATE_MEDIUM;
144 }
145 else
146 {
147 btRssiState = BTC_RSSI_STATE_STAY_LOW;
148 }
149 }
150 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
151 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
152 {
153 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
154 {
155 btRssiState = BTC_RSSI_STATE_HIGH;
156 }
157 else if(btRssi < rssiThresh)
158 {
159 btRssiState = BTC_RSSI_STATE_LOW;
160 }
161 else
162 {
163 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
164 }
165 }
166 else
167 {
168 if(btRssi < rssiThresh1)
169 {
170 btRssiState = BTC_RSSI_STATE_MEDIUM;
171 }
172 else
173 {
174 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
175 }
176 }
177 }
178
179 pCoexSta->preBtRssiState = btRssiState;
180
181 return btRssiState;
182 }
183
184 u1Byte
halbtc8723a2ant_WifiRssiState(IN PBTC_COEXIST pBtCoexist,IN u1Byte index,IN u1Byte levelNum,IN u1Byte rssiThresh,IN u1Byte rssiThresh1)185 halbtc8723a2ant_WifiRssiState(
186 IN PBTC_COEXIST pBtCoexist,
187 IN u1Byte index,
188 IN u1Byte levelNum,
189 IN u1Byte rssiThresh,
190 IN u1Byte rssiThresh1
191 )
192 {
193 s4Byte wifiRssi=0;
194 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
195
196 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
197
198 if(levelNum == 2)
199 {
200 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
201 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
202 {
203 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
204 {
205 wifiRssiState = BTC_RSSI_STATE_HIGH;
206 }
207 else
208 {
209 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
210 }
211 }
212 else
213 {
214 if(wifiRssi < rssiThresh)
215 {
216 wifiRssiState = BTC_RSSI_STATE_LOW;
217 }
218 else
219 {
220 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
221 }
222 }
223 }
224 else if(levelNum == 3)
225 {
226 if(rssiThresh > rssiThresh1)
227 {
228 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n"));
229 return pCoexSta->preWifiRssiState[index];
230 }
231
232 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
233 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
234 {
235 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
236 {
237 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
238 }
239 else
240 {
241 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
242 }
243 }
244 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
245 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
246 {
247 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
248 {
249 wifiRssiState = BTC_RSSI_STATE_HIGH;
250 }
251 else if(wifiRssi < rssiThresh)
252 {
253 wifiRssiState = BTC_RSSI_STATE_LOW;
254 }
255 else
256 {
257 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
258 }
259 }
260 else
261 {
262 if(wifiRssi < rssiThresh1)
263 {
264 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
265 }
266 else
267 {
268 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
269 }
270 }
271 }
272
273 pCoexSta->preWifiRssiState[index] = wifiRssiState;
274
275 return wifiRssiState;
276 }
277
278 VOID
halbtc8723a2ant_IndicateWifiChnlBwInfo(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)279 halbtc8723a2ant_IndicateWifiChnlBwInfo(
280 IN PBTC_COEXIST pBtCoexist,
281 IN u1Byte type
282 )
283 {
284 u1Byte H2C_Parameter[3] ={0};
285 u4Byte wifiBw;
286 u1Byte wifiCentralChnl;
287
288 // only 2.4G we need to inform bt the chnl mask
289 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
290 if( (BTC_MEDIA_CONNECT == type) &&
291 (wifiCentralChnl <= 14) )
292 {
293 H2C_Parameter[0] = 0x1;
294 H2C_Parameter[1] = wifiCentralChnl;
295 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
296 if(BTC_WIFI_BW_HT40 == wifiBw)
297 H2C_Parameter[2] = 0x30;
298 else
299 H2C_Parameter[2] = 0x20;
300 }
301
302 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
303 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
304 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
305
306 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x19=0x%x\n",
307 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
308
309 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x19, 3, H2C_Parameter);
310 }
311
312 VOID
halbtc8723a2ant_QueryBtInfo(IN PBTC_COEXIST pBtCoexist)313 halbtc8723a2ant_QueryBtInfo(
314 IN PBTC_COEXIST pBtCoexist
315 )
316 {
317 u1Byte H2C_Parameter[1] ={0};
318
319 pCoexSta->bC2hBtInfoReqSent = TRUE;
320
321 H2C_Parameter[0] |= BIT0; // trigger
322
323 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x38=0x%x\n",
324 H2C_Parameter[0]));
325
326 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x38, 1, H2C_Parameter);
327 }
328 u1Byte
halbtc8723a2ant_ActionAlgorithm(IN PBTC_COEXIST pBtCoexist)329 halbtc8723a2ant_ActionAlgorithm(
330 IN PBTC_COEXIST pBtCoexist
331 )
332 {
333 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
334 BOOLEAN bBtHsOn=FALSE, bBtBusy=FALSE, bLimitedDig=FALSE;
335 u1Byte algorithm=BT_8723A_2ANT_COEX_ALGO_UNDEFINED;
336 u1Byte numOfDiffProfile=0;
337
338 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
339
340 //======================
341 // here we get BT status first
342 //======================
343 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_IDLE;
344
345 if((pStackInfo->bScoExist) ||(bBtHsOn) ||(pStackInfo->bHidExist))
346 {
347 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO or HID or HS exists, set BT non-idle !!!\n"));
348 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
349 }
350 else
351 {
352 // A2dp profile
353 if( (pBtCoexist->stackInfo.numOfLink == 1) &&
354 (pStackInfo->bA2dpExist) )
355 {
356 if( (pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 100)
357 {
358 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP, low priority tx+rx < 100, set BT connected-idle!!!\n"));
359 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
360 }
361 else
362 {
363 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP, low priority tx+rx >= 100, set BT non-idle!!!\n"));
364 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
365 }
366 }
367 // Pan profile
368 if( (pBtCoexist->stackInfo.numOfLink == 1) &&
369 (pStackInfo->bPanExist) )
370 {
371 if((pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 600)
372 {
373 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN, low priority tx+rx < 600, set BT connected-idle!!!\n"));
374 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
375 }
376 else
377 {
378 if(pCoexSta->lowPriorityTx)
379 {
380 if((pCoexSta->lowPriorityRx /pCoexSta->lowPriorityTx)>9 )
381 {
382 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN, low priority rx/tx > 9, set BT connected-idle!!!\n"));
383 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
384 }
385 }
386 }
387 if(BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus)
388 {
389 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN, set BT non-idle!!!\n"));
390 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
391 }
392 }
393 // Pan+A2dp profile
394 if( (pBtCoexist->stackInfo.numOfLink == 2) &&
395 (pStackInfo->bA2dpExist) &&
396 (pStackInfo->bPanExist) )
397 {
398 if((pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 600)
399 {
400 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN+A2DP, low priority tx+rx < 600, set BT connected-idle!!!\n"));
401 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
402 }
403 else
404 {
405 if(pCoexSta->lowPriorityTx)
406 {
407 if((pCoexSta->lowPriorityRx /pCoexSta->lowPriorityTx)>9 )
408 {
409 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN+A2DP, low priority rx/tx > 9, set BT connected-idle!!!\n"));
410 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
411 }
412 }
413 }
414 if(BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus)
415 {
416 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN+A2DP, set BT non-idle!!!\n"));
417 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
418 }
419 }
420 }
421 if(BT_8723A_2ANT_BT_STATUS_IDLE != pCoexDm->btStatus)
422 {
423 bBtBusy = TRUE;
424 bLimitedDig = TRUE;
425 }
426 else
427 {
428 bBtBusy = FALSE;
429 bLimitedDig = FALSE;
430 }
431 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
432 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig);
433 //======================
434
435 if(!pStackInfo->bBtLinkExist)
436 {
437 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No profile exists!!!\n"));
438 return algorithm;
439 }
440
441 if(pStackInfo->bScoExist)
442 numOfDiffProfile++;
443 if(pStackInfo->bHidExist)
444 numOfDiffProfile++;
445 if(pStackInfo->bPanExist)
446 numOfDiffProfile++;
447 if(pStackInfo->bA2dpExist)
448 numOfDiffProfile++;
449
450 if(numOfDiffProfile == 1)
451 {
452 if(pStackInfo->bScoExist)
453 {
454 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n"));
455 algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
456 }
457 else
458 {
459 if(pStackInfo->bHidExist)
460 {
461 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n"));
462 algorithm = BT_8723A_2ANT_COEX_ALGO_HID;
463 }
464 else if(pStackInfo->bA2dpExist)
465 {
466 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n"));
467 algorithm = BT_8723A_2ANT_COEX_ALGO_A2DP;
468 }
469 else if(pStackInfo->bPanExist)
470 {
471 if(bBtHsOn)
472 {
473 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n"));
474 algorithm = BT_8723A_2ANT_COEX_ALGO_PANHS;
475 }
476 else
477 {
478 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n"));
479 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR;
480 }
481 }
482 }
483 }
484 else if(numOfDiffProfile == 2)
485 {
486 if(pStackInfo->bScoExist)
487 {
488 if(pStackInfo->bHidExist)
489 {
490 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n"));
491 algorithm = BT_8723A_2ANT_COEX_ALGO_HID;
492 }
493 else if(pStackInfo->bA2dpExist)
494 {
495 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n"));
496 algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
497 }
498 else if(pStackInfo->bPanExist)
499 {
500 if(bBtHsOn)
501 {
502 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n"));
503 algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
504 }
505 else
506 {
507 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n"));
508 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
509 }
510 }
511 }
512 else
513 {
514 if( pStackInfo->bHidExist &&
515 pStackInfo->bA2dpExist )
516 {
517 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n"));
518 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
519 }
520 else if( pStackInfo->bHidExist &&
521 pStackInfo->bPanExist )
522 {
523 if(bBtHsOn)
524 {
525 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n"));
526 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
527 }
528 else
529 {
530 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n"));
531 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
532 }
533 }
534 else if( pStackInfo->bPanExist &&
535 pStackInfo->bA2dpExist )
536 {
537 if(bBtHsOn)
538 {
539 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n"));
540 algorithm = BT_8723A_2ANT_COEX_ALGO_A2DP;
541 }
542 else
543 {
544 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n"));
545 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP;
546 }
547 }
548 }
549 }
550 else if(numOfDiffProfile == 3)
551 {
552 if(pStackInfo->bScoExist)
553 {
554 if( pStackInfo->bHidExist &&
555 pStackInfo->bA2dpExist )
556 {
557 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> HID\n"));
558 algorithm = BT_8723A_2ANT_COEX_ALGO_HID;
559 }
560 else if( pStackInfo->bHidExist &&
561 pStackInfo->bPanExist )
562 {
563 if(bBtHsOn)
564 {
565 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS)\n"));
566 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
567 }
568 else
569 {
570 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
571 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
572 }
573 }
574 else if( pStackInfo->bPanExist &&
575 pStackInfo->bA2dpExist )
576 {
577 if(bBtHsOn)
578 {
579 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
580 algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
581 }
582 else
583 {
584 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
585 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
586 }
587 }
588 }
589 else
590 {
591 if( pStackInfo->bHidExist &&
592 pStackInfo->bPanExist &&
593 pStackInfo->bA2dpExist )
594 {
595 if(bBtHsOn)
596 {
597 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
598 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
599 }
600 else
601 {
602 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
603 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
604 }
605 }
606 }
607 }
608 else if(numOfDiffProfile >= 3)
609 {
610 if(pStackInfo->bScoExist)
611 {
612 if( pStackInfo->bHidExist &&
613 pStackInfo->bPanExist &&
614 pStackInfo->bA2dpExist )
615 {
616 if(bBtHsOn)
617 {
618 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
619
620 }
621 else
622 {
623 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
624 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
625 }
626 }
627 }
628 }
629
630 return algorithm;
631 }
632
633 BOOLEAN
halbtc8723a2ant_NeedToDecBtPwr(IN PBTC_COEXIST pBtCoexist)634 halbtc8723a2ant_NeedToDecBtPwr(
635 IN PBTC_COEXIST pBtCoexist
636 )
637 {
638 BOOLEAN bRet=FALSE;
639 BOOLEAN bBtHsOn=FALSE, bWifiConnected=FALSE;
640 s4Byte btHsRssi=0;
641 u1Byte btRssiState=BTC_RSSI_STATE_HIGH;
642
643 btRssiState = halbtc8723a2ant_BtRssiState(2, 42, 0);
644
645 if(!pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn))
646 return FALSE;
647 if(!pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected))
648 return FALSE;
649 if(!pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi))
650 return FALSE;
651 if(BTC_RSSI_LOW(btRssiState))
652 return FALSE;
653
654 if(bWifiConnected)
655 {
656 if(bBtHsOn)
657 {
658 if(btHsRssi > 37)
659 {
660 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Need to decrease bt power for HS mode!!\n"));
661 bRet = TRUE;
662 }
663 }
664 else
665 {
666 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Need to decrease bt power for Wifi is connected!!\n"));
667 bRet = TRUE;
668 }
669 }
670
671 return bRet;
672 }
673
674 VOID
halbtc8723a2ant_SetFwDacSwingLevel(IN PBTC_COEXIST pBtCoexist,IN u1Byte dacSwingLvl)675 halbtc8723a2ant_SetFwDacSwingLevel(
676 IN PBTC_COEXIST pBtCoexist,
677 IN u1Byte dacSwingLvl
678 )
679 {
680 u1Byte H2C_Parameter[1] ={0};
681
682 // There are several type of dacswing
683 // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
684 H2C_Parameter[0] = dacSwingLvl;
685
686 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl));
687 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x29=0x%x\n", H2C_Parameter[0]));
688
689 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x29, 1, H2C_Parameter);
690 }
691
692 VOID
halbtc8723a2ant_SetFwDecBtPwr(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bDecBtPwr)693 halbtc8723a2ant_SetFwDecBtPwr(
694 IN PBTC_COEXIST pBtCoexist,
695 IN BOOLEAN bDecBtPwr
696 )
697 {
698 u1Byte H2C_Parameter[1] ={0};
699
700 H2C_Parameter[0] = 0;
701
702 if(bDecBtPwr)
703 {
704 H2C_Parameter[0] |= BIT1;
705 }
706
707 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power : %s, FW write 0x21=0x%x\n",
708 (bDecBtPwr? "Yes!!":"No!!"), H2C_Parameter[0]));
709
710 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x21, 1, H2C_Parameter);
711 }
712
713 VOID
halbtc8723a2ant_DecBtPwr(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bDecBtPwr)714 halbtc8723a2ant_DecBtPwr(
715 IN PBTC_COEXIST pBtCoexist,
716 IN BOOLEAN bForceExec,
717 IN BOOLEAN bDecBtPwr
718 )
719 {
720 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power = %s\n",
721 (bForceExec? "force to":""), ((bDecBtPwr)? "ON":"OFF")));
722 pCoexDm->bCurDecBtPwr = bDecBtPwr;
723
724 if(!bForceExec)
725 {
726 if(pCoexDm->bPreDecBtPwr == pCoexDm->bCurDecBtPwr)
727 return;
728 }
729 halbtc8723a2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->bCurDecBtPwr);
730
731 pCoexDm->bPreDecBtPwr = pCoexDm->bCurDecBtPwr;
732 }
733
734 VOID
halbtc8723a2ant_FwDacSwingLvl(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte fwDacSwingLvl)735 halbtc8723a2ant_FwDacSwingLvl(
736 IN PBTC_COEXIST pBtCoexist,
737 IN BOOLEAN bForceExec,
738 IN u1Byte fwDacSwingLvl
739 )
740 {
741 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n",
742 (bForceExec? "force to":""), fwDacSwingLvl));
743 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
744
745 if(!bForceExec)
746 {
747 if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
748 return;
749 }
750
751 halbtc8723a2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
752
753 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
754 }
755
756 VOID
halbtc8723a2ant_SetSwRfRxLpfCorner(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bRxRfShrinkOn)757 halbtc8723a2ant_SetSwRfRxLpfCorner(
758 IN PBTC_COEXIST pBtCoexist,
759 IN BOOLEAN bRxRfShrinkOn
760 )
761 {
762 if(bRxRfShrinkOn)
763 {
764 //Shrink RF Rx LPF corner
765 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
766 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7);
767 }
768 else
769 {
770 //Resume RF Rx LPF corner
771 // After initialized, we can use pCoexDm->btRf0x1eBackup
772 if(pBtCoexist->bInitilized)
773 {
774 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
775 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
776 }
777 }
778 }
779
780 VOID
halbtc8723a2ant_RfShrink(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bRxRfShrinkOn)781 halbtc8723a2ant_RfShrink(
782 IN PBTC_COEXIST pBtCoexist,
783 IN BOOLEAN bForceExec,
784 IN BOOLEAN bRxRfShrinkOn
785 )
786 {
787 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
788 (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
789 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
790
791 if(!bForceExec)
792 {
793 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
794 return;
795 }
796 halbtc8723a2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
797
798 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
799 }
800
801 VOID
halbtc8723a2ant_SetSwPenaltyTxRateAdaptive(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bLowPenaltyRa)802 halbtc8723a2ant_SetSwPenaltyTxRateAdaptive(
803 IN PBTC_COEXIST pBtCoexist,
804 IN BOOLEAN bLowPenaltyRa
805 )
806 {
807 u1Byte tmpU1;
808
809 tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd);
810 tmpU1 |= BIT0;
811 if(bLowPenaltyRa)
812 {
813 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
814 tmpU1 &= ~BIT2;
815 }
816 else
817 {
818 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
819 tmpU1 |= BIT2;
820 }
821
822 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1);
823 }
824
825 VOID
halbtc8723a2ant_LowPenaltyRa(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bLowPenaltyRa)826 halbtc8723a2ant_LowPenaltyRa(
827 IN PBTC_COEXIST pBtCoexist,
828 IN BOOLEAN bForceExec,
829 IN BOOLEAN bLowPenaltyRa
830 )
831 {
832 return;
833 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
834 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
835 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
836
837 if(!bForceExec)
838 {
839 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
840 return;
841 }
842 halbtc8723a2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
843
844 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
845 }
846
847 VOID
halbtc8723a2ant_SetSwFullTimeDacSwing(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bSwDacSwingOn,IN u4Byte swDacSwingLvl)848 halbtc8723a2ant_SetSwFullTimeDacSwing(
849 IN PBTC_COEXIST pBtCoexist,
850 IN BOOLEAN bSwDacSwingOn,
851 IN u4Byte swDacSwingLvl
852 )
853 {
854 if(bSwDacSwingOn)
855 {
856 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, swDacSwingLvl);
857 }
858 else
859 {
860 pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0);
861 }
862 }
863
864
865 VOID
halbtc8723a2ant_DacSwing(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bDacSwingOn,IN u4Byte dacSwingLvl)866 halbtc8723a2ant_DacSwing(
867 IN PBTC_COEXIST pBtCoexist,
868 IN BOOLEAN bForceExec,
869 IN BOOLEAN bDacSwingOn,
870 IN u4Byte dacSwingLvl
871 )
872 {
873 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
874 (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
875 pCoexDm->bCurDacSwingOn = bDacSwingOn;
876 pCoexDm->curDacSwingLvl = dacSwingLvl;
877
878 if(!bForceExec)
879 {
880 if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
881 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
882 return;
883 }
884 delay_ms(30);
885 halbtc8723a2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
886
887 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
888 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
889 }
890
891 VOID
halbtc8723a2ant_SetAdcBackOff(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bAdcBackOff)892 halbtc8723a2ant_SetAdcBackOff(
893 IN PBTC_COEXIST pBtCoexist,
894 IN BOOLEAN bAdcBackOff
895 )
896 {
897 if(bAdcBackOff)
898 {
899 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n"));
900 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a07611);
901 }
902 else
903 {
904 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n"));
905 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a05611);
906 }
907 }
908
909 VOID
halbtc8723a2ant_AdcBackOff(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bAdcBackOff)910 halbtc8723a2ant_AdcBackOff(
911 IN PBTC_COEXIST pBtCoexist,
912 IN BOOLEAN bForceExec,
913 IN BOOLEAN bAdcBackOff
914 )
915 {
916 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n",
917 (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));
918 pCoexDm->bCurAdcBackOff = bAdcBackOff;
919
920 if(!bForceExec)
921 {
922 if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff)
923 return;
924 }
925 halbtc8723a2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
926
927 pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
928 }
929
930 VOID
halbtc8723a2ant_SetAgcTable(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bAgcTableEn)931 halbtc8723a2ant_SetAgcTable(
932 IN PBTC_COEXIST pBtCoexist,
933 IN BOOLEAN bAgcTableEn
934 )
935 {
936 u1Byte rssiAdjustVal=0;
937
938 if(bAgcTableEn)
939 {
940 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n"));
941 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4e1c0001);
942 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4d1d0001);
943 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4c1e0001);
944 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4b1f0001);
945 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4a200001);
946
947 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xdc000);
948 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x90000);
949 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x51000);
950 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x12000);
951 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x00355);
952
953 rssiAdjustVal = 6;
954 }
955 else
956 {
957 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n"));
958 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x641c0001);
959 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x631d0001);
960 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x621e0001);
961 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x611f0001);
962 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x60200001);
963
964 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x32000);
965 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x71000);
966 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xb0000);
967 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xfc000);
968 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x30355);
969 }
970
971 // set rssiAdjustVal for wifi module.
972 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
973 }
974
975
976 VOID
halbtc8723a2ant_AgcTable(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bAgcTableEn)977 halbtc8723a2ant_AgcTable(
978 IN PBTC_COEXIST pBtCoexist,
979 IN BOOLEAN bForceExec,
980 IN BOOLEAN bAgcTableEn
981 )
982 {
983 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n",
984 (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));
985 pCoexDm->bCurAgcTableEn = bAgcTableEn;
986
987 if(!bForceExec)
988 {
989 if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
990 return;
991 }
992 halbtc8723a2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
993
994 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
995 }
996
997 VOID
halbtc8723a2ant_SetCoexTable(IN PBTC_COEXIST pBtCoexist,IN u4Byte val0x6c0,IN u4Byte val0x6c8,IN u1Byte val0x6cc)998 halbtc8723a2ant_SetCoexTable(
999 IN PBTC_COEXIST pBtCoexist,
1000 IN u4Byte val0x6c0,
1001 IN u4Byte val0x6c8,
1002 IN u1Byte val0x6cc
1003 )
1004 {
1005 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
1006 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
1007
1008 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
1009 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
1010
1011 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
1012 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
1013 }
1014
1015 VOID
halbtc8723a2ant_CoexTable(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u4Byte val0x6c0,IN u4Byte val0x6c8,IN u1Byte val0x6cc)1016 halbtc8723a2ant_CoexTable(
1017 IN PBTC_COEXIST pBtCoexist,
1018 IN BOOLEAN bForceExec,
1019 IN u4Byte val0x6c0,
1020 IN u4Byte val0x6c8,
1021 IN u1Byte val0x6cc
1022 )
1023 {
1024 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
1025 (bForceExec? "force to":""), val0x6c0, val0x6c8, val0x6cc));
1026 pCoexDm->curVal0x6c0 = val0x6c0;
1027 pCoexDm->curVal0x6c8 = val0x6c8;
1028 pCoexDm->curVal0x6cc = val0x6cc;
1029
1030 if(!bForceExec)
1031 {
1032 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
1033 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
1034 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
1035 return;
1036 }
1037 halbtc8723a2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c8, val0x6cc);
1038
1039 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
1040 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
1041 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
1042 }
1043
1044 VOID
halbtc8723a2ant_SetFwIgnoreWlanAct(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bEnable)1045 halbtc8723a2ant_SetFwIgnoreWlanAct(
1046 IN PBTC_COEXIST pBtCoexist,
1047 IN BOOLEAN bEnable
1048 )
1049 {
1050 u1Byte H2C_Parameter[1] ={0};
1051
1052 if(bEnable)
1053 {
1054 H2C_Parameter[0] |= BIT0; // function enable
1055 }
1056
1057 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x25=0x%x\n",
1058 H2C_Parameter[0]));
1059
1060 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x25, 1, H2C_Parameter);
1061 }
1062
1063 VOID
halbtc8723a2ant_IgnoreWlanAct(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bEnable)1064 halbtc8723a2ant_IgnoreWlanAct(
1065 IN PBTC_COEXIST pBtCoexist,
1066 IN BOOLEAN bForceExec,
1067 IN BOOLEAN bEnable
1068 )
1069 {
1070 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n",
1071 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
1072 pCoexDm->bCurIgnoreWlanAct = bEnable;
1073
1074 if(!bForceExec)
1075 {
1076 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
1077 return;
1078 }
1079 halbtc8723a2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
1080
1081 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
1082 }
1083
1084 VOID
halbtc8723a2ant_SetFwPstdma(IN PBTC_COEXIST pBtCoexist,IN u1Byte byte1,IN u1Byte byte2,IN u1Byte byte3,IN u1Byte byte4,IN u1Byte byte5)1085 halbtc8723a2ant_SetFwPstdma(
1086 IN PBTC_COEXIST pBtCoexist,
1087 IN u1Byte byte1,
1088 IN u1Byte byte2,
1089 IN u1Byte byte3,
1090 IN u1Byte byte4,
1091 IN u1Byte byte5
1092 )
1093 {
1094 u1Byte H2C_Parameter[5] ={0};
1095
1096 H2C_Parameter[0] = byte1;
1097 H2C_Parameter[1] = byte2;
1098 H2C_Parameter[2] = byte3;
1099 H2C_Parameter[3] = byte4;
1100 H2C_Parameter[4] = byte5;
1101
1102 pCoexDm->psTdmaPara[0] = byte1;
1103 pCoexDm->psTdmaPara[1] = byte2;
1104 pCoexDm->psTdmaPara[2] = byte3;
1105 pCoexDm->psTdmaPara[3] = byte4;
1106 pCoexDm->psTdmaPara[4] = byte5;
1107
1108 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x3a(5bytes)=0x%x%08x\n",
1109 H2C_Parameter[0],
1110 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
1111
1112 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x3a, 5, H2C_Parameter);
1113 }
1114
1115 VOID
halbtc8723a2ant_PsTdma(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bTurnOn,IN u1Byte type)1116 halbtc8723a2ant_PsTdma(
1117 IN PBTC_COEXIST pBtCoexist,
1118 IN BOOLEAN bForceExec,
1119 IN BOOLEAN bTurnOn,
1120 IN u1Byte type
1121 )
1122 {
1123 u4Byte btTxRxCnt=0;
1124
1125 btTxRxCnt = pCoexSta->highPriorityTx+pCoexSta->highPriorityRx+
1126 pCoexSta->lowPriorityTx+pCoexSta->lowPriorityRx;
1127
1128 if(btTxRxCnt > 3000)
1129 {
1130 pCoexDm->bCurPsTdmaOn = TRUE;
1131 pCoexDm->curPsTdma = 8;
1132 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], turn ON PS TDMA, type=%d for BT tx/rx counters=%d(>3000)\n",
1133 pCoexDm->curPsTdma, btTxRxCnt));
1134 }
1135 else
1136 {
1137 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
1138 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
1139 pCoexDm->bCurPsTdmaOn = bTurnOn;
1140 pCoexDm->curPsTdma = type;
1141 }
1142
1143 if(!bForceExec)
1144 {
1145 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
1146 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
1147 return;
1148 }
1149 if(pCoexDm->bCurPsTdmaOn)
1150 {
1151 switch(pCoexDm->curPsTdma)
1152 {
1153 case 1:
1154 default:
1155 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x98);
1156 break;
1157 case 2:
1158 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x98);
1159 break;
1160 case 3:
1161 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x98);
1162 break;
1163 case 4:
1164 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x5, 0x5, 0xe1, 0x80);
1165 break;
1166 case 5:
1167 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x98);
1168 break;
1169 case 6:
1170 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x98);
1171 break;
1172 case 7:
1173 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x98);
1174 break;
1175 case 8:
1176 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x5, 0x5, 0x60, 0x80);
1177 break;
1178 case 9:
1179 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x98);
1180 break;
1181 case 10:
1182 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x98);
1183 break;
1184 case 11:
1185 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x98);
1186 break;
1187 case 12:
1188 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x98);
1189 break;
1190 case 13:
1191 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x98);
1192 break;
1193 case 14:
1194 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x98);
1195 break;
1196 case 15:
1197 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x98);
1198 break;
1199 case 16:
1200 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x98);
1201 break;
1202 case 17:
1203 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x80);
1204 break;
1205 case 18:
1206 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x98);
1207 break;
1208 case 19:
1209 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x98);
1210 break;
1211 case 20:
1212 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x98);
1213 break;
1214 }
1215 }
1216 else
1217 {
1218 // disable PS tdma
1219 switch(pCoexDm->curPsTdma)
1220 {
1221 case 0:
1222 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
1223 break;
1224 case 1:
1225 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
1226 break;
1227 default:
1228 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
1229 break;
1230 }
1231 }
1232
1233 // update pre state
1234 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1235 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1236 }
1237
1238
1239 VOID
halbtc8723a2ant_CoexAllOff(IN PBTC_COEXIST pBtCoexist)1240 halbtc8723a2ant_CoexAllOff(
1241 IN PBTC_COEXIST pBtCoexist
1242 )
1243 {
1244 // fw all off
1245 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1246 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1247 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1248 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1249
1250 // sw all off
1251 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1252 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1253 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
1254 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
1255 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1256
1257 // hw all off
1258 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1259 }
1260
1261 VOID
halbtc8723a2ant_InitCoexDm(IN PBTC_COEXIST pBtCoexist)1262 halbtc8723a2ant_InitCoexDm(
1263 IN PBTC_COEXIST pBtCoexist
1264 )
1265 {
1266 // force to reset coex mechanism
1267 halbtc8723a2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0x55555555, 0xffff, 0x3);
1268 halbtc8723a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
1269 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 0x20);
1270 halbtc8723a2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, FALSE);
1271 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
1272
1273 halbtc8723a2ant_AgcTable(pBtCoexist, FORCE_EXEC, FALSE);
1274 halbtc8723a2ant_AdcBackOff(pBtCoexist, FORCE_EXEC, FALSE);
1275 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, FORCE_EXEC, FALSE);
1276 halbtc8723a2ant_RfShrink(pBtCoexist, FORCE_EXEC, FALSE);
1277 halbtc8723a2ant_DacSwing(pBtCoexist, FORCE_EXEC, FALSE, 0xc0);
1278 }
1279
1280 VOID
halbtc8723a2ant_BtInquiryPage(IN PBTC_COEXIST pBtCoexist)1281 halbtc8723a2ant_BtInquiryPage(
1282 IN PBTC_COEXIST pBtCoexist
1283 )
1284 {
1285 BOOLEAN bLowPwrDisable=TRUE;
1286
1287 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1288
1289 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1290 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1291 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
1292 }
1293
1294 VOID
halbtc8723a2ant_BtEnableAction(IN PBTC_COEXIST pBtCoexist)1295 halbtc8723a2ant_BtEnableAction(
1296 IN PBTC_COEXIST pBtCoexist
1297 )
1298 {
1299 BOOLEAN bWifiConnected=FALSE;
1300
1301 // Here we need to resend some wifi info to BT
1302 // because bt is reset and loss of the info.
1303 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1304 if(bWifiConnected)
1305 {
1306 halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, BTC_MEDIA_CONNECT);
1307 }
1308 else
1309 {
1310 halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, BTC_MEDIA_DISCONNECT);
1311 }
1312
1313 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
1314 }
1315
1316 VOID
halbtc8723a2ant_MonitorBtCtr(IN PBTC_COEXIST pBtCoexist)1317 halbtc8723a2ant_MonitorBtCtr(
1318 IN PBTC_COEXIST pBtCoexist
1319 )
1320 {
1321 u4Byte regHPTxRx, regLPTxRx, u4Tmp;
1322 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
1323 u1Byte u1Tmp;
1324
1325 regHPTxRx = 0x770;
1326 regLPTxRx = 0x774;
1327
1328 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
1329 regHPTx = u4Tmp & bMaskLWord;
1330 regHPRx = (u4Tmp & bMaskHWord)>>16;
1331
1332 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
1333 regLPTx = u4Tmp & bMaskLWord;
1334 regLPRx = (u4Tmp & bMaskHWord)>>16;
1335
1336 pCoexSta->highPriorityTx = regHPTx;
1337 pCoexSta->highPriorityRx = regHPRx;
1338 pCoexSta->lowPriorityTx = regLPTx;
1339 pCoexSta->lowPriorityRx = regLPRx;
1340
1341 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
1342 regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
1343 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
1344 regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
1345
1346 // reset counter
1347 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
1348 }
1349
1350 VOID
halbtc8723a2ant_MonitorBtEnableDisable(IN PBTC_COEXIST pBtCoexist)1351 halbtc8723a2ant_MonitorBtEnableDisable(
1352 IN PBTC_COEXIST pBtCoexist
1353 )
1354 {
1355 static BOOLEAN bPreBtDisabled=FALSE;
1356 static u4Byte btDisableCnt=0;
1357 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
1358
1359 // This function check if bt is disabled
1360
1361 if( pCoexSta->highPriorityTx == 0 &&
1362 pCoexSta->highPriorityRx == 0 &&
1363 pCoexSta->lowPriorityTx == 0 &&
1364 pCoexSta->lowPriorityRx == 0)
1365 {
1366 bBtActive = FALSE;
1367 }
1368 if( pCoexSta->highPriorityTx == 0xffff &&
1369 pCoexSta->highPriorityRx == 0xffff &&
1370 pCoexSta->lowPriorityTx == 0xffff &&
1371 pCoexSta->lowPriorityRx == 0xffff)
1372 {
1373 bBtActive = FALSE;
1374 }
1375 if(bBtActive)
1376 {
1377 btDisableCnt = 0;
1378 bBtDisabled = FALSE;
1379 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
1380 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n"));
1381 }
1382 else
1383 {
1384 btDisableCnt++;
1385 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n",
1386 btDisableCnt));
1387 if(btDisableCnt >= 2)
1388 {
1389 bBtDisabled = TRUE;
1390 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
1391 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n"));
1392 }
1393 }
1394 if(bPreBtDisabled != bBtDisabled)
1395 {
1396 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n",
1397 (bPreBtDisabled ? "disabled":"enabled"),
1398 (bBtDisabled ? "disabled":"enabled")));
1399 bPreBtDisabled = bBtDisabled;
1400 if(!bBtDisabled)
1401 {
1402 halbtc8723a2ant_BtEnableAction(pBtCoexist);
1403 }
1404 }
1405 }
1406
1407 BOOLEAN
halbtc8723a2ant_IsCommonAction(IN PBTC_COEXIST pBtCoexist)1408 halbtc8723a2ant_IsCommonAction(
1409 IN PBTC_COEXIST pBtCoexist
1410 )
1411 {
1412 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
1413 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE;
1414 BOOLEAN bLowPwrDisable=FALSE;
1415
1416 if(!pStackInfo->bBtLinkExist)
1417 {
1418 bLowPwrDisable = FALSE;
1419 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1420 }
1421 else
1422 {
1423 bLowPwrDisable = TRUE;
1424 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1425 }
1426
1427 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1428
1429 if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1430 BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus)
1431 {
1432 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle + Bt idle!!\n"));
1433
1434 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
1435 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
1436 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1437
1438 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1439 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1440 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1441
1442 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1443 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1444 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1445
1446 bCommon = TRUE;
1447 }
1448 else if(!halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1449 (BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus) )
1450 {
1451 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-idle + BT idle!!\n"));
1452
1453 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
1454 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
1455 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1456
1457 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1458 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1459 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1460 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
1461
1462 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1463 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1464 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1465
1466 bCommon = TRUE;
1467 }
1468 else if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1469 (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
1470 {
1471 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle + Bt connected idle!!\n"));
1472
1473 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
1474 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE);
1475 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1476
1477 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1478 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1479 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1480 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1481
1482 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1483 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1484 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1485
1486 bCommon = TRUE;
1487 }
1488 else if(!halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1489 (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
1490 {
1491 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-idle + Bt connected idle!!\n"));
1492
1493 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
1494 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE);
1495 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1496
1497 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1498 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1499 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1500 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1501
1502 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1503 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1504 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1505
1506 bCommon = TRUE;
1507 }
1508 else if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1509 (BT_8723A_2ANT_BT_STATUS_NON_IDLE == pCoexDm->btStatus) )
1510 {
1511 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle + BT non-idle!!\n"));
1512
1513 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
1514 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE);
1515 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1516
1517 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1518 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1519 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1520 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1521
1522 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1523 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1524 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1525
1526 bCommon = TRUE;
1527 }
1528 else if(halbtc8723a2ant_IsWifiConnectedIdle(pBtCoexist) &&
1529 (BT_8723A_2ANT_BT_STATUS_NON_IDLE == pCoexDm->btStatus) )
1530 {
1531 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected-idle + BT non-idle!!\n"));
1532
1533 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
1534 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE);
1535 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1536
1537 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1538 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
1539 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1540 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1541
1542 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1543 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1544 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1545
1546 bCommon = TRUE;
1547 }
1548 else
1549 {
1550 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-idle + BT non-idle!!\n"));
1551 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE);
1552 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE);
1553 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1554 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1555
1556 bCommon = FALSE;
1557 }
1558
1559 return bCommon;
1560 }
1561 VOID
halbtc8723a2ant_TdmaDurationAdjust(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bScoHid,IN BOOLEAN bTxPause,IN u1Byte maxInterval)1562 halbtc8723a2ant_TdmaDurationAdjust(
1563 IN PBTC_COEXIST pBtCoexist,
1564 IN BOOLEAN bScoHid,
1565 IN BOOLEAN bTxPause,
1566 IN u1Byte maxInterval
1567 )
1568 {
1569 static s4Byte up,dn,m,n,WaitCount;
1570 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
1571 u1Byte retryCount=0;
1572
1573 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n"));
1574
1575 if(pCoexDm->bResetTdmaAdjust)
1576 {
1577 pCoexDm->bResetTdmaAdjust = FALSE;
1578 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
1579 {
1580 if(bScoHid)
1581 {
1582 if(bTxPause)
1583 {
1584 if(maxInterval == 1)
1585 {
1586 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
1587 pCoexDm->psTdmaDuAdjType = 13;
1588 }
1589 else if(maxInterval == 2)
1590 {
1591 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
1592 pCoexDm->psTdmaDuAdjType = 14;
1593 }
1594 else if(maxInterval == 3)
1595 {
1596 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
1597 pCoexDm->psTdmaDuAdjType = 15;
1598 }
1599 else
1600 {
1601 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
1602 pCoexDm->psTdmaDuAdjType = 15;
1603 }
1604 }
1605 else
1606 {
1607 if(maxInterval == 1)
1608 {
1609 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
1610 pCoexDm->psTdmaDuAdjType = 9;
1611 }
1612 else if(maxInterval == 2)
1613 {
1614 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
1615 pCoexDm->psTdmaDuAdjType = 10;
1616 }
1617 else if(maxInterval == 3)
1618 {
1619 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
1620 pCoexDm->psTdmaDuAdjType = 11;
1621 }
1622 else
1623 {
1624 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
1625 pCoexDm->psTdmaDuAdjType = 11;
1626 }
1627 }
1628 }
1629 else
1630 {
1631 if(bTxPause)
1632 {
1633 if(maxInterval == 1)
1634 {
1635 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
1636 pCoexDm->psTdmaDuAdjType = 5;
1637 }
1638 else if(maxInterval == 2)
1639 {
1640 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
1641 pCoexDm->psTdmaDuAdjType = 6;
1642 }
1643 else if(maxInterval == 3)
1644 {
1645 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
1646 pCoexDm->psTdmaDuAdjType = 7;
1647 }
1648 else
1649 {
1650 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
1651 pCoexDm->psTdmaDuAdjType = 7;
1652 }
1653 }
1654 else
1655 {
1656 if(maxInterval == 1)
1657 {
1658 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
1659 pCoexDm->psTdmaDuAdjType = 1;
1660 }
1661 else if(maxInterval == 2)
1662 {
1663 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
1664 pCoexDm->psTdmaDuAdjType = 2;
1665 }
1666 else if(maxInterval == 3)
1667 {
1668 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
1669 pCoexDm->psTdmaDuAdjType = 3;
1670 }
1671 else
1672 {
1673 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
1674 pCoexDm->psTdmaDuAdjType = 3;
1675 }
1676 }
1677 }
1678 }
1679 //============
1680 up = 0;
1681 dn = 0;
1682 m = 1;
1683 n= 3;
1684 result = 0;
1685 WaitCount = 0;
1686 }
1687 else
1688 {
1689 //accquire the BT TRx retry count from BT_Info byte2
1690 retryCount = pCoexSta->btRetryCnt;
1691 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount));
1692 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
1693 up, dn, m, n, WaitCount));
1694 result = 0;
1695 WaitCount++;
1696
1697 if(retryCount == 0) // no retry in the last 2-second duration
1698 {
1699 up++;
1700 dn--;
1701
1702 if (dn <= 0)
1703 dn = 0;
1704
1705 if(up >= n) // if �s�� n ��2�� retry count��0, �h�ռeWiFi duration
1706 {
1707 WaitCount = 0;
1708 n = 3;
1709 up = 0;
1710 dn = 0;
1711 result = 1;
1712 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n"));
1713 }
1714 }
1715 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
1716 {
1717 up--;
1718 dn++;
1719
1720 if (up <= 0)
1721 up = 0;
1722
1723 if (dn == 2) // if �s�� 2 ��2�� retry count< 3, �h�կ�WiFi duration
1724 {
1725 if (WaitCount <= 2)
1726 m++; // �קK�@���b���level���Ӧ^
1727 else
1728 m = 1;
1729
1730 if ( m >= 20) //m �̤j�� = 20 ' �̤j120�� recheck�O�_�վ� WiFi duration.
1731 m = 20;
1732
1733 n = 3*m;
1734 up = 0;
1735 dn = 0;
1736 WaitCount = 0;
1737 result = -1;
1738 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
1739 }
1740 }
1741 else //retry count > 3, �u�n1�� retry count > 3, �h�կ�WiFi duration
1742 {
1743 if (WaitCount == 1)
1744 m++; // �קK�@���b���level���Ӧ^
1745 else
1746 m = 1;
1747
1748 if ( m >= 20) //m �̤j�� = 20 ' �̤j120�� recheck�O�_�վ� WiFi duration.
1749 m = 20;
1750
1751 n = 3*m;
1752 up = 0;
1753 dn = 0;
1754 WaitCount = 0;
1755 result = -1;
1756 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
1757 }
1758
1759 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval));
1760 if(maxInterval == 1)
1761 {
1762 if(bTxPause)
1763 {
1764 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
1765
1766 if(pCoexDm->curPsTdma == 1)
1767 {
1768 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
1769 pCoexDm->psTdmaDuAdjType = 5;
1770 }
1771 else if(pCoexDm->curPsTdma == 2)
1772 {
1773 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
1774 pCoexDm->psTdmaDuAdjType = 6;
1775 }
1776 else if(pCoexDm->curPsTdma == 3)
1777 {
1778 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
1779 pCoexDm->psTdmaDuAdjType = 7;
1780 }
1781 else if(pCoexDm->curPsTdma == 4)
1782 {
1783 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
1784 pCoexDm->psTdmaDuAdjType = 8;
1785 }
1786 if(pCoexDm->curPsTdma == 9)
1787 {
1788 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
1789 pCoexDm->psTdmaDuAdjType = 13;
1790 }
1791 else if(pCoexDm->curPsTdma == 10)
1792 {
1793 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
1794 pCoexDm->psTdmaDuAdjType = 14;
1795 }
1796 else if(pCoexDm->curPsTdma == 11)
1797 {
1798 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
1799 pCoexDm->psTdmaDuAdjType = 15;
1800 }
1801 else if(pCoexDm->curPsTdma == 12)
1802 {
1803 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
1804 pCoexDm->psTdmaDuAdjType = 16;
1805 }
1806
1807 if(result == -1)
1808 {
1809 if(pCoexDm->curPsTdma == 5)
1810 {
1811 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
1812 pCoexDm->psTdmaDuAdjType = 6;
1813 }
1814 else if(pCoexDm->curPsTdma == 6)
1815 {
1816 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
1817 pCoexDm->psTdmaDuAdjType = 7;
1818 }
1819 else if(pCoexDm->curPsTdma == 7)
1820 {
1821 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
1822 pCoexDm->psTdmaDuAdjType = 8;
1823 }
1824 else if(pCoexDm->curPsTdma == 13)
1825 {
1826 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
1827 pCoexDm->psTdmaDuAdjType = 14;
1828 }
1829 else if(pCoexDm->curPsTdma == 14)
1830 {
1831 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
1832 pCoexDm->psTdmaDuAdjType = 15;
1833 }
1834 else if(pCoexDm->curPsTdma == 15)
1835 {
1836 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
1837 pCoexDm->psTdmaDuAdjType = 16;
1838 }
1839 }
1840 else if (result == 1)
1841 {
1842 if(pCoexDm->curPsTdma == 8)
1843 {
1844 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
1845 pCoexDm->psTdmaDuAdjType = 7;
1846 }
1847 else if(pCoexDm->curPsTdma == 7)
1848 {
1849 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
1850 pCoexDm->psTdmaDuAdjType = 6;
1851 }
1852 else if(pCoexDm->curPsTdma == 6)
1853 {
1854 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
1855 pCoexDm->psTdmaDuAdjType = 5;
1856 }
1857 else if(pCoexDm->curPsTdma == 16)
1858 {
1859 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
1860 pCoexDm->psTdmaDuAdjType = 15;
1861 }
1862 else if(pCoexDm->curPsTdma == 15)
1863 {
1864 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
1865 pCoexDm->psTdmaDuAdjType = 14;
1866 }
1867 else if(pCoexDm->curPsTdma == 14)
1868 {
1869 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
1870 pCoexDm->psTdmaDuAdjType = 13;
1871 }
1872 }
1873 }
1874 else
1875 {
1876 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
1877 if(pCoexDm->curPsTdma == 5)
1878 {
1879 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
1880 pCoexDm->psTdmaDuAdjType = 1;
1881 }
1882 else if(pCoexDm->curPsTdma == 6)
1883 {
1884 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
1885 pCoexDm->psTdmaDuAdjType = 2;
1886 }
1887 else if(pCoexDm->curPsTdma == 7)
1888 {
1889 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
1890 pCoexDm->psTdmaDuAdjType = 3;
1891 }
1892 else if(pCoexDm->curPsTdma == 8)
1893 {
1894 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
1895 pCoexDm->psTdmaDuAdjType = 4;
1896 }
1897 if(pCoexDm->curPsTdma == 13)
1898 {
1899 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
1900 pCoexDm->psTdmaDuAdjType = 9;
1901 }
1902 else if(pCoexDm->curPsTdma == 14)
1903 {
1904 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
1905 pCoexDm->psTdmaDuAdjType = 10;
1906 }
1907 else if(pCoexDm->curPsTdma == 15)
1908 {
1909 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
1910 pCoexDm->psTdmaDuAdjType = 11;
1911 }
1912 else if(pCoexDm->curPsTdma == 16)
1913 {
1914 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
1915 pCoexDm->psTdmaDuAdjType = 12;
1916 }
1917
1918 if(result == -1)
1919 {
1920 if(pCoexDm->curPsTdma == 1)
1921 {
1922 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
1923 pCoexDm->psTdmaDuAdjType = 2;
1924 }
1925 else if(pCoexDm->curPsTdma == 2)
1926 {
1927 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
1928 pCoexDm->psTdmaDuAdjType = 3;
1929 }
1930 else if(pCoexDm->curPsTdma == 3)
1931 {
1932 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
1933 pCoexDm->psTdmaDuAdjType = 4;
1934 }
1935 else if(pCoexDm->curPsTdma == 9)
1936 {
1937 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
1938 pCoexDm->psTdmaDuAdjType = 10;
1939 }
1940 else if(pCoexDm->curPsTdma == 10)
1941 {
1942 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
1943 pCoexDm->psTdmaDuAdjType = 11;
1944 }
1945 else if(pCoexDm->curPsTdma == 11)
1946 {
1947 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
1948 pCoexDm->psTdmaDuAdjType = 12;
1949 }
1950 }
1951 else if (result == 1)
1952 {
1953 if(pCoexDm->curPsTdma == 4)
1954 {
1955 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
1956 pCoexDm->psTdmaDuAdjType = 3;
1957 }
1958 else if(pCoexDm->curPsTdma == 3)
1959 {
1960 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
1961 pCoexDm->psTdmaDuAdjType = 2;
1962 }
1963 else if(pCoexDm->curPsTdma == 2)
1964 {
1965 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
1966 pCoexDm->psTdmaDuAdjType = 1;
1967 }
1968 else if(pCoexDm->curPsTdma == 12)
1969 {
1970 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
1971 pCoexDm->psTdmaDuAdjType = 11;
1972 }
1973 else if(pCoexDm->curPsTdma == 11)
1974 {
1975 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
1976 pCoexDm->psTdmaDuAdjType = 10;
1977 }
1978 else if(pCoexDm->curPsTdma == 10)
1979 {
1980 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
1981 pCoexDm->psTdmaDuAdjType = 9;
1982 }
1983 }
1984 }
1985 }
1986 else if(maxInterval == 2)
1987 {
1988 if(bTxPause)
1989 {
1990 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
1991 if(pCoexDm->curPsTdma == 1)
1992 {
1993 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
1994 pCoexDm->psTdmaDuAdjType = 6;
1995 }
1996 else if(pCoexDm->curPsTdma == 2)
1997 {
1998 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
1999 pCoexDm->psTdmaDuAdjType = 6;
2000 }
2001 else if(pCoexDm->curPsTdma == 3)
2002 {
2003 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2004 pCoexDm->psTdmaDuAdjType = 7;
2005 }
2006 else if(pCoexDm->curPsTdma == 4)
2007 {
2008 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2009 pCoexDm->psTdmaDuAdjType = 8;
2010 }
2011 if(pCoexDm->curPsTdma == 9)
2012 {
2013 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2014 pCoexDm->psTdmaDuAdjType = 14;
2015 }
2016 else if(pCoexDm->curPsTdma == 10)
2017 {
2018 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2019 pCoexDm->psTdmaDuAdjType = 14;
2020 }
2021 else if(pCoexDm->curPsTdma == 11)
2022 {
2023 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2024 pCoexDm->psTdmaDuAdjType = 15;
2025 }
2026 else if(pCoexDm->curPsTdma == 12)
2027 {
2028 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2029 pCoexDm->psTdmaDuAdjType = 16;
2030 }
2031 if(result == -1)
2032 {
2033 if(pCoexDm->curPsTdma == 5)
2034 {
2035 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2036 pCoexDm->psTdmaDuAdjType = 6;
2037 }
2038 else if(pCoexDm->curPsTdma == 6)
2039 {
2040 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2041 pCoexDm->psTdmaDuAdjType = 7;
2042 }
2043 else if(pCoexDm->curPsTdma == 7)
2044 {
2045 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2046 pCoexDm->psTdmaDuAdjType = 8;
2047 }
2048 else if(pCoexDm->curPsTdma == 13)
2049 {
2050 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2051 pCoexDm->psTdmaDuAdjType = 14;
2052 }
2053 else if(pCoexDm->curPsTdma == 14)
2054 {
2055 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2056 pCoexDm->psTdmaDuAdjType = 15;
2057 }
2058 else if(pCoexDm->curPsTdma == 15)
2059 {
2060 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2061 pCoexDm->psTdmaDuAdjType = 16;
2062 }
2063 }
2064 else if (result == 1)
2065 {
2066 if(pCoexDm->curPsTdma == 8)
2067 {
2068 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2069 pCoexDm->psTdmaDuAdjType = 7;
2070 }
2071 else if(pCoexDm->curPsTdma == 7)
2072 {
2073 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2074 pCoexDm->psTdmaDuAdjType = 6;
2075 }
2076 else if(pCoexDm->curPsTdma == 6)
2077 {
2078 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2079 pCoexDm->psTdmaDuAdjType = 6;
2080 }
2081 else if(pCoexDm->curPsTdma == 16)
2082 {
2083 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2084 pCoexDm->psTdmaDuAdjType = 15;
2085 }
2086 else if(pCoexDm->curPsTdma == 15)
2087 {
2088 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2089 pCoexDm->psTdmaDuAdjType = 14;
2090 }
2091 else if(pCoexDm->curPsTdma == 14)
2092 {
2093 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2094 pCoexDm->psTdmaDuAdjType = 14;
2095 }
2096 }
2097 }
2098 else
2099 {
2100 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
2101 if(pCoexDm->curPsTdma == 5)
2102 {
2103 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2104 pCoexDm->psTdmaDuAdjType = 2;
2105 }
2106 else if(pCoexDm->curPsTdma == 6)
2107 {
2108 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2109 pCoexDm->psTdmaDuAdjType = 2;
2110 }
2111 else if(pCoexDm->curPsTdma == 7)
2112 {
2113 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2114 pCoexDm->psTdmaDuAdjType = 3;
2115 }
2116 else if(pCoexDm->curPsTdma == 8)
2117 {
2118 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2119 pCoexDm->psTdmaDuAdjType = 4;
2120 }
2121 if(pCoexDm->curPsTdma == 13)
2122 {
2123 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2124 pCoexDm->psTdmaDuAdjType = 10;
2125 }
2126 else if(pCoexDm->curPsTdma == 14)
2127 {
2128 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2129 pCoexDm->psTdmaDuAdjType = 10;
2130 }
2131 else if(pCoexDm->curPsTdma == 15)
2132 {
2133 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2134 pCoexDm->psTdmaDuAdjType = 11;
2135 }
2136 else if(pCoexDm->curPsTdma == 16)
2137 {
2138 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2139 pCoexDm->psTdmaDuAdjType = 12;
2140 }
2141 if(result == -1)
2142 {
2143 if(pCoexDm->curPsTdma == 1)
2144 {
2145 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2146 pCoexDm->psTdmaDuAdjType = 2;
2147 }
2148 else if(pCoexDm->curPsTdma == 2)
2149 {
2150 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2151 pCoexDm->psTdmaDuAdjType = 3;
2152 }
2153 else if(pCoexDm->curPsTdma == 3)
2154 {
2155 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2156 pCoexDm->psTdmaDuAdjType = 4;
2157 }
2158 else if(pCoexDm->curPsTdma == 9)
2159 {
2160 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2161 pCoexDm->psTdmaDuAdjType = 10;
2162 }
2163 else if(pCoexDm->curPsTdma == 10)
2164 {
2165 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2166 pCoexDm->psTdmaDuAdjType = 11;
2167 }
2168 else if(pCoexDm->curPsTdma == 11)
2169 {
2170 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2171 pCoexDm->psTdmaDuAdjType = 12;
2172 }
2173 }
2174 else if (result == 1)
2175 {
2176 if(pCoexDm->curPsTdma == 4)
2177 {
2178 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2179 pCoexDm->psTdmaDuAdjType = 3;
2180 }
2181 else if(pCoexDm->curPsTdma == 3)
2182 {
2183 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2184 pCoexDm->psTdmaDuAdjType = 2;
2185 }
2186 else if(pCoexDm->curPsTdma == 2)
2187 {
2188 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2189 pCoexDm->psTdmaDuAdjType = 2;
2190 }
2191 else if(pCoexDm->curPsTdma == 12)
2192 {
2193 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2194 pCoexDm->psTdmaDuAdjType = 11;
2195 }
2196 else if(pCoexDm->curPsTdma == 11)
2197 {
2198 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2199 pCoexDm->psTdmaDuAdjType = 10;
2200 }
2201 else if(pCoexDm->curPsTdma == 10)
2202 {
2203 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2204 pCoexDm->psTdmaDuAdjType = 10;
2205 }
2206 }
2207 }
2208 }
2209 else if(maxInterval == 3)
2210 {
2211 if(bTxPause)
2212 {
2213 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
2214 if(pCoexDm->curPsTdma == 1)
2215 {
2216 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2217 pCoexDm->psTdmaDuAdjType = 7;
2218 }
2219 else if(pCoexDm->curPsTdma == 2)
2220 {
2221 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2222 pCoexDm->psTdmaDuAdjType = 7;
2223 }
2224 else if(pCoexDm->curPsTdma == 3)
2225 {
2226 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2227 pCoexDm->psTdmaDuAdjType = 7;
2228 }
2229 else if(pCoexDm->curPsTdma == 4)
2230 {
2231 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2232 pCoexDm->psTdmaDuAdjType = 8;
2233 }
2234 if(pCoexDm->curPsTdma == 9)
2235 {
2236 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2237 pCoexDm->psTdmaDuAdjType = 15;
2238 }
2239 else if(pCoexDm->curPsTdma == 10)
2240 {
2241 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2242 pCoexDm->psTdmaDuAdjType = 15;
2243 }
2244 else if(pCoexDm->curPsTdma == 11)
2245 {
2246 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2247 pCoexDm->psTdmaDuAdjType = 15;
2248 }
2249 else if(pCoexDm->curPsTdma == 12)
2250 {
2251 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2252 pCoexDm->psTdmaDuAdjType = 16;
2253 }
2254 if(result == -1)
2255 {
2256 if(pCoexDm->curPsTdma == 5)
2257 {
2258 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2259 pCoexDm->psTdmaDuAdjType = 7;
2260 }
2261 else if(pCoexDm->curPsTdma == 6)
2262 {
2263 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2264 pCoexDm->psTdmaDuAdjType = 7;
2265 }
2266 else if(pCoexDm->curPsTdma == 7)
2267 {
2268 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2269 pCoexDm->psTdmaDuAdjType = 8;
2270 }
2271 else if(pCoexDm->curPsTdma == 13)
2272 {
2273 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2274 pCoexDm->psTdmaDuAdjType = 15;
2275 }
2276 else if(pCoexDm->curPsTdma == 14)
2277 {
2278 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2279 pCoexDm->psTdmaDuAdjType = 15;
2280 }
2281 else if(pCoexDm->curPsTdma == 15)
2282 {
2283 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2284 pCoexDm->psTdmaDuAdjType = 16;
2285 }
2286 }
2287 else if (result == 1)
2288 {
2289 if(pCoexDm->curPsTdma == 8)
2290 {
2291 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2292 pCoexDm->psTdmaDuAdjType = 7;
2293 }
2294 else if(pCoexDm->curPsTdma == 7)
2295 {
2296 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2297 pCoexDm->psTdmaDuAdjType = 7;
2298 }
2299 else if(pCoexDm->curPsTdma == 6)
2300 {
2301 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2302 pCoexDm->psTdmaDuAdjType = 7;
2303 }
2304 else if(pCoexDm->curPsTdma == 16)
2305 {
2306 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2307 pCoexDm->psTdmaDuAdjType = 15;
2308 }
2309 else if(pCoexDm->curPsTdma == 15)
2310 {
2311 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2312 pCoexDm->psTdmaDuAdjType = 15;
2313 }
2314 else if(pCoexDm->curPsTdma == 14)
2315 {
2316 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2317 pCoexDm->psTdmaDuAdjType = 15;
2318 }
2319 }
2320 }
2321 else
2322 {
2323 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
2324 if(pCoexDm->curPsTdma == 5)
2325 {
2326 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2327 pCoexDm->psTdmaDuAdjType = 3;
2328 }
2329 else if(pCoexDm->curPsTdma == 6)
2330 {
2331 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2332 pCoexDm->psTdmaDuAdjType = 3;
2333 }
2334 else if(pCoexDm->curPsTdma == 7)
2335 {
2336 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2337 pCoexDm->psTdmaDuAdjType = 3;
2338 }
2339 else if(pCoexDm->curPsTdma == 8)
2340 {
2341 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2342 pCoexDm->psTdmaDuAdjType = 4;
2343 }
2344 if(pCoexDm->curPsTdma == 13)
2345 {
2346 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2347 pCoexDm->psTdmaDuAdjType = 11;
2348 }
2349 else if(pCoexDm->curPsTdma == 14)
2350 {
2351 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2352 pCoexDm->psTdmaDuAdjType = 11;
2353 }
2354 else if(pCoexDm->curPsTdma == 15)
2355 {
2356 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2357 pCoexDm->psTdmaDuAdjType = 11;
2358 }
2359 else if(pCoexDm->curPsTdma == 16)
2360 {
2361 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2362 pCoexDm->psTdmaDuAdjType = 12;
2363 }
2364 if(result == -1)
2365 {
2366 if(pCoexDm->curPsTdma == 1)
2367 {
2368 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2369 pCoexDm->psTdmaDuAdjType = 3;
2370 }
2371 else if(pCoexDm->curPsTdma == 2)
2372 {
2373 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2374 pCoexDm->psTdmaDuAdjType = 3;
2375 }
2376 else if(pCoexDm->curPsTdma == 3)
2377 {
2378 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2379 pCoexDm->psTdmaDuAdjType = 4;
2380 }
2381 else if(pCoexDm->curPsTdma == 9)
2382 {
2383 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2384 pCoexDm->psTdmaDuAdjType = 11;
2385 }
2386 else if(pCoexDm->curPsTdma == 10)
2387 {
2388 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2389 pCoexDm->psTdmaDuAdjType = 11;
2390 }
2391 else if(pCoexDm->curPsTdma == 11)
2392 {
2393 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2394 pCoexDm->psTdmaDuAdjType = 12;
2395 }
2396 }
2397 else if (result == 1)
2398 {
2399 if(pCoexDm->curPsTdma == 4)
2400 {
2401 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2402 pCoexDm->psTdmaDuAdjType = 3;
2403 }
2404 else if(pCoexDm->curPsTdma == 3)
2405 {
2406 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2407 pCoexDm->psTdmaDuAdjType = 3;
2408 }
2409 else if(pCoexDm->curPsTdma == 2)
2410 {
2411 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2412 pCoexDm->psTdmaDuAdjType = 3;
2413 }
2414 else if(pCoexDm->curPsTdma == 12)
2415 {
2416 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2417 pCoexDm->psTdmaDuAdjType = 11;
2418 }
2419 else if(pCoexDm->curPsTdma == 11)
2420 {
2421 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2422 pCoexDm->psTdmaDuAdjType = 11;
2423 }
2424 else if(pCoexDm->curPsTdma == 10)
2425 {
2426 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2427 pCoexDm->psTdmaDuAdjType = 11;
2428 }
2429 }
2430 }
2431 }
2432 }
2433
2434 // if current PsTdma not match with the recorded one (when scan, dhcp...),
2435 // then we have to adjust it back to the previous record one.
2436 if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)
2437 {
2438 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
2439 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n",
2440 pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));
2441
2442 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2443 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2444 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2445
2446 if( !bScan && !bLink && !bRoam)
2447 {
2448 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
2449 }
2450 else
2451 {
2452 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
2453 }
2454 }
2455 }
2456
2457 // SCO only or SCO+PAN(HS)
2458 VOID
halbtc8723a2ant_ActionSco(IN PBTC_COEXIST pBtCoexist)2459 halbtc8723a2ant_ActionSco(
2460 IN PBTC_COEXIST pBtCoexist
2461 )
2462 {
2463 u1Byte wifiRssiState, wifiRssiState1;
2464 u4Byte wifiBw;
2465
2466 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2467 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
2468 else
2469 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2470 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2471
2472 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2473 if(BTC_WIFI_BW_HT40 == wifiBw)
2474 {
2475 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2476 // fw mechanism
2477 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2478 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2479 {
2480 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2481 }
2482 else
2483 {
2484 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2485 }
2486
2487 // sw mechanism
2488 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2489 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2490 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2491 }
2492 else
2493 {
2494 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2495 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2496
2497 // fw mechanism
2498 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2499 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2500 {
2501 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2502 }
2503 else
2504 {
2505 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2506 }
2507
2508 // sw mechanism
2509 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2510 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2511 {
2512 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
2513 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2514 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2515 }
2516 else
2517 {
2518 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2519 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2520 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2521 }
2522 }
2523 }
2524
2525
2526 VOID
halbtc8723a2ant_ActionHid(IN PBTC_COEXIST pBtCoexist)2527 halbtc8723a2ant_ActionHid(
2528 IN PBTC_COEXIST pBtCoexist
2529 )
2530 {
2531 u1Byte wifiRssiState, wifiRssiState1;
2532 u4Byte wifiBw;
2533
2534 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2535 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
2536 else
2537 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2538 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2539
2540 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2541 if(BTC_WIFI_BW_HT40 == wifiBw)
2542 {
2543 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2544 // fw mechanism
2545 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2546 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2547 {
2548 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
2549 }
2550 else
2551 {
2552 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
2553 }
2554
2555 // sw mechanism
2556 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2557 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2558 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2559 }
2560 else
2561 {
2562 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2563 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2564
2565 // fw mechanism
2566 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2567 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2568 {
2569 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
2570 }
2571 else
2572 {
2573 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
2574 }
2575
2576 // sw mechanism
2577 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2578 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2579 {
2580 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
2581 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2582 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2583 }
2584 else
2585 {
2586 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2587 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2588 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2589 }
2590 }
2591 }
2592
2593 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
2594 VOID
halbtc8723a2ant_ActionA2dp(IN PBTC_COEXIST pBtCoexist)2595 halbtc8723a2ant_ActionA2dp(
2596 IN PBTC_COEXIST pBtCoexist
2597 )
2598 {
2599 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
2600 u4Byte wifiBw;
2601
2602 btInfoExt = pCoexSta->btInfoExt;
2603
2604 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2605 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
2606 else
2607 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2608 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2609
2610 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2611 if(BTC_WIFI_BW_HT40 == wifiBw)
2612 {
2613 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2614
2615 // fw mechanism
2616 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2617 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2618 {
2619 if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
2620 {
2621 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3);
2622 }
2623 else
2624 {
2625 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);
2626 }
2627 }
2628 else
2629 {
2630 if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
2631 {
2632 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3);
2633 }
2634 else
2635 {
2636 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1);
2637 }
2638 }
2639
2640 // sw mechanism
2641 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2642 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2643 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2644 }
2645 else
2646 {
2647 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2648 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2649
2650 // fw mechanism
2651 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2652 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2653 {
2654 if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
2655 {
2656 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3);
2657 }
2658 else
2659 {
2660 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);
2661 }
2662 }
2663 else
2664 {
2665 if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
2666 {
2667 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3);
2668 }
2669 else
2670 {
2671 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1);
2672 }
2673 }
2674
2675 // sw mechanism
2676 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2677 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2678 {
2679 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
2680 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2681 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2682 }
2683 else
2684 {
2685 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2686 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2687 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2688 }
2689 }
2690 }
2691
2692 VOID
halbtc8723a2ant_ActionPanEdr(IN PBTC_COEXIST pBtCoexist)2693 halbtc8723a2ant_ActionPanEdr(
2694 IN PBTC_COEXIST pBtCoexist
2695 )
2696 {
2697 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
2698 u4Byte wifiBw;
2699
2700 btInfoExt = pCoexSta->btInfoExt;
2701
2702 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2703 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
2704 else
2705 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2706 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2707
2708 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2709 if(BTC_WIFI_BW_HT40 == wifiBw)
2710 {
2711 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2712
2713 // fw mechanism
2714 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2715 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2716 {
2717 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2718 }
2719 else
2720 {
2721 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2722 }
2723
2724 // sw mechanism
2725 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2726 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2727 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2728 }
2729 else
2730 {
2731 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2732 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2733
2734 // fw mechanism
2735 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2736 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2737 {
2738 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2739 }
2740 else
2741 {
2742 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2743 }
2744
2745 // sw mechanism
2746 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2747 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2748 {
2749 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
2750 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2751 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2752 }
2753 else
2754 {
2755 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2756 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2757 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2758 }
2759 }
2760 }
2761
2762
2763 //PAN(HS) only
2764 VOID
halbtc8723a2ant_ActionPanHs(IN PBTC_COEXIST pBtCoexist)2765 halbtc8723a2ant_ActionPanHs(
2766 IN PBTC_COEXIST pBtCoexist
2767 )
2768 {
2769 u1Byte wifiRssiState;
2770 u4Byte wifiBw;
2771
2772 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2773
2774 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2775 if(BTC_WIFI_BW_HT40 == wifiBw)
2776 {
2777 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2778
2779 // fw mechanism
2780 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2781 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2782 {
2783 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
2784 }
2785 else
2786 {
2787 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2788 }
2789 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2790
2791 // sw mechanism
2792 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2793 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2794 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2795 }
2796 else
2797 {
2798 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2799
2800 // fw mechanism
2801 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2802 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2803 {
2804 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
2805 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2806 }
2807 else
2808 {
2809 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2810 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2811 }
2812
2813 // sw mechanism
2814 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2815 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2816 {
2817 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
2818 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2819 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2820 }
2821 else
2822 {
2823 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2824 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2825 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2826 }
2827 }
2828 }
2829
2830 //PAN(EDR)+A2DP
2831 VOID
halbtc8723a2ant_ActionPanEdrA2dp(IN PBTC_COEXIST pBtCoexist)2832 halbtc8723a2ant_ActionPanEdrA2dp(
2833 IN PBTC_COEXIST pBtCoexist
2834 )
2835 {
2836 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
2837 u4Byte wifiBw;
2838
2839 btInfoExt = pCoexSta->btInfoExt;
2840
2841 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2842 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
2843 else
2844 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2845 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2846
2847 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2848 if(BTC_WIFI_BW_HT40 == wifiBw)
2849 {
2850 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2851
2852 // fw mechanism
2853 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2854 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2855 {
2856 if(btInfoExt&BIT0) //a2dp basic rate
2857 {
2858 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2859 }
2860 else //a2dp edr rate
2861 {
2862 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2863 }
2864 }
2865 else
2866 {
2867 if(btInfoExt&BIT0) //a2dp basic rate
2868 {
2869 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2870 }
2871 else //a2dp edr rate
2872 {
2873 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2874 }
2875 }
2876
2877 // sw mechanism
2878 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2879 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2880 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2881 }
2882 else
2883 {
2884 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2885 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
2886
2887 // fw mechanism
2888 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2889 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2890 {
2891 if(btInfoExt&BIT0) //a2dp basic rate
2892 {
2893 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2894 }
2895 else //a2dp edr rate
2896 {
2897 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2898 }
2899 }
2900 else
2901 {
2902 if(btInfoExt&BIT0) //a2dp basic rate
2903 {
2904 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2905 }
2906 else //a2dp edr rate
2907 {
2908 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2909 }
2910 }
2911
2912 // sw mechanism
2913 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2914 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2915 {
2916 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
2917 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2918 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2919 }
2920 else
2921 {
2922 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2923 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2924 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2925 }
2926 }
2927 }
2928
2929 VOID
halbtc8723a2ant_ActionPanEdrHid(IN PBTC_COEXIST pBtCoexist)2930 halbtc8723a2ant_ActionPanEdrHid(
2931 IN PBTC_COEXIST pBtCoexist
2932 )
2933 {
2934 u1Byte wifiRssiState, wifiRssiState1;
2935 u4Byte wifiBw;
2936
2937 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2938 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
2939 else
2940 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2941 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2942
2943 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2944 if(BTC_WIFI_BW_HT40 == wifiBw)
2945 {
2946 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2947
2948 // fw mechanism
2949 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2950 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2951 {
2952 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2953 }
2954 else
2955 {
2956 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2957 }
2958
2959 // sw mechanism
2960 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2961 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2962 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2963 }
2964 else
2965 {
2966 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2967 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2968
2969 // fw mechanism
2970 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2971 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2972 {
2973 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2974 }
2975 else
2976 {
2977 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2978 }
2979
2980 // sw mechanism
2981 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2982 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2983 {
2984 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
2985 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
2986 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2987 }
2988 else
2989 {
2990 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2991 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2992 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2993 }
2994 }
2995 }
2996
2997 // HID+A2DP+PAN(EDR)
2998 VOID
halbtc8723a2ant_ActionHidA2dpPanEdr(IN PBTC_COEXIST pBtCoexist)2999 halbtc8723a2ant_ActionHidA2dpPanEdr(
3000 IN PBTC_COEXIST pBtCoexist
3001 )
3002 {
3003 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
3004 u4Byte wifiBw;
3005
3006 btInfoExt = pCoexSta->btInfoExt;
3007
3008 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
3009 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
3010 else
3011 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
3012 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
3013
3014 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3015 if(BTC_WIFI_BW_HT40 == wifiBw)
3016 {
3017 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
3018
3019 // fw mechanism
3020 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
3021 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3022 {
3023 if(btInfoExt&BIT0) //a2dp basic rate
3024 {
3025 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
3026 }
3027 else //a2dp edr rate
3028 {
3029 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
3030 }
3031 }
3032 else
3033 {
3034 if(btInfoExt&BIT0) //a2dp basic rate
3035 {
3036 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
3037 }
3038 else //a2dp edr rate
3039 {
3040 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
3041 }
3042 }
3043
3044 // sw mechanism
3045 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
3046 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
3047 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3048 }
3049 else
3050 {
3051 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
3052 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
3053
3054 // fw mechanism
3055 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
3056 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3057 {
3058 if(btInfoExt&BIT0) //a2dp basic rate
3059 {
3060 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
3061 }
3062 else //a2dp edr rate
3063 {
3064 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
3065 }
3066 }
3067 else
3068 {
3069 if(btInfoExt&BIT0) //a2dp basic rate
3070 {
3071 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
3072 }
3073 else //a2dp edr rate
3074 {
3075 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
3076 }
3077 }
3078
3079 // sw mechanism
3080 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
3081 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
3082 {
3083 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
3084 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
3085 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3086 }
3087 else
3088 {
3089 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
3090 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
3091 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3092 }
3093 }
3094 }
3095
3096 VOID
halbtc8723a2ant_ActionHidA2dp(IN PBTC_COEXIST pBtCoexist)3097 halbtc8723a2ant_ActionHidA2dp(
3098 IN PBTC_COEXIST pBtCoexist
3099 )
3100 {
3101 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
3102 u4Byte wifiBw;
3103
3104 btInfoExt = pCoexSta->btInfoExt;
3105
3106 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
3107 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE);
3108 else
3109 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
3110 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
3111
3112 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3113 if(BTC_WIFI_BW_HT40 == wifiBw)
3114 {
3115 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
3116
3117 // fw mechanism
3118 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
3119 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3120 {
3121 if(btInfoExt&BIT0) //a2dp basic rate
3122 {
3123 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3);
3124 }
3125 else //a2dp edr rate
3126 {
3127 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 1);
3128 }
3129 }
3130 else
3131 {
3132 if(btInfoExt&BIT0) //a2dp basic rate
3133 {
3134 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);
3135 }
3136 else //a2dp edr rate
3137 {
3138 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 1);
3139 }
3140 }
3141
3142 // sw mechanism
3143 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
3144 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
3145 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3146 }
3147 else
3148 {
3149 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
3150 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
3151
3152 // fw mechanism
3153 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
3154 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3155 {
3156 if(btInfoExt&BIT0) //a2dp basic rate
3157 {
3158 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3);
3159 }
3160 else //a2dp edr rate
3161 {
3162 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 1);
3163 }
3164 }
3165 else
3166 {
3167 if(btInfoExt&BIT0) //a2dp basic rate
3168 {
3169 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);
3170 }
3171 else //a2dp edr rate
3172 {
3173 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 1);
3174 }
3175 }
3176
3177 // sw mechanism
3178 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
3179 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
3180 {
3181 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE);
3182 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE);
3183 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3184 }
3185 else
3186 {
3187 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
3188 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
3189 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3190 }
3191 }
3192 }
3193
3194 VOID
halbtc8723a2ant_RunCoexistMechanism(IN PBTC_COEXIST pBtCoexist)3195 halbtc8723a2ant_RunCoexistMechanism(
3196 IN PBTC_COEXIST pBtCoexist
3197 )
3198 {
3199 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
3200 u1Byte btInfoOriginal=0, btRetryCnt=0;
3201 u1Byte algorithm=0;
3202
3203 if(pBtCoexist->bManualControl)
3204 {
3205 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Manual control!!!\n"));
3206 return;
3207 }
3208
3209 if(pStackInfo->bProfileNotified)
3210 {
3211 if(pCoexSta->bHoldForStackOperation)
3212 {
3213 // if bt inquiry/page/pair, do not execute.
3214 return;
3215 }
3216
3217 algorithm = halbtc8723a2ant_ActionAlgorithm(pBtCoexist);
3218 if(pCoexSta->bHoldPeriodCnt && (BT_8723A_2ANT_COEX_ALGO_PANHS!=algorithm))
3219 {
3220 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex],Hold BT inquiry/page scan setting (cnt = %d)!!\n",
3221 pCoexSta->bHoldPeriodCnt));
3222 if(pCoexSta->bHoldPeriodCnt >= 6)
3223 {
3224 pCoexSta->bHoldPeriodCnt = 0;
3225 // next time the coexist parameters should be reset again.
3226 }
3227 else
3228 pCoexSta->bHoldPeriodCnt++;
3229 return;
3230 }
3231
3232 pCoexDm->curAlgorithm = algorithm;
3233 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm));
3234 if(halbtc8723a2ant_IsCommonAction(pBtCoexist))
3235 {
3236 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n"));
3237 pCoexDm->bResetTdmaAdjust = TRUE;
3238 }
3239 else
3240 {
3241 if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm)
3242 {
3243 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n",
3244 pCoexDm->preAlgorithm, pCoexDm->curAlgorithm));
3245 pCoexDm->bResetTdmaAdjust = TRUE;
3246 }
3247 switch(pCoexDm->curAlgorithm)
3248 {
3249 case BT_8723A_2ANT_COEX_ALGO_SCO:
3250 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n"));
3251 halbtc8723a2ant_ActionSco(pBtCoexist);
3252 break;
3253 case BT_8723A_2ANT_COEX_ALGO_HID:
3254 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n"));
3255 halbtc8723a2ant_ActionHid(pBtCoexist);
3256 break;
3257 case BT_8723A_2ANT_COEX_ALGO_A2DP:
3258 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n"));
3259 halbtc8723a2ant_ActionA2dp(pBtCoexist);
3260 break;
3261 case BT_8723A_2ANT_COEX_ALGO_PANEDR:
3262 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"));
3263 halbtc8723a2ant_ActionPanEdr(pBtCoexist);
3264 break;
3265 case BT_8723A_2ANT_COEX_ALGO_PANHS:
3266 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n"));
3267 halbtc8723a2ant_ActionPanHs(pBtCoexist);
3268 break;
3269 case BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP:
3270 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"));
3271 halbtc8723a2ant_ActionPanEdrA2dp(pBtCoexist);
3272 break;
3273 case BT_8723A_2ANT_COEX_ALGO_PANEDR_HID:
3274 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
3275 halbtc8723a2ant_ActionPanEdrHid(pBtCoexist);
3276 break;
3277 case BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
3278 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
3279 halbtc8723a2ant_ActionHidA2dpPanEdr(pBtCoexist);
3280 break;
3281 case BT_8723A_2ANT_COEX_ALGO_HID_A2DP:
3282 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"));
3283 halbtc8723a2ant_ActionHidA2dp(pBtCoexist);
3284 break;
3285 default:
3286 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"));
3287 halbtc8723a2ant_CoexAllOff(pBtCoexist);
3288 break;
3289 }
3290 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
3291 }
3292 }
3293 }
3294
3295 //============================================================
3296 // work around function start with wa_halbtc8723a2ant_
3297 //============================================================
3298 VOID
wa_halbtc8723a2ant_MonitorC2h(IN PBTC_COEXIST pBtCoexist)3299 wa_halbtc8723a2ant_MonitorC2h(
3300 IN PBTC_COEXIST pBtCoexist
3301 )
3302 {
3303 u1Byte tmp1b=0x0;
3304 u4Byte curC2hTotalCnt=0x0;
3305 static u4Byte preC2hTotalCnt=0x0, sameCntPollingTime=0x0;
3306
3307 curC2hTotalCnt+=pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8723A_2ANT_BT_RSP];
3308
3309 if(curC2hTotalCnt == preC2hTotalCnt)
3310 {
3311 sameCntPollingTime++;
3312 }
3313 else
3314 {
3315 preC2hTotalCnt = curC2hTotalCnt;
3316 sameCntPollingTime = 0;
3317 }
3318
3319 if(sameCntPollingTime >= 2)
3320 {
3321 tmp1b = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x1af);
3322 if(tmp1b != 0x0)
3323 {
3324 pCoexSta->c2hHangDetectCnt++;
3325 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x1af, 0x0);
3326 }
3327 }
3328 }
3329
3330 //============================================================
3331 // extern function start with EXhalbtc8723a2ant_
3332 //============================================================
3333 VOID
EXhalbtc8723a2ant_PowerOnSetting(IN PBTC_COEXIST pBtCoexist)3334 EXhalbtc8723a2ant_PowerOnSetting(
3335 IN PBTC_COEXIST pBtCoexist
3336 )
3337 {
3338 }
3339
3340 VOID
EXhalbtc8723a2ant_InitHwConfig(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bWifiOnly)3341 EXhalbtc8723a2ant_InitHwConfig(
3342 IN PBTC_COEXIST pBtCoexist,
3343 IN BOOLEAN bWifiOnly
3344 )
3345 {
3346 u4Byte u4Tmp=0;
3347 u1Byte u1Tmp=0;
3348
3349 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n"));
3350
3351 // backup rf 0x1e value
3352 pCoexDm->btRf0x1eBackup =
3353 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
3354
3355 // Enable counter statistics
3356 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
3357 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);
3358 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20);
3359 }
3360
3361 VOID
EXhalbtc8723a2ant_InitCoexDm(IN PBTC_COEXIST pBtCoexist)3362 EXhalbtc8723a2ant_InitCoexDm(
3363 IN PBTC_COEXIST pBtCoexist
3364 )
3365 {
3366 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n"));
3367
3368 halbtc8723a2ant_InitCoexDm(pBtCoexist);
3369 }
3370
3371 VOID
EXhalbtc8723a2ant_DisplayCoexInfo(IN PBTC_COEXIST pBtCoexist)3372 EXhalbtc8723a2ant_DisplayCoexInfo(
3373 IN PBTC_COEXIST pBtCoexist
3374 )
3375 {
3376 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
3377 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
3378 pu1Byte cliBuf=pBtCoexist->cliBuf;
3379 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
3380 u4Byte u4Tmp[4];
3381
3382 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
3383 CL_PRINTF(cliBuf);
3384
3385 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
3386 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
3387 CL_PRINTF(cliBuf);
3388
3389 if(pBtCoexist->bManualControl)
3390 {
3391 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!");
3392 CL_PRINTF(cliBuf);
3393 }
3394
3395 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
3396 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
3397 CL_PRINTF(cliBuf);
3398
3399 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \
3400 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
3401 pCoexDm->wifiChnlInfo[2]);
3402 CL_PRINTF(cliBuf);
3403
3404 // wifi status
3405 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
3406 CL_PRINTF(cliBuf);
3407 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
3408
3409 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
3410 CL_PRINTF(cliBuf);
3411
3412 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
3413 ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus)? "idle":( (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy"))),
3414 pCoexSta->btRssi, pCoexSta->btRetryCnt);
3415 CL_PRINTF(cliBuf);
3416
3417 if(pStackInfo->bProfileNotified)
3418 {
3419 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
3420 pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist);
3421 CL_PRINTF(cliBuf);
3422
3423 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
3424 }
3425
3426 btInfoExt = pCoexSta->btInfoExt;
3427 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
3428 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
3429 CL_PRINTF(cliBuf);
3430
3431 for(i=0; i<BT_INFO_SRC_8723A_2ANT_MAX; i++)
3432 {
3433 if(pCoexSta->btInfoC2hCnt[i])
3434 {
3435 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723a2Ant[i], \
3436 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
3437 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
3438 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
3439 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
3440 CL_PRINTF(cliBuf);
3441 }
3442 }
3443
3444 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "write 0x1af=0x0 num", \
3445 pCoexSta->c2hHangDetectCnt);
3446 CL_PRINTF(cliBuf);
3447
3448 // Sw mechanism
3449 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
3450 CL_PRINTF(cliBuf);
3451 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "SM1[ShRf/ LpRA/ LimDig]", \
3452 pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig);
3453 CL_PRINTF(cliBuf);
3454 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
3455 pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
3456 CL_PRINTF(cliBuf);
3457
3458 // Fw mechanism
3459 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
3460 CL_PRINTF(cliBuf);
3461
3462 if(!pBtCoexist->bManualControl)
3463 {
3464 psTdmaCase = pCoexDm->curPsTdma;
3465 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \
3466 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
3467 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
3468 pCoexDm->psTdmaPara[4], psTdmaCase);
3469 CL_PRINTF(cliBuf);
3470
3471 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
3472 pCoexDm->bCurDecBtPwr, pCoexDm->bCurIgnoreWlanAct);
3473 CL_PRINTF(cliBuf);
3474 }
3475
3476 // Hw setting
3477 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
3478 CL_PRINTF(cliBuf);
3479
3480 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
3481 pCoexDm->btRf0x1eBackup);
3482 CL_PRINTF(cliBuf);
3483
3484 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
3485 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x783);
3486 u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x796);
3487 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \
3488 u1Tmp[0], u1Tmp[1], u1Tmp[2]);
3489 CL_PRINTF(cliBuf);
3490
3491 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
3492 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x880", \
3493 u4Tmp[0]);
3494 CL_PRINTF(cliBuf);
3495
3496 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
3497 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \
3498 u1Tmp[0]);
3499 CL_PRINTF(cliBuf);
3500
3501 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
3502 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
3503 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
3504 u4Tmp[0], u1Tmp[0]);
3505 CL_PRINTF(cliBuf);
3506
3507 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x484);
3508 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \
3509 u4Tmp[0]);
3510 CL_PRINTF(cliBuf);
3511
3512 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
3513 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
3514 u4Tmp[0]);
3515 CL_PRINTF(cliBuf);
3516
3517 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
3518 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
3519 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
3520 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xdac);
3521 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xda0/0xda4/0xda8/0xdac(FA cnt)", \
3522 u4Tmp[0], u4Tmp[1], u4Tmp[2], u4Tmp[3]);
3523 CL_PRINTF(cliBuf);
3524
3525 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
3526 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
3527 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
3528 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
3529 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
3530 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
3531 CL_PRINTF(cliBuf);
3532
3533 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770 (hp rx[31:16]/tx[15:0])", \
3534 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
3535 CL_PRINTF(cliBuf);
3536 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
3537 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
3538 CL_PRINTF(cliBuf);
3539
3540 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
3541 }
3542
3543
3544 VOID
EXhalbtc8723a2ant_IpsNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)3545 EXhalbtc8723a2ant_IpsNotify(
3546 IN PBTC_COEXIST pBtCoexist,
3547 IN u1Byte type
3548 )
3549 {
3550 if(BTC_IPS_ENTER == type)
3551 {
3552 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n"));
3553 halbtc8723a2ant_CoexAllOff(pBtCoexist);
3554 }
3555 else if(BTC_IPS_LEAVE == type)
3556 {
3557 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n"));
3558 //halbtc8723a2ant_InitCoexDm(pBtCoexist);
3559 }
3560 }
3561
3562 VOID
EXhalbtc8723a2ant_LpsNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)3563 EXhalbtc8723a2ant_LpsNotify(
3564 IN PBTC_COEXIST pBtCoexist,
3565 IN u1Byte type
3566 )
3567 {
3568 if(BTC_LPS_ENABLE == type)
3569 {
3570 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n"));
3571 }
3572 else if(BTC_LPS_DISABLE == type)
3573 {
3574 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n"));
3575 }
3576 }
3577
3578 VOID
EXhalbtc8723a2ant_ScanNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)3579 EXhalbtc8723a2ant_ScanNotify(
3580 IN PBTC_COEXIST pBtCoexist,
3581 IN u1Byte type
3582 )
3583 {
3584 if(BTC_SCAN_START == type)
3585 {
3586 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));
3587 }
3588 else if(BTC_SCAN_FINISH == type)
3589 {
3590 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));
3591 }
3592 }
3593
3594 VOID
EXhalbtc8723a2ant_ConnectNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)3595 EXhalbtc8723a2ant_ConnectNotify(
3596 IN PBTC_COEXIST pBtCoexist,
3597 IN u1Byte type
3598 )
3599 {
3600 if(BTC_ASSOCIATE_START == type)
3601 {
3602 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));
3603 }
3604 else if(BTC_ASSOCIATE_FINISH == type)
3605 {
3606 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));
3607 }
3608 }
3609
3610 VOID
EXhalbtc8723a2ant_MediaStatusNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)3611 EXhalbtc8723a2ant_MediaStatusNotify(
3612 IN PBTC_COEXIST pBtCoexist,
3613 IN u1Byte type
3614 )
3615 {
3616 if(BTC_MEDIA_CONNECT == type)
3617 {
3618 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n"));
3619 }
3620 else
3621 {
3622 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n"));
3623 }
3624
3625 halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, type);
3626 }
3627
3628 VOID
EXhalbtc8723a2ant_SpecialPacketNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)3629 EXhalbtc8723a2ant_SpecialPacketNotify(
3630 IN PBTC_COEXIST pBtCoexist,
3631 IN u1Byte type
3632 )
3633 {
3634 if(type == BTC_PACKET_DHCP)
3635 {
3636 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n"));
3637 }
3638 }
3639
3640 VOID
EXhalbtc8723a2ant_BtInfoNotify(IN PBTC_COEXIST pBtCoexist,IN pu1Byte tmpBuf,IN u1Byte length)3641 EXhalbtc8723a2ant_BtInfoNotify(
3642 IN PBTC_COEXIST pBtCoexist,
3643 IN pu1Byte tmpBuf,
3644 IN u1Byte length
3645 )
3646 {
3647 u1Byte btInfo=0;
3648 u1Byte i, rspSource=0;
3649 BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE;
3650 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
3651
3652 pCoexSta->bC2hBtInfoReqSent = FALSE;
3653
3654 rspSource = BT_INFO_SRC_8723A_2ANT_BT_RSP;
3655 pCoexSta->btInfoC2hCnt[rspSource]++;
3656
3657 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
3658 for(i=0; i<length; i++)
3659 {
3660 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
3661 if(i == 0)
3662 btInfo = tmpBuf[i];
3663 if(i == length-1)
3664 {
3665 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i]));
3666 }
3667 else
3668 {
3669 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i]));
3670 }
3671 }
3672
3673 if(BT_INFO_SRC_8723A_2ANT_WIFI_FW != rspSource)
3674 {
3675 pCoexSta->btRetryCnt =
3676 pCoexSta->btInfoC2h[rspSource][1];
3677
3678 pCoexSta->btRssi =
3679 pCoexSta->btInfoC2h[rspSource][2]*2+10;
3680
3681 pCoexSta->btInfoExt =
3682 pCoexSta->btInfoC2h[rspSource][3];
3683 }
3684
3685 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3686 // check BIT2 first ==> check if bt is under inquiry or page scan
3687 if(btInfo & BT_INFO_8723A_2ANT_B_INQ_PAGE)
3688 {
3689 pCoexSta->bC2hBtInquiryPage = TRUE;
3690 }
3691 else
3692 {
3693 pCoexSta->bC2hBtInquiryPage = FALSE;
3694 }
3695 }
3696
3697 VOID
EXhalbtc8723a2ant_StackOperationNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)3698 EXhalbtc8723a2ant_StackOperationNotify(
3699 IN PBTC_COEXIST pBtCoexist,
3700 IN u1Byte type
3701 )
3702 {
3703 if(BTC_STACK_OP_INQ_PAGE_PAIR_START == type)
3704 {
3705 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], StackOP Inquiry/page/pair start notify\n"));
3706 pCoexSta->bHoldForStackOperation = TRUE;
3707 pCoexSta->bHoldPeriodCnt = 1;
3708 halbtc8723a2ant_BtInquiryPage(pBtCoexist);
3709 }
3710 else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
3711 {
3712 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], StackOP Inquiry/page/pair finish notify\n"));
3713 pCoexSta->bHoldForStackOperation = FALSE;
3714 }
3715 }
3716
3717 VOID
EXhalbtc8723a2ant_HaltNotify(IN PBTC_COEXIST pBtCoexist)3718 EXhalbtc8723a2ant_HaltNotify(
3719 IN PBTC_COEXIST pBtCoexist
3720 )
3721 {
3722 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n"));
3723
3724 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
3725 EXhalbtc8723a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3726 }
3727
3728 VOID
EXhalbtc8723a2ant_Periodical(IN PBTC_COEXIST pBtCoexist)3729 EXhalbtc8723a2ant_Periodical(
3730 IN PBTC_COEXIST pBtCoexist
3731 )
3732 {
3733 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Periodical!!\n"));
3734
3735 // work around for c2h hang
3736 wa_halbtc8723a2ant_MonitorC2h(pBtCoexist);
3737
3738 halbtc8723a2ant_QueryBtInfo(pBtCoexist);
3739 halbtc8723a2ant_MonitorBtCtr(pBtCoexist);
3740 halbtc8723a2ant_MonitorBtEnableDisable(pBtCoexist);
3741
3742 halbtc8723a2ant_RunCoexistMechanism(pBtCoexist);
3743 }
3744
3745
3746 #endif
3747
3748