1 /******************************************************************************
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
16 #include "Mp_Precomp.h"
18 /* Global variables, these are static variables */
19 static COEX_DM_8723B_2ANT GLCoexDm8723b2Ant;
20 static PCOEX_DM_8723B_2ANT pCoexDm = &GLCoexDm8723b2Ant;
21 static COEX_STA_8723B_2ANT GLCoexSta8723b2Ant;
22 static PCOEX_STA_8723B_2ANT pCoexSta = &GLCoexSta8723b2Ant;
24 static const char *const GLBtInfoSrc8723b2Ant[] = {
27 "BT Info[bt auto report]",
30 static u32 GLCoexVerDate8723b2Ant = 20131211;
31 static u32 GLCoexVer8723b2Ant = 0x40;
33 /* local function start with halbtc8723b2ant_ */
34 static u8 halbtc8723b2ant_BtRssiState(
35 u8 levelNum, u8 rssiThresh, u8 rssiThresh1
39 u8 btRssiState = pCoexSta->preBtRssiState;
41 btRssi = pCoexSta->btRssi;
45 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
46 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
48 if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
49 btRssiState = BTC_RSSI_STATE_HIGH;
50 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
52 btRssiState = BTC_RSSI_STATE_STAY_LOW;
53 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
56 if (btRssi < rssiThresh) {
57 btRssiState = BTC_RSSI_STATE_LOW;
58 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
60 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
61 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
64 } else if (levelNum == 3) {
65 if (rssiThresh > rssiThresh1) {
66 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
67 return pCoexSta->preBtRssiState;
71 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
72 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
74 if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
75 btRssiState = BTC_RSSI_STATE_MEDIUM;
76 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
78 btRssiState = BTC_RSSI_STATE_STAY_LOW;
79 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
82 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
83 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)
85 if (btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
86 btRssiState = BTC_RSSI_STATE_HIGH;
87 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
88 } else if (btRssi < rssiThresh) {
89 btRssiState = BTC_RSSI_STATE_LOW;
90 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
92 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
93 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
96 if (btRssi < rssiThresh1) {
97 btRssiState = BTC_RSSI_STATE_MEDIUM;
98 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
100 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
101 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
106 pCoexSta->preBtRssiState = btRssiState;
111 static u8 halbtc8723b2ant_WifiRssiState(
112 PBTC_COEXIST pBtCoexist,
120 u8 wifiRssiState = pCoexSta->preWifiRssiState[index];
122 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
126 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
127 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
129 if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
130 wifiRssiState = BTC_RSSI_STATE_HIGH;
131 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
133 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
134 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
137 if (wifiRssi < rssiThresh) {
138 wifiRssiState = BTC_RSSI_STATE_LOW;
139 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
141 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
142 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
145 } else if (levelNum == 3) {
146 if (rssiThresh > rssiThresh1) {
147 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
148 return pCoexSta->preWifiRssiState[index];
152 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
153 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
155 if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
156 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
157 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
159 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
160 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
163 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
164 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)
166 if (wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
167 wifiRssiState = BTC_RSSI_STATE_HIGH;
168 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
169 } else if (wifiRssi < rssiThresh) {
170 wifiRssiState = BTC_RSSI_STATE_LOW;
171 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
173 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
174 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
177 if (wifiRssi < rssiThresh1) {
178 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
179 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
181 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
182 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
187 pCoexSta->preWifiRssiState[index] = wifiRssiState;
189 return wifiRssiState;
192 static void halbtc8723b2ant_LimitedRx(
193 PBTC_COEXIST pBtCoexist,
196 bool bBtCtrlAggBufSize,
200 bool bRejectRxAgg = bRejApAggPkt;
201 bool bBtCtrlRxAggSize = bBtCtrlAggBufSize;
202 u8 rxAggSize = aggBufSize;
205 /* Rx Aggregation related setting */
207 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);
208 /* decide BT control aggregation buf size or not */
209 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);
210 /* aggregation buf size, only work when BT control Rx aggregation size. */
211 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
212 /* real update aggregation setting */
213 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
216 static void halbtc8723b2ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
218 u32 regHPTxRx, regLPTxRx, u4Tmp;
219 u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0;
224 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
225 regHPTx = u4Tmp & bMaskLWord;
226 regHPRx = (u4Tmp & bMaskHWord)>>16;
228 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
229 regLPTx = u4Tmp & bMaskLWord;
230 regLPRx = (u4Tmp & bMaskHWord)>>16;
232 pCoexSta->highPriorityTx = regHPTx;
233 pCoexSta->highPriorityRx = regHPRx;
234 pCoexSta->lowPriorityTx = regLPTx;
235 pCoexSta->lowPriorityRx = regLPRx;
241 "[BTCoex], High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
253 "[BTCoex], Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
263 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
266 static void halbtc8723b2ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
268 u8 H2C_Parameter[1] = {0};
270 pCoexSta->bC2hBtInfoReqSent = true;
272 H2C_Parameter[0] |= BIT0; /* trigger */
277 ("[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", H2C_Parameter[0])
280 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
283 static bool halbtc8723b2ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
285 static bool bPreWifiBusy = false, bPreUnder4way = false, bPreBtHsOn = false;
286 bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false;
287 bool bWifiConnected = false;
289 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
290 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
291 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
292 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
294 if (bWifiConnected) {
295 if (bWifiBusy != bPreWifiBusy) {
296 bPreWifiBusy = bWifiBusy;
300 if (bUnder4way != bPreUnder4way) {
301 bPreUnder4way = bUnder4way;
305 if (bBtHsOn != bPreBtHsOn) {
306 bPreBtHsOn = bBtHsOn;
314 static void halbtc8723b2ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
316 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
317 bool bBtHsOn = false;
319 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
321 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
322 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
323 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
324 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
325 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
327 /* work around for HS mode. */
329 pBtLinkInfo->bPanExist = true;
330 pBtLinkInfo->bBtLinkExist = true;
333 /* check if Sco only */
335 pBtLinkInfo->bScoExist &&
336 !pBtLinkInfo->bA2dpExist &&
337 !pBtLinkInfo->bPanExist &&
338 !pBtLinkInfo->bHidExist
340 pBtLinkInfo->bScoOnly = true;
342 pBtLinkInfo->bScoOnly = false;
344 /* check if A2dp only */
346 !pBtLinkInfo->bScoExist &&
347 pBtLinkInfo->bA2dpExist &&
348 !pBtLinkInfo->bPanExist &&
349 !pBtLinkInfo->bHidExist
351 pBtLinkInfo->bA2dpOnly = true;
353 pBtLinkInfo->bA2dpOnly = false;
355 /* check if Pan only */
357 !pBtLinkInfo->bScoExist &&
358 !pBtLinkInfo->bA2dpExist &&
359 pBtLinkInfo->bPanExist &&
360 !pBtLinkInfo->bHidExist
362 pBtLinkInfo->bPanOnly = true;
364 pBtLinkInfo->bPanOnly = false;
366 /* check if Hid only */
368 !pBtLinkInfo->bScoExist &&
369 !pBtLinkInfo->bA2dpExist &&
370 !pBtLinkInfo->bPanExist &&
371 pBtLinkInfo->bHidExist
373 pBtLinkInfo->bHidOnly = true;
375 pBtLinkInfo->bHidOnly = false;
378 static u8 halbtc8723b2ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
380 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
381 bool bBtHsOn = false;
382 u8 algorithm = BT_8723B_2ANT_COEX_ALGO_UNDEFINED;
383 u8 numOfDiffProfile = 0;
385 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
387 if (!pBtLinkInfo->bBtLinkExist) {
388 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n"));
392 if (pBtLinkInfo->bScoExist)
395 if (pBtLinkInfo->bHidExist)
398 if (pBtLinkInfo->bPanExist)
401 if (pBtLinkInfo->bA2dpExist)
404 if (numOfDiffProfile == 1) {
405 if (pBtLinkInfo->bScoExist) {
406 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n"));
407 algorithm = BT_8723B_2ANT_COEX_ALGO_SCO;
409 if (pBtLinkInfo->bHidExist) {
410 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
411 algorithm = BT_8723B_2ANT_COEX_ALGO_HID;
412 } else if (pBtLinkInfo->bA2dpExist) {
413 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
414 algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP;
415 } else if (pBtLinkInfo->bPanExist) {
417 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
418 algorithm = BT_8723B_2ANT_COEX_ALGO_PANHS;
420 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
421 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR;
425 } else if (numOfDiffProfile == 2) {
426 if (pBtLinkInfo->bScoExist) {
427 if (pBtLinkInfo->bHidExist) {
428 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n"));
429 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
430 } else if (pBtLinkInfo->bA2dpExist) {
431 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n"));
432 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
433 } else if (pBtLinkInfo->bPanExist) {
435 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
436 algorithm = BT_8723B_2ANT_COEX_ALGO_SCO;
438 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
439 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
444 pBtLinkInfo->bHidExist &&
445 pBtLinkInfo->bA2dpExist
447 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
448 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
450 pBtLinkInfo->bHidExist &&
451 pBtLinkInfo->bPanExist
454 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
455 algorithm = BT_8723B_2ANT_COEX_ALGO_HID;
457 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
458 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
461 pBtLinkInfo->bPanExist &&
462 pBtLinkInfo->bA2dpExist
465 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
466 algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS;
468 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
469 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP;
473 } else if (numOfDiffProfile == 3) {
474 if (pBtLinkInfo->bScoExist) {
476 pBtLinkInfo->bHidExist &&
477 pBtLinkInfo->bA2dpExist
482 ("[BTCoex], SCO + HID + A2DP ==> HID\n")
484 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
486 pBtLinkInfo->bHidExist &&
487 pBtLinkInfo->bPanExist
493 ("[BTCoex], SCO + HID + PAN(HS)\n")
495 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
500 ("[BTCoex], SCO + HID + PAN(EDR)\n")
502 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
505 pBtLinkInfo->bPanExist &&
506 pBtLinkInfo->bA2dpExist
509 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
510 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
512 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
513 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
518 pBtLinkInfo->bHidExist &&
519 pBtLinkInfo->bPanExist &&
520 pBtLinkInfo->bA2dpExist
523 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
524 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
526 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
527 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
531 } else if (numOfDiffProfile >= 3) {
532 if (pBtLinkInfo->bScoExist) {
534 pBtLinkInfo->bHidExist &&
535 pBtLinkInfo->bPanExist &&
536 pBtLinkInfo->bA2dpExist
539 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
542 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n"));
543 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
552 static void halbtc8723b2ant_SetFwDacSwingLevel(
553 PBTC_COEXIST pBtCoexist, u8 dacSwingLvl
556 u8 H2C_Parameter[1] = {0};
558 /* There are several type of dacswing */
559 /* 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */
560 H2C_Parameter[0] = dacSwingLvl;
565 ("[BTCoex], Set Dac Swing Level = 0x%x\n", dacSwingLvl)
570 ("[BTCoex], FW write 0x64 = 0x%x\n", H2C_Parameter[0])
573 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter);
576 static void halbtc8723b2ant_SetFwDecBtPwr(
577 PBTC_COEXIST pBtCoexist, u8 decBtPwrLvl
580 u8 H2C_Parameter[1] = {0};
582 H2C_Parameter[0] = decBtPwrLvl;
588 "[BTCoex], decrease Bt Power level = %d, FW write 0x62 = 0x%x\n",
594 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter);
597 static void halbtc8723b2ant_DecBtPwr(
598 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 decBtPwrLvl
605 "[BTCoex], %s Dec BT power level = %d\n",
606 (bForceExec ? "force to" : ""),
610 pCoexDm->curBtDecPwrLvl = decBtPwrLvl;
615 ALGO_TRACE_FW_DETAIL,
617 "[BTCoex], preBtDecPwrLvl =%d, curBtDecPwrLvl =%d\n",
618 pCoexDm->preBtDecPwrLvl,
619 pCoexDm->curBtDecPwrLvl
623 if (pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl)
626 halbtc8723b2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
628 pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
631 static void halbtc8723b2ant_FwDacSwingLvl(
632 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 fwDacSwingLvl
639 "[BTCoex], %s set FW Dac Swing level = %d\n",
640 (bForceExec ? "force to" : ""),
644 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
649 ALGO_TRACE_FW_DETAIL,
651 "[BTCoex], preFwDacSwingLvl =%d, curFwDacSwingLvl =%d\n",
652 pCoexDm->preFwDacSwingLvl,
653 pCoexDm->curFwDacSwingLvl
657 if (pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
661 halbtc8723b2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
663 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
666 static void halbtc8723b2ant_SetSwRfRxLpfCorner(
667 PBTC_COEXIST pBtCoexist,
672 /* Shrink RF Rx LPF corner */
676 ("[BTCoex], Shrink RF Rx LPF corner!!\n")
678 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc);
680 /* Resume RF Rx LPF corner */
681 /* After initialized, we can use pCoexDm->btRf0x1eBackup */
682 if (pBtCoexist->bInitilized) {
683 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
684 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
689 static void halbtc8723b2ant_RfShrink(
690 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bRxRfShrinkOn
697 "[BTCoex], %s turn Rx RF Shrink = %s\n",
698 (bForceExec ? "force to" : ""),
699 (bRxRfShrinkOn ? "ON" : "OFF")
702 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
707 ALGO_TRACE_SW_DETAIL,
709 "[BTCoex], bPreRfRxLpfShrink =%d, bCurRfRxLpfShrink =%d\n",
710 pCoexDm->bPreRfRxLpfShrink,
711 pCoexDm->bCurRfRxLpfShrink
715 if (pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
718 halbtc8723b2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
720 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
723 static void halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(
724 PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa
727 u8 H2C_Parameter[6] = {0};
729 H2C_Parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */
732 H2C_Parameter[1] |= BIT0;
733 H2C_Parameter[2] = 0x00; /* normal rate except MCS7/6/5, OFDM54/48/36 */
734 H2C_Parameter[3] = 0xf7; /* MCS7 or OFDM54 */
735 H2C_Parameter[4] = 0xf8; /* MCS6 or OFDM48 */
736 H2C_Parameter[5] = 0xf9; /* MCS5 or OFDM36 */
743 "[BTCoex], set WiFi Low-Penalty Retry: %s",
744 (bLowPenaltyRa ? "ON!!" : "OFF!!")
748 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
751 static void halbtc8723b2ant_LowPenaltyRa(
752 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa
760 "[BTCoex], %s turn LowPenaltyRA = %s\n",
761 (bForceExec ? "force to" : ""),
762 (bLowPenaltyRa ? "ON" : "OFF")
765 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
770 ALGO_TRACE_SW_DETAIL,
772 "[BTCoex], bPreLowPenaltyRa =%d, bCurLowPenaltyRa =%d\n",
773 pCoexDm->bPreLowPenaltyRa,
774 pCoexDm->bCurLowPenaltyRa
778 if (pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
781 halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
783 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
786 static void halbtc8723b2ant_SetDacSwingReg(PBTC_COEXIST pBtCoexist, u32 level)
793 ("[BTCoex], Write SwDacSwing = 0x%x\n", level)
795 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val);
798 static void halbtc8723b2ant_SetSwFullTimeDacSwing(
799 PBTC_COEXIST pBtCoexist, bool bSwDacSwingOn, u32 swDacSwingLvl
803 halbtc8723b2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
805 halbtc8723b2ant_SetDacSwingReg(pBtCoexist, 0x18);
809 static void halbtc8723b2ant_DacSwing(
810 PBTC_COEXIST pBtCoexist,
820 "[BTCoex], %s turn DacSwing =%s, dacSwingLvl = 0x%x\n",
821 (bForceExec ? "force to" : ""),
822 (bDacSwingOn ? "ON" : "OFF"),
826 pCoexDm->bCurDacSwingOn = bDacSwingOn;
827 pCoexDm->curDacSwingLvl = dacSwingLvl;
832 ALGO_TRACE_SW_DETAIL,
834 "[BTCoex], bPreDacSwingOn =%d, preDacSwingLvl = 0x%x, bCurDacSwingOn =%d, curDacSwingLvl = 0x%x\n",
835 pCoexDm->bPreDacSwingOn,
836 pCoexDm->preDacSwingLvl,
837 pCoexDm->bCurDacSwingOn,
838 pCoexDm->curDacSwingLvl
842 if ((pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
843 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl))
847 halbtc8723b2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
849 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
850 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
853 static void halbtc8723b2ant_SetAgcTable(
854 PBTC_COEXIST pBtCoexist, bool bAgcTableEn
857 u8 rssiAdjustVal = 0;
859 /* BB AGC Gain Table */
861 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB Agc Table On!\n"));
862 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e1A0001);
863 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d1B0001);
864 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6c1C0001);
865 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6b1D0001);
866 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1E0001);
867 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691F0001);
868 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68200001);
870 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB Agc Table Off!\n"));
871 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001);
872 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001);
873 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001);
874 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001);
875 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001);
876 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001);
877 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa4200001);
882 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
884 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
885 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff);
886 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe);
888 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
889 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3);
890 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6);
892 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
894 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1);
896 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
897 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff);
898 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe);
900 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
901 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3);
902 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6);
904 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0);
906 /* set rssiAdjustVal for wifi module. */
910 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
913 static void halbtc8723b2ant_AgcTable(
914 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bAgcTableEn
921 "[BTCoex], %s %s Agc Table\n",
922 (bForceExec ? "force to" : ""),
923 (bAgcTableEn ? "Enable" : "Disable")
926 pCoexDm->bCurAgcTableEn = bAgcTableEn;
931 ALGO_TRACE_SW_DETAIL,
933 "[BTCoex], bPreAgcTableEn =%d, bCurAgcTableEn =%d\n",
934 pCoexDm->bPreAgcTableEn,
935 pCoexDm->bCurAgcTableEn
939 if (pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
942 halbtc8723b2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
944 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
947 static void halbtc8723b2ant_SetCoexTable(
948 PBTC_COEXIST pBtCoexist,
958 ("[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0)
960 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
965 ("[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4)
967 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
972 ("[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8)
974 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
979 ("[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc)
981 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
984 static void halbtc8723b2ant_CoexTable(
985 PBTC_COEXIST pBtCoexist,
997 "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n",
998 (bForceExec ? "force to" : ""),
1005 pCoexDm->curVal0x6c0 = val0x6c0;
1006 pCoexDm->curVal0x6c4 = val0x6c4;
1007 pCoexDm->curVal0x6c8 = val0x6c8;
1008 pCoexDm->curVal0x6cc = val0x6cc;
1013 ALGO_TRACE_SW_DETAIL,
1015 "[BTCoex], preVal0x6c0 = 0x%x, preVal0x6c4 = 0x%x, preVal0x6c8 = 0x%x, preVal0x6cc = 0x%x !!\n",
1016 pCoexDm->preVal0x6c0,
1017 pCoexDm->preVal0x6c4,
1018 pCoexDm->preVal0x6c8,
1019 pCoexDm->preVal0x6cc
1024 ALGO_TRACE_SW_DETAIL,
1026 "[BTCoex], curVal0x6c0 = 0x%x, curVal0x6c4 = 0x%x, curVal0x6c8 = 0x%x, curVal0x6cc = 0x%x !!\n",
1027 pCoexDm->curVal0x6c0,
1028 pCoexDm->curVal0x6c4,
1029 pCoexDm->curVal0x6c8,
1030 pCoexDm->curVal0x6cc
1035 (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
1036 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
1037 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
1038 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc)
1042 halbtc8723b2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
1044 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
1045 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
1046 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
1047 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
1050 static void halbtc8723b2ant_CoexTableWithType(
1051 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
1056 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffff, 0x3);
1059 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
1062 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3);
1065 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff, 0x3);
1068 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffff, 0x3);
1071 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffff, 0x3);
1074 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3);
1077 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0xfafafafa, 0xffff, 0x3);
1080 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3);
1083 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aea5aea, 0xffff, 0x3);
1086 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aff5aff, 0xffff, 0x3);
1089 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5f5a5f, 0xffff, 0x3);
1092 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5f5f5f5f, 0xffff, 0x3);
1099 static void halbtc8723b2ant_SetFwIgnoreWlanAct(
1100 PBTC_COEXIST pBtCoexist, bool bEnable
1103 u8 H2C_Parameter[1] = {0};
1106 H2C_Parameter[0] |= BIT0; /* function enable */
1112 "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n",
1117 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
1120 static void halbtc8723b2ant_IgnoreWlanAct(
1121 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable
1128 "[BTCoex], %s turn Ignore WlanAct %s\n",
1129 (bForceExec ? "force to" : ""),
1130 (bEnable ? "ON" : "OFF")
1134 pCoexDm->bCurIgnoreWlanAct = bEnable;
1137 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
1138 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
1140 if (pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
1143 halbtc8723b2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
1145 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
1148 static void halbtc8723b2ant_SetFwPstdma(
1149 PBTC_COEXIST pBtCoexist,
1157 u8 H2C_Parameter[5] = {0};
1159 H2C_Parameter[0] = byte1;
1160 H2C_Parameter[1] = byte2;
1161 H2C_Parameter[2] = byte3;
1162 H2C_Parameter[3] = byte4;
1163 H2C_Parameter[4] = byte5;
1165 pCoexDm->psTdmaPara[0] = byte1;
1166 pCoexDm->psTdmaPara[1] = byte2;
1167 pCoexDm->psTdmaPara[2] = byte3;
1168 pCoexDm->psTdmaPara[3] = byte4;
1169 pCoexDm->psTdmaPara[4] = byte5;
1175 "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n",
1177 H2C_Parameter[1]<<24|
1178 H2C_Parameter[2]<<16|
1179 H2C_Parameter[3]<<8|
1184 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
1187 static void halbtc8723b2ant_SwMechanism1(
1188 PBTC_COEXIST pBtCoexist,
1192 bool bBTLNAConstrain
1195 halbtc8723b2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);
1196 halbtc8723b2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
1199 static void halbtc8723b2ant_SwMechanism2(
1200 PBTC_COEXIST pBtCoexist,
1201 bool bAGCTableShift,
1207 halbtc8723b2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);
1208 halbtc8723b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);
1211 static void halbtc8723b2ant_SetAntPath(
1212 PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
1215 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
1216 u32 fwVer = 0, u4Tmp = 0;
1217 bool bPgExtSwitch = false;
1218 bool bUseExtSwitch = false;
1219 u8 H2C_Parameter[2] = {0};
1221 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch);
1222 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); /* [31:16]=fw ver, [15:0]=fw sub ver */
1224 if ((fwVer > 0 && fwVer < 0xc0000) || bPgExtSwitch)
1225 bUseExtSwitch = true;
1228 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1);
1229 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff);
1230 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3);
1231 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77);
1232 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1);
1234 if (fwVer >= 0x180000) {
1235 /* Use H2C to set GNT_BT to LOW */
1236 H2C_Parameter[0] = 0;
1237 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
1239 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0);
1242 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
1244 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); /* WiFi TRx Mask off */
1245 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); /* BT TRx Mask off */
1247 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) {
1248 /* tell firmware "no antenna inverse" */
1249 H2C_Parameter[0] = 0;
1251 /* tell firmware "antenna inverse" */
1252 H2C_Parameter[0] = 1;
1255 if (bUseExtSwitch) {
1256 /* ext switch type */
1257 H2C_Parameter[1] = 1;
1259 /* int switch type */
1260 H2C_Parameter[1] = 0;
1262 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
1265 /* ext switch setting */
1266 if (bUseExtSwitch) {
1268 /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */
1269 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1272 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1275 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */
1276 switch (antPosType) {
1277 case BTC_ANT_WIFI_AT_MAIN:
1278 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); /* ext switch main at wifi */
1280 case BTC_ANT_WIFI_AT_AUX:
1281 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); /* ext switch aux at wifi */
1284 } else { /* internal switch */
1286 /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */
1287 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1290 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1293 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); /* fixed external switch S1->Main, S0->Aux */
1294 switch (antPosType) {
1295 case BTC_ANT_WIFI_AT_MAIN:
1296 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */
1298 case BTC_ANT_WIFI_AT_AUX:
1299 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); /* fixed internal switch S0->WiFi, S1->BT */
1305 static void halbtc8723b2ant_PsTdma(
1306 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
1313 "[BTCoex], %s turn %s PS TDMA, type =%d\n",
1314 (bForceExec ? "force to" : ""),
1315 (bTurnOn ? "ON" : "OFF"),
1319 pCoexDm->bCurPsTdmaOn = bTurnOn;
1320 pCoexDm->curPsTdma = type;
1325 ALGO_TRACE_FW_DETAIL,
1327 "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
1328 pCoexDm->bPrePsTdmaOn,
1329 pCoexDm->bCurPsTdmaOn
1334 ALGO_TRACE_FW_DETAIL,
1336 "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
1337 pCoexDm->prePsTdma, pCoexDm->curPsTdma
1342 (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
1343 (pCoexDm->prePsTdma == pCoexDm->curPsTdma)
1352 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1355 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
1358 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);
1361 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90);
1364 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
1367 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
1370 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);
1373 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90);
1376 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1379 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
1382 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90);
1385 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
1388 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
1391 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
1394 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90);
1397 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90);
1400 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90);
1403 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
1406 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90);
1409 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90);
1412 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);
1415 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1419 /* disable PS tdma */
1422 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
1425 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0);
1428 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
1433 /* update pre state */
1434 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1435 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1438 static void halbtc8723b2ant_CoexAllOff(PBTC_COEXIST pBtCoexist)
1441 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1442 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1443 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1446 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1447 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1450 /* pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); */
1451 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1454 static void halbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
1456 /* force to reset coex mechanism */
1458 halbtc8723b2ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 1);
1459 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
1460 halbtc8723b2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
1462 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1463 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1466 static void halbtc8723b2ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
1468 bool bWifiConnected = false;
1469 bool bLowPwrDisable = true;
1471 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1472 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1474 if (bWifiConnected) {
1475 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1476 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1478 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1479 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1482 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
1483 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1485 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1486 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1488 pCoexDm->bNeedRecover0x948 = true;
1489 pCoexDm->backup0x948 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
1491 halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, false, false);
1494 static bool halbtc8723b2ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
1496 u8 btRssiState = BTC_RSSI_STATE_HIGH;
1497 bool bCommon = false, bWifiConnected = false, bWifiBusy = false;
1498 bool bBtHsOn = false, bLowPwrDisable = false;
1500 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
1501 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1502 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
1504 if (!bWifiConnected) {
1505 bLowPwrDisable = false;
1506 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1507 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1509 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non-connected idle!!\n"));
1511 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1512 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1513 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1514 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1515 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1517 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1518 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1522 if (BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) {
1523 bLowPwrDisable = false;
1524 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1525 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1527 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
1529 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1530 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1531 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1532 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
1533 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1535 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1536 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1539 } else if (BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) {
1540 bLowPwrDisable = true;
1541 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1546 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
1547 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1549 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1550 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1551 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1552 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
1553 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1555 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1556 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1560 bLowPwrDisable = true;
1561 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1564 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
1570 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));
1571 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
1572 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1574 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1575 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1576 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 21);
1577 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);
1579 if (BTC_RSSI_HIGH(btRssiState))
1580 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1582 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1584 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1585 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1594 static void halbtc8723b2ant_TdmaDurationAdjust(
1595 PBTC_COEXIST pBtCoexist, bool bScoHid, bool bTxPause, u8 maxInterval
1598 static s32 up, dn, m, n, WaitCount;
1599 s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */
1602 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjust()\n"));
1604 if (!pCoexDm->bAutoTdmaAdjust) {
1605 pCoexDm->bAutoTdmaAdjust = true;
1606 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
1610 if (maxInterval == 1) {
1611 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1612 pCoexDm->psTdmaDuAdjType = 13;
1613 } else if (maxInterval == 2) {
1614 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1615 pCoexDm->psTdmaDuAdjType = 14;
1616 } else if (maxInterval == 3) {
1617 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1618 pCoexDm->psTdmaDuAdjType = 15;
1620 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1621 pCoexDm->psTdmaDuAdjType = 15;
1624 if (maxInterval == 1) {
1625 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1626 pCoexDm->psTdmaDuAdjType = 9;
1627 } else if (maxInterval == 2) {
1628 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1629 pCoexDm->psTdmaDuAdjType = 10;
1630 } else if (maxInterval == 3) {
1631 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1632 pCoexDm->psTdmaDuAdjType = 11;
1634 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1635 pCoexDm->psTdmaDuAdjType = 11;
1640 if (maxInterval == 1) {
1641 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1642 pCoexDm->psTdmaDuAdjType = 5;
1643 } else if (maxInterval == 2) {
1644 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1645 pCoexDm->psTdmaDuAdjType = 6;
1646 } else if (maxInterval == 3) {
1647 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1648 pCoexDm->psTdmaDuAdjType = 7;
1650 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1651 pCoexDm->psTdmaDuAdjType = 7;
1654 if (maxInterval == 1) {
1655 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1656 pCoexDm->psTdmaDuAdjType = 1;
1657 } else if (maxInterval == 2) {
1658 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1659 pCoexDm->psTdmaDuAdjType = 2;
1660 } else if (maxInterval == 3) {
1661 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1662 pCoexDm->psTdmaDuAdjType = 3;
1664 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1665 pCoexDm->psTdmaDuAdjType = 3;
1678 /* accquire the BT TRx retry count from BT_Info byte2 */
1679 retryCount = pCoexSta->btRetryCnt;
1680 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
1683 ALGO_TRACE_FW_DETAIL,
1685 "[BTCoex], up =%d, dn =%d, m =%d, n =%d, WaitCount =%d\n",
1686 up, dn, m, n, WaitCount
1692 if (retryCount == 0) { /* no retry in the last 2-second duration */
1699 if (up >= n) { /* if 連續 n 個2秒 retry count為0, 則調寬WiFi duration */
1705 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
1707 } else if (retryCount <= 3) { /* <=3 retry in the last 2-second duration */
1714 if (dn == 2) { /* if 連續 2 個2秒 retry count< 3, 則調窄WiFi duration */
1716 m++; /* 避免一直在兩個level中來回 */
1720 if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
1728 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
1730 } else { /* retry count > 3, 只要1次 retry count > 3, 則調窄WiFi duration */
1732 m++; /* 避免一直在兩個level中來回 */
1736 if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
1744 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
1747 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], max Interval = %d\n", maxInterval));
1748 if (maxInterval == 1) {
1750 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
1752 if (pCoexDm->curPsTdma == 71) {
1753 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1754 pCoexDm->psTdmaDuAdjType = 5;
1755 } else if (pCoexDm->curPsTdma == 1) {
1756 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1757 pCoexDm->psTdmaDuAdjType = 5;
1758 } else if (pCoexDm->curPsTdma == 2) {
1759 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1760 pCoexDm->psTdmaDuAdjType = 6;
1761 } else if (pCoexDm->curPsTdma == 3) {
1762 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1763 pCoexDm->psTdmaDuAdjType = 7;
1764 } else if (pCoexDm->curPsTdma == 4) {
1765 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1766 pCoexDm->psTdmaDuAdjType = 8;
1769 if (pCoexDm->curPsTdma == 9) {
1770 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1771 pCoexDm->psTdmaDuAdjType = 13;
1772 } else if (pCoexDm->curPsTdma == 10) {
1773 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1774 pCoexDm->psTdmaDuAdjType = 14;
1775 } else if (pCoexDm->curPsTdma == 11) {
1776 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1777 pCoexDm->psTdmaDuAdjType = 15;
1778 } else if (pCoexDm->curPsTdma == 12) {
1779 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1780 pCoexDm->psTdmaDuAdjType = 16;
1784 if (pCoexDm->curPsTdma == 5) {
1785 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1786 pCoexDm->psTdmaDuAdjType = 6;
1787 } else if (pCoexDm->curPsTdma == 6) {
1788 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1789 pCoexDm->psTdmaDuAdjType = 7;
1790 } else if (pCoexDm->curPsTdma == 7) {
1791 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1792 pCoexDm->psTdmaDuAdjType = 8;
1793 } else if (pCoexDm->curPsTdma == 13) {
1794 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1795 pCoexDm->psTdmaDuAdjType = 14;
1796 } else if (pCoexDm->curPsTdma == 14) {
1797 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1798 pCoexDm->psTdmaDuAdjType = 15;
1799 } else if (pCoexDm->curPsTdma == 15) {
1800 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1801 pCoexDm->psTdmaDuAdjType = 16;
1803 } else if (result == 1) {
1804 if (pCoexDm->curPsTdma == 8) {
1805 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1806 pCoexDm->psTdmaDuAdjType = 7;
1807 } else if (pCoexDm->curPsTdma == 7) {
1808 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1809 pCoexDm->psTdmaDuAdjType = 6;
1810 } else if (pCoexDm->curPsTdma == 6) {
1811 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
1812 pCoexDm->psTdmaDuAdjType = 5;
1813 } else if (pCoexDm->curPsTdma == 16) {
1814 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1815 pCoexDm->psTdmaDuAdjType = 15;
1816 } else if (pCoexDm->curPsTdma == 15) {
1817 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1818 pCoexDm->psTdmaDuAdjType = 14;
1819 } else if (pCoexDm->curPsTdma == 14) {
1820 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
1821 pCoexDm->psTdmaDuAdjType = 13;
1825 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
1826 if (pCoexDm->curPsTdma == 5) {
1827 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 71);
1828 pCoexDm->psTdmaDuAdjType = 71;
1829 } else if (pCoexDm->curPsTdma == 6) {
1830 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1831 pCoexDm->psTdmaDuAdjType = 2;
1832 } else if (pCoexDm->curPsTdma == 7) {
1833 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1834 pCoexDm->psTdmaDuAdjType = 3;
1835 } else if (pCoexDm->curPsTdma == 8) {
1836 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
1837 pCoexDm->psTdmaDuAdjType = 4;
1840 if (pCoexDm->curPsTdma == 13) {
1841 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1842 pCoexDm->psTdmaDuAdjType = 9;
1843 } else if (pCoexDm->curPsTdma == 14) {
1844 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1845 pCoexDm->psTdmaDuAdjType = 10;
1846 } else if (pCoexDm->curPsTdma == 15) {
1847 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1848 pCoexDm->psTdmaDuAdjType = 11;
1849 } else if (pCoexDm->curPsTdma == 16) {
1850 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
1851 pCoexDm->psTdmaDuAdjType = 12;
1855 if (pCoexDm->curPsTdma == 71) {
1856 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1857 pCoexDm->psTdmaDuAdjType = 1;
1858 } else if (pCoexDm->curPsTdma == 1) {
1859 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1860 pCoexDm->psTdmaDuAdjType = 2;
1861 } else if (pCoexDm->curPsTdma == 2) {
1862 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1863 pCoexDm->psTdmaDuAdjType = 3;
1864 } else if (pCoexDm->curPsTdma == 3) {
1865 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
1866 pCoexDm->psTdmaDuAdjType = 4;
1867 } else if (pCoexDm->curPsTdma == 9) {
1868 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1869 pCoexDm->psTdmaDuAdjType = 10;
1870 } else if (pCoexDm->curPsTdma == 10) {
1871 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1872 pCoexDm->psTdmaDuAdjType = 11;
1873 } else if (pCoexDm->curPsTdma == 11) {
1874 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
1875 pCoexDm->psTdmaDuAdjType = 12;
1877 } else if (result == 1) {
1878 if (pCoexDm->curPsTdma == 4) {
1879 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1880 pCoexDm->psTdmaDuAdjType = 3;
1881 } else if (pCoexDm->curPsTdma == 3) {
1882 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1883 pCoexDm->psTdmaDuAdjType = 2;
1884 } else if (pCoexDm->curPsTdma == 2) {
1885 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
1886 pCoexDm->psTdmaDuAdjType = 1;
1887 } else if (pCoexDm->curPsTdma == 1) {
1888 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 71);
1889 pCoexDm->psTdmaDuAdjType = 71;
1890 } else if (pCoexDm->curPsTdma == 12) {
1891 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1892 pCoexDm->psTdmaDuAdjType = 11;
1893 } else if (pCoexDm->curPsTdma == 11) {
1894 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1895 pCoexDm->psTdmaDuAdjType = 10;
1896 } else if (pCoexDm->curPsTdma == 10) {
1897 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
1898 pCoexDm->psTdmaDuAdjType = 9;
1902 } else if (maxInterval == 2) {
1904 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
1905 if (pCoexDm->curPsTdma == 1) {
1906 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1907 pCoexDm->psTdmaDuAdjType = 6;
1908 } else if (pCoexDm->curPsTdma == 2) {
1909 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1910 pCoexDm->psTdmaDuAdjType = 6;
1911 } else if (pCoexDm->curPsTdma == 3) {
1912 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1913 pCoexDm->psTdmaDuAdjType = 7;
1914 } else if (pCoexDm->curPsTdma == 4) {
1915 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1916 pCoexDm->psTdmaDuAdjType = 8;
1919 if (pCoexDm->curPsTdma == 9) {
1920 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1921 pCoexDm->psTdmaDuAdjType = 14;
1922 } else if (pCoexDm->curPsTdma == 10) {
1923 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1924 pCoexDm->psTdmaDuAdjType = 14;
1925 } else if (pCoexDm->curPsTdma == 11) {
1926 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1927 pCoexDm->psTdmaDuAdjType = 15;
1928 } else if (pCoexDm->curPsTdma == 12) {
1929 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1930 pCoexDm->psTdmaDuAdjType = 16;
1934 if (pCoexDm->curPsTdma == 5) {
1935 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1936 pCoexDm->psTdmaDuAdjType = 6;
1937 } else if (pCoexDm->curPsTdma == 6) {
1938 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1939 pCoexDm->psTdmaDuAdjType = 7;
1940 } else if (pCoexDm->curPsTdma == 7) {
1941 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
1942 pCoexDm->psTdmaDuAdjType = 8;
1943 } else if (pCoexDm->curPsTdma == 13) {
1944 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1945 pCoexDm->psTdmaDuAdjType = 14;
1946 } else if (pCoexDm->curPsTdma == 14) {
1947 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1948 pCoexDm->psTdmaDuAdjType = 15;
1949 } else if (pCoexDm->curPsTdma == 15) {
1950 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
1951 pCoexDm->psTdmaDuAdjType = 16;
1953 } else if (result == 1) {
1954 if (pCoexDm->curPsTdma == 8) {
1955 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1956 pCoexDm->psTdmaDuAdjType = 7;
1957 } else if (pCoexDm->curPsTdma == 7) {
1958 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1959 pCoexDm->psTdmaDuAdjType = 6;
1960 } else if (pCoexDm->curPsTdma == 6) {
1961 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
1962 pCoexDm->psTdmaDuAdjType = 6;
1963 } else if (pCoexDm->curPsTdma == 16) {
1964 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1965 pCoexDm->psTdmaDuAdjType = 15;
1966 } else if (pCoexDm->curPsTdma == 15) {
1967 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1968 pCoexDm->psTdmaDuAdjType = 14;
1969 } else if (pCoexDm->curPsTdma == 14) {
1970 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
1971 pCoexDm->psTdmaDuAdjType = 14;
1975 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
1976 if (pCoexDm->curPsTdma == 5) {
1977 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1978 pCoexDm->psTdmaDuAdjType = 2;
1979 } else if (pCoexDm->curPsTdma == 6) {
1980 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
1981 pCoexDm->psTdmaDuAdjType = 2;
1982 } else if (pCoexDm->curPsTdma == 7) {
1983 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1984 pCoexDm->psTdmaDuAdjType = 3;
1985 } else if (pCoexDm->curPsTdma == 8) {
1986 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
1987 pCoexDm->psTdmaDuAdjType = 4;
1990 if (pCoexDm->curPsTdma == 13) {
1991 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1992 pCoexDm->psTdmaDuAdjType = 10;
1993 } else if (pCoexDm->curPsTdma == 14) {
1994 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
1995 pCoexDm->psTdmaDuAdjType = 10;
1996 } else if (pCoexDm->curPsTdma == 15) {
1997 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1998 pCoexDm->psTdmaDuAdjType = 11;
1999 } else if (pCoexDm->curPsTdma == 16) {
2000 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2001 pCoexDm->psTdmaDuAdjType = 12;
2005 if (pCoexDm->curPsTdma == 1) {
2006 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2007 pCoexDm->psTdmaDuAdjType = 2;
2008 } else if (pCoexDm->curPsTdma == 2) {
2009 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2010 pCoexDm->psTdmaDuAdjType = 3;
2011 } else if (pCoexDm->curPsTdma == 3) {
2012 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2013 pCoexDm->psTdmaDuAdjType = 4;
2014 } else if (pCoexDm->curPsTdma == 9) {
2015 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2016 pCoexDm->psTdmaDuAdjType = 10;
2017 } else if (pCoexDm->curPsTdma == 10) {
2018 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2019 pCoexDm->psTdmaDuAdjType = 11;
2020 } else if (pCoexDm->curPsTdma == 11) {
2021 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2022 pCoexDm->psTdmaDuAdjType = 12;
2024 } else if (result == 1) {
2025 if (pCoexDm->curPsTdma == 4) {
2026 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2027 pCoexDm->psTdmaDuAdjType = 3;
2028 } else if (pCoexDm->curPsTdma == 3) {
2029 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2030 pCoexDm->psTdmaDuAdjType = 2;
2031 } else if (pCoexDm->curPsTdma == 2) {
2032 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
2033 pCoexDm->psTdmaDuAdjType = 2;
2034 } else if (pCoexDm->curPsTdma == 12) {
2035 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2036 pCoexDm->psTdmaDuAdjType = 11;
2037 } else if (pCoexDm->curPsTdma == 11) {
2038 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2039 pCoexDm->psTdmaDuAdjType = 10;
2040 } else if (pCoexDm->curPsTdma == 10) {
2041 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
2042 pCoexDm->psTdmaDuAdjType = 10;
2046 } else if (maxInterval == 3) {
2048 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
2049 if (pCoexDm->curPsTdma == 1) {
2050 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2051 pCoexDm->psTdmaDuAdjType = 7;
2052 } else if (pCoexDm->curPsTdma == 2) {
2053 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2054 pCoexDm->psTdmaDuAdjType = 7;
2055 } else if (pCoexDm->curPsTdma == 3) {
2056 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2057 pCoexDm->psTdmaDuAdjType = 7;
2058 } else if (pCoexDm->curPsTdma == 4) {
2059 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2060 pCoexDm->psTdmaDuAdjType = 8;
2063 if (pCoexDm->curPsTdma == 9) {
2064 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2065 pCoexDm->psTdmaDuAdjType = 15;
2066 } else if (pCoexDm->curPsTdma == 10) {
2067 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2068 pCoexDm->psTdmaDuAdjType = 15;
2069 } else if (pCoexDm->curPsTdma == 11) {
2070 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2071 pCoexDm->psTdmaDuAdjType = 15;
2072 } else if (pCoexDm->curPsTdma == 12) {
2073 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
2074 pCoexDm->psTdmaDuAdjType = 16;
2078 if (pCoexDm->curPsTdma == 5) {
2079 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2080 pCoexDm->psTdmaDuAdjType = 7;
2081 } else if (pCoexDm->curPsTdma == 6) {
2082 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2083 pCoexDm->psTdmaDuAdjType = 7;
2084 } else if (pCoexDm->curPsTdma == 7) {
2085 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
2086 pCoexDm->psTdmaDuAdjType = 8;
2087 } else if (pCoexDm->curPsTdma == 13) {
2088 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2089 pCoexDm->psTdmaDuAdjType = 15;
2090 } else if (pCoexDm->curPsTdma == 14) {
2091 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2092 pCoexDm->psTdmaDuAdjType = 15;
2093 } else if (pCoexDm->curPsTdma == 15) {
2094 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
2095 pCoexDm->psTdmaDuAdjType = 16;
2097 } else if (result == 1) {
2098 if (pCoexDm->curPsTdma == 8) {
2099 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2100 pCoexDm->psTdmaDuAdjType = 7;
2101 } else if (pCoexDm->curPsTdma == 7) {
2102 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2103 pCoexDm->psTdmaDuAdjType = 7;
2104 } else if (pCoexDm->curPsTdma == 6) {
2105 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
2106 pCoexDm->psTdmaDuAdjType = 7;
2107 } else if (pCoexDm->curPsTdma == 16) {
2108 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2109 pCoexDm->psTdmaDuAdjType = 15;
2110 } else if (pCoexDm->curPsTdma == 15) {
2111 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2112 pCoexDm->psTdmaDuAdjType = 15;
2113 } else if (pCoexDm->curPsTdma == 14) {
2114 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
2115 pCoexDm->psTdmaDuAdjType = 15;
2119 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
2120 if (pCoexDm->curPsTdma == 5) {
2121 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2122 pCoexDm->psTdmaDuAdjType = 3;
2123 } else if (pCoexDm->curPsTdma == 6) {
2124 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2125 pCoexDm->psTdmaDuAdjType = 3;
2126 } else if (pCoexDm->curPsTdma == 7) {
2127 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2128 pCoexDm->psTdmaDuAdjType = 3;
2129 } else if (pCoexDm->curPsTdma == 8) {
2130 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2131 pCoexDm->psTdmaDuAdjType = 4;
2134 if (pCoexDm->curPsTdma == 13) {
2135 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2136 pCoexDm->psTdmaDuAdjType = 11;
2137 } else if (pCoexDm->curPsTdma == 14) {
2138 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2139 pCoexDm->psTdmaDuAdjType = 11;
2140 } else if (pCoexDm->curPsTdma == 15) {
2141 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2142 pCoexDm->psTdmaDuAdjType = 11;
2143 } else if (pCoexDm->curPsTdma == 16) {
2144 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2145 pCoexDm->psTdmaDuAdjType = 12;
2149 if (pCoexDm->curPsTdma == 1) {
2150 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2151 pCoexDm->psTdmaDuAdjType = 3;
2152 } else if (pCoexDm->curPsTdma == 2) {
2153 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2154 pCoexDm->psTdmaDuAdjType = 3;
2155 } else if (pCoexDm->curPsTdma == 3) {
2156 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
2157 pCoexDm->psTdmaDuAdjType = 4;
2158 } else if (pCoexDm->curPsTdma == 9) {
2159 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2160 pCoexDm->psTdmaDuAdjType = 11;
2161 } else if (pCoexDm->curPsTdma == 10) {
2162 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2163 pCoexDm->psTdmaDuAdjType = 11;
2164 } else if (pCoexDm->curPsTdma == 11) {
2165 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
2166 pCoexDm->psTdmaDuAdjType = 12;
2168 } else if (result == 1) {
2169 if (pCoexDm->curPsTdma == 4) {
2170 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2171 pCoexDm->psTdmaDuAdjType = 3;
2172 } else if (pCoexDm->curPsTdma == 3) {
2173 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2174 pCoexDm->psTdmaDuAdjType = 3;
2175 } else if (pCoexDm->curPsTdma == 2) {
2176 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
2177 pCoexDm->psTdmaDuAdjType = 3;
2178 } else if (pCoexDm->curPsTdma == 12) {
2179 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2180 pCoexDm->psTdmaDuAdjType = 11;
2181 } else if (pCoexDm->curPsTdma == 11) {
2182 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2183 pCoexDm->psTdmaDuAdjType = 11;
2184 } else if (pCoexDm->curPsTdma == 10) {
2185 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
2186 pCoexDm->psTdmaDuAdjType = 11;
2193 /* if current PsTdma not match with the recorded one (when scan, dhcp...), */
2194 /* then we have to adjust it back to the previous record one. */
2195 if (pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) {
2196 bool bScan = false, bLink = false, bRoam = false;
2199 ALGO_TRACE_FW_DETAIL,
2201 "[BTCoex], PsTdma type dismatch!!!, curPsTdma =%d, recordPsTdma =%d\n",
2203 pCoexDm->psTdmaDuAdjType
2207 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
2208 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
2209 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
2211 if (!bScan && !bLink && !bRoam)
2212 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType);
2214 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
2219 /* SCO only or SCO+PAN(HS) */
2220 static void halbtc8723b2ant_ActionSco(PBTC_COEXIST pBtCoexist)
2222 u8 wifiRssiState, btRssiState;
2225 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2226 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2228 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2230 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2232 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4);
2234 if (BTC_RSSI_HIGH(btRssiState))
2235 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2237 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2239 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2241 if (BTC_WIFI_BW_LEGACY == wifiBw) /* for SCO quality at 11b/g mode */
2242 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2243 else /* for SCO quality & wifi performance balance at 11n mode */
2244 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
2246 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0); /* for voice quality */
2249 if (BTC_WIFI_BW_HT40 == wifiBw) {
2251 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2252 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2254 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2255 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4);
2257 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2258 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4);
2262 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2263 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2265 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2266 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4);
2268 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2269 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4);
2275 static void halbtc8723b2ant_ActionHid(PBTC_COEXIST pBtCoexist)
2277 u8 wifiRssiState, btRssiState;
2280 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2281 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2283 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2285 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2287 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2289 if (BTC_RSSI_HIGH(btRssiState))
2290 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2292 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2294 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2296 if (BTC_WIFI_BW_LEGACY == wifiBw) /* for HID at 11b/g mode */
2297 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2298 else /* for HID quality & wifi performance balance at 11n mode */
2299 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 9);
2302 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2303 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2305 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
2307 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
2310 if (BTC_WIFI_BW_HT40 == wifiBw) {
2312 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2313 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2315 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2316 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2318 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2319 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2323 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2324 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2326 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2327 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2329 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2330 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2335 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
2336 static void halbtc8723b2ant_ActionA2dp(PBTC_COEXIST pBtCoexist)
2338 u8 wifiRssiState, wifiRssiState1, btRssiState;
2342 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2343 wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, 40, 0);
2344 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2346 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
2348 /* define the office environment */
2349 if (apNum >= 10 && BTC_RSSI_HIGH(wifiRssiState1)) {
2350 /* DbgPrint(" AP#>10(%d)\n", apNum); */
2351 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2352 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2353 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2354 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2355 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2356 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
2359 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2360 if (BTC_WIFI_BW_HT40 == wifiBw) {
2361 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2362 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x18);
2364 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2365 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x18);
2370 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2371 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2373 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2375 if (BTC_RSSI_HIGH(btRssiState))
2376 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2378 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2380 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2383 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2384 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2386 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 1);
2388 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 1);
2391 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2392 if (BTC_WIFI_BW_HT40 == wifiBw) {
2394 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2395 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2397 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2398 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2400 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2401 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2405 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2406 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2408 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2409 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2411 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2412 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2417 static void halbtc8723b2ant_ActionA2dpPanHs(PBTC_COEXIST pBtCoexist)
2419 u8 wifiRssiState, btRssiState;
2422 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2423 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2425 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2427 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2429 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2431 if (BTC_RSSI_HIGH(btRssiState))
2432 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2434 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2436 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2438 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 2);
2441 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2442 if (BTC_WIFI_BW_HT40 == wifiBw) {
2444 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2445 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2447 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2448 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2450 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2451 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2455 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2456 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2458 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2459 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2461 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2462 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2467 static void halbtc8723b2ant_ActionPanEdr(PBTC_COEXIST pBtCoexist)
2469 u8 wifiRssiState, btRssiState;
2472 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2473 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2475 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2477 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2479 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2481 if (BTC_RSSI_HIGH(btRssiState))
2482 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2484 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2486 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10);
2489 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2490 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2492 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
2494 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
2497 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2498 if (BTC_WIFI_BW_HT40 == wifiBw) {
2500 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2501 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2503 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2504 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2506 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2507 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2511 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2512 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2514 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2515 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2517 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2518 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2525 static void halbtc8723b2ant_ActionPanHs(PBTC_COEXIST pBtCoexist)
2527 u8 wifiRssiState, btRssiState;
2530 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2531 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2533 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2535 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2537 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2539 if (BTC_RSSI_HIGH(btRssiState))
2540 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2542 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2544 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2546 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
2548 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2549 if (BTC_WIFI_BW_HT40 == wifiBw) {
2551 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2552 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2554 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2555 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2557 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2558 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2562 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2563 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2565 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2566 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2568 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2569 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2575 static void halbtc8723b2ant_ActionPanEdrA2dp(PBTC_COEXIST pBtCoexist)
2577 u8 wifiRssiState, btRssiState;
2580 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2581 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2583 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2585 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2587 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2589 if (BTC_RSSI_HIGH(btRssiState))
2590 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2592 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2594 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2597 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2598 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2600 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12);
2601 if (BTC_WIFI_BW_HT40 == wifiBw)
2602 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3);
2604 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 3);
2606 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2607 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3);
2611 if (BTC_WIFI_BW_HT40 == wifiBw) {
2613 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2614 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2616 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2617 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2619 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2620 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2624 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2625 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2627 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2628 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2630 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2631 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2636 static void halbtc8723b2ant_ActionPanEdrHid(PBTC_COEXIST pBtCoexist)
2638 u8 wifiRssiState, btRssiState;
2641 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2642 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2643 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2645 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2647 if (BTC_RSSI_HIGH(btRssiState))
2648 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2650 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2653 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2654 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2656 if (BTC_WIFI_BW_HT40 == wifiBw) {
2657 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3);
2658 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11);
2659 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780);
2661 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2662 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2663 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2665 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2);
2667 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2668 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11);
2669 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2670 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2674 if (BTC_WIFI_BW_HT40 == wifiBw) {
2676 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2677 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2679 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2680 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2682 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2683 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2687 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2688 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2690 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2691 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2693 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2694 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2699 /* HID+A2DP+PAN(EDR) */
2700 static void halbtc8723b2ant_ActionHidA2dpPanEdr(PBTC_COEXIST pBtCoexist)
2702 u8 wifiRssiState, btRssiState;
2705 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2706 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2708 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2710 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2712 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2714 if (BTC_RSSI_HIGH(btRssiState))
2715 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2717 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2719 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2721 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2724 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2725 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2727 if (BTC_WIFI_BW_HT40 == wifiBw)
2728 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2730 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 3);
2732 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 3);
2735 if (BTC_WIFI_BW_HT40 == wifiBw) {
2737 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2738 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2740 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2741 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2743 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2744 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2748 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2749 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2751 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2752 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2754 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2755 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2760 static void halbtc8723b2ant_ActionHidA2dp(PBTC_COEXIST pBtCoexist)
2762 u8 wifiRssiState, btRssiState;
2766 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2767 /* btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); */
2768 btRssiState = halbtc8723b2ant_BtRssiState(3, 29, 37);
2770 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2772 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, true, 0x5);
2774 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2776 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2777 if (BTC_WIFI_BW_LEGACY == wifiBw) {
2778 if (BTC_RSSI_HIGH(btRssiState))
2779 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2780 else if (BTC_RSSI_MEDIUM(btRssiState))
2781 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2783 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2785 /* only 802.11N mode we have to dec bt power to 4 degree */
2786 if (BTC_RSSI_HIGH(btRssiState)) {
2787 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
2788 /* need to check ap Number of Not */
2790 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
2792 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2793 } else if (BTC_RSSI_MEDIUM(btRssiState))
2794 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2796 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2799 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2802 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2803 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2805 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2);
2807 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2810 if (BTC_WIFI_BW_HT40 == wifiBw) {
2812 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2813 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2815 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2816 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2818 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2819 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2823 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2824 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2826 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2827 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2829 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2830 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2835 static void halbtc8723b2ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
2839 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism() ===>\n"));
2841 if (pBtCoexist->bManualControl) {
2842 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
2846 if (pCoexSta->bUnderIps) {
2847 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
2851 algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist);
2852 if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
2853 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT is under inquiry/page scan !!\n"));
2854 halbtc8723b2ant_ActionBtInquiry(pBtCoexist);
2857 if (pCoexDm->bNeedRecover0x948) {
2858 pCoexDm->bNeedRecover0x948 = false;
2859 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, pCoexDm->backup0x948);
2863 pCoexDm->curAlgorithm = algorithm;
2864 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Algorithm = %d\n", pCoexDm->curAlgorithm));
2866 if (halbtc8723b2ant_IsCommonAction(pBtCoexist)) {
2867 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant common.\n"));
2868 pCoexDm->bAutoTdmaAdjust = false;
2870 if (pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) {
2875 "[BTCoex], preAlgorithm =%d, curAlgorithm =%d\n",
2876 pCoexDm->preAlgorithm,
2877 pCoexDm->curAlgorithm
2880 pCoexDm->bAutoTdmaAdjust = false;
2884 switch (pCoexDm->curAlgorithm) {
2885 case BT_8723B_2ANT_COEX_ALGO_SCO:
2886 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n"));
2887 halbtc8723b2ant_ActionSco(pBtCoexist);
2889 case BT_8723B_2ANT_COEX_ALGO_HID:
2890 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID.\n"));
2891 halbtc8723b2ant_ActionHid(pBtCoexist);
2893 case BT_8723B_2ANT_COEX_ALGO_A2DP:
2894 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n"));
2895 halbtc8723b2ant_ActionA2dp(pBtCoexist);
2897 case BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS:
2898 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n"));
2899 halbtc8723b2ant_ActionA2dpPanHs(pBtCoexist);
2901 case BT_8723B_2ANT_COEX_ALGO_PANEDR:
2902 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"));
2903 halbtc8723b2ant_ActionPanEdr(pBtCoexist);
2905 case BT_8723B_2ANT_COEX_ALGO_PANHS:
2906 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n"));
2907 halbtc8723b2ant_ActionPanHs(pBtCoexist);
2909 case BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP:
2910 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"));
2911 halbtc8723b2ant_ActionPanEdrA2dp(pBtCoexist);
2913 case BT_8723B_2ANT_COEX_ALGO_PANEDR_HID:
2914 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
2915 halbtc8723b2ant_ActionPanEdrHid(pBtCoexist);
2917 case BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
2918 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
2919 halbtc8723b2ant_ActionHidA2dpPanEdr(pBtCoexist);
2921 case BT_8723B_2ANT_COEX_ALGO_HID_A2DP:
2922 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"));
2923 halbtc8723b2ant_ActionHidA2dp(pBtCoexist);
2926 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"));
2927 halbtc8723b2ant_CoexAllOff(pBtCoexist);
2930 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
2934 static void halbtc8723b2ant_WifiOffHwCfg(PBTC_COEXIST pBtCoexist)
2936 bool bIsInMpMode = false;
2937 u8 H2C_Parameter[2] = {0};
2940 /* set wlan_act to low */
2941 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
2943 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); /* WiFi goto standby while GNT_BT 0-->1 */
2944 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
2945 if (fwVer >= 0x180000) {
2946 /* Use H2C to set GNT_BT to HIGH */
2947 H2C_Parameter[0] = 1;
2948 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
2950 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
2952 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode);
2954 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); /* BT select s0/s1 is controlled by BT */
2956 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); /* BT select s0/s1 is controlled by WiFi */
2959 static void halbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bBackUp)
2963 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 2Ant Init HW Config!!\n"));
2965 /* backup rf 0x1e value */
2966 pCoexDm->btRf0x1eBackup =
2967 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
2969 /* 0x790[5:0]= 0x5 */
2970 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
2973 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
2975 /* Antenna config */
2976 halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, true, false);
2979 halbtc8723b2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
2981 /* Enable counter statistics */
2982 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); /* 0x76e[3] = 1, WLAN_Act control by PTA */
2983 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);
2984 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
2988 /* work around function start with wa_halbtc8723b2ant_ */
2991 /* extern function start with EXhalbtc8723b2ant_ */
2993 void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
2995 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
2996 u8 u1Tmp = 0x4; /* Set BIT2 by default since it's 2ant case */
2999 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20);
3001 /* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. */
3002 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
3003 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1);
3005 /* set GRAN_BT = 1 */
3006 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
3007 /* set WLAN_ACT = 0 */
3008 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
3011 /* S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) */
3012 /* Local setting bit define */
3013 /* BIT0: "0" for no antenna inverse; "1" for antenna inverse */
3014 /* BIT1: "0" for internal switch; "1" for external switch */
3015 /* BIT2: "0" for one antenna; "1" for two antenna */
3016 /* NOTE: here default all internal switch and 1-antenna ==> BIT1 = 0 and BIT2 = 0 */
3017 if (pBtCoexist->chipInterface == BTC_INTF_USB) {
3018 /* fixed at S0 for USB interface */
3019 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
3021 u1Tmp |= 0x1; /* antenna inverse */
3022 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);
3024 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
3026 /* for PCIE and SDIO interface, we check efuse 0xc3[6] */
3027 if (pBoardInfo->singleAntPath == 0) {
3029 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
3030 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
3031 } else if (pBoardInfo->singleAntPath == 1) {
3033 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
3034 u1Tmp |= 0x1; /* antenna inverse */
3035 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
3038 if (pBtCoexist->chipInterface == BTC_INTF_PCI)
3039 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp);
3040 else if (pBtCoexist->chipInterface == BTC_INTF_SDIO)
3041 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp);
3045 void EXhalbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly)
3047 halbtc8723b2ant_InitHwConfig(pBtCoexist, true);
3050 void EXhalbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
3052 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
3054 halbtc8723b2ant_InitCoexDm(pBtCoexist);
3057 void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
3059 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
3060 PBTC_STACK_INFO pStackInfo = &pBtCoexist->stackInfo;
3061 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
3062 u8 *cliBuf = pBtCoexist->cliBuf;
3063 u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0;
3065 bool bRoam = false, bScan = false, bLink = false, bWifiUnder5G = false;
3066 bool bBtHsOn = false, bWifiBusy = false;
3067 s32 wifiRssi = 0, btHsRssi = 0;
3068 u32 wifiBw, wifiTrafficDir, faOfdm, faCck;
3069 u8 wifiDot11Chnl, wifiHsChnl;
3070 u32 fwVer = 0, btPatchVer = 0;
3073 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
3076 if (pBtCoexist->bManualControl) {
3077 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
3079 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
3086 "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
3087 pBoardInfo->pgAntNum,
3088 pBoardInfo->btdmAntNum
3095 "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
3096 (pStackInfo->bProfileNotified ? "Yes" : "No"),
3097 pStackInfo->hciVersion
3101 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
3102 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
3103 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
3104 GLCoexVerDate8723b2Ant, GLCoexVer8723b2Ant, fwVer, btPatchVer, btPatchVer);
3107 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
3108 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
3109 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
3113 "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
3123 "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
3124 pCoexDm->wifiChnlInfo[0],
3125 pCoexDm->wifiChnlInfo[1],
3126 pCoexDm->wifiChnlInfo[2]
3130 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
3131 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
3132 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
3136 "\r\n %-35s = %d/ %d/ %d", "Wifi rssi/ HS rssi/ AP#", \
3143 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
3144 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
3145 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
3149 "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
3156 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
3157 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3158 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
3159 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
3163 "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
3164 (bWifiUnder5G ? "5G" : "2.4G"),
3165 ((BTC_WIFI_BW_LEGACY == wifiBw) ? "Legacy" : (((BTC_WIFI_BW_HT40 == wifiBw) ? "HT40" : "HT20"))),
3166 ((!bWifiBusy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) ? "uplink" : "downlink"))
3173 "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
3174 ((pBtCoexist->btInfo.bBtDisabled) ? ("disabled") : ((pCoexSta->bC2hBtInquiryPage) ? ("inquiry/page scan") : ((BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ? "non-connected idle" :
3175 ((BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ? "connected-idle" : "busy")))),
3177 pCoexSta->btRetryCnt
3184 "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
3185 pBtLinkInfo->bScoExist,
3186 pBtLinkInfo->bHidExist,
3187 pBtLinkInfo->bPanExist,
3188 pBtLinkInfo->bA2dpExist
3191 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
3193 btInfoExt = pCoexSta->btInfoExt;
3197 "\r\n %-35s = %s", "BT Info A2DP rate", \
3198 (btInfoExt&BIT0) ? "Basic rate" : "EDR rate"
3202 for (i = 0; i < BT_INFO_SRC_8723B_2ANT_MAX; i++) {
3203 if (pCoexSta->btInfoC2hCnt[i]) {
3207 "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b2Ant[i], \
3208 pCoexSta->btInfoC2h[i][0],
3209 pCoexSta->btInfoC2h[i][1],
3210 pCoexSta->btInfoC2h[i][2],
3211 pCoexSta->btInfoC2h[i][3],
3212 pCoexSta->btInfoC2h[i][4],
3213 pCoexSta->btInfoC2h[i][5],
3214 pCoexSta->btInfoC2h[i][6],
3215 pCoexSta->btInfoC2hCnt[i]
3224 "\r\n %-35s = %s/%s", "PS state, IPS/LPS", \
3225 ((pCoexSta->bUnderIps ? "IPS ON" : "IPS OFF")),
3226 ((pCoexSta->bUnderLps ? "LPS ON" : "LPS OFF"))
3229 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
3235 "\r\n %-35s", "============[Sw mechanism]============"
3241 "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \
3242 pCoexDm->bCurRfRxLpfShrink,
3243 pCoexDm->bCurLowPenaltyRa,
3244 pCoexDm->bLimitedDig
3250 "\r\n %-35s = %d/ %d/ %d(0x%x) ",
3251 "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
3252 pCoexDm->bCurAgcTableEn,
3253 pCoexDm->bCurAdcBackOff,
3254 pCoexDm->bCurDacSwingOn,
3255 pCoexDm->curDacSwingLvl
3260 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
3263 psTdmaCase = pCoexDm->curPsTdma;
3267 "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
3268 pCoexDm->psTdmaPara[0],
3269 pCoexDm->psTdmaPara[1],
3270 pCoexDm->psTdmaPara[2],
3271 pCoexDm->psTdmaPara[3],
3272 pCoexDm->psTdmaPara[4],
3273 psTdmaCase, pCoexDm->bAutoTdmaAdjust
3280 "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
3281 pCoexDm->curBtDecPwrLvl,
3282 pCoexDm->bCurIgnoreWlanAct
3287 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
3293 "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
3294 pCoexDm->btRf0x1eBackup
3298 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
3299 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
3303 "\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \
3305 (u4Tmp[0]&0x3e000000) >> 25
3310 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
3311 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
3312 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
3316 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \
3318 ((u1Tmp[0]&0x20)>>5),
3323 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c);
3324 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
3325 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944);
3329 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \
3337 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39);
3338 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
3339 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
3340 u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64);
3344 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \
3345 ((u1Tmp[0] & 0x8)>>3),
3347 ((u4Tmp[0]&0x01800000)>>23),
3352 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
3353 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
3357 "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
3363 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
3364 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c);
3368 "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
3374 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);
3375 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);
3376 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);
3377 u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0);
3379 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b);
3380 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
3383 ((u4Tmp[0]&0xffff0000) >> 16) +
3384 ((u4Tmp[1]&0xffff0000) >> 16) +
3385 (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \
3386 ((u4Tmp[3]&0xffff0000) >> 16) +
3387 (u4Tmp[3] & 0xffff);
3389 faCck = (u1Tmp[0] << 8) + u1Tmp[1];
3394 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
3401 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
3402 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
3403 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
3404 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
3408 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
3419 "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \
3420 pCoexSta->highPriorityRx,
3421 pCoexSta->highPriorityTx
3427 "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \
3428 pCoexSta->lowPriorityRx,
3429 pCoexSta->lowPriorityTx
3433 halbtc8723b2ant_MonitorBtCtr(pBtCoexist);
3434 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
3438 void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
3440 if (BTC_IPS_ENTER == type) {
3441 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
3442 pCoexSta->bUnderIps = true;
3443 halbtc8723b2ant_WifiOffHwCfg(pBtCoexist);
3444 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
3445 halbtc8723b2ant_CoexAllOff(pBtCoexist);
3446 } else if (BTC_IPS_LEAVE == type) {
3447 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
3448 pCoexSta->bUnderIps = false;
3449 halbtc8723b2ant_InitHwConfig(pBtCoexist, false);
3450 halbtc8723b2ant_InitCoexDm(pBtCoexist);
3451 halbtc8723b2ant_QueryBtInfo(pBtCoexist);
3455 void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
3457 if (BTC_LPS_ENABLE == type) {
3458 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
3459 pCoexSta->bUnderLps = true;
3460 } else if (BTC_LPS_DISABLE == type) {
3461 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
3462 pCoexSta->bUnderLps = false;
3466 void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
3468 if (BTC_SCAN_START == type) {
3469 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
3470 } else if (BTC_SCAN_FINISH == type) {
3471 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
3475 void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
3477 if (BTC_ASSOCIATE_START == type) {
3478 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
3479 } else if (BTC_ASSOCIATE_FINISH == type) {
3480 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
3484 void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
3486 u8 H2C_Parameter[3] = {0};
3491 if (BTC_MEDIA_CONNECT == type) {
3492 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
3494 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
3497 /* only 2.4G we need to inform bt the chnl mask */
3498 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
3499 if ((BTC_MEDIA_CONNECT == type) && (wifiCentralChnl <= 14)) {
3500 H2C_Parameter[0] = 0x1;
3501 H2C_Parameter[1] = wifiCentralChnl;
3502 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3503 if (BTC_WIFI_BW_HT40 == wifiBw)
3504 H2C_Parameter[2] = 0x30;
3506 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
3508 H2C_Parameter[2] = 0x30;
3510 H2C_Parameter[2] = 0x20;
3514 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
3515 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
3516 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
3522 "[BTCoex], FW write 0x66 = 0x%x\n",
3523 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]
3527 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
3530 void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
3532 if (type == BTC_PACKET_DHCP) {
3533 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
3537 void EXhalbtc8723b2ant_BtInfoNotify(
3538 PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
3542 u8 i, rspSource = 0;
3543 bool bBtBusy = false, bLimitedDig = false;
3544 bool bWifiConnected = false;
3546 pCoexSta->bC2hBtInfoReqSent = false;
3548 rspSource = tmpBuf[0]&0xf;
3549 if (rspSource >= BT_INFO_SRC_8723B_2ANT_MAX)
3550 rspSource = BT_INFO_SRC_8723B_2ANT_WIFI_FW;
3552 pCoexSta->btInfoC2hCnt[rspSource]++;
3554 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length =%d, hex data =[", rspSource, length));
3555 for (i = 0; i < length; i++) {
3556 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
3560 if (i == length-1) {
3561 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
3563 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
3567 if (pBtCoexist->bManualControl) {
3568 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
3572 if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
3573 pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2]&0xf; /* [3:0] */
3575 pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3]*2+10;
3577 pCoexSta->btInfoExt = pCoexSta->btInfoC2h[rspSource][4];
3579 pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
3580 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
3581 if (pCoexSta->bBtTxRxMask) {
3582 /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */
3583 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n"));
3584 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01);
3587 /* Here we need to resend some wifi info to BT */
3588 /* because bt is reset and loss of the info. */
3589 if ((pCoexSta->btInfoExt & BIT1)) {
3590 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
3591 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
3594 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
3596 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3599 if ((pCoexSta->btInfoExt & BIT3)) {
3600 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
3601 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, false);
3603 /* BT already NOT ignore Wlan active, do nothing here. */
3607 /* check BIT2 first ==> check if bt is under inquiry or page scan */
3608 if (btInfo & BT_INFO_8723B_2ANT_B_INQ_PAGE)
3609 pCoexSta->bC2hBtInquiryPage = true;
3611 pCoexSta->bC2hBtInquiryPage = false;
3613 /* set link exist status */
3614 if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) {
3615 pCoexSta->bBtLinkExist = false;
3616 pCoexSta->bPanExist = false;
3617 pCoexSta->bA2dpExist = false;
3618 pCoexSta->bHidExist = false;
3619 pCoexSta->bScoExist = false;
3620 } else { /* connection exists */
3621 pCoexSta->bBtLinkExist = true;
3622 if (btInfo & BT_INFO_8723B_2ANT_B_FTP)
3623 pCoexSta->bPanExist = true;
3625 pCoexSta->bPanExist = false;
3626 if (btInfo & BT_INFO_8723B_2ANT_B_A2DP)
3627 pCoexSta->bA2dpExist = true;
3629 pCoexSta->bA2dpExist = false;
3630 if (btInfo & BT_INFO_8723B_2ANT_B_HID)
3631 pCoexSta->bHidExist = true;
3633 pCoexSta->bHidExist = false;
3634 if (btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO)
3635 pCoexSta->bScoExist = true;
3637 pCoexSta->bScoExist = false;
3640 halbtc8723b2ant_UpdateBtLinkInfo(pBtCoexist);
3642 if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) {
3643 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
3644 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
3645 } else if (btInfo == BT_INFO_8723B_2ANT_B_CONNECTION) { /* connection exists but no busy */
3646 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE;
3647 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
3649 (btInfo&BT_INFO_8723B_2ANT_B_SCO_ESCO) ||
3650 (btInfo&BT_INFO_8723B_2ANT_B_SCO_BUSY)
3652 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_SCO_BUSY;
3653 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
3654 } else if (btInfo&BT_INFO_8723B_2ANT_B_ACL_BUSY) {
3655 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_ACL_BUSY;
3656 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
3658 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_MAX;
3659 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
3663 (BT_8723B_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
3664 (BT_8723B_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
3665 (BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)
3671 bLimitedDig = false;
3674 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
3676 pCoexDm->bLimitedDig = bLimitedDig;
3677 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig);
3679 halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);
3682 void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist)
3684 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
3686 halbtc8723b2ant_WifiOffHwCfg(pBtCoexist);
3687 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); /* BT goto standby while GNT_BT 1-->0 */
3688 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
3690 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3693 void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
3695 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
3697 if (BTC_WIFI_PNP_SLEEP == pnpState) {
3698 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to SLEEP\n"));
3699 } else if (BTC_WIFI_PNP_WAKE_UP == pnpState) {
3700 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to WAKE UP\n"));
3701 halbtc8723b2ant_InitHwConfig(pBtCoexist, false);
3702 halbtc8723b2ant_InitCoexDm(pBtCoexist);
3703 halbtc8723b2ant_QueryBtInfo(pBtCoexist);
3707 void EXhalbtc8723b2ant_Periodical(PBTC_COEXIST pBtCoexist)
3709 static u8 disVerInfoCnt = 0;
3710 u32 fwVer = 0, btPatchVer = 0;
3712 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical ===========================\n"));
3714 if (disVerInfoCnt <= 5) {
3716 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
3717 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
3718 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
3719 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
3720 GLCoexVerDate8723b2Ant, GLCoexVer8723b2Ant, fwVer, btPatchVer, btPatchVer));
3721 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
3725 halbtc8723b2ant_IsWifiStatusChanged(pBtCoexist) ||
3726 pCoexDm->bAutoTdmaAdjust
3728 halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);