1 //============================================================
4 // This file is for RTL8723A Co-exist mechanism
7 // 2012/08/22 Cosa first check in.
8 // 2012/11/14 Cosa Revise for 8723A 2Ant out sourcing.
10 //============================================================
12 //============================================================
14 //============================================================
15 #include "Mp_Precomp.h"
16 #if(BT_30_SUPPORT == 1)
17 //============================================================
18 // Global variables, these are static variables
19 //============================================================
20 static COEX_DM_8723A_2ANT GLCoexDm8723a2Ant;
21 static PCOEX_DM_8723A_2ANT pCoexDm=&GLCoexDm8723a2Ant;
22 static COEX_STA_8723A_2ANT GLCoexSta8723a2Ant;
23 static PCOEX_STA_8723A_2ANT pCoexSta=&GLCoexSta8723a2Ant;
25 const char *const GLBtInfoSrc8723a2Ant[]={
28 "BT Info[bt auto report]",
31 //============================================================
32 // local function proto type if needed
33 //============================================================
34 //============================================================
35 // local function start with halbtc8723a2ant_
36 //============================================================
38 halbtc8723a2ant_IsWifiIdle(
39 IN PBTC_COEXIST pBtCoexist
42 BOOLEAN bWifiConnected=FALSE, bScan=FALSE, bLink=FALSE, bRoam=FALSE;
44 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
45 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
46 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
47 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
62 halbtc8723a2ant_BtRssiState(
69 u1Byte btRssiState=pCoexSta->preBtRssiState;
71 btRssi = pCoexSta->btRssi;
75 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
76 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
78 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
80 btRssiState = BTC_RSSI_STATE_HIGH;
81 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
85 btRssiState = BTC_RSSI_STATE_STAY_LOW;
86 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
91 if(btRssi < rssiThresh)
93 btRssiState = BTC_RSSI_STATE_LOW;
94 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
98 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
99 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
103 else if(levelNum == 3)
105 if(rssiThresh > rssiThresh1)
107 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
108 return pCoexSta->preBtRssiState;
111 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
112 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
114 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
116 btRssiState = BTC_RSSI_STATE_MEDIUM;
117 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
121 btRssiState = BTC_RSSI_STATE_STAY_LOW;
122 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
125 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
126 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
128 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
130 btRssiState = BTC_RSSI_STATE_HIGH;
131 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
133 else if(btRssi < rssiThresh)
135 btRssiState = BTC_RSSI_STATE_LOW;
136 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
140 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
141 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
146 if(btRssi < rssiThresh1)
148 btRssiState = BTC_RSSI_STATE_MEDIUM;
149 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
153 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
154 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
159 pCoexSta->preBtRssiState = btRssiState;
165 halbtc8723a2ant_WifiRssiState(
166 IN PBTC_COEXIST pBtCoexist,
169 IN u1Byte rssiThresh,
170 IN u1Byte rssiThresh1
174 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
176 pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
180 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
181 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
183 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
185 wifiRssiState = BTC_RSSI_STATE_HIGH;
186 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
190 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
191 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
196 if(wifiRssi < rssiThresh)
198 wifiRssiState = BTC_RSSI_STATE_LOW;
199 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
203 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
204 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
208 else if(levelNum == 3)
210 if(rssiThresh > rssiThresh1)
212 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
213 return pCoexSta->preWifiRssiState[index];
216 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
217 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
219 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
221 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
222 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
226 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
227 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
230 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
231 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
233 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
235 wifiRssiState = BTC_RSSI_STATE_HIGH;
236 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
238 else if(wifiRssi < rssiThresh)
240 wifiRssiState = BTC_RSSI_STATE_LOW;
241 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
245 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
246 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
251 if(wifiRssi < rssiThresh1)
253 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
254 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
258 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
259 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
264 pCoexSta->preWifiRssiState[index] = wifiRssiState;
266 return wifiRssiState;
270 halbtc8723a2ant_IndicateWifiChnlBwInfo(
271 IN PBTC_COEXIST pBtCoexist,
275 u1Byte H2C_Parameter[3] ={0};
277 u1Byte wifiCentralChnl;
279 // only 2.4G we need to inform bt the chnl mask
280 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
281 if( (BTC_MEDIA_CONNECT == type) &&
282 (wifiCentralChnl <= 14) )
284 H2C_Parameter[0] = 0x1;
285 H2C_Parameter[1] = wifiCentralChnl;
286 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
287 if(BTC_WIFI_BW_HT40 == wifiBw)
288 H2C_Parameter[2] = 0x30;
290 H2C_Parameter[2] = 0x20;
293 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
294 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
295 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
297 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x19=0x%x\n",
298 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
300 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x19, 3, H2C_Parameter);
304 halbtc8723a2ant_QueryBtInfo(
305 IN PBTC_COEXIST pBtCoexist
308 u1Byte H2C_Parameter[1] ={0};
310 pCoexSta->bC2hBtInfoReqSent = true;
312 H2C_Parameter[0] |= BIT0; // trigger
314 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x38=0x%x\n",
317 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x38, 1, H2C_Parameter);
320 halbtc8723a2ant_ActionAlgorithm(
321 IN PBTC_COEXIST pBtCoexist
324 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
325 BOOLEAN bBtHsOn=FALSE, bBtBusy=FALSE, limited_dig=FALSE;
326 u1Byte algorithm=BT_8723A_2ANT_COEX_ALGO_UNDEFINED;
327 u1Byte numOfDiffProfile=0;
329 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
331 //======================
332 // here we get BT status first
333 //======================
334 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_IDLE;
336 if((pStackInfo->bScoExist) ||(bBtHsOn) ||(pStackInfo->bHidExist))
338 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO or HID or HS exists, set BT non-idle !!!\n"));
339 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
344 if( (pBtCoexist->stack_info.numOfLink == 1) &&
345 (pStackInfo->bA2dpExist) )
347 if( (pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 100)
349 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP, low priority tx+rx < 100, set BT connected-idle!!!\n"));
350 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
354 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP, low priority tx+rx >= 100, set BT non-idle!!!\n"));
355 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
359 if( (pBtCoexist->stack_info.numOfLink == 1) &&
360 (pStackInfo->bPanExist) )
362 if((pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 600)
364 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN, low priority tx+rx < 600, set BT connected-idle!!!\n"));
365 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
369 if(pCoexSta->lowPriorityTx)
371 if((pCoexSta->lowPriorityRx /pCoexSta->lowPriorityTx)>9 )
373 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN, low priority rx/tx > 9, set BT connected-idle!!!\n"));
374 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
378 if(BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus)
380 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN, set BT non-idle!!!\n"));
381 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
385 if( (pBtCoexist->stack_info.numOfLink == 2) &&
386 (pStackInfo->bA2dpExist) &&
387 (pStackInfo->bPanExist) )
389 if((pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 600)
391 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN+A2DP, low priority tx+rx < 600, set BT connected-idle!!!\n"));
392 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
396 if(pCoexSta->lowPriorityTx)
398 if((pCoexSta->lowPriorityRx /pCoexSta->lowPriorityTx)>9 )
400 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN+A2DP, low priority rx/tx > 9, set BT connected-idle!!!\n"));
401 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
405 if(BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus)
407 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN+A2DP, set BT non-idle!!!\n"));
408 pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
412 if(BT_8723A_2ANT_BT_STATUS_IDLE != pCoexDm->btStatus)
422 pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
423 pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
424 //======================
426 if(!pStackInfo->bBtLinkExist)
428 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No profile exists!!!\n"));
432 if(pStackInfo->bScoExist)
434 if(pStackInfo->bHidExist)
436 if(pStackInfo->bPanExist)
438 if(pStackInfo->bA2dpExist)
441 if(numOfDiffProfile == 1)
443 if(pStackInfo->bScoExist)
445 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n"));
446 algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
450 if(pStackInfo->bHidExist)
452 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
453 algorithm = BT_8723A_2ANT_COEX_ALGO_HID;
455 else if(pStackInfo->bA2dpExist)
457 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
458 algorithm = BT_8723A_2ANT_COEX_ALGO_A2DP;
460 else if(pStackInfo->bPanExist)
464 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
465 algorithm = BT_8723A_2ANT_COEX_ALGO_PANHS;
469 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
470 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR;
475 else if(numOfDiffProfile == 2)
477 if(pStackInfo->bScoExist)
479 if(pStackInfo->bHidExist)
481 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n"));
482 algorithm = BT_8723A_2ANT_COEX_ALGO_HID;
484 else if(pStackInfo->bA2dpExist)
486 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n"));
487 algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
489 else if(pStackInfo->bPanExist)
493 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
494 algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
498 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
499 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
505 if( pStackInfo->bHidExist &&
506 pStackInfo->bA2dpExist )
508 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
509 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
511 else if( pStackInfo->bHidExist &&
512 pStackInfo->bPanExist )
516 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
517 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
521 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
522 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
525 else if( pStackInfo->bPanExist &&
526 pStackInfo->bA2dpExist )
530 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
531 algorithm = BT_8723A_2ANT_COEX_ALGO_A2DP;
535 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
536 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP;
541 else if(numOfDiffProfile == 3)
543 if(pStackInfo->bScoExist)
545 if( pStackInfo->bHidExist &&
546 pStackInfo->bA2dpExist )
548 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP ==> HID\n"));
549 algorithm = BT_8723A_2ANT_COEX_ALGO_HID;
551 else if( pStackInfo->bHidExist &&
552 pStackInfo->bPanExist )
556 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(HS)\n"));
557 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
561 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
562 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
565 else if( pStackInfo->bPanExist &&
566 pStackInfo->bA2dpExist )
570 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
571 algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
575 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
576 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
582 if( pStackInfo->bHidExist &&
583 pStackInfo->bPanExist &&
584 pStackInfo->bA2dpExist )
588 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
589 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
593 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
594 algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
599 else if(numOfDiffProfile >= 3)
601 if(pStackInfo->bScoExist)
603 if( pStackInfo->bHidExist &&
604 pStackInfo->bPanExist &&
605 pStackInfo->bA2dpExist )
609 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
614 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
615 algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
625 halbtc8723a2ant_NeedToDecBtPwr(
626 IN PBTC_COEXIST pBtCoexist
630 BOOLEAN bBtHsOn=FALSE, bWifiConnected=FALSE;
633 if(!pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn))
635 if(!pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected))
637 if(!pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi))
646 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], Need to decrease bt power for HS mode!!\n"));
652 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], Need to decrease bt power for Wifi is connected!!\n"));
661 halbtc8723a2ant_SetFwDacSwingLevel(
662 IN PBTC_COEXIST pBtCoexist,
663 IN u1Byte dacSwingLvl
666 u1Byte H2C_Parameter[1] ={0};
668 // There are several type of dacswing
669 // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
670 H2C_Parameter[0] = dacSwingLvl;
672 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl));
673 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x29=0x%x\n", H2C_Parameter[0]));
675 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x29, 1, H2C_Parameter);
679 halbtc8723a2ant_SetFwDecBtPwr(
680 IN PBTC_COEXIST pBtCoexist,
684 u1Byte H2C_Parameter[1] ={0};
686 H2C_Parameter[0] = 0;
690 H2C_Parameter[0] |= BIT1;
693 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], decrease Bt Power : %s, FW write 0x21=0x%x\n",
694 (bDecBtPwr? "Yes!!":"No!!"), H2C_Parameter[0]));
696 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x21, 1, H2C_Parameter);
700 halbtc8723a2ant_DecBtPwr(
701 IN PBTC_COEXIST pBtCoexist,
702 IN BOOLEAN bForceExec,
706 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s Dec BT power = %s\n",
707 (bForceExec? "force to":""), ((bDecBtPwr)? "ON":"OFF")));
708 pCoexDm->bCurDecBtPwr = bDecBtPwr;
712 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreDecBtPwr=%d, bCurDecBtPwr=%d\n",
713 pCoexDm->bPreDecBtPwr, pCoexDm->bCurDecBtPwr));
715 if(pCoexDm->bPreDecBtPwr == pCoexDm->bCurDecBtPwr)
718 halbtc8723a2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->bCurDecBtPwr);
720 pCoexDm->bPreDecBtPwr = pCoexDm->bCurDecBtPwr;
724 halbtc8723a2ant_FwDacSwingLvl(
725 IN PBTC_COEXIST pBtCoexist,
726 IN BOOLEAN bForceExec,
727 IN u1Byte fwDacSwingLvl
730 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set FW Dac Swing level = %d\n",
731 (bForceExec? "force to":""), fwDacSwingLvl));
732 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
736 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preFwDacSwingLvl=%d, curFwDacSwingLvl=%d\n",
737 pCoexDm->preFwDacSwingLvl, pCoexDm->curFwDacSwingLvl));
739 if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
743 halbtc8723a2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
745 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
749 halbtc8723a2ant_SetSwRfRxLpfCorner(
750 IN PBTC_COEXIST pBtCoexist,
751 IN BOOLEAN bRxRfShrinkOn
756 //Shrink RF Rx LPF corner
757 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
758 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7);
762 //Resume RF Rx LPF corner
763 // After initialized, we can use pCoexDm->btRf0x1eBackup
764 if(pBtCoexist->initilized)
766 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
767 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
773 halbtc8723a2ant_RfShrink(
774 IN PBTC_COEXIST pBtCoexist,
775 IN BOOLEAN bForceExec,
776 IN BOOLEAN bRxRfShrinkOn
779 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
780 (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
781 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
785 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n",
786 pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink));
788 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
791 halbtc8723a2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
793 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
797 halbtc8723a2ant_SetSwPenaltyTxRateAdaptive(
798 IN PBTC_COEXIST pBtCoexist,
799 IN BOOLEAN bLowPenaltyRa
804 tmpU1 = pBtCoexist->btc_read_1byte(pBtCoexist, 0x4fd);
808 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
813 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
817 pBtCoexist->btc_write_1byte(pBtCoexist, 0x4fd, tmpU1);
821 halbtc8723a2ant_LowPenaltyRa(
822 IN PBTC_COEXIST pBtCoexist,
823 IN BOOLEAN bForceExec,
824 IN BOOLEAN bLowPenaltyRa
828 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
829 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
830 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
834 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
835 pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
837 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
840 halbtc8723a2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
842 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
846 halbtc8723a2ant_SetSwFullTimeDacSwing(
847 IN PBTC_COEXIST pBtCoexist,
848 IN BOOLEAN bSwDacSwingOn,
849 IN u4Byte swDacSwingLvl
854 pBtCoexist->btc_setBbReg(pBtCoexist, 0x880, 0xff000000, swDacSwingLvl);
858 pBtCoexist->btc_setBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0);
864 halbtc8723a2ant_DacSwing(
865 IN PBTC_COEXIST pBtCoexist,
866 IN BOOLEAN bForceExec,
867 IN BOOLEAN bDacSwingOn,
868 IN u4Byte dacSwingLvl
871 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
872 (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
873 pCoexDm->bCurDacSwingOn = bDacSwingOn;
874 pCoexDm->curDacSwingLvl = dacSwingLvl;
878 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
879 pCoexDm->bPreDacSwingOn, pCoexDm->preDacSwingLvl,
880 pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl));
882 if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
883 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
887 halbtc8723a2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
889 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
890 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
894 halbtc8723a2ant_SetAdcBackOff(
895 IN PBTC_COEXIST pBtCoexist,
896 IN BOOLEAN bAdcBackOff
901 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level On!\n"));
902 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc04,0x3a07611);
906 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level Off!\n"));
907 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc04,0x3a05611);
912 halbtc8723a2ant_AdcBackOff(
913 IN PBTC_COEXIST pBtCoexist,
914 IN BOOLEAN bForceExec,
915 IN BOOLEAN bAdcBackOff
918 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn AdcBackOff = %s\n",
919 (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));
920 pCoexDm->bCurAdcBackOff = bAdcBackOff;
924 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n",
925 pCoexDm->bPreAdcBackOff, pCoexDm->bCurAdcBackOff));
927 if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff)
930 halbtc8723a2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
932 pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
936 halbtc8723a2ant_SetAgcTable(
937 IN PBTC_COEXIST pBtCoexist,
938 IN BOOLEAN bAgcTableEn
941 u1Byte rssiAdjustVal=0;
945 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
946 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4e1c0001);
947 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4d1d0001);
948 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4c1e0001);
949 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4b1f0001);
950 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4a200001);
952 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xdc000);
953 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x90000);
954 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x51000);
955 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x12000);
956 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x00355);
962 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
963 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x641c0001);
964 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x631d0001);
965 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x621e0001);
966 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x611f0001);
967 pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x60200001);
969 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x32000);
970 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x71000);
971 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xb0000);
972 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xfc000);
973 pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x30355);
976 // set rssiAdjustVal for wifi module.
977 pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
982 halbtc8723a2ant_AgcTable(
983 IN PBTC_COEXIST pBtCoexist,
984 IN BOOLEAN bForceExec,
985 IN BOOLEAN bAgcTableEn
988 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s %s Agc Table\n",
989 (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));
990 pCoexDm->bCurAgcTableEn = bAgcTableEn;
994 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
995 pCoexDm->bPreAgcTableEn, pCoexDm->bCurAgcTableEn));
997 if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
1000 halbtc8723a2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
1002 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
1006 halbtc8723a2ant_SetCoexTable(
1007 IN PBTC_COEXIST pBtCoexist,
1013 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
1014 pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c0, val0x6c0);
1016 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
1017 pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c8, val0x6c8);
1019 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
1020 pBtCoexist->btc_write_1byte(pBtCoexist, 0x6cc, val0x6cc);
1024 halbtc8723a2ant_CoexTable(
1025 IN PBTC_COEXIST pBtCoexist,
1026 IN BOOLEAN bForceExec,
1032 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
1033 (bForceExec? "force to":""), val0x6c0, val0x6c8, val0x6cc));
1034 pCoexDm->curVal0x6c0 = val0x6c0;
1035 pCoexDm->curVal0x6c8 = val0x6c8;
1036 pCoexDm->curVal0x6cc = val0x6cc;
1040 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
1041 pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
1042 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
1043 pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
1045 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
1046 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
1047 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
1050 halbtc8723a2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c8, val0x6cc);
1052 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
1053 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
1054 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
1058 halbtc8723a2ant_SetFwIgnoreWlanAct(
1059 IN PBTC_COEXIST pBtCoexist,
1063 u1Byte H2C_Parameter[1] ={0};
1067 H2C_Parameter[0] |= BIT0; // function enable
1070 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x25=0x%x\n",
1073 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x25, 1, H2C_Parameter);
1077 halbtc8723a2ant_IgnoreWlanAct(
1078 IN PBTC_COEXIST pBtCoexist,
1079 IN BOOLEAN bForceExec,
1083 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
1084 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
1085 pCoexDm->bCurIgnoreWlanAct = bEnable;
1089 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
1090 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
1092 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
1095 halbtc8723a2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
1097 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
1101 halbtc8723a2ant_SetFwPstdma(
1102 IN PBTC_COEXIST pBtCoexist,
1110 u1Byte H2C_Parameter[5] ={0};
1112 H2C_Parameter[0] = byte1;
1113 H2C_Parameter[1] = byte2;
1114 H2C_Parameter[2] = byte3;
1115 H2C_Parameter[3] = byte4;
1116 H2C_Parameter[4] = byte5;
1118 pCoexDm->psTdmaPara[0] = byte1;
1119 pCoexDm->psTdmaPara[1] = byte2;
1120 pCoexDm->psTdmaPara[2] = byte3;
1121 pCoexDm->psTdmaPara[3] = byte4;
1122 pCoexDm->psTdmaPara[4] = byte5;
1124 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x3a(5bytes)=0x%x%08x\n",
1126 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
1128 pBtCoexist->btc_fill_h2c(pBtCoexist, 0x3a, 5, H2C_Parameter);
1132 halbtc8723a2ant_PsTdma(
1133 IN PBTC_COEXIST pBtCoexist,
1134 IN BOOLEAN bForceExec,
1141 btTxRxCnt = pCoexSta->highPriorityTx+pCoexSta->highPriorityRx+
1142 pCoexSta->lowPriorityTx+pCoexSta->lowPriorityRx;
1144 if(btTxRxCnt > 3000)
1146 pCoexDm->bCurPsTdmaOn = true;
1147 pCoexDm->curPsTdma = 8;
1148 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], turn ON PS TDMA, type=%d for BT tx/rx counters=%d(>3000)\n",
1149 pCoexDm->curPsTdma, btTxRxCnt));
1153 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
1154 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
1155 pCoexDm->bCurPsTdmaOn = bTurnOn;
1156 pCoexDm->curPsTdma = type;
1161 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
1162 pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn));
1163 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
1164 pCoexDm->prePsTdma, pCoexDm->curPsTdma));
1166 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
1167 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
1170 if(pCoexDm->bCurPsTdmaOn)
1172 switch(pCoexDm->curPsTdma)
1176 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x98);
1179 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x98);
1182 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x98);
1185 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x5, 0x5, 0xe1, 0x80);
1188 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x98);
1191 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x98);
1194 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x98);
1197 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x5, 0x5, 0x60, 0x80);
1200 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x98);
1203 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x98);
1206 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x98);
1209 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x98);
1212 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x98);
1215 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x98);
1218 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x98);
1221 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x98);
1224 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x80);
1227 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x98);
1230 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x98);
1233 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x98);
1240 switch(pCoexDm->curPsTdma)
1243 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
1246 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
1249 halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
1255 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1256 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1261 halbtc8723a2ant_CoexAllOff(
1262 IN PBTC_COEXIST pBtCoexist
1266 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1267 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1268 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1269 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1272 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1273 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1274 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
1275 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
1276 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1279 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1283 halbtc8723a2ant_InitCoexDm(
1284 IN PBTC_COEXIST pBtCoexist
1287 // force to reset coex mechanism
1288 halbtc8723a2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0x55555555, 0xffff, 0x3);
1289 halbtc8723a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
1290 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 0x20);
1291 halbtc8723a2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, FALSE);
1292 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
1294 halbtc8723a2ant_AgcTable(pBtCoexist, FORCE_EXEC, FALSE);
1295 halbtc8723a2ant_AdcBackOff(pBtCoexist, FORCE_EXEC, FALSE);
1296 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, FORCE_EXEC, FALSE);
1297 halbtc8723a2ant_RfShrink(pBtCoexist, FORCE_EXEC, FALSE);
1298 halbtc8723a2ant_DacSwing(pBtCoexist, FORCE_EXEC, FALSE, 0xc0);
1302 halbtc8723a2ant_BtInquiryPage(
1303 IN PBTC_COEXIST pBtCoexist
1306 BOOLEAN bLowPwrDisable=true;
1308 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1310 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1311 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1312 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1316 halbtc8723a2ant_BtEnableAction(
1317 IN PBTC_COEXIST pBtCoexist
1320 BOOLEAN bWifiConnected=FALSE;
1322 // Here we need to resend some wifi info to BT
1323 // because bt is reset and loss of the info.
1324 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1327 halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, BTC_MEDIA_CONNECT);
1331 halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, BTC_MEDIA_DISCONNECT);
1334 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
1338 halbtc8723a2ant_MonitorBtCtr(
1339 IN PBTC_COEXIST pBtCoexist
1342 u4Byte regHPTxRx, regLPTxRx, u4Tmp;
1343 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
1349 u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regHPTxRx);
1350 regHPTx = u4Tmp & MASKLWORD;
1351 regHPRx = (u4Tmp & MASKHWORD)>>16;
1353 u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regLPTxRx);
1354 regLPTx = u4Tmp & MASKLWORD;
1355 regLPRx = (u4Tmp & MASKHWORD)>>16;
1357 pCoexSta->highPriorityTx = regHPTx;
1358 pCoexSta->highPriorityRx = regHPRx;
1359 pCoexSta->lowPriorityTx = regLPTx;
1360 pCoexSta->lowPriorityRx = regLPRx;
1362 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
1363 regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
1364 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
1365 regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
1368 pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0xc);
1372 halbtc8723a2ant_MonitorBtEnableDisable(
1373 IN PBTC_COEXIST pBtCoexist
1376 static BOOLEAN bPreBtDisabled=FALSE;
1377 static u4Byte btDisableCnt=0;
1378 BOOLEAN bBtActive=true, bBtDisabled=FALSE;
1380 // This function check if bt is disabled
1382 if( pCoexSta->highPriorityTx == 0 &&
1383 pCoexSta->highPriorityRx == 0 &&
1384 pCoexSta->lowPriorityTx == 0 &&
1385 pCoexSta->lowPriorityRx == 0)
1389 if( pCoexSta->highPriorityTx == 0xffff &&
1390 pCoexSta->highPriorityRx == 0xffff &&
1391 pCoexSta->lowPriorityTx == 0xffff &&
1392 pCoexSta->lowPriorityRx == 0xffff)
1399 bBtDisabled = FALSE;
1400 pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
1401 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
1406 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
1408 if(btDisableCnt >= 2)
1411 pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
1412 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
1415 if(bPreBtDisabled != bBtDisabled)
1417 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
1418 (bPreBtDisabled ? "disabled":"enabled"),
1419 (bBtDisabled ? "disabled":"enabled")));
1420 bPreBtDisabled = bBtDisabled;
1423 halbtc8723a2ant_BtEnableAction(pBtCoexist);
1429 halbtc8723a2ant_IsCommonAction(
1430 IN PBTC_COEXIST pBtCoexist
1433 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
1434 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE;
1435 BOOLEAN bLowPwrDisable=FALSE;
1437 if(!pStackInfo->bBtLinkExist)
1439 bLowPwrDisable = FALSE;
1440 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1444 bLowPwrDisable = true;
1445 pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1448 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1450 if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1451 BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus)
1453 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi idle + Bt idle!!\n"));
1455 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
1456 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
1457 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1459 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1460 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1461 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1463 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1464 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1465 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1469 else if(!halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1470 (BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus) )
1472 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non-idle + BT idle!!\n"));
1474 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
1475 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
1476 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1478 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1479 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1480 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1481 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
1483 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1484 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1485 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1489 else if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1490 (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
1492 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi idle + Bt connected idle!!\n"));
1494 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
1495 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, true);
1496 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1498 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1499 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1500 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1501 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1503 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1504 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1505 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1509 else if(!halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1510 (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
1512 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non-idle + Bt connected idle!!\n"));
1514 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
1515 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, true);
1516 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1518 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1519 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1520 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1521 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1523 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1524 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1525 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1529 else if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
1530 (BT_8723A_2ANT_BT_STATUS_NON_IDLE == pCoexDm->btStatus) )
1532 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi idle + BT non-idle!!\n"));
1534 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
1535 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, true);
1536 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
1538 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1539 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1540 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1541 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
1543 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
1544 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
1545 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
1551 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non-idle + BT non-idle!!\n"));
1552 halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
1553 halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, true);
1554 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
1555 halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
1563 halbtc8723a2ant_TdmaDurationAdjust(
1564 IN PBTC_COEXIST pBtCoexist,
1566 IN BOOLEAN bTxPause,
1567 IN u1Byte maxInterval
1570 static s4Byte up,dn,m,n,WaitCount;
1571 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
1572 u1Byte retryCount=0;
1574 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjust()\n"));
1576 if(pCoexDm->bResetTdmaAdjust)
1578 pCoexDm->bResetTdmaAdjust = FALSE;
1579 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
1585 if(maxInterval == 1)
1587 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1588 pCoexDm->psTdmaDuAdjType = 13;
1590 else if(maxInterval == 2)
1592 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1593 pCoexDm->psTdmaDuAdjType = 14;
1595 else if(maxInterval == 3)
1597 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1598 pCoexDm->psTdmaDuAdjType = 15;
1602 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1603 pCoexDm->psTdmaDuAdjType = 15;
1608 if(maxInterval == 1)
1610 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1611 pCoexDm->psTdmaDuAdjType = 9;
1613 else if(maxInterval == 2)
1615 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1616 pCoexDm->psTdmaDuAdjType = 10;
1618 else if(maxInterval == 3)
1620 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1621 pCoexDm->psTdmaDuAdjType = 11;
1625 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1626 pCoexDm->psTdmaDuAdjType = 11;
1634 if(maxInterval == 1)
1636 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1637 pCoexDm->psTdmaDuAdjType = 5;
1639 else if(maxInterval == 2)
1641 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1642 pCoexDm->psTdmaDuAdjType = 6;
1644 else if(maxInterval == 3)
1646 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1647 pCoexDm->psTdmaDuAdjType = 7;
1651 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1652 pCoexDm->psTdmaDuAdjType = 7;
1657 if(maxInterval == 1)
1659 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1660 pCoexDm->psTdmaDuAdjType = 1;
1662 else if(maxInterval == 2)
1664 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1665 pCoexDm->psTdmaDuAdjType = 2;
1667 else if(maxInterval == 3)
1669 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1670 pCoexDm->psTdmaDuAdjType = 3;
1674 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1675 pCoexDm->psTdmaDuAdjType = 3;
1690 //accquire the BT TRx retry count from BT_Info byte2
1691 retryCount = pCoexSta->btRetryCnt;
1692 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
1693 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
1694 up, dn, m, n, WaitCount));
1698 if(retryCount == 0) // no retry in the last 2-second duration
1706 if(up >= n) // if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
1713 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
1716 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
1724 if (dn == 2) // if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
1727 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
1731 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
1739 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
1742 else //retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
1745 m++; // ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^
1749 if ( m >= 20) //m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
1757 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
1760 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], max Interval = %d\n", maxInterval));
1761 if(maxInterval == 1)
1765 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
1767 if(pCoexDm->curPsTdma == 1)
1769 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1770 pCoexDm->psTdmaDuAdjType = 5;
1772 else if(pCoexDm->curPsTdma == 2)
1774 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1775 pCoexDm->psTdmaDuAdjType = 6;
1777 else if(pCoexDm->curPsTdma == 3)
1779 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1780 pCoexDm->psTdmaDuAdjType = 7;
1782 else if(pCoexDm->curPsTdma == 4)
1784 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1785 pCoexDm->psTdmaDuAdjType = 8;
1787 if(pCoexDm->curPsTdma == 9)
1789 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1790 pCoexDm->psTdmaDuAdjType = 13;
1792 else if(pCoexDm->curPsTdma == 10)
1794 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1795 pCoexDm->psTdmaDuAdjType = 14;
1797 else if(pCoexDm->curPsTdma == 11)
1799 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1800 pCoexDm->psTdmaDuAdjType = 15;
1802 else if(pCoexDm->curPsTdma == 12)
1804 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1805 pCoexDm->psTdmaDuAdjType = 16;
1810 if(pCoexDm->curPsTdma == 5)
1812 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1813 pCoexDm->psTdmaDuAdjType = 6;
1815 else if(pCoexDm->curPsTdma == 6)
1817 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1818 pCoexDm->psTdmaDuAdjType = 7;
1820 else if(pCoexDm->curPsTdma == 7)
1822 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1823 pCoexDm->psTdmaDuAdjType = 8;
1825 else if(pCoexDm->curPsTdma == 13)
1827 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1828 pCoexDm->psTdmaDuAdjType = 14;
1830 else if(pCoexDm->curPsTdma == 14)
1832 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1833 pCoexDm->psTdmaDuAdjType = 15;
1835 else if(pCoexDm->curPsTdma == 15)
1837 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1838 pCoexDm->psTdmaDuAdjType = 16;
1841 else if (result == 1)
1843 if(pCoexDm->curPsTdma == 8)
1845 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1846 pCoexDm->psTdmaDuAdjType = 7;
1848 else if(pCoexDm->curPsTdma == 7)
1850 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1851 pCoexDm->psTdmaDuAdjType = 6;
1853 else if(pCoexDm->curPsTdma == 6)
1855 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1856 pCoexDm->psTdmaDuAdjType = 5;
1858 else if(pCoexDm->curPsTdma == 16)
1860 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1861 pCoexDm->psTdmaDuAdjType = 15;
1863 else if(pCoexDm->curPsTdma == 15)
1865 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1866 pCoexDm->psTdmaDuAdjType = 14;
1868 else if(pCoexDm->curPsTdma == 14)
1870 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1871 pCoexDm->psTdmaDuAdjType = 13;
1877 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
1878 if(pCoexDm->curPsTdma == 5)
1880 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1881 pCoexDm->psTdmaDuAdjType = 1;
1883 else if(pCoexDm->curPsTdma == 6)
1885 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1886 pCoexDm->psTdmaDuAdjType = 2;
1888 else if(pCoexDm->curPsTdma == 7)
1890 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1891 pCoexDm->psTdmaDuAdjType = 3;
1893 else if(pCoexDm->curPsTdma == 8)
1895 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
1896 pCoexDm->psTdmaDuAdjType = 4;
1898 if(pCoexDm->curPsTdma == 13)
1900 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1901 pCoexDm->psTdmaDuAdjType = 9;
1903 else if(pCoexDm->curPsTdma == 14)
1905 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1906 pCoexDm->psTdmaDuAdjType = 10;
1908 else if(pCoexDm->curPsTdma == 15)
1910 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1911 pCoexDm->psTdmaDuAdjType = 11;
1913 else if(pCoexDm->curPsTdma == 16)
1915 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
1916 pCoexDm->psTdmaDuAdjType = 12;
1921 if(pCoexDm->curPsTdma == 1)
1923 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1924 pCoexDm->psTdmaDuAdjType = 2;
1926 else if(pCoexDm->curPsTdma == 2)
1928 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1929 pCoexDm->psTdmaDuAdjType = 3;
1931 else if(pCoexDm->curPsTdma == 3)
1933 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
1934 pCoexDm->psTdmaDuAdjType = 4;
1936 else if(pCoexDm->curPsTdma == 9)
1938 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1939 pCoexDm->psTdmaDuAdjType = 10;
1941 else if(pCoexDm->curPsTdma == 10)
1943 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1944 pCoexDm->psTdmaDuAdjType = 11;
1946 else if(pCoexDm->curPsTdma == 11)
1948 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
1949 pCoexDm->psTdmaDuAdjType = 12;
1952 else if (result == 1)
1954 if(pCoexDm->curPsTdma == 4)
1956 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1957 pCoexDm->psTdmaDuAdjType = 3;
1959 else if(pCoexDm->curPsTdma == 3)
1961 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1962 pCoexDm->psTdmaDuAdjType = 2;
1964 else if(pCoexDm->curPsTdma == 2)
1966 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1967 pCoexDm->psTdmaDuAdjType = 1;
1969 else if(pCoexDm->curPsTdma == 12)
1971 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1972 pCoexDm->psTdmaDuAdjType = 11;
1974 else if(pCoexDm->curPsTdma == 11)
1976 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1977 pCoexDm->psTdmaDuAdjType = 10;
1979 else if(pCoexDm->curPsTdma == 10)
1981 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1982 pCoexDm->psTdmaDuAdjType = 9;
1987 else if(maxInterval == 2)
1991 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
1992 if(pCoexDm->curPsTdma == 1)
1994 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1995 pCoexDm->psTdmaDuAdjType = 6;
1997 else if(pCoexDm->curPsTdma == 2)
1999 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
2000 pCoexDm->psTdmaDuAdjType = 6;
2002 else if(pCoexDm->curPsTdma == 3)
2004 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2005 pCoexDm->psTdmaDuAdjType = 7;
2007 else if(pCoexDm->curPsTdma == 4)
2009 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2010 pCoexDm->psTdmaDuAdjType = 8;
2012 if(pCoexDm->curPsTdma == 9)
2014 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
2015 pCoexDm->psTdmaDuAdjType = 14;
2017 else if(pCoexDm->curPsTdma == 10)
2019 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
2020 pCoexDm->psTdmaDuAdjType = 14;
2022 else if(pCoexDm->curPsTdma == 11)
2024 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2025 pCoexDm->psTdmaDuAdjType = 15;
2027 else if(pCoexDm->curPsTdma == 12)
2029 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
2030 pCoexDm->psTdmaDuAdjType = 16;
2034 if(pCoexDm->curPsTdma == 5)
2036 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
2037 pCoexDm->psTdmaDuAdjType = 6;
2039 else if(pCoexDm->curPsTdma == 6)
2041 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2042 pCoexDm->psTdmaDuAdjType = 7;
2044 else if(pCoexDm->curPsTdma == 7)
2046 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2047 pCoexDm->psTdmaDuAdjType = 8;
2049 else if(pCoexDm->curPsTdma == 13)
2051 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
2052 pCoexDm->psTdmaDuAdjType = 14;
2054 else if(pCoexDm->curPsTdma == 14)
2056 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2057 pCoexDm->psTdmaDuAdjType = 15;
2059 else if(pCoexDm->curPsTdma == 15)
2061 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
2062 pCoexDm->psTdmaDuAdjType = 16;
2065 else if (result == 1)
2067 if(pCoexDm->curPsTdma == 8)
2069 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2070 pCoexDm->psTdmaDuAdjType = 7;
2072 else if(pCoexDm->curPsTdma == 7)
2074 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
2075 pCoexDm->psTdmaDuAdjType = 6;
2077 else if(pCoexDm->curPsTdma == 6)
2079 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
2080 pCoexDm->psTdmaDuAdjType = 6;
2082 else if(pCoexDm->curPsTdma == 16)
2084 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2085 pCoexDm->psTdmaDuAdjType = 15;
2087 else if(pCoexDm->curPsTdma == 15)
2089 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
2090 pCoexDm->psTdmaDuAdjType = 14;
2092 else if(pCoexDm->curPsTdma == 14)
2094 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
2095 pCoexDm->psTdmaDuAdjType = 14;
2101 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
2102 if(pCoexDm->curPsTdma == 5)
2104 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2105 pCoexDm->psTdmaDuAdjType = 2;
2107 else if(pCoexDm->curPsTdma == 6)
2109 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2110 pCoexDm->psTdmaDuAdjType = 2;
2112 else if(pCoexDm->curPsTdma == 7)
2114 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2115 pCoexDm->psTdmaDuAdjType = 3;
2117 else if(pCoexDm->curPsTdma == 8)
2119 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2120 pCoexDm->psTdmaDuAdjType = 4;
2122 if(pCoexDm->curPsTdma == 13)
2124 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2125 pCoexDm->psTdmaDuAdjType = 10;
2127 else if(pCoexDm->curPsTdma == 14)
2129 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2130 pCoexDm->psTdmaDuAdjType = 10;
2132 else if(pCoexDm->curPsTdma == 15)
2134 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2135 pCoexDm->psTdmaDuAdjType = 11;
2137 else if(pCoexDm->curPsTdma == 16)
2139 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2140 pCoexDm->psTdmaDuAdjType = 12;
2144 if(pCoexDm->curPsTdma == 1)
2146 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2147 pCoexDm->psTdmaDuAdjType = 2;
2149 else if(pCoexDm->curPsTdma == 2)
2151 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2152 pCoexDm->psTdmaDuAdjType = 3;
2154 else if(pCoexDm->curPsTdma == 3)
2156 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2157 pCoexDm->psTdmaDuAdjType = 4;
2159 else if(pCoexDm->curPsTdma == 9)
2161 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2162 pCoexDm->psTdmaDuAdjType = 10;
2164 else if(pCoexDm->curPsTdma == 10)
2166 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2167 pCoexDm->psTdmaDuAdjType = 11;
2169 else if(pCoexDm->curPsTdma == 11)
2171 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2172 pCoexDm->psTdmaDuAdjType = 12;
2175 else if (result == 1)
2177 if(pCoexDm->curPsTdma == 4)
2179 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2180 pCoexDm->psTdmaDuAdjType = 3;
2182 else if(pCoexDm->curPsTdma == 3)
2184 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2185 pCoexDm->psTdmaDuAdjType = 2;
2187 else if(pCoexDm->curPsTdma == 2)
2189 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2190 pCoexDm->psTdmaDuAdjType = 2;
2192 else if(pCoexDm->curPsTdma == 12)
2194 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2195 pCoexDm->psTdmaDuAdjType = 11;
2197 else if(pCoexDm->curPsTdma == 11)
2199 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2200 pCoexDm->psTdmaDuAdjType = 10;
2202 else if(pCoexDm->curPsTdma == 10)
2204 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2205 pCoexDm->psTdmaDuAdjType = 10;
2210 else if(maxInterval == 3)
2214 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
2215 if(pCoexDm->curPsTdma == 1)
2217 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2218 pCoexDm->psTdmaDuAdjType = 7;
2220 else if(pCoexDm->curPsTdma == 2)
2222 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2223 pCoexDm->psTdmaDuAdjType = 7;
2225 else if(pCoexDm->curPsTdma == 3)
2227 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2228 pCoexDm->psTdmaDuAdjType = 7;
2230 else if(pCoexDm->curPsTdma == 4)
2232 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2233 pCoexDm->psTdmaDuAdjType = 8;
2235 if(pCoexDm->curPsTdma == 9)
2237 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2238 pCoexDm->psTdmaDuAdjType = 15;
2240 else if(pCoexDm->curPsTdma == 10)
2242 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2243 pCoexDm->psTdmaDuAdjType = 15;
2245 else if(pCoexDm->curPsTdma == 11)
2247 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2248 pCoexDm->psTdmaDuAdjType = 15;
2250 else if(pCoexDm->curPsTdma == 12)
2252 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
2253 pCoexDm->psTdmaDuAdjType = 16;
2257 if(pCoexDm->curPsTdma == 5)
2259 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2260 pCoexDm->psTdmaDuAdjType = 7;
2262 else if(pCoexDm->curPsTdma == 6)
2264 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2265 pCoexDm->psTdmaDuAdjType = 7;
2267 else if(pCoexDm->curPsTdma == 7)
2269 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2270 pCoexDm->psTdmaDuAdjType = 8;
2272 else if(pCoexDm->curPsTdma == 13)
2274 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2275 pCoexDm->psTdmaDuAdjType = 15;
2277 else if(pCoexDm->curPsTdma == 14)
2279 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2280 pCoexDm->psTdmaDuAdjType = 15;
2282 else if(pCoexDm->curPsTdma == 15)
2284 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
2285 pCoexDm->psTdmaDuAdjType = 16;
2288 else if (result == 1)
2290 if(pCoexDm->curPsTdma == 8)
2292 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2293 pCoexDm->psTdmaDuAdjType = 7;
2295 else if(pCoexDm->curPsTdma == 7)
2297 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2298 pCoexDm->psTdmaDuAdjType = 7;
2300 else if(pCoexDm->curPsTdma == 6)
2302 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2303 pCoexDm->psTdmaDuAdjType = 7;
2305 else if(pCoexDm->curPsTdma == 16)
2307 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2308 pCoexDm->psTdmaDuAdjType = 15;
2310 else if(pCoexDm->curPsTdma == 15)
2312 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2313 pCoexDm->psTdmaDuAdjType = 15;
2315 else if(pCoexDm->curPsTdma == 14)
2317 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2318 pCoexDm->psTdmaDuAdjType = 15;
2324 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
2325 if(pCoexDm->curPsTdma == 5)
2327 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2328 pCoexDm->psTdmaDuAdjType = 3;
2330 else if(pCoexDm->curPsTdma == 6)
2332 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2333 pCoexDm->psTdmaDuAdjType = 3;
2335 else if(pCoexDm->curPsTdma == 7)
2337 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2338 pCoexDm->psTdmaDuAdjType = 3;
2340 else if(pCoexDm->curPsTdma == 8)
2342 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2343 pCoexDm->psTdmaDuAdjType = 4;
2345 if(pCoexDm->curPsTdma == 13)
2347 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2348 pCoexDm->psTdmaDuAdjType = 11;
2350 else if(pCoexDm->curPsTdma == 14)
2352 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2353 pCoexDm->psTdmaDuAdjType = 11;
2355 else if(pCoexDm->curPsTdma == 15)
2357 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2358 pCoexDm->psTdmaDuAdjType = 11;
2360 else if(pCoexDm->curPsTdma == 16)
2362 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2363 pCoexDm->psTdmaDuAdjType = 12;
2367 if(pCoexDm->curPsTdma == 1)
2369 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2370 pCoexDm->psTdmaDuAdjType = 3;
2372 else if(pCoexDm->curPsTdma == 2)
2374 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2375 pCoexDm->psTdmaDuAdjType = 3;
2377 else if(pCoexDm->curPsTdma == 3)
2379 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2380 pCoexDm->psTdmaDuAdjType = 4;
2382 else if(pCoexDm->curPsTdma == 9)
2384 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2385 pCoexDm->psTdmaDuAdjType = 11;
2387 else if(pCoexDm->curPsTdma == 10)
2389 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2390 pCoexDm->psTdmaDuAdjType = 11;
2392 else if(pCoexDm->curPsTdma == 11)
2394 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2395 pCoexDm->psTdmaDuAdjType = 12;
2398 else if (result == 1)
2400 if(pCoexDm->curPsTdma == 4)
2402 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2403 pCoexDm->psTdmaDuAdjType = 3;
2405 else if(pCoexDm->curPsTdma == 3)
2407 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2408 pCoexDm->psTdmaDuAdjType = 3;
2410 else if(pCoexDm->curPsTdma == 2)
2412 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2413 pCoexDm->psTdmaDuAdjType = 3;
2415 else if(pCoexDm->curPsTdma == 12)
2417 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2418 pCoexDm->psTdmaDuAdjType = 11;
2420 else if(pCoexDm->curPsTdma == 11)
2422 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2423 pCoexDm->psTdmaDuAdjType = 11;
2425 else if(pCoexDm->curPsTdma == 10)
2427 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2428 pCoexDm->psTdmaDuAdjType = 11;
2435 // if current PsTdma not match with the recorded one (when scan, dhcp...),
2436 // then we have to adjust it back to the previous record one.
2437 if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)
2439 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
2440 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n",
2441 pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));
2443 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2444 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2445 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2447 if( !bScan && !bLink && !bRoam)
2449 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType);
2453 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
2458 // SCO only or SCO+PAN(HS)
2460 halbtc8723a2ant_ActionSco(
2461 IN PBTC_COEXIST pBtCoexist
2464 u1Byte wifiRssiState, wifiRssiState1;
2467 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2468 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
2470 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2471 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2473 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2474 if(BTC_WIFI_BW_HT40 == wifiBw)
2476 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2478 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2479 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2481 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2485 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2489 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2490 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2491 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2495 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2496 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2499 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2500 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2502 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2506 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2510 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2511 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2513 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
2514 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2515 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2519 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2520 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2521 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2528 halbtc8723a2ant_ActionHid(
2529 IN PBTC_COEXIST pBtCoexist
2532 u1Byte wifiRssiState, wifiRssiState1;
2535 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2536 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
2538 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2539 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2541 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2542 if(BTC_WIFI_BW_HT40 == wifiBw)
2544 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2546 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2547 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2549 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
2553 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
2557 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2558 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2559 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2563 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2564 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2567 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2568 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2570 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
2574 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
2578 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2579 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2581 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
2582 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2583 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2587 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2588 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2589 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2594 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
2596 halbtc8723a2ant_ActionA2dp(
2597 IN PBTC_COEXIST pBtCoexist
2600 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
2603 btInfoExt = pCoexSta->btInfoExt;
2605 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2606 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
2608 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2609 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2611 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2612 if(BTC_WIFI_BW_HT40 == wifiBw)
2614 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2617 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2618 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2620 if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
2622 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3);
2626 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);
2631 if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
2633 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, true, 3);
2637 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, true, 1);
2642 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2643 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2644 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2648 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2649 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2652 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2653 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2655 if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
2657 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3);
2661 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);
2666 if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
2668 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, true, 3);
2672 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, true, 1);
2677 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2678 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2680 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
2681 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2682 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2686 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2687 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2688 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2694 halbtc8723a2ant_ActionPanEdr(
2695 IN PBTC_COEXIST pBtCoexist
2698 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
2701 btInfoExt = pCoexSta->btInfoExt;
2703 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2704 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
2706 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2707 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2709 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2710 if(BTC_WIFI_BW_HT40 == wifiBw)
2712 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2715 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2716 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2718 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2722 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
2726 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2727 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2728 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2732 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2733 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2736 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2737 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2739 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2743 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
2747 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2748 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2750 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
2751 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2752 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2756 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2757 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2758 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2766 halbtc8723a2ant_ActionPanHs(
2767 IN PBTC_COEXIST pBtCoexist
2770 u1Byte wifiRssiState;
2773 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2775 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2776 if(BTC_WIFI_BW_HT40 == wifiBw)
2778 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2781 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2782 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2784 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
2788 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2790 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2793 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2794 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2795 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2799 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2802 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2803 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2805 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
2806 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2810 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2811 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2815 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2816 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2818 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
2819 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2820 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2824 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2825 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2826 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2833 halbtc8723a2ant_ActionPanEdrA2dp(
2834 IN PBTC_COEXIST pBtCoexist
2837 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
2840 btInfoExt = pCoexSta->btInfoExt;
2842 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2843 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
2845 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2846 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2848 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2849 if(BTC_WIFI_BW_HT40 == wifiBw)
2851 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2854 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2855 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2857 if(btInfoExt&BIT0) //a2dp basic rate
2859 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2861 else //a2dp edr rate
2863 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2868 if(btInfoExt&BIT0) //a2dp basic rate
2870 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2872 else //a2dp edr rate
2874 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
2879 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2880 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2881 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2885 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2886 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
2889 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2890 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2892 if(btInfoExt&BIT0) //a2dp basic rate
2894 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2896 else //a2dp edr rate
2898 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2903 if(btInfoExt&BIT0) //a2dp basic rate
2905 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2907 else //a2dp edr rate
2909 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
2914 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
2915 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
2917 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
2918 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2919 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2923 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2924 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2925 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2931 halbtc8723a2ant_ActionPanEdrHid(
2932 IN PBTC_COEXIST pBtCoexist
2935 u1Byte wifiRssiState, wifiRssiState1;
2938 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
2939 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
2941 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
2942 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
2944 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2945 if(BTC_WIFI_BW_HT40 == wifiBw)
2947 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
2950 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2951 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2953 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2957 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
2961 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2962 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2963 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2967 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
2968 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
2971 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2972 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2974 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2978 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
2982 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2983 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
2985 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
2986 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
2987 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2991 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
2992 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
2993 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
2998 // HID+A2DP+PAN(EDR)
3000 halbtc8723a2ant_ActionHidA2dpPanEdr(
3001 IN PBTC_COEXIST pBtCoexist
3004 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
3007 btInfoExt = pCoexSta->btInfoExt;
3009 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
3010 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
3012 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
3013 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
3015 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3016 if(BTC_WIFI_BW_HT40 == wifiBw)
3018 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
3021 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
3022 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3024 if(btInfoExt&BIT0) //a2dp basic rate
3026 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
3028 else //a2dp edr rate
3030 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
3035 if(btInfoExt&BIT0) //a2dp basic rate
3037 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
3039 else //a2dp edr rate
3041 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
3046 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
3047 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
3048 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3052 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
3053 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
3056 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
3057 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3059 if(btInfoExt&BIT0) //a2dp basic rate
3061 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
3063 else //a2dp edr rate
3065 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
3070 if(btInfoExt&BIT0) //a2dp basic rate
3072 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
3074 else //a2dp edr rate
3076 halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
3081 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
3082 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
3084 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
3085 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
3086 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3090 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
3091 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
3092 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3098 halbtc8723a2ant_ActionHidA2dp(
3099 IN PBTC_COEXIST pBtCoexist
3102 u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
3105 btInfoExt = pCoexSta->btInfoExt;
3107 if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
3108 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
3110 halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
3111 halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
3113 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3114 if(BTC_WIFI_BW_HT40 == wifiBw)
3116 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
3119 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
3120 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3122 if(btInfoExt&BIT0) //a2dp basic rate
3124 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, FALSE, 3);
3126 else //a2dp edr rate
3128 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, FALSE, 1);
3133 if(btInfoExt&BIT0) //a2dp basic rate
3135 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, true, 3);
3137 else //a2dp edr rate
3139 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, true, 1);
3144 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
3145 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
3146 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3150 wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
3151 wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
3154 if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
3155 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3157 if(btInfoExt&BIT0) //a2dp basic rate
3159 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, FALSE, 3);
3161 else //a2dp edr rate
3163 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, FALSE, 1);
3168 if(btInfoExt&BIT0) //a2dp basic rate
3170 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, true, 3);
3172 else //a2dp edr rate
3174 halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, true, 1);
3179 if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
3180 (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
3182 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
3183 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
3184 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3188 halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
3189 halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
3190 halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
3196 halbtc8723a2ant_RunCoexistMechanism(
3197 IN PBTC_COEXIST pBtCoexist
3200 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
3201 u1Byte btInfoOriginal=0, btRetryCnt=0;
3204 if(pBtCoexist->manual_control)
3206 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Manual control!!!\n"));
3210 if(pStackInfo->bProfileNotified)
3212 if(pCoexSta->bHoldForStackOperation)
3214 // if bt inquiry/page/pair, do not execute.
3218 algorithm = halbtc8723a2ant_ActionAlgorithm(pBtCoexist);
3219 if(pCoexSta->bHoldPeriodCnt && (BT_8723A_2ANT_COEX_ALGO_PANHS!=algorithm))
3221 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex],Hold BT inquiry/page scan setting (cnt = %d)!!\n",
3222 pCoexSta->bHoldPeriodCnt));
3223 if(pCoexSta->bHoldPeriodCnt >= 6)
3225 pCoexSta->bHoldPeriodCnt = 0;
3226 // next time the coexist parameters should be reset again.
3229 pCoexSta->bHoldPeriodCnt++;
3233 pCoexDm->curAlgorithm = algorithm;
3234 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm));
3235 if(halbtc8723a2ant_IsCommonAction(pBtCoexist))
3237 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant common.\n"));
3238 pCoexDm->bResetTdmaAdjust = true;
3242 if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm)
3244 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n",
3245 pCoexDm->preAlgorithm, pCoexDm->curAlgorithm));
3246 pCoexDm->bResetTdmaAdjust = true;
3248 switch(pCoexDm->curAlgorithm)
3250 case BT_8723A_2ANT_COEX_ALGO_SCO:
3251 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n"));
3252 halbtc8723a2ant_ActionSco(pBtCoexist);
3254 case BT_8723A_2ANT_COEX_ALGO_HID:
3255 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID.\n"));
3256 halbtc8723a2ant_ActionHid(pBtCoexist);
3258 case BT_8723A_2ANT_COEX_ALGO_A2DP:
3259 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n"));
3260 halbtc8723a2ant_ActionA2dp(pBtCoexist);
3262 case BT_8723A_2ANT_COEX_ALGO_PANEDR:
3263 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"));
3264 halbtc8723a2ant_ActionPanEdr(pBtCoexist);
3266 case BT_8723A_2ANT_COEX_ALGO_PANHS:
3267 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n"));
3268 halbtc8723a2ant_ActionPanHs(pBtCoexist);
3270 case BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP:
3271 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"));
3272 halbtc8723a2ant_ActionPanEdrA2dp(pBtCoexist);
3274 case BT_8723A_2ANT_COEX_ALGO_PANEDR_HID:
3275 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
3276 halbtc8723a2ant_ActionPanEdrHid(pBtCoexist);
3278 case BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
3279 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
3280 halbtc8723a2ant_ActionHidA2dpPanEdr(pBtCoexist);
3282 case BT_8723A_2ANT_COEX_ALGO_HID_A2DP:
3283 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"));
3284 halbtc8723a2ant_ActionHidA2dp(pBtCoexist);
3287 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"));
3288 halbtc8723a2ant_CoexAllOff(pBtCoexist);
3291 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
3296 //============================================================
3297 // work around function start with wa_halbtc8723a2ant_
3298 //============================================================
3300 wa_halbtc8723a2ant_MonitorC2h(
3301 IN PBTC_COEXIST pBtCoexist
3305 u4Byte curC2hTotalCnt=0x0;
3306 static u4Byte preC2hTotalCnt=0x0, sameCntPollingTime=0x0;
3308 curC2hTotalCnt+=pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8723A_2ANT_BT_RSP];
3310 if(curC2hTotalCnt == preC2hTotalCnt)
3312 sameCntPollingTime++;
3316 preC2hTotalCnt = curC2hTotalCnt;
3317 sameCntPollingTime = 0;
3320 if(sameCntPollingTime >= 2)
3322 tmp1b = pBtCoexist->btc_read_1byte(pBtCoexist, 0x1af);
3325 pCoexSta->c2hHangDetectCnt++;
3326 pBtCoexist->btc_write_1byte(pBtCoexist, 0x1af, 0x0);
3331 //============================================================
3332 // extern function start with EXhalbtc8723a2ant_
3333 //============================================================
3335 EXhalbtc8723a2ant_InitHwConfig(
3336 IN PBTC_COEXIST pBtCoexist
3342 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 2Ant Init HW Config!!\n"));
3344 // backup rf 0x1e value
3345 pCoexDm->btRf0x1eBackup =
3346 pBtCoexist->btc_get_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
3348 // Enable counter statistics
3349 pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0x4);
3350 pBtCoexist->btc_write_1byte(pBtCoexist, 0x778, 0x3);
3351 pBtCoexist->btc_write_1byte(pBtCoexist, 0x40, 0x20);
3355 EXhalbtc8723a2ant_InitCoexDm(
3356 IN PBTC_COEXIST pBtCoexist
3359 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
3361 halbtc8723a2ant_InitCoexDm(pBtCoexist);
3365 EXhalbtc8723a2ant_DisplayCoexInfo(
3366 IN PBTC_COEXIST pBtCoexist
3369 struct btc_board_info * pBoardInfo=&pBtCoexist->board_info;
3370 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
3371 pu1Byte cliBuf=pBtCoexist->cli_buf;
3372 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
3374 BOOLEAN bRoam=FALSE, bScan=FALSE, bLink=FALSE, bWifiUnder5G=FALSE;
3375 BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
3376 s4Byte wifiRssi=0, btHsRssi=0;
3377 u4Byte wifiBw, wifiTrafficDir;
3378 u1Byte wifiDot11Chnl, wifiHsChnl;
3380 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
3383 if(!pBoardInfo->bt_exist)
3385 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
3390 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
3391 pBoardInfo->pg_ant_num, pBoardInfo->btdm_ant_num);
3394 if(pBtCoexist->manual_control)
3396 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!");
3400 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
3401 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
3404 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3405 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
3406 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
3407 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
3408 wifiDot11Chnl, wifiHsChnl, bBtHsOn);
3411 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
3412 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
3413 pCoexDm->wifiChnlInfo[2]);
3416 pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
3417 pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
3418 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
3419 wifiRssi, btHsRssi);
3422 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
3423 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
3424 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
3425 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
3426 bLink, bRoam, bScan);
3429 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
3430 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3431 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
3432 pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
3433 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
3434 (bWifiUnder5G? "5G":"2.4G"),
3435 ((BTC_WIFI_BW_LEGACY==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40==wifiBw)? "HT40":"HT20"))),
3436 ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
3439 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
3440 ((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"))),
3441 pCoexSta->btRssi, pCoexSta->btRetryCnt);
3444 if(pStackInfo->bProfileNotified)
3446 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
3447 pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist);
3450 pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
3453 btInfoExt = pCoexSta->btInfoExt;
3454 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
3455 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
3458 for(i=0; i<BT_INFO_SRC_8723A_2ANT_MAX; i++)
3460 if(pCoexSta->btInfoC2hCnt[i])
3462 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723a2Ant[i], \
3463 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
3464 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
3465 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
3466 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
3471 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "write 0x1af=0x0 num", \
3472 pCoexSta->c2hHangDetectCnt);
3476 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
3478 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "SM1[ShRf/ LpRA/ LimDig]", \
3479 pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->limited_dig);
3481 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
3482 pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
3486 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
3489 if(!pBtCoexist->manual_control)
3491 psTdmaCase = pCoexDm->curPsTdma;
3492 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \
3493 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
3494 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
3495 pCoexDm->psTdmaPara[4], psTdmaCase);
3498 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
3499 pCoexDm->bCurDecBtPwr, pCoexDm->bCurIgnoreWlanAct);
3504 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
3507 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
3508 pCoexDm->btRf0x1eBackup);
3511 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x778);
3512 u1Tmp[1] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x783);
3513 u1Tmp[2] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x796);
3514 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \
3515 u1Tmp[0], u1Tmp[1], u1Tmp[2]);
3518 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x880);
3519 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x880", \
3523 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x40);
3524 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \
3528 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x550);
3529 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x522);
3530 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
3531 u4Tmp[0], u1Tmp[0]);
3534 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x484);
3535 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \
3539 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xc50);
3540 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
3544 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xda0);
3545 u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xda4);
3546 u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xda8);
3547 u4Tmp[3] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xdac);
3548 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xda0/0xda4/0xda8/0xdac(FA cnt)", \
3549 u4Tmp[0], u4Tmp[1], u4Tmp[2], u4Tmp[3]);
3552 u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c0);
3553 u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c4);
3554 u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c8);
3555 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x6cc);
3556 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
3557 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
3560 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770 (hp rx[31:16]/tx[15:0])", \
3561 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
3563 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
3564 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
3567 // Tx mgnt queue hang or not, 0x41b should = 0xf, ex: 0xd ==>hang
3568 u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x41b);
3569 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x41b (mgntQ hang chk == 0xf)", \
3573 pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
3578 EXhalbtc8723a2ant_IpsNotify(
3579 IN PBTC_COEXIST pBtCoexist,
3583 if(BTC_IPS_ENTER == type)
3585 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
3586 halbtc8723a2ant_CoexAllOff(pBtCoexist);
3588 else if(BTC_IPS_LEAVE == type)
3590 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
3591 //halbtc8723a2ant_InitCoexDm(pBtCoexist);
3596 EXhalbtc8723a2ant_LpsNotify(
3597 IN PBTC_COEXIST pBtCoexist,
3601 if(BTC_LPS_ENABLE == type)
3603 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
3605 else if(BTC_LPS_DISABLE == type)
3607 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
3612 EXhalbtc8723a2ant_ScanNotify(
3613 IN PBTC_COEXIST pBtCoexist,
3617 if(BTC_SCAN_START == type)
3619 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
3621 else if(BTC_SCAN_FINISH == type)
3623 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
3628 EXhalbtc8723a2ant_ConnectNotify(
3629 IN PBTC_COEXIST pBtCoexist,
3633 if(BTC_ASSOCIATE_START == type)
3635 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
3637 else if(BTC_ASSOCIATE_FINISH == type)
3639 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
3644 EXhalbtc8723a2ant_MediaStatusNotify(
3645 IN PBTC_COEXIST pBtCoexist,
3649 if(BTC_MEDIA_CONNECT == type)
3651 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
3655 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
3658 halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, type);
3662 EXhalbtc8723a2ant_SpecialPacketNotify(
3663 IN PBTC_COEXIST pBtCoexist,
3667 if(type == BTC_PACKET_DHCP)
3669 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
3674 EXhalbtc8723a2ant_BtInfoNotify(
3675 IN PBTC_COEXIST pBtCoexist,
3681 u1Byte i, rspSource=0;
3682 BOOLEAN bBtBusy=FALSE, limited_dig=FALSE;
3683 BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
3685 pCoexSta->bC2hBtInfoReqSent = FALSE;
3687 rspSource = BT_INFO_SRC_8723A_2ANT_BT_RSP;
3688 pCoexSta->btInfoC2hCnt[rspSource]++;
3690 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
3691 for(i=0; i<length; i++)
3693 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
3698 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
3702 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
3706 if(BT_INFO_SRC_8723A_2ANT_WIFI_FW != rspSource)
3708 pCoexSta->btRetryCnt =
3709 pCoexSta->btInfoC2h[rspSource][1];
3712 pCoexSta->btInfoC2h[rspSource][2]*2+10;
3714 pCoexSta->btInfoExt =
3715 pCoexSta->btInfoC2h[rspSource][3];
3718 pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3719 // check BIT2 first ==> check if bt is under inquiry or page scan
3720 if(btInfo & BT_INFO_8723A_2ANT_B_INQ_PAGE)
3722 pCoexSta->bC2hBtInquiryPage = true;
3726 pCoexSta->bC2hBtInquiryPage = FALSE;
3731 EXhalbtc8723a2ant_StackOperationNotify(
3732 IN PBTC_COEXIST pBtCoexist,
3736 if(BTC_STACK_OP_INQ_PAGE_PAIR_START == type)
3738 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair start notify\n"));
3739 pCoexSta->bHoldForStackOperation = true;
3740 pCoexSta->bHoldPeriodCnt = 1;
3741 halbtc8723a2ant_BtInquiryPage(pBtCoexist);
3743 else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
3745 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair finish notify\n"));
3746 pCoexSta->bHoldForStackOperation = FALSE;
3751 EXhalbtc8723a2ant_HaltNotify(
3752 IN PBTC_COEXIST pBtCoexist
3755 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
3757 halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
3758 EXhalbtc8723a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3762 EXhalbtc8723a2ant_Periodical(
3763 IN PBTC_COEXIST pBtCoexist
3766 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], 2Ant Periodical!!\n"));
3768 // work around for c2h hang
3769 wa_halbtc8723a2ant_MonitorC2h(pBtCoexist);
3771 halbtc8723a2ant_QueryBtInfo(pBtCoexist);
3772 halbtc8723a2ant_MonitorBtCtr(pBtCoexist);
3773 halbtc8723a2ant_MonitorBtEnableDisable(pBtCoexist);
3775 halbtc8723a2ant_RunCoexistMechanism(pBtCoexist);