1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include "Mp_Precomp.h"
17
18
19static COEX_DM_8723B_2ANT GLCoexDm8723b2Ant;
20static PCOEX_DM_8723B_2ANT pCoexDm = &GLCoexDm8723b2Ant;
21static COEX_STA_8723B_2ANT GLCoexSta8723b2Ant;
22static PCOEX_STA_8723B_2ANT pCoexSta = &GLCoexSta8723b2Ant;
23
24static const char *const GLBtInfoSrc8723b2Ant[] = {
25 "BT Info[wifi fw]",
26 "BT Info[bt rsp]",
27 "BT Info[bt auto report]",
28};
29
30static u32 GLCoexVerDate8723b2Ant = 20131211;
31static u32 GLCoexVer8723b2Ant = 0x40;
32
33
34static u8 halbtc8723b2ant_BtRssiState(
35 u8 levelNum, u8 rssiThresh, u8 rssiThresh1
36)
37{
38 s32 btRssi = 0;
39 u8 btRssiState = pCoexSta->preBtRssiState;
40
41 btRssi = pCoexSta->btRssi;
42
43 if (levelNum == 2) {
44 if (
45 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
46 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
47 ) {
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"));
51 } else {
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"));
54 }
55 } else {
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"));
59 } else {
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"));
62 }
63 }
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;
68 }
69
70 if (
71 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
72 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
73 ) {
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"));
77 } else {
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"));
80 }
81 } else if (
82 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
83 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)
84 ) {
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"));
91 } else {
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"));
94 }
95 } else {
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"));
99 } else {
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"));
102 }
103 }
104 }
105
106 pCoexSta->preBtRssiState = btRssiState;
107
108 return btRssiState;
109}
110
111static u8 halbtc8723b2ant_WifiRssiState(
112 PBTC_COEXIST pBtCoexist,
113 u8 index,
114 u8 levelNum,
115 u8 rssiThresh,
116 u8 rssiThresh1
117)
118{
119 s32 wifiRssi = 0;
120 u8 wifiRssiState = pCoexSta->preWifiRssiState[index];
121
122 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
123
124 if (levelNum == 2) {
125 if (
126 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
127 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
128 ) {
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"));
132 } else {
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"));
135 }
136 } else {
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"));
140 } else {
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"));
143 }
144 }
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];
149 }
150
151 if (
152 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
153 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
154 ) {
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"));
158 } else {
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"));
161 }
162 } else if (
163 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
164 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)
165 ) {
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"));
172 } else {
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"));
175 }
176 } else {
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"));
180 } else {
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"));
183 }
184 }
185 }
186
187 pCoexSta->preWifiRssiState[index] = wifiRssiState;
188
189 return wifiRssiState;
190}
191
192static void halbtc8723b2ant_LimitedRx(
193 PBTC_COEXIST pBtCoexist,
194 bool bForceExec,
195 bool bRejApAggPkt,
196 bool bBtCtrlAggBufSize,
197 u8 aggBufSize
198)
199{
200 bool bRejectRxAgg = bRejApAggPkt;
201 bool bBtCtrlRxAggSize = bBtCtrlAggBufSize;
202 u8 rxAggSize = aggBufSize;
203
204
205
206
207 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);
208
209 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);
210
211 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
212
213 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
214}
215
216static void halbtc8723b2ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
217{
218 u32 regHPTxRx, regLPTxRx, u4Tmp;
219 u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0;
220
221 regHPTxRx = 0x770;
222 regLPTxRx = 0x774;
223
224 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
225 regHPTx = u4Tmp & bMaskLWord;
226 regHPRx = (u4Tmp & bMaskHWord)>>16;
227
228 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
229 regLPTx = u4Tmp & bMaskLWord;
230 regLPRx = (u4Tmp & bMaskHWord)>>16;
231
232 pCoexSta->highPriorityTx = regHPTx;
233 pCoexSta->highPriorityRx = regHPRx;
234 pCoexSta->lowPriorityTx = regLPTx;
235 pCoexSta->lowPriorityRx = regLPRx;
236
237 BTC_PRINT(
238 BTC_MSG_ALGORITHM,
239 ALGO_BT_MONITOR,
240 (
241 "[BTCoex], High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
242 regHPTxRx,
243 regHPTx,
244 regHPTx,
245 regHPRx,
246 regHPRx
247 )
248 );
249 BTC_PRINT(
250 BTC_MSG_ALGORITHM,
251 ALGO_BT_MONITOR,
252 (
253 "[BTCoex], Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
254 regLPTxRx,
255 regLPTx,
256 regLPTx,
257 regLPRx,
258 regLPRx
259 )
260 );
261
262
263 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
264}
265
266static void halbtc8723b2ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
267{
268 u8 H2C_Parameter[1] = {0};
269
270 pCoexSta->bC2hBtInfoReqSent = true;
271
272 H2C_Parameter[0] |= BIT0;
273
274 BTC_PRINT(
275 BTC_MSG_ALGORITHM,
276 ALGO_TRACE_FW_EXEC,
277 ("[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", H2C_Parameter[0])
278 );
279
280 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
281}
282
283static bool halbtc8723b2ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
284{
285 static bool bPreWifiBusy, bPreUnder4way, bPreBtHsOn;
286 bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false;
287 bool bWifiConnected = false;
288
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);
293
294 if (bWifiConnected) {
295 if (bWifiBusy != bPreWifiBusy) {
296 bPreWifiBusy = bWifiBusy;
297 return true;
298 }
299
300 if (bUnder4way != bPreUnder4way) {
301 bPreUnder4way = bUnder4way;
302 return true;
303 }
304
305 if (bBtHsOn != bPreBtHsOn) {
306 bPreBtHsOn = bBtHsOn;
307 return true;
308 }
309 }
310
311 return false;
312}
313
314static void halbtc8723b2ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
315{
316 PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
317 bool bBtHsOn = false;
318
319 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
320
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;
326
327
328 if (bBtHsOn) {
329 pBtLinkInfo->bPanExist = true;
330 pBtLinkInfo->bBtLinkExist = true;
331 }
332
333
334 if (
335 pBtLinkInfo->bScoExist &&
336 !pBtLinkInfo->bA2dpExist &&
337 !pBtLinkInfo->bPanExist &&
338 !pBtLinkInfo->bHidExist
339 )
340 pBtLinkInfo->bScoOnly = true;
341 else
342 pBtLinkInfo->bScoOnly = false;
343
344
345 if (
346 !pBtLinkInfo->bScoExist &&
347 pBtLinkInfo->bA2dpExist &&
348 !pBtLinkInfo->bPanExist &&
349 !pBtLinkInfo->bHidExist
350 )
351 pBtLinkInfo->bA2dpOnly = true;
352 else
353 pBtLinkInfo->bA2dpOnly = false;
354
355
356 if (
357 !pBtLinkInfo->bScoExist &&
358 !pBtLinkInfo->bA2dpExist &&
359 pBtLinkInfo->bPanExist &&
360 !pBtLinkInfo->bHidExist
361 )
362 pBtLinkInfo->bPanOnly = true;
363 else
364 pBtLinkInfo->bPanOnly = false;
365
366
367 if (
368 !pBtLinkInfo->bScoExist &&
369 !pBtLinkInfo->bA2dpExist &&
370 !pBtLinkInfo->bPanExist &&
371 pBtLinkInfo->bHidExist
372 )
373 pBtLinkInfo->bHidOnly = true;
374 else
375 pBtLinkInfo->bHidOnly = false;
376}
377
378static u8 halbtc8723b2ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
379{
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;
384
385 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
386
387 if (!pBtLinkInfo->bBtLinkExist) {
388 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n"));
389 return algorithm;
390 }
391
392 if (pBtLinkInfo->bScoExist)
393 numOfDiffProfile++;
394
395 if (pBtLinkInfo->bHidExist)
396 numOfDiffProfile++;
397
398 if (pBtLinkInfo->bPanExist)
399 numOfDiffProfile++;
400
401 if (pBtLinkInfo->bA2dpExist)
402 numOfDiffProfile++;
403
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;
408 } else {
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) {
416 if (bBtHsOn) {
417 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
418 algorithm = BT_8723B_2ANT_COEX_ALGO_PANHS;
419 } else {
420 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
421 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR;
422 }
423 }
424 }
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) {
434 if (bBtHsOn) {
435 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
436 algorithm = BT_8723B_2ANT_COEX_ALGO_SCO;
437 } else {
438 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
439 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
440 }
441 }
442 } else {
443 if (
444 pBtLinkInfo->bHidExist &&
445 pBtLinkInfo->bA2dpExist
446 ) {
447 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
448 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
449 } else if (
450 pBtLinkInfo->bHidExist &&
451 pBtLinkInfo->bPanExist
452 ) {
453 if (bBtHsOn) {
454 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
455 algorithm = BT_8723B_2ANT_COEX_ALGO_HID;
456 } else {
457 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
458 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
459 }
460 } else if (
461 pBtLinkInfo->bPanExist &&
462 pBtLinkInfo->bA2dpExist
463 ) {
464 if (bBtHsOn) {
465 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
466 algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS;
467 } else {
468 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
469 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP;
470 }
471 }
472 }
473 } else if (numOfDiffProfile == 3) {
474 if (pBtLinkInfo->bScoExist) {
475 if (
476 pBtLinkInfo->bHidExist &&
477 pBtLinkInfo->bA2dpExist
478 ) {
479 BTC_PRINT(
480 BTC_MSG_ALGORITHM,
481 ALGO_TRACE,
482 ("[BTCoex], SCO + HID + A2DP ==> HID\n")
483 );
484 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
485 } else if (
486 pBtLinkInfo->bHidExist &&
487 pBtLinkInfo->bPanExist
488 ) {
489 if (bBtHsOn) {
490 BTC_PRINT(
491 BTC_MSG_ALGORITHM,
492 ALGO_TRACE,
493 ("[BTCoex], SCO + HID + PAN(HS)\n")
494 );
495 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
496 } else {
497 BTC_PRINT(
498 BTC_MSG_ALGORITHM,
499 ALGO_TRACE,
500 ("[BTCoex], SCO + HID + PAN(EDR)\n")
501 );
502 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
503 }
504 } else if (
505 pBtLinkInfo->bPanExist &&
506 pBtLinkInfo->bA2dpExist
507 ) {
508 if (bBtHsOn) {
509 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
510 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
511 } else {
512 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
513 algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
514 }
515 }
516 } else {
517 if (
518 pBtLinkInfo->bHidExist &&
519 pBtLinkInfo->bPanExist &&
520 pBtLinkInfo->bA2dpExist
521 ) {
522 if (bBtHsOn) {
523 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
524 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
525 } else {
526 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
527 algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
528 }
529 }
530 }
531 } else if (numOfDiffProfile >= 3) {
532 if (pBtLinkInfo->bScoExist) {
533 if (
534 pBtLinkInfo->bHidExist &&
535 pBtLinkInfo->bPanExist &&
536 pBtLinkInfo->bA2dpExist
537 ) {
538 if (bBtHsOn) {
539 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
540
541 } else {
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;
544 }
545 }
546 }
547 }
548
549 return algorithm;
550}
551
552static void halbtc8723b2ant_SetFwDacSwingLevel(
553 PBTC_COEXIST pBtCoexist, u8 dacSwingLvl
554)
555{
556 u8 H2C_Parameter[1] = {0};
557
558
559
560 H2C_Parameter[0] = dacSwingLvl;
561
562 BTC_PRINT(
563 BTC_MSG_ALGORITHM,
564 ALGO_TRACE_FW_EXEC,
565 ("[BTCoex], Set Dac Swing Level = 0x%x\n", dacSwingLvl)
566 );
567 BTC_PRINT(
568 BTC_MSG_ALGORITHM,
569 ALGO_TRACE_FW_EXEC,
570 ("[BTCoex], FW write 0x64 = 0x%x\n", H2C_Parameter[0])
571 );
572
573 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter);
574}
575
576static void halbtc8723b2ant_SetFwDecBtPwr(
577 PBTC_COEXIST pBtCoexist, u8 decBtPwrLvl
578)
579{
580 u8 H2C_Parameter[1] = {0};
581
582 H2C_Parameter[0] = decBtPwrLvl;
583
584 BTC_PRINT(
585 BTC_MSG_ALGORITHM,
586 ALGO_TRACE_FW_EXEC,
587 (
588 "[BTCoex], decrease Bt Power level = %d, FW write 0x62 = 0x%x\n",
589 decBtPwrLvl,
590 H2C_Parameter[0]
591 )
592 );
593
594 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter);
595}
596
597static void halbtc8723b2ant_DecBtPwr(
598 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 decBtPwrLvl
599)
600{
601 BTC_PRINT(
602 BTC_MSG_ALGORITHM,
603 ALGO_TRACE_FW,
604 (
605 "[BTCoex], %s Dec BT power level = %d\n",
606 (bForceExec ? "force to" : ""),
607 decBtPwrLvl
608 )
609 );
610 pCoexDm->curBtDecPwrLvl = decBtPwrLvl;
611
612 if (!bForceExec) {
613 BTC_PRINT(
614 BTC_MSG_ALGORITHM,
615 ALGO_TRACE_FW_DETAIL,
616 (
617 "[BTCoex], preBtDecPwrLvl =%d, curBtDecPwrLvl =%d\n",
618 pCoexDm->preBtDecPwrLvl,
619 pCoexDm->curBtDecPwrLvl
620 )
621 );
622
623 if (pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl)
624 return;
625 }
626 halbtc8723b2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
627
628 pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
629}
630
631static void halbtc8723b2ant_FwDacSwingLvl(
632 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 fwDacSwingLvl
633)
634{
635 BTC_PRINT(
636 BTC_MSG_ALGORITHM,
637 ALGO_TRACE_FW,
638 (
639 "[BTCoex], %s set FW Dac Swing level = %d\n",
640 (bForceExec ? "force to" : ""),
641 fwDacSwingLvl
642 )
643 );
644 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
645
646 if (!bForceExec) {
647 BTC_PRINT(
648 BTC_MSG_ALGORITHM,
649 ALGO_TRACE_FW_DETAIL,
650 (
651 "[BTCoex], preFwDacSwingLvl =%d, curFwDacSwingLvl =%d\n",
652 pCoexDm->preFwDacSwingLvl,
653 pCoexDm->curFwDacSwingLvl
654 )
655 );
656
657 if (pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
658 return;
659 }
660
661 halbtc8723b2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
662
663 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
664}
665
666static void halbtc8723b2ant_SetSwRfRxLpfCorner(
667 PBTC_COEXIST pBtCoexist,
668 bool bRxRfShrinkOn
669)
670{
671 if (bRxRfShrinkOn) {
672
673 BTC_PRINT(
674 BTC_MSG_ALGORITHM,
675 ALGO_TRACE_SW_EXEC,
676 ("[BTCoex], Shrink RF Rx LPF corner!!\n")
677 );
678 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc);
679 } else {
680
681
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);
685 }
686 }
687}
688
689static void halbtc8723b2ant_RfShrink(
690 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bRxRfShrinkOn
691)
692{
693 BTC_PRINT(
694 BTC_MSG_ALGORITHM,
695 ALGO_TRACE_SW,
696 (
697 "[BTCoex], %s turn Rx RF Shrink = %s\n",
698 (bForceExec ? "force to" : ""),
699 (bRxRfShrinkOn ? "ON" : "OFF")
700 )
701 );
702 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
703
704 if (!bForceExec) {
705 BTC_PRINT(
706 BTC_MSG_ALGORITHM,
707 ALGO_TRACE_SW_DETAIL,
708 (
709 "[BTCoex], bPreRfRxLpfShrink =%d, bCurRfRxLpfShrink =%d\n",
710 pCoexDm->bPreRfRxLpfShrink,
711 pCoexDm->bCurRfRxLpfShrink
712 )
713 );
714
715 if (pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
716 return;
717 }
718 halbtc8723b2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
719
720 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
721}
722
723static void halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(
724 PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa
725)
726{
727 u8 H2C_Parameter[6] = {0};
728
729 H2C_Parameter[0] = 0x6;
730
731 if (bLowPenaltyRa) {
732 H2C_Parameter[1] |= BIT0;
733 H2C_Parameter[2] = 0x00;
734 H2C_Parameter[3] = 0xf7;
735 H2C_Parameter[4] = 0xf8;
736 H2C_Parameter[5] = 0xf9;
737 }
738
739 BTC_PRINT(
740 BTC_MSG_ALGORITHM,
741 ALGO_TRACE_FW_EXEC,
742 (
743 "[BTCoex], set WiFi Low-Penalty Retry: %s",
744 (bLowPenaltyRa ? "ON!!" : "OFF!!")
745 )
746 );
747
748 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
749}
750
751static void halbtc8723b2ant_LowPenaltyRa(
752 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa
753)
754{
755
756 BTC_PRINT(
757 BTC_MSG_ALGORITHM,
758 ALGO_TRACE_SW,
759 (
760 "[BTCoex], %s turn LowPenaltyRA = %s\n",
761 (bForceExec ? "force to" : ""),
762 (bLowPenaltyRa ? "ON" : "OFF")
763 )
764 );
765 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
766
767 if (!bForceExec) {
768 BTC_PRINT(
769 BTC_MSG_ALGORITHM,
770 ALGO_TRACE_SW_DETAIL,
771 (
772 "[BTCoex], bPreLowPenaltyRa =%d, bCurLowPenaltyRa =%d\n",
773 pCoexDm->bPreLowPenaltyRa,
774 pCoexDm->bCurLowPenaltyRa
775 )
776 );
777
778 if (pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
779 return;
780 }
781 halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
782
783 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
784}
785
786static void halbtc8723b2ant_SetDacSwingReg(PBTC_COEXIST pBtCoexist, u32 level)
787{
788 u8 val = (u8)level;
789
790 BTC_PRINT(
791 BTC_MSG_ALGORITHM,
792 ALGO_TRACE_SW_EXEC,
793 ("[BTCoex], Write SwDacSwing = 0x%x\n", level)
794 );
795 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val);
796}
797
798static void halbtc8723b2ant_SetSwFullTimeDacSwing(
799 PBTC_COEXIST pBtCoexist, bool bSwDacSwingOn, u32 swDacSwingLvl
800)
801{
802 if (bSwDacSwingOn)
803 halbtc8723b2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
804 else
805 halbtc8723b2ant_SetDacSwingReg(pBtCoexist, 0x18);
806}
807
808
809static void halbtc8723b2ant_DacSwing(
810 PBTC_COEXIST pBtCoexist,
811 bool bForceExec,
812 bool bDacSwingOn,
813 u32 dacSwingLvl
814)
815{
816 BTC_PRINT(
817 BTC_MSG_ALGORITHM,
818 ALGO_TRACE_SW,
819 (
820 "[BTCoex], %s turn DacSwing =%s, dacSwingLvl = 0x%x\n",
821 (bForceExec ? "force to" : ""),
822 (bDacSwingOn ? "ON" : "OFF"),
823 dacSwingLvl
824 )
825 );
826 pCoexDm->bCurDacSwingOn = bDacSwingOn;
827 pCoexDm->curDacSwingLvl = dacSwingLvl;
828
829 if (!bForceExec) {
830 BTC_PRINT(
831 BTC_MSG_ALGORITHM,
832 ALGO_TRACE_SW_DETAIL,
833 (
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
839 )
840 );
841
842 if ((pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
843 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl))
844 return;
845 }
846 mdelay(30);
847 halbtc8723b2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
848
849 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
850 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
851}
852
853static void halbtc8723b2ant_SetAgcTable(
854 PBTC_COEXIST pBtCoexist, bool bAgcTableEn
855)
856{
857 u8 rssiAdjustVal = 0;
858
859
860 if (bAgcTableEn) {
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);
869 } else {
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);
878 }
879
880
881
882 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
883 if (bAgcTableEn) {
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);
887 } else {
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);
891 }
892 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
893
894 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1);
895 if (bAgcTableEn) {
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);
899 } else {
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);
903 }
904 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0);
905
906
907 if (bAgcTableEn)
908 rssiAdjustVal = 8;
909
910 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
911}
912
913static void halbtc8723b2ant_AgcTable(
914 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bAgcTableEn
915)
916{
917 BTC_PRINT(
918 BTC_MSG_ALGORITHM,
919 ALGO_TRACE_SW,
920 (
921 "[BTCoex], %s %s Agc Table\n",
922 (bForceExec ? "force to" : ""),
923 (bAgcTableEn ? "Enable" : "Disable")
924 )
925 );
926 pCoexDm->bCurAgcTableEn = bAgcTableEn;
927
928 if (!bForceExec) {
929 BTC_PRINT(
930 BTC_MSG_ALGORITHM,
931 ALGO_TRACE_SW_DETAIL,
932 (
933 "[BTCoex], bPreAgcTableEn =%d, bCurAgcTableEn =%d\n",
934 pCoexDm->bPreAgcTableEn,
935 pCoexDm->bCurAgcTableEn
936 )
937 );
938
939 if (pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
940 return;
941 }
942 halbtc8723b2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
943
944 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
945}
946
947static void halbtc8723b2ant_SetCoexTable(
948 PBTC_COEXIST pBtCoexist,
949 u32 val0x6c0,
950 u32 val0x6c4,
951 u32 val0x6c8,
952 u8 val0x6cc
953)
954{
955 BTC_PRINT(
956 BTC_MSG_ALGORITHM,
957 ALGO_TRACE_SW_EXEC,
958 ("[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0)
959 );
960 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
961
962 BTC_PRINT(
963 BTC_MSG_ALGORITHM,
964 ALGO_TRACE_SW_EXEC,
965 ("[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4)
966 );
967 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
968
969 BTC_PRINT(
970 BTC_MSG_ALGORITHM,
971 ALGO_TRACE_SW_EXEC,
972 ("[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8)
973 );
974 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
975
976 BTC_PRINT(
977 BTC_MSG_ALGORITHM,
978 ALGO_TRACE_SW_EXEC,
979 ("[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc)
980 );
981 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
982}
983
984static void halbtc8723b2ant_CoexTable(
985 PBTC_COEXIST pBtCoexist,
986 bool bForceExec,
987 u32 val0x6c0,
988 u32 val0x6c4,
989 u32 val0x6c8,
990 u8 val0x6cc
991)
992{
993 BTC_PRINT(
994 BTC_MSG_ALGORITHM,
995 ALGO_TRACE_SW,
996 (
997 "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n",
998 (bForceExec ? "force to" : ""),
999 val0x6c0,
1000 val0x6c4,
1001 val0x6c8,
1002 val0x6cc
1003 )
1004 );
1005 pCoexDm->curVal0x6c0 = val0x6c0;
1006 pCoexDm->curVal0x6c4 = val0x6c4;
1007 pCoexDm->curVal0x6c8 = val0x6c8;
1008 pCoexDm->curVal0x6cc = val0x6cc;
1009
1010 if (!bForceExec) {
1011 BTC_PRINT(
1012 BTC_MSG_ALGORITHM,
1013 ALGO_TRACE_SW_DETAIL,
1014 (
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
1020 )
1021 );
1022 BTC_PRINT(
1023 BTC_MSG_ALGORITHM,
1024 ALGO_TRACE_SW_DETAIL,
1025 (
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
1031 )
1032 );
1033
1034 if (
1035 (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
1036 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
1037 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
1038 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc)
1039 )
1040 return;
1041 }
1042 halbtc8723b2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
1043
1044 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
1045 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
1046 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
1047 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
1048}
1049
1050static void halbtc8723b2ant_CoexTableWithType(
1051 PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
1052)
1053{
1054 switch (type) {
1055 case 0:
1056 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffff, 0x3);
1057 break;
1058 case 1:
1059 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
1060 break;
1061 case 2:
1062 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3);
1063 break;
1064 case 3:
1065 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff, 0x3);
1066 break;
1067 case 4:
1068 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffff, 0x3);
1069 break;
1070 case 5:
1071 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffff, 0x3);
1072 break;
1073 case 6:
1074 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3);
1075 break;
1076 case 7:
1077 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0xfafafafa, 0xffff, 0x3);
1078 break;
1079 case 8:
1080 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3);
1081 break;
1082 case 9:
1083 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aea5aea, 0xffff, 0x3);
1084 break;
1085 case 10:
1086 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aff5aff, 0xffff, 0x3);
1087 break;
1088 case 11:
1089 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5f5a5f, 0xffff, 0x3);
1090 break;
1091 case 12:
1092 halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5f5f5f5f, 0xffff, 0x3);
1093 break;
1094 default:
1095 break;
1096 }
1097}
1098
1099static void halbtc8723b2ant_SetFwIgnoreWlanAct(
1100 PBTC_COEXIST pBtCoexist, bool bEnable
1101)
1102{
1103 u8 H2C_Parameter[1] = {0};
1104
1105 if (bEnable)
1106 H2C_Parameter[0] |= BIT0;
1107
1108 BTC_PRINT(
1109 BTC_MSG_ALGORITHM,
1110 ALGO_TRACE_FW_EXEC,
1111 (
1112 "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n",
1113 H2C_Parameter[0]
1114 )
1115 );
1116
1117 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
1118}
1119
1120static void halbtc8723b2ant_IgnoreWlanAct(
1121 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable
1122)
1123{
1124 BTC_PRINT(
1125 BTC_MSG_ALGORITHM,
1126 ALGO_TRACE_FW,
1127 (
1128 "[BTCoex], %s turn Ignore WlanAct %s\n",
1129 (bForceExec ? "force to" : ""),
1130 (bEnable ? "ON" : "OFF")
1131 )
1132 );
1133
1134 pCoexDm->bCurIgnoreWlanAct = bEnable;
1135
1136 if (!bForceExec) {
1137 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
1138 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
1139
1140 if (pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
1141 return;
1142 }
1143 halbtc8723b2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
1144
1145 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
1146}
1147
1148static void halbtc8723b2ant_SetFwPstdma(
1149 PBTC_COEXIST pBtCoexist,
1150 u8 byte1,
1151 u8 byte2,
1152 u8 byte3,
1153 u8 byte4,
1154 u8 byte5
1155)
1156{
1157 u8 H2C_Parameter[5] = {0};
1158
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;
1164
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;
1170
1171 BTC_PRINT(
1172 BTC_MSG_ALGORITHM,
1173 ALGO_TRACE_FW_EXEC,
1174 (
1175 "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n",
1176 H2C_Parameter[0],
1177 H2C_Parameter[1]<<24|
1178 H2C_Parameter[2]<<16|
1179 H2C_Parameter[3]<<8|
1180 H2C_Parameter[4]
1181 )
1182 );
1183
1184 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
1185}
1186
1187static void halbtc8723b2ant_SwMechanism1(
1188 PBTC_COEXIST pBtCoexist,
1189 bool bShrinkRxLPF,
1190 bool bLowPenaltyRA,
1191 bool bLimitedDIG,
1192 bool bBTLNAConstrain
1193)
1194{
1195 halbtc8723b2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);
1196 halbtc8723b2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
1197}
1198
1199static void halbtc8723b2ant_SwMechanism2(
1200 PBTC_COEXIST pBtCoexist,
1201 bool bAGCTableShift,
1202 bool bADCBackOff,
1203 bool bSWDACSwing,
1204 u32 dacSwingLvl
1205)
1206{
1207 halbtc8723b2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);
1208 halbtc8723b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);
1209}
1210
1211static void halbtc8723b2ant_SetAntPath(
1212 PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
1213)
1214{
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};
1220
1221 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch);
1222 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
1223
1224 if ((fwVer > 0 && fwVer < 0xc0000) || bPgExtSwitch)
1225 bUseExtSwitch = true;
1226
1227 if (bInitHwCfg) {
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);
1233
1234 if (fwVer >= 0x180000) {
1235
1236 H2C_Parameter[0] = 0;
1237 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
1238 } else {
1239 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0);
1240 }
1241
1242 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
1243
1244 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
1245 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01);
1246
1247 if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) {
1248
1249 H2C_Parameter[0] = 0;
1250 } else {
1251
1252 H2C_Parameter[0] = 1;
1253 }
1254
1255 if (bUseExtSwitch) {
1256
1257 H2C_Parameter[1] = 1;
1258 } else {
1259
1260 H2C_Parameter[1] = 0;
1261 }
1262 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);
1263 }
1264
1265
1266 if (bUseExtSwitch) {
1267 if (bInitHwCfg) {
1268
1269 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1270 u4Tmp &= ~BIT23;
1271 u4Tmp |= BIT24;
1272 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1273 }
1274
1275 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
1276 switch (antPosType) {
1277 case BTC_ANT_WIFI_AT_MAIN:
1278 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1);
1279 break;
1280 case BTC_ANT_WIFI_AT_AUX:
1281 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2);
1282 break;
1283 }
1284 } else {
1285 if (bInitHwCfg) {
1286
1287 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1288 u4Tmp |= BIT23;
1289 u4Tmp &= ~BIT24;
1290 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1291 }
1292
1293 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0);
1294 switch (antPosType) {
1295 case BTC_ANT_WIFI_AT_MAIN:
1296 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
1297 break;
1298 case BTC_ANT_WIFI_AT_AUX:
1299 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
1300 break;
1301 }
1302 }
1303}
1304
1305static void halbtc8723b2ant_PsTdma(
1306 PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
1307)
1308{
1309 BTC_PRINT(
1310 BTC_MSG_ALGORITHM,
1311 ALGO_TRACE_FW,
1312 (
1313 "[BTCoex], %s turn %s PS TDMA, type =%d\n",
1314 (bForceExec ? "force to" : ""),
1315 (bTurnOn ? "ON" : "OFF"),
1316 type
1317 )
1318 );
1319 pCoexDm->bCurPsTdmaOn = bTurnOn;
1320 pCoexDm->curPsTdma = type;
1321
1322 if (!bForceExec) {
1323 BTC_PRINT(
1324 BTC_MSG_ALGORITHM,
1325 ALGO_TRACE_FW_DETAIL,
1326 (
1327 "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
1328 pCoexDm->bPrePsTdmaOn,
1329 pCoexDm->bCurPsTdmaOn
1330 )
1331 );
1332 BTC_PRINT(
1333 BTC_MSG_ALGORITHM,
1334 ALGO_TRACE_FW_DETAIL,
1335 (
1336 "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
1337 pCoexDm->prePsTdma, pCoexDm->curPsTdma
1338 )
1339 );
1340
1341 if (
1342 (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
1343 (pCoexDm->prePsTdma == pCoexDm->curPsTdma)
1344 )
1345 return;
1346 }
1347
1348 if (bTurnOn) {
1349 switch (type) {
1350 case 1:
1351 default:
1352 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1353 break;
1354 case 2:
1355 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
1356 break;
1357 case 3:
1358 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);
1359 break;
1360 case 4:
1361 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90);
1362 break;
1363 case 5:
1364 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
1365 break;
1366 case 6:
1367 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
1368 break;
1369 case 7:
1370 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);
1371 break;
1372 case 8:
1373 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90);
1374 break;
1375 case 9:
1376 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1377 break;
1378 case 10:
1379 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
1380 break;
1381 case 11:
1382 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90);
1383 break;
1384 case 12:
1385 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
1386 break;
1387 case 13:
1388 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);
1389 break;
1390 case 14:
1391 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);
1392 break;
1393 case 15:
1394 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90);
1395 break;
1396 case 16:
1397 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90);
1398 break;
1399 case 17:
1400 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90);
1401 break;
1402 case 18:
1403 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
1404 break;
1405 case 19:
1406 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90);
1407 break;
1408 case 20:
1409 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90);
1410 break;
1411 case 21:
1412 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);
1413 break;
1414 case 71:
1415 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1416 break;
1417 }
1418 } else {
1419
1420 switch (type) {
1421 case 0:
1422 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
1423 break;
1424 case 1:
1425 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0);
1426 break;
1427 default:
1428 halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);
1429 break;
1430 }
1431 }
1432
1433
1434 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1435 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1436}
1437
1438static void halbtc8723b2ant_CoexAllOff(PBTC_COEXIST pBtCoexist)
1439{
1440
1441 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1442 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1443 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1444
1445
1446 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1447 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1448
1449
1450
1451 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1452}
1453
1454static void halbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
1455{
1456
1457
1458 halbtc8723b2ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 1);
1459 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
1460 halbtc8723b2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
1461
1462 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1463 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1464}
1465
1466static void halbtc8723b2ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
1467{
1468 bool bWifiConnected = false;
1469 bool bLowPwrDisable = true;
1470
1471 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1472 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
1473
1474 if (bWifiConnected) {
1475 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
1476 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1477 } else {
1478 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1479 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
1480 }
1481
1482 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
1483 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1484
1485 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1486 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1487
1488 pCoexDm->bNeedRecover0x948 = true;
1489 pCoexDm->backup0x948 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
1490
1491 halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, false, false);
1492}
1493
1494static bool halbtc8723b2ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
1495{
1496 u8 btRssiState = BTC_RSSI_STATE_HIGH;
1497 bool bCommon = false, bWifiConnected = false, bWifiBusy = false;
1498 bool bBtHsOn = false, bLowPwrDisable = false;
1499
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);
1503
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);
1508
1509 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non-connected idle!!\n"));
1510
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);
1516
1517 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1518 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1519
1520 bCommon = true;
1521 } else {
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);
1526
1527 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
1528
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);
1534
1535 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1536 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1537
1538 bCommon = true;
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);
1542
1543 if (bBtHsOn)
1544 return false;
1545
1546 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
1547 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
1548
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);
1554
1555 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
1556 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1557
1558 bCommon = true;
1559 } else {
1560 bLowPwrDisable = true;
1561 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1562
1563 if (bWifiBusy) {
1564 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
1565 bCommon = false;
1566 } else {
1567 if (bBtHsOn)
1568 return false;
1569
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);
1573
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);
1578
1579 if (BTC_RSSI_HIGH(btRssiState))
1580 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
1581 else
1582 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1583
1584 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
1585 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
1586 bCommon = true;
1587 }
1588 }
1589 }
1590
1591 return bCommon;
1592}
1593
1594static void halbtc8723b2ant_TdmaDurationAdjust(
1595 PBTC_COEXIST pBtCoexist, bool bScoHid, bool bTxPause, u8 maxInterval
1596)
1597{
1598 static s32 up, dn, m, n, WaitCount;
1599 s32 result;
1600 u8 retryCount = 0;
1601
1602 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjust()\n"));
1603
1604 if (!pCoexDm->bAutoTdmaAdjust) {
1605 pCoexDm->bAutoTdmaAdjust = true;
1606 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
1607 {
1608 if (bScoHid) {
1609 if (bTxPause) {
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;
1619 } else {
1620 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
1621 pCoexDm->psTdmaDuAdjType = 15;
1622 }
1623 } else {
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;
1633 } else {
1634 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
1635 pCoexDm->psTdmaDuAdjType = 11;
1636 }
1637 }
1638 } else {
1639 if (bTxPause) {
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;
1649 } else {
1650 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
1651 pCoexDm->psTdmaDuAdjType = 7;
1652 }
1653 } else {
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;
1663 } else {
1664 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
1665 pCoexDm->psTdmaDuAdjType = 3;
1666 }
1667 }
1668 }
1669 }
1670
1671 up = 0;
1672 dn = 0;
1673 m = 1;
1674 n = 3;
1675 result = 0;
1676 WaitCount = 0;
1677 } else {
1678
1679 retryCount = pCoexSta->btRetryCnt;
1680 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
1681 BTC_PRINT(
1682 BTC_MSG_ALGORITHM,
1683 ALGO_TRACE_FW_DETAIL,
1684 (
1685 "[BTCoex], up =%d, dn =%d, m =%d, n =%d, WaitCount =%d\n",
1686 up, dn, m, n, WaitCount
1687 )
1688 );
1689 result = 0;
1690 WaitCount++;
1691
1692 if (retryCount == 0) {
1693 up++;
1694 dn--;
1695
1696 if (dn <= 0)
1697 dn = 0;
1698
1699 if (up >= n) {
1700 WaitCount = 0;
1701 n = 3;
1702 up = 0;
1703 dn = 0;
1704 result = 1;
1705 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
1706 }
1707 } else if (retryCount <= 3) {
1708 up--;
1709 dn++;
1710
1711 if (up <= 0)
1712 up = 0;
1713
1714 if (dn == 2) {
1715 if (WaitCount <= 2)
1716 m++;
1717 else
1718 m = 1;
1719
1720 if (m >= 20)
1721 m = 20;
1722
1723 n = 3*m;
1724 up = 0;
1725 dn = 0;
1726 WaitCount = 0;
1727 result = -1;
1728 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
1729 }
1730 } else {
1731 if (WaitCount == 1)
1732 m++;
1733 else
1734 m = 1;
1735
1736 if (m >= 20)
1737 m = 20;
1738
1739 n = 3*m;
1740 up = 0;
1741 dn = 0;
1742 WaitCount = 0;
1743 result = -1;
1744 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
1745 }
1746
1747 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], max Interval = %d\n", maxInterval));
1748 if (maxInterval == 1) {
1749 if (bTxPause) {
1750 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
1751
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;
1767 }
1768
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;
1781 }
1782
1783 if (result == -1) {
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;
1802 }
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;
1822 }
1823 }
1824 } else {
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;
1838 }
1839
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;
1852 }
1853
1854 if (result == -1) {
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;
1876 }
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;
1899 }
1900 }
1901 }
1902 } else if (maxInterval == 2) {
1903 if (bTxPause) {
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;
1917 }
1918
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;
1931 }
1932
1933 if (result == -1) {
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;
1952 }
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;
1972 }
1973 }
1974 } else {
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;
1988 }
1989
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;
2002 }
2003
2004 if (result == -1) {
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;
2023 }
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;
2043 }
2044 }
2045 }
2046 } else if (maxInterval == 3) {
2047 if (bTxPause) {
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;
2061 }
2062
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;
2075 }
2076
2077 if (result == -1) {
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;
2096 }
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;
2116 }
2117 }
2118 } else {
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;
2132 }
2133
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;
2146 }
2147
2148 if (result == -1) {
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;
2167 }
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;
2187 }
2188 }
2189 }
2190 }
2191 }
2192
2193
2194
2195 if (pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) {
2196 bool bScan = false, bLink = false, bRoam = false;
2197 BTC_PRINT(
2198 BTC_MSG_ALGORITHM,
2199 ALGO_TRACE_FW_DETAIL,
2200 (
2201 "[BTCoex], PsTdma type dismatch!!!, curPsTdma =%d, recordPsTdma =%d\n",
2202 pCoexDm->curPsTdma,
2203 pCoexDm->psTdmaDuAdjType
2204 )
2205 );
2206
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);
2210
2211 if (!bScan && !bLink && !bRoam)
2212 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType);
2213 else {
2214 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
2215 }
2216 }
2217}
2218
2219
2220static void halbtc8723b2ant_ActionSco(PBTC_COEXIST pBtCoexist)
2221{
2222 u8 wifiRssiState, btRssiState;
2223 u32 wifiBw;
2224
2225 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2226 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2227
2228 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2229
2230 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2231
2232 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4);
2233
2234 if (BTC_RSSI_HIGH(btRssiState))
2235 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2236 else
2237 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2238
2239 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2240
2241 if (BTC_WIFI_BW_LEGACY == wifiBw)
2242 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
2243 else
2244 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
2245
2246 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0);
2247
2248
2249 if (BTC_WIFI_BW_HT40 == wifiBw) {
2250 if (
2251 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2252 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2253 ) {
2254 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2255 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4);
2256 } else {
2257 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2258 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4);
2259 }
2260 } else {
2261 if (
2262 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2263 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2264 ) {
2265 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2266 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4);
2267 } else {
2268 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2269 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4);
2270 }
2271 }
2272}
2273
2274
2275static void halbtc8723b2ant_ActionHid(PBTC_COEXIST pBtCoexist)
2276{
2277 u8 wifiRssiState, btRssiState;
2278 u32 wifiBw;
2279
2280 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2281 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2282
2283 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2284
2285 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2286
2287 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2288
2289 if (BTC_RSSI_HIGH(btRssiState))
2290 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2291 else
2292 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2293
2294 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2295
2296 if (BTC_WIFI_BW_LEGACY == wifiBw)
2297 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2298 else
2299 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 9);
2300
2301 if (
2302 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2303 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2304 )
2305 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
2306 else
2307 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
2308
2309
2310 if (BTC_WIFI_BW_HT40 == wifiBw) {
2311 if (
2312 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2313 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2314 ) {
2315 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2316 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2317 } else {
2318 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2319 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2320 }
2321 } else {
2322 if (
2323 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2324 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2325 ) {
2326 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2327 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2328 } else {
2329 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2330 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2331 }
2332 }
2333}
2334
2335
2336static void halbtc8723b2ant_ActionA2dp(PBTC_COEXIST pBtCoexist)
2337{
2338 u8 wifiRssiState, wifiRssiState1, btRssiState;
2339 u32 wifiBw;
2340 u8 apNum = 0;
2341
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);
2345
2346 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
2347
2348
2349 if (apNum >= 10 && BTC_RSSI_HIGH(wifiRssiState1)) {
2350
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);
2357
2358
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);
2363 } else {
2364 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2365 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x18);
2366 }
2367 return;
2368 }
2369
2370 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2371 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2372
2373 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2374
2375 if (BTC_RSSI_HIGH(btRssiState))
2376 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2377 else
2378 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2379
2380 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2381
2382 if (
2383 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2384 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2385 )
2386 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 1);
2387 else
2388 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 1);
2389
2390
2391 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2392 if (BTC_WIFI_BW_HT40 == wifiBw) {
2393 if (
2394 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2395 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2396 ) {
2397 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2398 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2399 } else {
2400 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2401 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2402 }
2403 } else {
2404 if (
2405 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2406 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2407 ) {
2408 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2409 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2410 } else {
2411 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2412 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2413 }
2414 }
2415}
2416
2417static void halbtc8723b2ant_ActionA2dpPanHs(PBTC_COEXIST pBtCoexist)
2418{
2419 u8 wifiRssiState, btRssiState;
2420 u32 wifiBw;
2421
2422 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2423 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2424
2425 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2426
2427 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2428
2429 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2430
2431 if (BTC_RSSI_HIGH(btRssiState))
2432 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2433 else
2434 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2435
2436 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2437
2438 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 2);
2439
2440
2441 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2442 if (BTC_WIFI_BW_HT40 == wifiBw) {
2443 if (
2444 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2445 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2446 ) {
2447 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2448 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2449 } else {
2450 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2451 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2452 }
2453 } else {
2454 if (
2455 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2456 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2457 ) {
2458 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2459 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2460 } else {
2461 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2462 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2463 }
2464 }
2465}
2466
2467static void halbtc8723b2ant_ActionPanEdr(PBTC_COEXIST pBtCoexist)
2468{
2469 u8 wifiRssiState, btRssiState;
2470 u32 wifiBw;
2471
2472 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2473 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2474
2475 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2476
2477 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2478
2479 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2480
2481 if (BTC_RSSI_HIGH(btRssiState))
2482 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2483 else
2484 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2485
2486 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10);
2487
2488 if (
2489 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2490 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2491 )
2492 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
2493 else
2494 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
2495
2496
2497 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2498 if (BTC_WIFI_BW_HT40 == wifiBw) {
2499 if (
2500 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2501 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2502 ) {
2503 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2504 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2505 } else {
2506 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2507 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2508 }
2509 } else {
2510 if (
2511 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2512 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2513 ) {
2514 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2515 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2516 } else {
2517 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2518 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2519 }
2520 }
2521}
2522
2523
2524
2525static void halbtc8723b2ant_ActionPanHs(PBTC_COEXIST pBtCoexist)
2526{
2527 u8 wifiRssiState, btRssiState;
2528 u32 wifiBw;
2529
2530 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2531 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2532
2533 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2534
2535 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2536
2537 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2538
2539 if (BTC_RSSI_HIGH(btRssiState))
2540 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2541 else
2542 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2543
2544 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2545
2546 halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
2547
2548 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2549 if (BTC_WIFI_BW_HT40 == wifiBw) {
2550 if (
2551 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2552 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2553 ) {
2554 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2555 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2556 } else {
2557 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2558 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2559 }
2560 } else {
2561 if (
2562 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2563 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2564 ) {
2565 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2566 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2567 } else {
2568 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2569 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2570 }
2571 }
2572}
2573
2574
2575static void halbtc8723b2ant_ActionPanEdrA2dp(PBTC_COEXIST pBtCoexist)
2576{
2577 u8 wifiRssiState, btRssiState;
2578 u32 wifiBw;
2579
2580 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2581 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2582
2583 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2584
2585 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2586
2587 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2588
2589 if (BTC_RSSI_HIGH(btRssiState))
2590 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2591 else
2592 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2593
2594 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2595
2596 if (
2597 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2598 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2599 ) {
2600 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12);
2601 if (BTC_WIFI_BW_HT40 == wifiBw)
2602 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3);
2603 else
2604 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 3);
2605 } else {
2606 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2607 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3);
2608 }
2609
2610
2611 if (BTC_WIFI_BW_HT40 == wifiBw) {
2612 if (
2613 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2614 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2615 ) {
2616 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2617 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2618 } else {
2619 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false);
2620 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2621 }
2622 } else {
2623 if (
2624 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2625 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2626 ) {
2627 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2628 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2629 } else {
2630 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false);
2631 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2632 }
2633 }
2634}
2635
2636static void halbtc8723b2ant_ActionPanEdrHid(PBTC_COEXIST pBtCoexist)
2637{
2638 u8 wifiRssiState, btRssiState;
2639 u32 wifiBw;
2640
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);
2644
2645 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2646
2647 if (BTC_RSSI_HIGH(btRssiState))
2648 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2649 else
2650 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2651
2652 if (
2653 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2654 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2655 ) {
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);
2660 } else {
2661 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2662 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2663 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2664 }
2665 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2);
2666 } else {
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);
2671 }
2672
2673
2674 if (BTC_WIFI_BW_HT40 == wifiBw) {
2675 if (
2676 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2677 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2678 ) {
2679 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2680 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2681 } else {
2682 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2683 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2684 }
2685 } else {
2686 if (
2687 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2688 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2689 ) {
2690 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2691 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2692 } else {
2693 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2694 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2695 }
2696 }
2697}
2698
2699
2700static void halbtc8723b2ant_ActionHidA2dpPanEdr(PBTC_COEXIST pBtCoexist)
2701{
2702 u8 wifiRssiState, btRssiState;
2703 u32 wifiBw;
2704
2705 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2706 btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0);
2707
2708 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2709
2710 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8);
2711
2712 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2713
2714 if (BTC_RSSI_HIGH(btRssiState))
2715 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2716 else
2717 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2718
2719 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2720
2721 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2722
2723 if (
2724 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2725 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2726 ) {
2727 if (BTC_WIFI_BW_HT40 == wifiBw)
2728 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2729 else
2730 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 3);
2731 } else
2732 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 3);
2733
2734
2735 if (BTC_WIFI_BW_HT40 == wifiBw) {
2736 if (
2737 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2738 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2739 ) {
2740 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2741 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2742 } else {
2743 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2744 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2745 }
2746 } else {
2747 if (
2748 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2749 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2750 ) {
2751 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2752 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2753 } else {
2754 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2755 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2756 }
2757 }
2758}
2759
2760static void halbtc8723b2ant_ActionHidA2dp(PBTC_COEXIST pBtCoexist)
2761{
2762 u8 wifiRssiState, btRssiState;
2763 u32 wifiBw;
2764 u8 apNum = 0;
2765
2766 wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
2767
2768 btRssiState = halbtc8723b2ant_BtRssiState(3, 29, 37);
2769
2770 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
2771
2772 halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, true, 0x5);
2773
2774 halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2775
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);
2782 else
2783 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2784 } else {
2785
2786 if (BTC_RSSI_HIGH(btRssiState)) {
2787 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
2788
2789 if (apNum < 10)
2790 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
2791 else
2792 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2793 } else if (BTC_RSSI_MEDIUM(btRssiState))
2794 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
2795 else
2796 halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2797 }
2798
2799 halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
2800
2801 if (
2802 (btRssiState == BTC_RSSI_STATE_HIGH) ||
2803 (btRssiState == BTC_RSSI_STATE_STAY_HIGH)
2804 )
2805 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2);
2806 else
2807 halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2);
2808
2809
2810 if (BTC_WIFI_BW_HT40 == wifiBw) {
2811 if (
2812 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2813 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2814 ) {
2815 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2816 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2817 } else {
2818 halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false);
2819 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2820 }
2821 } else {
2822 if (
2823 (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
2824 (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)
2825 ) {
2826 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2827 halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18);
2828 } else {
2829 halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false);
2830 halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
2831 }
2832 }
2833}
2834
2835static void halbtc8723b2ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
2836{
2837 u8 algorithm = 0;
2838
2839 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism() ===>\n"));
2840
2841 if (pBtCoexist->bManualControl) {
2842 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
2843 return;
2844 }
2845
2846 if (pCoexSta->bUnderIps) {
2847 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
2848 return;
2849 }
2850
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);
2855 return;
2856 } else {
2857 if (pCoexDm->bNeedRecover0x948) {
2858 pCoexDm->bNeedRecover0x948 = false;
2859 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, pCoexDm->backup0x948);
2860 }
2861 }
2862
2863 pCoexDm->curAlgorithm = algorithm;
2864 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Algorithm = %d\n", pCoexDm->curAlgorithm));
2865
2866 if (halbtc8723b2ant_IsCommonAction(pBtCoexist)) {
2867 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant common.\n"));
2868 pCoexDm->bAutoTdmaAdjust = false;
2869 } else {
2870 if (pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) {
2871 BTC_PRINT(
2872 BTC_MSG_ALGORITHM,
2873 ALGO_TRACE,
2874 (
2875 "[BTCoex], preAlgorithm =%d, curAlgorithm =%d\n",
2876 pCoexDm->preAlgorithm,
2877 pCoexDm->curAlgorithm
2878 )
2879 );
2880 pCoexDm->bAutoTdmaAdjust = false;
2881 }
2882
2883
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);
2888 break;
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);
2892 break;
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);
2896 break;
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);
2900 break;
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);
2904 break;
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);
2908 break;
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);
2912 break;
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);
2916 break;
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);
2920 break;
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);
2924 break;
2925 default:
2926 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"));
2927 halbtc8723b2ant_CoexAllOff(pBtCoexist);
2928 break;
2929 }
2930 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
2931 }
2932}
2933
2934static void halbtc8723b2ant_WifiOffHwCfg(PBTC_COEXIST pBtCoexist)
2935{
2936 bool bIsInMpMode = false;
2937 u8 H2C_Parameter[2] = {0};
2938 u32 fwVer = 0;
2939
2940
2941 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
2942
2943 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780);
2944 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
2945 if (fwVer >= 0x180000) {
2946
2947 H2C_Parameter[0] = 1;
2948 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);
2949 } else
2950 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
2951
2952 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode);
2953 if (!bIsInMpMode)
2954 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0);
2955 else
2956 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1);
2957}
2958
2959static void halbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bBackUp)
2960{
2961 u8 u1Tmp = 0;
2962
2963 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 2Ant Init HW Config!!\n"));
2964
2965
2966 pCoexDm->btRf0x1eBackup =
2967 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
2968
2969
2970 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
2971 u1Tmp &= 0xc0;
2972 u1Tmp |= 0x5;
2973 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
2974
2975
2976 halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, true, false);
2977
2978
2979 halbtc8723b2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
2980
2981
2982 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
2983 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);
2984 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);
2985}
2986
2987
2988
2989
2990
2991
2992
2993void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
2994{
2995 PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
2996 u8 u1Tmp = 0x4;
2997 u16 u2Tmp = 0x0;
2998
2999 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20);
3000
3001
3002 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
3003 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1);
3004
3005
3006 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
3007
3008 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
3009
3010
3011
3012
3013
3014
3015
3016
3017 if (pBtCoexist->chipInterface == BTC_INTF_USB) {
3018
3019 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
3020
3021 u1Tmp |= 0x1;
3022 pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);
3023
3024 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
3025 } else {
3026
3027 if (pBoardInfo->singleAntPath == 0) {
3028
3029 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280);
3030 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
3031 } else if (pBoardInfo->singleAntPath == 1) {
3032
3033 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0);
3034 u1Tmp |= 0x1;
3035 pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT;
3036 }
3037
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);
3042 }
3043}
3044
3045void EXhalbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly)
3046{
3047 halbtc8723b2ant_InitHwConfig(pBtCoexist, true);
3048}
3049
3050void EXhalbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
3051{
3052 BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
3053
3054 halbtc8723b2ant_InitCoexDm(pBtCoexist);
3055}
3056
3057void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
3058{
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;
3064 u32 u4Tmp[4];
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;
3071 u8 apNum = 0;
3072
3073 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
3074 CL_PRINTF(cliBuf);
3075
3076 if (pBtCoexist->bManualControl) {
3077 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
3078 CL_PRINTF(cliBuf);
3079 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
3080 CL_PRINTF(cliBuf);
3081 }
3082
3083 CL_SPRINTF(
3084 cliBuf,
3085 BT_TMP_BUF_SIZE,
3086 "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
3087 pBoardInfo->pgAntNum,
3088 pBoardInfo->btdmAntNum
3089 );
3090 CL_PRINTF(cliBuf);
3091
3092 CL_SPRINTF(
3093 cliBuf,
3094 BT_TMP_BUF_SIZE,
3095 "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
3096 (pStackInfo->bProfileNotified ? "Yes" : "No"),
3097 pStackInfo->hciVersion
3098 );
3099 CL_PRINTF(cliBuf);
3100
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);
3105 CL_PRINTF(cliBuf);
3106
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);
3110 CL_SPRINTF(
3111 cliBuf,
3112 BT_TMP_BUF_SIZE,
3113 "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
3114 wifiDot11Chnl,
3115 wifiHsChnl,
3116 bBtHsOn
3117 );
3118 CL_PRINTF(cliBuf);
3119
3120 CL_SPRINTF(
3121 cliBuf,
3122 BT_TMP_BUF_SIZE,
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]
3127 );
3128 CL_PRINTF(cliBuf);
3129
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);
3133 CL_SPRINTF(
3134 cliBuf,
3135 BT_TMP_BUF_SIZE,
3136 "\r\n %-35s = %d/ %d/ %d", "Wifi rssi/ HS rssi/ AP#", \
3137 wifiRssi,
3138 btHsRssi,
3139 apNum
3140 );
3141 CL_PRINTF(cliBuf);
3142
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);
3146 CL_SPRINTF(
3147 cliBuf,
3148 BT_TMP_BUF_SIZE,
3149 "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
3150 bLink,
3151 bRoam,
3152 bScan
3153 );
3154 CL_PRINTF(cliBuf);
3155
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);
3160 CL_SPRINTF(
3161 cliBuf,
3162 BT_TMP_BUF_SIZE,
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"))
3167 );
3168 CL_PRINTF(cliBuf);
3169
3170 CL_SPRINTF(
3171 cliBuf,
3172 BT_TMP_BUF_SIZE,
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")))),
3176 pCoexSta->btRssi,
3177 pCoexSta->btRetryCnt
3178 );
3179 CL_PRINTF(cliBuf);
3180
3181 CL_SPRINTF(
3182 cliBuf,
3183 BT_TMP_BUF_SIZE,
3184 "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
3185 pBtLinkInfo->bScoExist,
3186 pBtLinkInfo->bHidExist,
3187 pBtLinkInfo->bPanExist,
3188 pBtLinkInfo->bA2dpExist
3189 );
3190 CL_PRINTF(cliBuf);
3191 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
3192
3193 btInfoExt = pCoexSta->btInfoExt;
3194 CL_SPRINTF(
3195 cliBuf,
3196 BT_TMP_BUF_SIZE,
3197 "\r\n %-35s = %s", "BT Info A2DP rate", \
3198 (btInfoExt&BIT0) ? "Basic rate" : "EDR rate"
3199 );
3200 CL_PRINTF(cliBuf);
3201
3202 for (i = 0; i < BT_INFO_SRC_8723B_2ANT_MAX; i++) {
3203 if (pCoexSta->btInfoC2hCnt[i]) {
3204 CL_SPRINTF(
3205 cliBuf,
3206 BT_TMP_BUF_SIZE,
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]
3216 );
3217 CL_PRINTF(cliBuf);
3218 }
3219 }
3220
3221 CL_SPRINTF(
3222 cliBuf,
3223 BT_TMP_BUF_SIZE,
3224 "\r\n %-35s = %s/%s", "PS state, IPS/LPS", \
3225 ((pCoexSta->bUnderIps ? "IPS ON" : "IPS OFF")),
3226 ((pCoexSta->bUnderLps ? "LPS ON" : "LPS OFF"))
3227 );
3228 CL_PRINTF(cliBuf);
3229 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
3230
3231
3232 CL_SPRINTF(
3233 cliBuf,
3234 BT_TMP_BUF_SIZE,
3235 "\r\n %-35s", "============[Sw mechanism]============"
3236 );
3237 CL_PRINTF(cliBuf);
3238 CL_SPRINTF(
3239 cliBuf,
3240 BT_TMP_BUF_SIZE,
3241 "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \
3242 pCoexDm->bCurRfRxLpfShrink,
3243 pCoexDm->bCurLowPenaltyRa,
3244 pCoexDm->bLimitedDig
3245 );
3246 CL_PRINTF(cliBuf);
3247 CL_SPRINTF(
3248 cliBuf,
3249 BT_TMP_BUF_SIZE,
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
3256 );
3257 CL_PRINTF(cliBuf);
3258
3259
3260 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
3261 CL_PRINTF(cliBuf);
3262
3263 psTdmaCase = pCoexDm->curPsTdma;
3264 CL_SPRINTF(
3265 cliBuf,
3266 BT_TMP_BUF_SIZE,
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
3274 );
3275 CL_PRINTF(cliBuf);
3276
3277 CL_SPRINTF(
3278 cliBuf,
3279 BT_TMP_BUF_SIZE,
3280 "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
3281 pCoexDm->curBtDecPwrLvl,
3282 pCoexDm->bCurIgnoreWlanAct
3283 );
3284 CL_PRINTF(cliBuf);
3285
3286
3287 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
3288 CL_PRINTF(cliBuf);
3289
3290 CL_SPRINTF(
3291 cliBuf,
3292 BT_TMP_BUF_SIZE,
3293 "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
3294 pCoexDm->btRf0x1eBackup
3295 );
3296 CL_PRINTF(cliBuf);
3297
3298 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
3299 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);
3300 CL_SPRINTF(
3301 cliBuf,
3302 BT_TMP_BUF_SIZE,
3303 "\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \
3304 u1Tmp[0],
3305 (u4Tmp[0]&0x3e000000) >> 25
3306 );
3307 CL_PRINTF(cliBuf);
3308
3309
3310 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948);
3311 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67);
3312 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);
3313 CL_SPRINTF(
3314 cliBuf,
3315 BT_TMP_BUF_SIZE,
3316 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \
3317 u4Tmp[0],
3318 ((u1Tmp[0]&0x20)>>5),
3319 u1Tmp[1]
3320 );
3321 CL_PRINTF(cliBuf);
3322
3323 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c);
3324 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
3325 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944);
3326 CL_SPRINTF(
3327 cliBuf,
3328 BT_TMP_BUF_SIZE,
3329 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \
3330 u4Tmp[0]&0x3,
3331 u4Tmp[1]&0xff,
3332 u4Tmp[2]&0x3
3333 );
3334 CL_PRINTF(cliBuf);
3335
3336
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);
3341 CL_SPRINTF(
3342 cliBuf,
3343 BT_TMP_BUF_SIZE,
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),
3346 u1Tmp[1],
3347 ((u4Tmp[0]&0x01800000)>>23),
3348 u1Tmp[2]&0x1
3349 );
3350 CL_PRINTF(cliBuf);
3351
3352 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
3353 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
3354 CL_SPRINTF(
3355 cliBuf,
3356 BT_TMP_BUF_SIZE,
3357 "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
3358 u4Tmp[0],
3359 u1Tmp[0]
3360 );
3361 CL_PRINTF(cliBuf);
3362
3363 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
3364 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c);
3365 CL_SPRINTF(
3366 cliBuf,
3367 BT_TMP_BUF_SIZE,
3368 "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
3369 u4Tmp[0]&0xff,
3370 u1Tmp[0]
3371 );
3372 CL_PRINTF(cliBuf);
3373
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);
3378
3379 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b);
3380 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
3381
3382 faOfdm =
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);
3388
3389 faCck = (u1Tmp[0] << 8) + u1Tmp[1];
3390
3391 CL_SPRINTF(
3392 cliBuf,
3393 BT_TMP_BUF_SIZE,
3394 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
3395 u4Tmp[0]&0xffff,
3396 faOfdm,
3397 faCck
3398 );
3399 CL_PRINTF(cliBuf);
3400
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);
3405 CL_SPRINTF(
3406 cliBuf,
3407 BT_TMP_BUF_SIZE,
3408 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
3409 u4Tmp[0],
3410 u4Tmp[1],
3411 u4Tmp[2],
3412 u1Tmp[0]
3413 );
3414 CL_PRINTF(cliBuf);
3415
3416 CL_SPRINTF(
3417 cliBuf,
3418 BT_TMP_BUF_SIZE,
3419 "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \
3420 pCoexSta->highPriorityRx,
3421 pCoexSta->highPriorityTx
3422 );
3423 CL_PRINTF(cliBuf);
3424 CL_SPRINTF(
3425 cliBuf,
3426 BT_TMP_BUF_SIZE,
3427 "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \
3428 pCoexSta->lowPriorityRx,
3429 pCoexSta->lowPriorityTx
3430 );
3431 CL_PRINTF(cliBuf);
3432
3433 halbtc8723b2ant_MonitorBtCtr(pBtCoexist);
3434 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
3435}
3436
3437
3438void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
3439{
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);
3452 }
3453}
3454
3455void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
3456{
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;
3463 }
3464}
3465
3466void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
3467{
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"));
3472 }
3473}
3474
3475void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
3476{
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"));
3481 }
3482}
3483
3484void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
3485{
3486 u8 H2C_Parameter[3] = {0};
3487 u32 wifiBw;
3488 u8 wifiCentralChnl;
3489 u8 apNum = 0;
3490
3491 if (BTC_MEDIA_CONNECT == type) {
3492 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
3493 } else {
3494 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
3495 }
3496
3497
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;
3505 else {
3506 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);
3507 if (apNum < 10)
3508 H2C_Parameter[2] = 0x30;
3509 else
3510 H2C_Parameter[2] = 0x20;
3511 }
3512 }
3513
3514 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
3515 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
3516 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
3517
3518 BTC_PRINT(
3519 BTC_MSG_ALGORITHM,
3520 ALGO_TRACE_FW_EXEC,
3521 (
3522 "[BTCoex], FW write 0x66 = 0x%x\n",
3523 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]
3524 )
3525 );
3526
3527 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
3528}
3529
3530void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
3531{
3532 if (type == BTC_PACKET_DHCP) {
3533 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
3534 }
3535}
3536
3537void EXhalbtc8723b2ant_BtInfoNotify(
3538 PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
3539)
3540{
3541 u8 btInfo = 0;
3542 u8 i, rspSource = 0;
3543 bool bBtBusy = false, bLimitedDig = false;
3544 bool bWifiConnected = false;
3545
3546 pCoexSta->bC2hBtInfoReqSent = false;
3547
3548 rspSource = tmpBuf[0]&0xf;
3549 if (rspSource >= BT_INFO_SRC_8723B_2ANT_MAX)
3550 rspSource = BT_INFO_SRC_8723B_2ANT_WIFI_FW;
3551
3552 pCoexSta->btInfoC2hCnt[rspSource]++;
3553
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];
3557 if (i == 1)
3558 btInfo = tmpBuf[i];
3559
3560 if (i == length-1) {
3561 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
3562 } else {
3563 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
3564 }
3565 }
3566
3567 if (pBtCoexist->bManualControl) {
3568 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
3569 return;
3570 }
3571
3572 if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
3573 pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2]&0xf;
3574
3575 pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3]*2+10;
3576
3577 pCoexSta->btInfoExt = pCoexSta->btInfoC2h[rspSource][4];
3578
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
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);
3585 }
3586
3587
3588
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);
3592
3593 if (bWifiConnected)
3594 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
3595 else
3596 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3597 }
3598
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);
3602 } else {
3603
3604 }
3605 }
3606
3607
3608 if (btInfo & BT_INFO_8723B_2ANT_B_INQ_PAGE)
3609 pCoexSta->bC2hBtInquiryPage = true;
3610 else
3611 pCoexSta->bC2hBtInquiryPage = false;
3612
3613
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 {
3621 pCoexSta->bBtLinkExist = true;
3622 if (btInfo & BT_INFO_8723B_2ANT_B_FTP)
3623 pCoexSta->bPanExist = true;
3624 else
3625 pCoexSta->bPanExist = false;
3626 if (btInfo & BT_INFO_8723B_2ANT_B_A2DP)
3627 pCoexSta->bA2dpExist = true;
3628 else
3629 pCoexSta->bA2dpExist = false;
3630 if (btInfo & BT_INFO_8723B_2ANT_B_HID)
3631 pCoexSta->bHidExist = true;
3632 else
3633 pCoexSta->bHidExist = false;
3634 if (btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO)
3635 pCoexSta->bScoExist = true;
3636 else
3637 pCoexSta->bScoExist = false;
3638 }
3639
3640 halbtc8723b2ant_UpdateBtLinkInfo(pBtCoexist);
3641
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) {
3646 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE;
3647 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
3648 } else if (
3649 (btInfo&BT_INFO_8723B_2ANT_B_SCO_ESCO) ||
3650 (btInfo&BT_INFO_8723B_2ANT_B_SCO_BUSY)
3651 ) {
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"));
3657 } else {
3658 pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_MAX;
3659 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
3660 }
3661
3662 if (
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)
3666 ) {
3667 bBtBusy = true;
3668 bLimitedDig = true;
3669 } else {
3670 bBtBusy = false;
3671 bLimitedDig = false;
3672 }
3673
3674 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
3675
3676 pCoexDm->bLimitedDig = bLimitedDig;
3677 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig);
3678
3679 halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);
3680}
3681
3682void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist)
3683{
3684 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
3685
3686 halbtc8723b2ant_WifiOffHwCfg(pBtCoexist);
3687 pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15);
3688 halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
3689
3690 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
3691}
3692
3693void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
3694{
3695 BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
3696
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);
3704 }
3705}
3706
3707void EXhalbtc8723b2ant_Periodical(PBTC_COEXIST pBtCoexist)
3708{
3709 static u8 disVerInfoCnt;
3710 u32 fwVer = 0, btPatchVer = 0;
3711
3712 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical ===========================\n"));
3713
3714 if (disVerInfoCnt <= 5) {
3715 disVerInfoCnt += 1;
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"));
3722 }
3723
3724 if (
3725 halbtc8723b2ant_IsWifiStatusChanged(pBtCoexist) ||
3726 pCoexDm->bAutoTdmaAdjust
3727 )
3728 halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);
3729}
3730