1 /* SPDX-License-Identifier: GPL-2.0 */
2 //============================================================
3 // Description:
4 //
5 // This file is for RTL8192E Co-exist mechanism
6 //
7 // History
8 // 2012/11/15 Cosa first check in.
9 //
10 //============================================================
11
12 //============================================================
13 // include files
14 //============================================================
15 #include "Mp_Precomp.h"
16 #if(BT_30_SUPPORT == 1)
17 //============================================================
18 // Global variables, these are static variables
19 //============================================================
20 static COEX_DM_8192E_2ANT GLCoexDm8192e2Ant;
21 static PCOEX_DM_8192E_2ANT pCoexDm=&GLCoexDm8192e2Ant;
22 static COEX_STA_8192E_2ANT GLCoexSta8192e2Ant;
23 static PCOEX_STA_8192E_2ANT pCoexSta=&GLCoexSta8192e2Ant;
24
25 const char *const GLBtInfoSrc8192e2Ant[]={
26 "BT Info[wifi fw]",
27 "BT Info[bt rsp]",
28 "BT Info[bt auto report]",
29 };
30
31 u4Byte GLCoexVerDate8192e2Ant=20150615;
32 u4Byte GLCoexVer8192e2Ant=0x41;
33
34 //============================================================
35 // local function proto type if needed
36 //============================================================
37 //============================================================
38 // local function start with halbtc8192e2ant_
39 //============================================================
40 u1Byte
halbtc8192e2ant_BtRssiState(u1Byte levelNum,u1Byte rssiThresh,u1Byte rssiThresh1)41 halbtc8192e2ant_BtRssiState(
42 u1Byte levelNum,
43 u1Byte rssiThresh,
44 u1Byte rssiThresh1
45 )
46 {
47 s4Byte btRssi=0;
48 u1Byte btRssiState=pCoexSta->preBtRssiState;
49
50 btRssi = pCoexSta->btRssi;
51
52 if(levelNum == 2)
53 {
54 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
55 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
56 {
57 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT))
58 {
59 btRssiState = BTC_RSSI_STATE_HIGH;
60 }
61 else
62 {
63 btRssiState = BTC_RSSI_STATE_STAY_LOW;
64 }
65 }
66 else
67 {
68 if(btRssi < rssiThresh)
69 {
70 btRssiState = BTC_RSSI_STATE_LOW;
71 }
72 else
73 {
74 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
75 }
76 }
77 }
78 else if(levelNum == 3)
79 {
80 if(rssiThresh > rssiThresh1)
81 {
82 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n"));
83 return pCoexSta->preBtRssiState;
84 }
85
86 if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
87 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
88 {
89 if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT))
90 {
91 btRssiState = BTC_RSSI_STATE_MEDIUM;
92 }
93 else
94 {
95 btRssiState = BTC_RSSI_STATE_STAY_LOW;
96 }
97 }
98 else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
99 (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
100 {
101 if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT))
102 {
103 btRssiState = BTC_RSSI_STATE_HIGH;
104 }
105 else if(btRssi < rssiThresh)
106 {
107 btRssiState = BTC_RSSI_STATE_LOW;
108 }
109 else
110 {
111 btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
112 }
113 }
114 else
115 {
116 if(btRssi < rssiThresh1)
117 {
118 btRssiState = BTC_RSSI_STATE_MEDIUM;
119 }
120 else
121 {
122 btRssiState = BTC_RSSI_STATE_STAY_HIGH;
123 }
124 }
125 }
126
127 pCoexSta->preBtRssiState = btRssiState;
128
129 return btRssiState;
130 }
131
132 u1Byte
halbtc8192e2ant_WifiRssiState(IN PBTC_COEXIST pBtCoexist,IN u1Byte index,IN u1Byte levelNum,IN u1Byte rssiThresh,IN u1Byte rssiThresh1)133 halbtc8192e2ant_WifiRssiState(
134 IN PBTC_COEXIST pBtCoexist,
135 IN u1Byte index,
136 IN u1Byte levelNum,
137 IN u1Byte rssiThresh,
138 IN u1Byte rssiThresh1
139 )
140 {
141 s4Byte wifiRssi=0;
142 u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
143
144 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
145
146 if(levelNum == 2)
147 {
148 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
149 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
150 {
151 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT))
152 {
153 wifiRssiState = BTC_RSSI_STATE_HIGH;
154 }
155 else
156 {
157 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
158 }
159 }
160 else
161 {
162 if(wifiRssi < rssiThresh)
163 {
164 wifiRssiState = BTC_RSSI_STATE_LOW;
165 }
166 else
167 {
168 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
169 }
170 }
171 }
172 else if(levelNum == 3)
173 {
174 if(rssiThresh > rssiThresh1)
175 {
176 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n"));
177 return pCoexSta->preWifiRssiState[index];
178 }
179
180 if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
181 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
182 {
183 if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT))
184 {
185 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
186 }
187 else
188 {
189 wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
190 }
191 }
192 else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
193 (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
194 {
195 if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT))
196 {
197 wifiRssiState = BTC_RSSI_STATE_HIGH;
198 }
199 else if(wifiRssi < rssiThresh)
200 {
201 wifiRssiState = BTC_RSSI_STATE_LOW;
202 }
203 else
204 {
205 wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
206 }
207 }
208 else
209 {
210 if(wifiRssi < rssiThresh1)
211 {
212 wifiRssiState = BTC_RSSI_STATE_MEDIUM;
213 }
214 else
215 {
216 wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
217 }
218 }
219 }
220
221 pCoexSta->preWifiRssiState[index] = wifiRssiState;
222
223 return wifiRssiState;
224 }
225
226 VOID
halbtc8192e2ant_MonitorBtEnableDisable(IN PBTC_COEXIST pBtCoexist)227 halbtc8192e2ant_MonitorBtEnableDisable(
228 IN PBTC_COEXIST pBtCoexist
229 )
230 {
231 static BOOLEAN bPreBtDisabled=FALSE;
232 static u4Byte btDisableCnt=0;
233 BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE;
234
235 // This function check if bt is disabled
236
237 if( pCoexSta->highPriorityTx == 0 &&
238 pCoexSta->highPriorityRx == 0 &&
239 pCoexSta->lowPriorityTx == 0 &&
240 pCoexSta->lowPriorityRx == 0)
241 {
242 bBtActive = FALSE;
243 }
244 if( pCoexSta->highPriorityTx == 0xffff &&
245 pCoexSta->highPriorityRx == 0xffff &&
246 pCoexSta->lowPriorityTx == 0xffff &&
247 pCoexSta->lowPriorityRx == 0xffff)
248 {
249 bBtActive = FALSE;
250 }
251 if(bBtActive)
252 {
253 btDisableCnt = 0;
254 bBtDisabled = FALSE;
255 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
256 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n"));
257 }
258 else
259 {
260 btDisableCnt++;
261 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n",
262 btDisableCnt));
263 if(btDisableCnt >= 2)
264 {
265 bBtDisabled = TRUE;
266 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
267 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n"));
268 }
269 }
270 if(bPreBtDisabled != bBtDisabled)
271 {
272 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n",
273 (bPreBtDisabled ? "disabled":"enabled"),
274 (bBtDisabled ? "disabled":"enabled")));
275 bPreBtDisabled = bBtDisabled;
276 if(!bBtDisabled)
277 {
278 }
279 else
280 {
281 }
282 }
283 }
284
285 u4Byte
halbtc8192e2ant_DecideRaMask(IN PBTC_COEXIST pBtCoexist,IN u1Byte ssType,IN u4Byte raMaskType)286 halbtc8192e2ant_DecideRaMask(
287 IN PBTC_COEXIST pBtCoexist,
288 IN u1Byte ssType,
289 IN u4Byte raMaskType
290 )
291 {
292 u4Byte disRaMask=0x0;
293
294 switch(raMaskType)
295 {
296 case 0: // normal mode
297 if(ssType == 2)
298 disRaMask = 0x0; // enable 2ss
299 else
300 disRaMask = 0xfff00000; // disable 2ss
301 break;
302 case 1: // disable cck 1/2
303 if(ssType == 2)
304 disRaMask = 0x00000003; // enable 2ss
305 else
306 disRaMask = 0xfff00003; // disable 2ss
307 break;
308 case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4
309 if(ssType == 2)
310 disRaMask = 0x0001f1f7; // enable 2ss
311 else
312 disRaMask = 0xfff1f1f7; // disable 2ss
313 break;
314 default:
315 break;
316 }
317
318 return disRaMask;
319 }
320
321 VOID
halbtc8192e2ant_UpdateRaMask(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u4Byte disRateMask)322 halbtc8192e2ant_UpdateRaMask(
323 IN PBTC_COEXIST pBtCoexist,
324 IN BOOLEAN bForceExec,
325 IN u4Byte disRateMask
326 )
327 {
328 pCoexDm->curRaMask = disRateMask;
329
330 if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask))
331 {
332 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask);
333 }
334 pCoexDm->preRaMask = pCoexDm->curRaMask;
335 }
336
337 VOID
halbtc8192e2ant_AutoRateFallbackRetry(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte type)338 halbtc8192e2ant_AutoRateFallbackRetry(
339 IN PBTC_COEXIST pBtCoexist,
340 IN BOOLEAN bForceExec,
341 IN u1Byte type
342 )
343 {
344 BOOLEAN bWifiUnderBMode=FALSE;
345
346 pCoexDm->curArfrType = type;
347
348 if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType))
349 {
350 switch(pCoexDm->curArfrType)
351 {
352 case 0: // normal mode
353 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1);
354 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2);
355 break;
356 case 1:
357 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
358 if(bWifiUnderBMode)
359 {
360 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
361 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101);
362 }
363 else
364 {
365 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);
366 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201);
367 }
368 break;
369 default:
370 break;
371 }
372 }
373
374 pCoexDm->preArfrType = pCoexDm->curArfrType;
375 }
376
377 VOID
halbtc8192e2ant_RetryLimit(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte type)378 halbtc8192e2ant_RetryLimit(
379 IN PBTC_COEXIST pBtCoexist,
380 IN BOOLEAN bForceExec,
381 IN u1Byte type
382 )
383 {
384 pCoexDm->curRetryLimitType = type;
385
386 if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType))
387 {
388 switch(pCoexDm->curRetryLimitType)
389 {
390 case 0: // normal mode
391 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit);
392 break;
393 case 1: // retry limit=8
394 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808);
395 break;
396 default:
397 break;
398 }
399 }
400
401 pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType;
402 }
403
404 VOID
halbtc8192e2ant_AmpduMaxTime(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte type)405 halbtc8192e2ant_AmpduMaxTime(
406 IN PBTC_COEXIST pBtCoexist,
407 IN BOOLEAN bForceExec,
408 IN u1Byte type
409 )
410 {
411 pCoexDm->curAmpduTimeType = type;
412
413 if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType))
414 {
415 switch(pCoexDm->curAmpduTimeType)
416 {
417 case 0: // normal mode
418 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime);
419 break;
420 case 1: // AMPDU timw = 0x38 * 32us
421 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38);
422 break;
423 default:
424 break;
425 }
426 }
427
428 pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType;
429 }
430
431 VOID
halbtc8192e2ant_LimitedTx(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte raMaskType,IN u1Byte arfrType,IN u1Byte retryLimitType,IN u1Byte ampduTimeType)432 halbtc8192e2ant_LimitedTx(
433 IN PBTC_COEXIST pBtCoexist,
434 IN BOOLEAN bForceExec,
435 IN u1Byte raMaskType,
436 IN u1Byte arfrType,
437 IN u1Byte retryLimitType,
438 IN u1Byte ampduTimeType
439 )
440 {
441 u4Byte disRaMask=0x0;
442
443 pCoexDm->curRaMaskType = raMaskType;
444 disRaMask = halbtc8192e2ant_DecideRaMask(pBtCoexist, pCoexDm->curSsType, raMaskType);
445 halbtc8192e2ant_UpdateRaMask(pBtCoexist, bForceExec, disRaMask);
446
447 halbtc8192e2ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType);
448 halbtc8192e2ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType);
449 halbtc8192e2ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType);
450 }
451
452 VOID
halbtc8192e2ant_LimitedRx(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bRejApAggPkt,IN BOOLEAN bBtCtrlAggBufSize,IN u1Byte aggBufSize)453 halbtc8192e2ant_LimitedRx(
454 IN PBTC_COEXIST pBtCoexist,
455 IN BOOLEAN bForceExec,
456 IN BOOLEAN bRejApAggPkt,
457 IN BOOLEAN bBtCtrlAggBufSize,
458 IN u1Byte aggBufSize
459 )
460 {
461 BOOLEAN bRejectRxAgg=bRejApAggPkt;
462 BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize;
463 u1Byte rxAggSize=aggBufSize;
464
465 //============================================
466 // Rx Aggregation related setting
467 //============================================
468 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);
469 // decide BT control aggregation buf size or not
470 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);
471 // aggregation buf size, only work when BT control Rx aggregation size.
472 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
473 // real update aggregation setting
474 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
475
476
477 }
478
479 VOID
halbtc8192e2ant_MonitorBtCtr(IN PBTC_COEXIST pBtCoexist)480 halbtc8192e2ant_MonitorBtCtr(
481 IN PBTC_COEXIST pBtCoexist
482 )
483 {
484 u4Byte regHPTxRx, regLPTxRx, u4Tmp;
485 u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
486 u1Byte u1Tmp;
487
488 regHPTxRx = 0x770;
489 regLPTxRx = 0x774;
490
491 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
492 regHPTx = u4Tmp & bMaskLWord;
493 regHPRx = (u4Tmp & bMaskHWord)>>16;
494
495 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
496 regLPTx = u4Tmp & bMaskLWord;
497 regLPRx = (u4Tmp & bMaskHWord)>>16;
498
499 pCoexSta->highPriorityTx = regHPTx;
500 pCoexSta->highPriorityRx = regHPRx;
501 pCoexSta->lowPriorityTx = regLPTx;
502 pCoexSta->lowPriorityRx = regLPRx;
503
504 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
505 regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
506 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
507 regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
508
509 // reset counter
510 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
511 }
512
513 VOID
halbtc8192e2ant_QueryBtInfo(IN PBTC_COEXIST pBtCoexist)514 halbtc8192e2ant_QueryBtInfo(
515 IN PBTC_COEXIST pBtCoexist
516 )
517 {
518 u1Byte H2C_Parameter[1] ={0};
519
520 pCoexSta->bC2hBtInfoReqSent = TRUE;
521
522 H2C_Parameter[0] |= BIT0; // trigger
523
524 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
525 H2C_Parameter[0]));
526
527 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
528 }
529
530 BOOLEAN
halbtc8192e2ant_IsWifiStatusChanged(IN PBTC_COEXIST pBtCoexist)531 halbtc8192e2ant_IsWifiStatusChanged(
532 IN PBTC_COEXIST pBtCoexist
533 )
534 {
535 static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;
536 BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;
537 BOOLEAN bWifiConnected=FALSE;
538 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH;
539
540
541 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
542 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
543 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
544 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
545
546 if(bWifiConnected)
547 {
548 if(bWifiBusy != bPreWifiBusy)
549 {
550 bPreWifiBusy = bWifiBusy;
551 return TRUE;
552 }
553 if(bUnder4way != bPreUnder4way)
554 {
555 bPreUnder4way = bUnder4way;
556 return TRUE;
557 }
558 if(bBtHsOn != bPreBtHsOn)
559 {
560 bPreBtHsOn = bBtHsOn;
561 return TRUE;
562 }
563
564
565 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist,3, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
566
567 if ( (BTC_RSSI_STATE_HIGH ==wifiRssiState ) || (BTC_RSSI_STATE_LOW ==wifiRssiState ))
568 {
569 return TRUE;
570 }
571
572 }
573
574 return FALSE;
575 }
576
577 VOID
halbtc8192e2ant_UpdateBtLinkInfo(IN PBTC_COEXIST pBtCoexist)578 halbtc8192e2ant_UpdateBtLinkInfo(
579 IN PBTC_COEXIST pBtCoexist
580 )
581 {
582 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
583 BOOLEAN bBtHsOn=FALSE;
584
585 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
586
587 pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
588 pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
589 pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
590 pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
591 pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
592
593 // work around for HS mode.
594 if(bBtHsOn)
595 {
596 pBtLinkInfo->bPanExist = TRUE;
597 pBtLinkInfo->bBtLinkExist = TRUE;
598 }
599
600 // check if Sco only
601 if( pBtLinkInfo->bScoExist &&
602 !pBtLinkInfo->bA2dpExist &&
603 !pBtLinkInfo->bPanExist &&
604 !pBtLinkInfo->bHidExist )
605 pBtLinkInfo->bScoOnly = TRUE;
606 else
607 pBtLinkInfo->bScoOnly = FALSE;
608
609 // check if A2dp only
610 if( !pBtLinkInfo->bScoExist &&
611 pBtLinkInfo->bA2dpExist &&
612 !pBtLinkInfo->bPanExist &&
613 !pBtLinkInfo->bHidExist )
614 pBtLinkInfo->bA2dpOnly = TRUE;
615 else
616 pBtLinkInfo->bA2dpOnly = FALSE;
617
618 // check if Pan only
619 if( !pBtLinkInfo->bScoExist &&
620 !pBtLinkInfo->bA2dpExist &&
621 pBtLinkInfo->bPanExist &&
622 !pBtLinkInfo->bHidExist )
623 pBtLinkInfo->bPanOnly = TRUE;
624 else
625 pBtLinkInfo->bPanOnly = FALSE;
626
627 // check if Hid only
628 if( !pBtLinkInfo->bScoExist &&
629 !pBtLinkInfo->bA2dpExist &&
630 !pBtLinkInfo->bPanExist &&
631 pBtLinkInfo->bHidExist )
632 pBtLinkInfo->bHidOnly = TRUE;
633 else
634 pBtLinkInfo->bHidOnly = FALSE;
635 }
636
637 u1Byte
halbtc8192e2ant_ActionAlgorithm(IN PBTC_COEXIST pBtCoexist)638 halbtc8192e2ant_ActionAlgorithm(
639 IN PBTC_COEXIST pBtCoexist
640 )
641 {
642 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
643 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
644 BOOLEAN bBtHsOn=FALSE;
645 u1Byte algorithm=BT_8192E_2ANT_COEX_ALGO_UNDEFINED;
646 u1Byte numOfDiffProfile=0;
647
648 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
649
650 if(!pBtLinkInfo->bBtLinkExist)
651 {
652 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n"));
653 return algorithm;
654 }
655
656 if(pBtLinkInfo->bScoExist)
657 numOfDiffProfile++;
658 if(pBtLinkInfo->bHidExist)
659 numOfDiffProfile++;
660 if(pBtLinkInfo->bPanExist)
661 numOfDiffProfile++;
662 if(pBtLinkInfo->bA2dpExist)
663 numOfDiffProfile++;
664
665
666 if(numOfDiffProfile == 1)
667 {
668 if(pBtLinkInfo->bScoExist)
669 {
670 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n"));
671 algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
672 }
673 else
674 {
675 if(pBtLinkInfo->bHidExist)
676 {
677 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n"));
678 algorithm = BT_8192E_2ANT_COEX_ALGO_HID;
679 }
680 else if(pBtLinkInfo->bA2dpExist)
681 {
682 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n"));
683 algorithm = BT_8192E_2ANT_COEX_ALGO_A2DP;
684 }
685 else if(pBtLinkInfo->bPanExist)
686 {
687 if(bBtHsOn)
688 {
689 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n"));
690 algorithm = BT_8192E_2ANT_COEX_ALGO_PANHS;
691 }
692 else
693 {
694 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n"));
695 algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR;
696 }
697 }
698 }
699 }
700 else if(numOfDiffProfile == 2)
701 {
702 if(pBtLinkInfo->bScoExist)
703 {
704 if(pBtLinkInfo->bHidExist)
705 {
706 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n"));
707 algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
708 }
709 else if(pBtLinkInfo->bA2dpExist)
710 {
711 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n"));
712 algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
713 }
714 else if(pBtLinkInfo->bPanExist)
715 {
716 if(bBtHsOn)
717 {
718 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n"));
719 algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
720 }
721 else
722 {
723 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n"));
724 algorithm = BT_8192E_2ANT_COEX_ALGO_SCO_PAN;
725 }
726 }
727 }
728 else
729 {
730 if( pBtLinkInfo->bHidExist &&
731 pBtLinkInfo->bA2dpExist )
732 {
733 if(pStackInfo->numOfHid >= 2)
734 {
735 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID*2 + A2DP\n"));
736 algorithm = BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
737 }
738 else
739 {
740 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n"));
741 algorithm = BT_8192E_2ANT_COEX_ALGO_HID_A2DP;
742 }
743 }
744 else if( pBtLinkInfo->bHidExist &&
745 pBtLinkInfo->bPanExist )
746 {
747 if(bBtHsOn)
748 {
749 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n"));
750 algorithm = BT_8192E_2ANT_COEX_ALGO_HID;
751 }
752 else
753 {
754 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n"));
755 algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
756 }
757 }
758 else if( pBtLinkInfo->bPanExist &&
759 pBtLinkInfo->bA2dpExist )
760 {
761 if(bBtHsOn)
762 {
763 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n"));
764 algorithm = BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS;
765 }
766 else
767 {
768 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n"));
769 algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP;
770 }
771 }
772 }
773 }
774 else if(numOfDiffProfile == 3)
775 {
776 if(pBtLinkInfo->bScoExist)
777 {
778 if( pBtLinkInfo->bHidExist &&
779 pBtLinkInfo->bA2dpExist )
780 {
781 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> HID\n"));
782 algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
783 }
784 else if( pBtLinkInfo->bHidExist &&
785 pBtLinkInfo->bPanExist )
786 {
787 if(bBtHsOn)
788 {
789 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS)\n"));
790 algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
791 }
792 else
793 {
794 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
795 algorithm = BT_8192E_2ANT_COEX_ALGO_SCO_PAN;
796 }
797 }
798 else if( pBtLinkInfo->bPanExist &&
799 pBtLinkInfo->bA2dpExist )
800 {
801 if(bBtHsOn)
802 {
803 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
804 algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
805 }
806 else
807 {
808 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
809 algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
810 }
811 }
812 }
813 else
814 {
815 if( pBtLinkInfo->bHidExist &&
816 pBtLinkInfo->bPanExist &&
817 pBtLinkInfo->bA2dpExist )
818 {
819 if(bBtHsOn)
820 {
821 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
822 algorithm = BT_8192E_2ANT_COEX_ALGO_HID_A2DP;
823 }
824 else
825 {
826 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
827 algorithm = BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
828 }
829 }
830 }
831 }
832 else if(numOfDiffProfile >= 3)
833 {
834 if(pBtLinkInfo->bScoExist)
835 {
836 if( pBtLinkInfo->bHidExist &&
837 pBtLinkInfo->bPanExist &&
838 pBtLinkInfo->bA2dpExist )
839 {
840 if(bBtHsOn)
841 {
842 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
843
844 }
845 else
846 {
847 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
848 algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
849 }
850 }
851 }
852 }
853
854 return algorithm;
855 }
856
857 VOID
halbtc8192e2ant_SetFwDacSwingLevel(IN PBTC_COEXIST pBtCoexist,IN u1Byte dacSwingLvl)858 halbtc8192e2ant_SetFwDacSwingLevel(
859 IN PBTC_COEXIST pBtCoexist,
860 IN u1Byte dacSwingLvl
861 )
862 {
863 u1Byte H2C_Parameter[1] ={0};
864
865 // There are several type of dacswing
866 // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
867 H2C_Parameter[0] = dacSwingLvl;
868
869 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl));
870 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0]));
871
872 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter);
873 }
874
875 VOID
halbtc8192e2ant_SetFwDecBtPwr(IN PBTC_COEXIST pBtCoexist,IN u1Byte decBtPwrLvl)876 halbtc8192e2ant_SetFwDecBtPwr(
877 IN PBTC_COEXIST pBtCoexist,
878 IN u1Byte decBtPwrLvl
879 )
880 {
881 u1Byte H2C_Parameter[1] ={0};
882
883 H2C_Parameter[0] = decBtPwrLvl;
884
885 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n",
886 decBtPwrLvl, H2C_Parameter[0]));
887
888 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter);
889 }
890
891 VOID
halbtc8192e2ant_DecBtPwr(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte decBtPwrLvl)892 halbtc8192e2ant_DecBtPwr(
893 IN PBTC_COEXIST pBtCoexist,
894 IN BOOLEAN bForceExec,
895 IN u1Byte decBtPwrLvl
896 )
897 {
898 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power level = %d\n",
899 (bForceExec? "force to":""), decBtPwrLvl));
900 pCoexDm->curBtDecPwrLvl = decBtPwrLvl;
901
902 if(!bForceExec)
903 {
904 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], preBtDecPwrLvl=%d, curBtDecPwrLvl=%d\n",
905 pCoexDm->preBtDecPwrLvl, pCoexDm->curBtDecPwrLvl));
906 #if 0 // work around, avoid h2c command fail.
907 if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl)
908 return;
909 #endif
910 }
911 halbtc8192e2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
912
913 pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
914 }
915
916 VOID
halbtc8192e2ant_SetBtAutoReport(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bEnableAutoReport)917 halbtc8192e2ant_SetBtAutoReport(
918 IN PBTC_COEXIST pBtCoexist,
919 IN BOOLEAN bEnableAutoReport
920 )
921 {
922 u1Byte H2C_Parameter[1] ={0};
923
924 H2C_Parameter[0] = 0;
925
926 if(bEnableAutoReport)
927 {
928 H2C_Parameter[0] |= BIT0;
929 }
930
931 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
932 (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));
933
934 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter);
935 }
936
937 VOID
halbtc8192e2ant_BtAutoReport(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bEnableAutoReport)938 halbtc8192e2ant_BtAutoReport(
939 IN PBTC_COEXIST pBtCoexist,
940 IN BOOLEAN bForceExec,
941 IN BOOLEAN bEnableAutoReport
942 )
943 {
944 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n",
945 (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
946 pCoexDm->bCurBtAutoReport = bEnableAutoReport;
947
948 if(!bForceExec)
949 {
950 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
951 pCoexDm->bPreBtAutoReport, pCoexDm->bCurBtAutoReport));
952
953 if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
954 return;
955 }
956 halbtc8192e2ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
957
958 pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
959 }
960
961 VOID
halbtc8192e2ant_FwDacSwingLvl(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte fwDacSwingLvl)962 halbtc8192e2ant_FwDacSwingLvl(
963 IN PBTC_COEXIST pBtCoexist,
964 IN BOOLEAN bForceExec,
965 IN u1Byte fwDacSwingLvl
966 )
967 {
968 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n",
969 (bForceExec? "force to":""), fwDacSwingLvl));
970 pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
971
972 if(!bForceExec)
973 {
974 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], preFwDacSwingLvl=%d, curFwDacSwingLvl=%d\n",
975 pCoexDm->preFwDacSwingLvl, pCoexDm->curFwDacSwingLvl));
976
977 if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
978 return;
979 }
980
981 halbtc8192e2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
982
983 pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
984 }
985
986 VOID
halbtc8192e2ant_SetSwRfRxLpfCorner(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bRxRfShrinkOn)987 halbtc8192e2ant_SetSwRfRxLpfCorner(
988 IN PBTC_COEXIST pBtCoexist,
989 IN BOOLEAN bRxRfShrinkOn
990 )
991 {
992 if(bRxRfShrinkOn)
993 {
994 //Shrink RF Rx LPF corner
995 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
996 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc);
997 }
998 else
999 {
1000 //Resume RF Rx LPF corner
1001 // After initialized, we can use pCoexDm->btRf0x1eBackup
1002 if(pBtCoexist->bInitilized)
1003 {
1004 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
1005 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
1006 }
1007 }
1008 }
1009
1010 VOID
halbtc8192e2ant_RfShrink(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bRxRfShrinkOn)1011 halbtc8192e2ant_RfShrink(
1012 IN PBTC_COEXIST pBtCoexist,
1013 IN BOOLEAN bForceExec,
1014 IN BOOLEAN bRxRfShrinkOn
1015 )
1016 {
1017 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
1018 (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
1019 pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
1020
1021 if(!bForceExec)
1022 {
1023 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n",
1024 pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink));
1025
1026 if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
1027 return;
1028 }
1029 halbtc8192e2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
1030
1031 pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
1032 }
1033
1034 VOID
halbtc8192e2ant_SetSwPenaltyTxRateAdaptive(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bLowPenaltyRa)1035 halbtc8192e2ant_SetSwPenaltyTxRateAdaptive(
1036 IN PBTC_COEXIST pBtCoexist,
1037 IN BOOLEAN bLowPenaltyRa
1038 )
1039 {
1040 u1Byte H2C_Parameter[6] ={0};
1041
1042 H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty
1043
1044 if(bLowPenaltyRa)
1045 {
1046 H2C_Parameter[1] |= BIT0;
1047 H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36
1048 H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54
1049 H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48
1050 H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36
1051 }
1052
1053 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s",
1054 (bLowPenaltyRa? "ON!!":"OFF!!")) );
1055
1056 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);
1057 }
1058
1059 VOID
halbtc8192e2ant_LowPenaltyRa(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bLowPenaltyRa)1060 halbtc8192e2ant_LowPenaltyRa(
1061 IN PBTC_COEXIST pBtCoexist,
1062 IN BOOLEAN bForceExec,
1063 IN BOOLEAN bLowPenaltyRa
1064 )
1065 {
1066 //return;
1067 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
1068 (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
1069 pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
1070
1071 if(!bForceExec)
1072 {
1073 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
1074 pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
1075
1076 if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
1077 return;
1078 }
1079 halbtc8192e2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
1080
1081 pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
1082 }
1083
1084 VOID
halbtc8192e2ant_SetDacSwingReg(IN PBTC_COEXIST pBtCoexist,IN u4Byte level)1085 halbtc8192e2ant_SetDacSwingReg(
1086 IN PBTC_COEXIST pBtCoexist,
1087 IN u4Byte level
1088 )
1089 {
1090 u1Byte val=(u1Byte)level;
1091
1092 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Write SwDacSwing = 0x%x\n", level));
1093 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val);
1094 }
1095
1096 VOID
halbtc8192e2ant_SetSwFullTimeDacSwing(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bSwDacSwingOn,IN u4Byte swDacSwingLvl)1097 halbtc8192e2ant_SetSwFullTimeDacSwing(
1098 IN PBTC_COEXIST pBtCoexist,
1099 IN BOOLEAN bSwDacSwingOn,
1100 IN u4Byte swDacSwingLvl
1101 )
1102 {
1103 if(bSwDacSwingOn)
1104 {
1105 halbtc8192e2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
1106 }
1107 else
1108 {
1109 halbtc8192e2ant_SetDacSwingReg(pBtCoexist, 0x18);
1110 }
1111 }
1112
1113
1114 VOID
halbtc8192e2ant_DacSwing(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bDacSwingOn,IN u4Byte dacSwingLvl)1115 halbtc8192e2ant_DacSwing(
1116 IN PBTC_COEXIST pBtCoexist,
1117 IN BOOLEAN bForceExec,
1118 IN BOOLEAN bDacSwingOn,
1119 IN u4Byte dacSwingLvl
1120 )
1121 {
1122 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
1123 (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
1124 pCoexDm->bCurDacSwingOn = bDacSwingOn;
1125 pCoexDm->curDacSwingLvl = dacSwingLvl;
1126
1127 if(!bForceExec)
1128 {
1129 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
1130 pCoexDm->bPreDacSwingOn, pCoexDm->preDacSwingLvl,
1131 pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl));
1132
1133 if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
1134 (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
1135 return;
1136 }
1137 delay_ms(30);
1138 halbtc8192e2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
1139
1140 pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
1141 pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
1142 }
1143
1144 VOID
halbtc8192e2ant_SetAdcBackOff(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bAdcBackOff)1145 halbtc8192e2ant_SetAdcBackOff(
1146 IN PBTC_COEXIST pBtCoexist,
1147 IN BOOLEAN bAdcBackOff
1148 )
1149 {
1150 if(bAdcBackOff)
1151 {
1152 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n"));
1153 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc05, 0x30, 0x3);
1154 }
1155 else
1156 {
1157 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n"));
1158 pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc05, 0x30, 0x1);
1159 }
1160 }
1161
1162 VOID
halbtc8192e2ant_AdcBackOff(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bAdcBackOff)1163 halbtc8192e2ant_AdcBackOff(
1164 IN PBTC_COEXIST pBtCoexist,
1165 IN BOOLEAN bForceExec,
1166 IN BOOLEAN bAdcBackOff
1167 )
1168 {
1169 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n",
1170 (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));
1171 pCoexDm->bCurAdcBackOff = bAdcBackOff;
1172
1173 if(!bForceExec)
1174 {
1175 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n",
1176 pCoexDm->bPreAdcBackOff, pCoexDm->bCurAdcBackOff));
1177
1178 if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff)
1179 return;
1180 }
1181 halbtc8192e2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
1182
1183 pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
1184 }
1185
1186 VOID
halbtc8192e2ant_SetAgcTable(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bAgcTableEn)1187 halbtc8192e2ant_SetAgcTable(
1188 IN PBTC_COEXIST pBtCoexist,
1189 IN BOOLEAN bAgcTableEn
1190 )
1191 {
1192 u1Byte rssiAdjustVal=0;
1193
1194 //=================BB AGC Gain Table
1195 if(bAgcTableEn)
1196 {
1197 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table On!\n"));
1198 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x0a1A0001);
1199 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x091B0001);
1200 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x081C0001);
1201 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x071D0001);
1202 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x061E0001);
1203 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x051F0001);
1204 }
1205 else
1206 {
1207 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table Off!\n"));
1208 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001);
1209 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001);
1210 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001);
1211 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001);
1212 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001);
1213 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001);
1214 }
1215
1216 #if 0
1217 //=================RF Gain
1218 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
1219 if(bAgcTableEn)
1220 {
1221 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n"));
1222 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff);
1223 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe);
1224 }
1225 else
1226 {
1227 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n"));
1228 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3);
1229 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6);
1230 }
1231 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
1232
1233 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1);
1234 if(bAgcTableEn)
1235 {
1236 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n"));
1237 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff);
1238 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe);
1239 }
1240 else
1241 {
1242 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n"));
1243 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3);
1244 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6);
1245 }
1246 pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0);
1247
1248 // set rssiAdjustVal for wifi module.
1249 if(bAgcTableEn)
1250 {
1251 rssiAdjustVal = 8;
1252 }
1253 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
1254 #endif
1255
1256 }
1257
1258 VOID
halbtc8192e2ant_AgcTable(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bAgcTableEn)1259 halbtc8192e2ant_AgcTable(
1260 IN PBTC_COEXIST pBtCoexist,
1261 IN BOOLEAN bForceExec,
1262 IN BOOLEAN bAgcTableEn
1263 )
1264 {
1265 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n",
1266 (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));
1267 pCoexDm->bCurAgcTableEn = bAgcTableEn;
1268
1269 if(!bForceExec)
1270 {
1271 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
1272 pCoexDm->bPreAgcTableEn, pCoexDm->bCurAgcTableEn));
1273
1274 if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
1275 return;
1276 }
1277 halbtc8192e2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
1278
1279 pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
1280 }
1281
1282 VOID
halbtc8192e2ant_SetCoexTable(IN PBTC_COEXIST pBtCoexist,IN u4Byte val0x6c0,IN u4Byte val0x6c4,IN u4Byte val0x6c8,IN u1Byte val0x6cc)1283 halbtc8192e2ant_SetCoexTable(
1284 IN PBTC_COEXIST pBtCoexist,
1285 IN u4Byte val0x6c0,
1286 IN u4Byte val0x6c4,
1287 IN u4Byte val0x6c8,
1288 IN u1Byte val0x6cc
1289 )
1290 {
1291 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
1292 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);
1293
1294 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
1295 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);
1296
1297 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
1298 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);
1299
1300 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
1301 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);
1302 }
1303
1304 VOID
halbtc8192e2ant_CoexTable(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u4Byte val0x6c0,IN u4Byte val0x6c4,IN u4Byte val0x6c8,IN u1Byte val0x6cc)1305 halbtc8192e2ant_CoexTable(
1306 IN PBTC_COEXIST pBtCoexist,
1307 IN BOOLEAN bForceExec,
1308 IN u4Byte val0x6c0,
1309 IN u4Byte val0x6c4,
1310 IN u4Byte val0x6c8,
1311 IN u1Byte val0x6cc
1312 )
1313 {
1314 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
1315 (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc));
1316 pCoexDm->curVal0x6c0 = val0x6c0;
1317 pCoexDm->curVal0x6c4 = val0x6c4;
1318 pCoexDm->curVal0x6c8 = val0x6c8;
1319 pCoexDm->curVal0x6cc = val0x6cc;
1320
1321 if(!bForceExec)
1322 {
1323 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c4=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
1324 pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
1325 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
1326 pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
1327
1328 if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
1329 (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
1330 (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
1331 (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
1332 return;
1333 }
1334 halbtc8192e2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
1335
1336 pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
1337 pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
1338 pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
1339 pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
1340 }
1341
1342 VOID
halbtc8192e2ant_CoexTableWithType(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte type)1343 halbtc8192e2ant_CoexTableWithType(
1344 IN PBTC_COEXIST pBtCoexist,
1345 IN BOOLEAN bForceExec,
1346 IN u1Byte type
1347 )
1348 {
1349 pCoexSta->nCoexTableType = type;
1350
1351 switch(type)
1352 {
1353 case 0:
1354 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
1355 break;
1356 case 1:
1357 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);
1358 break;
1359 case 2:
1360 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5ffb5ffb, 0xffffff, 0x3);
1361 break;
1362 case 3:
1363 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5fdf5fdf, 0x5fdb5fdb, 0xffffff, 0x3);
1364 break;
1365 case 4:
1366 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0xdfffdfff, 0x5ffb5ffb, 0xffffff, 0x3);
1367 break;
1368 case 5:
1369 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5ddd5ddd, 0x5fdb5fdb, 0xffffff, 0x3);
1370 break;
1371 case 6:
1372 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5a5a5a5a, 0xffffff, 0x3);
1373 break;
1374 case 7:
1375 if(pCoexSta->nScanAPNum <= NOISY_AP_NUM_THRESH)
1376 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xfafafafa, 0xffffff, 0x3);
1377 else
1378 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0x5a5a5a5a, 0xffffff, 0x3);
1379 break;
1380 case 8:
1381 halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5f5f5f5f, 0x5a5a5a5a, 0xffffff, 0x3);
1382 break;
1383 default:
1384 break;
1385 }
1386 }
1387
1388 VOID
halbtc8192e2ant_SetFwIgnoreWlanAct(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bEnable)1389 halbtc8192e2ant_SetFwIgnoreWlanAct(
1390 IN PBTC_COEXIST pBtCoexist,
1391 IN BOOLEAN bEnable
1392 )
1393 {
1394 u1Byte H2C_Parameter[1] ={0};
1395
1396 if(bEnable)
1397 {
1398 H2C_Parameter[0] |= BIT0; // function enable
1399 }
1400
1401 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
1402 H2C_Parameter[0]));
1403
1404 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);
1405 }
1406
1407
1408 VOID
halbtc8192e2ant_IgnoreWlanAct(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bEnable)1409 halbtc8192e2ant_IgnoreWlanAct(
1410 IN PBTC_COEXIST pBtCoexist,
1411 IN BOOLEAN bForceExec,
1412 IN BOOLEAN bEnable
1413 )
1414 {
1415 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n",
1416 (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
1417 pCoexDm->bCurIgnoreWlanAct = bEnable;
1418
1419 if(!bForceExec)
1420 {
1421 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
1422 pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
1423
1424 if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
1425 return;
1426 }
1427 halbtc8192e2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
1428
1429 pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
1430 }
1431
1432
1433 VOID
halbtc8192e2ant_SetLpsRpwm(IN PBTC_COEXIST pBtCoexist,IN u1Byte lpsVal,IN u1Byte rpwmVal)1434 halbtc8192e2ant_SetLpsRpwm(
1435 IN PBTC_COEXIST pBtCoexist,
1436 IN u1Byte lpsVal,
1437 IN u1Byte rpwmVal
1438 )
1439 {
1440 u1Byte lps=lpsVal;
1441 u1Byte rpwm=rpwmVal;
1442
1443 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);
1444 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
1445 }
1446
1447
1448 VOID
halbtc8192e2ant_LpsRpwm(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte lpsVal,IN u1Byte rpwmVal)1449 halbtc8192e2ant_LpsRpwm(
1450 IN PBTC_COEXIST pBtCoexist,
1451 IN BOOLEAN bForceExec,
1452 IN u1Byte lpsVal,
1453 IN u1Byte rpwmVal
1454 )
1455 {
1456 BOOLEAN bForceExecPwrCmd=FALSE;
1457
1458 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
1459 (bForceExec? "force to":""), lpsVal, rpwmVal));
1460 pCoexDm->curLps = lpsVal;
1461 pCoexDm->curRpwm = rpwmVal;
1462
1463 if(!bForceExec)
1464 {
1465 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], preLps/curLps=0x%x/0x%x, preRpwm/curRpwm=0x%x/0x%x!!\n",
1466 pCoexDm->preLps, pCoexDm->curLps, pCoexDm->preRpwm, pCoexDm->curRpwm));
1467
1468 if( (pCoexDm->preLps == pCoexDm->curLps) &&
1469 (pCoexDm->preRpwm == pCoexDm->curRpwm) )
1470 {
1471 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], LPS-RPWM_Last=0x%x , LPS-RPWM_Now=0x%x!!\n",
1472 pCoexDm->preRpwm, pCoexDm->curRpwm));
1473
1474 return;
1475 }
1476 }
1477 halbtc8192e2ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
1478
1479 pCoexDm->preLps = pCoexDm->curLps;
1480 pCoexDm->preRpwm = pCoexDm->curRpwm;
1481 }
1482
1483
1484
1485 VOID
halbtc8192e2ant_SetFwPstdma(IN PBTC_COEXIST pBtCoexist,IN u1Byte byte1,IN u1Byte byte2,IN u1Byte byte3,IN u1Byte byte4,IN u1Byte byte5)1486 halbtc8192e2ant_SetFwPstdma(
1487 IN PBTC_COEXIST pBtCoexist,
1488 IN u1Byte byte1,
1489 IN u1Byte byte2,
1490 IN u1Byte byte3,
1491 IN u1Byte byte4,
1492 IN u1Byte byte5
1493 )
1494 {
1495 u1Byte H2C_Parameter[5] ={0};
1496 u1Byte realByte1=byte1, realByte5=byte5;
1497 BOOLEAN bApEnable=FALSE;
1498
1499 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
1500
1501 if(bApEnable)
1502 {
1503 if(byte1&BIT4 && !(byte1&BIT5))
1504 {
1505 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n"));
1506 realByte1 &= ~BIT4;
1507 realByte1 |= BIT5;
1508
1509 realByte5 |= BIT5;
1510 realByte5 &= ~BIT6;
1511 }
1512 }
1513
1514 H2C_Parameter[0] = realByte1;
1515 H2C_Parameter[1] = byte2;
1516 H2C_Parameter[2] = byte3;
1517 H2C_Parameter[3] = byte4;
1518 H2C_Parameter[4] = realByte5;
1519
1520 pCoexDm->psTdmaPara[0] = realByte1;
1521 pCoexDm->psTdmaPara[1] = byte2;
1522 pCoexDm->psTdmaPara[2] = byte3;
1523 pCoexDm->psTdmaPara[3] = byte4;
1524 pCoexDm->psTdmaPara[4] = realByte5;
1525
1526 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n",
1527 H2C_Parameter[0],
1528 H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
1529
1530 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);
1531 }
1532
1533
1534 VOID
halbtc8192e2ant_SwMechanism1(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bShrinkRxLPF,IN BOOLEAN bLowPenaltyRA,IN BOOLEAN bLimitedDIG,IN BOOLEAN bBTLNAConstrain)1535 halbtc8192e2ant_SwMechanism1(
1536 IN PBTC_COEXIST pBtCoexist,
1537 IN BOOLEAN bShrinkRxLPF,
1538 IN BOOLEAN bLowPenaltyRA,
1539 IN BOOLEAN bLimitedDIG,
1540 IN BOOLEAN bBTLNAConstrain
1541 )
1542 {
1543 /*
1544 u4Byte wifiBw;
1545
1546 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1547
1548 if(BTC_WIFI_BW_HT40 != wifiBw) //only shrink RF Rx LPF for HT40
1549 {
1550 if (bShrinkRxLPF)
1551 bShrinkRxLPF = FALSE;
1552 }
1553 */
1554
1555 halbtc8192e2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);
1556 //halbtc8192e2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
1557 }
1558
1559 VOID
halbtc8192e2ant_SwMechanism2(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bAGCTableShift,IN BOOLEAN bADCBackOff,IN BOOLEAN bSWDACSwing,IN u4Byte dacSwingLvl)1560 halbtc8192e2ant_SwMechanism2(
1561 IN PBTC_COEXIST pBtCoexist,
1562 IN BOOLEAN bAGCTableShift,
1563 IN BOOLEAN bADCBackOff,
1564 IN BOOLEAN bSWDACSwing,
1565 IN u4Byte dacSwingLvl
1566 )
1567 {
1568 halbtc8192e2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);
1569 //halbtc8192e2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff);
1570 halbtc8192e2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);
1571 }
1572
1573 VOID
halbtc8192e2ant_SetAntPath(IN PBTC_COEXIST pBtCoexist,IN u1Byte antPosType,IN BOOLEAN bInitHwCfg,IN BOOLEAN bWifiOff)1574 halbtc8192e2ant_SetAntPath(
1575 IN PBTC_COEXIST pBtCoexist,
1576 IN u1Byte antPosType,
1577 IN BOOLEAN bInitHwCfg,
1578 IN BOOLEAN bWifiOff
1579 )
1580 {
1581 u4Byte u4Tmp=0;
1582
1583 if(bInitHwCfg)
1584 {
1585 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x944, 0x24);
1586 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x930, 0x700700);
1587 if(pBtCoexist->chipInterface == BTC_INTF_USB)
1588 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004);
1589 else
1590 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004);
1591
1592 // 0x4c[27][24]='00', Set Antenna to BB
1593 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1594 u4Tmp &= ~BIT24;
1595 u4Tmp &= ~BIT27;
1596 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1597 }
1598 else if(bWifiOff)
1599 {
1600 if(pBtCoexist->chipInterface == BTC_INTF_USB)
1601 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004);
1602 else
1603 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004);
1604
1605 // 0x4c[27][24]='11', Set Antenna to BT, 0x64[8:7]=0, 0x64[2]=1
1606 u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);
1607 u4Tmp |= BIT24;
1608 u4Tmp |= BIT27;
1609 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);
1610 }
1611
1612 // ext switch setting
1613 switch(antPosType)
1614 {
1615 case BTC_ANT_PATH_WIFI:
1616 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4);
1617 break;
1618 case BTC_ANT_PATH_BT:
1619 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x20);
1620 break;
1621 default:
1622 case BTC_ANT_PATH_PTA:
1623 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4);
1624 break;
1625 }
1626 }
1627
1628 VOID
halbtc8192e2ant_PsTdma(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN BOOLEAN bTurnOn,IN u1Byte type)1629 halbtc8192e2ant_PsTdma(
1630 IN PBTC_COEXIST pBtCoexist,
1631 IN BOOLEAN bForceExec,
1632 IN BOOLEAN bTurnOn,
1633 IN u1Byte type
1634 )
1635 {
1636 BOOLEAN bTurnOnByCnt=FALSE;
1637 u1Byte psTdmaTypeByCnt=0;
1638 s1Byte nWiFiDurationAdjust = 0x0;
1639
1640 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
1641 (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
1642 pCoexDm->bCurPsTdmaOn = bTurnOn;
1643 pCoexDm->curPsTdma = type;
1644
1645 if(!bForceExec)
1646 {
1647 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
1648 pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn));
1649 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
1650 pCoexDm->prePsTdma, pCoexDm->curPsTdma));
1651
1652 if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
1653 (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
1654 return;
1655 }
1656
1657 if (pCoexSta->nScanAPNum >= 40)
1658 nWiFiDurationAdjust = -15;
1659 else if (pCoexSta->nScanAPNum >= 20)
1660 nWiFiDurationAdjust = -10;
1661
1662 /*
1663 if (!pCoexSta->bForceLpsOn) //only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30
1664 {
1665 psTdmaByte0Val = 0x61; //no null-pkt
1666 psTdmaByte3Val = 0x11; // no tx-pause at BT-slot
1667 psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle
1668 }
1669
1670
1671 if ( (type == 3) || (type == 13) || (type == 14) )
1672 {
1673 psTdmaByte4Val = psTdmaByte4Val & 0xbf; //no dynamic slot for multi-profile
1674
1675 if (!bWifiBusy)
1676 psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts)
1677 }
1678
1679 if (pBtLinkInfo->bSlaveRole == TRUE)
1680 psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts)
1681
1682 */
1683 if(bTurnOn)
1684 {
1685 switch(type)
1686 {
1687 case 1:
1688 default: //d1,wb
1689 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x11, 0x10);
1690 break;
1691 case 2:
1692 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x32, 0x03, 0x11, 0x10);
1693 break;
1694 case 3:
1695 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x28, 0x03, 0x11, 0x10);
1696 break;
1697 case 4:
1698 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0x11, 0x10);
1699 break;
1700 case 5: //d1,pb,TXpause
1701 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x63, 0x3c, 0x03, 0x90, 0x10);
1702 break;
1703 case 6:
1704 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x63, 0x32, 0x03, 0x90, 0x10);
1705 break;
1706 case 7:
1707 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x63, 0x28, 0x03, 0x90, 0x10);
1708 break;
1709 case 8:
1710 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x63, 0x1e, 0x03, 0x90, 0x10);
1711 break;
1712 case 9: //d1,bb
1713 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x31, 0x10);
1714 break;
1715 case 10:
1716 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x32, 0x03, 0x31, 0x10);
1717 break;
1718 case 11:
1719 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x28, 0x03, 0x31, 0x10);
1720 break;
1721 case 12:
1722 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0x31, 0x10);
1723 break;
1724 case 13: //d1,bb,TXpause
1725 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x30, 0x10);
1726 break;
1727 case 14:
1728 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x32, 0x03, 0x30, 0x10);
1729 break;
1730 case 15:
1731 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x28, 0x03, 0x30, 0x10);
1732 break;
1733 case 16:
1734 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0x30, 0x10);
1735 break;
1736 case 17:
1737 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x03, 0x10, 0x10);
1738 break;
1739 case 18:
1740 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);
1741 break;
1742 case 19:
1743 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90);
1744 break;
1745 case 20:
1746 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90);
1747 break;
1748 case 21:
1749 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x03, 0x11, 0x11);
1750 break;
1751 case 71:
1752 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);
1753 break;
1754
1755 // following cases is for wifi rssi low // bad antenna isolation, started from 81
1756 case 80:
1757 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x3c, 0x3, 0x90, 0x50);
1758 break;
1759 case 81:
1760 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x3a+nWiFiDurationAdjust, 0x3, 0x90, 0x50);
1761 break;
1762 case 82:
1763 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x30+nWiFiDurationAdjust, 0x03, 0x90, 0x50);
1764 break;
1765 case 83:
1766 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x21, 0x03, 0x90, 0x50);
1767 break;
1768 case 84:
1769 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x15, 0x3, 0x90, 0x50);
1770 break;
1771 case 85:
1772 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x3a, 0x03, 0x90, 0x50);
1773 break;
1774 case 86:
1775 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x21, 0x03, 0x90, 0x50);
1776 break;
1777
1778 }
1779 }
1780 else
1781 {
1782 // disable PS tdma
1783 switch(type)
1784 {
1785 default:
1786 case 0: //ANT2PTA, 0x778=1
1787 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
1788 halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE);
1789 break;
1790 case 1: //ANT2BT, 0x778=3
1791 halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
1792 delay_ms(5);
1793 halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE);
1794 break;
1795
1796 }
1797 }
1798
1799 // update pre state
1800 pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
1801 pCoexDm->prePsTdma = pCoexDm->curPsTdma;
1802 }
1803
1804 VOID
halbtc8192e2ant_SetSwitchSsType(IN PBTC_COEXIST pBtCoexist,IN u1Byte ssType)1805 halbtc8192e2ant_SetSwitchSsType(
1806 IN PBTC_COEXIST pBtCoexist,
1807 IN u1Byte ssType
1808 )
1809 {
1810 u1Byte mimoPs=BTC_MIMO_PS_DYNAMIC;
1811 u4Byte disRaMask=0x0;
1812
1813 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], REAL set SS Type = %d\n", ssType));
1814
1815 disRaMask = halbtc8192e2ant_DecideRaMask(pBtCoexist, ssType, pCoexDm->curRaMaskType);
1816 halbtc8192e2ant_UpdateRaMask(pBtCoexist, FORCE_EXEC, disRaMask);
1817
1818 if(ssType == 1)
1819 {
1820 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
1821 // switch ofdm path
1822 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xc04, 0x11);
1823 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xd04, 0x1);
1824 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x90c, 0x81111111);
1825 // switch cck patch
1826 //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xe77, 0x4, 0x1);
1827 //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xa07, 0x81);
1828 mimoPs=BTC_MIMO_PS_STATIC;
1829 }
1830 else if(ssType == 2)
1831 {
1832 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
1833 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xc04, 0x33);
1834 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xd04, 0x3);
1835 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x90c, 0x81121313);
1836 // remove, if 0xe77[2]=0x0 then CCK will fail, advised by Jenyu
1837 //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xe77, 0x4, 0x0);
1838 //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xa07, 0x41);
1839 mimoPs=BTC_MIMO_PS_DYNAMIC;
1840 }
1841
1842 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimoPs); // set rx 1ss or 2ss
1843 }
1844
1845 VOID
halbtc8192e2ant_SwitchSsType(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bForceExec,IN u1Byte newSsType)1846 halbtc8192e2ant_SwitchSsType(
1847 IN PBTC_COEXIST pBtCoexist,
1848 IN BOOLEAN bForceExec,
1849 IN u1Byte newSsType
1850 )
1851 {
1852 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], %s Switch SS Type = %d\n",
1853 (bForceExec? "force to":""), newSsType));
1854 pCoexDm->curSsType = newSsType;
1855
1856 if(!bForceExec)
1857 {
1858 if(pCoexDm->preSsType == pCoexDm->curSsType)
1859 return;
1860 }
1861 halbtc8192e2ant_SetSwitchSsType(pBtCoexist, pCoexDm->curSsType);
1862
1863 pCoexDm->preSsType = pCoexDm->curSsType;
1864 }
1865
1866 VOID
halbtc8192e2ant_PsTdmaCheckForPowerSaveState(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bNewPsState)1867 halbtc8192e2ant_PsTdmaCheckForPowerSaveState(
1868 IN PBTC_COEXIST pBtCoexist,
1869 IN BOOLEAN bNewPsState
1870 )
1871 {
1872 u1Byte lpsMode=0x0;
1873
1874 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
1875
1876 if(lpsMode) // already under LPS state
1877 {
1878 if(bNewPsState)
1879 {
1880 // keep state under LPS, do nothing.
1881 }
1882 else
1883 {
1884 // will leave LPS state, turn off psTdma first
1885 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1886 }
1887 }
1888 else // NO PS state
1889 {
1890 if(bNewPsState)
1891 {
1892 // will enter LPS state, turn off psTdma first
1893 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
1894 }
1895 else
1896 {
1897 // keep state under NO PS state, do nothing.
1898 }
1899 }
1900 }
1901
1902 VOID
halbtc8192e2ant_PowerSaveState(IN PBTC_COEXIST pBtCoexist,IN u1Byte psType,IN u1Byte lpsVal,IN u1Byte rpwmVal)1903 halbtc8192e2ant_PowerSaveState(
1904 IN PBTC_COEXIST pBtCoexist,
1905 IN u1Byte psType,
1906 IN u1Byte lpsVal,
1907 IN u1Byte rpwmVal
1908 )
1909 {
1910 BOOLEAN bLowPwrDisable=FALSE;
1911 BOOLEAN bApEnable=FALSE;
1912
1913 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
1914
1915 if(bApEnable)
1916 {
1917 psType = BTC_PS_WIFI_NATIVE;
1918 lpsVal = 0x0;
1919 rpwmVal = 0x0;
1920 }
1921
1922 switch(psType)
1923 {
1924 case BTC_PS_WIFI_NATIVE:
1925 // recover to original 32k low power setting
1926 bLowPwrDisable = TRUE;
1927 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1928 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
1929 pCoexSta->bForceLpsOn = FALSE;
1930 break;
1931 case BTC_PS_LPS_ON:
1932 halbtc8192e2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);
1933 halbtc8192e2ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
1934 // when coex force to enter LPS, do not enter 32k low power.
1935 bLowPwrDisable = TRUE;
1936 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1937 // power save must executed before psTdma.
1938 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
1939 pCoexSta->bForceLpsOn = TRUE;
1940 break;
1941 case BTC_PS_LPS_OFF:
1942 halbtc8192e2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
1943 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
1944 pCoexSta->bForceLpsOn = FALSE;
1945 break;
1946 default:
1947 break;
1948 }
1949 }
1950
1951
1952 VOID
halbtc8192e2ant_CoexAllOff(IN PBTC_COEXIST pBtCoexist)1953 halbtc8192e2ant_CoexAllOff(
1954 IN PBTC_COEXIST pBtCoexist
1955 )
1956 {
1957 // fw all off
1958 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
1959 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
1960 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
1961 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
1962
1963 // sw all off
1964 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
1965 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
1966
1967 // hw all off
1968 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
1969 }
1970
1971 VOID
halbtc8192e2ant_InitCoexDm(IN PBTC_COEXIST pBtCoexist)1972 halbtc8192e2ant_InitCoexDm(
1973 IN PBTC_COEXIST pBtCoexist
1974 )
1975 {
1976 // force to reset coex mechanism
1977
1978 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
1979 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
1980 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
1981 halbtc8192e2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
1982
1983 halbtc8192e2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
1984 halbtc8192e2ant_SwitchSsType(pBtCoexist, FORCE_EXEC, 2);
1985
1986 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
1987 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
1988 }
1989
1990 VOID
halbtc8192e2ant_ActionBtInquiry(IN PBTC_COEXIST pBtCoexist)1991 halbtc8192e2ant_ActionBtInquiry(
1992 IN PBTC_COEXIST pBtCoexist
1993 )
1994 {
1995 // BOOLEAN bLowPwrDisable=TRUE;
1996
1997 // pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
1998
1999 // halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
2000
2001 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2002 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2003 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 21);
2004 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2005 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2006
2007 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
2008 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2009 }
2010
2011 VOID
halbtc8192e2ant_ActionWiFiLinkProcess(IN PBTC_COEXIST pBtCoexist)2012 halbtc8192e2ant_ActionWiFiLinkProcess(
2013 IN PBTC_COEXIST pBtCoexist
2014 )
2015 {
2016
2017 }
2018
2019 BOOLEAN
halbtc8192e2ant_IsCommonAction(IN PBTC_COEXIST pBtCoexist)2020 halbtc8192e2ant_IsCommonAction(
2021 IN PBTC_COEXIST pBtCoexist
2022 )
2023 {
2024 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
2025 BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
2026 BOOLEAN bBtHsOn=FALSE, bLowPwrDisable=FALSE;
2027
2028 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
2029 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
2030 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
2031
2032 if(pBtLinkInfo->bScoExist || pBtLinkInfo->bHidExist)
2033 {
2034 halbtc8192e2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 0, 0, 0);
2035 }
2036 else
2037 {
2038 halbtc8192e2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
2039 }
2040
2041 if(!bWifiConnected)
2042 {
2043 // bLowPwrDisable = FALSE;
2044 // pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
2045
2046 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2047
2048 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-connected idle!!\n"));
2049
2050 if( (BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ||
2051 (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
2052 {
2053 // halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2);
2054 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
2055 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2056 }
2057 else
2058 {
2059 // halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
2060 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2061 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
2062 }
2063
2064 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2065 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2066
2067 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
2068 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2069
2070 bCommon = TRUE;
2071 }
2072 else
2073 {
2074 if(BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
2075 {
2076 // bLowPwrDisable = FALSE;
2077 // pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
2078
2079 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
2080 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2081 // halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2);
2082 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2083 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2084 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2085 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2086
2087 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
2088 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2089
2090 bCommon = TRUE;
2091 }
2092 else if(BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
2093 {
2094 // bLowPwrDisable = TRUE;
2095 // pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
2096
2097 if(bBtHsOn)
2098 return FALSE;
2099 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
2100
2101 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2102 // halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2);
2103 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2104 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
2105 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2106 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2107
2108 halbtc8192e2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);
2109 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2110
2111 bCommon = TRUE;
2112 }
2113 else
2114 {
2115 // bLowPwrDisable = TRUE;
2116 // pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
2117
2118 if(bWifiBusy)
2119 {
2120 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));
2121 bCommon = FALSE;
2122 }
2123 else
2124 {
2125 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));
2126
2127 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
2128 // halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
2129 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
2130 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 21);
2131 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
2132 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
2133 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
2134 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
2135 bCommon = TRUE;
2136 }
2137 }
2138 }
2139
2140 return bCommon;
2141 }
2142
2143
2144 VOID
halbtc8192e2ant_TdmaDurationAdjust(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bScoHid,IN BOOLEAN bTxPause,IN u1Byte maxInterval)2145 halbtc8192e2ant_TdmaDurationAdjust(
2146 IN PBTC_COEXIST pBtCoexist,
2147 IN BOOLEAN bScoHid,
2148 IN BOOLEAN bTxPause,
2149 IN u1Byte maxInterval
2150 )
2151 {
2152 static s4Byte up,dn,m,n,WaitCount;
2153 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
2154 u1Byte retryCount=0;
2155
2156 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n"));
2157
2158 if(!pCoexDm->bAutoTdmaAdjust)
2159 {
2160 pCoexDm->bAutoTdmaAdjust = TRUE;
2161 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
2162 {
2163 if(bScoHid)
2164 {
2165 if(bTxPause)
2166 {
2167 if(maxInterval == 1)
2168 {
2169 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
2170 pCoexDm->psTdmaDuAdjType = 13;
2171 }
2172 else if(maxInterval == 2)
2173 {
2174 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2175 pCoexDm->psTdmaDuAdjType = 14;
2176 }
2177 else if(maxInterval == 3)
2178 {
2179 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2180 pCoexDm->psTdmaDuAdjType = 15;
2181 }
2182 else
2183 {
2184 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2185 pCoexDm->psTdmaDuAdjType = 15;
2186 }
2187 }
2188 else
2189 {
2190 if(maxInterval == 1)
2191 {
2192 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
2193 pCoexDm->psTdmaDuAdjType = 9;
2194 }
2195 else if(maxInterval == 2)
2196 {
2197 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2198 pCoexDm->psTdmaDuAdjType = 10;
2199 }
2200 else if(maxInterval == 3)
2201 {
2202 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2203 pCoexDm->psTdmaDuAdjType = 11;
2204 }
2205 else
2206 {
2207 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2208 pCoexDm->psTdmaDuAdjType = 11;
2209 }
2210 }
2211 }
2212 else
2213 {
2214 if(bTxPause)
2215 {
2216 if(maxInterval == 1)
2217 {
2218 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
2219 pCoexDm->psTdmaDuAdjType = 5;
2220 }
2221 else if(maxInterval == 2)
2222 {
2223 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2224 pCoexDm->psTdmaDuAdjType = 6;
2225 }
2226 else if(maxInterval == 3)
2227 {
2228 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2229 pCoexDm->psTdmaDuAdjType = 7;
2230 }
2231 else
2232 {
2233 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2234 pCoexDm->psTdmaDuAdjType = 7;
2235 }
2236 }
2237 else
2238 {
2239 if(maxInterval == 1)
2240 {
2241 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
2242 pCoexDm->psTdmaDuAdjType = 1;
2243 }
2244 else if(maxInterval == 2)
2245 {
2246 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2247 pCoexDm->psTdmaDuAdjType = 2;
2248 }
2249 else if(maxInterval == 3)
2250 {
2251 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2252 pCoexDm->psTdmaDuAdjType = 3;
2253 }
2254 else
2255 {
2256 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2257 pCoexDm->psTdmaDuAdjType = 3;
2258 }
2259 }
2260 }
2261 }
2262 //============
2263 up = 0;
2264 dn = 0;
2265 m = 1;
2266 n= 3;
2267 result = 0;
2268 WaitCount = 0;
2269 }
2270 else
2271 {
2272 //accquire the BT TRx retry count from BT_Info byte2
2273 retryCount = pCoexSta->btRetryCnt;
2274 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount));
2275 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
2276 up, dn, m, n, WaitCount));
2277 result = 0;
2278 WaitCount++;
2279
2280 if(retryCount == 0) // no retry in the last 2-second duration
2281 {
2282 up++;
2283 dn--;
2284
2285 if (dn <= 0)
2286 dn = 0;
2287
2288 if(up >= n) // if �s�� n ��2�� retry count��0, �h�ռeWiFi duration
2289 {
2290 WaitCount = 0;
2291 n = 3;
2292 up = 0;
2293 dn = 0;
2294 result = 1;
2295 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n"));
2296 }
2297 }
2298 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
2299 {
2300 up--;
2301 dn++;
2302
2303 if (up <= 0)
2304 up = 0;
2305
2306 if (dn == 2) // if �s�� 2 ��2�� retry count< 3, �h�կ�WiFi duration
2307 {
2308 if (WaitCount <= 2)
2309 m++; // �קK�@���b���level���Ӧ^
2310 else
2311 m = 1;
2312
2313 if ( m >= 20) //m �̤j�� = 20 ' �̤j120�� recheck�O�_�վ� WiFi duration.
2314 m = 20;
2315
2316 n = 3*m;
2317 up = 0;
2318 dn = 0;
2319 WaitCount = 0;
2320 result = -1;
2321 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
2322 }
2323 }
2324 else //retry count > 3, �u�n1�� retry count > 3, �h�կ�WiFi duration
2325 {
2326 if (WaitCount == 1)
2327 m++; // �קK�@���b���level���Ӧ^
2328 else
2329 m = 1;
2330
2331 if ( m >= 20) //m �̤j�� = 20 ' �̤j120�� recheck�O�_�վ� WiFi duration.
2332 m = 20;
2333
2334 n = 3*m;
2335 up = 0;
2336 dn = 0;
2337 WaitCount = 0;
2338 result = -1;
2339 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
2340 }
2341
2342 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval));
2343 if(maxInterval == 1)
2344 {
2345 if(bTxPause)
2346 {
2347 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
2348
2349 if(pCoexDm->curPsTdma == 1)
2350 {
2351 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
2352 pCoexDm->psTdmaDuAdjType = 5;
2353 }
2354 else if(pCoexDm->curPsTdma == 2)
2355 {
2356 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2357 pCoexDm->psTdmaDuAdjType = 6;
2358 }
2359 else if(pCoexDm->curPsTdma == 3)
2360 {
2361 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2362 pCoexDm->psTdmaDuAdjType = 7;
2363 }
2364 else if(pCoexDm->curPsTdma == 4)
2365 {
2366 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2367 pCoexDm->psTdmaDuAdjType = 8;
2368 }
2369 if(pCoexDm->curPsTdma == 9)
2370 {
2371 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
2372 pCoexDm->psTdmaDuAdjType = 13;
2373 }
2374 else if(pCoexDm->curPsTdma == 10)
2375 {
2376 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2377 pCoexDm->psTdmaDuAdjType = 14;
2378 }
2379 else if(pCoexDm->curPsTdma == 11)
2380 {
2381 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2382 pCoexDm->psTdmaDuAdjType = 15;
2383 }
2384 else if(pCoexDm->curPsTdma == 12)
2385 {
2386 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2387 pCoexDm->psTdmaDuAdjType = 16;
2388 }
2389
2390 if(result == -1)
2391 {
2392 if(pCoexDm->curPsTdma == 5)
2393 {
2394 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2395 pCoexDm->psTdmaDuAdjType = 6;
2396 }
2397 else if(pCoexDm->curPsTdma == 6)
2398 {
2399 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2400 pCoexDm->psTdmaDuAdjType = 7;
2401 }
2402 else if(pCoexDm->curPsTdma == 7)
2403 {
2404 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2405 pCoexDm->psTdmaDuAdjType = 8;
2406 }
2407 else if(pCoexDm->curPsTdma == 13)
2408 {
2409 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2410 pCoexDm->psTdmaDuAdjType = 14;
2411 }
2412 else if(pCoexDm->curPsTdma == 14)
2413 {
2414 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2415 pCoexDm->psTdmaDuAdjType = 15;
2416 }
2417 else if(pCoexDm->curPsTdma == 15)
2418 {
2419 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2420 pCoexDm->psTdmaDuAdjType = 16;
2421 }
2422 }
2423 else if (result == 1)
2424 {
2425 if(pCoexDm->curPsTdma == 8)
2426 {
2427 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2428 pCoexDm->psTdmaDuAdjType = 7;
2429 }
2430 else if(pCoexDm->curPsTdma == 7)
2431 {
2432 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2433 pCoexDm->psTdmaDuAdjType = 6;
2434 }
2435 else if(pCoexDm->curPsTdma == 6)
2436 {
2437 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);
2438 pCoexDm->psTdmaDuAdjType = 5;
2439 }
2440 else if(pCoexDm->curPsTdma == 16)
2441 {
2442 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2443 pCoexDm->psTdmaDuAdjType = 15;
2444 }
2445 else if(pCoexDm->curPsTdma == 15)
2446 {
2447 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2448 pCoexDm->psTdmaDuAdjType = 14;
2449 }
2450 else if(pCoexDm->curPsTdma == 14)
2451 {
2452 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);
2453 pCoexDm->psTdmaDuAdjType = 13;
2454 }
2455 }
2456 }
2457 else
2458 {
2459 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
2460 if(pCoexDm->curPsTdma == 5)
2461 {
2462 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
2463 pCoexDm->psTdmaDuAdjType = 1;
2464 }
2465 else if(pCoexDm->curPsTdma == 6)
2466 {
2467 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2468 pCoexDm->psTdmaDuAdjType = 2;
2469 }
2470 else if(pCoexDm->curPsTdma == 7)
2471 {
2472 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2473 pCoexDm->psTdmaDuAdjType = 3;
2474 }
2475 else if(pCoexDm->curPsTdma == 8)
2476 {
2477 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2478 pCoexDm->psTdmaDuAdjType = 4;
2479 }
2480 if(pCoexDm->curPsTdma == 13)
2481 {
2482 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
2483 pCoexDm->psTdmaDuAdjType = 9;
2484 }
2485 else if(pCoexDm->curPsTdma == 14)
2486 {
2487 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2488 pCoexDm->psTdmaDuAdjType = 10;
2489 }
2490 else if(pCoexDm->curPsTdma == 15)
2491 {
2492 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2493 pCoexDm->psTdmaDuAdjType = 11;
2494 }
2495 else if(pCoexDm->curPsTdma == 16)
2496 {
2497 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2498 pCoexDm->psTdmaDuAdjType = 12;
2499 }
2500
2501 if(result == -1)
2502 {
2503 if(pCoexDm->curPsTdma == 1)
2504 {
2505 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2506 pCoexDm->psTdmaDuAdjType = 2;
2507 }
2508 else if(pCoexDm->curPsTdma == 2)
2509 {
2510 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2511 pCoexDm->psTdmaDuAdjType = 3;
2512 }
2513 else if(pCoexDm->curPsTdma == 3)
2514 {
2515 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2516 pCoexDm->psTdmaDuAdjType = 4;
2517 }
2518 else if(pCoexDm->curPsTdma == 9)
2519 {
2520 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2521 pCoexDm->psTdmaDuAdjType = 10;
2522 }
2523 else if(pCoexDm->curPsTdma == 10)
2524 {
2525 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2526 pCoexDm->psTdmaDuAdjType = 11;
2527 }
2528 else if(pCoexDm->curPsTdma == 11)
2529 {
2530 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2531 pCoexDm->psTdmaDuAdjType = 12;
2532 }
2533 }
2534 else if (result == 1)
2535 {
2536 if(pCoexDm->curPsTdma == 4)
2537 {
2538 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2539 pCoexDm->psTdmaDuAdjType = 3;
2540 }
2541 else if(pCoexDm->curPsTdma == 3)
2542 {
2543 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2544 pCoexDm->psTdmaDuAdjType = 2;
2545 }
2546 else if(pCoexDm->curPsTdma == 2)
2547 {
2548 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);
2549 pCoexDm->psTdmaDuAdjType = 1;
2550 }
2551 else if(pCoexDm->curPsTdma == 12)
2552 {
2553 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2554 pCoexDm->psTdmaDuAdjType = 11;
2555 }
2556 else if(pCoexDm->curPsTdma == 11)
2557 {
2558 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2559 pCoexDm->psTdmaDuAdjType = 10;
2560 }
2561 else if(pCoexDm->curPsTdma == 10)
2562 {
2563 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);
2564 pCoexDm->psTdmaDuAdjType = 9;
2565 }
2566 }
2567 }
2568 }
2569 else if(maxInterval == 2)
2570 {
2571 if(bTxPause)
2572 {
2573 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
2574 if(pCoexDm->curPsTdma == 1)
2575 {
2576 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2577 pCoexDm->psTdmaDuAdjType = 6;
2578 }
2579 else if(pCoexDm->curPsTdma == 2)
2580 {
2581 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2582 pCoexDm->psTdmaDuAdjType = 6;
2583 }
2584 else if(pCoexDm->curPsTdma == 3)
2585 {
2586 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2587 pCoexDm->psTdmaDuAdjType = 7;
2588 }
2589 else if(pCoexDm->curPsTdma == 4)
2590 {
2591 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2592 pCoexDm->psTdmaDuAdjType = 8;
2593 }
2594 if(pCoexDm->curPsTdma == 9)
2595 {
2596 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2597 pCoexDm->psTdmaDuAdjType = 14;
2598 }
2599 else if(pCoexDm->curPsTdma == 10)
2600 {
2601 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2602 pCoexDm->psTdmaDuAdjType = 14;
2603 }
2604 else if(pCoexDm->curPsTdma == 11)
2605 {
2606 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2607 pCoexDm->psTdmaDuAdjType = 15;
2608 }
2609 else if(pCoexDm->curPsTdma == 12)
2610 {
2611 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2612 pCoexDm->psTdmaDuAdjType = 16;
2613 }
2614 if(result == -1)
2615 {
2616 if(pCoexDm->curPsTdma == 5)
2617 {
2618 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2619 pCoexDm->psTdmaDuAdjType = 6;
2620 }
2621 else if(pCoexDm->curPsTdma == 6)
2622 {
2623 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2624 pCoexDm->psTdmaDuAdjType = 7;
2625 }
2626 else if(pCoexDm->curPsTdma == 7)
2627 {
2628 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2629 pCoexDm->psTdmaDuAdjType = 8;
2630 }
2631 else if(pCoexDm->curPsTdma == 13)
2632 {
2633 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2634 pCoexDm->psTdmaDuAdjType = 14;
2635 }
2636 else if(pCoexDm->curPsTdma == 14)
2637 {
2638 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2639 pCoexDm->psTdmaDuAdjType = 15;
2640 }
2641 else if(pCoexDm->curPsTdma == 15)
2642 {
2643 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2644 pCoexDm->psTdmaDuAdjType = 16;
2645 }
2646 }
2647 else if (result == 1)
2648 {
2649 if(pCoexDm->curPsTdma == 8)
2650 {
2651 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2652 pCoexDm->psTdmaDuAdjType = 7;
2653 }
2654 else if(pCoexDm->curPsTdma == 7)
2655 {
2656 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2657 pCoexDm->psTdmaDuAdjType = 6;
2658 }
2659 else if(pCoexDm->curPsTdma == 6)
2660 {
2661 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);
2662 pCoexDm->psTdmaDuAdjType = 6;
2663 }
2664 else if(pCoexDm->curPsTdma == 16)
2665 {
2666 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2667 pCoexDm->psTdmaDuAdjType = 15;
2668 }
2669 else if(pCoexDm->curPsTdma == 15)
2670 {
2671 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2672 pCoexDm->psTdmaDuAdjType = 14;
2673 }
2674 else if(pCoexDm->curPsTdma == 14)
2675 {
2676 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);
2677 pCoexDm->psTdmaDuAdjType = 14;
2678 }
2679 }
2680 }
2681 else
2682 {
2683 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
2684 if(pCoexDm->curPsTdma == 5)
2685 {
2686 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2687 pCoexDm->psTdmaDuAdjType = 2;
2688 }
2689 else if(pCoexDm->curPsTdma == 6)
2690 {
2691 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2692 pCoexDm->psTdmaDuAdjType = 2;
2693 }
2694 else if(pCoexDm->curPsTdma == 7)
2695 {
2696 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2697 pCoexDm->psTdmaDuAdjType = 3;
2698 }
2699 else if(pCoexDm->curPsTdma == 8)
2700 {
2701 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2702 pCoexDm->psTdmaDuAdjType = 4;
2703 }
2704 if(pCoexDm->curPsTdma == 13)
2705 {
2706 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2707 pCoexDm->psTdmaDuAdjType = 10;
2708 }
2709 else if(pCoexDm->curPsTdma == 14)
2710 {
2711 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2712 pCoexDm->psTdmaDuAdjType = 10;
2713 }
2714 else if(pCoexDm->curPsTdma == 15)
2715 {
2716 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2717 pCoexDm->psTdmaDuAdjType = 11;
2718 }
2719 else if(pCoexDm->curPsTdma == 16)
2720 {
2721 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2722 pCoexDm->psTdmaDuAdjType = 12;
2723 }
2724 if(result == -1)
2725 {
2726 if(pCoexDm->curPsTdma == 1)
2727 {
2728 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2729 pCoexDm->psTdmaDuAdjType = 2;
2730 }
2731 else if(pCoexDm->curPsTdma == 2)
2732 {
2733 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2734 pCoexDm->psTdmaDuAdjType = 3;
2735 }
2736 else if(pCoexDm->curPsTdma == 3)
2737 {
2738 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2739 pCoexDm->psTdmaDuAdjType = 4;
2740 }
2741 else if(pCoexDm->curPsTdma == 9)
2742 {
2743 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2744 pCoexDm->psTdmaDuAdjType = 10;
2745 }
2746 else if(pCoexDm->curPsTdma == 10)
2747 {
2748 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2749 pCoexDm->psTdmaDuAdjType = 11;
2750 }
2751 else if(pCoexDm->curPsTdma == 11)
2752 {
2753 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2754 pCoexDm->psTdmaDuAdjType = 12;
2755 }
2756 }
2757 else if (result == 1)
2758 {
2759 if(pCoexDm->curPsTdma == 4)
2760 {
2761 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2762 pCoexDm->psTdmaDuAdjType = 3;
2763 }
2764 else if(pCoexDm->curPsTdma == 3)
2765 {
2766 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2767 pCoexDm->psTdmaDuAdjType = 2;
2768 }
2769 else if(pCoexDm->curPsTdma == 2)
2770 {
2771 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);
2772 pCoexDm->psTdmaDuAdjType = 2;
2773 }
2774 else if(pCoexDm->curPsTdma == 12)
2775 {
2776 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2777 pCoexDm->psTdmaDuAdjType = 11;
2778 }
2779 else if(pCoexDm->curPsTdma == 11)
2780 {
2781 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2782 pCoexDm->psTdmaDuAdjType = 10;
2783 }
2784 else if(pCoexDm->curPsTdma == 10)
2785 {
2786 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);
2787 pCoexDm->psTdmaDuAdjType = 10;
2788 }
2789 }
2790 }
2791 }
2792 else if(maxInterval == 3)
2793 {
2794 if(bTxPause)
2795 {
2796 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));
2797 if(pCoexDm->curPsTdma == 1)
2798 {
2799 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2800 pCoexDm->psTdmaDuAdjType = 7;
2801 }
2802 else if(pCoexDm->curPsTdma == 2)
2803 {
2804 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2805 pCoexDm->psTdmaDuAdjType = 7;
2806 }
2807 else if(pCoexDm->curPsTdma == 3)
2808 {
2809 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2810 pCoexDm->psTdmaDuAdjType = 7;
2811 }
2812 else if(pCoexDm->curPsTdma == 4)
2813 {
2814 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2815 pCoexDm->psTdmaDuAdjType = 8;
2816 }
2817 if(pCoexDm->curPsTdma == 9)
2818 {
2819 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2820 pCoexDm->psTdmaDuAdjType = 15;
2821 }
2822 else if(pCoexDm->curPsTdma == 10)
2823 {
2824 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2825 pCoexDm->psTdmaDuAdjType = 15;
2826 }
2827 else if(pCoexDm->curPsTdma == 11)
2828 {
2829 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2830 pCoexDm->psTdmaDuAdjType = 15;
2831 }
2832 else if(pCoexDm->curPsTdma == 12)
2833 {
2834 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2835 pCoexDm->psTdmaDuAdjType = 16;
2836 }
2837 if(result == -1)
2838 {
2839 if(pCoexDm->curPsTdma == 5)
2840 {
2841 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2842 pCoexDm->psTdmaDuAdjType = 7;
2843 }
2844 else if(pCoexDm->curPsTdma == 6)
2845 {
2846 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2847 pCoexDm->psTdmaDuAdjType = 7;
2848 }
2849 else if(pCoexDm->curPsTdma == 7)
2850 {
2851 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);
2852 pCoexDm->psTdmaDuAdjType = 8;
2853 }
2854 else if(pCoexDm->curPsTdma == 13)
2855 {
2856 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2857 pCoexDm->psTdmaDuAdjType = 15;
2858 }
2859 else if(pCoexDm->curPsTdma == 14)
2860 {
2861 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2862 pCoexDm->psTdmaDuAdjType = 15;
2863 }
2864 else if(pCoexDm->curPsTdma == 15)
2865 {
2866 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);
2867 pCoexDm->psTdmaDuAdjType = 16;
2868 }
2869 }
2870 else if (result == 1)
2871 {
2872 if(pCoexDm->curPsTdma == 8)
2873 {
2874 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2875 pCoexDm->psTdmaDuAdjType = 7;
2876 }
2877 else if(pCoexDm->curPsTdma == 7)
2878 {
2879 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2880 pCoexDm->psTdmaDuAdjType = 7;
2881 }
2882 else if(pCoexDm->curPsTdma == 6)
2883 {
2884 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);
2885 pCoexDm->psTdmaDuAdjType = 7;
2886 }
2887 else if(pCoexDm->curPsTdma == 16)
2888 {
2889 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2890 pCoexDm->psTdmaDuAdjType = 15;
2891 }
2892 else if(pCoexDm->curPsTdma == 15)
2893 {
2894 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2895 pCoexDm->psTdmaDuAdjType = 15;
2896 }
2897 else if(pCoexDm->curPsTdma == 14)
2898 {
2899 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);
2900 pCoexDm->psTdmaDuAdjType = 15;
2901 }
2902 }
2903 }
2904 else
2905 {
2906 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));
2907 if(pCoexDm->curPsTdma == 5)
2908 {
2909 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2910 pCoexDm->psTdmaDuAdjType = 3;
2911 }
2912 else if(pCoexDm->curPsTdma == 6)
2913 {
2914 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2915 pCoexDm->psTdmaDuAdjType = 3;
2916 }
2917 else if(pCoexDm->curPsTdma == 7)
2918 {
2919 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2920 pCoexDm->psTdmaDuAdjType = 3;
2921 }
2922 else if(pCoexDm->curPsTdma == 8)
2923 {
2924 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2925 pCoexDm->psTdmaDuAdjType = 4;
2926 }
2927 if(pCoexDm->curPsTdma == 13)
2928 {
2929 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2930 pCoexDm->psTdmaDuAdjType = 11;
2931 }
2932 else if(pCoexDm->curPsTdma == 14)
2933 {
2934 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2935 pCoexDm->psTdmaDuAdjType = 11;
2936 }
2937 else if(pCoexDm->curPsTdma == 15)
2938 {
2939 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2940 pCoexDm->psTdmaDuAdjType = 11;
2941 }
2942 else if(pCoexDm->curPsTdma == 16)
2943 {
2944 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2945 pCoexDm->psTdmaDuAdjType = 12;
2946 }
2947 if(result == -1)
2948 {
2949 if(pCoexDm->curPsTdma == 1)
2950 {
2951 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2952 pCoexDm->psTdmaDuAdjType = 3;
2953 }
2954 else if(pCoexDm->curPsTdma == 2)
2955 {
2956 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2957 pCoexDm->psTdmaDuAdjType = 3;
2958 }
2959 else if(pCoexDm->curPsTdma == 3)
2960 {
2961 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);
2962 pCoexDm->psTdmaDuAdjType = 4;
2963 }
2964 else if(pCoexDm->curPsTdma == 9)
2965 {
2966 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2967 pCoexDm->psTdmaDuAdjType = 11;
2968 }
2969 else if(pCoexDm->curPsTdma == 10)
2970 {
2971 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
2972 pCoexDm->psTdmaDuAdjType = 11;
2973 }
2974 else if(pCoexDm->curPsTdma == 11)
2975 {
2976 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);
2977 pCoexDm->psTdmaDuAdjType = 12;
2978 }
2979 }
2980 else if (result == 1)
2981 {
2982 if(pCoexDm->curPsTdma == 4)
2983 {
2984 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2985 pCoexDm->psTdmaDuAdjType = 3;
2986 }
2987 else if(pCoexDm->curPsTdma == 3)
2988 {
2989 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2990 pCoexDm->psTdmaDuAdjType = 3;
2991 }
2992 else if(pCoexDm->curPsTdma == 2)
2993 {
2994 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);
2995 pCoexDm->psTdmaDuAdjType = 3;
2996 }
2997 else if(pCoexDm->curPsTdma == 12)
2998 {
2999 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
3000 pCoexDm->psTdmaDuAdjType = 11;
3001 }
3002 else if(pCoexDm->curPsTdma == 11)
3003 {
3004 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
3005 pCoexDm->psTdmaDuAdjType = 11;
3006 }
3007 else if(pCoexDm->curPsTdma == 10)
3008 {
3009 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);
3010 pCoexDm->psTdmaDuAdjType = 11;
3011 }
3012 }
3013 }
3014 }
3015 }
3016
3017 // if current PsTdma not match with the recorded one (when scan, dhcp...),
3018 // then we have to adjust it back to the previous record one.
3019 if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)
3020 {
3021 BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
3022 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n",
3023 pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));
3024
3025 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
3026 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
3027 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
3028
3029 if( !bScan && !bLink && !bRoam)
3030 {
3031 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
3032 }
3033 else
3034 {
3035 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
3036 }
3037 }
3038 }
3039
3040 VOID
halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(IN PBTC_COEXIST pBtCoexist)3041 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(
3042 IN PBTC_COEXIST pBtCoexist//,
3043 //IN u1Byte wifiStatus
3044 )
3045 {
3046 static s4Byte up,dn,m,n,WaitCount;
3047 s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
3048 u1Byte retryCount=0, btInfoExt;
3049
3050 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow()\n"));
3051 #if 0
3052 if( (BT_8192E_2ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
3053 (BT_8192E_2ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
3054 (BT_8192E_2ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
3055 {
3056 if( pCoexDm->curPsTdma != 81 &&
3057 pCoexDm->curPsTdma != 82 &&
3058 pCoexDm->curPsTdma != 83 &&
3059 pCoexDm->curPsTdma != 84 )
3060 {
3061 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82);
3062 pCoexDm->psTdmaDuAdjType = 82;
3063
3064 up = 0;
3065 dn = 0;
3066 m = 1;
3067 n= 3;
3068 result = 0;
3069 WaitCount = 0;
3070 }
3071 return;
3072 }
3073 #endif
3074 pCoexDm->bAutoTdmaAdjust = FALSE;
3075
3076 retryCount = pCoexSta->btRetryCnt;
3077 btInfoExt = pCoexSta->btInfoExt;
3078
3079 if(!pCoexDm->bAutoTdmaAdjustLowRssi)
3080 {
3081 pCoexDm->bAutoTdmaAdjustLowRssi = TRUE;
3082 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjustForWifiRssiLow()!!\n"));
3083
3084 /*
3085 if(BT_INFO_8192E_2ANT_A2DP_BASIC_RATE(btInfoExt))
3086 {
3087 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83);
3088 pCoexDm->psTdmaDuAdjType = 83;
3089 }
3090 else
3091 */
3092 {
3093 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 81);
3094 pCoexDm->psTdmaDuAdjType = 81;
3095 }
3096 //============
3097 up = 0;
3098 dn = 0;
3099 m = 1;
3100 n= 3;
3101 result = 0;
3102 WaitCount = 0;
3103 }
3104 else
3105 {
3106 //accquire the BT TRx retry count from BT_Info byte2
3107 // retryCount = pCoexSta->btRetryCnt;
3108 // btInfoExt = pCoexSta->btInfoExt;
3109 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount));
3110 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
3111 up, dn, m, n, WaitCount));
3112 result = 0;
3113 WaitCount++;
3114
3115 if ( (pCoexSta->lowPriorityTx) > 1050 || (pCoexSta->lowPriorityRx) > 1250 )
3116 retryCount++;
3117
3118 if(retryCount == 0) // no retry in the last 2-second duration
3119 {
3120 up++;
3121 dn--;
3122
3123 if (dn <= 0)
3124 dn = 0;
3125
3126 if(up >= n) // if �s�� n ��2�� retry count��0, �h�ռeWiFi duration
3127 {
3128 WaitCount = 0;
3129 n = 3;
3130 up = 0;
3131 dn = 0;
3132 result = 1;
3133 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n"));
3134 }
3135 }
3136 else if (retryCount <= 3) // <=3 retry in the last 2-second duration
3137 {
3138 up--;
3139 dn++;
3140
3141 if (up <= 0)
3142 up = 0;
3143
3144 if (dn == 2) // if �s�� 2 ��2�� retry count< 3, �h�կ�WiFi duration
3145 {
3146 if (WaitCount <= 2)
3147 m++; // �קK�@���b���level���Ӧ^
3148 else
3149 m = 1;
3150
3151 if ( m >= 20) //m �̤j�� = 20 ' �̤j120�� recheck�O�_�վ� WiFi duration.
3152 m = 20;
3153
3154 n = 3*m;
3155 up = 0;
3156 dn = 0;
3157 WaitCount = 0;
3158 result = -1;
3159 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
3160 }
3161 }
3162 else //retry count > 3, �u�n1�� retry count > 3, �h�կ�WiFi duration
3163 {
3164 if (WaitCount == 1)
3165 m++; // �קK�@���b���level���Ӧ^
3166 else
3167 m = 1;
3168
3169 if ( m >= 20) //m �̤j�� = 20 ' �̤j120�� recheck�O�_�վ� WiFi duration.
3170 m = 20;
3171
3172 n = 3*m;
3173 up = 0;
3174 dn = 0;
3175 WaitCount = 0;
3176 result = -1;
3177 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
3178 }
3179
3180 if(result == -1)
3181 {
3182 /*
3183 if( (BT_INFO_8192E_2ANT_A2DP_BASIC_RATE(btInfoExt)) &&
3184 ((pCoexDm->curPsTdma == 81) ||(pCoexDm->curPsTdma == 82)) )
3185 if( (BT_INFO_8192E_2ANT_A2DP_BASIC_RATE(btInfoExt)) &&
3186 ((pCoexDm->curPsTdma == 81) ||(pCoexDm->curPsTdma == 82)) )
3187
3188 {
3189 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 84);
3190 pCoexDm->psTdmaDuAdjType = 84;
3191 }
3192 */
3193 if(pCoexDm->curPsTdma == 80)
3194 {
3195 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 81);
3196 pCoexDm->psTdmaDuAdjType = 81;
3197 }
3198 else if(pCoexDm->curPsTdma == 81)
3199 {
3200 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82);
3201 pCoexDm->psTdmaDuAdjType = 82;
3202 }
3203 else if(pCoexDm->curPsTdma == 82)
3204 {
3205 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83);
3206 pCoexDm->psTdmaDuAdjType = 83;
3207 }
3208 else if(pCoexDm->curPsTdma == 83)
3209 {
3210 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 84);
3211 pCoexDm->psTdmaDuAdjType = 84;
3212 }
3213 }
3214 else if(result == 1)
3215 {
3216 /*
3217 if( (BT_INFO_8192E_2ANT_A2DP_BASIC_RATE(btInfoExt)) &&
3218 ((pCoexDm->curPsTdma == 81) ||(pCoexDm->curPsTdma == 82)) )
3219 {
3220 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83);
3221 pCoexDm->psTdmaDuAdjType = 83;
3222 }
3223 */
3224 if(pCoexDm->curPsTdma == 84)
3225 {
3226 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83);
3227 pCoexDm->psTdmaDuAdjType = 83;
3228 }
3229 else if(pCoexDm->curPsTdma == 83)
3230 {
3231 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82);
3232 pCoexDm->psTdmaDuAdjType = 82;
3233 }
3234 else if(pCoexDm->curPsTdma == 82)
3235 {
3236 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 81);
3237 pCoexDm->psTdmaDuAdjType = 81;
3238 }
3239 else if((pCoexDm->curPsTdma == 81)&&((pCoexSta->nScanAPNum <= NOISY_AP_NUM_THRESH)))
3240 {
3241 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 80);
3242 pCoexDm->psTdmaDuAdjType = 80;
3243 }
3244
3245 }
3246
3247 if( pCoexDm->curPsTdma != 80 &&
3248 pCoexDm->curPsTdma != 81 &&
3249 pCoexDm->curPsTdma != 82 &&
3250 pCoexDm->curPsTdma != 83 &&
3251 pCoexDm->curPsTdma != 84 )
3252 {
3253 // recover to previous adjust type
3254 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);
3255 }
3256 }
3257 }
3258
3259 VOID
halbtc8192e2ant_GetBtRssiThreshold(IN PBTC_COEXIST pBtCoexist,IN pu1Byte pThres0,IN pu1Byte pThres1)3260 halbtc8192e2ant_GetBtRssiThreshold(
3261 IN PBTC_COEXIST pBtCoexist,
3262 IN pu1Byte pThres0,
3263 IN pu1Byte pThres1
3264 )
3265 {
3266 u1Byte antType, btThreshold=0;
3267
3268 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_ANT_TYPE, &antType);
3269
3270 switch(antType)
3271 {
3272 case BTC_ANT_TYPE_0: // 92E with SPDT
3273 *pThres0 = 100;
3274 *pThres1 = 100;
3275 break;
3276 case BTC_ANT_TYPE_1: //92E without SPDT, poor antenna isolation
3277 *pThres0 = 34;
3278 *pThres1 = 42;
3279 break;
3280 case BTC_ANT_TYPE_2: //92E without SPDT, normal antenna isolation
3281 *pThres0 = 34; //92E with coupler, goodl antenna isolation
3282 *pThres1 = 42;
3283 break;
3284 case BTC_ANT_TYPE_3:
3285 *pThres0 = 34;
3286 *pThres1 = 42;
3287 break;
3288 case BTC_ANT_TYPE_4:
3289 *pThres0 = 34;
3290 *pThres1 = 42;
3291 break;
3292 default:
3293 break;
3294 }
3295 }
3296
3297
3298 //undefined
3299 VOID
halbtc8192e2ant_ActionUndefined(IN PBTC_COEXIST pBtCoexist)3300 halbtc8192e2ant_ActionUndefined(
3301 IN PBTC_COEXIST pBtCoexist
3302 )
3303 {
3304 // power save state
3305 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3306
3307 // coex table
3308 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3309
3310 // pstdma
3311 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
3312
3313 // decrease BT power
3314 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3315
3316 // limited Rx
3317 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
3318
3319 // fw dac swing level
3320 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
3321
3322 // sw mechanism
3323 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
3324 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
3325 }
3326
3327
3328 // SCO only or SCO+PAN(HS)
3329 VOID
halbtc8192e2ant_ActionSco(IN PBTC_COEXIST pBtCoexist)3330 halbtc8192e2ant_ActionSco(
3331 IN PBTC_COEXIST pBtCoexist
3332 )
3333 {
3334 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH;
3335 u4Byte wifiBw;
3336 u1Byte btThresh0=0, btThresh1=0;
3337 BOOLEAN bApEnable=FALSE;
3338
3339 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
3340
3341 halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1);
3342 btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1);
3343
3344 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0);
3345 // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
3346
3347 // power save state
3348 if((bApEnable == TRUE) || (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))))
3349 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3350 else
3351 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3352 // halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, TRUE, 0x50, 0x4);
3353
3354 // coex table
3355 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))
3356 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3357 else
3358 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3359
3360 // pstdma
3361 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))
3362 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
3363 else
3364 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
3365
3366 // decrease BT power
3367 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3368
3369 // limited Rx
3370 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
3371
3372 // fw dac swing level
3373 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
3374
3375 // sw mechanism
3376 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
3377 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
3378 }
3379
3380 VOID
halbtc8192e2ant_ActionScoPan(IN PBTC_COEXIST pBtCoexist)3381 halbtc8192e2ant_ActionScoPan(
3382 IN PBTC_COEXIST pBtCoexist
3383 )
3384 {
3385 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH;
3386 u4Byte wifiBw;
3387 u1Byte btThresh0=0, btThresh1=0;
3388 BOOLEAN bApEnable=FALSE;
3389
3390 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
3391
3392 halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1);
3393 btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1);
3394
3395 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0);
3396 // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
3397
3398 // power save state
3399 if((bApEnable == TRUE) || (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))))
3400 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3401 else
3402 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3403
3404 // coex table
3405 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))
3406 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);
3407 else
3408 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3409
3410
3411 // pstdm
3412 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3413 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); //shielding room
3414 else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3415 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 10); //open space //antenna at BT
3416 else //low RSSI
3417 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86);
3418
3419
3420 /*
3421 // decrease BT power
3422 if(BTC_RSSI_LOW(btRssiState))
3423 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3424 else if(BTC_RSSI_MEDIUM(btRssiState))
3425 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
3426 else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room
3427 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
3428 */
3429
3430 // limited Rx
3431 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
3432
3433 // fw dac swing level
3434 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
3435
3436 // sw mechanism
3437 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
3438 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3439 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room
3440 else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3441 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space
3442 else //low RSSI
3443 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
3444 }
3445
3446 VOID
halbtc8192e2ant_ActionHid(IN PBTC_COEXIST pBtCoexist)3447 halbtc8192e2ant_ActionHid(
3448 IN PBTC_COEXIST pBtCoexist
3449 )
3450 {
3451 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH;
3452 u4Byte wifiBw;
3453 u1Byte anttype=0;
3454 BOOLEAN bApEnable=FALSE;
3455
3456 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
3457 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_ANT_TYPE, &anttype);
3458
3459 // halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1);
3460 // btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1);
3461
3462 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0);
3463 btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
3464
3465 if(anttype == 0)//ANTTYPE = 0 92E 2ant with SPDT
3466 {
3467 // power save state & pstdma & coex table
3468 pCoexDm->bAutoTdmaAdjust = FALSE;
3469 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3470 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3471 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
3472 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3473 }
3474 else if(anttype == 1) //92E 2ant with coupler and bad ant. isolation, 92E 3ant with bad ant. isolation
3475 {
3476 // power save state & pstdma & coex table
3477 pCoexDm->bAutoTdmaAdjust = FALSE;
3478 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3479 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3480 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
3481 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3482 }
3483 else if(anttype == 2)//ANTTYPE = 2, 92E 2ant with coupler and normal/good ant. isolation, 92E 3ant with normal ant. isolation
3484 {
3485 // power save state & pstdma & coex table
3486 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3487 { //WIFI RSSI = high & BT RSSI = high & shielding room
3488 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3489 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 9);
3490 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3);
3491 }
3492 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3493 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
3494 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3495 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 9);
3496 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3);
3497 }
3498 else //WIFI RSSI || BT RSSI == low
3499 {
3500 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3501 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 9);
3502 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3);
3503 }
3504 }
3505 else if(anttype == 3) //ANTTYPE = 3, 92E 3ant with good ant. isolation
3506 {
3507 // power save state & pstdma & coex table
3508 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3509 { //WIFI RSSI = high & BT RSSI = high & shielding room
3510 pCoexDm->bAutoTdmaAdjust = FALSE;
3511 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3512 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3513 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
3514 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3515
3516 }
3517 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3518 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
3519 pCoexDm->bAutoTdmaAdjust = FALSE;
3520 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3521 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3522 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
3523 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3524
3525 }
3526 else //WIFI RSSI || BT RSSI == low
3527 {
3528 pCoexDm->bAutoTdmaAdjust = FALSE;
3529 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3530 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3531 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
3532 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3533 }
3534 }
3535 else //ANTTYPE = 4 for test
3536 {
3537 // power save state & pstdma & coex table
3538 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3539 { //WIFI RSSI = high & BT RSSI = high & shielding room
3540 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3541 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3542 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3543 }
3544 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3545 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
3546 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3547 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3548 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3549 }
3550 else //WIFI RSSI || BT RSSI == low
3551 {
3552 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3553 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3554 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3555 }
3556 }
3557
3558 // power save state
3559 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3560
3561 // coex table
3562 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3563
3564 // pstdma
3565 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
3566
3567 // decrease BT power
3568 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3569
3570 // limited Rx
3571 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
3572
3573 // fw dac swing level
3574 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
3575
3576 // sw mechanism
3577 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
3578 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
3579 }
3580
3581 //A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
3582 VOID
halbtc8192e2ant_ActionA2dp(IN PBTC_COEXIST pBtCoexist)3583 halbtc8192e2ant_ActionA2dp(
3584 IN PBTC_COEXIST pBtCoexist
3585 )
3586 {
3587 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH;
3588 u4Byte wifiBw;
3589 u1Byte anttype=0;
3590
3591 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_ANT_TYPE, &anttype);
3592
3593 // halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1);
3594 // btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1);
3595
3596 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0);
3597 btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
3598
3599 // anttype = 4;
3600
3601 if(anttype == 0)//ANTTYPE = 0 92E 2ant with SPDT
3602 {
3603 // power save state & pstdma & coex table
3604 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3605 { //WIFI RSSI = high & BT RSSI = high & shielding room
3606 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3607 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3608 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3609 }
3610 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3611 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
3612 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3613 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3614 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3615 }
3616 else //WIFI RSSI || BT RSSI == low
3617 {
3618 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3619 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3620 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3621 }
3622 }
3623 else if(anttype == 1) //92E 2ant with coupler and bad ant. isolation, 92E 3ant with bad ant. isolation
3624 {
3625 // power save state & pstdma & coex table
3626 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3627 { //WIFI RSSI = high & BT RSSI = high & shielding room
3628 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3629 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); //shielding room
3630 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3631 }
3632 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3633 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
3634 pCoexDm->bAutoTdmaAdjust = FALSE;
3635 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3636 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3637 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
3638 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3639 }
3640 else //WIFI RSSI || BT RSSI == low
3641 {
3642 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3643 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3644 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3645 }
3646
3647 }
3648 else if(anttype == 2)//ANTTYPE = 2, 92E 2ant with coupler and normal/good ant. isolation, 92E 3ant with normal ant. isolation
3649 {
3650 // power save state & pstdma & coex table
3651 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3652 { //WIFI RSSI = high & BT RSSI = high & shielding room
3653 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3654 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);
3655 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);
3656 }
3657 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3658 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
3659 pCoexDm->bAutoTdmaAdjust = FALSE;
3660 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3661 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3662 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
3663 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3664 }
3665 else //WIFI RSSI || BT RSSI == low
3666 {
3667 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3668 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3669 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3670 }
3671 }
3672 else if(anttype == 3) //ANTTYPE = 3, 92E 3ant with good ant. isolation
3673 {
3674 // power save state & pstdma & coex table
3675 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3676 { //WIFI RSSI = high & BT RSSI = high & shielding room
3677 pCoexDm->bAutoTdmaAdjust = FALSE;
3678 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3679 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3680 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
3681 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3682
3683 }
3684 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3685 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
3686 pCoexDm->bAutoTdmaAdjust = FALSE;
3687 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3688 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3689 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
3690 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3691
3692 }
3693 else //WIFI RSSI || BT RSSI == low
3694 {
3695 pCoexDm->bAutoTdmaAdjust = FALSE;
3696 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3697 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3698 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
3699 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3700 }
3701 }
3702 else //ANTTYPE = 4 for test
3703 {
3704 // power save state & pstdma & coex table
3705 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3706 { //WIFI RSSI = high & BT RSSI = high & shielding room
3707 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3708 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3709 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3710 }
3711 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3712 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
3713 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3714 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3715 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3716 }
3717 else //WIFI RSSI || BT RSSI == low
3718 {
3719 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3720 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
3721 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
3722 }
3723 }
3724
3725 /*
3726 // decrease BT power
3727 if(BTC_RSSI_LOW(btRssiState))
3728 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3729 else if(BTC_RSSI_MEDIUM(btRssiState))
3730 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
3731 else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room
3732 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
3733 */
3734 // limited Rx
3735 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
3736
3737 // fw dac swing level
3738 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
3739
3740 // sw mechanism
3741 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
3742 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3743 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room
3744 else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3745 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x06); //open space
3746 else //low RSSI
3747 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
3748 }
3749
3750 VOID
halbtc8192e2ant_ActionA2dpPanHs(IN PBTC_COEXIST pBtCoexist)3751 halbtc8192e2ant_ActionA2dpPanHs(
3752 IN PBTC_COEXIST pBtCoexist
3753 )
3754 {
3755 u1Byte wifiRssiState, btRssiState=BTC_RSSI_STATE_HIGH;
3756 u4Byte wifiBw;
3757
3758 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
3759 btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
3760
3761 // halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
3762 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
3763
3764 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
3765 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
3766
3767 if( (btRssiState == BTC_RSSI_STATE_LOW) ||
3768 (btRssiState == BTC_RSSI_STATE_STAY_LOW) )
3769 {
3770 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2);
3771 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3772 }
3773 else if( (btRssiState == BTC_RSSI_STATE_MEDIUM) ||
3774 (btRssiState == BTC_RSSI_STATE_STAY_MEDIUM) )
3775 {
3776 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 2);
3777 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
3778 }
3779 else if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
3780 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3781 {
3782 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 2);
3783 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
3784 }
3785
3786 // sw mechanism
3787 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3788 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
3789 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
3790 }
3791
3792 VOID
halbtc8192e2ant_ActionPanEdr(IN PBTC_COEXIST pBtCoexist)3793 halbtc8192e2ant_ActionPanEdr(
3794 IN PBTC_COEXIST pBtCoexist
3795 )
3796 {
3797 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH;
3798 u4Byte wifiBw;
3799 u1Byte btThresh0=0, btThresh1=0;
3800
3801 halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1);
3802 btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1);
3803
3804 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0);
3805 // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
3806
3807 // power save state
3808 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))
3809 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3810 else
3811 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3812
3813 // coex table
3814 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))
3815 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
3816 else
3817 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3818
3819 // pstdma
3820 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3821 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); //shielding room
3822 else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3823 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); //open space //antenna at BT
3824 else //low RSSI
3825 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 85);
3826
3827 /*
3828 // decrease BT power
3829 if(BTC_RSSI_LOW(btRssiState))
3830 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3831 else if(BTC_RSSI_MEDIUM(btRssiState))
3832 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
3833 else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room
3834 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
3835 */
3836
3837 // limited Rx
3838 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
3839
3840 // fw dac swing level
3841 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
3842
3843 // sw mechanism
3844 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
3845 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3846 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room
3847 else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3848 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space
3849 else //low RSSI
3850 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
3851 }
3852
3853 //PAN(HS) only
3854 VOID
halbtc8192e2ant_ActionPanHs(IN PBTC_COEXIST pBtCoexist)3855 halbtc8192e2ant_ActionPanHs(
3856 IN PBTC_COEXIST pBtCoexist
3857 )
3858 {
3859 u1Byte wifiRssiState, btRssiState=BTC_RSSI_STATE_HIGH;
3860 u4Byte wifiBw;
3861
3862 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);
3863 btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
3864
3865 // halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
3866 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
3867 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3868 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
3869 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
3870
3871 if( (btRssiState == BTC_RSSI_STATE_LOW) ||
3872 (btRssiState == BTC_RSSI_STATE_STAY_LOW) )
3873 {
3874 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3875 }
3876 else if( (btRssiState == BTC_RSSI_STATE_MEDIUM) ||
3877 (btRssiState == BTC_RSSI_STATE_STAY_MEDIUM) )
3878 {
3879 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
3880 }
3881 else if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
3882 (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
3883 {
3884 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
3885 }
3886 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);
3887
3888 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
3889 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
3890 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
3891 }
3892
3893 //PAN(EDR)+A2DP
3894 VOID
halbtc8192e2ant_ActionPanEdrA2dp(IN PBTC_COEXIST pBtCoexist)3895 halbtc8192e2ant_ActionPanEdrA2dp(
3896 IN PBTC_COEXIST pBtCoexist
3897 )
3898 {
3899 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH;
3900 u4Byte wifiBw;
3901 u1Byte btThresh0=0, btThresh1=0;
3902
3903 halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1);
3904 btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1);
3905
3906 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0);
3907 // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
3908
3909 // power save state
3910 if((BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))))
3911 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3912 else
3913 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3914
3915 // coex table
3916 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))
3917 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
3918 else
3919 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3920
3921 // pstdma
3922 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3923 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); //shielding room
3924 else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3925 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); //open space //antenna at BT
3926 else //low RSSI
3927 {
3928 pCoexDm->bAutoTdmaAdjust = FALSE;
3929 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
3930 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86);
3931 }
3932
3933 /*
3934 // decrease BT power
3935 if(BTC_RSSI_LOW(btRssiState))
3936 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3937 else if(BTC_RSSI_MEDIUM(btRssiState))
3938 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
3939 else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room
3940 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
3941 */
3942
3943 // limited Rx
3944 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
3945
3946 // fw dac swing level
3947 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
3948
3949 // sw mechanism
3950 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
3951 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3952 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room
3953 else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3954 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space
3955 else //low RSSI
3956 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
3957 }
3958
3959 VOID
halbtc8192e2ant_ActionPanEdrHid(IN PBTC_COEXIST pBtCoexist)3960 halbtc8192e2ant_ActionPanEdrHid(
3961 IN PBTC_COEXIST pBtCoexist
3962 )
3963 {
3964 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH;
3965 u4Byte wifiBw;
3966 u1Byte btThresh0=0, btThresh1=0;
3967
3968 halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1);
3969 btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1);
3970
3971 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0);
3972 // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
3973
3974 // power save state
3975 if((BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))))
3976 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
3977 else
3978 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
3979
3980 // coex table
3981 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))
3982 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3);
3983 else
3984 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
3985
3986 // pstdm
3987 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
3988 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); //shielding room
3989 else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
3990 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); //open space //antenna at BT
3991 else //low RSSI
3992 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86);
3993
3994 /*
3995 // decrease BT power
3996 if(BTC_RSSI_LOW(btRssiState))
3997 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
3998 else if(BTC_RSSI_MEDIUM(btRssiState))
3999 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
4000 else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room
4001 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
4002 */
4003
4004 // limited Rx
4005 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
4006
4007 // fw dac swing level
4008 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
4009
4010 // sw mechanism
4011 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
4012 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
4013 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room
4014 else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
4015 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space
4016 else //low RSSI
4017 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
4018 }
4019
4020 // HID+A2DP+PAN(EDR)
4021 VOID
halbtc8192e2ant_ActionHidA2dpPanEdr(IN PBTC_COEXIST pBtCoexist)4022 halbtc8192e2ant_ActionHidA2dpPanEdr(
4023 IN PBTC_COEXIST pBtCoexist
4024 )
4025 {
4026 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH;
4027 u4Byte wifiBw;
4028 u1Byte btThresh0=0, btThresh1=0;
4029
4030 halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1);
4031 btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1);
4032
4033 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0);
4034 // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
4035
4036 // power save state
4037 if((BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))))
4038 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
4039 else
4040 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
4041
4042 // coex table
4043 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))
4044 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3);
4045 else
4046 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); //6
4047
4048 // pstdma
4049 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
4050 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); //shielding room
4051 else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
4052 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); //open space //antenna at BT
4053 else //low RSSI
4054 {
4055 pCoexDm->bAutoTdmaAdjust = FALSE;
4056 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
4057 halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86);
4058 }
4059
4060 /*
4061 // decrease BT power
4062 if(BTC_RSSI_LOW(btRssiState))
4063 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
4064 else if(BTC_RSSI_MEDIUM(btRssiState))
4065 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
4066 else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room
4067 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
4068 */
4069 // limited Rx
4070 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
4071
4072 // fw dac swing level
4073 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
4074
4075 // sw mechanism
4076 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
4077 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
4078 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room
4079 else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
4080 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space
4081 else //low RSSI
4082 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
4083 }
4084
4085 VOID
halbtc8192e2ant_ActionHidA2dp(IN PBTC_COEXIST pBtCoexist)4086 halbtc8192e2ant_ActionHidA2dp(
4087 IN PBTC_COEXIST pBtCoexist
4088 )
4089 {
4090 u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH;
4091 u4Byte wifiBw;
4092 u1Byte btThresh0=0, btThresh1=0, anttype=0;
4093
4094 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_ANT_TYPE, &anttype);
4095
4096 // halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1);
4097 // btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1);
4098
4099 wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0);
4100 btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42);
4101
4102 if(anttype == 0)//ANTTYPE = 0 92E 2ant with SPDT
4103 {
4104 // power save state & pstdma & coex table
4105 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
4106 {
4107 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
4108 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83);
4109 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
4110
4111 }
4112 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
4113 {
4114 pCoexDm->bAutoTdmaAdjust = FALSE;
4115 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
4116 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
4117 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
4118 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
4119 }
4120 else
4121 {
4122 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
4123 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83);
4124 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
4125 }
4126 }
4127 else if(anttype == 1) //92E 2ant with coupler and bad ant. isolation, 92E 3ant with bad ant. isolation
4128 {
4129 // power save state & pstdma & coex table
4130 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
4131 {
4132 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
4133 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2);
4134 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
4135 }
4136 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
4137 {
4138 pCoexDm->bAutoTdmaAdjust = FALSE;
4139 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
4140 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
4141 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
4142 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
4143 }
4144 else
4145 {
4146 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
4147 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83);
4148 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
4149 }
4150 }
4151 else if(anttype == 2)//ANTTYPE = 2, 92E 2ant with coupler and normal/good ant. isolation, 92E 3ant with normal ant. isolation
4152 {
4153 // power save state & pstdma & coex table
4154 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
4155 { //WIFI RSSI = high & BT RSSI = high & shielding room
4156 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
4157 halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2);
4158 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
4159 }
4160 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
4161 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
4162 pCoexDm->bAutoTdmaAdjust = FALSE;
4163 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
4164 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
4165 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
4166 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
4167 }
4168 else //WIFI RSSI || BT RSSI == low
4169 {
4170 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
4171 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83);
4172 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);
4173 }
4174 }
4175 else if(anttype == 3) //ANTTYPE = 3, 92E 3ant with good ant. isolation
4176 {
4177 // power save state & pstdma & coex table
4178 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
4179 { //WIFI RSSI = high & BT RSSI = high & shielding room
4180 pCoexDm->bAutoTdmaAdjust = FALSE;
4181 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
4182 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
4183 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
4184 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
4185
4186 }
4187 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
4188 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
4189 pCoexDm->bAutoTdmaAdjust = FALSE;
4190 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
4191 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
4192 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
4193 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
4194
4195 }
4196 else //WIFI RSSI || BT RSSI == low
4197 {
4198 pCoexDm->bAutoTdmaAdjust = FALSE;
4199 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
4200 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
4201 halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);
4202 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
4203 }
4204 }
4205 else //ANTTYPE = 4 for test
4206 {
4207 // power save state & pstdma & coex table
4208 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
4209 { //WIFI RSSI = high & BT RSSI = high & shielding room
4210 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
4211 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
4212 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
4213 }
4214 else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
4215 { //WIFI RSSI = high & BT RSSI = high & noisy enviroment
4216 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
4217 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
4218 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
4219 }
4220 else //WIFI RSSI || BT RSSI == low
4221 {
4222 halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);
4223 halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist);
4224 halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
4225 }
4226 }
4227
4228 /*
4229 // decrease BT power
4230 if(BTC_RSSI_LOW(btRssiState))
4231 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
4232 else if(BTC_RSSI_MEDIUM(btRssiState))
4233 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
4234 else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room
4235 halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);
4236 */
4237
4238 // limited Rx
4239 halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);
4240
4241 // fw dac swing level
4242 halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);
4243
4244 // sw mechanism
4245 halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
4246 if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH))
4247 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room
4248 else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH))
4249 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x06); //open space
4250 else //low RSSI
4251 halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
4252 }
4253
4254 VOID
halbtc8192e2ant_ActionBtWhckTest(IN PBTC_COEXIST pBtCoexist)4255 halbtc8192e2ant_ActionBtWhckTest(
4256 IN PBTC_COEXIST pBtCoexist
4257 )
4258 {
4259
4260 }
4261
4262 VOID
halbtc8192e2ant_ActionWifiMultiPort(IN PBTC_COEXIST pBtCoexist)4263 halbtc8192e2ant_ActionWifiMultiPort(
4264 IN PBTC_COEXIST pBtCoexist
4265 )
4266 {
4267
4268 }
4269
4270 VOID
halbtc8192e2ant_RunCoexistMechanism(IN PBTC_COEXIST pBtCoexist)4271 halbtc8192e2ant_RunCoexistMechanism(
4272 IN PBTC_COEXIST pBtCoexist
4273 )
4274 {
4275 BOOLEAN bWifiUnder5G=FALSE;
4276 u1Byte btInfoOriginal=0, btRetryCnt=0;
4277 u1Byte algorithm=0;
4278
4279 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n"));
4280
4281 if(pBtCoexist->bManualControl)
4282 {
4283 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
4284 return;
4285 }
4286
4287 if(pCoexSta->bUnderIps)
4288 {
4289 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n"));
4290 return;
4291 }
4292
4293 algorithm = halbtc8192e2ant_ActionAlgorithm(pBtCoexist);
4294 if(pCoexSta->bC2hBtInquiryPage && (BT_8192E_2ANT_COEX_ALGO_PANHS!=algorithm))
4295 {
4296 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n"));
4297 halbtc8192e2ant_ActionBtInquiry(pBtCoexist);
4298 return;
4299 }
4300
4301 pCoexDm->curAlgorithm = algorithm;
4302 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm));
4303
4304 if(halbtc8192e2ant_IsCommonAction(pBtCoexist))
4305 {
4306 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n"));
4307 pCoexDm->bAutoTdmaAdjust = FALSE;
4308 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
4309 }
4310 else
4311 {
4312 if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm)
4313 {
4314 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n",
4315 pCoexDm->preAlgorithm, pCoexDm->curAlgorithm));
4316 pCoexDm->bAutoTdmaAdjust = FALSE;
4317 pCoexDm->bAutoTdmaAdjustLowRssi = FALSE;
4318 }
4319 switch(pCoexDm->curAlgorithm)
4320 {
4321 case BT_8192E_2ANT_COEX_ALGO_SCO:
4322 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n"));
4323 halbtc8192e2ant_ActionSco(pBtCoexist);
4324 break;
4325 case BT_8192E_2ANT_COEX_ALGO_SCO_PAN:
4326 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO+PAN(EDR).\n"));
4327 halbtc8192e2ant_ActionScoPan(pBtCoexist);
4328 break;
4329 case BT_8192E_2ANT_COEX_ALGO_HID:
4330 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n"));
4331 halbtc8192e2ant_ActionHid(pBtCoexist);
4332 break;
4333 case BT_8192E_2ANT_COEX_ALGO_A2DP:
4334 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n"));
4335 halbtc8192e2ant_ActionA2dp(pBtCoexist);
4336 break;
4337 case BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS:
4338 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n"));
4339 halbtc8192e2ant_ActionA2dpPanHs(pBtCoexist);
4340 break;
4341 case BT_8192E_2ANT_COEX_ALGO_PANEDR:
4342 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"));
4343 halbtc8192e2ant_ActionPanEdr(pBtCoexist);
4344 break;
4345 case BT_8192E_2ANT_COEX_ALGO_PANHS:
4346 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n"));
4347 halbtc8192e2ant_ActionPanHs(pBtCoexist);
4348 break;
4349 case BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP:
4350 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"));
4351 halbtc8192e2ant_ActionPanEdrA2dp(pBtCoexist);
4352 break;
4353 case BT_8192E_2ANT_COEX_ALGO_PANEDR_HID:
4354 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
4355 halbtc8192e2ant_ActionPanEdrHid(pBtCoexist);
4356 break;
4357 case BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
4358 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
4359 halbtc8192e2ant_ActionHidA2dpPanEdr(pBtCoexist);
4360 break;
4361 case BT_8192E_2ANT_COEX_ALGO_HID_A2DP:
4362 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"));
4363 halbtc8192e2ant_ActionHidA2dp(pBtCoexist);
4364 break;
4365 default:
4366 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = undefined!!\n"));
4367 halbtc8192e2ant_ActionUndefined(pBtCoexist);
4368 break;
4369 }
4370 pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
4371 }
4372 }
4373
4374 VOID
halbtc8192e2ant_InitHwConfig(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bBackUp)4375 halbtc8192e2ant_InitHwConfig(
4376 IN PBTC_COEXIST pBtCoexist,
4377 IN BOOLEAN bBackUp
4378 )
4379 {
4380 u4Byte u4Tmp=0;
4381 u2Byte u2Tmp=0;
4382 u1Byte u1Tmp=0;
4383
4384 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n"));
4385
4386 if(bBackUp)
4387 {
4388 // backup rf 0x1e value
4389 pCoexDm->btRf0x1eBackup =
4390 pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
4391
4392 pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
4393 pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
4394 pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
4395 pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
4396 }
4397
4398 // antenna sw ctrl to bt
4399 halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, TRUE, FALSE);
4400
4401 halbtc8192e2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
4402
4403 // antenna switch control parameter
4404 pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x858, 0x55555555);
4405
4406 // coex parameters
4407 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);
4408 // 0x790[5:0]=0x5
4409 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);
4410 u1Tmp &= 0xc0;
4411 u1Tmp |= 0x5;
4412 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);
4413
4414 // enable counter statistics
4415 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);
4416
4417 // enable PTA
4418 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20);
4419 // enable mailbox interface
4420 u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x40);
4421 u2Tmp |= BIT9;
4422 pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x40, u2Tmp);
4423
4424 // enable PTA I2C mailbox
4425 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x101);
4426 u1Tmp |= BIT4;
4427 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x101, u1Tmp);
4428
4429 // enable bt clock when wifi is disabled.
4430 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x93);
4431 u1Tmp |= BIT0;
4432 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x93, u1Tmp);
4433 // enable bt clock when suspend.
4434 u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7);
4435 u1Tmp |= BIT0;
4436 pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x7, u1Tmp);
4437 }
4438
4439 //============================================================
4440 // work around function start with wa_halbtc8192e2ant_
4441 //============================================================
4442 //============================================================
4443 // extern function start with EXhalbtc8192e2ant_
4444 //============================================================
4445 VOID
EXhalbtc8192e2ant_PowerOnSetting(IN PBTC_COEXIST pBtCoexist)4446 EXhalbtc8192e2ant_PowerOnSetting(
4447 IN PBTC_COEXIST pBtCoexist
4448 )
4449 {
4450 }
4451
4452 VOID
EXhalbtc8192e2ant_InitHwConfig(IN PBTC_COEXIST pBtCoexist,IN BOOLEAN bWifiOnly)4453 EXhalbtc8192e2ant_InitHwConfig(
4454 IN PBTC_COEXIST pBtCoexist,
4455 IN BOOLEAN bWifiOnly
4456 )
4457 {
4458 halbtc8192e2ant_InitHwConfig(pBtCoexist, TRUE);
4459 }
4460
4461 VOID
EXhalbtc8192e2ant_InitCoexDm(IN PBTC_COEXIST pBtCoexist)4462 EXhalbtc8192e2ant_InitCoexDm(
4463 IN PBTC_COEXIST pBtCoexist
4464 )
4465 {
4466 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n"));
4467
4468 halbtc8192e2ant_InitCoexDm(pBtCoexist);
4469 }
4470
4471 VOID
EXhalbtc8192e2ant_DisplayCoexInfo(IN PBTC_COEXIST pBtCoexist)4472 EXhalbtc8192e2ant_DisplayCoexInfo(
4473 IN PBTC_COEXIST pBtCoexist
4474 )
4475 {
4476 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
4477 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
4478 pu1Byte cliBuf=pBtCoexist->cliBuf;
4479 u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
4480 u2Byte u2Tmp[4];
4481 u4Byte u4Tmp[4];
4482 u4Byte faOfdm, faCck;
4483 u4Byte fwVer=0, btPatchVer=0;
4484
4485 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
4486 CL_PRINTF(cliBuf);
4487
4488 if(pBtCoexist->bManualControl)
4489 {
4490 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
4491 CL_PRINTF(cliBuf);
4492 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
4493 CL_PRINTF(cliBuf);
4494 }
4495
4496 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
4497 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);
4498 CL_PRINTF(cliBuf);
4499
4500 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Antenna type:", \
4501 pBoardInfo->antType);
4502 CL_PRINTF(cliBuf);
4503
4504 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
4505 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
4506 CL_PRINTF(cliBuf);
4507
4508 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
4509 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
4510 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
4511 GLCoexVerDate8192e2Ant, GLCoexVer8192e2Ant, fwVer, btPatchVer, btPatchVer);
4512 CL_PRINTF(cliBuf);
4513
4514 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \
4515 pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
4516 pCoexDm->wifiChnlInfo[2]);
4517 CL_PRINTF(cliBuf);
4518
4519 // wifi status
4520 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");
4521 CL_PRINTF(cliBuf);
4522 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);
4523
4524 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");
4525 CL_PRINTF(cliBuf);
4526
4527 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
4528 ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
4529 ( (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
4530 pCoexSta->btRssi, pCoexSta->btRetryCnt);
4531 CL_PRINTF(cliBuf);
4532
4533 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
4534 pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist);
4535 CL_PRINTF(cliBuf);
4536 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
4537
4538 btInfoExt = pCoexSta->btInfoExt;
4539 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
4540 (btInfoExt&BIT0)? "Basic rate":"EDR rate");
4541 CL_PRINTF(cliBuf);
4542
4543 for(i=0; i<BT_INFO_SRC_8192E_2ANT_MAX; i++)
4544 {
4545 if(pCoexSta->btInfoC2hCnt[i])
4546 {
4547 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8192e2Ant[i], \
4548 pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
4549 pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
4550 pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
4551 pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
4552 CL_PRINTF(cliBuf);
4553 }
4554 }
4555 /*
4556 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "SS Type", \
4557 pCoexDm->curSsType);
4558 CL_PRINTF(cliBuf);
4559 */
4560 // Sw mechanism
4561 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
4562 CL_PRINTF(cliBuf);
4563 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \
4564 pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig);
4565 CL_PRINTF(cliBuf);
4566 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
4567 pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
4568 CL_PRINTF(cliBuf);
4569
4570 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \
4571 pBtCoexist->btInfo.raMask);
4572 CL_PRINTF(cliBuf);
4573
4574 // Fw mechanism
4575 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
4576 CL_PRINTF(cliBuf);
4577
4578 psTdmaCase = pCoexDm->curPsTdma;
4579 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
4580 pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
4581 pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
4582 pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
4583 CL_PRINTF(cliBuf);
4584
4585 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
4586 pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct);
4587 CL_PRINTF(cliBuf);
4588
4589 // Hw setting
4590 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
4591 CL_PRINTF(cliBuf);
4592
4593 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
4594 pCoexDm->btRf0x1eBackup);
4595 CL_PRINTF(cliBuf);
4596
4597 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", \
4598 pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime);
4599 CL_PRINTF(cliBuf);
4600
4601 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);
4602 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);
4603 u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);
4604 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);
4605 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \
4606 u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]);
4607 CL_PRINTF(cliBuf);
4608
4609 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc04);
4610 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xd04);
4611 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x90c);
4612 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xc04/ 0xd04/ 0x90c", \
4613 u4Tmp[0], u4Tmp[1], u4Tmp[2]);
4614 CL_PRINTF(cliBuf);
4615
4616 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);
4617 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \
4618 u1Tmp[0]);
4619 CL_PRINTF(cliBuf);
4620
4621 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x92c);
4622 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930);
4623 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x92c/ 0x930", \
4624 (u1Tmp[0]), u4Tmp[0]);
4625 CL_PRINTF(cliBuf);
4626
4627 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);
4628 u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4f);
4629 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x40/ 0x4f", \
4630 u1Tmp[0], u1Tmp[1]);
4631 CL_PRINTF(cliBuf);
4632
4633 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);
4634 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);
4635 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
4636 u4Tmp[0], u1Tmp[0]);
4637 CL_PRINTF(cliBuf);
4638
4639 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);
4640 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
4641 u4Tmp[0]);
4642 CL_PRINTF(cliBuf);
4643
4644 u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);
4645 u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);
4646 u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);
4647 u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);
4648 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
4649 u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
4650 CL_PRINTF(cliBuf);
4651
4652 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \
4653 pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
4654 CL_PRINTF(cliBuf);
4655 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
4656 pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
4657 CL_PRINTF(cliBuf);
4658 #if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 1)
4659 halbtc8192e2ant_MonitorBtCtr(pBtCoexist);
4660 #endif
4661 pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
4662 }
4663
4664
4665 VOID
EXhalbtc8192e2ant_IpsNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)4666 EXhalbtc8192e2ant_IpsNotify(
4667 IN PBTC_COEXIST pBtCoexist,
4668 IN u1Byte type
4669 )
4670 {
4671 if(BTC_IPS_ENTER == type)
4672 {
4673 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n"));
4674 pCoexSta->bUnderIps = TRUE;
4675 halbtc8192e2ant_CoexAllOff(pBtCoexist);
4676 halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
4677 }
4678 else if(BTC_IPS_LEAVE == type)
4679 {
4680 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n"));
4681 pCoexSta->bUnderIps = FALSE;
4682 }
4683 }
4684
4685 VOID
EXhalbtc8192e2ant_LpsNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)4686 EXhalbtc8192e2ant_LpsNotify(
4687 IN PBTC_COEXIST pBtCoexist,
4688 IN u1Byte type
4689 )
4690 {
4691 if(BTC_LPS_ENABLE == type)
4692 {
4693 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n"));
4694 pCoexSta->bUnderLps = TRUE;
4695 }
4696 else if(BTC_LPS_DISABLE == type)
4697 {
4698 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n"));
4699 pCoexSta->bUnderLps = FALSE;
4700 }
4701 }
4702
4703 VOID
EXhalbtc8192e2ant_ScanNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)4704 EXhalbtc8192e2ant_ScanNotify(
4705 IN PBTC_COEXIST pBtCoexist,
4706 IN u1Byte type
4707 )
4708 {
4709 if(BTC_SCAN_START == type)
4710 {
4711 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));
4712 }
4713 else if(BTC_SCAN_FINISH == type)
4714 {
4715 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));
4716 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum);
4717
4718 }
4719 }
4720
4721 VOID
EXhalbtc8192e2ant_ConnectNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)4722 EXhalbtc8192e2ant_ConnectNotify(
4723 IN PBTC_COEXIST pBtCoexist,
4724 IN u1Byte type
4725 )
4726 {
4727 if(BTC_ASSOCIATE_START == type)
4728 {
4729 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));
4730 }
4731 else if(BTC_ASSOCIATE_FINISH == type)
4732 {
4733 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));
4734 }
4735 }
4736
4737 VOID
EXhalbtc8192e2ant_MediaStatusNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)4738 EXhalbtc8192e2ant_MediaStatusNotify(
4739 IN PBTC_COEXIST pBtCoexist,
4740 IN u1Byte type
4741 )
4742 {
4743 u1Byte H2C_Parameter[3] ={0};
4744 u4Byte wifiBw;
4745 u1Byte wifiCentralChnl;
4746
4747 if(pBtCoexist->bManualControl ||
4748 pBtCoexist->bStopCoexDm ||
4749 pBtCoexist->btInfo.bBtDisabled )
4750 return;
4751
4752 if(BTC_MEDIA_CONNECT == type)
4753 {
4754 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n"));
4755 }
4756 else
4757 {
4758 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n"));
4759 }
4760
4761
4762 // only 2.4G we need to inform bt the chnl mask
4763 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
4764 if( (BTC_MEDIA_CONNECT == type) &&
4765 (wifiCentralChnl <= 14) )
4766 {
4767 H2C_Parameter[0] = 0x1;
4768 H2C_Parameter[1] = wifiCentralChnl;
4769 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
4770 if(BTC_WIFI_BW_HT40 == wifiBw)
4771 H2C_Parameter[2] = 0x30;
4772 else
4773 H2C_Parameter[2] = 0x20;
4774 }
4775
4776 pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
4777 pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
4778 pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
4779
4780 RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n",
4781 H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
4782
4783 pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
4784 }
4785
4786 VOID
EXhalbtc8192e2ant_SpecialPacketNotify(IN PBTC_COEXIST pBtCoexist,IN u1Byte type)4787 EXhalbtc8192e2ant_SpecialPacketNotify(
4788 IN PBTC_COEXIST pBtCoexist,
4789 IN u1Byte type
4790 )
4791 {
4792 if(type == BTC_PACKET_DHCP)
4793 {
4794 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n"));
4795 }
4796 }
4797
4798 VOID
EXhalbtc8192e2ant_BtInfoNotify(IN PBTC_COEXIST pBtCoexist,IN pu1Byte tmpBuf,IN u1Byte length)4799 EXhalbtc8192e2ant_BtInfoNotify(
4800 IN PBTC_COEXIST pBtCoexist,
4801 IN pu1Byte tmpBuf,
4802 IN u1Byte length
4803 )
4804 {
4805 PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;
4806 u1Byte btInfo=0;
4807 u1Byte i, rspSource=0;
4808 BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE;
4809 BOOLEAN bWifiConnected=FALSE;
4810
4811 pCoexSta->bC2hBtInfoReqSent = FALSE;
4812
4813 rspSource = tmpBuf[0]&0xf;
4814 if(rspSource >= BT_INFO_SRC_8192E_2ANT_MAX)
4815 rspSource = BT_INFO_SRC_8192E_2ANT_WIFI_FW;
4816 pCoexSta->btInfoC2hCnt[rspSource]++;
4817
4818 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
4819 for(i=0; i<length; i++)
4820 {
4821 pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
4822 if(i == 1)
4823 btInfo = tmpBuf[i];
4824 if(i == length-1)
4825 {
4826 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i]));
4827 }
4828 else
4829 {
4830 RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i]));
4831 }
4832 }
4833
4834 if(BT_INFO_SRC_8192E_2ANT_WIFI_FW != rspSource)
4835 {
4836 pCoexSta->btRetryCnt = // [3:0]
4837 pCoexSta->btInfoC2h[rspSource][2]&0xf;
4838
4839 pCoexSta->btRssi =
4840 pCoexSta->btInfoC2h[rspSource][3]*2+10;
4841
4842 pCoexSta->btInfoExt =
4843 pCoexSta->btInfoC2h[rspSource][4];
4844
4845 // Here we need to resend some wifi info to BT
4846 // because bt is reset and loss of the info.
4847 if( (pCoexSta->btInfoExt & BIT1) )
4848 {
4849 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
4850
4851 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
4852
4853 if(bWifiConnected)
4854 {
4855 EXhalbtc8192e2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
4856 }
4857 else
4858 {
4859 EXhalbtc8192e2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
4860 }
4861 }
4862
4863 if( (pCoexSta->btInfoExt & BIT3) )
4864 {
4865 if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm)
4866 {
4867 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
4868 halbtc8192e2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
4869 }
4870 }
4871 else
4872 {
4873 // BT already NOT ignore Wlan active, do nothing here.
4874 }
4875
4876 #if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 0)
4877 if( (pCoexSta->btInfoExt & BIT4) )
4878 {
4879 // BT auto report already enabled, do nothing
4880 }
4881 else
4882 {
4883 halbtc8192e2ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);
4884 }
4885 #endif
4886 }
4887
4888 // check BIT2 first ==> check if bt is under inquiry or page scan
4889 if(btInfo & BT_INFO_8192E_2ANT_B_INQ_PAGE)
4890 pCoexSta->bC2hBtInquiryPage = TRUE;
4891 else
4892 pCoexSta->bC2hBtInquiryPage = FALSE;
4893
4894 // set link exist status
4895 if(!(btInfo&BT_INFO_8192E_2ANT_B_CONNECTION))
4896 {
4897 pCoexSta->bBtLinkExist = FALSE;
4898 pCoexSta->bPanExist = FALSE;
4899 pCoexSta->bA2dpExist = FALSE;
4900 pCoexSta->bHidExist = FALSE;
4901 pCoexSta->bScoExist = FALSE;
4902 }
4903 else // connection exists
4904 {
4905 pCoexSta->bBtLinkExist = TRUE;
4906 if(btInfo & BT_INFO_8192E_2ANT_B_FTP)
4907 pCoexSta->bPanExist = TRUE;
4908 else
4909 pCoexSta->bPanExist = FALSE;
4910 if(btInfo & BT_INFO_8192E_2ANT_B_A2DP)
4911 pCoexSta->bA2dpExist = TRUE;
4912 else
4913 pCoexSta->bA2dpExist = FALSE;
4914 if(btInfo & BT_INFO_8192E_2ANT_B_HID)
4915 pCoexSta->bHidExist = TRUE;
4916 else
4917 pCoexSta->bHidExist = FALSE;
4918 if(btInfo & BT_INFO_8192E_2ANT_B_SCO_ESCO)
4919 pCoexSta->bScoExist = TRUE;
4920 else
4921 pCoexSta->bScoExist = FALSE;
4922 }
4923
4924 halbtc8192e2ant_UpdateBtLinkInfo(pBtCoexist);
4925
4926 if(!(btInfo&BT_INFO_8192E_2ANT_B_CONNECTION))
4927 {
4928 pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
4929 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
4930 }
4931 else if(btInfo == BT_INFO_8192E_2ANT_B_CONNECTION) // connection exists but no busy
4932 {
4933 pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE;
4934 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
4935 }
4936 else if((btInfo&BT_INFO_8192E_2ANT_B_SCO_ESCO) ||
4937 (btInfo&BT_INFO_8192E_2ANT_B_SCO_BUSY))
4938 {
4939 pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_SCO_BUSY;
4940 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
4941 }
4942 else if(btInfo&BT_INFO_8192E_2ANT_B_ACL_BUSY)
4943 {
4944 pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_ACL_BUSY;
4945 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
4946 }
4947 else
4948 {
4949 pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_MAX;
4950 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));
4951 }
4952
4953 if( (BT_8192E_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
4954 (BT_8192E_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
4955 (BT_8192E_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
4956 {
4957 bBtBusy = TRUE;
4958 bLimitedDig = TRUE;
4959 }
4960 else
4961 {
4962 bBtBusy = FALSE;
4963 bLimitedDig = FALSE;
4964 }
4965
4966 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
4967
4968 pCoexDm->bLimitedDig = bLimitedDig;
4969 pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig);
4970
4971 halbtc8192e2ant_RunCoexistMechanism(pBtCoexist);
4972 }
4973
4974 VOID
EXhalbtc8192e2ant_HaltNotify(IN PBTC_COEXIST pBtCoexist)4975 EXhalbtc8192e2ant_HaltNotify(
4976 IN PBTC_COEXIST pBtCoexist
4977 )
4978 {
4979 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n"));
4980
4981 halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE);
4982 halbtc8192e2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);
4983 EXhalbtc8192e2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
4984 }
4985
4986 VOID
EXhalbtc8192e2ant_Periodical(IN PBTC_COEXIST pBtCoexist)4987 EXhalbtc8192e2ant_Periodical(
4988 IN PBTC_COEXIST pBtCoexist
4989 )
4990 {
4991 static u1Byte disVerInfoCnt=0;
4992 u4Byte fwVer=0, btPatchVer=0;
4993 PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;
4994 PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo;
4995
4996 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n"));
4997
4998 if(disVerInfoCnt <= 5)
4999 {
5000 disVerInfoCnt += 1;
5001 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));
5002 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n",
5003 pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));
5004 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n",
5005 ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
5006 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
5007 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
5008 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",
5009 GLCoexVerDate8192e2Ant, GLCoexVer8192e2Ant, fwVer, btPatchVer, btPatchVer));
5010 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));
5011 }
5012
5013 #if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 0)
5014 halbtc8192e2ant_QueryBtInfo(pBtCoexist);
5015 halbtc8192e2ant_MonitorBtCtr(pBtCoexist);
5016 halbtc8192e2ant_MonitorBtEnableDisable(pBtCoexist);
5017 #else
5018 if( halbtc8192e2ant_IsWifiStatusChanged(pBtCoexist) ||
5019 pCoexDm->bAutoTdmaAdjust)
5020 {
5021 halbtc8192e2ant_RunCoexistMechanism(pBtCoexist);
5022 }
5023 #endif
5024 }
5025
5026
5027 #endif
5028
5029