1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
4 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
8 #include "Mp_Precomp.h"
10 /* Global variables, these are static variables */
11 static COEX_DM_8723B_2ANT GLCoexDm8723b2Ant;
12 static PCOEX_DM_8723B_2ANT pCoexDm = &GLCoexDm8723b2Ant;
13 static COEX_STA_8723B_2ANT GLCoexSta8723b2Ant;
14 static PCOEX_STA_8723B_2ANT pCoexSta = &GLCoexSta8723b2Ant;
16 static const char *const GLBtInfoSrc8723b2Ant[] = {
19 "BT Info[bt auto report]",
22 static u32 GLCoexVerDate8723b2Ant = 20131211;
23 static u32 GLCoexVer8723b2Ant = 0x40;
25 /* local function start with halbtc8723b2ant_ */
26 static u8 halbtc8723b2ant_BtRssiState(
27 u8 levelNum, u8 rssiThresh, u8 rssiThresh1
31 u8 btRssiState = pCoexSta->preBtRssiState;
33 btRssi = pCoexSta->btRssi;
37 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
38 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
40 if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
41 btRssiState = BTC_RSSI_STATE_HIGH;
42 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
44 btRssiState = BTC_RSSI_STATE_STAY_LOW;
45 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
48 if (btRssi < rssiThresh) {
49 btRssiState = BTC_RSSI_STATE_LOW;
50 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
52 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
53 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
56 } else if (levelNum == 3) {
57 if (rssiThresh > rssiThresh1) {
58 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
59 return pCoexSta->preBtRssiState;
63 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
64 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
66 if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
67 btRssiState = BTC_RSSI_STATE_MEDIUM;
68 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
70 btRssiState = BTC_RSSI_STATE_STAY_LOW;
71 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
74 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
75 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)
77 if (btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
78 btRssiState = BTC_RSSI_STATE_HIGH;
79 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
80 } else if (btRssi < rssiThresh) {
81 btRssiState = BTC_RSSI_STATE_LOW;
82 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
84 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
85 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
88 if (btRssi < rssiThresh1) {
89 btRssiState = BTC_RSSI_STATE_MEDIUM;
90 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
92 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
93 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
98 pCoexSta->preBtRssiState = btRssiState;
103 static u8 halbtc8723b2ant_WifiRssiState(
104 PBTC_COEXIST pBtCoexist,
112 u8 wifiRssiState = pCoexSta->preWifiRssiState[index];
114 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
118 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
119 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
121 if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
122 wifiRssiState = BTC_RSSI_STATE_HIGH;
123 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
125 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
126 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
129 if (wifiRssi < rssiThresh) {
130 wifiRssiState = BTC_RSSI_STATE_LOW;
131 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
133 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
134 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
137 } else if (levelNum == 3) {
138 if (rssiThresh > rssiThresh1) {
139 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
140 return pCoexSta->preWifiRssiState[index];
144 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
145 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
147 if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
148 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
149 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
151 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
152 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
155 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
156 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)
158 if (wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
159 wifiRssiState = BTC_RSSI_STATE_HIGH;
160 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
161 } else if (wifiRssi < rssiThresh) {
162 wifiRssiState = BTC_RSSI_STATE_LOW;
163 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
165 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
166 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
169 if (wifiRssi < rssiThresh1) {
170 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
171 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
173 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
174 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
179 pCoexSta->preWifiRssiState[index] = wifiRssiState;
181 return wifiRssiState;
184 static void halbtc8723b2ant_LimitedRx(
185 PBTC_COEXIST pBtCoexist,
188 bool bBtCtrlAggBufSize,
192 bool bRejectRxAgg = bRejApAggPkt;
193 bool bBtCtrlRxAggSize = bBtCtrlAggBufSize;
194 u8 rxAggSize = aggBufSize;
197 /* Rx Aggregation related setting */
199 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);
200 /* decide BT control aggregation buf size or not */
201 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);
202 /* aggregation buf size, only work when BT control Rx aggregation size. */
203 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
204 /* real update aggregation setting */
205 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
208 static void halbtc8723b2ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
210 u32 regHPTxRx, regLPTxRx, u4Tmp;
211 u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0;
216 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
217 regHPTx = u4Tmp & bMaskLWord;
218 regHPRx = (u4Tmp & bMaskHWord)>>16;
220 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
221 regLPTx = u4Tmp & bMaskLWord;
222 regLPRx = (u4Tmp & bMaskHWord)>>16;
224 pCoexSta->highPriorityTx = regHPTx;
225 pCoexSta->highPriorityRx = regHPRx;
226 pCoexSta->lowPriorityTx = regLPTx;
227 pCoexSta->lowPriorityRx = regLPRx;
233 "[BTCoex], High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
245 "[BTCoex], Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
255 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
258 static void halbtc8723b2ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
260 u8 H2C_Parameter[1] = {0};
262 pCoexSta->bC2hBtInfoReqSent = true;
264 H2C_Parameter[0] |= BIT0; /* trigger */
269 ("[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", H2C_Parameter[0])
272 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
275 static bool halbtc8723b2ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
277 static bool bPreWifiBusy, bPreUnder4way, bPreBtHsOn;
278 bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false;
279 bool bWifiConnected = false;
281 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
282 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
283 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
284 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
286 if (bWifiConnected) {
287 if (bWifiBusy != bPreWifiBusy) {
288 bPreWifiBusy = bWifiBusy;
292 if (bUnder4way != bPreUnder4way) {
293 bPreUnder4way = bUnder4way;
297 if (bBtHsOn != bPreBtHsOn) {
298 bPreBtHsOn = bBtHsOn;
306 static void halbtc8723b2ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
308 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
309 bool bBtHsOn = false;
311 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
313 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
314 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
315 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
316 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
317 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
319 /* work around for HS mode. */
321 pBtLinkInfo->bPanExist = true;
322 pBtLinkInfo->bBtLinkExist = true;
325 /* check if Sco only */
327 pBtLinkInfo->bScoExist &&
328 !pBtLinkInfo->bA2dpExist &&
329 !pBtLinkInfo->bPanExist &&
330 !pBtLinkInfo->bHidExist
332 pBtLinkInfo->bScoOnly = true;
334 pBtLinkInfo->bScoOnly = false;
336 /* check if A2dp only */
338 !pBtLinkInfo->bScoExist &&
339 pBtLinkInfo->bA2dpExist &&
340 !pBtLinkInfo->bPanExist &&
341 !pBtLinkInfo->bHidExist
343 pBtLinkInfo->bA2dpOnly = true;
345 pBtLinkInfo->bA2dpOnly = false;
347 /* check if Pan only */
349 !pBtLinkInfo->bScoExist &&
350 !pBtLinkInfo->bA2dpExist &&
351 pBtLinkInfo->bPanExist &&
352 !pBtLinkInfo->bHidExist
354 pBtLinkInfo->bPanOnly = true;
356 pBtLinkInfo->bPanOnly = false;
358 /* check if Hid only */
360 !pBtLinkInfo->bScoExist &&
361 !pBtLinkInfo->bA2dpExist &&
362 !pBtLinkInfo->bPanExist &&
363 pBtLinkInfo->bHidExist
365 pBtLinkInfo->bHidOnly = true;
367 pBtLinkInfo->bHidOnly = false;
370 static u8 halbtc8723b2ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
372 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
373 bool bBtHsOn = false;
374 u8 algorithm = BT_8723B_2ANT_COEX_ALGO_UNDEFINED;
375 u8 numOfDiffProfile = 0;
377 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
379 if (!pBtLinkInfo->bBtLinkExist) {
380 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n"));
384 if (pBtLinkInfo->bScoExist)
387 if (pBtLinkInfo->bHidExist)
390 if (pBtLinkInfo->bPanExist)
393 if (pBtLinkInfo->bA2dpExist)
396 if (numOfDiffProfile == 1) {
397 if (pBtLinkInfo->bScoExist) {
398 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n"));
399 algorithm = BT_8723B_2ANT_COEX_ALGO_SCO;
401 if (pBtLinkInfo->bHidExist) {
402 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
403 algorithm = BT_8723B_2ANT_COEX_ALGO_HID;
404 } else if (pBtLinkInfo->bA2dpExist) {
405 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
406 algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP;
407 } else if (pBtLinkInfo->bPanExist) {
409 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
410 algorithm = BT_8723B_2ANT_COEX_ALGO_PANHS;
412 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
413 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR;
417 } else if (numOfDiffProfile == 2) {
418 if (pBtLinkInfo->bScoExist) {
419 if (pBtLinkInfo->bHidExist) {
420 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n"));
421 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
422 } else if (pBtLinkInfo->bA2dpExist) {
423 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n"));
424 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
425 } else if (pBtLinkInfo->bPanExist) {
427 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
428 algorithm = BT_8723B_2ANT_COEX_ALGO_SCO;
430 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
431 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
436 pBtLinkInfo->bHidExist &&
437 pBtLinkInfo->bA2dpExist
439 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
440 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
442 pBtLinkInfo->bHidExist &&
443 pBtLinkInfo->bPanExist
446 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
447 algorithm = BT_8723B_2ANT_COEX_ALGO_HID;
449 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
450 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
453 pBtLinkInfo->bPanExist &&
454 pBtLinkInfo->bA2dpExist
457 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
458 algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS;
460 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
461 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP;
465 } else if (numOfDiffProfile == 3) {
466 if (pBtLinkInfo->bScoExist) {
468 pBtLinkInfo->bHidExist &&
469 pBtLinkInfo->bA2dpExist
474 ("[BTCoex], SCO + HID + A2DP ==> HID\n")
476 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
478 pBtLinkInfo->bHidExist &&
479 pBtLinkInfo->bPanExist
485 ("[BTCoex], SCO + HID + PAN(HS)\n")
487 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
492 ("[BTCoex], SCO + HID + PAN(EDR)\n")
494 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
497 pBtLinkInfo->bPanExist &&
498 pBtLinkInfo->bA2dpExist
501 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
502 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
504 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
505 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
510 pBtLinkInfo->bHidExist &&
511 pBtLinkInfo->bPanExist &&
512 pBtLinkInfo->bA2dpExist
515 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
516 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
518 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
519 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
523 } else if (numOfDiffProfile >= 3) {
524 if (pBtLinkInfo->bScoExist) {
526 pBtLinkInfo->bHidExist &&
527 pBtLinkInfo->bPanExist &&
528 pBtLinkInfo->bA2dpExist
531 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
534 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n"));
535 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
544 static void halbtc8723b2ant_SetFwDacSwingLevel(
545 PBTC_COEXIST pBtCoexist, u8 dacSwingLvl
548 u8 H2C_Parameter[1] = {0};
550 /* There are several type of dacswing */
551 /* 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */
552 H2C_Parameter[0] = dacSwingLvl;
557 ("[BTCoex], Set Dac Swing Level = 0x%x\n", dacSwingLvl)
562 ("[BTCoex], FW write 0x64 = 0x%x\n", H2C_Parameter[0])
565 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter);
568 static void halbtc8723b2ant_SetFwDecBtPwr(
569 PBTC_COEXIST pBtCoexist, u8 decBtPwrLvl
572 u8 H2C_Parameter[1] = {0};
574 H2C_Parameter[0] = decBtPwrLvl;
580 "[BTCoex], decrease Bt Power level = %d, FW write 0x62 = 0x%x\n",
586 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter);
589 static void halbtc8723b2ant_DecBtPwr(
590 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 decBtPwrLvl
597 "[BTCoex], %s Dec BT power level = %d\n",
598 (bForceExec ? "force to" : ""),
602 pCoexDm->curBtDecPwrLvl = decBtPwrLvl;
607 ALGO_TRACE_FW_DETAIL,
609 "[BTCoex], preBtDecPwrLvl =%d, curBtDecPwrLvl =%d\n",
610 pCoexDm->preBtDecPwrLvl,
611 pCoexDm->curBtDecPwrLvl
615 if (pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl)
618 halbtc8723b2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
620 pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
623 static void halbtc8723b2ant_FwDacSwingLvl(
624 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 fwDacSwingLvl
631 "[BTCoex], %s set FW Dac Swing level = %d\n",
632 (bForceExec ? "force to" : ""),
636 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
641 ALGO_TRACE_FW_DETAIL,
643 "[BTCoex], preFwDacSwingLvl =%d, curFwDacSwingLvl =%d\n",
644 pCoexDm->preFwDacSwingLvl,
645 pCoexDm->curFwDacSwingLvl
649 if (pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
653 halbtc8723b2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
655 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
658 static void halbtc8723b2ant_SetSwRfRxLpfCorner(
659 PBTC_COEXIST pBtCoexist,
664 /* Shrink RF Rx LPF corner */
668 ("[BTCoex], Shrink RF Rx LPF corner!!\n")
670 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc);
672 /* Resume RF Rx LPF corner */
673 /* After initialized, we can use pCoexDm->btRf0x1eBackup */
674 if (pBtCoexist->bInitilized) {
675 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
676 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
681 static void halbtc8723b2ant_RfShrink(
682 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bRxRfShrinkOn
689 "[BTCoex], %s turn Rx RF Shrink = %s\n",
690 (bForceExec ? "force to" : ""),
691 (bRxRfShrinkOn ? "ON" : "OFF")
694 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
699 ALGO_TRACE_SW_DETAIL,
701 "[BTCoex], bPreRfRxLpfShrink =%d, bCurRfRxLpfShrink =%d\n",
702 pCoexDm->bPreRfRxLpfShrink,
703 pCoexDm->bCurRfRxLpfShrink
707 if (pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
710 halbtc8723b2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
712 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
715 static void halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(
716 PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa
719 u8 H2C_Parameter[6] = {0};
721 H2C_Parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */
724 H2C_Parameter[1] |= BIT0;
725 H2C_Parameter[2] = 0x00; /* normal rate except MCS7/6/5, OFDM54/48/36 */
726 H2C_Parameter[3] = 0xf7; /* MCS7 or OFDM54 */
727 H2C_Parameter[4] = 0xf8; /* MCS6 or OFDM48 */
728 H2C_Parameter[5] = 0xf9; /* MCS5 or OFDM36 */
735 "[BTCoex], set WiFi Low-Penalty Retry: %s",
736 (bLowPenaltyRa ? "ON!!" : "OFF!!")
740 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
743 static void halbtc8723b2ant_LowPenaltyRa(
744 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa
752 "[BTCoex], %s turn LowPenaltyRA = %s\n",
753 (bForceExec ? "force to" : ""),
754 (bLowPenaltyRa ? "ON" : "OFF")
757 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
762 ALGO_TRACE_SW_DETAIL,
764 "[BTCoex], bPreLowPenaltyRa =%d, bCurLowPenaltyRa =%d\n",
765 pCoexDm->bPreLowPenaltyRa,
766 pCoexDm->bCurLowPenaltyRa
770 if (pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
773 halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
775 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
778 static void halbtc8723b2ant_SetDacSwingReg(PBTC_COEXIST pBtCoexist, u32 level)
785 ("[BTCoex], Write SwDacSwing = 0x%x\n", level)
787 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val);
790 static void halbtc8723b2ant_SetSwFullTimeDacSwing(
791 PBTC_COEXIST pBtCoexist, bool bSwDacSwingOn, u32 swDacSwingLvl
795 halbtc8723b2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
797 halbtc8723b2ant_SetDacSwingReg(pBtCoexist, 0x18);
801 static void halbtc8723b2ant_DacSwing(
802 PBTC_COEXIST pBtCoexist,
812 "[BTCoex], %s turn DacSwing =%s, dacSwingLvl = 0x%x\n",
813 (bForceExec ? "force to" : ""),
814 (bDacSwingOn ? "ON" : "OFF"),
818 pCoexDm->bCurDacSwingOn = bDacSwingOn;
819 pCoexDm->curDacSwingLvl = dacSwingLvl;
824 ALGO_TRACE_SW_DETAIL,
826 "[BTCoex], bPreDacSwingOn =%d, preDacSwingLvl = 0x%x, bCurDacSwingOn =%d, curDacSwingLvl = 0x%x\n",
827 pCoexDm->bPreDacSwingOn,
828 pCoexDm->preDacSwingLvl,
829 pCoexDm->bCurDacSwingOn,
830 pCoexDm->curDacSwingLvl
834 if ((pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
835 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl))
839 halbtc8723b2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
841 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
842 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
845 static void halbtc8723b2ant_SetAgcTable(
846 PBTC_COEXIST pBtCoexist, bool bAgcTableEn
849 u8 rssiAdjustVal = 0;
851 /* BB AGC Gain Table */
853 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB Agc Table On!\n"));
854 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e1A0001);
855 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d1B0001);
856 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6c1C0001);
857 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6b1D0001);
858 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1E0001);
859 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691F0001);
860 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68200001);
862 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB Agc Table Off!\n"));
863 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001);
864 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001);
865 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001);
866 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001);
867 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001);
868 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001);
869 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa4200001);
874 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
876 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
877 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff);
878 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe);
880 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
881 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3);
882 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6);
884 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
886 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1);
888 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
889 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff);
890 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe);
892 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
893 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3);
894 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6);
896 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0);
898 /* set rssiAdjustVal for wifi module. */
902 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
905 static void halbtc8723b2ant_AgcTable(
906 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bAgcTableEn
913 "[BTCoex], %s %s Agc Table\n",
914 (bForceExec ? "force to" : ""),
915 (bAgcTableEn ? "Enable" : "Disable")
918 pCoexDm->bCurAgcTableEn = bAgcTableEn;
923 ALGO_TRACE_SW_DETAIL,
925 "[BTCoex], bPreAgcTableEn =%d, bCurAgcTableEn =%d\n",
926 pCoexDm->bPreAgcTableEn,
927 pCoexDm->bCurAgcTableEn
931 if (pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
934 halbtc8723b2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
936 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
939 static void halbtc8723b2ant_SetCoexTable(
940 PBTC_COEXIST pBtCoexist,
950 ("[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0)
952 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
957 ("[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4)
959 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
964 ("[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8)
966 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
971 ("[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc)
973 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
976 static void halbtc8723b2ant_CoexTable(
977 PBTC_COEXIST pBtCoexist,
989 "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n",
990 (bForceExec ? "force to" : ""),
997 pCoexDm->curVal0x6c0 = val0x6c0;
998 pCoexDm->curVal0x6c4 = val0x6c4;
999 pCoexDm->curVal0x6c8 = val0x6c8;
1000 pCoexDm->curVal0x6cc = val0x6cc;
1005 ALGO_TRACE_SW_DETAIL,
1007 "[BTCoex], preVal0x6c0 = 0x%x, preVal0x6c4 = 0x%x, preVal0x6c8 = 0x%x, preVal0x6cc = 0x%x !!\n",
1008 pCoexDm->preVal0x6c0,
1009 pCoexDm->preVal0x6c4,
1010 pCoexDm->preVal0x6c8,
1011 pCoexDm->preVal0x6cc
1016 ALGO_TRACE_SW_DETAIL,
1018 "[BTCoex], curVal0x6c0 = 0x%x, curVal0x6c4 = 0x%x, curVal0x6c8 = 0x%x, curVal0x6cc = 0x%x !!\n",
1019 pCoexDm->curVal0x6c0,
1020 pCoexDm->curVal0x6c4,
1021 pCoexDm->curVal0x6c8,
1022 pCoexDm->curVal0x6cc
1027 (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
1028 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
1029 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
1030 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc)
1034 halbtc8723b2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
1036 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
1037 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
1038 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
1039 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
1042 static void halbtc8723b2ant_CoexTableWithType(
1043 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
1048 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffff, 0x3);
1051 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
1054 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3);
1057 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff, 0x3);
1060 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffff, 0x3);
1063 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffff, 0x3);
1066 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3);
1069 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0xfafafafa, 0xffff, 0x3);
1072 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3);
1075 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aea5aea, 0xffff, 0x3);
1078 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aff5aff, 0xffff, 0x3);
1081 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5f5a5f, 0xffff, 0x3);
1084 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5f5f5f5f, 0xffff, 0x3);
1091 static void halbtc8723b2ant_SetFwIgnoreWlanAct(
1092 PBTC_COEXIST pBtCoexist, bool bEnable
1095 u8 H2C_Parameter[1] = {0};
1098 H2C_Parameter[0] |= BIT0; /* function enable */
1104 "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n",
1109 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
1112 static void halbtc8723b2ant_IgnoreWlanAct(
1113 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable
1120 "[BTCoex], %s turn Ignore WlanAct %s\n",
1121 (bForceExec ? "force to" : ""),
1122 (bEnable ? "ON" : "OFF")
1126 pCoexDm->bCurIgnoreWlanAct = bEnable;
1129 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
1130 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
1132 if (pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
1135 halbtc8723b2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
1137 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
1140 static void halbtc8723b2ant_SetFwPstdma(
1141 PBTC_COEXIST pBtCoexist,
1149 u8 H2C_Parameter[5] = {0};
1151 H2C_Parameter[0] = byte1;
1152 H2C_Parameter[1] = byte2;
1153 H2C_Parameter[2] = byte3;
1154 H2C_Parameter[3] = byte4;
1155 H2C_Parameter[4] = byte5;
1157 pCoexDm->psTdmaPara[0] = byte1;
1158 pCoexDm->psTdmaPara[1] = byte2;
1159 pCoexDm->psTdmaPara[2] = byte3;
1160 pCoexDm->psTdmaPara[3] = byte4;
1161 pCoexDm->psTdmaPara[4] = byte5;
1167 "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n",
1169 H2C_Parameter[1]<<24|
1170 H2C_Parameter[2]<<16|
1171 H2C_Parameter[3]<<8|
1176 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
1179 static void halbtc8723b2ant_SwMechanism1(
1180 PBTC_COEXIST pBtCoexist,
1184 bool bBTLNAConstrain
1187 halbtc8723b2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);
1188 halbtc8723b2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
1191 static void halbtc8723b2ant_SwMechanism2(
1192 PBTC_COEXIST pBtCoexist,
1193 bool bAGCTableShift,
1199 halbtc8723b2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);
1200 halbtc8723b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);
1203 static void halbtc8723b2ant_SetAntPath(
1204 PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
1207 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
1208 u32 fwVer = 0, u4Tmp = 0;
1209 bool bPgExtSwitch = false;
1210 bool bUseExtSwitch = false;
1211 u8 H2C_Parameter[2] = {0};
1213 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch);
1214 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); /* [31:16]=fw ver, [15:0]=fw sub ver */
1216 if ((fwVer > 0 && fwVer < 0xc0000) || bPgExtSwitch)
1217 bUseExtSwitch = true;
1220 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1);
1221 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff);
1222 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3);
1223 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77);
1224 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1);
1226 if (fwVer >= 0x180000) {
1227 /* Use H2C to set GNT_BT to LOW */
1228 H2C_Parameter[0] = 0;
1229 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
1231 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0);
1234 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
1236 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); /* WiFi TRx Mask off */
1237 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); /* BT TRx Mask off */
1239 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) {
1240 /* tell firmware "no antenna inverse" */
1241 H2C_Parameter[0] = 0;
1243 /* tell firmware "antenna inverse" */
1244 H2C_Parameter[0] = 1;
1247 if (bUseExtSwitch) {
1248 /* ext switch type */
1249 H2C_Parameter[1] = 1;
1251 /* int switch type */
1252 H2C_Parameter[1] = 0;
1254 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
1257 /* ext switch setting */
1258 if (bUseExtSwitch) {
1260 /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */
1261 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1264 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1267 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */
1268 switch (antPosType) {
1269 case BTC_ANT_WIFI_AT_MAIN:
1270 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); /* ext switch main at wifi */
1272 case BTC_ANT_WIFI_AT_AUX:
1273 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); /* ext switch aux at wifi */
1276 } else { /* internal switch */
1278 /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */
1279 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1282 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1285 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); /* fixed external switch S1->Main, S0->Aux */
1286 switch (antPosType) {
1287 case BTC_ANT_WIFI_AT_MAIN:
1288 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */
1290 case BTC_ANT_WIFI_AT_AUX:
1291 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); /* fixed internal switch S0->WiFi, S1->BT */
1297 static void halbtc8723b2ant_PsTdma(
1298 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
1305 "[BTCoex], %s turn %s PS TDMA, type =%d\n",
1306 (bForceExec ? "force to" : ""),
1307 (bTurnOn ? "ON" : "OFF"),
1311 pCoexDm->bCurPsTdmaOn = bTurnOn;
1312 pCoexDm->curPsTdma = type;
1317 ALGO_TRACE_FW_DETAIL,
1319 "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
1320 pCoexDm->bPrePsTdmaOn,
1321 pCoexDm->bCurPsTdmaOn
1326 ALGO_TRACE_FW_DETAIL,
1328 "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
1329 pCoexDm->prePsTdma, pCoexDm->curPsTdma
1334 (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
1335 (pCoexDm->prePsTdma == pCoexDm->curPsTdma)
1344 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1347 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
1350 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);
1353 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90);
1356 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
1359 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
1362 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);
1365 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90);
1368 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1371 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
1374 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90);
1377 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
1380 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
1383 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
1386 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90);
1389 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90);
1392 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90);
1395 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
1398 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90);
1401 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90);
1404 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);
1407 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1411 /* disable PS tdma */
1414 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
1417 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0);
1420 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
1425 /* update pre state */
1426 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1427 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1430 static void halbtc8723b2ant_CoexAllOff(PBTC_COEXIST pBtCoexist)
1433 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1434 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1435 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1438 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1439 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1442 /* pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); */
1443 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1446 static void halbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
1448 /* force to reset coex mechanism */
1450 halbtc8723b2ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 1);
1451 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
1452 halbtc8723b2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
1454 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1455 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1458 static void halbtc8723b2ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
1460 bool bWifiConnected = false;
1461 bool bLowPwrDisable = true;
1463 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1464 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1466 if (bWifiConnected) {
1467 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1468 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1470 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1471 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1474 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
1475 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1477 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1478 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1480 pCoexDm->bNeedRecover0x948 = true;
1481 pCoexDm->backup0x948 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
1483 halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, false, false);
1486 static bool halbtc8723b2ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
1488 u8 btRssiState = BTC_RSSI_STATE_HIGH;
1489 bool bCommon = false, bWifiConnected = false, bWifiBusy = false;
1490 bool bBtHsOn = false, bLowPwrDisable = false;
1492 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
1493 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1494 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
1496 if (!bWifiConnected) {
1497 bLowPwrDisable = false;
1498 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1499 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1501 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non-connected idle!!\n"));
1503 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1504 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1505 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1506 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1507 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1509 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1510 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1514 if (BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) {
1515 bLowPwrDisable = false;
1516 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1517 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1519 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
1521 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1522 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1523 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1524 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
1525 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1527 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1528 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1531 } else if (BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) {
1532 bLowPwrDisable = true;
1533 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1538 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
1539 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1541 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1542 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1543 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1544 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
1545 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1547 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1548 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1552 bLowPwrDisable = true;
1553 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1556 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
1562 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));
1563 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1564 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1566 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1567 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1568 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 21);
1569 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
1571 if (BTC_RSSI_HIGH(btRssiState))
1572 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1574 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1576 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1577 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1586 static void halbtc8723b2ant_TdmaDurationAdjust(
1587 PBTC_COEXIST pBtCoexist, bool bScoHid, bool bTxPause, u8 maxInterval
1590 static s32 up, dn, m, n, WaitCount;
1591 s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */
1594 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjust()\n"));
1596 if (!pCoexDm->bAutoTdmaAdjust) {
1597 pCoexDm->bAutoTdmaAdjust = true;
1598 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
1602 if (maxInterval == 1) {
1603 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1604 pCoexDm->psTdmaDuAdjType = 13;
1605 } else if (maxInterval == 2) {
1606 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1607 pCoexDm->psTdmaDuAdjType = 14;
1608 } else if (maxInterval == 3) {
1609 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1610 pCoexDm->psTdmaDuAdjType = 15;
1612 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1613 pCoexDm->psTdmaDuAdjType = 15;
1616 if (maxInterval == 1) {
1617 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1618 pCoexDm->psTdmaDuAdjType = 9;
1619 } else if (maxInterval == 2) {
1620 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1621 pCoexDm->psTdmaDuAdjType = 10;
1622 } else if (maxInterval == 3) {
1623 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1624 pCoexDm->psTdmaDuAdjType = 11;
1626 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1627 pCoexDm->psTdmaDuAdjType = 11;
1632 if (maxInterval == 1) {
1633 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1634 pCoexDm->psTdmaDuAdjType = 5;
1635 } else if (maxInterval == 2) {
1636 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1637 pCoexDm->psTdmaDuAdjType = 6;
1638 } else if (maxInterval == 3) {
1639 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1640 pCoexDm->psTdmaDuAdjType = 7;
1642 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1643 pCoexDm->psTdmaDuAdjType = 7;
1646 if (maxInterval == 1) {
1647 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1648 pCoexDm->psTdmaDuAdjType = 1;
1649 } else if (maxInterval == 2) {
1650 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1651 pCoexDm->psTdmaDuAdjType = 2;
1652 } else if (maxInterval == 3) {
1653 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1654 pCoexDm->psTdmaDuAdjType = 3;
1656 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1657 pCoexDm->psTdmaDuAdjType = 3;
1670 /* accquire the BT TRx retry count from BT_Info byte2 */
1671 retryCount = pCoexSta->btRetryCnt;
1672 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
1675 ALGO_TRACE_FW_DETAIL,
1677 "[BTCoex], up =%d, dn =%d, m =%d, n =%d, WaitCount =%d\n",
1678 up, dn, m, n, WaitCount
1684 if (retryCount == 0) { /* no retry in the last 2-second duration */
1691 if (up >= n) { /* if 連續 n 個2秒 retry count為0, 則調寬WiFi duration */
1697 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
1699 } else if (retryCount <= 3) { /* <=3 retry in the last 2-second duration */
1706 if (dn == 2) { /* if 連續 2 個2秒 retry count< 3, 則調窄WiFi duration */
1708 m++; /* 避免一直在兩個level中來回 */
1712 if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
1720 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
1722 } else { /* retry count > 3, 只要1次 retry count > 3, 則調窄WiFi duration */
1724 m++; /* 避免一直在兩個level中來回 */
1728 if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
1736 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
1739 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], max Interval = %d\n", maxInterval));
1740 if (maxInterval == 1) {
1742 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
1744 if (pCoexDm->curPsTdma == 71) {
1745 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1746 pCoexDm->psTdmaDuAdjType = 5;
1747 } else if (pCoexDm->curPsTdma == 1) {
1748 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1749 pCoexDm->psTdmaDuAdjType = 5;
1750 } else if (pCoexDm->curPsTdma == 2) {
1751 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1752 pCoexDm->psTdmaDuAdjType = 6;
1753 } else if (pCoexDm->curPsTdma == 3) {
1754 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1755 pCoexDm->psTdmaDuAdjType = 7;
1756 } else if (pCoexDm->curPsTdma == 4) {
1757 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1758 pCoexDm->psTdmaDuAdjType = 8;
1761 if (pCoexDm->curPsTdma == 9) {
1762 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1763 pCoexDm->psTdmaDuAdjType = 13;
1764 } else if (pCoexDm->curPsTdma == 10) {
1765 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1766 pCoexDm->psTdmaDuAdjType = 14;
1767 } else if (pCoexDm->curPsTdma == 11) {
1768 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1769 pCoexDm->psTdmaDuAdjType = 15;
1770 } else if (pCoexDm->curPsTdma == 12) {
1771 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1772 pCoexDm->psTdmaDuAdjType = 16;
1776 if (pCoexDm->curPsTdma == 5) {
1777 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1778 pCoexDm->psTdmaDuAdjType = 6;
1779 } else if (pCoexDm->curPsTdma == 6) {
1780 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1781 pCoexDm->psTdmaDuAdjType = 7;
1782 } else if (pCoexDm->curPsTdma == 7) {
1783 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1784 pCoexDm->psTdmaDuAdjType = 8;
1785 } else if (pCoexDm->curPsTdma == 13) {
1786 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1787 pCoexDm->psTdmaDuAdjType = 14;
1788 } else if (pCoexDm->curPsTdma == 14) {
1789 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1790 pCoexDm->psTdmaDuAdjType = 15;
1791 } else if (pCoexDm->curPsTdma == 15) {
1792 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1793 pCoexDm->psTdmaDuAdjType = 16;
1795 } else if (result == 1) {
1796 if (pCoexDm->curPsTdma == 8) {
1797 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1798 pCoexDm->psTdmaDuAdjType = 7;
1799 } else if (pCoexDm->curPsTdma == 7) {
1800 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1801 pCoexDm->psTdmaDuAdjType = 6;
1802 } else if (pCoexDm->curPsTdma == 6) {
1803 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1804 pCoexDm->psTdmaDuAdjType = 5;
1805 } else if (pCoexDm->curPsTdma == 16) {
1806 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1807 pCoexDm->psTdmaDuAdjType = 15;
1808 } else if (pCoexDm->curPsTdma == 15) {
1809 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1810 pCoexDm->psTdmaDuAdjType = 14;
1811 } else if (pCoexDm->curPsTdma == 14) {
1812 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1813 pCoexDm->psTdmaDuAdjType = 13;
1817 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
1818 if (pCoexDm->curPsTdma == 5) {
1819 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 71);
1820 pCoexDm->psTdmaDuAdjType = 71;
1821 } else if (pCoexDm->curPsTdma == 6) {
1822 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1823 pCoexDm->psTdmaDuAdjType = 2;
1824 } else if (pCoexDm->curPsTdma == 7) {
1825 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1826 pCoexDm->psTdmaDuAdjType = 3;
1827 } else if (pCoexDm->curPsTdma == 8) {
1828 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
1829 pCoexDm->psTdmaDuAdjType = 4;
1832 if (pCoexDm->curPsTdma == 13) {
1833 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1834 pCoexDm->psTdmaDuAdjType = 9;
1835 } else if (pCoexDm->curPsTdma == 14) {
1836 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1837 pCoexDm->psTdmaDuAdjType = 10;
1838 } else if (pCoexDm->curPsTdma == 15) {
1839 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1840 pCoexDm->psTdmaDuAdjType = 11;
1841 } else if (pCoexDm->curPsTdma == 16) {
1842 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
1843 pCoexDm->psTdmaDuAdjType = 12;
1847 if (pCoexDm->curPsTdma == 71) {
1848 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1849 pCoexDm->psTdmaDuAdjType = 1;
1850 } else if (pCoexDm->curPsTdma == 1) {
1851 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1852 pCoexDm->psTdmaDuAdjType = 2;
1853 } else if (pCoexDm->curPsTdma == 2) {
1854 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1855 pCoexDm->psTdmaDuAdjType = 3;
1856 } else if (pCoexDm->curPsTdma == 3) {
1857 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
1858 pCoexDm->psTdmaDuAdjType = 4;
1859 } else if (pCoexDm->curPsTdma == 9) {
1860 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1861 pCoexDm->psTdmaDuAdjType = 10;
1862 } else if (pCoexDm->curPsTdma == 10) {
1863 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1864 pCoexDm->psTdmaDuAdjType = 11;
1865 } else if (pCoexDm->curPsTdma == 11) {
1866 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
1867 pCoexDm->psTdmaDuAdjType = 12;
1869 } else if (result == 1) {
1870 if (pCoexDm->curPsTdma == 4) {
1871 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1872 pCoexDm->psTdmaDuAdjType = 3;
1873 } else if (pCoexDm->curPsTdma == 3) {
1874 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1875 pCoexDm->psTdmaDuAdjType = 2;
1876 } else if (pCoexDm->curPsTdma == 2) {
1877 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1878 pCoexDm->psTdmaDuAdjType = 1;
1879 } else if (pCoexDm->curPsTdma == 1) {
1880 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 71);
1881 pCoexDm->psTdmaDuAdjType = 71;
1882 } else if (pCoexDm->curPsTdma == 12) {
1883 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1884 pCoexDm->psTdmaDuAdjType = 11;
1885 } else if (pCoexDm->curPsTdma == 11) {
1886 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1887 pCoexDm->psTdmaDuAdjType = 10;
1888 } else if (pCoexDm->curPsTdma == 10) {
1889 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1890 pCoexDm->psTdmaDuAdjType = 9;
1894 } else if (maxInterval == 2) {
1896 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
1897 if (pCoexDm->curPsTdma == 1) {
1898 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1899 pCoexDm->psTdmaDuAdjType = 6;
1900 } else if (pCoexDm->curPsTdma == 2) {
1901 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1902 pCoexDm->psTdmaDuAdjType = 6;
1903 } else if (pCoexDm->curPsTdma == 3) {
1904 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1905 pCoexDm->psTdmaDuAdjType = 7;
1906 } else if (pCoexDm->curPsTdma == 4) {
1907 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1908 pCoexDm->psTdmaDuAdjType = 8;
1911 if (pCoexDm->curPsTdma == 9) {
1912 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1913 pCoexDm->psTdmaDuAdjType = 14;
1914 } else if (pCoexDm->curPsTdma == 10) {
1915 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1916 pCoexDm->psTdmaDuAdjType = 14;
1917 } else if (pCoexDm->curPsTdma == 11) {
1918 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1919 pCoexDm->psTdmaDuAdjType = 15;
1920 } else if (pCoexDm->curPsTdma == 12) {
1921 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1922 pCoexDm->psTdmaDuAdjType = 16;
1926 if (pCoexDm->curPsTdma == 5) {
1927 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1928 pCoexDm->psTdmaDuAdjType = 6;
1929 } else if (pCoexDm->curPsTdma == 6) {
1930 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1931 pCoexDm->psTdmaDuAdjType = 7;
1932 } else if (pCoexDm->curPsTdma == 7) {
1933 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1934 pCoexDm->psTdmaDuAdjType = 8;
1935 } else if (pCoexDm->curPsTdma == 13) {
1936 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1937 pCoexDm->psTdmaDuAdjType = 14;
1938 } else if (pCoexDm->curPsTdma == 14) {
1939 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1940 pCoexDm->psTdmaDuAdjType = 15;
1941 } else if (pCoexDm->curPsTdma == 15) {
1942 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1943 pCoexDm->psTdmaDuAdjType = 16;
1945 } else if (result == 1) {
1946 if (pCoexDm->curPsTdma == 8) {
1947 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1948 pCoexDm->psTdmaDuAdjType = 7;
1949 } else if (pCoexDm->curPsTdma == 7) {
1950 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1951 pCoexDm->psTdmaDuAdjType = 6;
1952 } else if (pCoexDm->curPsTdma == 6) {
1953 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1954 pCoexDm->psTdmaDuAdjType = 6;
1955 } else if (pCoexDm->curPsTdma == 16) {
1956 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1957 pCoexDm->psTdmaDuAdjType = 15;
1958 } else if (pCoexDm->curPsTdma == 15) {
1959 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1960 pCoexDm->psTdmaDuAdjType = 14;
1961 } else if (pCoexDm->curPsTdma == 14) {
1962 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1963 pCoexDm->psTdmaDuAdjType = 14;
1967 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
1968 if (pCoexDm->curPsTdma == 5) {
1969 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1970 pCoexDm->psTdmaDuAdjType = 2;
1971 } else if (pCoexDm->curPsTdma == 6) {
1972 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1973 pCoexDm->psTdmaDuAdjType = 2;
1974 } else if (pCoexDm->curPsTdma == 7) {
1975 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1976 pCoexDm->psTdmaDuAdjType = 3;
1977 } else if (pCoexDm->curPsTdma == 8) {
1978 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
1979 pCoexDm->psTdmaDuAdjType = 4;
1982 if (pCoexDm->curPsTdma == 13) {
1983 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1984 pCoexDm->psTdmaDuAdjType = 10;
1985 } else if (pCoexDm->curPsTdma == 14) {
1986 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1987 pCoexDm->psTdmaDuAdjType = 10;
1988 } else if (pCoexDm->curPsTdma == 15) {
1989 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1990 pCoexDm->psTdmaDuAdjType = 11;
1991 } else if (pCoexDm->curPsTdma == 16) {
1992 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
1993 pCoexDm->psTdmaDuAdjType = 12;
1997 if (pCoexDm->curPsTdma == 1) {
1998 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1999 pCoexDm->psTdmaDuAdjType = 2;
2000 } else if (pCoexDm->curPsTdma == 2) {
2001 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2002 pCoexDm->psTdmaDuAdjType = 3;
2003 } else if (pCoexDm->curPsTdma == 3) {
2004 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2005 pCoexDm->psTdmaDuAdjType = 4;
2006 } else if (pCoexDm->curPsTdma == 9) {
2007 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2008 pCoexDm->psTdmaDuAdjType = 10;
2009 } else if (pCoexDm->curPsTdma == 10) {
2010 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2011 pCoexDm->psTdmaDuAdjType = 11;
2012 } else if (pCoexDm->curPsTdma == 11) {
2013 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2014 pCoexDm->psTdmaDuAdjType = 12;
2016 } else if (result == 1) {
2017 if (pCoexDm->curPsTdma == 4) {
2018 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2019 pCoexDm->psTdmaDuAdjType = 3;
2020 } else if (pCoexDm->curPsTdma == 3) {
2021 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2022 pCoexDm->psTdmaDuAdjType = 2;
2023 } else if (pCoexDm->curPsTdma == 2) {
2024 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2025 pCoexDm->psTdmaDuAdjType = 2;
2026 } else if (pCoexDm->curPsTdma == 12) {
2027 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2028 pCoexDm->psTdmaDuAdjType = 11;
2029 } else if (pCoexDm->curPsTdma == 11) {
2030 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2031 pCoexDm->psTdmaDuAdjType = 10;
2032 } else if (pCoexDm->curPsTdma == 10) {
2033 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2034 pCoexDm->psTdmaDuAdjType = 10;
2038 } else if (maxInterval == 3) {
2040 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
2041 if (pCoexDm->curPsTdma == 1) {
2042 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2043 pCoexDm->psTdmaDuAdjType = 7;
2044 } else if (pCoexDm->curPsTdma == 2) {
2045 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2046 pCoexDm->psTdmaDuAdjType = 7;
2047 } else if (pCoexDm->curPsTdma == 3) {
2048 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2049 pCoexDm->psTdmaDuAdjType = 7;
2050 } else if (pCoexDm->curPsTdma == 4) {
2051 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2052 pCoexDm->psTdmaDuAdjType = 8;
2055 if (pCoexDm->curPsTdma == 9) {
2056 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2057 pCoexDm->psTdmaDuAdjType = 15;
2058 } else if (pCoexDm->curPsTdma == 10) {
2059 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2060 pCoexDm->psTdmaDuAdjType = 15;
2061 } else if (pCoexDm->curPsTdma == 11) {
2062 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2063 pCoexDm->psTdmaDuAdjType = 15;
2064 } else if (pCoexDm->curPsTdma == 12) {
2065 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
2066 pCoexDm->psTdmaDuAdjType = 16;
2070 if (pCoexDm->curPsTdma == 5) {
2071 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2072 pCoexDm->psTdmaDuAdjType = 7;
2073 } else if (pCoexDm->curPsTdma == 6) {
2074 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2075 pCoexDm->psTdmaDuAdjType = 7;
2076 } else if (pCoexDm->curPsTdma == 7) {
2077 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2078 pCoexDm->psTdmaDuAdjType = 8;
2079 } else if (pCoexDm->curPsTdma == 13) {
2080 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2081 pCoexDm->psTdmaDuAdjType = 15;
2082 } else if (pCoexDm->curPsTdma == 14) {
2083 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2084 pCoexDm->psTdmaDuAdjType = 15;
2085 } else if (pCoexDm->curPsTdma == 15) {
2086 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
2087 pCoexDm->psTdmaDuAdjType = 16;
2089 } else if (result == 1) {
2090 if (pCoexDm->curPsTdma == 8) {
2091 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2092 pCoexDm->psTdmaDuAdjType = 7;
2093 } else if (pCoexDm->curPsTdma == 7) {
2094 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2095 pCoexDm->psTdmaDuAdjType = 7;
2096 } else if (pCoexDm->curPsTdma == 6) {
2097 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2098 pCoexDm->psTdmaDuAdjType = 7;
2099 } else if (pCoexDm->curPsTdma == 16) {
2100 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2101 pCoexDm->psTdmaDuAdjType = 15;
2102 } else if (pCoexDm->curPsTdma == 15) {
2103 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2104 pCoexDm->psTdmaDuAdjType = 15;
2105 } else if (pCoexDm->curPsTdma == 14) {
2106 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2107 pCoexDm->psTdmaDuAdjType = 15;
2111 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
2112 if (pCoexDm->curPsTdma == 5) {
2113 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2114 pCoexDm->psTdmaDuAdjType = 3;
2115 } else if (pCoexDm->curPsTdma == 6) {
2116 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2117 pCoexDm->psTdmaDuAdjType = 3;
2118 } else if (pCoexDm->curPsTdma == 7) {
2119 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2120 pCoexDm->psTdmaDuAdjType = 3;
2121 } else if (pCoexDm->curPsTdma == 8) {
2122 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2123 pCoexDm->psTdmaDuAdjType = 4;
2126 if (pCoexDm->curPsTdma == 13) {
2127 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2128 pCoexDm->psTdmaDuAdjType = 11;
2129 } else if (pCoexDm->curPsTdma == 14) {
2130 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2131 pCoexDm->psTdmaDuAdjType = 11;
2132 } else if (pCoexDm->curPsTdma == 15) {
2133 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2134 pCoexDm->psTdmaDuAdjType = 11;
2135 } else if (pCoexDm->curPsTdma == 16) {
2136 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2137 pCoexDm->psTdmaDuAdjType = 12;
2141 if (pCoexDm->curPsTdma == 1) {
2142 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2143 pCoexDm->psTdmaDuAdjType = 3;
2144 } else if (pCoexDm->curPsTdma == 2) {
2145 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2146 pCoexDm->psTdmaDuAdjType = 3;
2147 } else if (pCoexDm->curPsTdma == 3) {
2148 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2149 pCoexDm->psTdmaDuAdjType = 4;
2150 } else if (pCoexDm->curPsTdma == 9) {
2151 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2152 pCoexDm->psTdmaDuAdjType = 11;
2153 } else if (pCoexDm->curPsTdma == 10) {
2154 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2155 pCoexDm->psTdmaDuAdjType = 11;
2156 } else if (pCoexDm->curPsTdma == 11) {
2157 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2158 pCoexDm->psTdmaDuAdjType = 12;
2160 } else if (result == 1) {
2161 if (pCoexDm->curPsTdma == 4) {
2162 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2163 pCoexDm->psTdmaDuAdjType = 3;
2164 } else if (pCoexDm->curPsTdma == 3) {
2165 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2166 pCoexDm->psTdmaDuAdjType = 3;
2167 } else if (pCoexDm->curPsTdma == 2) {
2168 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2169 pCoexDm->psTdmaDuAdjType = 3;
2170 } else if (pCoexDm->curPsTdma == 12) {
2171 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2172 pCoexDm->psTdmaDuAdjType = 11;
2173 } else if (pCoexDm->curPsTdma == 11) {
2174 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2175 pCoexDm->psTdmaDuAdjType = 11;
2176 } else if (pCoexDm->curPsTdma == 10) {
2177 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2178 pCoexDm->psTdmaDuAdjType = 11;
2185 /* if current PsTdma not match with the recorded one (when scan, dhcp...), */
2186 /* then we have to adjust it back to the previous record one. */
2187 if (pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) {
2188 bool bScan = false, bLink = false, bRoam = false;
2191 ALGO_TRACE_FW_DETAIL,
2193 "[BTCoex], PsTdma type mismatch!!!, curPsTdma =%d, recordPsTdma =%d\n",
2195 pCoexDm->psTdmaDuAdjType
2199 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2200 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2201 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2203 if (!bScan && !bLink && !bRoam)
2204 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType);
2206 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
2211 /* SCO only or SCO+PAN(HS) */
2212 static void halbtc8723b2ant_ActionSco(PBTC_COEXIST pBtCoexist)
2214 u8 wifiRssiState, btRssiState;
2217 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2218 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2220 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2222 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2224 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4);
2226 if (BTC_RSSI_HIGH(btRssiState))
2227 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2229 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2231 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2233 if (BTC_WIFI_BW_LEGACY == wifiBw) /* for SCO quality at 11b/g mode */
2234 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2235 else /* for SCO quality & wifi performance balance at 11n mode */
2236 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
2238 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0); /* for voice quality */
2241 if (BTC_WIFI_BW_HT40 == wifiBw) {
2243 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2244 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2246 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2247 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4);
2249 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2250 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4);
2254 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2255 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2257 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2258 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4);
2260 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2261 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4);
2267 static void halbtc8723b2ant_ActionHid(PBTC_COEXIST pBtCoexist)
2269 u8 wifiRssiState, btRssiState;
2272 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2273 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2275 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2277 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2279 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2281 if (BTC_RSSI_HIGH(btRssiState))
2282 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2284 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2286 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2288 if (BTC_WIFI_BW_LEGACY == wifiBw) /* for HID at 11b/g mode */
2289 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2290 else /* for HID quality & wifi performance balance at 11n mode */
2291 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 9);
2294 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2295 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2297 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
2299 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
2302 if (BTC_WIFI_BW_HT40 == wifiBw) {
2304 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2305 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2307 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2308 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2310 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2311 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2315 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2316 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2318 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2319 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2321 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2322 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2327 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
2328 static void halbtc8723b2ant_ActionA2dp(PBTC_COEXIST pBtCoexist)
2330 u8 wifiRssiState, wifiRssiState1, btRssiState;
2334 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2335 wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, 40, 0);
2336 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2338 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
2340 /* define the office environment */
2341 if (apNum >= 10 && BTC_RSSI_HIGH(wifiRssiState1)) {
2342 /* DbgPrint(" AP#>10(%d)\n", apNum); */
2343 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2344 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2345 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2346 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2347 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2348 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
2351 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2352 if (BTC_WIFI_BW_HT40 == wifiBw) {
2353 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2354 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x18);
2356 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2357 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x18);
2362 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2363 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2365 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2367 if (BTC_RSSI_HIGH(btRssiState))
2368 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2370 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2372 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2375 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2376 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2378 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 1);
2380 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 1);
2383 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2384 if (BTC_WIFI_BW_HT40 == wifiBw) {
2386 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2387 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2389 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2390 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2392 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2393 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2397 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2398 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2400 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2401 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2403 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2404 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2409 static void halbtc8723b2ant_ActionA2dpPanHs(PBTC_COEXIST pBtCoexist)
2411 u8 wifiRssiState, btRssiState;
2414 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2415 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2417 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2419 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2421 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2423 if (BTC_RSSI_HIGH(btRssiState))
2424 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2426 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2428 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2430 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 2);
2433 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2434 if (BTC_WIFI_BW_HT40 == wifiBw) {
2436 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2437 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2439 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2440 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2442 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2443 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2447 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2448 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2450 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2451 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2453 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2454 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2459 static void halbtc8723b2ant_ActionPanEdr(PBTC_COEXIST pBtCoexist)
2461 u8 wifiRssiState, btRssiState;
2464 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2465 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2467 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2469 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2471 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2473 if (BTC_RSSI_HIGH(btRssiState))
2474 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2476 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2478 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10);
2481 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2482 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2484 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
2486 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
2489 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2490 if (BTC_WIFI_BW_HT40 == wifiBw) {
2492 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2493 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2495 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2496 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2498 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2499 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2503 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2504 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2506 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2507 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2509 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2510 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2517 static void halbtc8723b2ant_ActionPanHs(PBTC_COEXIST pBtCoexist)
2519 u8 wifiRssiState, btRssiState;
2522 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2523 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2525 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2527 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2529 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2531 if (BTC_RSSI_HIGH(btRssiState))
2532 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2534 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2536 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2538 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
2540 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2541 if (BTC_WIFI_BW_HT40 == wifiBw) {
2543 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2544 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2546 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2547 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2549 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2550 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2554 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2555 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2557 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2558 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2560 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2561 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2567 static void halbtc8723b2ant_ActionPanEdrA2dp(PBTC_COEXIST pBtCoexist)
2569 u8 wifiRssiState, btRssiState;
2572 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2573 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2575 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2577 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2579 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2581 if (BTC_RSSI_HIGH(btRssiState))
2582 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2584 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2586 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2589 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2590 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2592 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12);
2593 if (BTC_WIFI_BW_HT40 == wifiBw)
2594 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3);
2596 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 3);
2598 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2599 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3);
2603 if (BTC_WIFI_BW_HT40 == wifiBw) {
2605 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2606 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2608 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2609 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2611 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2612 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2616 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2617 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2619 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2620 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2622 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2623 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2628 static void halbtc8723b2ant_ActionPanEdrHid(PBTC_COEXIST pBtCoexist)
2630 u8 wifiRssiState, btRssiState;
2633 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2634 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2635 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2637 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2639 if (BTC_RSSI_HIGH(btRssiState))
2640 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2642 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2645 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2646 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2648 if (BTC_WIFI_BW_HT40 == wifiBw) {
2649 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3);
2650 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11);
2651 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780);
2653 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2654 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2655 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2657 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2);
2659 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2660 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11);
2661 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2662 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2666 if (BTC_WIFI_BW_HT40 == wifiBw) {
2668 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2669 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2671 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2672 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2674 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2675 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2679 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2680 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2682 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2683 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2685 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2686 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2691 /* HID+A2DP+PAN(EDR) */
2692 static void halbtc8723b2ant_ActionHidA2dpPanEdr(PBTC_COEXIST pBtCoexist)
2694 u8 wifiRssiState, btRssiState;
2697 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2698 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2700 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2702 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2704 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2706 if (BTC_RSSI_HIGH(btRssiState))
2707 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2709 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2711 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2713 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2716 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2717 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2719 if (BTC_WIFI_BW_HT40 == wifiBw)
2720 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2722 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 3);
2724 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 3);
2727 if (BTC_WIFI_BW_HT40 == wifiBw) {
2729 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2730 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2732 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2733 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2735 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2736 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2740 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2741 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2743 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2744 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2746 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2747 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2752 static void halbtc8723b2ant_ActionHidA2dp(PBTC_COEXIST pBtCoexist)
2754 u8 wifiRssiState, btRssiState;
2758 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2759 /* btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); */
2760 btRssiState = halbtc8723b2ant_BtRssiState(3, 29, 37);
2762 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2764 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, true, 0x5);
2766 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2768 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2769 if (BTC_WIFI_BW_LEGACY == wifiBw) {
2770 if (BTC_RSSI_HIGH(btRssiState))
2771 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2772 else if (BTC_RSSI_MEDIUM(btRssiState))
2773 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2775 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2777 /* only 802.11N mode we have to dec bt power to 4 degree */
2778 if (BTC_RSSI_HIGH(btRssiState)) {
2779 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
2780 /* need to check ap Number of Not */
2782 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
2784 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2785 } else if (BTC_RSSI_MEDIUM(btRssiState))
2786 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2788 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2791 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2794 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2795 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2797 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2);
2799 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2802 if (BTC_WIFI_BW_HT40 == wifiBw) {
2804 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2805 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2807 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2808 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2810 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2811 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2815 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2816 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2818 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2819 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2821 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2822 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2827 static void halbtc8723b2ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
2831 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism() ===>\n"));
2833 if (pBtCoexist->bManualControl) {
2834 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
2838 if (pCoexSta->bUnderIps) {
2839 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
2843 algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist);
2844 if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
2845 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT is under inquiry/page scan !!\n"));
2846 halbtc8723b2ant_ActionBtInquiry(pBtCoexist);
2849 if (pCoexDm->bNeedRecover0x948) {
2850 pCoexDm->bNeedRecover0x948 = false;
2851 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, pCoexDm->backup0x948);
2855 pCoexDm->curAlgorithm = algorithm;
2856 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Algorithm = %d\n", pCoexDm->curAlgorithm));
2858 if (halbtc8723b2ant_IsCommonAction(pBtCoexist)) {
2859 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant common.\n"));
2860 pCoexDm->bAutoTdmaAdjust = false;
2862 if (pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) {
2867 "[BTCoex], preAlgorithm =%d, curAlgorithm =%d\n",
2868 pCoexDm->preAlgorithm,
2869 pCoexDm->curAlgorithm
2872 pCoexDm->bAutoTdmaAdjust = false;
2876 switch (pCoexDm->curAlgorithm) {
2877 case BT_8723B_2ANT_COEX_ALGO_SCO:
2878 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n"));
2879 halbtc8723b2ant_ActionSco(pBtCoexist);
2881 case BT_8723B_2ANT_COEX_ALGO_HID:
2882 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID.\n"));
2883 halbtc8723b2ant_ActionHid(pBtCoexist);
2885 case BT_8723B_2ANT_COEX_ALGO_A2DP:
2886 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n"));
2887 halbtc8723b2ant_ActionA2dp(pBtCoexist);
2889 case BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS:
2890 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n"));
2891 halbtc8723b2ant_ActionA2dpPanHs(pBtCoexist);
2893 case BT_8723B_2ANT_COEX_ALGO_PANEDR:
2894 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"));
2895 halbtc8723b2ant_ActionPanEdr(pBtCoexist);
2897 case BT_8723B_2ANT_COEX_ALGO_PANHS:
2898 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n"));
2899 halbtc8723b2ant_ActionPanHs(pBtCoexist);
2901 case BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP:
2902 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"));
2903 halbtc8723b2ant_ActionPanEdrA2dp(pBtCoexist);
2905 case BT_8723B_2ANT_COEX_ALGO_PANEDR_HID:
2906 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
2907 halbtc8723b2ant_ActionPanEdrHid(pBtCoexist);
2909 case BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
2910 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
2911 halbtc8723b2ant_ActionHidA2dpPanEdr(pBtCoexist);
2913 case BT_8723B_2ANT_COEX_ALGO_HID_A2DP:
2914 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"));
2915 halbtc8723b2ant_ActionHidA2dp(pBtCoexist);
2918 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"));
2919 halbtc8723b2ant_CoexAllOff(pBtCoexist);
2922 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
2926 static void halbtc8723b2ant_WifiOffHwCfg(PBTC_COEXIST pBtCoexist)
2928 bool bIsInMpMode = false;
2929 u8 H2C_Parameter[2] = {0};
2932 /* set wlan_act to low */
2933 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
2935 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); /* WiFi goto standby while GNT_BT 0-->1 */
2936 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
2937 if (fwVer >= 0x180000) {
2938 /* Use H2C to set GNT_BT to HIGH */
2939 H2C_Parameter[0] = 1;
2940 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
2942 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
2944 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode);
2946 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); /* BT select s0/s1 is controlled by BT */
2948 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); /* BT select s0/s1 is controlled by WiFi */
2951 static void halbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bBackUp)
2955 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 2Ant Init HW Config!!\n"));
2957 /* backup rf 0x1e value */
2958 pCoexDm->btRf0x1eBackup =
2959 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
2961 /* 0x790[5:0]= 0x5 */
2962 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
2965 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
2967 /* Antenna config */
2968 halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, true, false);
2971 halbtc8723b2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
2973 /* Enable counter statistics */
2974 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); /* 0x76e[3] = 1, WLAN_Act control by PTA */
2975 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);
2976 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
2980 /* work around function start with wa_halbtc8723b2ant_ */
2983 /* extern function start with EXhalbtc8723b2ant_ */
2985 void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
2987 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
2988 u8 u1Tmp = 0x4; /* Set BIT2 by default since it's 2ant case */
2991 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20);
2993 /* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. */
2994 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
2995 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1);
2997 /* set GRAN_BT = 1 */
2998 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
2999 /* set WLAN_ACT = 0 */
3000 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
3003 /* S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) */
3004 /* Local setting bit define */
3005 /* BIT0: "0" for no antenna inverse; "1" for antenna inverse */
3006 /* BIT1: "0" for internal switch; "1" for external switch */
3007 /* BIT2: "0" for one antenna; "1" for two antenna */
3008 /* NOTE: here default all internal switch and 1-antenna ==> BIT1 = 0 and BIT2 = 0 */
3009 if (pBtCoexist->chipInterface == BTC_INTF_USB) {
3010 /* fixed at S0 for USB interface */
3011 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
3013 u1Tmp |= 0x1; /* antenna inverse */
3014 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);
3016 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
3018 /* for PCIE and SDIO interface, we check efuse 0xc3[6] */
3019 if (pBoardInfo->singleAntPath == 0) {
3021 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
3022 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
3023 } else if (pBoardInfo->singleAntPath == 1) {
3025 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
3026 u1Tmp |= 0x1; /* antenna inverse */
3027 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
3030 if (pBtCoexist->chipInterface == BTC_INTF_PCI)
3031 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp);
3032 else if (pBtCoexist->chipInterface == BTC_INTF_SDIO)
3033 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp);
3037 void EXhalbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly)
3039 halbtc8723b2ant_InitHwConfig(pBtCoexist, true);
3042 void EXhalbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
3044 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
3046 halbtc8723b2ant_InitCoexDm(pBtCoexist);
3049 void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
3051 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
3052 PBTC_STACK_INFO pStackInfo = &pBtCoexist->stackInfo;
3053 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
3054 u8 *cliBuf = pBtCoexist->cliBuf;
3055 u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0;
3057 bool bRoam = false, bScan = false, bLink = false, bWifiUnder5G = false;
3058 bool bBtHsOn = false, bWifiBusy = false;
3059 s32 wifiRssi = 0, btHsRssi = 0;
3060 u32 wifiBw, wifiTrafficDir, faOfdm, faCck;
3061 u8 wifiDot11Chnl, wifiHsChnl;
3062 u32 fwVer = 0, btPatchVer = 0;
3065 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
3068 if (pBtCoexist->bManualControl) {
3069 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
3071 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
3078 "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
3079 pBoardInfo->pgAntNum,
3080 pBoardInfo->btdmAntNum
3087 "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
3088 (pStackInfo->bProfileNotified ? "Yes" : "No"),
3089 pStackInfo->hciVersion
3093 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
3094 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
3095 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
3096 GLCoexVerDate8723b2Ant, GLCoexVer8723b2Ant, fwVer, btPatchVer, btPatchVer);
3099 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3100 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
3101 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
3105 "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
3115 "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
3116 pCoexDm->wifiChnlInfo[0],
3117 pCoexDm->wifiChnlInfo[1],
3118 pCoexDm->wifiChnlInfo[2]
3122 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
3123 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
3124 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
3128 "\r\n %-35s = %d/ %d/ %d", "Wifi rssi/ HS rssi/ AP#", \
3135 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
3136 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
3137 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
3141 "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
3148 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
3149 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3150 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
3151 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
3155 "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
3156 (bWifiUnder5G ? "5G" : "2.4G"),
3157 ((BTC_WIFI_BW_LEGACY == wifiBw) ? "Legacy" : (((BTC_WIFI_BW_HT40 == wifiBw) ? "HT40" : "HT20"))),
3158 ((!bWifiBusy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) ? "uplink" : "downlink"))
3165 "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
3166 ((pBtCoexist->btInfo.bBtDisabled) ? ("disabled") : ((pCoexSta->bC2hBtInquiryPage) ? ("inquiry/page scan") : ((BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ? "non-connected idle" :
3167 ((BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ? "connected-idle" : "busy")))),
3169 pCoexSta->btRetryCnt
3176 "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
3177 pBtLinkInfo->bScoExist,
3178 pBtLinkInfo->bHidExist,
3179 pBtLinkInfo->bPanExist,
3180 pBtLinkInfo->bA2dpExist
3183 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
3185 btInfoExt = pCoexSta->btInfoExt;
3189 "\r\n %-35s = %s", "BT Info A2DP rate", \
3190 (btInfoExt&BIT0) ? "Basic rate" : "EDR rate"
3194 for (i = 0; i < BT_INFO_SRC_8723B_2ANT_MAX; i++) {
3195 if (pCoexSta->btInfoC2hCnt[i]) {
3199 "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b2Ant[i], \
3200 pCoexSta->btInfoC2h[i][0],
3201 pCoexSta->btInfoC2h[i][1],
3202 pCoexSta->btInfoC2h[i][2],
3203 pCoexSta->btInfoC2h[i][3],
3204 pCoexSta->btInfoC2h[i][4],
3205 pCoexSta->btInfoC2h[i][5],
3206 pCoexSta->btInfoC2h[i][6],
3207 pCoexSta->btInfoC2hCnt[i]
3216 "\r\n %-35s = %s/%s", "PS state, IPS/LPS", \
3217 ((pCoexSta->bUnderIps ? "IPS ON" : "IPS OFF")),
3218 ((pCoexSta->bUnderLps ? "LPS ON" : "LPS OFF"))
3221 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
3227 "\r\n %-35s", "============[Sw mechanism]============"
3233 "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \
3234 pCoexDm->bCurRfRxLpfShrink,
3235 pCoexDm->bCurLowPenaltyRa,
3236 pCoexDm->bLimitedDig
3242 "\r\n %-35s = %d/ %d/ %d(0x%x) ",
3243 "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
3244 pCoexDm->bCurAgcTableEn,
3245 pCoexDm->bCurAdcBackOff,
3246 pCoexDm->bCurDacSwingOn,
3247 pCoexDm->curDacSwingLvl
3252 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
3255 psTdmaCase = pCoexDm->curPsTdma;
3259 "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
3260 pCoexDm->psTdmaPara[0],
3261 pCoexDm->psTdmaPara[1],
3262 pCoexDm->psTdmaPara[2],
3263 pCoexDm->psTdmaPara[3],
3264 pCoexDm->psTdmaPara[4],
3265 psTdmaCase, pCoexDm->bAutoTdmaAdjust
3272 "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
3273 pCoexDm->curBtDecPwrLvl,
3274 pCoexDm->bCurIgnoreWlanAct
3279 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
3285 "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
3286 pCoexDm->btRf0x1eBackup
3290 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
3291 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
3295 "\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \
3297 (u4Tmp[0]&0x3e000000) >> 25
3302 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
3303 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
3304 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
3308 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \
3310 ((u1Tmp[0]&0x20)>>5),
3315 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c);
3316 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
3317 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944);
3321 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \
3329 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39);
3330 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
3331 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
3332 u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64);
3336 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \
3337 ((u1Tmp[0] & 0x8)>>3),
3339 ((u4Tmp[0]&0x01800000)>>23),
3344 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
3345 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
3349 "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
3355 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
3356 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c);
3360 "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
3366 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
3367 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
3368 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
3369 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0);
3371 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b);
3372 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
3375 ((u4Tmp[0]&0xffff0000) >> 16) +
3376 ((u4Tmp[1]&0xffff0000) >> 16) +
3377 (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \
3378 ((u4Tmp[3]&0xffff0000) >> 16) +
3379 (u4Tmp[3] & 0xffff);
3381 faCck = (u1Tmp[0] << 8) + u1Tmp[1];
3386 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
3393 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
3394 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
3395 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
3396 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
3400 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
3411 "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \
3412 pCoexSta->highPriorityRx,
3413 pCoexSta->highPriorityTx
3419 "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \
3420 pCoexSta->lowPriorityRx,
3421 pCoexSta->lowPriorityTx
3425 halbtc8723b2ant_MonitorBtCtr(pBtCoexist);
3426 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
3430 void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
3432 if (BTC_IPS_ENTER == type) {
3433 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
3434 pCoexSta->bUnderIps = true;
3435 halbtc8723b2ant_WifiOffHwCfg(pBtCoexist);
3436 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
3437 halbtc8723b2ant_CoexAllOff(pBtCoexist);
3438 } else if (BTC_IPS_LEAVE == type) {
3439 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
3440 pCoexSta->bUnderIps = false;
3441 halbtc8723b2ant_InitHwConfig(pBtCoexist, false);
3442 halbtc8723b2ant_InitCoexDm(pBtCoexist);
3443 halbtc8723b2ant_QueryBtInfo(pBtCoexist);
3447 void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
3449 if (BTC_LPS_ENABLE == type) {
3450 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
3451 pCoexSta->bUnderLps = true;
3452 } else if (BTC_LPS_DISABLE == type) {
3453 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
3454 pCoexSta->bUnderLps = false;
3458 void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
3460 if (BTC_SCAN_START == type) {
3461 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
3462 } else if (BTC_SCAN_FINISH == type) {
3463 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
3467 void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
3469 if (BTC_ASSOCIATE_START == type) {
3470 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
3471 } else if (BTC_ASSOCIATE_FINISH == type) {
3472 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
3476 void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
3478 u8 H2C_Parameter[3] = {0};
3483 if (BTC_MEDIA_CONNECT == type) {
3484 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
3486 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
3489 /* only 2.4G we need to inform bt the chnl mask */
3490 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
3491 if ((BTC_MEDIA_CONNECT == type) && (wifiCentralChnl <= 14)) {
3492 H2C_Parameter[0] = 0x1;
3493 H2C_Parameter[1] = wifiCentralChnl;
3494 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3495 if (BTC_WIFI_BW_HT40 == wifiBw)
3496 H2C_Parameter[2] = 0x30;
3498 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
3500 H2C_Parameter[2] = 0x30;
3502 H2C_Parameter[2] = 0x20;
3506 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
3507 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
3508 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
3514 "[BTCoex], FW write 0x66 = 0x%x\n",
3515 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]
3519 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
3522 void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
3524 if (type == BTC_PACKET_DHCP) {
3525 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
3529 void EXhalbtc8723b2ant_BtInfoNotify(
3530 PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
3534 u8 i, rspSource = 0;
3535 bool bBtBusy = false, bLimitedDig = false;
3536 bool bWifiConnected = false;
3538 pCoexSta->bC2hBtInfoReqSent = false;
3540 rspSource = tmpBuf[0]&0xf;
3541 if (rspSource >= BT_INFO_SRC_8723B_2ANT_MAX)
3542 rspSource = BT_INFO_SRC_8723B_2ANT_WIFI_FW;
3544 pCoexSta->btInfoC2hCnt[rspSource]++;
3546 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length =%d, hex data =[", rspSource, length));
3547 for (i = 0; i < length; i++) {
3548 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
3552 if (i == length-1) {
3553 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
3555 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
3559 if (pBtCoexist->bManualControl) {
3560 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
3564 if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
3565 pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2]&0xf; /* [3:0] */
3567 pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3]*2+10;
3569 pCoexSta->btInfoExt = pCoexSta->btInfoC2h[rspSource][4];
3571 pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
3572 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
3573 if (pCoexSta->bBtTxRxMask) {
3574 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */
3575 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n"));
3576 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01);
3579 /* Here we need to resend some wifi info to BT */
3580 /* because bt is reset and loss of the info. */
3581 if ((pCoexSta->btInfoExt & BIT1)) {
3582 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
3583 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3586 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
3588 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3591 if ((pCoexSta->btInfoExt & BIT3)) {
3592 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
3593 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, false);
3595 /* BT already NOT ignore Wlan active, do nothing here. */
3599 /* check BIT2 first ==> check if bt is under inquiry or page scan */
3600 if (btInfo & BT_INFO_8723B_2ANT_B_INQ_PAGE)
3601 pCoexSta->bC2hBtInquiryPage = true;
3603 pCoexSta->bC2hBtInquiryPage = false;
3605 /* set link exist status */
3606 if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) {
3607 pCoexSta->bBtLinkExist = false;
3608 pCoexSta->bPanExist = false;
3609 pCoexSta->bA2dpExist = false;
3610 pCoexSta->bHidExist = false;
3611 pCoexSta->bScoExist = false;
3612 } else { /* connection exists */
3613 pCoexSta->bBtLinkExist = true;
3614 if (btInfo & BT_INFO_8723B_2ANT_B_FTP)
3615 pCoexSta->bPanExist = true;
3617 pCoexSta->bPanExist = false;
3618 if (btInfo & BT_INFO_8723B_2ANT_B_A2DP)
3619 pCoexSta->bA2dpExist = true;
3621 pCoexSta->bA2dpExist = false;
3622 if (btInfo & BT_INFO_8723B_2ANT_B_HID)
3623 pCoexSta->bHidExist = true;
3625 pCoexSta->bHidExist = false;
3626 if (btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO)
3627 pCoexSta->bScoExist = true;
3629 pCoexSta->bScoExist = false;
3632 halbtc8723b2ant_UpdateBtLinkInfo(pBtCoexist);
3634 if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) {
3635 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
3636 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
3637 } else if (btInfo == BT_INFO_8723B_2ANT_B_CONNECTION) { /* connection exists but no busy */
3638 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE;
3639 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
3641 (btInfo&BT_INFO_8723B_2ANT_B_SCO_ESCO) ||
3642 (btInfo&BT_INFO_8723B_2ANT_B_SCO_BUSY)
3644 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_SCO_BUSY;
3645 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
3646 } else if (btInfo&BT_INFO_8723B_2ANT_B_ACL_BUSY) {
3647 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_ACL_BUSY;
3648 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
3650 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_MAX;
3651 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
3655 (BT_8723B_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
3656 (BT_8723B_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
3657 (BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)
3663 bLimitedDig = false;
3666 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
3668 pCoexDm->bLimitedDig = bLimitedDig;
3669 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig);
3671 halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);
3674 void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist)
3676 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
3678 halbtc8723b2ant_WifiOffHwCfg(pBtCoexist);
3679 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); /* BT goto standby while GNT_BT 1-->0 */
3680 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
3682 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3685 void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
3687 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
3689 if (BTC_WIFI_PNP_SLEEP == pnpState) {
3690 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to SLEEP\n"));
3691 } else if (BTC_WIFI_PNP_WAKE_UP == pnpState) {
3692 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to WAKE UP\n"));
3693 halbtc8723b2ant_InitHwConfig(pBtCoexist, false);
3694 halbtc8723b2ant_InitCoexDm(pBtCoexist);
3695 halbtc8723b2ant_QueryBtInfo(pBtCoexist);
3699 void EXhalbtc8723b2ant_Periodical(PBTC_COEXIST pBtCoexist)
3701 static u8 disVerInfoCnt;
3702 u32 fwVer = 0, btPatchVer = 0;
3704 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical ===========================\n"));
3706 if (disVerInfoCnt <= 5) {
3708 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
3709 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
3710 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
3711 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
3712 GLCoexVerDate8723b2Ant, GLCoexVer8723b2Ant, fwVer, btPatchVer, btPatchVer));
3713 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
3717 halbtc8723b2ant_IsWifiStatusChanged(pBtCoexist) ||
3718 pCoexDm->bAutoTdmaAdjust
3720 halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);