Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/hal/hal_btcoex.c
1307 views
1
/******************************************************************************
2
*
3
* Copyright(c) 2013 - 2017 Realtek Corporation.
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms of version 2 of the GNU General Public License as
7
* published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
*****************************************************************************/
15
#define __HAL_BTCOEX_C__
16
17
#ifdef CONFIG_BT_COEXIST
18
19
#include <hal_data.h>
20
#include <hal_btcoex.h>
21
#include "btc/mp_precomp.h"
22
23
/* ************************************
24
* Global variables
25
* ************************************ */
26
const char *const BtProfileString[] = {
27
"NONE",
28
"A2DP",
29
"PAN",
30
"HID",
31
"SCO",
32
};
33
34
const char *const BtSpecString[] = {
35
"1.0b",
36
"1.1",
37
"1.2",
38
"2.0+EDR",
39
"2.1+EDR",
40
"3.0+HS",
41
"4.0",
42
};
43
44
const char *const BtLinkRoleString[] = {
45
"Master",
46
"Slave",
47
};
48
49
const char *const h2cStaString[] = {
50
"successful",
51
"h2c busy",
52
"rf off",
53
"fw not read",
54
};
55
56
const char *const ioStaString[] = {
57
"success",
58
"can not IO",
59
"rf off",
60
"fw not read",
61
"wait io timeout",
62
"invalid len",
63
"idle Q empty",
64
"insert waitQ fail",
65
"unknown fail",
66
"wrong level",
67
"h2c stopped",
68
};
69
70
const char *const GLBtcWifiBwString[] = {
71
"11bg",
72
"HT20",
73
"HT40",
74
"VHT80",
75
"VHT160"
76
};
77
78
const char *const GLBtcWifiFreqString[] = {
79
"2.4G",
80
"5G",
81
"2.4G+5G"
82
};
83
84
const char *const GLBtcIotPeerString[] = {
85
"UNKNOWN",
86
"REALTEK",
87
"REALTEK_92SE",
88
"BROADCOM",
89
"RALINK",
90
"ATHEROS",
91
"CISCO",
92
"MERU",
93
"MARVELL",
94
"REALTEK_SOFTAP", /* peer is RealTek SOFT_AP, by Bohn, 2009.12.17 */
95
"SELF_SOFTAP", /* Self is SoftAP */
96
"AIRGO",
97
"INTEL",
98
"RTK_APCLIENT",
99
"REALTEK_81XX",
100
"REALTEK_WOW",
101
"REALTEK_JAGUAR_BCUTAP",
102
"REALTEK_JAGUAR_CCUTAP"
103
};
104
105
const char *const coexOpcodeString[] = {
106
"Wifi status notify",
107
"Wifi progress",
108
"Wifi info",
109
"Power state",
110
"Set Control",
111
"Get Control"
112
};
113
114
const char *const coexIndTypeString[] = {
115
"bt info",
116
"pstdma",
117
"limited tx/rx",
118
"coex table",
119
"request"
120
};
121
122
const char *const coexH2cResultString[] = {
123
"ok",
124
"unknown",
125
"un opcode",
126
"opVer MM",
127
"par Err",
128
"par OoR",
129
"reqNum MM",
130
"halMac Fail",
131
"h2c TimeOut",
132
"Invalid c2h Len",
133
"data overflow"
134
};
135
136
#define HALBTCOUTSRC_AGG_CHK_WINDOW_IN_MS 8000
137
138
struct btc_coexist GLBtCoexist;
139
BTC_OFFLOAD gl_coex_offload;
140
u8 GLBtcWiFiInScanState;
141
u8 GLBtcWiFiInIQKState;
142
u8 GLBtcWiFiInIPS;
143
u8 GLBtcWiFiInLPS;
144
u8 GLBtcBtCoexAliveRegistered;
145
146
/*
147
* BT control H2C/C2H
148
*/
149
/* EXT_EID */
150
typedef enum _bt_ext_eid {
151
C2H_WIFI_FW_ACTIVE_RSP = 0,
152
C2H_TRIG_BY_BT_FW
153
} BT_EXT_EID;
154
155
/* C2H_STATUS */
156
typedef enum _bt_c2h_status {
157
BT_STATUS_OK = 0,
158
BT_STATUS_VERSION_MISMATCH,
159
BT_STATUS_UNKNOWN_OPCODE,
160
BT_STATUS_ERROR_PARAMETER
161
} BT_C2H_STATUS;
162
163
/* C2H BT OP CODES */
164
typedef enum _bt_op_code {
165
BT_OP_GET_BT_VERSION = 0x00,
166
BT_OP_WRITE_REG_ADDR = 0x0c,
167
BT_OP_WRITE_REG_VALUE = 0x0d,
168
169
BT_OP_READ_REG = 0x11,
170
171
BT_LO_OP_GET_AFH_MAP_L = 0x1e,
172
BT_LO_OP_GET_AFH_MAP_M = 0x1f,
173
BT_LO_OP_GET_AFH_MAP_H = 0x20,
174
175
BT_OP_GET_BT_COEX_SUPPORTED_FEATURE = 0x2a,
176
BT_OP_GET_BT_COEX_SUPPORTED_VERSION = 0x2b,
177
BT_OP_GET_BT_ANT_DET_VAL = 0x2c,
178
BT_OP_GET_BT_BLE_SCAN_TYPE = 0x2d,
179
BT_OP_GET_BT_BLE_SCAN_PARA = 0x2e,
180
BT_OP_GET_BT_DEVICE_INFO = 0x30,
181
BT_OP_GET_BT_FORBIDDEN_SLOT_VAL = 0x31,
182
BT_OP_SET_BT_LANCONSTRAIN_LEVEL = 0x32,
183
BT_OP_SET_BT_TEST_MODE_VAL = 0x33,
184
BT_OP_MAX
185
} BT_OP_CODE;
186
187
#define BTC_MPOPER_TIMEOUT 50 /* unit: ms */
188
189
#define C2H_MAX_SIZE 16
190
u8 GLBtcBtMpOperSeq;
191
_mutex GLBtcBtMpOperLock;
192
_timer GLBtcBtMpOperTimer;
193
_sema GLBtcBtMpRptSema;
194
u8 GLBtcBtMpRptSeq;
195
u8 GLBtcBtMpRptStatus;
196
u8 GLBtcBtMpRptRsp[C2H_MAX_SIZE];
197
u8 GLBtcBtMpRptRspSize;
198
u8 GLBtcBtMpRptWait;
199
u8 GLBtcBtMpRptWiFiOK;
200
u8 GLBtcBtMpRptBTOK;
201
202
/*
203
* Debug
204
*/
205
u32 GLBtcDbgType[COMP_MAX];
206
u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE];
207
u8 gl_btc_trace_buf[BT_TMP_BUF_SIZE];
208
209
typedef struct _btcoexdbginfo {
210
u8 *info;
211
u32 size; /* buffer total size */
212
u32 len; /* now used length */
213
} BTCDBGINFO, *PBTCDBGINFO;
214
215
BTCDBGINFO GLBtcDbgInfo;
216
217
#define BT_Operation(Adapter) _FALSE
218
219
static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size)
220
{
221
if (NULL == pinfo)
222
return;
223
224
_rtw_memset(pinfo, 0, sizeof(BTCDBGINFO));
225
226
if (pbuf && size) {
227
pinfo->info = pbuf;
228
pinfo->size = size;
229
}
230
}
231
232
void DBG_BT_INFO(u8 *dbgmsg)
233
{
234
PBTCDBGINFO pinfo;
235
u32 msglen, buflen;
236
u8 *pbuf;
237
238
239
pinfo = &GLBtcDbgInfo;
240
241
if (NULL == pinfo->info)
242
return;
243
244
msglen = strlen(dbgmsg);
245
if (pinfo->len + msglen > pinfo->size)
246
return;
247
248
pbuf = pinfo->info + pinfo->len;
249
_rtw_memcpy(pbuf, dbgmsg, msglen);
250
pinfo->len += msglen;
251
}
252
253
/* ************************************
254
* Debug related function
255
* ************************************ */
256
static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist)
257
{
258
if (!pBtCoexist->bBinded ||
259
NULL == pBtCoexist->Adapter)
260
return _FALSE;
261
return _TRUE;
262
}
263
264
static void halbtcoutsrc_DbgInit(void)
265
{
266
u8 i;
267
268
for (i = 0; i < COMP_MAX; i++)
269
GLBtcDbgType[i] = 0;
270
}
271
272
static void halbtcoutsrc_EnterPwrLock(PBTC_COEXIST pBtCoexist)
273
{
274
struct dvobj_priv *dvobj = adapter_to_dvobj((PADAPTER)pBtCoexist->Adapter);
275
struct pwrctrl_priv *pwrpriv = dvobj_to_pwrctl(dvobj);
276
277
_enter_pwrlock(&pwrpriv->lock);
278
}
279
280
static void halbtcoutsrc_ExitPwrLock(PBTC_COEXIST pBtCoexist)
281
{
282
struct dvobj_priv *dvobj = adapter_to_dvobj((PADAPTER)pBtCoexist->Adapter);
283
struct pwrctrl_priv *pwrpriv = dvobj_to_pwrctl(dvobj);
284
285
_exit_pwrlock(&pwrpriv->lock);
286
}
287
288
static u8 halbtcoutsrc_IsHwMailboxExist(PBTC_COEXIST pBtCoexist)
289
{
290
if (pBtCoexist->board_info.bt_chip_type == BTC_CHIP_CSR_BC4
291
|| pBtCoexist->board_info.bt_chip_type == BTC_CHIP_CSR_BC8
292
)
293
return _FALSE;
294
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
295
return _FALSE;
296
else
297
return _TRUE;
298
}
299
300
static u8 halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist)
301
{
302
PADAPTER padapter;
303
304
305
padapter = pBtCoexist->Adapter;
306
307
pBtCoexist->bt_info.bt_ctrl_lps = _TRUE;
308
pBtCoexist->bt_info.bt_lps_on = _FALSE;
309
310
return rtw_btcoex_LPS_Leave(padapter);
311
}
312
313
void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist)
314
{
315
PADAPTER padapter;
316
317
318
padapter = pBtCoexist->Adapter;
319
320
if (pBtCoexist->bdontenterLPS == _FALSE) {
321
pBtCoexist->bt_info.bt_ctrl_lps = _TRUE;
322
pBtCoexist->bt_info.bt_lps_on = _TRUE;
323
324
rtw_btcoex_LPS_Enter(padapter);
325
}
326
}
327
328
void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist)
329
{
330
PADAPTER padapter;
331
332
333
334
padapter = pBtCoexist->Adapter;
335
336
if (pBtCoexist->bt_info.bt_ctrl_lps) {
337
pBtCoexist->bt_info.bt_lps_on = _FALSE;
338
rtw_btcoex_LPS_Leave(padapter);
339
pBtCoexist->bt_info.bt_ctrl_lps = _FALSE;
340
341
/* recover the LPS state to the original */
342
#if 0
343
padapter->hal_func.UpdateLPSStatusHandler(
344
padapter,
345
pPSC->RegLeisurePsMode,
346
pPSC->RegPowerSaveMode);
347
#endif
348
}
349
}
350
351
void halbtcoutsrc_Pre_NormalLps(PBTC_COEXIST pBtCoexist)
352
{
353
PADAPTER padapter;
354
355
padapter = pBtCoexist->Adapter;
356
357
if (pBtCoexist->bt_info.bt_ctrl_lps) {
358
pBtCoexist->bt_info.bt_lps_on = _FALSE;
359
rtw_btcoex_LPS_Leave(padapter);
360
}
361
}
362
363
void halbtcoutsrc_Post_NormalLps(PBTC_COEXIST pBtCoexist)
364
{
365
if (pBtCoexist->bt_info.bt_ctrl_lps)
366
pBtCoexist->bt_info.bt_ctrl_lps = _FALSE;
367
}
368
369
/*
370
* Constraint:
371
* 1. this function will request pwrctrl->lock
372
*/
373
void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist)
374
{
375
#ifdef CONFIG_LPS_LCLK
376
PADAPTER padapter;
377
PHAL_DATA_TYPE pHalData;
378
struct pwrctrl_priv *pwrctrl;
379
s32 ready;
380
systime stime;
381
s32 utime;
382
u32 timeout; /* unit: ms */
383
384
385
padapter = pBtCoexist->Adapter;
386
pHalData = GET_HAL_DATA(padapter);
387
pwrctrl = adapter_to_pwrctl(padapter);
388
ready = _FAIL;
389
#ifdef LPS_RPWM_WAIT_MS
390
timeout = LPS_RPWM_WAIT_MS;
391
#else /* !LPS_RPWM_WAIT_MS */
392
timeout = 30;
393
#endif /* !LPS_RPWM_WAIT_MS */
394
395
if (GLBtcBtCoexAliveRegistered == _TRUE)
396
return;
397
398
stime = rtw_get_current_time();
399
do {
400
ready = rtw_register_task_alive(padapter, BTCOEX_ALIVE);
401
if (_SUCCESS == ready)
402
break;
403
404
utime = rtw_get_passing_time_ms(stime);
405
if (utime > timeout)
406
break;
407
408
rtw_msleep_os(1);
409
} while (1);
410
411
GLBtcBtCoexAliveRegistered = _TRUE;
412
#endif /* CONFIG_LPS_LCLK */
413
}
414
415
/*
416
* Constraint:
417
* 1. this function will request pwrctrl->lock
418
*/
419
void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist)
420
{
421
#ifdef CONFIG_LPS_LCLK
422
PADAPTER padapter;
423
424
if (GLBtcBtCoexAliveRegistered == _FALSE)
425
return;
426
427
padapter = pBtCoexist->Adapter;
428
rtw_unregister_task_alive(padapter, BTCOEX_ALIVE);
429
430
GLBtcBtCoexAliveRegistered = _FALSE;
431
#endif /* CONFIG_LPS_LCLK */
432
}
433
434
void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisable)
435
{
436
pBtCoexist->bt_info.bt_disable_low_pwr = bLowPwrDisable;
437
if (bLowPwrDisable)
438
halbtcoutsrc_LeaveLowPower(pBtCoexist); /* leave 32k low power. */
439
else
440
halbtcoutsrc_NormalLowPower(pBtCoexist); /* original 32k low power behavior. */
441
}
442
443
void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist)
444
{
445
PADAPTER padapter;
446
BOOLEAN bNeedToAct = _FALSE;
447
static u32 preTime = 0;
448
u32 curTime = 0;
449
450
padapter = pBtCoexist->Adapter;
451
452
/* ===================================== */
453
/* To void continuous deleteBA=>addBA=>deleteBA=>addBA */
454
/* This function is not allowed to continuous called. */
455
/* It can only be called after 8 seconds. */
456
/* ===================================== */
457
458
curTime = rtw_systime_to_ms(rtw_get_current_time());
459
if ((curTime - preTime) < HALBTCOUTSRC_AGG_CHK_WINDOW_IN_MS) /* over 8 seconds you can execute this function again. */
460
return;
461
else
462
preTime = curTime;
463
464
if (pBtCoexist->bt_info.reject_agg_pkt) {
465
bNeedToAct = _TRUE;
466
pBtCoexist->bt_info.pre_reject_agg_pkt = pBtCoexist->bt_info.reject_agg_pkt;
467
} else {
468
if (pBtCoexist->bt_info.pre_reject_agg_pkt) {
469
bNeedToAct = _TRUE;
470
pBtCoexist->bt_info.pre_reject_agg_pkt = pBtCoexist->bt_info.reject_agg_pkt;
471
}
472
473
if (pBtCoexist->bt_info.pre_bt_ctrl_agg_buf_size !=
474
pBtCoexist->bt_info.bt_ctrl_agg_buf_size) {
475
bNeedToAct = _TRUE;
476
pBtCoexist->bt_info.pre_bt_ctrl_agg_buf_size = pBtCoexist->bt_info.bt_ctrl_agg_buf_size;
477
}
478
479
if (pBtCoexist->bt_info.bt_ctrl_agg_buf_size) {
480
if (pBtCoexist->bt_info.pre_agg_buf_size !=
481
pBtCoexist->bt_info.agg_buf_size)
482
bNeedToAct = _TRUE;
483
pBtCoexist->bt_info.pre_agg_buf_size = pBtCoexist->bt_info.agg_buf_size;
484
}
485
}
486
487
if (bNeedToAct)
488
rtw_btcoex_rx_ampdu_apply(padapter);
489
}
490
491
u8 halbtcoutsrc_is_autoload_fail(PBTC_COEXIST pBtCoexist)
492
{
493
PADAPTER padapter;
494
PHAL_DATA_TYPE pHalData;
495
496
padapter = pBtCoexist->Adapter;
497
pHalData = GET_HAL_DATA(padapter);
498
499
return pHalData->bautoload_fail_flag;
500
}
501
502
u8 halbtcoutsrc_is_fw_ready(PBTC_COEXIST pBtCoexist)
503
{
504
PADAPTER padapter;
505
506
padapter = pBtCoexist->Adapter;
507
508
return GET_HAL_DATA(padapter)->bFWReady;
509
}
510
511
u8 halbtcoutsrc_IsDualBandConnected(PADAPTER padapter)
512
{
513
u8 ret = BTC_MULTIPORT_SCC;
514
515
#ifdef CONFIG_MCC_MODE
516
if (MCC_EN(padapter) && (rtw_hal_check_mcc_status(padapter, MCC_STATUS_DOING_MCC))) {
517
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
518
struct mcc_obj_priv *mccobjpriv = &(dvobj->mcc_objpriv);
519
u8 band0 = mccobjpriv->iface[0]->mlmeextpriv.cur_channel > 14 ? BAND_ON_5G : BAND_ON_2_4G;
520
u8 band1 = mccobjpriv->iface[1]->mlmeextpriv.cur_channel > 14 ? BAND_ON_5G : BAND_ON_2_4G;
521
522
if (band0 != band1)
523
ret = BTC_MULTIPORT_MCC_DUAL_BAND;
524
else
525
ret = BTC_MULTIPORT_MCC_DUAL_CHANNEL;
526
}
527
#endif
528
529
return ret;
530
}
531
532
u8 halbtcoutsrc_IsWifiBusy(PADAPTER padapter)
533
{
534
if (rtw_mi_check_status(padapter, MI_AP_ASSOC))
535
return _TRUE;
536
if (rtw_mi_busy_traffic_check(padapter, _FALSE))
537
return _TRUE;
538
539
return _FALSE;
540
}
541
542
static u32 _halbtcoutsrc_GetWifiLinkStatus(PADAPTER padapter)
543
{
544
struct mlme_priv *pmlmepriv;
545
u8 bp2p;
546
u32 portConnectedStatus;
547
548
549
pmlmepriv = &padapter->mlmepriv;
550
bp2p = _FALSE;
551
portConnectedStatus = 0;
552
553
#ifdef CONFIG_P2P
554
if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE))
555
bp2p = _TRUE;
556
#endif /* CONFIG_P2P */
557
558
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE) {
559
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) {
560
if (_TRUE == bp2p)
561
portConnectedStatus |= WIFI_P2P_GO_CONNECTED;
562
else
563
portConnectedStatus |= WIFI_AP_CONNECTED;
564
} else {
565
if (_TRUE == bp2p)
566
portConnectedStatus |= WIFI_P2P_GC_CONNECTED;
567
else
568
portConnectedStatus |= WIFI_STA_CONNECTED;
569
}
570
}
571
572
return portConnectedStatus;
573
}
574
575
u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
576
{
577
/* ================================= */
578
/* return value: */
579
/* [31:16]=> connected port number */
580
/* [15:0]=> port connected bit define */
581
/* ================================ */
582
583
PADAPTER padapter;
584
u32 retVal;
585
u32 portConnectedStatus, numOfConnectedPort;
586
struct dvobj_priv *dvobj;
587
_adapter *iface;
588
int i;
589
590
padapter = pBtCoexist->Adapter;
591
retVal = 0;
592
portConnectedStatus = 0;
593
numOfConnectedPort = 0;
594
dvobj = adapter_to_dvobj(padapter);
595
596
for (i = 0; i < dvobj->iface_nums; i++) {
597
iface = dvobj->padapters[i];
598
if ((iface) && rtw_is_adapter_up(iface)) {
599
retVal = _halbtcoutsrc_GetWifiLinkStatus(iface);
600
if (retVal) {
601
portConnectedStatus |= retVal;
602
numOfConnectedPort++;
603
}
604
}
605
}
606
retVal = (numOfConnectedPort << 16) | portConnectedStatus;
607
608
return retVal;
609
}
610
611
struct btc_wifi_link_info halbtcoutsrc_getwifilinkinfo(PBTC_COEXIST pBtCoexist)
612
{
613
u8 n_assoc_iface = 0, i =0, mcc_en = _FALSE;
614
PADAPTER adapter = NULL;
615
PADAPTER iface = NULL;
616
PADAPTER sta_iface = NULL, p2p_iface = NULL, ap_iface = NULL;
617
BTC_LINK_MODE btc_link_moe = BTC_LINK_MAX;
618
struct dvobj_priv *dvobj = NULL;
619
struct mlme_ext_priv *mlmeext = NULL;
620
struct btc_wifi_link_info wifi_link_info;
621
622
adapter = (PADAPTER)pBtCoexist->Adapter;
623
dvobj = adapter_to_dvobj(adapter);
624
n_assoc_iface = rtw_mi_get_assoc_if_num(adapter);
625
626
/* init value */
627
wifi_link_info.link_mode = BTC_LINK_NONE;
628
wifi_link_info.sta_center_channel = 0;
629
wifi_link_info.p2p_center_channel = 0;
630
wifi_link_info.bany_client_join_go = _FALSE;
631
wifi_link_info.benable_noa = _FALSE;
632
wifi_link_info.bhotspot = _FALSE;
633
634
for (i = 0; i < dvobj->iface_nums; i++) {
635
iface = dvobj->padapters[i];
636
if (!iface)
637
continue;
638
639
mlmeext = &iface->mlmeextpriv;
640
if (MLME_IS_GO(iface)) {
641
wifi_link_info.link_mode = BTC_LINK_ONLY_GO;
642
wifi_link_info.p2p_center_channel =
643
rtw_get_center_ch(mlmeext->cur_channel, mlmeext->cur_bwmode, mlmeext->cur_ch_offset);
644
p2p_iface = iface;
645
if (rtw_linked_check(iface))
646
wifi_link_info.bany_client_join_go = _TRUE;
647
} else if (MLME_IS_GC(iface)) {
648
wifi_link_info.link_mode = BTC_LINK_ONLY_GC;
649
wifi_link_info.p2p_center_channel =
650
rtw_get_center_ch(mlmeext->cur_channel, mlmeext->cur_bwmode, mlmeext->cur_ch_offset);
651
p2p_iface = iface;
652
} else if (MLME_IS_AP(iface)) {
653
wifi_link_info.link_mode = BTC_LINK_ONLY_AP;
654
ap_iface = iface;
655
wifi_link_info.p2p_center_channel =
656
rtw_get_center_ch(mlmeext->cur_channel, mlmeext->cur_bwmode, mlmeext->cur_ch_offset);
657
} else if (MLME_IS_STA(iface) && rtw_linked_check(iface)) {
658
wifi_link_info.link_mode = BTC_LINK_ONLY_STA;
659
wifi_link_info.sta_center_channel =
660
rtw_get_center_ch(mlmeext->cur_channel, mlmeext->cur_bwmode, mlmeext->cur_ch_offset);
661
sta_iface = iface;
662
}
663
}
664
665
#ifdef CONFIG_MCC_MODE
666
if (MCC_EN(adapter)) {
667
if (rtw_hal_check_mcc_status(adapter, MCC_STATUS_DOING_MCC))
668
mcc_en = _TRUE;
669
}
670
#endif/* CONFIG_MCC_MODE */
671
672
if (n_assoc_iface == 0) {
673
wifi_link_info.link_mode = BTC_LINK_NONE;
674
} else if (n_assoc_iface == 1) {
675
/* by pass */
676
} else if (n_assoc_iface == 2) {
677
if (sta_iface && p2p_iface) {
678
u8 band_sta = sta_iface->mlmeextpriv.cur_channel > 14 ? BAND_ON_5G : BAND_ON_2_4G;
679
u8 band_p2p = p2p_iface->mlmeextpriv.cur_channel > 14 ? BAND_ON_5G : BAND_ON_2_4G;
680
if (band_sta == band_p2p) {
681
switch (band_sta) {
682
case BAND_ON_2_4G:
683
if (MLME_IS_GO(p2p_iface)) {
684
#ifdef CONFIG_MCC_MODE
685
wifi_link_info.link_mode =
686
mcc_en == _TRUE ? BTC_LINK_2G_MCC_GO_STA : BTC_LINK_2G_SCC_GO_STA;
687
#else /* !CONFIG_MCC_MODE */
688
wifi_link_info.link_mode = BTC_LINK_2G_SCC_GO_STA;
689
#endif /* CONFIG_MCC_MODE */
690
} else if (MLME_IS_GC(p2p_iface)) {
691
#ifdef CONFIG_MCC_MODE
692
wifi_link_info.link_mode =
693
mcc_en == _TRUE ? BTC_LINK_2G_MCC_GC_STA : BTC_LINK_2G_SCC_GC_STA;
694
#else /* !CONFIG_MCC_MODE */
695
wifi_link_info.link_mode = BTC_LINK_2G_SCC_GC_STA;
696
#endif /* CONFIG_MCC_MODE */
697
}
698
break;
699
case BAND_ON_5G:
700
if (MLME_IS_GO(p2p_iface)) {
701
#ifdef CONFIG_MCC_MODE
702
wifi_link_info.link_mode =
703
mcc_en == _TRUE ? BTC_LINK_5G_MCC_GO_STA : BTC_LINK_5G_SCC_GO_STA;
704
#else /* !CONFIG_MCC_MODE */
705
wifi_link_info.link_mode = BTC_LINK_5G_SCC_GO_STA;
706
#endif /* CONFIG_MCC_MODE */
707
} else if (MLME_IS_GC(p2p_iface)) {
708
#ifdef CONFIG_MCC_MODE
709
wifi_link_info.link_mode =
710
mcc_en == _TRUE ? BTC_LINK_5G_MCC_GC_STA : BTC_LINK_5G_SCC_GC_STA;
711
#else /* !CONFIG_MCC_MODE */
712
wifi_link_info.link_mode = BTC_LINK_5G_SCC_GC_STA;
713
#endif /* CONFIG_MCC_MODE */
714
}
715
break;
716
}
717
} else {
718
if (MLME_IS_GO(p2p_iface))
719
wifi_link_info.link_mode = BTC_LINK_25G_MCC_GO_STA;
720
else if (MLME_IS_GC(p2p_iface))
721
wifi_link_info.link_mode = BTC_LINK_25G_MCC_GC_STA;
722
}
723
}
724
} else {
725
if (pBtCoexist->board_info.btdm_ant_num == 1)
726
RTW_ERR("%s do not support n_assoc_iface > 2 (ant_num == 1)", __func__);
727
}
728
729
return wifi_link_info;
730
}
731
732
733
static void _btmpoper_timer_hdl(void *p)
734
{
735
if (GLBtcBtMpRptWait == _TRUE) {
736
GLBtcBtMpRptWait = _FALSE;
737
_rtw_up_sema(&GLBtcBtMpRptSema);
738
}
739
}
740
741
/*
742
* !IMPORTANT!
743
* Before call this function, caller should acquire "GLBtcBtMpOperLock"!
744
* Othrewise there will be racing problem and something may go wrong.
745
*/
746
static u8 _btmpoper_cmd(PBTC_COEXIST pBtCoexist, u8 opcode, u8 opcodever, u8 *cmd, u8 size)
747
{
748
PADAPTER padapter;
749
u8 buf[H2C_BTMP_OPER_LEN] = {0};
750
u8 buflen;
751
u8 seq;
752
s32 ret;
753
754
755
if (!cmd && size)
756
size = 0;
757
if ((size + 2) > H2C_BTMP_OPER_LEN)
758
return BT_STATUS_H2C_LENGTH_EXCEEDED;
759
buflen = size + 2;
760
761
seq = GLBtcBtMpOperSeq & 0xF;
762
GLBtcBtMpOperSeq++;
763
764
buf[0] = (opcodever & 0xF) | (seq << 4);
765
buf[1] = opcode;
766
if (cmd && size)
767
_rtw_memcpy(buf + 2, cmd, size);
768
769
GLBtcBtMpRptWait = _TRUE;
770
GLBtcBtMpRptWiFiOK = _FALSE;
771
GLBtcBtMpRptBTOK = _FALSE;
772
GLBtcBtMpRptStatus = 0;
773
padapter = pBtCoexist->Adapter;
774
_set_timer(&GLBtcBtMpOperTimer, BTC_MPOPER_TIMEOUT);
775
if (rtw_hal_fill_h2c_cmd(padapter, H2C_BT_MP_OPER, buflen, buf) == _FAIL) {
776
_cancel_timer_ex(&GLBtcBtMpOperTimer);
777
ret = BT_STATUS_H2C_FAIL;
778
goto exit;
779
}
780
781
_rtw_down_sema(&GLBtcBtMpRptSema);
782
/* GLBtcBtMpRptWait should be _FALSE here*/
783
784
if (GLBtcBtMpRptWiFiOK == _FALSE) {
785
RTW_ERR("%s: Didn't get H2C Rsp Event!\n", __FUNCTION__);
786
ret = BT_STATUS_H2C_TIMTOUT;
787
goto exit;
788
}
789
if (GLBtcBtMpRptBTOK == _FALSE) {
790
RTW_DBG("%s: Didn't get BT response!\n", __FUNCTION__);
791
ret = BT_STATUS_H2C_BT_NO_RSP;
792
goto exit;
793
}
794
795
if (seq != GLBtcBtMpRptSeq) {
796
RTW_ERR("%s: Sequence number not match!(%d!=%d)!\n",
797
__FUNCTION__, seq, GLBtcBtMpRptSeq);
798
ret = BT_STATUS_C2H_REQNUM_MISMATCH;
799
goto exit;
800
}
801
802
switch (GLBtcBtMpRptStatus) {
803
/* Examine the status reported from C2H */
804
case BT_STATUS_OK:
805
ret = BT_STATUS_BT_OP_SUCCESS;
806
RTW_DBG("%s: C2H status = BT_STATUS_BT_OP_SUCCESS\n", __FUNCTION__);
807
break;
808
case BT_STATUS_VERSION_MISMATCH:
809
ret = BT_STATUS_OPCODE_L_VERSION_MISMATCH;
810
RTW_DBG("%s: C2H status = BT_STATUS_OPCODE_L_VERSION_MISMATCH\n", __FUNCTION__);
811
break;
812
case BT_STATUS_UNKNOWN_OPCODE:
813
ret = BT_STATUS_UNKNOWN_OPCODE_L;
814
RTW_DBG("%s: C2H status = MP_BT_STATUS_UNKNOWN_OPCODE_L\n", __FUNCTION__);
815
break;
816
case BT_STATUS_ERROR_PARAMETER:
817
ret = BT_STATUS_PARAMETER_FORMAT_ERROR_L;
818
RTW_DBG("%s: C2H status = MP_BT_STATUS_PARAMETER_FORMAT_ERROR_L\n", __FUNCTION__);
819
break;
820
default:
821
ret = BT_STATUS_UNKNOWN_STATUS_L;
822
RTW_DBG("%s: C2H status = MP_BT_STATUS_UNKNOWN_STATUS_L\n", __FUNCTION__);
823
break;
824
}
825
826
exit:
827
return ret;
828
}
829
830
u32 halbtcoutsrc_GetBtPatchVer(PBTC_COEXIST pBtCoexist)
831
{
832
if (pBtCoexist->bt_info.get_bt_fw_ver_cnt <= 5) {
833
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
834
_irqL irqL;
835
u8 ret;
836
837
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
838
839
ret = _btmpoper_cmd(pBtCoexist, BT_OP_GET_BT_VERSION, 0, NULL, 0);
840
if (BT_STATUS_BT_OP_SUCCESS == ret) {
841
pBtCoexist->bt_info.bt_real_fw_ver = le32_to_cpu(*(u32 *)GLBtcBtMpRptRsp);
842
pBtCoexist->bt_info.get_bt_fw_ver_cnt++;
843
}
844
845
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
846
} else {
847
#ifdef CONFIG_BT_COEXIST_SOCKET_TRX
848
u8 dataLen = 2;
849
u8 buf[4] = {0};
850
851
buf[0] = 0x0; /* OP_Code */
852
buf[1] = 0x0; /* OP_Code_Length */
853
BT_SendEventExtBtCoexControl(pBtCoexist->Adapter, _FALSE, dataLen, &buf[0]);
854
#endif /* !CONFIG_BT_COEXIST_SOCKET_TRX */
855
}
856
}
857
858
return pBtCoexist->bt_info.bt_real_fw_ver;
859
}
860
861
s32 halbtcoutsrc_GetWifiRssi(PADAPTER padapter)
862
{
863
return rtw_dm_get_min_rssi(padapter);
864
}
865
866
u32 halbtcoutsrc_GetBtCoexSupportedFeature(void *pBtcContext)
867
{
868
PBTC_COEXIST pBtCoexist;
869
u32 ret = BT_STATUS_BT_OP_SUCCESS;
870
u32 data = 0;
871
872
pBtCoexist = (PBTC_COEXIST)pBtcContext;
873
874
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
875
u8 buf[3] = {0};
876
_irqL irqL;
877
u8 op_code;
878
u8 status;
879
880
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
881
882
op_code = BT_OP_GET_BT_COEX_SUPPORTED_FEATURE;
883
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
884
if (status == BT_STATUS_BT_OP_SUCCESS)
885
data = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp);
886
else
887
ret = SET_BT_MP_OPER_RET(op_code, status);
888
889
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
890
891
} else
892
ret = BT_STATUS_NOT_IMPLEMENT;
893
894
return data;
895
}
896
897
u32 halbtcoutsrc_GetBtCoexSupportedVersion(void *pBtcContext)
898
{
899
PBTC_COEXIST pBtCoexist;
900
u32 ret = BT_STATUS_BT_OP_SUCCESS;
901
u32 data = 0xFFFF;
902
903
pBtCoexist = (PBTC_COEXIST)pBtcContext;
904
905
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
906
u8 buf[3] = {0};
907
_irqL irqL;
908
u8 op_code;
909
u8 status;
910
911
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
912
913
op_code = BT_OP_GET_BT_COEX_SUPPORTED_VERSION;
914
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
915
if (status == BT_STATUS_BT_OP_SUCCESS)
916
data = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp);
917
else
918
ret = SET_BT_MP_OPER_RET(op_code, status);
919
920
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
921
922
} else
923
ret = BT_STATUS_NOT_IMPLEMENT;
924
925
return data;
926
}
927
928
u32 halbtcoutsrc_GetBtDeviceInfo(void *pBtcContext)
929
{
930
PBTC_COEXIST pBtCoexist;
931
u32 ret = BT_STATUS_BT_OP_SUCCESS;
932
u32 btDeviceInfo = 0;
933
934
pBtCoexist = (PBTC_COEXIST)pBtcContext;
935
936
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
937
u8 buf[3] = {0};
938
_irqL irqL;
939
u8 op_code;
940
u8 status;
941
942
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
943
944
op_code = BT_OP_GET_BT_DEVICE_INFO;
945
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
946
if (status == BT_STATUS_BT_OP_SUCCESS)
947
btDeviceInfo = le32_to_cpu(*(u32 *)GLBtcBtMpRptRsp);
948
else
949
ret = SET_BT_MP_OPER_RET(op_code, status);
950
951
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
952
953
} else
954
ret = BT_STATUS_NOT_IMPLEMENT;
955
956
return btDeviceInfo;
957
}
958
959
u32 halbtcoutsrc_GetBtForbiddenSlotVal(void *pBtcContext)
960
{
961
PBTC_COEXIST pBtCoexist;
962
u32 ret = BT_STATUS_BT_OP_SUCCESS;
963
u32 btForbiddenSlotVal = 0;
964
965
pBtCoexist = (PBTC_COEXIST)pBtcContext;
966
967
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
968
u8 buf[3] = {0};
969
_irqL irqL;
970
u8 op_code;
971
u8 status;
972
973
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
974
975
op_code = BT_OP_GET_BT_FORBIDDEN_SLOT_VAL;
976
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
977
if (status == BT_STATUS_BT_OP_SUCCESS)
978
btForbiddenSlotVal = le32_to_cpu(*(u32 *)GLBtcBtMpRptRsp);
979
else
980
ret = SET_BT_MP_OPER_RET(op_code, status);
981
982
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
983
984
} else
985
ret = BT_STATUS_NOT_IMPLEMENT;
986
987
return btForbiddenSlotVal;
988
}
989
990
static u8 halbtcoutsrc_GetWifiScanAPNum(PADAPTER padapter)
991
{
992
struct mlme_priv *pmlmepriv;
993
struct mlme_ext_priv *pmlmeext;
994
static u8 scan_AP_num = 0;
995
996
997
pmlmepriv = &padapter->mlmepriv;
998
pmlmeext = &padapter->mlmeextpriv;
999
1000
if (GLBtcWiFiInScanState == _FALSE) {
1001
if (pmlmepriv->num_of_scanned > 0xFF)
1002
scan_AP_num = 0xFF;
1003
else
1004
scan_AP_num = (u8)pmlmepriv->num_of_scanned;
1005
}
1006
1007
return scan_AP_num;
1008
}
1009
1010
u32 halbtcoutsrc_GetPhydmVersion(void *pBtcContext)
1011
{
1012
struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
1013
PADAPTER Adapter = pBtCoexist->Adapter;
1014
1015
#ifdef CONFIG_RTL8192E
1016
return RELEASE_VERSION_8192E;
1017
#endif
1018
1019
#ifdef CONFIG_RTL8821A
1020
return RELEASE_VERSION_8821A;
1021
#endif
1022
1023
#ifdef CONFIG_RTL8723B
1024
return RELEASE_VERSION_8723B;
1025
#endif
1026
1027
#ifdef CONFIG_RTL8812A
1028
return RELEASE_VERSION_8812A;
1029
#endif
1030
1031
#ifdef CONFIG_RTL8703B
1032
return RELEASE_VERSION_8703B;
1033
#endif
1034
1035
#ifdef CONFIG_RTL8822B
1036
return RELEASE_VERSION_8822B;
1037
#endif
1038
1039
#ifdef CONFIG_RTL8723D
1040
return RELEASE_VERSION_8723D;
1041
#endif
1042
1043
#ifdef CONFIG_RTL8821C
1044
return RELEASE_VERSION_8821C;
1045
#endif
1046
1047
#ifdef CONFIG_RTL8192F
1048
return RELEASE_VERSION_8192F;
1049
#endif
1050
1051
#ifdef CONFIG_RTL8822C
1052
return RELEASE_VERSION_8822C;
1053
#endif
1054
1055
#ifdef CONFIG_RTL8814A
1056
return RELEASE_VERSION_8814A;
1057
#endif
1058
1059
#ifdef CONFIG_RTL8814B
1060
return RELEASE_VERSION_8814B;
1061
#endif
1062
}
1063
1064
u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
1065
{
1066
PBTC_COEXIST pBtCoexist;
1067
PADAPTER padapter;
1068
PHAL_DATA_TYPE pHalData;
1069
struct mlme_ext_priv *mlmeext;
1070
struct btc_wifi_link_info *wifi_link_info;
1071
u8 bSoftApExist, bVwifiExist;
1072
u8 *pu8;
1073
s32 *pS4Tmp;
1074
u32 *pU4Tmp;
1075
u8 *pU1Tmp;
1076
u16 *pU2Tmp;
1077
u8 ret;
1078
1079
1080
pBtCoexist = (PBTC_COEXIST)pBtcContext;
1081
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1082
return _FALSE;
1083
1084
padapter = pBtCoexist->Adapter;
1085
pHalData = GET_HAL_DATA(padapter);
1086
mlmeext = &padapter->mlmeextpriv;
1087
bSoftApExist = _FALSE;
1088
bVwifiExist = _FALSE;
1089
pu8 = (u8 *)pOutBuf;
1090
pS4Tmp = (s32 *)pOutBuf;
1091
pU4Tmp = (u32 *)pOutBuf;
1092
pU1Tmp = (u8 *)pOutBuf;
1093
pU2Tmp = (u16*)pOutBuf;
1094
wifi_link_info = (struct btc_wifi_link_info *)pOutBuf;
1095
ret = _TRUE;
1096
1097
switch (getType) {
1098
case BTC_GET_BL_HS_OPERATION:
1099
*pu8 = _FALSE;
1100
ret = _FALSE;
1101
break;
1102
1103
case BTC_GET_BL_HS_CONNECTING:
1104
*pu8 = _FALSE;
1105
ret = _FALSE;
1106
break;
1107
1108
case BTC_GET_BL_WIFI_FW_READY:
1109
*pu8 = halbtcoutsrc_is_fw_ready(pBtCoexist);
1110
break;
1111
1112
case BTC_GET_BL_WIFI_CONNECTED:
1113
*pu8 = (rtw_mi_check_status(padapter, MI_LINKED)) ? _TRUE : _FALSE;
1114
break;
1115
1116
case BTC_GET_BL_WIFI_DUAL_BAND_CONNECTED:
1117
*pu8 = halbtcoutsrc_IsDualBandConnected(padapter);
1118
break;
1119
1120
case BTC_GET_BL_WIFI_BUSY:
1121
*pu8 = halbtcoutsrc_IsWifiBusy(padapter);
1122
break;
1123
1124
case BTC_GET_BL_WIFI_SCAN:
1125
#if 0
1126
*pu8 = (rtw_mi_check_fwstate(padapter, WIFI_SITE_MONITOR)) ? _TRUE : _FALSE;
1127
#else
1128
/* Use the value of the new variable GLBtcWiFiInScanState to judge whether WiFi is in scan state or not, since the originally used flag
1129
WIFI_SITE_MONITOR in fwstate may not be cleared in time */
1130
*pu8 = GLBtcWiFiInScanState;
1131
#endif
1132
break;
1133
1134
case BTC_GET_BL_WIFI_LINK:
1135
*pu8 = (rtw_mi_check_status(padapter, MI_STA_LINKING)) ? _TRUE : _FALSE;
1136
break;
1137
1138
case BTC_GET_BL_WIFI_ROAM:
1139
*pu8 = (rtw_mi_check_status(padapter, MI_STA_LINKING)) ? _TRUE : _FALSE;
1140
break;
1141
1142
case BTC_GET_BL_WIFI_4_WAY_PROGRESS:
1143
*pu8 = _FALSE;
1144
break;
1145
1146
case BTC_GET_BL_WIFI_UNDER_5G:
1147
*pu8 = (pHalData->current_band_type == BAND_ON_5G) ? _TRUE : _FALSE;
1148
break;
1149
1150
case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
1151
*pu8 = (rtw_mi_check_status(padapter, MI_AP_MODE)) ? _TRUE : _FALSE;
1152
break;
1153
1154
case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
1155
*pu8 = padapter->securitypriv.dot11PrivacyAlgrthm == 0 ? _FALSE : _TRUE;
1156
break;
1157
1158
case BTC_GET_BL_WIFI_UNDER_B_MODE:
1159
if (mlmeext->cur_wireless_mode == WIRELESS_11B)
1160
*pu8 = _TRUE;
1161
else
1162
*pu8 = _FALSE;
1163
break;
1164
1165
case BTC_GET_BL_WIFI_IS_IN_MP_MODE:
1166
if (padapter->registrypriv.mp_mode == 0)
1167
*pu8 = _FALSE;
1168
else
1169
*pu8 = _TRUE;
1170
break;
1171
1172
case BTC_GET_BL_EXT_SWITCH:
1173
*pu8 = _FALSE;
1174
break;
1175
case BTC_GET_BL_IS_ASUS_8723B:
1176
/* Always return FALSE in linux driver since this case is added only for windows driver */
1177
*pu8 = _FALSE;
1178
break;
1179
1180
case BTC_GET_BL_RF4CE_CONNECTED:
1181
#ifdef CONFIG_RF4CE_COEXIST
1182
if (hal_btcoex_get_rf4ce_link_state() == 0)
1183
*pu8 = FALSE;
1184
else
1185
*pu8 = TRUE;
1186
#else
1187
*pu8 = FALSE;
1188
#endif
1189
break;
1190
1191
case BTC_GET_BL_WIFI_LW_PWR_STATE:
1192
/* return false due to coex do not run during 32K */
1193
*pu8 = FALSE;
1194
break;
1195
1196
case BTC_GET_S4_WIFI_RSSI:
1197
*pS4Tmp = halbtcoutsrc_GetWifiRssi(padapter);
1198
break;
1199
1200
case BTC_GET_S4_HS_RSSI:
1201
*pS4Tmp = 0;
1202
ret = _FALSE;
1203
break;
1204
1205
case BTC_GET_U4_WIFI_BW:
1206
if (IsLegacyOnly(mlmeext->cur_wireless_mode))
1207
*pU4Tmp = BTC_WIFI_BW_LEGACY;
1208
else {
1209
switch (pHalData->current_channel_bw) {
1210
case CHANNEL_WIDTH_20:
1211
*pU4Tmp = BTC_WIFI_BW_HT20;
1212
break;
1213
case CHANNEL_WIDTH_40:
1214
*pU4Tmp = BTC_WIFI_BW_HT40;
1215
break;
1216
case CHANNEL_WIDTH_80:
1217
*pU4Tmp = BTC_WIFI_BW_HT80;
1218
break;
1219
case CHANNEL_WIDTH_160:
1220
*pU4Tmp = BTC_WIFI_BW_HT160;
1221
break;
1222
default:
1223
RTW_INFO("[BTCOEX] unknown bandwidth(%d)\n", pHalData->current_channel_bw);
1224
*pU4Tmp = BTC_WIFI_BW_HT40;
1225
break;
1226
}
1227
1228
}
1229
break;
1230
1231
case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
1232
case BTC_GET_U4_WIFI_TRAFFIC_DIR:
1233
{
1234
PRT_LINK_DETECT_T plinkinfo;
1235
plinkinfo = &padapter->mlmepriv.LinkDetectInfo;
1236
1237
if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod)
1238
*pU4Tmp = BTC_WIFI_TRAFFIC_TX;
1239
else
1240
*pU4Tmp = BTC_WIFI_TRAFFIC_RX;
1241
}
1242
break;
1243
1244
case BTC_GET_U4_WIFI_FW_VER:
1245
*pU4Tmp = pHalData->firmware_version << 16;
1246
*pU4Tmp |= pHalData->firmware_sub_version;
1247
break;
1248
1249
case BTC_GET_U4_WIFI_PHY_VER:
1250
*pU4Tmp = halbtcoutsrc_GetPhydmVersion(pBtCoexist);
1251
break;
1252
1253
case BTC_GET_U4_WIFI_LINK_STATUS:
1254
*pU4Tmp = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist);
1255
break;
1256
case BTC_GET_BL_WIFI_LINK_INFO:
1257
*wifi_link_info = halbtcoutsrc_getwifilinkinfo(pBtCoexist);
1258
break;
1259
case BTC_GET_U4_BT_PATCH_VER:
1260
*pU4Tmp = halbtcoutsrc_GetBtPatchVer(pBtCoexist);
1261
break;
1262
1263
case BTC_GET_U4_VENDOR:
1264
*pU4Tmp = BTC_VENDOR_OTHER;
1265
break;
1266
1267
case BTC_GET_U4_SUPPORTED_VERSION:
1268
*pU4Tmp = halbtcoutsrc_GetBtCoexSupportedVersion(pBtCoexist);
1269
break;
1270
case BTC_GET_U4_SUPPORTED_FEATURE:
1271
*pU4Tmp = halbtcoutsrc_GetBtCoexSupportedFeature(pBtCoexist);
1272
break;
1273
1274
case BTC_GET_U4_BT_DEVICE_INFO:
1275
*pU4Tmp = halbtcoutsrc_GetBtDeviceInfo(pBtCoexist);
1276
break;
1277
1278
case BTC_GET_U4_BT_FORBIDDEN_SLOT_VAL:
1279
*pU4Tmp = halbtcoutsrc_GetBtForbiddenSlotVal(pBtCoexist);
1280
break;
1281
1282
case BTC_GET_U4_WIFI_IQK_TOTAL:
1283
*pU4Tmp = pHalData->odmpriv.n_iqk_cnt;
1284
break;
1285
1286
case BTC_GET_U4_WIFI_IQK_OK:
1287
*pU4Tmp = pHalData->odmpriv.n_iqk_ok_cnt;
1288
break;
1289
1290
case BTC_GET_U4_WIFI_IQK_FAIL:
1291
*pU4Tmp = pHalData->odmpriv.n_iqk_fail_cnt;
1292
break;
1293
1294
case BTC_GET_U1_WIFI_DOT11_CHNL:
1295
*pU1Tmp = padapter->mlmeextpriv.cur_channel;
1296
break;
1297
1298
case BTC_GET_U1_WIFI_CENTRAL_CHNL:
1299
*pU1Tmp = pHalData->current_channel;
1300
break;
1301
1302
case BTC_GET_U1_WIFI_HS_CHNL:
1303
*pU1Tmp = 0;
1304
ret = _FALSE;
1305
break;
1306
1307
case BTC_GET_U1_WIFI_P2P_CHNL:
1308
#ifdef CONFIG_P2P
1309
{
1310
struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
1311
1312
*pU1Tmp = pwdinfo->operating_channel;
1313
}
1314
#else
1315
*pU1Tmp = 0;
1316
#endif
1317
break;
1318
1319
case BTC_GET_U1_MAC_PHY_MODE:
1320
/* *pU1Tmp = BTC_SMSP;
1321
* *pU1Tmp = BTC_DMSP;
1322
* *pU1Tmp = BTC_DMDP;
1323
* *pU1Tmp = BTC_MP_UNKNOWN; */
1324
break;
1325
1326
case BTC_GET_U1_AP_NUM:
1327
*pU1Tmp = halbtcoutsrc_GetWifiScanAPNum(padapter);
1328
break;
1329
case BTC_GET_U1_ANT_TYPE:
1330
switch (pHalData->bt_coexist.btAntisolation) {
1331
case 0:
1332
*pU1Tmp = (u8)BTC_ANT_TYPE_0;
1333
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_0;
1334
break;
1335
case 1:
1336
*pU1Tmp = (u8)BTC_ANT_TYPE_1;
1337
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_1;
1338
break;
1339
case 2:
1340
*pU1Tmp = (u8)BTC_ANT_TYPE_2;
1341
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_2;
1342
break;
1343
case 3:
1344
*pU1Tmp = (u8)BTC_ANT_TYPE_3;
1345
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_3;
1346
break;
1347
case 4:
1348
*pU1Tmp = (u8)BTC_ANT_TYPE_4;
1349
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_4;
1350
break;
1351
}
1352
break;
1353
case BTC_GET_U1_IOT_PEER:
1354
*pU1Tmp = mlmeext->mlmext_info.assoc_AP_vendor;
1355
break;
1356
1357
/* =======1Ant=========== */
1358
case BTC_GET_U1_LPS_MODE:
1359
*pU1Tmp = padapter->dvobj->pwrctl_priv.pwr_mode;
1360
break;
1361
1362
case BTC_GET_U2_BEACON_PERIOD:
1363
*pU2Tmp = mlmeext->mlmext_info.bcn_interval;
1364
break;
1365
1366
default:
1367
ret = _FALSE;
1368
break;
1369
}
1370
1371
return ret;
1372
}
1373
1374
u16 halbtcoutsrc_LnaConstrainLvl(void *pBtcContext, u8 *lna_constrain_level)
1375
{
1376
PBTC_COEXIST pBtCoexist;
1377
u16 ret = BT_STATUS_BT_OP_SUCCESS;
1378
1379
pBtCoexist = (PBTC_COEXIST)pBtcContext;
1380
1381
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
1382
_irqL irqL;
1383
u8 op_code;
1384
1385
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
1386
1387
ret = _btmpoper_cmd(pBtCoexist, BT_OP_SET_BT_LANCONSTRAIN_LEVEL, 0, lna_constrain_level, 1);
1388
1389
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
1390
} else {
1391
ret = BT_STATUS_NOT_IMPLEMENT;
1392
RTW_INFO("%s halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == FALSE\n", __func__);
1393
}
1394
1395
return ret;
1396
}
1397
1398
u8 halbtcoutsrc_SetBtGoldenRxRange(void *pBtcContext, u8 profile, u8 range_shift)
1399
{
1400
/* wait for implementation if necessary */
1401
1402
return 0;
1403
}
1404
1405
u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
1406
{
1407
PBTC_COEXIST pBtCoexist;
1408
PADAPTER padapter;
1409
PHAL_DATA_TYPE pHalData;
1410
u8 *pu8;
1411
u8 *pU1Tmp;
1412
u16 *pU2Tmp;
1413
u32 *pU4Tmp;
1414
u8 ret;
1415
u8 result = _TRUE;
1416
1417
1418
pBtCoexist = (PBTC_COEXIST)pBtcContext;
1419
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1420
return _FALSE;
1421
1422
padapter = pBtCoexist->Adapter;
1423
pHalData = GET_HAL_DATA(padapter);
1424
pu8 = (u8 *)pInBuf;
1425
pU1Tmp = (u8 *)pInBuf;
1426
pU2Tmp = (u16*)pInBuf;
1427
pU4Tmp = (u32 *)pInBuf;
1428
ret = _TRUE;
1429
1430
switch (setType) {
1431
/* set some u8 type variables. */
1432
case BTC_SET_BL_BT_DISABLE:
1433
pBtCoexist->bt_info.bt_disabled = *pu8;
1434
break;
1435
1436
case BTC_SET_BL_BT_ENABLE_DISABLE_CHANGE:
1437
pBtCoexist->bt_info.bt_enable_disable_change = *pu8;
1438
break;
1439
1440
case BTC_SET_BL_BT_TRAFFIC_BUSY:
1441
pBtCoexist->bt_info.bt_busy = *pu8;
1442
break;
1443
1444
case BTC_SET_BL_BT_LIMITED_DIG:
1445
pBtCoexist->bt_info.limited_dig = *pu8;
1446
break;
1447
1448
case BTC_SET_BL_FORCE_TO_ROAM:
1449
pBtCoexist->bt_info.force_to_roam = *pu8;
1450
break;
1451
1452
case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
1453
pBtCoexist->bt_info.reject_agg_pkt = *pu8;
1454
break;
1455
1456
case BTC_SET_BL_BT_CTRL_AGG_SIZE:
1457
pBtCoexist->bt_info.bt_ctrl_agg_buf_size = *pu8;
1458
break;
1459
1460
case BTC_SET_BL_INC_SCAN_DEV_NUM:
1461
pBtCoexist->bt_info.increase_scan_dev_num = *pu8;
1462
break;
1463
1464
case BTC_SET_BL_BT_TX_RX_MASK:
1465
pBtCoexist->bt_info.bt_tx_rx_mask = *pu8;
1466
break;
1467
1468
case BTC_SET_BL_MIRACAST_PLUS_BT:
1469
pBtCoexist->bt_info.miracast_plus_bt = *pu8;
1470
break;
1471
1472
/* set some u8 type variables. */
1473
case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
1474
pBtCoexist->bt_info.rssi_adjust_for_agc_table_on = *pU1Tmp;
1475
break;
1476
1477
case BTC_SET_U1_AGG_BUF_SIZE:
1478
pBtCoexist->bt_info.agg_buf_size = *pU1Tmp;
1479
break;
1480
1481
/* the following are some action which will be triggered */
1482
case BTC_SET_ACT_GET_BT_RSSI:
1483
#if 0
1484
BT_SendGetBtRssiEvent(padapter);
1485
#else
1486
ret = _FALSE;
1487
#endif
1488
break;
1489
1490
case BTC_SET_ACT_AGGREGATE_CTRL:
1491
halbtcoutsrc_AggregationCheck(pBtCoexist);
1492
break;
1493
1494
/* =======1Ant=========== */
1495
/* set some u8 type variables. */
1496
case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
1497
pBtCoexist->bt_info.rssi_adjust_for_1ant_coex_type = *pU1Tmp;
1498
break;
1499
1500
case BTC_SET_U1_LPS_VAL:
1501
pBtCoexist->bt_info.lps_val = *pU1Tmp;
1502
break;
1503
1504
case BTC_SET_U1_RPWM_VAL:
1505
pBtCoexist->bt_info.rpwm_val = *pU1Tmp;
1506
break;
1507
1508
/* the following are some action which will be triggered */
1509
case BTC_SET_ACT_LEAVE_LPS:
1510
result = halbtcoutsrc_LeaveLps(pBtCoexist);
1511
break;
1512
1513
case BTC_SET_ACT_ENTER_LPS:
1514
halbtcoutsrc_EnterLps(pBtCoexist);
1515
break;
1516
1517
case BTC_SET_ACT_NORMAL_LPS:
1518
halbtcoutsrc_NormalLps(pBtCoexist);
1519
break;
1520
1521
case BTC_SET_ACT_PRE_NORMAL_LPS:
1522
halbtcoutsrc_Pre_NormalLps(pBtCoexist);
1523
break;
1524
1525
case BTC_SET_ACT_POST_NORMAL_LPS:
1526
halbtcoutsrc_Post_NormalLps(pBtCoexist);
1527
break;
1528
1529
case BTC_SET_ACT_DISABLE_LOW_POWER:
1530
halbtcoutsrc_DisableLowPower(pBtCoexist, *pu8);
1531
break;
1532
1533
case BTC_SET_ACT_UPDATE_RAMASK:
1534
/*
1535
pBtCoexist->bt_info.ra_mask = *pU4Tmp;
1536
1537
if (check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE) == _TRUE) {
1538
struct sta_info *psta;
1539
PWLAN_BSSID_EX cur_network;
1540
1541
cur_network = &padapter->mlmeextpriv.mlmext_info.network;
1542
psta = rtw_get_stainfo(&padapter->stapriv, cur_network->MacAddress);
1543
rtw_hal_update_ra_mask(psta);
1544
}
1545
*/
1546
break;
1547
1548
case BTC_SET_ACT_SEND_MIMO_PS: {
1549
u8 newMimoPsMode = 3;
1550
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
1551
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1552
1553
/* *pU1Tmp = 0 use SM_PS static type */
1554
/* *pU1Tmp = 1 disable SM_PS */
1555
if (*pU1Tmp == 0)
1556
newMimoPsMode = WLAN_HT_CAP_SM_PS_STATIC;
1557
else if (*pU1Tmp == 1)
1558
newMimoPsMode = WLAN_HT_CAP_SM_PS_DISABLED;
1559
1560
if (check_fwstate(&padapter->mlmepriv , WIFI_ASOC_STATE) == _TRUE) {
1561
/* issue_action_SM_PS(padapter, get_my_bssid(&(pmlmeinfo->network)), newMimoPsMode); */
1562
issue_action_SM_PS_wait_ack(padapter , get_my_bssid(&(pmlmeinfo->network)) , newMimoPsMode, 3 , 1);
1563
}
1564
}
1565
break;
1566
1567
case BTC_SET_ACT_CTRL_BT_INFO:
1568
#ifdef CONFIG_BT_COEXIST_SOCKET_TRX
1569
{
1570
u8 dataLen = *pU1Tmp;
1571
u8 tmpBuf[BTC_TMP_BUF_SHORT];
1572
if (dataLen)
1573
_rtw_memcpy(tmpBuf, pU1Tmp + 1, dataLen);
1574
BT_SendEventExtBtInfoControl(padapter, dataLen, &tmpBuf[0]);
1575
}
1576
#else /* !CONFIG_BT_COEXIST_SOCKET_TRX */
1577
ret = _FALSE;
1578
#endif /* CONFIG_BT_COEXIST_SOCKET_TRX */
1579
break;
1580
1581
case BTC_SET_ACT_CTRL_BT_COEX:
1582
#ifdef CONFIG_BT_COEXIST_SOCKET_TRX
1583
{
1584
u8 dataLen = *pU1Tmp;
1585
u8 tmpBuf[BTC_TMP_BUF_SHORT];
1586
if (dataLen)
1587
_rtw_memcpy(tmpBuf, pU1Tmp + 1, dataLen);
1588
BT_SendEventExtBtCoexControl(padapter, _FALSE, dataLen, &tmpBuf[0]);
1589
}
1590
#else /* !CONFIG_BT_COEXIST_SOCKET_TRX */
1591
ret = _FALSE;
1592
#endif /* CONFIG_BT_COEXIST_SOCKET_TRX */
1593
break;
1594
case BTC_SET_ACT_CTRL_8723B_ANT:
1595
#if 0
1596
{
1597
u8 dataLen = *pU1Tmp;
1598
u8 tmpBuf[BTC_TMP_BUF_SHORT];
1599
if (dataLen)
1600
PlatformMoveMemory(&tmpBuf[0], pU1Tmp + 1, dataLen);
1601
BT_Set8723bAnt(Adapter, dataLen, &tmpBuf[0]);
1602
}
1603
#else
1604
ret = _FALSE;
1605
#endif
1606
break;
1607
case BTC_SET_BL_BT_LNA_CONSTRAIN_LEVEL:
1608
halbtcoutsrc_LnaConstrainLvl(pBtCoexist, pu8);
1609
break;
1610
case BTC_SET_BL_BT_GOLDEN_RX_RANGE:
1611
halbtcoutsrc_SetBtGoldenRxRange(pBtCoexist, (*pU2Tmp & 0xff00) >> 8, (*pU2Tmp & 0xff));
1612
break;
1613
case BTC_SET_RESET_COEX_VAR:
1614
_rtw_memset(&pBtCoexist->coex_dm, 0x00, sizeof(pBtCoexist->coex_dm));
1615
_rtw_memset(&pBtCoexist->coex_sta, 0x00, sizeof(pBtCoexist->coex_sta));
1616
1617
switch(pBtCoexist->chip_type) {
1618
#ifdef CONFIG_RTL8822B
1619
case BTC_CHIP_RTL8822B:
1620
_rtw_memset(&pBtCoexist->coex_dm_8822b_1ant, 0x00, sizeof(pBtCoexist->coex_dm_8822b_1ant));
1621
_rtw_memset(&pBtCoexist->coex_dm_8822b_2ant, 0x00, sizeof(pBtCoexist->coex_dm_8822b_2ant));
1622
break;
1623
#endif
1624
#ifdef CONFIG_RTL8821C
1625
case BTC_CHIP_RTL8821C:
1626
_rtw_memset(&pBtCoexist->coex_dm_8821c_1ant, 0x00, sizeof(pBtCoexist->coex_dm_8821c_1ant));
1627
_rtw_memset(&pBtCoexist->coex_dm_8821c_2ant, 0x00, sizeof(pBtCoexist->coex_dm_8821c_2ant));
1628
break;
1629
#endif
1630
#ifdef CONFIG_RTL8723D
1631
case BTC_CHIP_RTL8723D:
1632
_rtw_memset(&pBtCoexist->coex_dm_8723d_1ant, 0x00, sizeof(pBtCoexist->coex_dm_8723d_1ant));
1633
_rtw_memset(&pBtCoexist->coex_dm_8723d_2ant, 0x00, sizeof(pBtCoexist->coex_dm_8723d_2ant));
1634
break;
1635
#endif
1636
}
1637
break;
1638
/* ===================== */
1639
default:
1640
ret = _FALSE;
1641
break;
1642
}
1643
1644
return result;
1645
}
1646
1647
u8 halbtcoutsrc_UnderIps(PBTC_COEXIST pBtCoexist)
1648
{
1649
PADAPTER padapter;
1650
struct pwrctrl_priv *pwrpriv;
1651
u8 bMacPwrCtrlOn;
1652
1653
padapter = pBtCoexist->Adapter;
1654
pwrpriv = &padapter->dvobj->pwrctl_priv;
1655
bMacPwrCtrlOn = _FALSE;
1656
1657
if ((_TRUE == pwrpriv->bips_processing)
1658
&& (IPS_NONE != pwrpriv->ips_mode_req)
1659
)
1660
return _TRUE;
1661
1662
if (rf_off == pwrpriv->rf_pwrstate)
1663
return _TRUE;
1664
1665
rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn);
1666
if (_FALSE == bMacPwrCtrlOn)
1667
return _TRUE;
1668
1669
return _FALSE;
1670
}
1671
1672
u8 halbtcoutsrc_UnderLps(PBTC_COEXIST pBtCoexist)
1673
{
1674
return GLBtcWiFiInLPS;
1675
}
1676
1677
u8 halbtcoutsrc_Under32K(PBTC_COEXIST pBtCoexist)
1678
{
1679
/* todo: the method to check whether wifi is under 32K or not */
1680
return _FALSE;
1681
}
1682
1683
void halbtcoutsrc_DisplayCoexStatistics(PBTC_COEXIST pBtCoexist)
1684
{
1685
#if 0
1686
PADAPTER padapter = (PADAPTER)pBtCoexist->Adapter;
1687
PBT_MGNT pBtMgnt = &padapter->MgntInfo.BtInfo.BtMgnt;
1688
PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter);
1689
u8 *cliBuf = pBtCoexist->cliBuf;
1690
u8 i, j;
1691
u8 tmpbuf[BTC_TMP_BUF_SHORT];
1692
1693
1694
if (gl_coex_offload.cnt_h2c_sent) {
1695
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Coex h2c notify]============");
1696
CL_PRINTF(cliBuf);
1697
1698
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = H2c(%d)/Ack(%d)", "Coex h2c/c2h overall statistics",
1699
gl_coex_offload.cnt_h2c_sent, gl_coex_offload.cnt_c2h_ack);
1700
for (j = 0; j < COL_STATUS_MAX; j++) {
1701
if (gl_coex_offload.status[j]) {
1702
CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, ", %s:%d", coexH2cResultString[j], gl_coex_offload.status[j]);
1703
CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, BTC_TMP_BUF_SHORT);
1704
}
1705
}
1706
CL_PRINTF(cliBuf);
1707
}
1708
for (i = 0; i < COL_OP_WIFI_OPCODE_MAX; i++) {
1709
if (gl_coex_offload.h2c_record[i].count) {
1710
/*==========================================*/
1711
/* H2C result statistics*/
1712
/*==========================================*/
1713
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = total:%d", coexOpcodeString[i], gl_coex_offload.h2c_record[i].count);
1714
for (j = 0; j < COL_STATUS_MAX; j++) {
1715
if (gl_coex_offload.h2c_record[i].status[j]) {
1716
CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, ", %s:%d", coexH2cResultString[j], gl_coex_offload.h2c_record[i].status[j]);
1717
CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, BTC_TMP_BUF_SHORT);
1718
}
1719
}
1720
CL_PRINTF(cliBuf);
1721
/*==========================================*/
1722
/* H2C/C2H content*/
1723
/*==========================================*/
1724
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = ", "H2C / C2H content");
1725
for (j = 0; j < gl_coex_offload.h2c_record[i].h2c_len; j++) {
1726
CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, "%02x ", gl_coex_offload.h2c_record[i].h2c_buf[j]);
1727
CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, 3);
1728
}
1729
if (gl_coex_offload.h2c_record[i].c2h_ack_len) {
1730
CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, "/ ", 2);
1731
for (j = 0; j < gl_coex_offload.h2c_record[i].c2h_ack_len; j++) {
1732
CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, "%02x ", gl_coex_offload.h2c_record[i].c2h_ack_buf[j]);
1733
CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, 3);
1734
}
1735
}
1736
CL_PRINTF(cliBuf);
1737
/*==========================================*/
1738
}
1739
}
1740
1741
if (gl_coex_offload.cnt_c2h_ind) {
1742
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Coex c2h indication]============");
1743
CL_PRINTF(cliBuf);
1744
1745
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = Ind(%d)", "C2H indication statistics",
1746
gl_coex_offload.cnt_c2h_ind);
1747
for (j = 0; j < COL_STATUS_MAX; j++) {
1748
if (gl_coex_offload.c2h_ind_status[j]) {
1749
CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, ", %s:%d", coexH2cResultString[j], gl_coex_offload.c2h_ind_status[j]);
1750
CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, BTC_TMP_BUF_SHORT);
1751
}
1752
}
1753
CL_PRINTF(cliBuf);
1754
}
1755
for (i = 0; i < COL_IND_MAX; i++) {
1756
if (gl_coex_offload.c2h_ind_record[i].count) {
1757
/*==========================================*/
1758
/* H2C result statistics*/
1759
/*==========================================*/
1760
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = total:%d", coexIndTypeString[i], gl_coex_offload.c2h_ind_record[i].count);
1761
for (j = 0; j < COL_STATUS_MAX; j++) {
1762
if (gl_coex_offload.c2h_ind_record[i].status[j]) {
1763
CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, ", %s:%d", coexH2cResultString[j], gl_coex_offload.c2h_ind_record[i].status[j]);
1764
CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, BTC_TMP_BUF_SHORT);
1765
}
1766
}
1767
CL_PRINTF(cliBuf);
1768
/*==========================================*/
1769
/* content*/
1770
/*==========================================*/
1771
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = ", "C2H indication content");
1772
for (j = 0; j < gl_coex_offload.c2h_ind_record[i].ind_len; j++) {
1773
CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, "%02x ", gl_coex_offload.c2h_ind_record[i].ind_buf[j]);
1774
CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, 3);
1775
}
1776
CL_PRINTF(cliBuf);
1777
/*==========================================*/
1778
}
1779
}
1780
1781
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Statistics]============");
1782
CL_PRINTF(cliBuf);
1783
1784
#if (H2C_USE_IO_THREAD != 1)
1785
for (i = 0; i < H2C_STATUS_MAX; i++) {
1786
if (pHalData->h2cStatistics[i]) {
1787
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s] = %d", "H2C statistics", \
1788
h2cStaString[i], pHalData->h2cStatistics[i]);
1789
CL_PRINTF(cliBuf);
1790
}
1791
}
1792
#else
1793
for (i = 0; i < IO_STATUS_MAX; i++) {
1794
if (Adapter->ioComStr.ioH2cStatistics[i]) {
1795
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s] = %d", "H2C statistics", \
1796
ioStaString[i], Adapter->ioComStr.ioH2cStatistics[i]);
1797
CL_PRINTF(cliBuf);
1798
}
1799
}
1800
#endif
1801
#if 0
1802
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "lastHMEBoxNum", \
1803
pHalData->LastHMEBoxNum);
1804
CL_PRINTF(cliBuf);
1805
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x / 0x%x", "LastOkH2c/FirstFailH2c(fwNotRead)", \
1806
pHalData->lastSuccessH2cEid, pHalData->firstFailedH2cEid);
1807
CL_PRINTF(cliBuf);
1808
1809
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "c2hIsr/c2hIntr/clr1AF/noRdy/noBuf", \
1810
pHalData->InterruptLog.nIMR_C2HCMD, DBG_Var.c2hInterruptCnt, DBG_Var.c2hClrReadC2hCnt,
1811
DBG_Var.c2hNotReadyCnt, DBG_Var.c2hBufAlloFailCnt);
1812
CL_PRINTF(cliBuf);
1813
1814
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "c2hPacket", \
1815
DBG_Var.c2hPacketCnt);
1816
CL_PRINTF(cliBuf);
1817
#endif
1818
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Periodical/ DbgCtrl", \
1819
pBtCoexist->statistics.cntPeriodical, pBtCoexist->statistics.cntDbgCtrl);
1820
CL_PRINTF(cliBuf);
1821
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "PowerOn/InitHw/InitCoexDm/RfStatus", \
1822
pBtCoexist->statistics.cntPowerOn, pBtCoexist->statistics.cntInitHwConfig, pBtCoexist->statistics.cntInitCoexDm,
1823
pBtCoexist->statistics.cntRfStatusNotify);
1824
CL_PRINTF(cliBuf);
1825
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "Ips/Lps/Scan/Connect/Mstatus", \
1826
pBtCoexist->statistics.cntIpsNotify, pBtCoexist->statistics.cntLpsNotify,
1827
pBtCoexist->statistics.cntScanNotify, pBtCoexist->statistics.cntConnectNotify,
1828
pBtCoexist->statistics.cntMediaStatusNotify);
1829
CL_PRINTF(cliBuf);
1830
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Special pkt/Bt info/ bind",
1831
pBtCoexist->statistics.cntSpecialPacketNotify, pBtCoexist->statistics.cntBtInfoNotify,
1832
pBtCoexist->statistics.cntBind);
1833
CL_PRINTF(cliBuf);
1834
#endif
1835
PADAPTER padapter = pBtCoexist->Adapter;
1836
PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter);
1837
u8 *cliBuf = pBtCoexist->cli_buf;
1838
1839
if (pHalData->EEPROMBluetoothCoexist == 1) {
1840
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Coex Status]============");
1841
CL_PRINTF(cliBuf);
1842
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IsBtDisabled", rtw_btcoex_IsBtDisabled(padapter));
1843
CL_PRINTF(cliBuf);
1844
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IsBtControlLps", rtw_btcoex_IsBtControlLps(padapter));
1845
CL_PRINTF(cliBuf);
1846
}
1847
}
1848
1849
void halbtcoutsrc_DisplayBtLinkInfo(PBTC_COEXIST pBtCoexist)
1850
{
1851
#if 0
1852
PADAPTER padapter = (PADAPTER)pBtCoexist->Adapter;
1853
PBT_MGNT pBtMgnt = &padapter->MgntInfo.BtInfo.BtMgnt;
1854
u8 *cliBuf = pBtCoexist->cliBuf;
1855
u8 i;
1856
1857
1858
if (pBtCoexist->stack_info.profile_notified) {
1859
for (i = 0; i < pBtMgnt->ExtConfig.NumberOfACL; i++) {
1860
if (pBtMgnt->ExtConfig.HCIExtensionVer >= 1) {
1861
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s", "Bt link type/spec/role", \
1862
BtProfileString[pBtMgnt->ExtConfig.aclLink[i].BTProfile],
1863
BtSpecString[pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec],
1864
BtLinkRoleString[pBtMgnt->ExtConfig.aclLink[i].linkRole]);
1865
CL_PRINTF(cliBuf);
1866
} else {
1867
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s", "Bt link type/spec", \
1868
BtProfileString[pBtMgnt->ExtConfig.aclLink[i].BTProfile],
1869
BtSpecString[pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec]);
1870
CL_PRINTF(cliBuf);
1871
}
1872
}
1873
}
1874
#endif
1875
}
1876
1877
void halbtcoutsrc_DisplayWifiStatus(PBTC_COEXIST pBtCoexist)
1878
{
1879
PADAPTER padapter = pBtCoexist->Adapter;
1880
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
1881
u8 *cliBuf = pBtCoexist->cli_buf;
1882
s32 wifiRssi = 0, btHsRssi = 0;
1883
BOOLEAN bScan = _FALSE, bLink = _FALSE, bRoam = _FALSE, bWifiBusy = _FALSE, bWifiUnderBMode = _FALSE;
1884
u32 wifiBw = BTC_WIFI_BW_HT20, wifiTrafficDir = BTC_WIFI_TRAFFIC_TX, wifiFreq = BTC_FREQ_2_4G;
1885
u32 wifiLinkStatus = 0x0;
1886
BOOLEAN bBtHsOn = _FALSE, bLowPower = _FALSE;
1887
u8 wifiChnl = 0, wifiP2PChnl = 0, nScanAPNum = 0, FwPSState;
1888
u32 iqk_cnt_total = 0, iqk_cnt_ok = 0, iqk_cnt_fail = 0;
1889
u16 wifiBcnInterval = 0;
1890
PHAL_DATA_TYPE hal = GET_HAL_DATA(padapter);
1891
struct btc_wifi_link_info wifi_link_info;
1892
1893
wifi_link_info = halbtcoutsrc_getwifilinkinfo(pBtCoexist);
1894
1895
switch (wifi_link_info.link_mode) {
1896
case BTC_LINK_NONE:
1897
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1898
"None", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1899
wifiFreq = hal->current_channel > 14 ? BTC_FREQ_5G : BTC_FREQ_2_4G;
1900
break;
1901
case BTC_LINK_ONLY_GO:
1902
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1903
"ONLY_GO", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1904
wifiFreq = hal->current_channel > 14 ? BTC_FREQ_5G : BTC_FREQ_2_4G;
1905
break;
1906
case BTC_LINK_ONLY_GC:
1907
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1908
"ONLY_GC", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1909
wifiFreq = hal->current_channel > 14 ? BTC_FREQ_5G : BTC_FREQ_2_4G;
1910
break;
1911
case BTC_LINK_ONLY_STA:
1912
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1913
"ONLY_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1914
wifiFreq = hal->current_channel > 14 ? BTC_FREQ_5G : BTC_FREQ_2_4G;
1915
break;
1916
case BTC_LINK_ONLY_AP:
1917
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1918
"ONLY_AP", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1919
wifiFreq = hal->current_channel > 14 ? BTC_FREQ_5G : BTC_FREQ_2_4G;
1920
break;
1921
case BTC_LINK_2G_MCC_GO_STA:
1922
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1923
"24G_MCC_GO_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1924
wifiFreq = BTC_FREQ_2_4G;
1925
break;
1926
case BTC_LINK_5G_MCC_GO_STA:
1927
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1928
"5G_MCC_GO_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1929
wifiFreq = BTC_FREQ_5G;
1930
break;
1931
case BTC_LINK_25G_MCC_GO_STA:
1932
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1933
"2BANDS_MCC_GO_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1934
wifiFreq = BTC_FREQ_25G;
1935
break;
1936
case BTC_LINK_2G_MCC_GC_STA:
1937
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1938
"24G_MCC_GC_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1939
wifiFreq = BTC_FREQ_2_4G;
1940
break;
1941
case BTC_LINK_5G_MCC_GC_STA:
1942
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1943
"5G_MCC_GC_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1944
wifiFreq = BTC_FREQ_5G;
1945
break;
1946
case BTC_LINK_25G_MCC_GC_STA:
1947
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1948
"2BANDS_MCC_GC_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1949
wifiFreq = BTC_FREQ_25G;
1950
break;
1951
case BTC_LINK_2G_SCC_GO_STA:
1952
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1953
"24G_SCC_GO_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1954
wifiFreq = BTC_FREQ_2_4G;
1955
break;
1956
case BTC_LINK_5G_SCC_GO_STA:
1957
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1958
"5G_SCC_GO_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1959
wifiFreq = BTC_FREQ_5G;
1960
break;
1961
case BTC_LINK_2G_SCC_GC_STA:
1962
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1963
"24G_SCC_GC_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1964
wifiFreq = BTC_FREQ_2_4G;
1965
break;
1966
case BTC_LINK_5G_SCC_GC_STA:
1967
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1968
"5G_SCC_GC_STA", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1969
wifiFreq = BTC_FREQ_5G;
1970
break;
1971
default:
1972
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %d/ %d", "WifiLinkMode/HotSpa/Noa/ClientJoin",
1973
"UNKNOWN", wifi_link_info.bhotspot, wifi_link_info.benable_noa, wifi_link_info.bany_client_join_go);
1974
wifiFreq = hal->current_channel > 14 ? BTC_FREQ_5G : BTC_FREQ_2_4G;
1975
break;
1976
}
1977
1978
CL_PRINTF(cliBuf);
1979
1980
wifiLinkStatus = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist);
1981
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "STA/vWifi/HS/p2pGo/p2pGc",
1982
((wifiLinkStatus & WIFI_STA_CONNECTED) ? 1 : 0), ((wifiLinkStatus & WIFI_AP_CONNECTED) ? 1 : 0),
1983
((wifiLinkStatus & WIFI_HS_CONNECTED) ? 1 : 0), ((wifiLinkStatus & WIFI_P2P_GO_CONNECTED) ? 1 : 0),
1984
((wifiLinkStatus & WIFI_P2P_GC_CONNECTED) ? 1 : 0));
1985
CL_PRINTF(cliBuf);
1986
1987
pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
1988
pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
1989
pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
1990
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Link/ Roam/ Scan",
1991
bLink, bRoam, bScan);
1992
CL_PRINTF(cliBuf);
1993
1994
pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_IQK_TOTAL, &iqk_cnt_total);
1995
pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_IQK_OK, &iqk_cnt_ok);
1996
pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_IQK_FAIL, &iqk_cnt_fail);
1997
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d %s %s",
1998
"IQK All/ OK/ Fail/AutoLoad/FWDL", iqk_cnt_total, iqk_cnt_ok, iqk_cnt_fail,
1999
((halbtcoutsrc_is_autoload_fail(pBtCoexist) == _TRUE) ? "fail":"ok"), ((halbtcoutsrc_is_fw_ready(pBtCoexist) == _TRUE) ? "ok":"fail"));
2000
CL_PRINTF(cliBuf);
2001
2002
if (wifiLinkStatus & WIFI_STA_CONNECTED) {
2003
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "IOT Peer", GLBtcIotPeerString[padapter->mlmeextpriv.mlmext_info.assoc_AP_vendor]);
2004
CL_PRINTF(cliBuf);
2005
}
2006
2007
pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
2008
pBtCoexist->btc_get(pBtCoexist, BTC_GET_U2_BEACON_PERIOD, &wifiBcnInterval);
2009
wifiChnl = wifi_link_info.sta_center_channel;
2010
wifiP2PChnl = wifi_link_info.p2p_center_channel;
2011
2012
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d dBm/ %d/ %d/ %d", "RSSI/ STA_Chnl/ P2P_Chnl/ BI",
2013
wifiRssi-100, wifiChnl, wifiP2PChnl, wifiBcnInterval);
2014
CL_PRINTF(cliBuf);
2015
2016
pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
2017
pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
2018
pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
2019
pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
2020
pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_AP_NUM, &nScanAPNum);
2021
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s/ %d ", "Band/ BW/ Traffic/ APCnt",
2022
GLBtcWifiFreqString[wifiFreq], ((bWifiUnderBMode) ? "11b" : GLBtcWifiBwString[wifiBw]),
2023
((!bWifiBusy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) ? "uplink" : "downlink")),
2024
nScanAPNum);
2025
CL_PRINTF(cliBuf);
2026
2027
/* power status */
2028
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s%s%s", "Power Status", \
2029
((halbtcoutsrc_UnderIps(pBtCoexist) == _TRUE) ? "IPS ON" : "IPS OFF"),
2030
((halbtcoutsrc_UnderLps(pBtCoexist) == _TRUE) ? ", LPS ON" : ", LPS OFF"),
2031
((halbtcoutsrc_Under32K(pBtCoexist) == _TRUE) ? ", 32k" : ""));
2032
CL_PRINTF(cliBuf);
2033
2034
CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x (0x%x/0x%x)", "Power mode cmd(lps/rpwm)",
2035
pBtCoexist->pwrModeVal[0], pBtCoexist->pwrModeVal[1],
2036
pBtCoexist->pwrModeVal[2], pBtCoexist->pwrModeVal[3],
2037
pBtCoexist->pwrModeVal[4], pBtCoexist->pwrModeVal[5],
2038
pBtCoexist->bt_info.lps_val,
2039
pBtCoexist->bt_info.rpwm_val);
2040
CL_PRINTF(cliBuf);
2041
}
2042
2043
void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType)
2044
{
2045
PBTC_COEXIST pBtCoexist;
2046
2047
2048
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2049
switch (dispType) {
2050
case BTC_DBG_DISP_COEX_STATISTICS:
2051
halbtcoutsrc_DisplayCoexStatistics(pBtCoexist);
2052
break;
2053
case BTC_DBG_DISP_BT_LINK_INFO:
2054
halbtcoutsrc_DisplayBtLinkInfo(pBtCoexist);
2055
break;
2056
case BTC_DBG_DISP_WIFI_STATUS:
2057
halbtcoutsrc_DisplayWifiStatus(pBtCoexist);
2058
break;
2059
default:
2060
break;
2061
}
2062
}
2063
2064
/* ************************************
2065
* IO related function
2066
* ************************************ */
2067
u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
2068
{
2069
PBTC_COEXIST pBtCoexist;
2070
PADAPTER padapter;
2071
2072
2073
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2074
padapter = pBtCoexist->Adapter;
2075
2076
return rtw_read8(padapter, RegAddr);
2077
}
2078
2079
u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
2080
{
2081
PBTC_COEXIST pBtCoexist;
2082
PADAPTER padapter;
2083
2084
2085
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2086
padapter = pBtCoexist->Adapter;
2087
2088
return rtw_read16(padapter, RegAddr);
2089
}
2090
2091
u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
2092
{
2093
PBTC_COEXIST pBtCoexist;
2094
PADAPTER padapter;
2095
2096
2097
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2098
padapter = pBtCoexist->Adapter;
2099
2100
return rtw_read32(padapter, RegAddr);
2101
}
2102
2103
void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
2104
{
2105
PBTC_COEXIST pBtCoexist;
2106
PADAPTER padapter;
2107
2108
2109
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2110
padapter = pBtCoexist->Adapter;
2111
2112
rtw_write8(padapter, RegAddr, Data);
2113
}
2114
2115
void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b)
2116
{
2117
PBTC_COEXIST pBtCoexist;
2118
PADAPTER padapter;
2119
u8 originalValue, bitShift;
2120
u8 i;
2121
2122
2123
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2124
padapter = pBtCoexist->Adapter;
2125
originalValue = 0;
2126
bitShift = 0;
2127
2128
if (bitMask != 0xff) {
2129
originalValue = rtw_read8(padapter, regAddr);
2130
2131
for (i = 0; i <= 7; i++) {
2132
if ((bitMask >> i) & 0x1)
2133
break;
2134
}
2135
bitShift = i;
2136
2137
data1b = (originalValue & ~bitMask) | ((data1b << bitShift) & bitMask);
2138
}
2139
2140
rtw_write8(padapter, regAddr, data1b);
2141
}
2142
2143
void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
2144
{
2145
PBTC_COEXIST pBtCoexist;
2146
PADAPTER padapter;
2147
2148
2149
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2150
padapter = pBtCoexist->Adapter;
2151
2152
rtw_write16(padapter, RegAddr, Data);
2153
}
2154
2155
void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
2156
{
2157
PBTC_COEXIST pBtCoexist;
2158
PADAPTER padapter;
2159
2160
2161
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2162
padapter = pBtCoexist->Adapter;
2163
2164
rtw_write32(padapter, RegAddr, Data);
2165
}
2166
2167
void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
2168
{
2169
PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext;
2170
PADAPTER Adapter = pBtCoexist->Adapter;
2171
2172
if (BTC_INTF_SDIO == pBtCoexist->chip_interface)
2173
rtw_write8(Adapter, SDIO_LOCAL_BASE | RegAddr, Data);
2174
else
2175
rtw_write8(Adapter, RegAddr, Data);
2176
}
2177
2178
u32 halbtcoutsrc_WaitLIndirectReg_Ready(void *pBtcContext)
2179
{
2180
PBTC_COEXIST btc = (PBTC_COEXIST)pBtcContext;
2181
u32 delay_count = 0, reg = 0;
2182
2183
if (!btc->chip_para->lte_indirect_access)
2184
return 0;
2185
2186
switch (btc->chip_para->indirect_type) {
2187
case BTC_INDIRECT_1700:
2188
reg = 0x1703;
2189
break;
2190
case BTC_INDIRECT_7C0:
2191
reg = 0x7C3;
2192
break;
2193
default:
2194
return 0;
2195
}
2196
2197
/* wait for ready bit before access */
2198
while (1) {
2199
if ((halbtcoutsrc_Read1Byte(btc, reg) & BIT(5)) == 0) {
2200
rtw_mdelay_os(10);
2201
if (++delay_count >= 10)
2202
break;
2203
} else {
2204
break;
2205
}
2206
}
2207
2208
return delay_count;
2209
}
2210
2211
u32 halbtcoutsrc_ReadLIndirectReg(void *pBtcContext, u16 reg_addr)
2212
{
2213
PBTC_COEXIST btc = (PBTC_COEXIST)pBtcContext;
2214
u32 val = 0;
2215
2216
if (!btc->chip_para->lte_indirect_access)
2217
return 0;
2218
2219
/* wait for ready bit before access */
2220
halbtcoutsrc_WaitLIndirectReg_Ready(btc);
2221
2222
switch (btc->chip_para->indirect_type) {
2223
case BTC_INDIRECT_1700:
2224
halbtcoutsrc_Write4Byte(btc, 0x1700, 0x800F0000 | reg_addr);
2225
val = halbtcoutsrc_Read4Byte(btc, 0x1708); /* get read data */
2226
break;
2227
case BTC_INDIRECT_7C0:
2228
halbtcoutsrc_Write4Byte(btc, 0x7c0, 0x800F0000 | reg_addr);
2229
val = halbtcoutsrc_Read4Byte(btc, 0x7c8); /* get read data */
2230
break;
2231
}
2232
2233
return val;
2234
}
2235
2236
void halbtcoutsrc_WriteLIndirectReg(void *pBtcContext, u16 reg_addr, u32 bit_mask, u32 reg_value)
2237
{
2238
PBTC_COEXIST btc = (PBTC_COEXIST)pBtcContext;
2239
u32 val, i = 0, bitpos = 0, reg0, reg1;
2240
2241
if (!btc->chip_para->lte_indirect_access)
2242
return;
2243
2244
if (bit_mask == 0x0)
2245
return;
2246
2247
switch (btc->chip_para->indirect_type) {
2248
case BTC_INDIRECT_1700:
2249
reg0 = 0x1700;
2250
reg1 = 0x1704;
2251
break;
2252
case BTC_INDIRECT_7C0:
2253
reg0 = 0x7C0;
2254
reg1 = 0x7C4;
2255
break;
2256
default:
2257
return;
2258
}
2259
2260
if (bit_mask == 0xffffffff) {
2261
/* wait for ready bit before access 0x1700 */
2262
halbtcoutsrc_WaitLIndirectReg_Ready(btc);
2263
2264
/* put write data */
2265
halbtcoutsrc_Write4Byte(btc, reg1, reg_value);
2266
halbtcoutsrc_Write4Byte(btc, reg0, 0xc00F0000 | reg_addr);
2267
} else {
2268
for (i = 0; i <= 31; i++) {
2269
if (((bit_mask >> i) & 0x1) == 0x1) {
2270
bitpos = i;
2271
break;
2272
}
2273
}
2274
2275
/* read back register value before write */
2276
val = halbtcoutsrc_ReadLIndirectReg(btc, reg_addr);
2277
val = (val & (~bit_mask)) | (reg_value << bitpos);
2278
2279
/* wait for ready bit before access 0x1700 */
2280
halbtcoutsrc_WaitLIndirectReg_Ready(btc);
2281
2282
halbtcoutsrc_Write4Byte(btc, reg1, val); /* put write data */
2283
halbtcoutsrc_Write4Byte(btc, reg0, 0xc00F0000 | reg_addr);
2284
}
2285
}
2286
2287
void halbtcoutsrc_Read_scbd(void *pBtcContext, u16* score_board_val)
2288
{
2289
PBTC_COEXIST btc = (PBTC_COEXIST)pBtcContext;
2290
struct btc_coex_sta *coex_sta = &btc->coex_sta;
2291
const struct btc_chip_para *chip_para = btc->chip_para;
2292
2293
if (!chip_para->scbd_support)
2294
return;
2295
2296
*score_board_val = (btc->btc_read_2byte(btc, 0xaa)) & 0x7fff;
2297
coex_sta->score_board_BW = *score_board_val;
2298
}
2299
2300
void halbtcoutsrc_Write_scbd(void *pBtcContext, u16 bitpos, u8 state)
2301
{
2302
PBTC_COEXIST btc = (PBTC_COEXIST)pBtcContext;
2303
struct btc_coex_sta *coex_sta = &btc->coex_sta;
2304
const struct btc_chip_para *chip_para = btc->chip_para;
2305
u16 val = 0x2;
2306
u8* btc_dbg_buf = &gl_btc_trace_buf[0];
2307
2308
if (!chip_para->scbd_support)
2309
return;
2310
2311
val = val | coex_sta->score_board_WB;
2312
2313
/* for 8822b, Scoreboard[10]: 0: CQDDR off, 1: CQDDR on
2314
* for 8822c, Scoreboard[10]: 0: CQDDR on, 1:CQDDR fix 2M
2315
*/
2316
if (!btc->chip_para->new_scbd10_def && (bitpos & BTC_SCBD_FIX2M)) {
2317
if (state)
2318
val = val & (~BTC_SCBD_FIX2M);
2319
else
2320
val = val | BTC_SCBD_FIX2M;
2321
} else {
2322
if (state)
2323
val = val | bitpos;
2324
else
2325
val = val & (~bitpos);
2326
}
2327
2328
if (val != coex_sta->score_board_WB) {
2329
coex_sta->score_board_WB = val;
2330
val = val | 0x8000;
2331
btc->btc_write_2byte(btc, 0xaa, val);
2332
2333
BTC_SPRINTF(btc_dbg_buf, BT_TMP_BUF_SIZE,
2334
"[BTCoex], write scoreboard 0x%x\n", val);
2335
} else {
2336
BTC_SPRINTF(btc_dbg_buf, BT_TMP_BUF_SIZE,
2337
"[BTCoex], %s: return for nochange\n", __func__);
2338
}
2339
2340
BTC_TRACE(btc_dbg_buf);
2341
}
2342
2343
void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data)
2344
{
2345
PBTC_COEXIST pBtCoexist;
2346
PADAPTER padapter;
2347
2348
2349
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2350
padapter = pBtCoexist->Adapter;
2351
2352
phy_set_bb_reg(padapter, RegAddr, BitMask, Data);
2353
}
2354
2355
2356
u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
2357
{
2358
PBTC_COEXIST pBtCoexist;
2359
PADAPTER padapter;
2360
2361
2362
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2363
padapter = pBtCoexist->Adapter;
2364
2365
return phy_query_bb_reg(padapter, RegAddr, BitMask);
2366
}
2367
2368
void halbtcoutsrc_SetRfReg(void *pBtcContext, enum rf_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
2369
{
2370
PBTC_COEXIST pBtCoexist;
2371
PADAPTER padapter;
2372
2373
2374
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2375
padapter = pBtCoexist->Adapter;
2376
2377
phy_set_rf_reg(padapter, eRFPath, RegAddr, BitMask, Data);
2378
}
2379
2380
u32 halbtcoutsrc_GetRfReg(void *pBtcContext, enum rf_path eRFPath, u32 RegAddr, u32 BitMask)
2381
{
2382
PBTC_COEXIST pBtCoexist;
2383
PADAPTER padapter;
2384
2385
2386
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2387
padapter = pBtCoexist->Adapter;
2388
2389
return phy_query_rf_reg(padapter, eRFPath, RegAddr, BitMask);
2390
}
2391
2392
u16 halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 Data)
2393
{
2394
PBTC_COEXIST pBtCoexist;
2395
u16 ret = BT_STATUS_BT_OP_SUCCESS;
2396
2397
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2398
2399
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
2400
u8 buf[3] = {0};
2401
_irqL irqL;
2402
u8 op_code;
2403
u8 status;
2404
2405
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2406
2407
Data = cpu_to_le32(Data);
2408
op_code = BT_OP_WRITE_REG_VALUE;
2409
status = _btmpoper_cmd(pBtCoexist, op_code, 0, (u8 *)&Data, 3);
2410
if (status != BT_STATUS_BT_OP_SUCCESS)
2411
ret = SET_BT_MP_OPER_RET(op_code, status);
2412
else {
2413
buf[0] = RegType;
2414
*(u16 *)(buf + 1) = cpu_to_le16((u16)RegAddr);
2415
op_code = BT_OP_WRITE_REG_ADDR;
2416
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 3);
2417
if (status != BT_STATUS_BT_OP_SUCCESS)
2418
ret = SET_BT_MP_OPER_RET(op_code, status);
2419
}
2420
2421
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2422
} else
2423
ret = BT_STATUS_NOT_IMPLEMENT;
2424
2425
return ret;
2426
}
2427
2428
u8 halbtcoutsrc_SetBtAntDetection(void *pBtcContext, u8 txTime, u8 btChnl)
2429
{
2430
/* Always return _FALSE since we don't implement this yet */
2431
#if 0
2432
PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext;
2433
PADAPTER Adapter = pBtCoexist->Adapter;
2434
u8 btCanTx = 0;
2435
BOOLEAN bStatus = FALSE;
2436
2437
bStatus = NDBG_SetBtAntDetection(Adapter, txTime, btChnl, &btCanTx);
2438
if (bStatus && btCanTx)
2439
return _TRUE;
2440
else
2441
return _FALSE;
2442
#else
2443
return _FALSE;
2444
#endif
2445
}
2446
2447
BOOLEAN
2448
halbtcoutsrc_SetBtTRXMASK(
2449
void *pBtcContext,
2450
u8 bt_trx_mask
2451
)
2452
{
2453
/* Always return _FALSE since we don't implement this yet */
2454
#if 0
2455
struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
2456
PADAPTER Adapter = pBtCoexist->Adapter;
2457
BOOLEAN bStatus = FALSE;
2458
u8 btCanTx = 0;
2459
2460
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter) || IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)
2461
|| IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
2462
2463
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2464
bStatus = NDBG_SetBtTRXMASK(Adapter, 1, bt_trx_mask, &btCanTx);
2465
else
2466
bStatus = NDBG_SetBtTRXMASK(Adapter, 2, bt_trx_mask, &btCanTx);
2467
}
2468
2469
2470
if (bStatus)
2471
return TRUE;
2472
else
2473
return FALSE;
2474
#else
2475
return _FALSE;
2476
#endif
2477
}
2478
2479
u16 halbtcoutsrc_GetBtReg_with_status(void *pBtcContext, u8 RegType, u32 RegAddr, u32 *data)
2480
{
2481
PBTC_COEXIST pBtCoexist;
2482
u16 ret = BT_STATUS_BT_OP_SUCCESS;
2483
2484
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2485
2486
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
2487
u8 buf[3] = {0};
2488
_irqL irqL;
2489
u8 op_code;
2490
u8 status;
2491
2492
buf[0] = RegType;
2493
*(u16 *)(buf + 1) = cpu_to_le16((u16)RegAddr);
2494
2495
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2496
2497
op_code = BT_OP_READ_REG;
2498
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 3);
2499
if (status == BT_STATUS_BT_OP_SUCCESS)
2500
*data = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp);
2501
else
2502
ret = SET_BT_MP_OPER_RET(op_code, status);
2503
2504
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2505
2506
} else
2507
ret = BT_STATUS_NOT_IMPLEMENT;
2508
2509
return ret;
2510
}
2511
2512
u32 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr)
2513
{
2514
u32 regVal;
2515
2516
return (BT_STATUS_BT_OP_SUCCESS == halbtcoutsrc_GetBtReg_with_status(pBtcContext, RegType, RegAddr, &regVal)) ? regVal : 0xffffffff;
2517
}
2518
2519
u16 halbtcoutsrc_setbttestmode(void *pBtcContext, u8 Type)
2520
{
2521
PBTC_COEXIST pBtCoexist;
2522
u16 ret = BT_STATUS_BT_OP_SUCCESS;
2523
2524
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2525
2526
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
2527
_irqL irqL;
2528
u8 op_code;
2529
u8 status;
2530
2531
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2532
2533
Type = cpu_to_le32(Type);
2534
op_code = BT_OP_SET_BT_TEST_MODE_VAL;
2535
status = _btmpoper_cmd(pBtCoexist, op_code, 0, (u8 *)&Type, 3);
2536
if (status != BT_STATUS_BT_OP_SUCCESS)
2537
ret = SET_BT_MP_OPER_RET(op_code, status);
2538
2539
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2540
} else
2541
ret = BT_STATUS_NOT_IMPLEMENT;
2542
2543
return ret;
2544
2545
}
2546
2547
2548
void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer)
2549
{
2550
PBTC_COEXIST pBtCoexist;
2551
PADAPTER padapter;
2552
s32 ret = 0;
2553
2554
2555
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2556
padapter = pBtCoexist->Adapter;
2557
2558
ret = rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer);
2559
2560
#ifdef CONFIG_RTL8192F
2561
if (ret == _SUCCESS) {
2562
switch (elementId) {
2563
case H2C_BT_INFO:
2564
case H2C_BT_IGNORE_WLANACT:
2565
case H2C_WL_OPMODE:
2566
case H2C_BT_MP_OPER:
2567
case H2C_BT_CONTROL:
2568
rtw_msleep_os(20);
2569
break;
2570
}
2571
}
2572
#endif
2573
}
2574
2575
static void halbtcoutsrc_coex_offload_init(void)
2576
{
2577
u8 i;
2578
2579
gl_coex_offload.h2c_req_num = 0;
2580
gl_coex_offload.cnt_h2c_sent = 0;
2581
gl_coex_offload.cnt_c2h_ack = 0;
2582
gl_coex_offload.cnt_c2h_ind = 0;
2583
2584
for (i = 0; i < COL_MAX_H2C_REQ_NUM; i++)
2585
init_completion(&gl_coex_offload.c2h_event[i]);
2586
}
2587
2588
static COL_H2C_STATUS halbtcoutsrc_send_h2c(PADAPTER Adapter, PCOL_H2C pcol_h2c, u16 h2c_cmd_len)
2589
{
2590
COL_H2C_STATUS h2c_status = COL_STATUS_C2H_OK;
2591
u8 i;
2592
2593
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0))
2594
reinit_completion(&gl_coex_offload.c2h_event[pcol_h2c->req_num]); /* set event to un signaled state */
2595
#else
2596
INIT_COMPLETION(gl_coex_offload.c2h_event[pcol_h2c->req_num]);
2597
#endif
2598
2599
if (TRUE) {
2600
#if 0 /*(USE_HAL_MAC_API == 1) */
2601
if (RT_STATUS_SUCCESS == HAL_MAC_Send_BT_COEX(&GET_HAL_MAC_INFO(Adapter), (u8 *)(pcol_h2c), (u32)h2c_cmd_len, 1)) {
2602
if (!wait_for_completion_timeout(&gl_coex_offload.c2h_event[pcol_h2c->req_num], 20)) {
2603
h2c_status = COL_STATUS_H2C_TIMTOUT;
2604
}
2605
} else {
2606
h2c_status = COL_STATUS_H2C_HALMAC_FAIL;
2607
}
2608
#endif
2609
}
2610
2611
return h2c_status;
2612
}
2613
2614
static COL_H2C_STATUS halbtcoutsrc_check_c2h_ack(PADAPTER Adapter, PCOL_SINGLE_H2C_RECORD pH2cRecord)
2615
{
2616
COL_H2C_STATUS c2h_status = COL_STATUS_C2H_OK;
2617
PCOL_H2C p_h2c_cmd = (PCOL_H2C)&pH2cRecord->h2c_buf[0];
2618
u8 req_num = p_h2c_cmd->req_num;
2619
PCOL_C2H_ACK p_c2h_ack = (PCOL_C2H_ACK)&gl_coex_offload.c2h_ack_buf[req_num];
2620
2621
2622
if ((COL_C2H_ACK_HDR_LEN + p_c2h_ack->ret_len) > gl_coex_offload.c2h_ack_len[req_num]) {
2623
c2h_status = COL_STATUS_COEX_DATA_OVERFLOW;
2624
return c2h_status;
2625
}
2626
/* else */
2627
{
2628
_rtw_memmove(&pH2cRecord->c2h_ack_buf[0], &gl_coex_offload.c2h_ack_buf[req_num], gl_coex_offload.c2h_ack_len[req_num]);
2629
pH2cRecord->c2h_ack_len = gl_coex_offload.c2h_ack_len[req_num];
2630
}
2631
2632
2633
if (p_c2h_ack->req_num != p_h2c_cmd->req_num) {
2634
c2h_status = COL_STATUS_C2H_REQ_NUM_MISMATCH;
2635
} else if (p_c2h_ack->opcode_ver != p_h2c_cmd->opcode_ver) {
2636
c2h_status = COL_STATUS_C2H_OPCODE_VER_MISMATCH;
2637
} else {
2638
c2h_status = p_c2h_ack->status;
2639
}
2640
2641
return c2h_status;
2642
}
2643
2644
COL_H2C_STATUS halbtcoutsrc_CoexH2cProcess(void *pBtCoexist,
2645
u8 opcode, u8 opcode_ver, u8 *ph2c_par, u8 h2c_par_len)
2646
{
2647
PADAPTER Adapter = ((struct btc_coexist *)pBtCoexist)->Adapter;
2648
u8 H2C_Parameter[BTC_TMP_BUF_SHORT] = {0};
2649
PCOL_H2C pcol_h2c = (PCOL_H2C)&H2C_Parameter[0];
2650
u16 paraLen = 0;
2651
COL_H2C_STATUS h2c_status = COL_STATUS_C2H_OK, c2h_status = COL_STATUS_C2H_OK;
2652
COL_H2C_STATUS ret_status = COL_STATUS_C2H_OK;
2653
u16 i, col_h2c_len = 0;
2654
2655
pcol_h2c->opcode = opcode;
2656
pcol_h2c->opcode_ver = opcode_ver;
2657
pcol_h2c->req_num = gl_coex_offload.h2c_req_num;
2658
gl_coex_offload.h2c_req_num++;
2659
gl_coex_offload.h2c_req_num %= 16;
2660
2661
_rtw_memmove(&pcol_h2c->buf[0], ph2c_par, h2c_par_len);
2662
2663
2664
col_h2c_len = h2c_par_len + 2; /* 2=sizeof(OPCode, OPCode_version and Request number) */
2665
BT_PrintData(Adapter, "[COL], H2C cmd: ", col_h2c_len, H2C_Parameter);
2666
2667
gl_coex_offload.cnt_h2c_sent++;
2668
2669
gl_coex_offload.h2c_record[opcode].count++;
2670
gl_coex_offload.h2c_record[opcode].h2c_len = col_h2c_len;
2671
_rtw_memmove((void *)&gl_coex_offload.h2c_record[opcode].h2c_buf[0], (void *)pcol_h2c, col_h2c_len);
2672
2673
h2c_status = halbtcoutsrc_send_h2c(Adapter, pcol_h2c, col_h2c_len);
2674
2675
gl_coex_offload.h2c_record[opcode].c2h_ack_len = 0;
2676
2677
if (COL_STATUS_C2H_OK == h2c_status) {
2678
/* if reach here, it means H2C get the correct c2h response, */
2679
c2h_status = halbtcoutsrc_check_c2h_ack(Adapter, &gl_coex_offload.h2c_record[opcode]);
2680
ret_status = c2h_status;
2681
} else {
2682
/* check h2c status error, return error status code to upper layer. */
2683
ret_status = h2c_status;
2684
}
2685
gl_coex_offload.h2c_record[opcode].status[ret_status]++;
2686
gl_coex_offload.status[ret_status]++;
2687
2688
return ret_status;
2689
}
2690
2691
u8 halbtcoutsrc_GetAntDetValFromBt(void *pBtcContext)
2692
{
2693
/* Always return 0 since we don't implement this yet */
2694
#if 0
2695
struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
2696
PADAPTER Adapter = pBtCoexist->Adapter;
2697
u8 AntDetVal = 0x0;
2698
u8 opcodeVer = 1;
2699
BOOLEAN status = false;
2700
2701
status = NDBG_GetAntDetValFromBt(Adapter, opcodeVer, &AntDetVal);
2702
2703
RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$ halbtcoutsrc_GetAntDetValFromBt(): status = %d, feature = %x\n", status, AntDetVal));
2704
2705
return AntDetVal;
2706
#else
2707
return 0;
2708
#endif
2709
}
2710
2711
u8 halbtcoutsrc_GetBleScanTypeFromBt(void *pBtcContext)
2712
{
2713
PBTC_COEXIST pBtCoexist;
2714
u32 ret = BT_STATUS_BT_OP_SUCCESS;
2715
u8 data = 0;
2716
2717
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2718
2719
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
2720
u8 buf[3] = {0};
2721
_irqL irqL;
2722
u8 op_code;
2723
u8 status;
2724
2725
2726
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2727
2728
op_code = BT_OP_GET_BT_BLE_SCAN_TYPE;
2729
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
2730
if (status == BT_STATUS_BT_OP_SUCCESS)
2731
data = *(u8 *)GLBtcBtMpRptRsp;
2732
else
2733
ret = SET_BT_MP_OPER_RET(op_code, status);
2734
2735
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2736
2737
} else
2738
ret = BT_STATUS_NOT_IMPLEMENT;
2739
2740
return data;
2741
}
2742
2743
u32 halbtcoutsrc_GetBleScanParaFromBt(void *pBtcContext, u8 scanType)
2744
{
2745
PBTC_COEXIST pBtCoexist;
2746
u32 ret = BT_STATUS_BT_OP_SUCCESS;
2747
u32 data = 0;
2748
2749
pBtCoexist = (PBTC_COEXIST)pBtcContext;
2750
2751
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
2752
u8 buf[3] = {0};
2753
_irqL irqL;
2754
u8 op_code;
2755
u8 status;
2756
2757
buf[0] = scanType;
2758
2759
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2760
2761
op_code = BT_OP_GET_BT_BLE_SCAN_PARA;
2762
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 1);
2763
if (status == BT_STATUS_BT_OP_SUCCESS)
2764
data = le32_to_cpu(*(u32 *)GLBtcBtMpRptRsp);
2765
else
2766
ret = SET_BT_MP_OPER_RET(op_code, status);
2767
2768
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2769
2770
} else
2771
ret = BT_STATUS_NOT_IMPLEMENT;
2772
2773
return data;
2774
}
2775
2776
u8 halbtcoutsrc_GetBtAFHMapFromBt(void *pBtcContext, u8 mapType, u8 *afhMap)
2777
{
2778
struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
2779
u8 buf[2] = {0};
2780
_irqL irqL;
2781
u8 op_code;
2782
u32 *AfhMapL = (u32 *)&(afhMap[0]);
2783
u32 *AfhMapM = (u32 *)&(afhMap[4]);
2784
u16 *AfhMapH = (u16 *)&(afhMap[8]);
2785
u8 status;
2786
u32 ret = BT_STATUS_BT_OP_SUCCESS;
2787
2788
if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _FALSE)
2789
return _FALSE;
2790
2791
buf[0] = 0;
2792
buf[1] = mapType;
2793
2794
_enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2795
2796
op_code = BT_LO_OP_GET_AFH_MAP_L;
2797
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
2798
if (status == BT_STATUS_BT_OP_SUCCESS)
2799
*AfhMapL = le32_to_cpu(*(u32 *)GLBtcBtMpRptRsp);
2800
else {
2801
ret = SET_BT_MP_OPER_RET(op_code, status);
2802
goto exit;
2803
}
2804
2805
op_code = BT_LO_OP_GET_AFH_MAP_M;
2806
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
2807
if (status == BT_STATUS_BT_OP_SUCCESS)
2808
*AfhMapM = le32_to_cpu(*(u32 *)GLBtcBtMpRptRsp);
2809
else {
2810
ret = SET_BT_MP_OPER_RET(op_code, status);
2811
goto exit;
2812
}
2813
2814
op_code = BT_LO_OP_GET_AFH_MAP_H;
2815
status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
2816
if (status == BT_STATUS_BT_OP_SUCCESS)
2817
*AfhMapH = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp);
2818
else {
2819
ret = SET_BT_MP_OPER_RET(op_code, status);
2820
goto exit;
2821
}
2822
2823
exit:
2824
2825
_exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
2826
2827
return (ret == BT_STATUS_BT_OP_SUCCESS) ? _TRUE : _FALSE;
2828
}
2829
2830
u8 halbtcoutsrc_SetTimer(void *pBtcContext, u32 type, u32 val)
2831
{
2832
struct btc_coexist *pBtCoexist=(struct btc_coexist *)pBtcContext;
2833
2834
if (type >= BTC_TIMER_MAX)
2835
return _FALSE;
2836
2837
pBtCoexist->coex_sta.cnt_timer[type] = val;
2838
2839
RTW_DBG("[BTC], Set Timer: type = %d, val = %d\n", type, val);
2840
2841
return _TRUE;
2842
}
2843
2844
u32 halbtcoutsrc_SetAtomic (void *btc_ctx, u32 *target, u32 val)
2845
{
2846
*target = val;
2847
return _SUCCESS;
2848
}
2849
2850
void halbtcoutsrc_phydm_modify_AntDiv_HwSw(void *pBtcContext, u8 is_hw)
2851
{
2852
/* empty function since we don't need it */
2853
}
2854
2855
void halbtcoutsrc_phydm_modify_RA_PCR_threshold(void *pBtcContext, u8 RA_offset_direction, u8 RA_threshold_offset)
2856
{
2857
struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
2858
2859
/* switch to #if 0 in case the phydm version does not provide the function */
2860
#if 1
2861
phydm_modify_RA_PCR_threshold(pBtCoexist->odm_priv, RA_offset_direction, RA_threshold_offset);
2862
#endif
2863
}
2864
2865
u32 halbtcoutsrc_phydm_query_PHY_counter(void *pBtcContext, u8 info_type)
2866
{
2867
struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
2868
2869
/* switch to #if 0 in case the phydm version does not provide the function */
2870
#if 1
2871
return phydm_cmn_info_query((struct dm_struct *)pBtCoexist->odm_priv, (enum phydm_info_query)info_type);
2872
#else
2873
return 0;
2874
#endif
2875
}
2876
2877
void halbtcoutsrc_reduce_wl_tx_power(void *pBtcContext, s8 tx_power)
2878
{
2879
struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
2880
HAL_DATA_TYPE *pHalData = GET_HAL_DATA((PADAPTER)pBtCoexist->Adapter);
2881
2882
/* The reduction of wl tx pwr should be processed inside the set tx pwr lvl function */
2883
if (IS_HARDWARE_TYPE_8822C(pBtCoexist->Adapter))
2884
rtw_hal_set_tx_power_level(pBtCoexist->Adapter, pHalData->current_channel);
2885
}
2886
2887
#if 0
2888
static void BT_CoexOffloadRecordErrC2hAck(PADAPTER Adapter)
2889
{
2890
PADAPTER pDefaultAdapter = GetDefaultAdapter(Adapter);
2891
2892
if (pDefaultAdapter != Adapter)
2893
return;
2894
2895
if (!hal_btcoex_IsBtExist(Adapter))
2896
return;
2897
2898
gl_coex_offload.cnt_c2h_ack++;
2899
2900
gl_coex_offload.status[COL_STATUS_INVALID_C2H_LEN]++;
2901
}
2902
2903
static void BT_CoexOffloadC2hAckCheck(PADAPTER Adapter, u8 *tmpBuf, u8 length)
2904
{
2905
PADAPTER pDefaultAdapter = GetDefaultAdapter(Adapter);
2906
PCOL_C2H_ACK p_c2h_ack = NULL;
2907
u8 req_num = 0xff;
2908
2909
if (pDefaultAdapter != Adapter)
2910
return;
2911
2912
if (!hal_btcoex_IsBtExist(Adapter))
2913
return;
2914
2915
gl_coex_offload.cnt_c2h_ack++;
2916
2917
if (length < COL_C2H_ACK_HDR_LEN) { /* c2h ack length must >= 3 (status, opcode_ver, req_num and ret_len) */
2918
gl_coex_offload.status[COL_STATUS_INVALID_C2H_LEN]++;
2919
} else {
2920
BT_PrintData(Adapter, "[COL], c2h ack:", length, tmpBuf);
2921
2922
p_c2h_ack = (PCOL_C2H_ACK)tmpBuf;
2923
req_num = p_c2h_ack->req_num;
2924
2925
_rtw_memmove(&gl_coex_offload.c2h_ack_buf[req_num][0], tmpBuf, length);
2926
gl_coex_offload.c2h_ack_len[req_num] = length;
2927
2928
complete(&gl_coex_offload.c2h_event[req_num]);
2929
}
2930
}
2931
2932
static void BT_CoexOffloadC2hIndCheck(PADAPTER Adapter, u8 *tmpBuf, u8 length)
2933
{
2934
PADAPTER pDefaultAdapter = GetDefaultAdapter(Adapter);
2935
PCOL_C2H_IND p_c2h_ind = NULL;
2936
u8 ind_type = 0, ind_version = 0, ind_length = 0;
2937
2938
if (pDefaultAdapter != Adapter)
2939
return;
2940
2941
if (!hal_btcoex_IsBtExist(Adapter))
2942
return;
2943
2944
gl_coex_offload.cnt_c2h_ind++;
2945
2946
if (length < COL_C2H_IND_HDR_LEN) { /* c2h indication length must >= 3 (type, version and length) */
2947
gl_coex_offload.c2h_ind_status[COL_STATUS_INVALID_C2H_LEN]++;
2948
} else {
2949
BT_PrintData(Adapter, "[COL], c2h indication:", length, tmpBuf);
2950
2951
p_c2h_ind = (PCOL_C2H_IND)tmpBuf;
2952
ind_type = p_c2h_ind->type;
2953
ind_version = p_c2h_ind->version;
2954
ind_length = p_c2h_ind->length;
2955
2956
_rtw_memmove(&gl_coex_offload.c2h_ind_buf[0], tmpBuf, length);
2957
gl_coex_offload.c2h_ind_len = length;
2958
2959
/* log */
2960
gl_coex_offload.c2h_ind_record[ind_type].count++;
2961
gl_coex_offload.c2h_ind_record[ind_type].status[COL_STATUS_C2H_OK]++;
2962
_rtw_memmove(&gl_coex_offload.c2h_ind_record[ind_type].ind_buf[0], tmpBuf, length);
2963
gl_coex_offload.c2h_ind_record[ind_type].ind_len = length;
2964
2965
gl_coex_offload.c2h_ind_status[COL_STATUS_C2H_OK]++;
2966
/*TODO: need to check c2h indication length*/
2967
/* TODO: Notification */
2968
}
2969
}
2970
2971
void BT_CoexOffloadC2hCheck(PADAPTER Adapter, u8 *Buffer, u8 Length)
2972
{
2973
#if 0 /*(USE_HAL_MAC_API == 1)*/
2974
u8 c2hSubCmdId = 0, c2hAckLen = 0, h2cCmdId = 0, h2cSubCmdId = 0, c2hIndLen = 0;
2975
2976
BT_PrintData(Adapter, "[COL], c2h packet:", Length - 2, Buffer + 2);
2977
c2hSubCmdId = (u8)C2H_HDR_GET_C2H_SUB_CMD_ID(Buffer);
2978
2979
if (c2hSubCmdId == C2H_SUB_CMD_ID_H2C_ACK_HDR ||
2980
c2hSubCmdId == C2H_SUB_CMD_ID_BT_COEX_INFO) {
2981
if (c2hSubCmdId == C2H_SUB_CMD_ID_H2C_ACK_HDR) {
2982
/* coex c2h ack */
2983
h2cCmdId = (u8)H2C_ACK_HDR_GET_H2C_CMD_ID(Buffer);
2984
h2cSubCmdId = (u8)H2C_ACK_HDR_GET_H2C_SUB_CMD_ID(Buffer);
2985
if (h2cCmdId == 0xff && h2cSubCmdId == 0x60) {
2986
c2hAckLen = (u8)C2H_HDR_GET_LEN(Buffer);
2987
if (c2hAckLen >= 8)
2988
BT_CoexOffloadC2hAckCheck(Adapter, &Buffer[12], (u8)(c2hAckLen - 8));
2989
else
2990
BT_CoexOffloadRecordErrC2hAck(Adapter);
2991
}
2992
} else if (c2hSubCmdId == C2H_SUB_CMD_ID_BT_COEX_INFO) {
2993
/* coex c2h indication */
2994
c2hIndLen = (u8)C2H_HDR_GET_LEN(Buffer);
2995
BT_CoexOffloadC2hIndCheck(Adapter, &Buffer[4], (u8)c2hIndLen);
2996
}
2997
}
2998
#endif
2999
}
3000
#endif
3001
3002
/* ************************************
3003
* Extern functions called by other module
3004
* ************************************ */
3005
u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter)
3006
{
3007
PBTC_COEXIST pBtCoexist = &GLBtCoexist;
3008
HAL_DATA_TYPE *pHalData = GET_HAL_DATA((PADAPTER)padapter);
3009
3010
if (pBtCoexist->bBinded)
3011
return _FALSE;
3012
else
3013
pBtCoexist->bBinded = _TRUE;
3014
3015
pBtCoexist->statistics.cnt_bind++;
3016
3017
pBtCoexist->Adapter = padapter;
3018
pBtCoexist->odm_priv = (void *)&(pHalData->odmpriv);
3019
3020
pBtCoexist->stack_info.profile_notified = _FALSE;
3021
3022
pBtCoexist->bt_info.bt_ctrl_agg_buf_size = _FALSE;
3023
pBtCoexist->bt_info.agg_buf_size = 5;
3024
3025
pBtCoexist->bt_info.increase_scan_dev_num = _FALSE;
3026
pBtCoexist->bt_info.miracast_plus_bt = _FALSE;
3027
3028
/* for btc common architecture, inform chip type to coex. mechanism */
3029
if(IS_HARDWARE_TYPE_8822C(padapter)) {
3030
#ifdef CONFIG_RTL8822C
3031
pBtCoexist->chip_type = BTC_CHIP_RTL8822C;
3032
pBtCoexist->chip_para = &btc_chip_para_8822c;
3033
#endif
3034
}
3035
#ifdef CONFIG_RTL8192F
3036
else if (IS_HARDWARE_TYPE_8192F(padapter)) {
3037
pBtCoexist->chip_type = BTC_CHIP_RTL8725A;
3038
pBtCoexist->chip_para = &btc_chip_para_8192f;
3039
}
3040
#endif
3041
else {
3042
pBtCoexist->chip_type = BTC_CHIP_UNDEF;
3043
pBtCoexist->chip_para = NULL;
3044
}
3045
3046
return _TRUE;
3047
}
3048
3049
void EXhalbtcoutsrc_AntInfoSetting(void *padapter)
3050
{
3051
PBTC_COEXIST pBtCoexist = &GLBtCoexist;
3052
u8 antNum = 1, singleAntPath = 0;
3053
3054
antNum = rtw_btcoex_get_pg_ant_num((PADAPTER)padapter);
3055
EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_PG, antNum);
3056
3057
if (antNum == 1) {
3058
singleAntPath = rtw_btcoex_get_pg_single_ant_path((PADAPTER)padapter);
3059
EXhalbtcoutsrc_SetSingleAntPath(singleAntPath);
3060
}
3061
3062
pBtCoexist->board_info.customerID = RT_CID_DEFAULT;
3063
pBtCoexist->board_info.customer_id = RT_CID_DEFAULT;
3064
3065
/* set default antenna position to main port */
3066
pBtCoexist->board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
3067
3068
pBtCoexist->board_info.btdm_ant_det_finish = _FALSE;
3069
pBtCoexist->board_info.btdm_ant_num_by_ant_det = 1;
3070
3071
pBtCoexist->board_info.tfbga_package = rtw_btcoex_is_tfbga_package_type((PADAPTER)padapter);
3072
3073
pBtCoexist->board_info.rfe_type = rtw_btcoex_get_pg_rfe_type((PADAPTER)padapter);
3074
3075
pBtCoexist->board_info.ant_div_cfg = rtw_btcoex_get_ant_div_cfg((PADAPTER)padapter);
3076
3077
pBtCoexist->board_info.ant_distance = 10;
3078
}
3079
3080
u8 EXhalbtcoutsrc_InitlizeVariables(void *padapter)
3081
{
3082
PBTC_COEXIST pBtCoexist = &GLBtCoexist;
3083
3084
/* pBtCoexist->statistics.cntBind++; */
3085
3086
halbtcoutsrc_DbgInit();
3087
3088
halbtcoutsrc_coex_offload_init();
3089
3090
#ifdef CONFIG_PCI_HCI
3091
pBtCoexist->chip_interface = BTC_INTF_PCI;
3092
#elif defined(CONFIG_USB_HCI)
3093
pBtCoexist->chip_interface = BTC_INTF_USB;
3094
#elif defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
3095
pBtCoexist->chip_interface = BTC_INTF_SDIO;
3096
#else
3097
pBtCoexist->chip_interface = BTC_INTF_UNKNOWN;
3098
#endif
3099
3100
EXhalbtcoutsrc_BindBtCoexWithAdapter(padapter);
3101
3102
pBtCoexist->btc_read_1byte = halbtcoutsrc_Read1Byte;
3103
pBtCoexist->btc_write_1byte = halbtcoutsrc_Write1Byte;
3104
pBtCoexist->btc_write_1byte_bitmask = halbtcoutsrc_BitMaskWrite1Byte;
3105
pBtCoexist->btc_read_2byte = halbtcoutsrc_Read2Byte;
3106
pBtCoexist->btc_write_2byte = halbtcoutsrc_Write2Byte;
3107
pBtCoexist->btc_read_4byte = halbtcoutsrc_Read4Byte;
3108
pBtCoexist->btc_write_4byte = halbtcoutsrc_Write4Byte;
3109
pBtCoexist->btc_write_local_reg_1byte = halbtcoutsrc_WriteLocalReg1Byte;
3110
3111
pBtCoexist->btc_read_linderct = halbtcoutsrc_ReadLIndirectReg;
3112
pBtCoexist->btc_write_linderct = halbtcoutsrc_WriteLIndirectReg;
3113
3114
pBtCoexist->btc_read_scbd = halbtcoutsrc_Read_scbd;
3115
pBtCoexist->btc_write_scbd = halbtcoutsrc_Write_scbd;
3116
3117
pBtCoexist->btc_set_bb_reg = halbtcoutsrc_SetBbReg;
3118
pBtCoexist->btc_get_bb_reg = halbtcoutsrc_GetBbReg;
3119
3120
pBtCoexist->btc_set_rf_reg = halbtcoutsrc_SetRfReg;
3121
pBtCoexist->btc_get_rf_reg = halbtcoutsrc_GetRfReg;
3122
3123
pBtCoexist->btc_fill_h2c = halbtcoutsrc_FillH2cCmd;
3124
pBtCoexist->btc_disp_dbg_msg = halbtcoutsrc_DisplayDbgMsg;
3125
3126
pBtCoexist->btc_get = halbtcoutsrc_Get;
3127
pBtCoexist->btc_set = halbtcoutsrc_Set;
3128
pBtCoexist->btc_get_bt_reg = halbtcoutsrc_GetBtReg;
3129
pBtCoexist->btc_set_bt_reg = halbtcoutsrc_SetBtReg;
3130
pBtCoexist->btc_set_bt_ant_detection = halbtcoutsrc_SetBtAntDetection;
3131
pBtCoexist->btc_set_bt_trx_mask = halbtcoutsrc_SetBtTRXMASK;
3132
pBtCoexist->btc_coex_h2c_process = halbtcoutsrc_CoexH2cProcess;
3133
pBtCoexist->btc_get_bt_coex_supported_feature = halbtcoutsrc_GetBtCoexSupportedFeature;
3134
pBtCoexist->btc_get_bt_coex_supported_version= halbtcoutsrc_GetBtCoexSupportedVersion;
3135
pBtCoexist->btc_get_ant_det_val_from_bt = halbtcoutsrc_GetAntDetValFromBt;
3136
pBtCoexist->btc_get_ble_scan_type_from_bt = halbtcoutsrc_GetBleScanTypeFromBt;
3137
pBtCoexist->btc_get_ble_scan_para_from_bt = halbtcoutsrc_GetBleScanParaFromBt;
3138
pBtCoexist->btc_get_bt_afh_map_from_bt = halbtcoutsrc_GetBtAFHMapFromBt;
3139
pBtCoexist->btc_get_bt_phydm_version = halbtcoutsrc_GetPhydmVersion;
3140
pBtCoexist->btc_set_timer = halbtcoutsrc_SetTimer;
3141
pBtCoexist->btc_set_atomic= halbtcoutsrc_SetAtomic;
3142
pBtCoexist->btc_phydm_modify_RA_PCR_threshold = halbtcoutsrc_phydm_modify_RA_PCR_threshold;
3143
pBtCoexist->btc_phydm_query_PHY_counter = halbtcoutsrc_phydm_query_PHY_counter;
3144
pBtCoexist->btc_reduce_wl_tx_power = halbtcoutsrc_reduce_wl_tx_power;
3145
pBtCoexist->btc_phydm_modify_antdiv_hwsw = halbtcoutsrc_phydm_modify_AntDiv_HwSw;
3146
3147
pBtCoexist->cli_buf = &GLBtcDbgBuf[0];
3148
3149
GLBtcWiFiInScanState = _FALSE;
3150
3151
GLBtcWiFiInIQKState = _FALSE;
3152
3153
GLBtcWiFiInIPS = _FALSE;
3154
3155
GLBtcWiFiInLPS = _FALSE;
3156
3157
GLBtcBtCoexAliveRegistered = _FALSE;
3158
3159
/* BT Control H2C/C2H*/
3160
GLBtcBtMpOperSeq = 0;
3161
_rtw_mutex_init(&GLBtcBtMpOperLock);
3162
rtw_init_timer(&GLBtcBtMpOperTimer, padapter, _btmpoper_timer_hdl, pBtCoexist);
3163
_rtw_init_sema(&GLBtcBtMpRptSema, 0);
3164
GLBtcBtMpRptSeq = 0;
3165
GLBtcBtMpRptStatus = 0;
3166
_rtw_memset(GLBtcBtMpRptRsp, 0, C2H_MAX_SIZE);
3167
GLBtcBtMpRptRspSize = 0;
3168
GLBtcBtMpRptWait = _FALSE;
3169
GLBtcBtMpRptWiFiOK = _FALSE;
3170
GLBtcBtMpRptBTOK = _FALSE;
3171
3172
return _TRUE;
3173
}
3174
3175
void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist)
3176
{
3177
HAL_DATA_TYPE *pHalData = NULL;
3178
3179
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3180
return;
3181
3182
pHalData = GET_HAL_DATA((PADAPTER)pBtCoexist->Adapter);
3183
3184
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
3185
rtw_btc_ex_power_on_setting(pBtCoexist);
3186
3187
#else
3188
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3189
#ifdef CONFIG_RTL8723B
3190
if (pBtCoexist->board_info.btdm_ant_num == 2)
3191
ex_halbtc8723b2ant_power_on_setting(pBtCoexist);
3192
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3193
ex_halbtc8723b1ant_power_on_setting(pBtCoexist);
3194
#endif
3195
}
3196
3197
#ifdef CONFIG_RTL8703B
3198
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
3199
if (pBtCoexist->board_info.btdm_ant_num == 1)
3200
ex_halbtc8703b1ant_power_on_setting(pBtCoexist);
3201
}
3202
#endif
3203
3204
#ifdef CONFIG_RTL8723D
3205
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3206
if (pBtCoexist->board_info.btdm_ant_num == 2)
3207
ex_halbtc8723d2ant_power_on_setting(pBtCoexist);
3208
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3209
ex_halbtc8723d1ant_power_on_setting(pBtCoexist);
3210
}
3211
#endif
3212
3213
#ifdef CONFIG_RTL8821A
3214
else if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
3215
if (pBtCoexist->board_info.btdm_ant_num == 1)
3216
ex_halbtc8821a1ant_power_on_setting(pBtCoexist);
3217
else if (pBtCoexist->board_info.btdm_ant_num == 2)
3218
ex_halbtc8821a2ant_power_on_setting(pBtCoexist);
3219
}
3220
#endif
3221
3222
#ifdef CONFIG_RTL8822B
3223
else if ((IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) && (pHalData->EEPROMBluetoothCoexist == _TRUE)) {
3224
if (pBtCoexist->board_info.btdm_ant_num == 1)
3225
ex_halbtc8822b1ant_power_on_setting(pBtCoexist);
3226
else if (pBtCoexist->board_info.btdm_ant_num == 2)
3227
ex_halbtc8822b2ant_power_on_setting(pBtCoexist);
3228
}
3229
#endif
3230
3231
#ifdef CONFIG_RTL8821C
3232
else if ((IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) && (pHalData->EEPROMBluetoothCoexist == _TRUE)) {
3233
if (pBtCoexist->board_info.btdm_ant_num == 2)
3234
ex_halbtc8821c2ant_power_on_setting(pBtCoexist);
3235
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3236
ex_halbtc8821c1ant_power_on_setting(pBtCoexist);
3237
}
3238
#endif
3239
3240
#ifdef CONFIG_RTL8814A
3241
if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
3242
if (pBtCoexist->board_info.btdm_ant_num == 2)
3243
ex_halbtc8814a2ant_power_on_setting(pBtCoexist);
3244
/* else if (pBtCoexist->board_info.btdm_ant_num == 1)
3245
ex_halbtc8814a1ant_power_on_setting(pBtCoexist); */
3246
}
3247
#endif
3248
3249
#endif
3250
}
3251
3252
void EXhalbtcoutsrc_PreLoadFirmware(PBTC_COEXIST pBtCoexist)
3253
{
3254
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3255
return;
3256
3257
pBtCoexist->statistics.cnt_pre_load_firmware++;
3258
3259
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3260
#ifdef CONFIG_RTL8723B
3261
if (pBtCoexist->board_info.btdm_ant_num == 2)
3262
ex_halbtc8723b2ant_pre_load_firmware(pBtCoexist);
3263
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3264
ex_halbtc8723b1ant_pre_load_firmware(pBtCoexist);
3265
#endif
3266
}
3267
3268
#ifdef CONFIG_RTL8723D
3269
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3270
if (pBtCoexist->board_info.btdm_ant_num == 2)
3271
ex_halbtc8723d2ant_pre_load_firmware(pBtCoexist);
3272
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3273
ex_halbtc8723d1ant_pre_load_firmware(pBtCoexist);
3274
}
3275
#endif
3276
3277
#ifdef CONFIG_RTL8821C
3278
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
3279
if (pBtCoexist->board_info.btdm_ant_num == 2)
3280
ex_halbtc8821c2ant_pre_load_firmware(pBtCoexist);
3281
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3282
ex_halbtc8821c1ant_pre_load_firmware(pBtCoexist);
3283
}
3284
#endif
3285
}
3286
3287
void EXhalbtcoutsrc_init_hw_config(PBTC_COEXIST pBtCoexist, u8 bWifiOnly)
3288
{
3289
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3290
return;
3291
3292
pBtCoexist->statistics.cnt_init_hw_config++;
3293
3294
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
3295
rtw_btc_ex_init_hw_config(pBtCoexist, bWifiOnly);
3296
#else
3297
3298
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
3299
#ifdef CONFIG_RTL8821A
3300
if (pBtCoexist->board_info.btdm_ant_num == 2)
3301
ex_halbtc8821a2ant_init_hw_config(pBtCoexist, bWifiOnly);
3302
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3303
ex_halbtc8821a1ant_init_hw_config(pBtCoexist, bWifiOnly);
3304
#endif
3305
}
3306
3307
#ifdef CONFIG_RTL8723B
3308
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3309
if (pBtCoexist->board_info.btdm_ant_num == 2)
3310
ex_halbtc8723b2ant_init_hw_config(pBtCoexist, bWifiOnly);
3311
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3312
ex_halbtc8723b1ant_init_hw_config(pBtCoexist, bWifiOnly);
3313
}
3314
#endif
3315
3316
#ifdef CONFIG_RTL8703B
3317
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
3318
if (pBtCoexist->board_info.btdm_ant_num == 1)
3319
ex_halbtc8703b1ant_init_hw_config(pBtCoexist, bWifiOnly);
3320
}
3321
#endif
3322
3323
#ifdef CONFIG_RTL8723D
3324
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3325
if (pBtCoexist->board_info.btdm_ant_num == 2)
3326
ex_halbtc8723d2ant_init_hw_config(pBtCoexist, bWifiOnly);
3327
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3328
ex_halbtc8723d1ant_init_hw_config(pBtCoexist, bWifiOnly);
3329
}
3330
#endif
3331
3332
#ifdef CONFIG_RTL8192E
3333
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
3334
if (pBtCoexist->board_info.btdm_ant_num == 2)
3335
ex_halbtc8192e2ant_init_hw_config(pBtCoexist, bWifiOnly);
3336
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3337
ex_halbtc8192e1ant_init_hw_config(pBtCoexist, bWifiOnly);
3338
}
3339
#endif
3340
3341
#ifdef CONFIG_RTL8812A
3342
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
3343
if (pBtCoexist->board_info.btdm_ant_num == 2)
3344
ex_halbtc8812a2ant_init_hw_config(pBtCoexist, bWifiOnly);
3345
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3346
ex_halbtc8812a1ant_init_hw_config(pBtCoexist, bWifiOnly);
3347
}
3348
#endif
3349
3350
#ifdef CONFIG_RTL8822B
3351
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
3352
if (pBtCoexist->board_info.btdm_ant_num == 1)
3353
ex_halbtc8822b1ant_init_hw_config(pBtCoexist, bWifiOnly);
3354
else if (pBtCoexist->board_info.btdm_ant_num == 2)
3355
ex_halbtc8822b2ant_init_hw_config(pBtCoexist, bWifiOnly);
3356
}
3357
#endif
3358
3359
#ifdef CONFIG_RTL8821C
3360
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
3361
if (pBtCoexist->board_info.btdm_ant_num == 2)
3362
ex_halbtc8821c2ant_init_hw_config(pBtCoexist, bWifiOnly);
3363
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3364
ex_halbtc8821c1ant_init_hw_config(pBtCoexist, bWifiOnly);
3365
}
3366
#endif
3367
3368
#ifdef CONFIG_RTL8814A
3369
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
3370
if (pBtCoexist->board_info.btdm_ant_num == 2)
3371
ex_halbtc8814a2ant_init_hw_config(pBtCoexist, bWifiOnly);
3372
}
3373
#endif
3374
3375
#endif
3376
}
3377
3378
void EXhalbtcoutsrc_init_coex_dm(PBTC_COEXIST pBtCoexist)
3379
{
3380
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3381
return;
3382
3383
pBtCoexist->statistics.cnt_init_coex_dm++;
3384
3385
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
3386
rtw_btc_ex_init_coex_dm(pBtCoexist);
3387
#else
3388
3389
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
3390
#ifdef CONFIG_RTL8821A
3391
if (pBtCoexist->board_info.btdm_ant_num == 2)
3392
ex_halbtc8821a2ant_init_coex_dm(pBtCoexist);
3393
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3394
ex_halbtc8821a1ant_init_coex_dm(pBtCoexist);
3395
#endif
3396
}
3397
3398
#ifdef CONFIG_RTL8723B
3399
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3400
if (pBtCoexist->board_info.btdm_ant_num == 2)
3401
ex_halbtc8723b2ant_init_coex_dm(pBtCoexist);
3402
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3403
ex_halbtc8723b1ant_init_coex_dm(pBtCoexist);
3404
}
3405
#endif
3406
3407
#ifdef CONFIG_RTL8703B
3408
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
3409
if (pBtCoexist->board_info.btdm_ant_num == 1)
3410
ex_halbtc8703b1ant_init_coex_dm(pBtCoexist);
3411
}
3412
#endif
3413
3414
#ifdef CONFIG_RTL8723D
3415
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3416
if (pBtCoexist->board_info.btdm_ant_num == 2)
3417
ex_halbtc8723d2ant_init_coex_dm(pBtCoexist);
3418
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3419
ex_halbtc8723d1ant_init_coex_dm(pBtCoexist);
3420
}
3421
#endif
3422
3423
#ifdef CONFIG_RTL8192E
3424
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
3425
if (pBtCoexist->board_info.btdm_ant_num == 2)
3426
ex_halbtc8192e2ant_init_coex_dm(pBtCoexist);
3427
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3428
ex_halbtc8192e1ant_init_coex_dm(pBtCoexist);
3429
}
3430
#endif
3431
3432
#ifdef CONFIG_RTL8812A
3433
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
3434
if (pBtCoexist->board_info.btdm_ant_num == 2)
3435
ex_halbtc8812a2ant_init_coex_dm(pBtCoexist);
3436
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3437
ex_halbtc8812a1ant_init_coex_dm(pBtCoexist);
3438
}
3439
#endif
3440
3441
#ifdef CONFIG_RTL8822B
3442
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
3443
if (pBtCoexist->board_info.btdm_ant_num == 1)
3444
ex_halbtc8822b1ant_init_coex_dm(pBtCoexist);
3445
else if (pBtCoexist->board_info.btdm_ant_num == 2)
3446
ex_halbtc8822b2ant_init_coex_dm(pBtCoexist);
3447
}
3448
#endif
3449
3450
#ifdef CONFIG_RTL8821C
3451
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
3452
if (pBtCoexist->board_info.btdm_ant_num == 2)
3453
ex_halbtc8821c2ant_init_coex_dm(pBtCoexist);
3454
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3455
ex_halbtc8821c1ant_init_coex_dm(pBtCoexist);
3456
}
3457
#endif
3458
3459
#ifdef CONFIG_RTL8814A
3460
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
3461
if (pBtCoexist->board_info.btdm_ant_num == 2)
3462
ex_halbtc8814a2ant_init_coex_dm(pBtCoexist);
3463
}
3464
#endif
3465
3466
#endif
3467
3468
pBtCoexist->initilized = _TRUE;
3469
}
3470
3471
void EXhalbtcoutsrc_ips_notify(PBTC_COEXIST pBtCoexist, u8 type)
3472
{
3473
u8 ipsType;
3474
3475
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3476
return;
3477
3478
pBtCoexist->statistics.cnt_ips_notify++;
3479
if (pBtCoexist->manual_control)
3480
return;
3481
3482
if (IPS_NONE == type) {
3483
ipsType = BTC_IPS_LEAVE;
3484
GLBtcWiFiInIPS = _FALSE;
3485
} else {
3486
ipsType = BTC_IPS_ENTER;
3487
GLBtcWiFiInIPS = _TRUE;
3488
}
3489
3490
/* All notify is called in cmd thread, don't need to leave low power again
3491
* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
3492
3493
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
3494
rtw_btc_ex_ips_notify(pBtCoexist, ipsType);
3495
#else
3496
3497
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
3498
#ifdef CONFIG_RTL8821A
3499
if (pBtCoexist->board_info.btdm_ant_num == 2)
3500
ex_halbtc8821a2ant_ips_notify(pBtCoexist, ipsType);
3501
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3502
ex_halbtc8821a1ant_ips_notify(pBtCoexist, ipsType);
3503
#endif
3504
}
3505
3506
#ifdef CONFIG_RTL8723B
3507
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3508
if (pBtCoexist->board_info.btdm_ant_num == 2)
3509
ex_halbtc8723b2ant_ips_notify(pBtCoexist, ipsType);
3510
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3511
ex_halbtc8723b1ant_ips_notify(pBtCoexist, ipsType);
3512
}
3513
#endif
3514
3515
#ifdef CONFIG_RTL8703B
3516
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
3517
if (pBtCoexist->board_info.btdm_ant_num == 1)
3518
ex_halbtc8703b1ant_ips_notify(pBtCoexist, ipsType);
3519
}
3520
#endif
3521
3522
#ifdef CONFIG_RTL8723D
3523
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3524
if (pBtCoexist->board_info.btdm_ant_num == 2)
3525
ex_halbtc8723d2ant_ips_notify(pBtCoexist, ipsType);
3526
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3527
ex_halbtc8723d1ant_ips_notify(pBtCoexist, ipsType);
3528
}
3529
#endif
3530
3531
#ifdef CONFIG_RTL8192E
3532
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
3533
if (pBtCoexist->board_info.btdm_ant_num == 2)
3534
ex_halbtc8192e2ant_ips_notify(pBtCoexist, ipsType);
3535
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3536
ex_halbtc8192e1ant_ips_notify(pBtCoexist, ipsType);
3537
}
3538
#endif
3539
3540
#ifdef CONFIG_RTL8812A
3541
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
3542
if (pBtCoexist->board_info.btdm_ant_num == 2)
3543
ex_halbtc8812a2ant_ips_notify(pBtCoexist, ipsType);
3544
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3545
ex_halbtc8812a1ant_ips_notify(pBtCoexist, ipsType);
3546
}
3547
#endif
3548
3549
#ifdef CONFIG_RTL8822B
3550
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
3551
if (pBtCoexist->board_info.btdm_ant_num == 1)
3552
ex_halbtc8822b1ant_ips_notify(pBtCoexist, ipsType);
3553
else if (pBtCoexist->board_info.btdm_ant_num == 2)
3554
ex_halbtc8822b2ant_ips_notify(pBtCoexist, ipsType);
3555
}
3556
#endif
3557
3558
#ifdef CONFIG_RTL8821C
3559
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
3560
if (pBtCoexist->board_info.btdm_ant_num == 2)
3561
ex_halbtc8821c2ant_ips_notify(pBtCoexist, ipsType);
3562
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3563
ex_halbtc8821c1ant_ips_notify(pBtCoexist, ipsType);
3564
}
3565
#endif
3566
3567
#ifdef CONFIG_RTL8814A
3568
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
3569
if (pBtCoexist->board_info.btdm_ant_num == 2)
3570
ex_halbtc8814a2ant_ips_notify(pBtCoexist, ipsType);
3571
}
3572
#endif
3573
3574
#endif
3575
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
3576
}
3577
3578
void EXhalbtcoutsrc_lps_notify(PBTC_COEXIST pBtCoexist, u8 type)
3579
{
3580
u8 lpsType;
3581
3582
3583
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3584
return;
3585
3586
pBtCoexist->statistics.cnt_lps_notify++;
3587
if (pBtCoexist->manual_control)
3588
return;
3589
3590
if (PS_MODE_ACTIVE == type) {
3591
lpsType = BTC_LPS_DISABLE;
3592
GLBtcWiFiInLPS = _FALSE;
3593
} else {
3594
lpsType = BTC_LPS_ENABLE;
3595
GLBtcWiFiInLPS = _TRUE;
3596
}
3597
3598
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
3599
rtw_btc_ex_lps_notify(pBtCoexist, lpsType);
3600
#else
3601
3602
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
3603
#ifdef CONFIG_RTL8821A
3604
if (pBtCoexist->board_info.btdm_ant_num == 2)
3605
ex_halbtc8821a2ant_lps_notify(pBtCoexist, lpsType);
3606
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3607
ex_halbtc8821a1ant_lps_notify(pBtCoexist, lpsType);
3608
#endif
3609
}
3610
3611
#ifdef CONFIG_RTL8723B
3612
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3613
if (pBtCoexist->board_info.btdm_ant_num == 2)
3614
ex_halbtc8723b2ant_lps_notify(pBtCoexist, lpsType);
3615
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3616
ex_halbtc8723b1ant_lps_notify(pBtCoexist, lpsType);
3617
}
3618
#endif
3619
3620
#ifdef CONFIG_RTL8703B
3621
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
3622
if (pBtCoexist->board_info.btdm_ant_num == 1)
3623
ex_halbtc8703b1ant_lps_notify(pBtCoexist, lpsType);
3624
}
3625
#endif
3626
3627
#ifdef CONFIG_RTL8723D
3628
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3629
if (pBtCoexist->board_info.btdm_ant_num == 2)
3630
ex_halbtc8723d2ant_lps_notify(pBtCoexist, lpsType);
3631
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3632
ex_halbtc8723d1ant_lps_notify(pBtCoexist, lpsType);
3633
}
3634
#endif
3635
3636
#ifdef CONFIG_RTL8192E
3637
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
3638
if (pBtCoexist->board_info.btdm_ant_num == 2)
3639
ex_halbtc8192e2ant_lps_notify(pBtCoexist, lpsType);
3640
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3641
ex_halbtc8192e1ant_lps_notify(pBtCoexist, lpsType);
3642
}
3643
#endif
3644
3645
#ifdef CONFIG_RTL8812A
3646
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
3647
if (pBtCoexist->board_info.btdm_ant_num == 2)
3648
ex_halbtc8812a2ant_lps_notify(pBtCoexist, lpsType);
3649
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3650
ex_halbtc8812a1ant_lps_notify(pBtCoexist, lpsType);
3651
}
3652
#endif
3653
3654
#ifdef CONFIG_RTL8822B
3655
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
3656
if (pBtCoexist->board_info.btdm_ant_num == 1)
3657
ex_halbtc8822b1ant_lps_notify(pBtCoexist, lpsType);
3658
else if (pBtCoexist->board_info.btdm_ant_num == 2)
3659
ex_halbtc8822b2ant_lps_notify(pBtCoexist, lpsType);
3660
}
3661
#endif
3662
3663
#ifdef CONFIG_RTL8821C
3664
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
3665
if (pBtCoexist->board_info.btdm_ant_num == 2)
3666
ex_halbtc8821c2ant_lps_notify(pBtCoexist, lpsType);
3667
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3668
ex_halbtc8821c1ant_lps_notify(pBtCoexist, lpsType);
3669
}
3670
#endif
3671
3672
#ifdef CONFIG_RTL8814A
3673
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
3674
if (pBtCoexist->board_info.btdm_ant_num == 2)
3675
ex_halbtc8814a2ant_lps_notify(pBtCoexist, lpsType);
3676
}
3677
#endif
3678
3679
#endif
3680
}
3681
3682
void EXhalbtcoutsrc_scan_notify(PBTC_COEXIST pBtCoexist, u8 type)
3683
{
3684
u8 scanType;
3685
3686
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3687
return;
3688
pBtCoexist->statistics.cnt_scan_notify++;
3689
if (pBtCoexist->manual_control)
3690
return;
3691
3692
if (type) {
3693
scanType = BTC_SCAN_START;
3694
GLBtcWiFiInScanState = _TRUE;
3695
} else {
3696
scanType = BTC_SCAN_FINISH;
3697
GLBtcWiFiInScanState = _FALSE;
3698
}
3699
3700
/* All notify is called in cmd thread, don't need to leave low power again
3701
* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
3702
3703
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
3704
rtw_btc_ex_scan_notify(pBtCoexist, scanType);
3705
#else
3706
3707
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
3708
#ifdef CONFIG_RTL8821A
3709
if (pBtCoexist->board_info.btdm_ant_num == 2)
3710
ex_halbtc8821a2ant_scan_notify(pBtCoexist, scanType);
3711
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3712
ex_halbtc8821a1ant_scan_notify(pBtCoexist, scanType);
3713
#endif
3714
}
3715
3716
#ifdef CONFIG_RTL8723B
3717
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3718
if (pBtCoexist->board_info.btdm_ant_num == 2)
3719
ex_halbtc8723b2ant_scan_notify(pBtCoexist, scanType);
3720
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3721
ex_halbtc8723b1ant_scan_notify(pBtCoexist, scanType);
3722
}
3723
#endif
3724
3725
#ifdef CONFIG_RTL8703B
3726
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
3727
if (pBtCoexist->board_info.btdm_ant_num == 1)
3728
ex_halbtc8703b1ant_scan_notify(pBtCoexist, scanType);
3729
}
3730
#endif
3731
3732
#ifdef CONFIG_RTL8723D
3733
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3734
if (pBtCoexist->board_info.btdm_ant_num == 2)
3735
ex_halbtc8723d2ant_scan_notify(pBtCoexist, scanType);
3736
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3737
ex_halbtc8723d1ant_scan_notify(pBtCoexist, scanType);
3738
}
3739
#endif
3740
3741
#ifdef CONFIG_RTL8192E
3742
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
3743
if (pBtCoexist->board_info.btdm_ant_num == 2)
3744
ex_halbtc8192e2ant_scan_notify(pBtCoexist, scanType);
3745
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3746
ex_halbtc8192e1ant_scan_notify(pBtCoexist, scanType);
3747
}
3748
#endif
3749
3750
#ifdef CONFIG_RTL8812A
3751
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
3752
if (pBtCoexist->board_info.btdm_ant_num == 2)
3753
ex_halbtc8812a2ant_scan_notify(pBtCoexist, scanType);
3754
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3755
ex_halbtc8812a1ant_scan_notify(pBtCoexist, scanType);
3756
}
3757
#endif
3758
3759
#ifdef CONFIG_RTL8822B
3760
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
3761
if (pBtCoexist->board_info.btdm_ant_num == 1)
3762
ex_halbtc8822b1ant_scan_notify(pBtCoexist, scanType);
3763
else if (pBtCoexist->board_info.btdm_ant_num == 2)
3764
ex_halbtc8822b2ant_scan_notify(pBtCoexist, scanType);
3765
}
3766
#endif
3767
3768
#ifdef CONFIG_RTL8821C
3769
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
3770
if (pBtCoexist->board_info.btdm_ant_num == 2)
3771
ex_halbtc8821c2ant_scan_notify(pBtCoexist, scanType);
3772
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3773
ex_halbtc8821c1ant_scan_notify(pBtCoexist, scanType);
3774
}
3775
#endif
3776
3777
#ifdef CONFIG_RTL8814A
3778
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
3779
if (pBtCoexist->board_info.btdm_ant_num == 2)
3780
ex_halbtc8814a2ant_scan_notify(pBtCoexist, scanType);
3781
}
3782
#endif
3783
3784
#endif
3785
3786
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
3787
}
3788
3789
void EXhalbtcoutsrc_SetAntennaPathNotify(PBTC_COEXIST pBtCoexist, u8 type)
3790
{
3791
#if 0
3792
u8 switchType;
3793
3794
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3795
return;
3796
3797
if (pBtCoexist->manual_control)
3798
return;
3799
3800
halbtcoutsrc_LeaveLowPower(pBtCoexist);
3801
3802
switchType = type;
3803
3804
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3805
if (pBtCoexist->board_info.btdm_ant_num == 1)
3806
ex_halbtc8723b1ant_set_antenna_notify(pBtCoexist, type);
3807
}
3808
if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3809
if (pBtCoexist->board_info.btdm_ant_num == 1)
3810
ex_halbtc8723d1ant_set_antenna_notify(pBtCoexist, type);
3811
else if (pBtCoexist->board_info.btdm_ant_num == 2)
3812
ex_halbtc8723d2ant_set_antenna_notify(pBtCoexist, type);
3813
}
3814
3815
halbtcoutsrc_NormalLowPower(pBtCoexist);
3816
#endif
3817
}
3818
3819
void EXhalbtcoutsrc_connect_notify(PBTC_COEXIST pBtCoexist, u8 assoType)
3820
{
3821
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3822
return;
3823
pBtCoexist->statistics.cnt_connect_notify++;
3824
if (pBtCoexist->manual_control)
3825
return;
3826
3827
/* All notify is called in cmd thread, don't need to leave low power again
3828
* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
3829
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
3830
rtw_btc_ex_connect_notify(pBtCoexist, assoType);
3831
#else
3832
3833
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
3834
#ifdef CONFIG_RTL8821A
3835
if (pBtCoexist->board_info.btdm_ant_num == 2)
3836
ex_halbtc8821a2ant_connect_notify(pBtCoexist, assoType);
3837
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3838
ex_halbtc8821a1ant_connect_notify(pBtCoexist, assoType);
3839
#endif
3840
}
3841
3842
#ifdef CONFIG_RTL8723B
3843
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3844
if (pBtCoexist->board_info.btdm_ant_num == 2)
3845
ex_halbtc8723b2ant_connect_notify(pBtCoexist, assoType);
3846
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3847
ex_halbtc8723b1ant_connect_notify(pBtCoexist, assoType);
3848
}
3849
#endif
3850
3851
#ifdef CONFIG_RTL8703B
3852
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
3853
if (pBtCoexist->board_info.btdm_ant_num == 1)
3854
ex_halbtc8703b1ant_connect_notify(pBtCoexist, assoType);
3855
}
3856
#endif
3857
3858
#ifdef CONFIG_RTL8723D
3859
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3860
if (pBtCoexist->board_info.btdm_ant_num == 2)
3861
ex_halbtc8723d2ant_connect_notify(pBtCoexist, assoType);
3862
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3863
ex_halbtc8723d1ant_connect_notify(pBtCoexist, assoType);
3864
}
3865
#endif
3866
3867
#ifdef CONFIG_RTL8192E
3868
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
3869
if (pBtCoexist->board_info.btdm_ant_num == 2)
3870
ex_halbtc8192e2ant_connect_notify(pBtCoexist, assoType);
3871
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3872
ex_halbtc8192e1ant_connect_notify(pBtCoexist, assoType);
3873
}
3874
#endif
3875
3876
#ifdef CONFIG_RTL8812A
3877
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
3878
if (pBtCoexist->board_info.btdm_ant_num == 2)
3879
ex_halbtc8812a2ant_connect_notify(pBtCoexist, assoType);
3880
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3881
ex_halbtc8812a1ant_connect_notify(pBtCoexist, assoType);
3882
}
3883
#endif
3884
3885
#ifdef CONFIG_RTL8822B
3886
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
3887
if (pBtCoexist->board_info.btdm_ant_num == 1)
3888
ex_halbtc8822b1ant_connect_notify(pBtCoexist, assoType);
3889
else if (pBtCoexist->board_info.btdm_ant_num == 2)
3890
ex_halbtc8822b2ant_connect_notify(pBtCoexist, assoType);
3891
}
3892
#endif
3893
3894
#ifdef CONFIG_RTL8821C
3895
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
3896
if (pBtCoexist->board_info.btdm_ant_num == 2)
3897
ex_halbtc8821c2ant_connect_notify(pBtCoexist, assoType);
3898
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3899
ex_halbtc8821c1ant_connect_notify(pBtCoexist, assoType);
3900
}
3901
#endif
3902
3903
#ifdef CONFIG_RTL8814A
3904
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
3905
if (pBtCoexist->board_info.btdm_ant_num == 2)
3906
ex_halbtc8814a2ant_connect_notify(pBtCoexist, assoType);
3907
}
3908
#endif
3909
3910
#endif
3911
3912
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
3913
}
3914
3915
void EXhalbtcoutsrc_media_status_notify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus)
3916
{
3917
u8 mStatus = BTC_MEDIA_MAX;
3918
PADAPTER adapter = NULL;
3919
HAL_DATA_TYPE *hal = NULL;
3920
3921
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
3922
return;
3923
3924
if (pBtCoexist->manual_control)
3925
return;
3926
3927
pBtCoexist->statistics.cnt_media_status_notify++;
3928
adapter = (PADAPTER)pBtCoexist->Adapter;
3929
hal = GET_HAL_DATA(adapter);
3930
3931
if (RT_MEDIA_CONNECT == mediaStatus) {
3932
if (hal->current_band_type == BAND_ON_2_4G)
3933
mStatus = BTC_MEDIA_CONNECT;
3934
else if (hal->current_band_type == BAND_ON_5G)
3935
mStatus = BTC_MEDIA_CONNECT_5G;
3936
else {
3937
mStatus = BTC_MEDIA_CONNECT;
3938
RTW_ERR("%s unknow band type\n", __func__);
3939
}
3940
} else
3941
mStatus = BTC_MEDIA_DISCONNECT;
3942
3943
/* All notify is called in cmd thread, don't need to leave low power again
3944
* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
3945
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
3946
rtw_btc_ex_media_status_notify(pBtCoexist, mStatus);
3947
#else
3948
3949
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
3950
#ifdef CONFIG_RTL8821A
3951
/* compatible for 8821A */
3952
if (mStatus == BTC_MEDIA_CONNECT_5G)
3953
mStatus = BTC_MEDIA_CONNECT;
3954
if (pBtCoexist->board_info.btdm_ant_num == 2)
3955
ex_halbtc8821a2ant_media_status_notify(pBtCoexist, mStatus);
3956
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3957
ex_halbtc8821a1ant_media_status_notify(pBtCoexist, mStatus);
3958
#endif
3959
}
3960
3961
#ifdef CONFIG_RTL8723B
3962
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
3963
if (pBtCoexist->board_info.btdm_ant_num == 2)
3964
ex_halbtc8723b2ant_media_status_notify(pBtCoexist, mStatus);
3965
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3966
ex_halbtc8723b1ant_media_status_notify(pBtCoexist, mStatus);
3967
}
3968
#endif
3969
3970
#ifdef CONFIG_RTL8703B
3971
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
3972
if (pBtCoexist->board_info.btdm_ant_num == 1)
3973
ex_halbtc8703b1ant_media_status_notify(pBtCoexist, mStatus);
3974
}
3975
#endif
3976
3977
#ifdef CONFIG_RTL8723D
3978
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
3979
if (pBtCoexist->board_info.btdm_ant_num == 2)
3980
ex_halbtc8723d2ant_media_status_notify(pBtCoexist, mStatus);
3981
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3982
ex_halbtc8723d1ant_media_status_notify(pBtCoexist, mStatus);
3983
}
3984
#endif
3985
3986
#ifdef CONFIG_RTL8192E
3987
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
3988
if (pBtCoexist->board_info.btdm_ant_num == 2)
3989
ex_halbtc8192e2ant_media_status_notify(pBtCoexist, mStatus);
3990
else if (pBtCoexist->board_info.btdm_ant_num == 1)
3991
ex_halbtc8192e1ant_media_status_notify(pBtCoexist, mStatus);
3992
}
3993
#endif
3994
3995
#ifdef CONFIG_RTL8812A
3996
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
3997
/* compatible for 8812A */
3998
if (mStatus == BTC_MEDIA_CONNECT_5G)
3999
mStatus = BTC_MEDIA_CONNECT;
4000
if (pBtCoexist->board_info.btdm_ant_num == 2)
4001
ex_halbtc8812a2ant_media_status_notify(pBtCoexist, mStatus);
4002
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4003
ex_halbtc8812a1ant_media_status_notify(pBtCoexist, mStatus);
4004
}
4005
#endif
4006
4007
#ifdef CONFIG_RTL8822B
4008
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
4009
if (pBtCoexist->board_info.btdm_ant_num == 1)
4010
ex_halbtc8822b1ant_media_status_notify(pBtCoexist, mStatus);
4011
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4012
ex_halbtc8822b2ant_media_status_notify(pBtCoexist, mStatus);
4013
}
4014
#endif
4015
4016
#ifdef CONFIG_RTL8821C
4017
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
4018
if (pBtCoexist->board_info.btdm_ant_num == 2)
4019
ex_halbtc8821c2ant_media_status_notify(pBtCoexist, mStatus);
4020
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4021
ex_halbtc8821c1ant_media_status_notify(pBtCoexist, mStatus);
4022
}
4023
#endif
4024
4025
#ifdef CONFIG_RTL8814A
4026
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
4027
if (pBtCoexist->board_info.btdm_ant_num == 2)
4028
ex_halbtc8814a2ant_media_status_notify(pBtCoexist, mStatus);
4029
}
4030
#endif
4031
4032
#endif
4033
4034
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
4035
}
4036
4037
void EXhalbtcoutsrc_specific_packet_notify(PBTC_COEXIST pBtCoexist, u8 pktType)
4038
{
4039
u8 packetType;
4040
PADAPTER adapter = NULL;
4041
HAL_DATA_TYPE *hal = NULL;
4042
4043
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4044
return;
4045
4046
if (pBtCoexist->manual_control)
4047
return;
4048
4049
pBtCoexist->statistics.cnt_specific_packet_notify++;
4050
adapter = (PADAPTER)pBtCoexist->Adapter;
4051
hal = GET_HAL_DATA(adapter);
4052
4053
if (PACKET_DHCP == pktType)
4054
packetType = BTC_PACKET_DHCP;
4055
else if (PACKET_EAPOL == pktType)
4056
packetType = BTC_PACKET_EAPOL;
4057
else if (PACKET_ARP == pktType)
4058
packetType = BTC_PACKET_ARP;
4059
else {
4060
packetType = BTC_PACKET_UNKNOWN;
4061
return;
4062
}
4063
4064
if (hal->current_band_type == BAND_ON_5G)
4065
packetType |= BTC_5G_BAND;
4066
4067
/* All notify is called in cmd thread, don't need to leave low power again
4068
* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
4069
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4070
rtw_btc_ex_specific_packet_notify(pBtCoexist, packetType);
4071
#else
4072
4073
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
4074
#ifdef CONFIG_RTL8821A
4075
/* compatible for 8821A */
4076
if (hal->current_band_type == BAND_ON_5G)
4077
packetType &= ~BTC_5G_BAND;
4078
4079
if (pBtCoexist->board_info.btdm_ant_num == 2)
4080
ex_halbtc8821a2ant_specific_packet_notify(pBtCoexist, packetType);
4081
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4082
ex_halbtc8821a1ant_specific_packet_notify(pBtCoexist, packetType);
4083
#endif
4084
}
4085
4086
#ifdef CONFIG_RTL8723B
4087
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
4088
if (pBtCoexist->board_info.btdm_ant_num == 2)
4089
ex_halbtc8723b2ant_specific_packet_notify(pBtCoexist, packetType);
4090
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4091
ex_halbtc8723b1ant_specific_packet_notify(pBtCoexist, packetType);
4092
}
4093
#endif
4094
4095
#ifdef CONFIG_RTL8703B
4096
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
4097
if (pBtCoexist->board_info.btdm_ant_num == 1)
4098
ex_halbtc8703b1ant_specific_packet_notify(pBtCoexist, packetType);
4099
}
4100
#endif
4101
4102
#ifdef CONFIG_RTL8723D
4103
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
4104
if (pBtCoexist->board_info.btdm_ant_num == 2)
4105
ex_halbtc8723d2ant_specific_packet_notify(pBtCoexist, packetType);
4106
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4107
ex_halbtc8723d1ant_specific_packet_notify(pBtCoexist, packetType);
4108
}
4109
#endif
4110
4111
#ifdef CONFIG_RTL8192E
4112
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
4113
if (pBtCoexist->board_info.btdm_ant_num == 2)
4114
ex_halbtc8192e2ant_specific_packet_notify(pBtCoexist, packetType);
4115
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4116
ex_halbtc8192e1ant_specific_packet_notify(pBtCoexist, packetType);
4117
}
4118
#endif
4119
4120
#ifdef CONFIG_RTL8812A
4121
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
4122
/* compatible for 8812A */
4123
if (hal->current_band_type == BAND_ON_5G)
4124
packetType &= ~BTC_5G_BAND;
4125
4126
if (pBtCoexist->board_info.btdm_ant_num == 2)
4127
ex_halbtc8812a2ant_specific_packet_notify(pBtCoexist, packetType);
4128
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4129
ex_halbtc8812a1ant_specific_packet_notify(pBtCoexist, packetType);
4130
}
4131
#endif
4132
4133
#ifdef CONFIG_RTL8822B
4134
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
4135
if (pBtCoexist->board_info.btdm_ant_num == 1)
4136
ex_halbtc8822b1ant_specific_packet_notify(pBtCoexist, packetType);
4137
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4138
ex_halbtc8822b2ant_specific_packet_notify(pBtCoexist, packetType);
4139
}
4140
#endif
4141
4142
#ifdef CONFIG_RTL8821C
4143
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
4144
if (pBtCoexist->board_info.btdm_ant_num == 2)
4145
ex_halbtc8821c2ant_specific_packet_notify(pBtCoexist, packetType);
4146
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4147
ex_halbtc8821c1ant_specific_packet_notify(pBtCoexist, packetType);
4148
}
4149
#endif
4150
4151
#ifdef CONFIG_RTL8814A
4152
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
4153
if (pBtCoexist->board_info.btdm_ant_num == 2)
4154
ex_halbtc8814a2ant_specific_packet_notify(pBtCoexist, packetType);
4155
}
4156
#endif
4157
4158
#endif
4159
4160
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
4161
}
4162
4163
void EXhalbtcoutsrc_bt_info_notify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length)
4164
{
4165
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4166
return;
4167
4168
pBtCoexist->statistics.cnt_bt_info_notify++;
4169
4170
/* All notify is called in cmd thread, don't need to leave low power again
4171
* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
4172
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4173
rtw_btc_ex_bt_info_notify(pBtCoexist, tmpBuf, length);
4174
#else
4175
4176
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
4177
#ifdef CONFIG_RTL8821A
4178
if (pBtCoexist->board_info.btdm_ant_num == 2)
4179
ex_halbtc8821a2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4180
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4181
ex_halbtc8821a1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4182
#endif
4183
}
4184
4185
#ifdef CONFIG_RTL8723B
4186
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
4187
if (pBtCoexist->board_info.btdm_ant_num == 2)
4188
ex_halbtc8723b2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4189
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4190
ex_halbtc8723b1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4191
}
4192
#endif
4193
4194
#ifdef CONFIG_RTL8703B
4195
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
4196
if (pBtCoexist->board_info.btdm_ant_num == 1)
4197
ex_halbtc8703b1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4198
}
4199
#endif
4200
4201
#ifdef CONFIG_RTL8723D
4202
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
4203
if (pBtCoexist->board_info.btdm_ant_num == 2)
4204
ex_halbtc8723d2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4205
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4206
ex_halbtc8723d1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4207
}
4208
#endif
4209
4210
#ifdef CONFIG_RTL8192E
4211
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
4212
if (pBtCoexist->board_info.btdm_ant_num == 2)
4213
ex_halbtc8192e2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4214
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4215
ex_halbtc8192e1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4216
}
4217
#endif
4218
4219
#ifdef CONFIG_RTL8812A
4220
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
4221
if (pBtCoexist->board_info.btdm_ant_num == 2)
4222
ex_halbtc8812a2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4223
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4224
ex_halbtc8812a1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4225
}
4226
#endif
4227
4228
#ifdef CONFIG_RTL8822B
4229
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
4230
if (pBtCoexist->board_info.btdm_ant_num == 1)
4231
ex_halbtc8822b1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4232
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4233
ex_halbtc8822b2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4234
}
4235
#endif
4236
4237
#ifdef CONFIG_RTL8821C
4238
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
4239
if (pBtCoexist->board_info.btdm_ant_num == 2)
4240
ex_halbtc8821c2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4241
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4242
ex_halbtc8821c1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4243
}
4244
#endif
4245
4246
#ifdef CONFIG_RTL8814A
4247
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
4248
if (pBtCoexist->board_info.btdm_ant_num == 2)
4249
ex_halbtc8814a2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
4250
}
4251
#endif
4252
4253
#endif
4254
4255
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
4256
}
4257
4258
void EXhalbtcoutsrc_WlFwDbgInfoNotify(PBTC_COEXIST pBtCoexist, u8* tmpBuf, u8 length)
4259
{
4260
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4261
return;
4262
4263
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4264
rtw_btc_ex_wl_fwdbginfo_notify(pBtCoexist, tmpBuf, length);
4265
#else
4266
4267
if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
4268
#ifdef CONFIG_RTL8703B
4269
if (pBtCoexist->board_info.btdm_ant_num == 1)
4270
ex_halbtc8703b1ant_wl_fwdbginfo_notify(pBtCoexist, tmpBuf, length);
4271
#endif
4272
}
4273
4274
#ifdef CONFIG_RTL8723D
4275
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
4276
if (pBtCoexist->board_info.btdm_ant_num == 1)
4277
ex_halbtc8723d1ant_wl_fwdbginfo_notify(pBtCoexist, tmpBuf, length);
4278
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4279
ex_halbtc8723d2ant_wl_fwdbginfo_notify(pBtCoexist, tmpBuf, length);
4280
}
4281
#endif
4282
4283
#ifdef CONFIG_RTL8821C
4284
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
4285
if (pBtCoexist->board_info.btdm_ant_num == 2)
4286
ex_halbtc8821c2ant_wl_fwdbginfo_notify(pBtCoexist, tmpBuf, length);
4287
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4288
ex_halbtc8821c1ant_wl_fwdbginfo_notify(pBtCoexist, tmpBuf, length);
4289
}
4290
#endif
4291
4292
#endif
4293
}
4294
4295
void EXhalbtcoutsrc_rx_rate_change_notify(PBTC_COEXIST pBtCoexist, u8 is_data_frame, u8 btc_rate_id)
4296
{
4297
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4298
return;
4299
4300
pBtCoexist->statistics.cnt_rate_id_notify++;
4301
4302
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4303
rtw_btc_ex_rx_rate_change_notify(pBtCoexist, is_data_frame, btc_rate_id);
4304
#else
4305
4306
if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
4307
#ifdef CONFIG_RTL8703B
4308
if (pBtCoexist->board_info.btdm_ant_num == 1)
4309
ex_halbtc8703b1ant_rx_rate_change_notify(pBtCoexist, is_data_frame, btc_rate_id);
4310
#endif
4311
}
4312
4313
#ifdef CONFIG_RTL8723D
4314
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
4315
if (pBtCoexist->board_info.btdm_ant_num == 1)
4316
ex_halbtc8723d1ant_rx_rate_change_notify(pBtCoexist, is_data_frame, btc_rate_id);
4317
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4318
ex_halbtc8723d2ant_rx_rate_change_notify(pBtCoexist, is_data_frame, btc_rate_id);
4319
}
4320
#endif
4321
4322
#ifdef CONFIG_RTL8821C
4323
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
4324
if (pBtCoexist->board_info.btdm_ant_num == 1)
4325
ex_halbtc8821c1ant_rx_rate_change_notify(pBtCoexist, is_data_frame, btc_rate_id);
4326
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4327
ex_halbtc8821c2ant_rx_rate_change_notify(pBtCoexist, is_data_frame, btc_rate_id);
4328
}
4329
#endif
4330
4331
#endif
4332
}
4333
4334
void
4335
EXhalbtcoutsrc_RfStatusNotify(
4336
PBTC_COEXIST pBtCoexist,
4337
u8 type
4338
)
4339
{
4340
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4341
return;
4342
pBtCoexist->statistics.cnt_rf_status_notify++;
4343
4344
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4345
rtw_btc_ex_rf_status_notify(pBtCoexist, type);
4346
#else
4347
4348
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
4349
#ifdef CONFIG_RTL8723B
4350
if (pBtCoexist->board_info.btdm_ant_num == 1)
4351
ex_halbtc8723b1ant_rf_status_notify(pBtCoexist, type);
4352
#endif
4353
}
4354
4355
#ifdef CONFIG_RTL8703B
4356
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
4357
if (pBtCoexist->board_info.btdm_ant_num == 1)
4358
ex_halbtc8703b1ant_rf_status_notify(pBtCoexist, type);
4359
}
4360
#endif
4361
4362
#ifdef CONFIG_RTL8723D
4363
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
4364
if (pBtCoexist->board_info.btdm_ant_num == 1)
4365
ex_halbtc8723d1ant_rf_status_notify(pBtCoexist, type);
4366
}
4367
#endif
4368
4369
#ifdef CONFIG_RTL8822B
4370
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
4371
if (pBtCoexist->board_info.btdm_ant_num == 1)
4372
ex_halbtc8822b1ant_rf_status_notify(pBtCoexist, type);
4373
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4374
ex_halbtc8822b2ant_rf_status_notify(pBtCoexist, type);
4375
}
4376
#endif
4377
4378
#ifdef CONFIG_RTL8821C
4379
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
4380
if (pBtCoexist->board_info.btdm_ant_num == 2)
4381
ex_halbtc8821c2ant_rf_status_notify(pBtCoexist, type);
4382
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4383
ex_halbtc8821c1ant_rf_status_notify(pBtCoexist, type);
4384
}
4385
#endif
4386
4387
#ifdef CONFIG_RTL8814A
4388
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
4389
if (pBtCoexist->board_info.btdm_ant_num == 2)
4390
ex_halbtc8814a2ant_rf_status_notify(pBtCoexist, type);
4391
}
4392
#endif
4393
4394
#endif
4395
}
4396
4397
void EXhalbtcoutsrc_StackOperationNotify(PBTC_COEXIST pBtCoexist, u8 type)
4398
{
4399
#if 0
4400
u8 stackOpType;
4401
4402
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4403
return;
4404
pBtCoexist->statistics.cntStackOperationNotify++;
4405
if (pBtCoexist->manual_control)
4406
return;
4407
4408
if ((HCI_BT_OP_INQUIRY_START == type) ||
4409
(HCI_BT_OP_PAGING_START == type) ||
4410
(HCI_BT_OP_PAIRING_START == type))
4411
stackOpType = BTC_STACK_OP_INQ_PAGE_PAIR_START;
4412
else if ((HCI_BT_OP_INQUIRY_FINISH == type) ||
4413
(HCI_BT_OP_PAGING_SUCCESS == type) ||
4414
(HCI_BT_OP_PAGING_UNSUCCESS == type) ||
4415
(HCI_BT_OP_PAIRING_FINISH == type))
4416
stackOpType = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH;
4417
else
4418
stackOpType = BTC_STACK_OP_NONE;
4419
4420
#endif
4421
}
4422
4423
void EXhalbtcoutsrc_halt_notify(PBTC_COEXIST pBtCoexist)
4424
{
4425
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4426
return;
4427
4428
pBtCoexist->statistics.cnt_halt_notify++;
4429
4430
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4431
rtw_btc_ex_halt_notify(pBtCoexist);
4432
#else
4433
4434
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
4435
#ifdef CONFIG_RTL8821A
4436
if (pBtCoexist->board_info.btdm_ant_num == 2)
4437
ex_halbtc8821a2ant_halt_notify(pBtCoexist);
4438
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4439
ex_halbtc8821a1ant_halt_notify(pBtCoexist);
4440
#endif
4441
}
4442
4443
#ifdef CONFIG_RTL8723B
4444
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
4445
if (pBtCoexist->board_info.btdm_ant_num == 2)
4446
ex_halbtc8723b2ant_halt_notify(pBtCoexist);
4447
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4448
ex_halbtc8723b1ant_halt_notify(pBtCoexist);
4449
}
4450
#endif
4451
4452
#ifdef CONFIG_RTL8703B
4453
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
4454
if (pBtCoexist->board_info.btdm_ant_num == 1)
4455
ex_halbtc8703b1ant_halt_notify(pBtCoexist);
4456
}
4457
#endif
4458
4459
#ifdef CONFIG_RTL8723D
4460
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
4461
if (pBtCoexist->board_info.btdm_ant_num == 2)
4462
ex_halbtc8723d2ant_halt_notify(pBtCoexist);
4463
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4464
ex_halbtc8723d1ant_halt_notify(pBtCoexist);
4465
}
4466
#endif
4467
4468
#ifdef CONFIG_RTL8192E
4469
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
4470
if (pBtCoexist->board_info.btdm_ant_num == 2)
4471
ex_halbtc8192e2ant_halt_notify(pBtCoexist);
4472
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4473
ex_halbtc8192e1ant_halt_notify(pBtCoexist);
4474
}
4475
#endif
4476
4477
#ifdef CONFIG_RTL8812A
4478
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
4479
if (pBtCoexist->board_info.btdm_ant_num == 2)
4480
ex_halbtc8812a2ant_halt_notify(pBtCoexist);
4481
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4482
ex_halbtc8812a1ant_halt_notify(pBtCoexist);
4483
}
4484
#endif
4485
4486
#ifdef CONFIG_RTL8822B
4487
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
4488
if (pBtCoexist->board_info.btdm_ant_num == 1)
4489
ex_halbtc8822b1ant_halt_notify(pBtCoexist);
4490
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4491
ex_halbtc8822b2ant_halt_notify(pBtCoexist);
4492
}
4493
#endif
4494
4495
#ifdef CONFIG_RTL8821C
4496
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
4497
if (pBtCoexist->board_info.btdm_ant_num == 2)
4498
ex_halbtc8821c2ant_halt_notify(pBtCoexist);
4499
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4500
ex_halbtc8821c1ant_halt_notify(pBtCoexist);
4501
}
4502
#endif
4503
4504
#ifdef CONFIG_RTL8814A
4505
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
4506
if (pBtCoexist->board_info.btdm_ant_num == 2)
4507
ex_halbtc8814a2ant_halt_notify(pBtCoexist);
4508
}
4509
#endif
4510
4511
#endif
4512
}
4513
4514
void EXhalbtcoutsrc_SwitchBtTRxMask(PBTC_COEXIST pBtCoexist)
4515
{
4516
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
4517
if (pBtCoexist->board_info.btdm_ant_num == 2) {
4518
halbtcoutsrc_SetBtReg(pBtCoexist, 0, 0x3c, 0x01); /* BT goto standby while GNT_BT 1-->0 */
4519
} else if (pBtCoexist->board_info.btdm_ant_num == 1) {
4520
halbtcoutsrc_SetBtReg(pBtCoexist, 0, 0x3c, 0x15); /* BT goto standby while GNT_BT 1-->0 */
4521
}
4522
}
4523
}
4524
4525
void EXhalbtcoutsrc_pnp_notify(PBTC_COEXIST pBtCoexist, u8 pnpState)
4526
{
4527
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4528
return;
4529
4530
pBtCoexist->statistics.cnt_pnp_notify++;
4531
4532
/* */
4533
/* currently only 1ant we have to do the notification, */
4534
/* once pnp is notified to sleep state, we have to leave LPS that we can sleep normally. */
4535
/* */
4536
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4537
rtw_btc_ex_pnp_notify(pBtCoexist, pnpState);
4538
#else
4539
4540
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
4541
#ifdef CONFIG_RTL8723B
4542
if (pBtCoexist->board_info.btdm_ant_num == 1)
4543
ex_halbtc8723b1ant_pnp_notify(pBtCoexist, pnpState);
4544
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4545
ex_halbtc8723b2ant_pnp_notify(pBtCoexist, pnpState);
4546
#endif
4547
}
4548
4549
#ifdef CONFIG_RTL8703B
4550
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
4551
if (pBtCoexist->board_info.btdm_ant_num == 1)
4552
ex_halbtc8703b1ant_pnp_notify(pBtCoexist, pnpState);
4553
}
4554
#endif
4555
4556
#ifdef CONFIG_RTL8723D
4557
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
4558
if (pBtCoexist->board_info.btdm_ant_num == 1)
4559
ex_halbtc8723d1ant_pnp_notify(pBtCoexist, pnpState);
4560
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4561
ex_halbtc8723d2ant_pnp_notify(pBtCoexist, pnpState);
4562
}
4563
#endif
4564
4565
#ifdef CONFIG_RTL8821A
4566
else if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
4567
if (pBtCoexist->board_info.btdm_ant_num == 1)
4568
ex_halbtc8821a1ant_pnp_notify(pBtCoexist, pnpState);
4569
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4570
ex_halbtc8821a2ant_pnp_notify(pBtCoexist, pnpState);
4571
}
4572
#endif
4573
4574
#ifdef CONFIG_RTL8192E
4575
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
4576
if (pBtCoexist->board_info.btdm_ant_num == 1)
4577
ex_halbtc8192e1ant_pnp_notify(pBtCoexist, pnpState);
4578
}
4579
#endif
4580
4581
#ifdef CONFIG_RTL8812A
4582
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
4583
if (pBtCoexist->board_info.btdm_ant_num == 1)
4584
ex_halbtc8812a1ant_pnp_notify(pBtCoexist, pnpState);
4585
}
4586
#endif
4587
4588
#ifdef CONFIG_RTL8822B
4589
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
4590
if (pBtCoexist->board_info.btdm_ant_num == 1)
4591
ex_halbtc8822b1ant_pnp_notify(pBtCoexist, pnpState);
4592
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4593
ex_halbtc8822b2ant_pnp_notify(pBtCoexist, pnpState);
4594
}
4595
#endif
4596
4597
#ifdef CONFIG_RTL8821C
4598
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
4599
if (pBtCoexist->board_info.btdm_ant_num == 2)
4600
ex_halbtc8821c2ant_pnp_notify(pBtCoexist, pnpState);
4601
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4602
ex_halbtc8821c1ant_pnp_notify(pBtCoexist, pnpState);
4603
}
4604
#endif
4605
4606
#ifdef CONFIG_RTL8814A
4607
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
4608
if (pBtCoexist->board_info.btdm_ant_num == 2)
4609
ex_halbtc8814a2ant_pnp_notify(pBtCoexist, pnpState);
4610
}
4611
#endif
4612
4613
#endif
4614
}
4615
4616
void EXhalbtcoutsrc_CoexDmSwitch(PBTC_COEXIST pBtCoexist)
4617
{
4618
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4619
return;
4620
pBtCoexist->statistics.cnt_coex_dm_switch++;
4621
4622
halbtcoutsrc_LeaveLowPower(pBtCoexist);
4623
4624
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
4625
#ifdef CONFIG_RTL8723B
4626
if (pBtCoexist->board_info.btdm_ant_num == 1) {
4627
pBtCoexist->stop_coex_dm = TRUE;
4628
ex_halbtc8723b1ant_coex_dm_reset(pBtCoexist);
4629
EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_DETECTED, 2);
4630
ex_halbtc8723b2ant_init_hw_config(pBtCoexist, FALSE);
4631
ex_halbtc8723b2ant_init_coex_dm(pBtCoexist);
4632
pBtCoexist->stop_coex_dm = FALSE;
4633
}
4634
#endif
4635
}
4636
4637
#ifdef CONFIG_RTL8723D
4638
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
4639
if (pBtCoexist->board_info.btdm_ant_num == 1) {
4640
pBtCoexist->stop_coex_dm = TRUE;
4641
ex_halbtc8723d1ant_coex_dm_reset(pBtCoexist);
4642
EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_DETECTED, 2);
4643
ex_halbtc8723d2ant_init_hw_config(pBtCoexist, FALSE);
4644
ex_halbtc8723d2ant_init_coex_dm(pBtCoexist);
4645
pBtCoexist->stop_coex_dm = FALSE;
4646
}
4647
}
4648
#endif
4649
4650
halbtcoutsrc_NormalLowPower(pBtCoexist);
4651
}
4652
4653
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4654
void EXhalbtcoutsrc_TimerNotify(PBTC_COEXIST pBtCoexist, u32 timer_type)
4655
{
4656
rtw_btc_ex_timerup_notify(pBtCoexist, timer_type);
4657
}
4658
4659
void EXhalbtcoutsrc_WLStatusChangeNotify(PBTC_COEXIST pBtCoexist, u32 change_type)
4660
{
4661
rtw_btc_ex_wl_status_change_notify(pBtCoexist, change_type);
4662
}
4663
4664
u32 EXhalbtcoutsrc_CoexTimerCheck(PBTC_COEXIST pBtCoexist)
4665
{
4666
u32 i, timer_map = 0;
4667
4668
for (i = 0; i < BTC_TIMER_MAX; i++) {
4669
if (pBtCoexist->coex_sta.cnt_timer[i] > 0) {
4670
if (pBtCoexist->coex_sta.cnt_timer[i] == 1) {
4671
timer_map |= BIT(i);
4672
RTW_DBG("[BTC], %s(): timer_map = 0x%x\n", __func__, timer_map);
4673
}
4674
4675
pBtCoexist->coex_sta.cnt_timer[i]--;
4676
}
4677
}
4678
4679
return timer_map;
4680
}
4681
4682
u32 EXhalbtcoutsrc_WLStatusCheck(PBTC_COEXIST pBtCoexist)
4683
{
4684
struct btc_wifi_link_info link_info;
4685
const struct btc_chip_para *chip_para = pBtCoexist->chip_para;
4686
u32 change_map = 0;
4687
static bool wl_busy_pre;
4688
bool wl_busy = _FALSE;
4689
s32 wl_rssi;
4690
u32 traffic_dir;
4691
u8 i, tmp;
4692
static u8 rssi_step_pre = 5, wl_noisy_level_pre = 4;
4693
4694
/* WL busy to idle or idle to busy */
4695
pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &wl_busy);
4696
if (wl_busy != wl_busy_pre) {
4697
if (wl_busy)
4698
change_map |= BIT(BTC_WLSTATUS_CHANGE_TOBUSY);
4699
else
4700
change_map |= BIT(BTC_WLSTATUS_CHANGE_TOIDLE);
4701
4702
wl_busy_pre = wl_busy;
4703
}
4704
4705
/* WL RSSI */
4706
pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wl_rssi);
4707
tmp = (u8)(wl_rssi & 0xff);
4708
for (i = 0; i < 4; i++) {
4709
if (tmp >= chip_para->wl_rssi_step[i])
4710
break;
4711
}
4712
4713
if (rssi_step_pre != i) {
4714
rssi_step_pre = i;
4715
change_map |= BIT(BTC_WLSTATUS_CHANGE_RSSI);
4716
}
4717
4718
/* WL Link info */
4719
pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK_INFO, &link_info);
4720
if (link_info.link_mode != pBtCoexist->wifi_link_info.link_mode ||
4721
link_info.sta_center_channel !=
4722
pBtCoexist->wifi_link_info.sta_center_channel ||
4723
link_info.p2p_center_channel !=
4724
pBtCoexist->wifi_link_info.p2p_center_channel ||
4725
link_info.bany_client_join_go !=
4726
pBtCoexist->wifi_link_info.bany_client_join_go) {
4727
change_map |= BIT(BTC_WLSTATUS_CHANGE_LINKINFO);
4728
pBtCoexist->wifi_link_info = link_info;
4729
}
4730
4731
/* WL Traffic Direction */
4732
pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIR, &traffic_dir);
4733
if (wl_busy && traffic_dir != pBtCoexist->wifi_link_info_ext.traffic_dir) {
4734
change_map |= BIT(BTC_WLSTATUS_CHANGE_DIR);
4735
pBtCoexist->wifi_link_info_ext.traffic_dir = traffic_dir;
4736
}
4737
4738
/* Noisy Detect */
4739
if (pBtCoexist->coex_sta.wl_noisy_level != wl_noisy_level_pre) {
4740
change_map |= BIT(BTC_WLSTATUS_CHANGE_NOISY);
4741
wl_noisy_level_pre = pBtCoexist->coex_sta.wl_noisy_level;
4742
}
4743
4744
RTW_DBG("[BTC], %s(): change_map = 0x%x\n", __func__, change_map);
4745
4746
return change_map;
4747
}
4748
4749
void EXhalbtcoutsrc_status_monitor(PBTC_COEXIST pBtCoexist)
4750
{
4751
u32 timer_up_type = 0, wl_status_change_type = 0;
4752
4753
timer_up_type = EXhalbtcoutsrc_CoexTimerCheck(pBtCoexist);
4754
if (timer_up_type != 0)
4755
EXhalbtcoutsrc_TimerNotify(pBtCoexist, timer_up_type);
4756
4757
wl_status_change_type = EXhalbtcoutsrc_WLStatusCheck(pBtCoexist);
4758
if (wl_status_change_type != 0)
4759
EXhalbtcoutsrc_WLStatusChangeNotify(pBtCoexist, wl_status_change_type);
4760
4761
rtw_btc_ex_periodical(pBtCoexist);
4762
}
4763
#endif
4764
4765
void EXhalbtcoutsrc_periodical(PBTC_COEXIST pBtCoexist)
4766
{
4767
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4768
return;
4769
pBtCoexist->statistics.cnt_periodical++;
4770
4771
/* Periodical should be called in cmd thread, */
4772
/* don't need to leave low power again
4773
* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
4774
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4775
EXhalbtcoutsrc_status_monitor(pBtCoexist);
4776
#else
4777
4778
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
4779
#ifdef CONFIG_RTL8821A
4780
if (pBtCoexist->board_info.btdm_ant_num == 2)
4781
ex_halbtc8821a2ant_periodical(pBtCoexist);
4782
else if (pBtCoexist->board_info.btdm_ant_num == 1) {
4783
if (!halbtcoutsrc_UnderIps(pBtCoexist))
4784
ex_halbtc8821a1ant_periodical(pBtCoexist);
4785
}
4786
#endif
4787
}
4788
4789
#ifdef CONFIG_RTL8723B
4790
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
4791
if (pBtCoexist->board_info.btdm_ant_num == 2)
4792
ex_halbtc8723b2ant_periodical(pBtCoexist);
4793
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4794
ex_halbtc8723b1ant_periodical(pBtCoexist);
4795
}
4796
#endif
4797
4798
#ifdef CONFIG_RTL8723D
4799
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
4800
if (pBtCoexist->board_info.btdm_ant_num == 2)
4801
ex_halbtc8723d2ant_periodical(pBtCoexist);
4802
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4803
ex_halbtc8723d1ant_periodical(pBtCoexist);
4804
}
4805
#endif
4806
4807
#ifdef CONFIG_RTL8703B
4808
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
4809
if (pBtCoexist->board_info.btdm_ant_num == 1)
4810
ex_halbtc8703b1ant_periodical(pBtCoexist);
4811
}
4812
#endif
4813
4814
#ifdef CONFIG_RTL8192E
4815
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
4816
if (pBtCoexist->board_info.btdm_ant_num == 2)
4817
ex_halbtc8192e2ant_periodical(pBtCoexist);
4818
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4819
ex_halbtc8192e1ant_periodical(pBtCoexist);
4820
}
4821
#endif
4822
4823
#ifdef CONFIG_RTL8812A
4824
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
4825
if (pBtCoexist->board_info.btdm_ant_num == 2)
4826
ex_halbtc8812a2ant_periodical(pBtCoexist);
4827
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4828
ex_halbtc8812a1ant_periodical(pBtCoexist);
4829
}
4830
#endif
4831
4832
#ifdef CONFIG_RTL8822B
4833
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
4834
if (pBtCoexist->board_info.btdm_ant_num == 1)
4835
ex_halbtc8822b1ant_periodical(pBtCoexist);
4836
else if (pBtCoexist->board_info.btdm_ant_num == 2)
4837
ex_halbtc8822b2ant_periodical(pBtCoexist);
4838
}
4839
#endif
4840
4841
#ifdef CONFIG_RTL8821C
4842
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
4843
if (pBtCoexist->board_info.btdm_ant_num == 2)
4844
ex_halbtc8821c2ant_periodical(pBtCoexist);
4845
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4846
ex_halbtc8821c1ant_periodical(pBtCoexist);
4847
}
4848
#endif
4849
4850
#ifdef CONFIG_RTL8814A
4851
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
4852
if (pBtCoexist->board_info.btdm_ant_num == 2)
4853
ex_halbtc8814a2ant_periodical(pBtCoexist);
4854
}
4855
#endif
4856
4857
#endif
4858
4859
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
4860
}
4861
4862
void EXhalbtcoutsrc_dbg_control(PBTC_COEXIST pBtCoexist, u8 opCode, u8 opLen, u8 *pData)
4863
{
4864
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4865
return;
4866
4867
pBtCoexist->statistics.cnt_dbg_ctrl++;
4868
4869
/* This function doesn't be called yet, */
4870
/* default no need to leave low power to avoid deadlock
4871
* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
4872
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
4873
/* rtw_btc_ex_dbg_control(pBtCoexist, opCode, opLen, pData); */
4874
#else
4875
4876
if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
4877
#ifdef CONFIG_RTL8192E
4878
if (pBtCoexist->board_info.btdm_ant_num == 1)
4879
ex_halbtc8192e1ant_dbg_control(pBtCoexist, opCode, opLen, pData);
4880
#endif
4881
}
4882
4883
#ifdef CONFIG_RTL8812A
4884
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
4885
if (pBtCoexist->board_info.btdm_ant_num == 2)
4886
ex_halbtc8812a2ant_dbg_control(pBtCoexist, opCode, opLen, pData);
4887
else if (pBtCoexist->board_info.btdm_ant_num == 1)
4888
ex_halbtc8812a1ant_dbg_control(pBtCoexist, opCode, opLen, pData);
4889
}
4890
#endif
4891
4892
#ifdef CONFIG_RTL8822B
4893
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter))
4894
if(pBtCoexist->board_info.btdm_ant_num == 1)
4895
ex_halbtc8822b1ant_dbg_control(pBtCoexist, opCode, opLen, pData);
4896
#endif
4897
4898
#endif
4899
4900
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
4901
}
4902
4903
#if 0
4904
void
4905
EXhalbtcoutsrc_AntennaDetection(
4906
PBTC_COEXIST pBtCoexist,
4907
u32 centFreq,
4908
u32 offset,
4909
u32 span,
4910
u32 seconds
4911
)
4912
{
4913
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4914
return;
4915
4916
/* Need to refine the following power save operations to enable this function in the future */
4917
#if 0
4918
IPSDisable(pBtCoexist->Adapter, FALSE, 0);
4919
LeisurePSLeave(pBtCoexist->Adapter, LPS_DISABLE_BT_COEX);
4920
#endif
4921
4922
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
4923
if (pBtCoexist->board_info.btdm_ant_num == 1)
4924
ex_halbtc8723b1ant_AntennaDetection(pBtCoexist, centFreq, offset, span, seconds);
4925
}
4926
4927
/* IPSReturn(pBtCoexist->Adapter, 0xff); */
4928
}
4929
#endif
4930
4931
void EXhalbtcoutsrc_StackUpdateProfileInfo(void)
4932
{
4933
#ifdef CONFIG_BT_COEXIST_SOCKET_TRX
4934
PBTC_COEXIST pBtCoexist = &GLBtCoexist;
4935
PADAPTER padapter = NULL;
4936
PBT_MGNT pBtMgnt = NULL;
4937
u8 i;
4938
4939
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4940
return;
4941
4942
padapter = (PADAPTER)pBtCoexist->Adapter;
4943
pBtMgnt = &padapter->coex_info.BtMgnt;
4944
4945
pBtCoexist->stack_info.profile_notified = _TRUE;
4946
4947
pBtCoexist->stack_info.num_of_link =
4948
pBtMgnt->ExtConfig.NumberOfACL + pBtMgnt->ExtConfig.NumberOfSCO;
4949
4950
/* reset first */
4951
pBtCoexist->stack_info.bt_link_exist = _FALSE;
4952
pBtCoexist->stack_info.sco_exist = _FALSE;
4953
pBtCoexist->stack_info.acl_exist = _FALSE;
4954
pBtCoexist->stack_info.a2dp_exist = _FALSE;
4955
pBtCoexist->stack_info.hid_exist = _FALSE;
4956
pBtCoexist->stack_info.num_of_hid = 0;
4957
pBtCoexist->stack_info.pan_exist = _FALSE;
4958
4959
if (!pBtMgnt->ExtConfig.NumberOfACL)
4960
pBtCoexist->stack_info.min_bt_rssi = 0;
4961
4962
if (pBtCoexist->stack_info.num_of_link) {
4963
pBtCoexist->stack_info.bt_link_exist = _TRUE;
4964
if (pBtMgnt->ExtConfig.NumberOfSCO)
4965
pBtCoexist->stack_info.sco_exist = _TRUE;
4966
if (pBtMgnt->ExtConfig.NumberOfACL)
4967
pBtCoexist->stack_info.acl_exist = _TRUE;
4968
}
4969
4970
for (i = 0; i < pBtMgnt->ExtConfig.NumberOfACL; i++) {
4971
if (BT_PROFILE_A2DP == pBtMgnt->ExtConfig.aclLink[i].BTProfile)
4972
pBtCoexist->stack_info.a2dp_exist = _TRUE;
4973
else if (BT_PROFILE_PAN == pBtMgnt->ExtConfig.aclLink[i].BTProfile)
4974
pBtCoexist->stack_info.pan_exist = _TRUE;
4975
else if (BT_PROFILE_HID == pBtMgnt->ExtConfig.aclLink[i].BTProfile) {
4976
pBtCoexist->stack_info.hid_exist = _TRUE;
4977
pBtCoexist->stack_info.num_of_hid++;
4978
} else
4979
pBtCoexist->stack_info.unknown_acl_exist = _TRUE;
4980
}
4981
#endif /* CONFIG_BT_COEXIST_SOCKET_TRX */
4982
}
4983
4984
void EXhalbtcoutsrc_UpdateMinBtRssi(s8 btRssi)
4985
{
4986
PBTC_COEXIST pBtCoexist = &GLBtCoexist;
4987
4988
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4989
return;
4990
4991
pBtCoexist->stack_info.min_bt_rssi = btRssi;
4992
}
4993
4994
void EXhalbtcoutsrc_SetHciVersion(u16 hciVersion)
4995
{
4996
PBTC_COEXIST pBtCoexist = &GLBtCoexist;
4997
4998
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
4999
return;
5000
5001
pBtCoexist->stack_info.hci_version = hciVersion;
5002
}
5003
5004
void EXhalbtcoutsrc_SetBtPatchVersion(u16 btHciVersion, u16 btPatchVersion)
5005
{
5006
PBTC_COEXIST pBtCoexist = &GLBtCoexist;
5007
5008
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
5009
return;
5010
5011
pBtCoexist->bt_info.bt_real_fw_ver = btPatchVersion;
5012
pBtCoexist->bt_info.bt_hci_ver = btHciVersion;
5013
}
5014
5015
#if 0
5016
void EXhalbtcoutsrc_SetBtExist(u8 bBtExist)
5017
{
5018
GLBtCoexist.boardInfo.bBtExist = bBtExist;
5019
}
5020
#endif
5021
void EXhalbtcoutsrc_SetChipType(u8 chipType)
5022
{
5023
switch (chipType) {
5024
default:
5025
case BT_2WIRE:
5026
case BT_ISSC_3WIRE:
5027
case BT_ACCEL:
5028
case BT_RTL8756:
5029
GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_UNDEF;
5030
break;
5031
case BT_CSR_BC4:
5032
GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
5033
break;
5034
case BT_CSR_BC8:
5035
GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
5036
break;
5037
case BT_RTL8723A:
5038
GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A;
5039
break;
5040
case BT_RTL8821:
5041
GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_RTL8821;
5042
break;
5043
case BT_RTL8723B:
5044
GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B;
5045
break;
5046
}
5047
}
5048
5049
void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum)
5050
{
5051
if (BT_COEX_ANT_TYPE_PG == type) {
5052
GLBtCoexist.board_info.pg_ant_num = antNum;
5053
GLBtCoexist.board_info.btdm_ant_num = antNum;
5054
#if 0
5055
/* The antenna position: Main (default) or Aux for pgAntNum=2 && btdmAntNum =1 */
5056
/* The antenna position should be determined by auto-detect mechanism */
5057
/* The following is assumed to main, and those must be modified if y auto-detect mechanism is ready */
5058
if ((GLBtCoexist.board_info.pg_ant_num == 2) && (GLBtCoexist.board_info.btdm_ant_num == 1))
5059
GLBtCoexist.board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
5060
else
5061
GLBtCoexist.board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
5062
#endif
5063
} else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
5064
GLBtCoexist.board_info.btdm_ant_num = antNum;
5065
/* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */
5066
} else if (BT_COEX_ANT_TYPE_DETECTED == type) {
5067
GLBtCoexist.board_info.btdm_ant_num = antNum;
5068
/* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */
5069
}
5070
}
5071
5072
/*
5073
* Currently used by 8723b only, S0 or S1
5074
* */
5075
void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath)
5076
{
5077
GLBtCoexist.board_info.single_ant_path = singleAntPath;
5078
}
5079
5080
void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist)
5081
{
5082
HAL_DATA_TYPE *pHalData = NULL;
5083
5084
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
5085
return;
5086
5087
halbtcoutsrc_LeaveLowPower(pBtCoexist);
5088
5089
/* To prevent the racing with IPS enter */
5090
halbtcoutsrc_EnterPwrLock(pBtCoexist);
5091
5092
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
5093
pHalData = GET_HAL_DATA((PADAPTER)pBtCoexist->Adapter);
5094
5095
if (pHalData->EEPROMBluetoothCoexist == _TRUE)
5096
rtw_btc_ex_display_coex_info(pBtCoexist);
5097
#else
5098
5099
if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
5100
#ifdef CONFIG_RTL8821A
5101
if (pBtCoexist->board_info.btdm_ant_num == 2)
5102
ex_halbtc8821a2ant_display_coex_info(pBtCoexist);
5103
else if (pBtCoexist->board_info.btdm_ant_num == 1)
5104
ex_halbtc8821a1ant_display_coex_info(pBtCoexist);
5105
#endif
5106
}
5107
5108
#ifdef CONFIG_RTL8723B
5109
else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
5110
if (pBtCoexist->board_info.btdm_ant_num == 2)
5111
ex_halbtc8723b2ant_display_coex_info(pBtCoexist);
5112
else if (pBtCoexist->board_info.btdm_ant_num == 1)
5113
ex_halbtc8723b1ant_display_coex_info(pBtCoexist);
5114
}
5115
#endif
5116
5117
#ifdef CONFIG_RTL8703B
5118
else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
5119
if (pBtCoexist->board_info.btdm_ant_num == 1)
5120
ex_halbtc8703b1ant_display_coex_info(pBtCoexist);
5121
}
5122
#endif
5123
5124
#ifdef CONFIG_RTL8723D
5125
else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
5126
if (pBtCoexist->board_info.btdm_ant_num == 2)
5127
ex_halbtc8723d2ant_display_coex_info(pBtCoexist);
5128
else if (pBtCoexist->board_info.btdm_ant_num == 1)
5129
ex_halbtc8723d1ant_display_coex_info(pBtCoexist);
5130
}
5131
#endif
5132
5133
#ifdef CONFIG_RTL8192E
5134
else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
5135
if (pBtCoexist->board_info.btdm_ant_num == 2)
5136
ex_halbtc8192e2ant_display_coex_info(pBtCoexist);
5137
else if (pBtCoexist->board_info.btdm_ant_num == 1)
5138
ex_halbtc8192e1ant_display_coex_info(pBtCoexist);
5139
}
5140
#endif
5141
5142
#ifdef CONFIG_RTL8812A
5143
else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
5144
if (pBtCoexist->board_info.btdm_ant_num == 2)
5145
ex_halbtc8812a2ant_display_coex_info(pBtCoexist);
5146
else if (pBtCoexist->board_info.btdm_ant_num == 1)
5147
ex_halbtc8812a1ant_display_coex_info(pBtCoexist);
5148
}
5149
#endif
5150
5151
#ifdef CONFIG_RTL8822B
5152
else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
5153
if (pBtCoexist->board_info.btdm_ant_num == 1)
5154
ex_halbtc8822b1ant_display_coex_info(pBtCoexist);
5155
else if (pBtCoexist->board_info.btdm_ant_num == 2)
5156
ex_halbtc8822b2ant_display_coex_info(pBtCoexist);
5157
}
5158
#endif
5159
5160
#ifdef CONFIG_RTL8821C
5161
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
5162
if (pBtCoexist->board_info.btdm_ant_num == 2)
5163
ex_halbtc8821c2ant_display_coex_info(pBtCoexist);
5164
else if (pBtCoexist->board_info.btdm_ant_num == 1)
5165
ex_halbtc8821c1ant_display_coex_info(pBtCoexist);
5166
}
5167
#endif
5168
5169
#ifdef CONFIG_RTL8814A
5170
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
5171
if (pBtCoexist->board_info.btdm_ant_num == 2)
5172
ex_halbtc8814a2ant_display_coex_info(pBtCoexist);
5173
}
5174
#endif
5175
5176
#endif
5177
5178
halbtcoutsrc_ExitPwrLock(pBtCoexist);
5179
5180
halbtcoutsrc_NormalLowPower(pBtCoexist);
5181
}
5182
5183
void EXhalbtcoutsrc_DisplayAntDetection(PBTC_COEXIST pBtCoexist)
5184
{
5185
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
5186
return;
5187
5188
halbtcoutsrc_LeaveLowPower(pBtCoexist);
5189
5190
if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
5191
#ifdef CONFIG_RTL8723B
5192
if (pBtCoexist->board_info.btdm_ant_num == 1)
5193
ex_halbtc8723b1ant_display_ant_detection(pBtCoexist);
5194
#endif
5195
}
5196
5197
halbtcoutsrc_NormalLowPower(pBtCoexist);
5198
}
5199
5200
void ex_halbtcoutsrc_pta_off_on_notify(PBTC_COEXIST pBtCoexist, u8 bBTON)
5201
{
5202
if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
5203
#ifdef CONFIG_RTL8812A
5204
if (pBtCoexist->board_info.btdm_ant_num == 2)
5205
ex_halbtc8812a2ant_pta_off_on_notify(pBtCoexist, (bBTON == _TRUE) ? BTC_BT_ON : BTC_BT_OFF);
5206
#endif
5207
}
5208
5209
#ifdef CONFIG_RTL8814A
5210
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
5211
if (pBtCoexist->board_info.btdm_ant_num == 2)
5212
ex_halbtc8814a2ant_pta_off_on_notify(pBtCoexist, (bBTON == _TRUE) ? BTC_BT_ON : BTC_BT_OFF);
5213
}
5214
#endif
5215
}
5216
5217
void EXhalbtcoutsrc_set_rfe_type(u8 type)
5218
{
5219
GLBtCoexist.board_info.rfe_type= type;
5220
}
5221
5222
#ifdef CONFIG_RF4CE_COEXIST
5223
void EXhalbtcoutsrc_set_rf4ce_link_state(u8 state)
5224
{
5225
GLBtCoexist.rf4ce_info.link_state = state;
5226
}
5227
5228
u8 EXhalbtcoutsrc_get_rf4ce_link_state(void)
5229
{
5230
return GLBtCoexist.rf4ce_info.link_state;
5231
}
5232
#endif
5233
5234
void EXhalbtcoutsrc_switchband_notify(struct btc_coexist *pBtCoexist, u8 type)
5235
{
5236
if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
5237
return;
5238
5239
if(pBtCoexist->manual_control)
5240
return;
5241
5242
/* Driver should guarantee that the HW status isn't in low power mode */
5243
/* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
5244
#if (CONFIG_BTCOEX_SUPPORT_BTC_CMN == 1)
5245
rtw_btc_ex_switchband_notify(pBtCoexist, type);
5246
#else
5247
5248
if(IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
5249
#ifdef CONFIG_RTL8822B
5250
if(pBtCoexist->board_info.btdm_ant_num == 1)
5251
ex_halbtc8822b1ant_switchband_notify(pBtCoexist, type);
5252
else if(pBtCoexist->board_info.btdm_ant_num == 2)
5253
ex_halbtc8822b2ant_switchband_notify(pBtCoexist, type);
5254
#endif
5255
}
5256
5257
#ifdef CONFIG_RTL8821C
5258
else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
5259
if (pBtCoexist->board_info.btdm_ant_num == 2)
5260
ex_halbtc8821c2ant_switchband_notify(pBtCoexist, type);
5261
else if (pBtCoexist->board_info.btdm_ant_num == 1)
5262
ex_halbtc8821c1ant_switchband_notify(pBtCoexist, type);
5263
}
5264
#endif
5265
5266
#ifdef CONFIG_RTL8814A
5267
else if (IS_HARDWARE_TYPE_8814A(pBtCoexist->Adapter)) {
5268
if (pBtCoexist->board_info.btdm_ant_num == 2)
5269
ex_halbtc8814a2ant_switchband_notify(pBtCoexist, type);
5270
}
5271
#endif
5272
5273
#endif
5274
5275
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
5276
}
5277
5278
u8 EXhalbtcoutsrc_rate_id_to_btc_rate_id(u8 rate_id)
5279
{
5280
u8 btc_rate_id = BTC_UNKNOWN;
5281
5282
switch (rate_id) {
5283
/* CCK rates */
5284
case DESC_RATE1M:
5285
btc_rate_id = BTC_CCK_1;
5286
break;
5287
case DESC_RATE2M:
5288
btc_rate_id = BTC_CCK_2;
5289
break;
5290
case DESC_RATE5_5M:
5291
btc_rate_id = BTC_CCK_5_5;
5292
break;
5293
case DESC_RATE11M:
5294
btc_rate_id = BTC_CCK_11;
5295
break;
5296
5297
/* OFDM rates */
5298
case DESC_RATE6M:
5299
btc_rate_id = BTC_OFDM_6;
5300
break;
5301
case DESC_RATE9M:
5302
btc_rate_id = BTC_OFDM_9;
5303
break;
5304
case DESC_RATE12M:
5305
btc_rate_id = BTC_OFDM_12;
5306
break;
5307
case DESC_RATE18M:
5308
btc_rate_id = BTC_OFDM_18;
5309
break;
5310
case DESC_RATE24M:
5311
btc_rate_id = BTC_OFDM_24;
5312
break;
5313
case DESC_RATE36M:
5314
btc_rate_id = BTC_OFDM_36;
5315
break;
5316
case DESC_RATE48M:
5317
btc_rate_id = BTC_OFDM_48;
5318
break;
5319
case DESC_RATE54M:
5320
btc_rate_id = BTC_OFDM_54;
5321
break;
5322
5323
/* MCS rates */
5324
case DESC_RATEMCS0:
5325
btc_rate_id = BTC_MCS_0;
5326
break;
5327
case DESC_RATEMCS1:
5328
btc_rate_id = BTC_MCS_1;
5329
break;
5330
case DESC_RATEMCS2:
5331
btc_rate_id = BTC_MCS_2;
5332
break;
5333
case DESC_RATEMCS3:
5334
btc_rate_id = BTC_MCS_3;
5335
break;
5336
case DESC_RATEMCS4:
5337
btc_rate_id = BTC_MCS_4;
5338
break;
5339
case DESC_RATEMCS5:
5340
btc_rate_id = BTC_MCS_5;
5341
break;
5342
case DESC_RATEMCS6:
5343
btc_rate_id = BTC_MCS_6;
5344
break;
5345
case DESC_RATEMCS7:
5346
btc_rate_id = BTC_MCS_7;
5347
break;
5348
case DESC_RATEMCS8:
5349
btc_rate_id = BTC_MCS_8;
5350
break;
5351
case DESC_RATEMCS9:
5352
btc_rate_id = BTC_MCS_9;
5353
break;
5354
case DESC_RATEMCS10:
5355
btc_rate_id = BTC_MCS_10;
5356
break;
5357
case DESC_RATEMCS11:
5358
btc_rate_id = BTC_MCS_11;
5359
break;
5360
case DESC_RATEMCS12:
5361
btc_rate_id = BTC_MCS_12;
5362
break;
5363
case DESC_RATEMCS13:
5364
btc_rate_id = BTC_MCS_13;
5365
break;
5366
case DESC_RATEMCS14:
5367
btc_rate_id = BTC_MCS_14;
5368
break;
5369
case DESC_RATEMCS15:
5370
btc_rate_id = BTC_MCS_15;
5371
break;
5372
case DESC_RATEMCS16:
5373
btc_rate_id = BTC_MCS_16;
5374
break;
5375
case DESC_RATEMCS17:
5376
btc_rate_id = BTC_MCS_17;
5377
break;
5378
case DESC_RATEMCS18:
5379
btc_rate_id = BTC_MCS_18;
5380
break;
5381
case DESC_RATEMCS19:
5382
btc_rate_id = BTC_MCS_19;
5383
break;
5384
case DESC_RATEMCS20:
5385
btc_rate_id = BTC_MCS_20;
5386
break;
5387
case DESC_RATEMCS21:
5388
btc_rate_id = BTC_MCS_21;
5389
break;
5390
case DESC_RATEMCS22:
5391
btc_rate_id = BTC_MCS_22;
5392
break;
5393
case DESC_RATEMCS23:
5394
btc_rate_id = BTC_MCS_23;
5395
break;
5396
case DESC_RATEMCS24:
5397
btc_rate_id = BTC_MCS_24;
5398
break;
5399
case DESC_RATEMCS25:
5400
btc_rate_id = BTC_MCS_25;
5401
break;
5402
case DESC_RATEMCS26:
5403
btc_rate_id = BTC_MCS_26;
5404
break;
5405
case DESC_RATEMCS27:
5406
btc_rate_id = BTC_MCS_27;
5407
break;
5408
case DESC_RATEMCS28:
5409
btc_rate_id = BTC_MCS_28;
5410
break;
5411
case DESC_RATEMCS29:
5412
btc_rate_id = BTC_MCS_29;
5413
break;
5414
case DESC_RATEMCS30:
5415
btc_rate_id = BTC_MCS_30;
5416
break;
5417
case DESC_RATEMCS31:
5418
btc_rate_id = BTC_MCS_31;
5419
break;
5420
5421
case DESC_RATEVHTSS1MCS0:
5422
btc_rate_id = BTC_VHT_1SS_MCS_0;
5423
break;
5424
case DESC_RATEVHTSS1MCS1:
5425
btc_rate_id = BTC_VHT_1SS_MCS_1;
5426
break;
5427
case DESC_RATEVHTSS1MCS2:
5428
btc_rate_id = BTC_VHT_1SS_MCS_2;
5429
break;
5430
case DESC_RATEVHTSS1MCS3:
5431
btc_rate_id = BTC_VHT_1SS_MCS_3;
5432
break;
5433
case DESC_RATEVHTSS1MCS4:
5434
btc_rate_id = BTC_VHT_1SS_MCS_4;
5435
break;
5436
case DESC_RATEVHTSS1MCS5:
5437
btc_rate_id = BTC_VHT_1SS_MCS_5;
5438
break;
5439
case DESC_RATEVHTSS1MCS6:
5440
btc_rate_id = BTC_VHT_1SS_MCS_6;
5441
break;
5442
case DESC_RATEVHTSS1MCS7:
5443
btc_rate_id = BTC_VHT_1SS_MCS_7;
5444
break;
5445
case DESC_RATEVHTSS1MCS8:
5446
btc_rate_id = BTC_VHT_1SS_MCS_8;
5447
break;
5448
case DESC_RATEVHTSS1MCS9:
5449
btc_rate_id = BTC_VHT_1SS_MCS_9;
5450
break;
5451
5452
case DESC_RATEVHTSS2MCS0:
5453
btc_rate_id = BTC_VHT_2SS_MCS_0;
5454
break;
5455
case DESC_RATEVHTSS2MCS1:
5456
btc_rate_id = BTC_VHT_2SS_MCS_1;
5457
break;
5458
case DESC_RATEVHTSS2MCS2:
5459
btc_rate_id = BTC_VHT_2SS_MCS_2;
5460
break;
5461
case DESC_RATEVHTSS2MCS3:
5462
btc_rate_id = BTC_VHT_2SS_MCS_3;
5463
break;
5464
case DESC_RATEVHTSS2MCS4:
5465
btc_rate_id = BTC_VHT_2SS_MCS_4;
5466
break;
5467
case DESC_RATEVHTSS2MCS5:
5468
btc_rate_id = BTC_VHT_2SS_MCS_5;
5469
break;
5470
case DESC_RATEVHTSS2MCS6:
5471
btc_rate_id = BTC_VHT_2SS_MCS_6;
5472
break;
5473
case DESC_RATEVHTSS2MCS7:
5474
btc_rate_id = BTC_VHT_2SS_MCS_7;
5475
break;
5476
case DESC_RATEVHTSS2MCS8:
5477
btc_rate_id = BTC_VHT_2SS_MCS_8;
5478
break;
5479
case DESC_RATEVHTSS2MCS9:
5480
btc_rate_id = BTC_VHT_2SS_MCS_9;
5481
break;
5482
5483
case DESC_RATEVHTSS3MCS0:
5484
btc_rate_id = BTC_VHT_3SS_MCS_0;
5485
break;
5486
case DESC_RATEVHTSS3MCS1:
5487
btc_rate_id = BTC_VHT_3SS_MCS_1;
5488
break;
5489
case DESC_RATEVHTSS3MCS2:
5490
btc_rate_id = BTC_VHT_3SS_MCS_2;
5491
break;
5492
case DESC_RATEVHTSS3MCS3:
5493
btc_rate_id = BTC_VHT_3SS_MCS_3;
5494
break;
5495
case DESC_RATEVHTSS3MCS4:
5496
btc_rate_id = BTC_VHT_3SS_MCS_4;
5497
break;
5498
case DESC_RATEVHTSS3MCS5:
5499
btc_rate_id = BTC_VHT_3SS_MCS_5;
5500
break;
5501
case DESC_RATEVHTSS3MCS6:
5502
btc_rate_id = BTC_VHT_3SS_MCS_6;
5503
break;
5504
case DESC_RATEVHTSS3MCS7:
5505
btc_rate_id = BTC_VHT_3SS_MCS_7;
5506
break;
5507
case DESC_RATEVHTSS3MCS8:
5508
btc_rate_id = BTC_VHT_3SS_MCS_8;
5509
break;
5510
case DESC_RATEVHTSS3MCS9:
5511
btc_rate_id = BTC_VHT_3SS_MCS_9;
5512
break;
5513
5514
case DESC_RATEVHTSS4MCS0:
5515
btc_rate_id = BTC_VHT_4SS_MCS_0;
5516
break;
5517
case DESC_RATEVHTSS4MCS1:
5518
btc_rate_id = BTC_VHT_4SS_MCS_1;
5519
break;
5520
case DESC_RATEVHTSS4MCS2:
5521
btc_rate_id = BTC_VHT_4SS_MCS_2;
5522
break;
5523
case DESC_RATEVHTSS4MCS3:
5524
btc_rate_id = BTC_VHT_4SS_MCS_3;
5525
break;
5526
case DESC_RATEVHTSS4MCS4:
5527
btc_rate_id = BTC_VHT_4SS_MCS_4;
5528
break;
5529
case DESC_RATEVHTSS4MCS5:
5530
btc_rate_id = BTC_VHT_4SS_MCS_5;
5531
break;
5532
case DESC_RATEVHTSS4MCS6:
5533
btc_rate_id = BTC_VHT_4SS_MCS_6;
5534
break;
5535
case DESC_RATEVHTSS4MCS7:
5536
btc_rate_id = BTC_VHT_4SS_MCS_7;
5537
break;
5538
case DESC_RATEVHTSS4MCS8:
5539
btc_rate_id = BTC_VHT_4SS_MCS_8;
5540
break;
5541
case DESC_RATEVHTSS4MCS9:
5542
btc_rate_id = BTC_VHT_4SS_MCS_9;
5543
break;
5544
}
5545
5546
return btc_rate_id;
5547
}
5548
5549
/*
5550
* Description:
5551
* Run BT-Coexist mechansim or not
5552
*
5553
*/
5554
void hal_btcoex_SetBTCoexist(PADAPTER padapter, u8 bBtExist)
5555
{
5556
PHAL_DATA_TYPE pHalData;
5557
5558
5559
pHalData = GET_HAL_DATA(padapter);
5560
pHalData->bt_coexist.bBtExist = bBtExist;
5561
}
5562
5563
/*
5564
* Dewcription:
5565
* Check is co-exist mechanism enabled or not
5566
*
5567
* Return:
5568
* _TRUE Enable BT co-exist mechanism
5569
* _FALSE Disable BT co-exist mechanism
5570
*/
5571
u8 hal_btcoex_IsBtExist(PADAPTER padapter)
5572
{
5573
PHAL_DATA_TYPE pHalData;
5574
5575
5576
pHalData = GET_HAL_DATA(padapter);
5577
return pHalData->bt_coexist.bBtExist;
5578
}
5579
5580
u8 hal_btcoex_IsBtDisabled(PADAPTER padapter)
5581
{
5582
if (!hal_btcoex_IsBtExist(padapter))
5583
return _TRUE;
5584
5585
if (GLBtCoexist.bt_info.bt_disabled)
5586
return _TRUE;
5587
else
5588
return _FALSE;
5589
}
5590
5591
void hal_btcoex_SetChipType(PADAPTER padapter, u8 chipType)
5592
{
5593
PHAL_DATA_TYPE pHalData;
5594
5595
pHalData = GET_HAL_DATA(padapter);
5596
pHalData->bt_coexist.btChipType = chipType;
5597
}
5598
5599
void hal_btcoex_SetPgAntNum(PADAPTER padapter, u8 antNum)
5600
{
5601
PHAL_DATA_TYPE pHalData;
5602
5603
pHalData = GET_HAL_DATA(padapter);
5604
5605
pHalData->bt_coexist.btTotalAntNum = antNum;
5606
}
5607
5608
u8 hal_btcoex_Initialize(PADAPTER padapter)
5609
{
5610
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
5611
u8 ret;
5612
5613
_rtw_memset(&GLBtCoexist, 0, sizeof(GLBtCoexist));
5614
5615
ret = EXhalbtcoutsrc_InitlizeVariables((void *)padapter);
5616
5617
return ret;
5618
}
5619
5620
void hal_btcoex_PowerOnSetting(PADAPTER padapter)
5621
{
5622
EXhalbtcoutsrc_PowerOnSetting(&GLBtCoexist);
5623
}
5624
5625
void hal_btcoex_AntInfoSetting(PADAPTER padapter)
5626
{
5627
hal_btcoex_SetBTCoexist(padapter, rtw_btcoex_get_bt_coexist(padapter));
5628
hal_btcoex_SetChipType(padapter, rtw_btcoex_get_chip_type(padapter));
5629
hal_btcoex_SetPgAntNum(padapter, rtw_btcoex_get_pg_ant_num(padapter));
5630
5631
EXhalbtcoutsrc_AntInfoSetting(padapter);
5632
}
5633
5634
void hal_btcoex_PowerOffSetting(PADAPTER padapter)
5635
{
5636
/* Clear the WiFi on/off bit in scoreboard reg. if necessary */
5637
if (IS_HARDWARE_TYPE_8703B(padapter) || IS_HARDWARE_TYPE_8723D(padapter)
5638
|| IS_HARDWARE_TYPE_8821C(padapter) || IS_HARDWARE_TYPE_8822B(padapter)
5639
|| IS_HARDWARE_TYPE_8822C(padapter))
5640
rtw_write16(padapter, 0xaa, 0x8000);
5641
}
5642
5643
void hal_btcoex_PreLoadFirmware(PADAPTER padapter)
5644
{
5645
EXhalbtcoutsrc_PreLoadFirmware(&GLBtCoexist);
5646
}
5647
5648
void hal_btcoex_InitHwConfig(PADAPTER padapter, u8 bWifiOnly)
5649
{
5650
if (!hal_btcoex_IsBtExist(padapter))
5651
return;
5652
5653
EXhalbtcoutsrc_init_hw_config(&GLBtCoexist, bWifiOnly);
5654
EXhalbtcoutsrc_init_coex_dm(&GLBtCoexist);
5655
}
5656
5657
void hal_btcoex_IpsNotify(PADAPTER padapter, u8 type)
5658
{
5659
EXhalbtcoutsrc_ips_notify(&GLBtCoexist, type);
5660
}
5661
5662
void hal_btcoex_LpsNotify(PADAPTER padapter, u8 type)
5663
{
5664
EXhalbtcoutsrc_lps_notify(&GLBtCoexist, type);
5665
}
5666
5667
void hal_btcoex_ScanNotify(PADAPTER padapter, u8 type)
5668
{
5669
EXhalbtcoutsrc_scan_notify(&GLBtCoexist, type);
5670
}
5671
5672
void hal_btcoex_ConnectNotify(PADAPTER padapter, u8 action)
5673
{
5674
u8 assoType = 0;
5675
u8 is_5g_band = _FALSE;
5676
5677
is_5g_band = (padapter->mlmeextpriv.cur_channel > 14) ? _TRUE : _FALSE;
5678
5679
if (action == _TRUE) {
5680
if (is_5g_band == _TRUE)
5681
assoType = BTC_ASSOCIATE_5G_START;
5682
else
5683
assoType = BTC_ASSOCIATE_START;
5684
}
5685
else {
5686
if (is_5g_band == _TRUE)
5687
assoType = BTC_ASSOCIATE_5G_FINISH;
5688
else
5689
assoType = BTC_ASSOCIATE_FINISH;
5690
}
5691
5692
EXhalbtcoutsrc_connect_notify(&GLBtCoexist, assoType);
5693
}
5694
5695
void hal_btcoex_MediaStatusNotify(PADAPTER padapter, u8 mediaStatus)
5696
{
5697
EXhalbtcoutsrc_media_status_notify(&GLBtCoexist, mediaStatus);
5698
}
5699
5700
void hal_btcoex_SpecialPacketNotify(PADAPTER padapter, u8 pktType)
5701
{
5702
EXhalbtcoutsrc_specific_packet_notify(&GLBtCoexist, pktType);
5703
}
5704
5705
void hal_btcoex_IQKNotify(PADAPTER padapter, u8 state)
5706
{
5707
GLBtcWiFiInIQKState = state;
5708
}
5709
5710
void hal_btcoex_BtInfoNotify(PADAPTER padapter, u8 length, u8 *tmpBuf)
5711
{
5712
if (GLBtcWiFiInIQKState == _TRUE)
5713
return;
5714
5715
EXhalbtcoutsrc_bt_info_notify(&GLBtCoexist, tmpBuf, length);
5716
}
5717
5718
void hal_btcoex_BtMpRptNotify(PADAPTER padapter, u8 length, u8 *tmpBuf)
5719
{
5720
u8 extid, status, len, seq;
5721
5722
5723
if (GLBtcBtMpRptWait == _FALSE)
5724
return;
5725
5726
if ((length < 3) || (!tmpBuf))
5727
return;
5728
5729
extid = tmpBuf[0];
5730
/* not response from BT FW then exit*/
5731
switch (extid) {
5732
case C2H_WIFI_FW_ACTIVE_RSP:
5733
GLBtcBtMpRptWiFiOK = _TRUE;
5734
break;
5735
5736
case C2H_TRIG_BY_BT_FW:
5737
GLBtcBtMpRptBTOK = _TRUE;
5738
5739
status = tmpBuf[1] & 0xF;
5740
len = length - 3;
5741
seq = tmpBuf[2] >> 4;
5742
5743
GLBtcBtMpRptSeq = seq;
5744
GLBtcBtMpRptStatus = status;
5745
_rtw_memcpy(GLBtcBtMpRptRsp, tmpBuf + 3, len);
5746
GLBtcBtMpRptRspSize = len;
5747
5748
break;
5749
5750
default:
5751
return;
5752
}
5753
5754
if ((GLBtcBtMpRptWiFiOK == _TRUE) && (GLBtcBtMpRptBTOK == _TRUE)) {
5755
GLBtcBtMpRptWait = _FALSE;
5756
_cancel_timer_ex(&GLBtcBtMpOperTimer);
5757
_rtw_up_sema(&GLBtcBtMpRptSema);
5758
}
5759
}
5760
5761
void hal_btcoex_SuspendNotify(PADAPTER padapter, u8 state)
5762
{
5763
switch (state) {
5764
case BTCOEX_SUSPEND_STATE_SUSPEND:
5765
EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_SLEEP);
5766
break;
5767
case BTCOEX_SUSPEND_STATE_SUSPEND_KEEP_ANT:
5768
/* should switch to "#if 1" once all ICs' coex. revision are upgraded to support the KEEP_ANT case */
5769
#if 0
5770
EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_SLEEP_KEEP_ANT);
5771
#else
5772
EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_SLEEP);
5773
EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_SLEEP_KEEP_ANT);
5774
#endif
5775
break;
5776
case BTCOEX_SUSPEND_STATE_RESUME:
5777
#ifdef CONFIG_FW_MULTI_PORT_SUPPORT
5778
/* re-download FW after resume, inform WL FW port number */
5779
rtw_hal_set_wifi_btc_port_id_cmd(GLBtCoexist.Adapter);
5780
#endif
5781
EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_WAKE_UP);
5782
break;
5783
}
5784
}
5785
5786
void hal_btcoex_HaltNotify(PADAPTER padapter, u8 do_halt)
5787
{
5788
if (do_halt == 1)
5789
EXhalbtcoutsrc_halt_notify(&GLBtCoexist);
5790
5791
GLBtCoexist.bBinded = _FALSE;
5792
GLBtCoexist.Adapter = NULL;
5793
}
5794
5795
void hal_btcoex_SwitchBtTRxMask(PADAPTER padapter)
5796
{
5797
EXhalbtcoutsrc_SwitchBtTRxMask(&GLBtCoexist);
5798
}
5799
5800
void hal_btcoex_Hanlder(PADAPTER padapter)
5801
{
5802
u32 bt_patch_ver;
5803
5804
EXhalbtcoutsrc_periodical(&GLBtCoexist);
5805
5806
if (GLBtCoexist.bt_info.bt_get_fw_ver == 0) {
5807
GLBtCoexist.btc_get(&GLBtCoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
5808
GLBtCoexist.bt_info.bt_get_fw_ver = bt_patch_ver;
5809
}
5810
}
5811
5812
s32 hal_btcoex_IsBTCoexRejectAMPDU(PADAPTER padapter)
5813
{
5814
return (s32)GLBtCoexist.bt_info.reject_agg_pkt;
5815
}
5816
5817
s32 hal_btcoex_IsBTCoexCtrlAMPDUSize(PADAPTER padapter)
5818
{
5819
return (s32)GLBtCoexist.bt_info.bt_ctrl_agg_buf_size;
5820
}
5821
5822
u32 hal_btcoex_GetAMPDUSize(PADAPTER padapter)
5823
{
5824
return (u32)GLBtCoexist.bt_info.agg_buf_size;
5825
}
5826
5827
void hal_btcoex_SetManualControl(PADAPTER padapter, u8 bmanual)
5828
{
5829
GLBtCoexist.manual_control = bmanual;
5830
}
5831
5832
u8 hal_btcoex_1Ant(PADAPTER padapter)
5833
{
5834
if (hal_btcoex_IsBtExist(padapter) == _FALSE)
5835
return _FALSE;
5836
5837
if (GLBtCoexist.board_info.btdm_ant_num == 1)
5838
return _TRUE;
5839
5840
return _FALSE;
5841
}
5842
5843
u8 hal_btcoex_IsBtControlLps(PADAPTER padapter)
5844
{
5845
if (GLBtCoexist.bdontenterLPS == _TRUE)
5846
return _TRUE;
5847
5848
if (hal_btcoex_IsBtExist(padapter) == _FALSE)
5849
return _FALSE;
5850
5851
if (GLBtCoexist.bt_info.bt_disabled)
5852
return _FALSE;
5853
5854
if (GLBtCoexist.bt_info.bt_ctrl_lps)
5855
return _TRUE;
5856
5857
return _FALSE;
5858
}
5859
5860
u8 hal_btcoex_IsLpsOn(PADAPTER padapter)
5861
{
5862
if (GLBtCoexist.bdontenterLPS == _TRUE)
5863
return _FALSE;
5864
5865
if (hal_btcoex_IsBtExist(padapter) == _FALSE)
5866
return _FALSE;
5867
5868
if (GLBtCoexist.bt_info.bt_disabled)
5869
return _FALSE;
5870
5871
if (GLBtCoexist.bt_info.bt_lps_on)
5872
return _TRUE;
5873
5874
return _FALSE;
5875
}
5876
5877
u8 hal_btcoex_RpwmVal(PADAPTER padapter)
5878
{
5879
return GLBtCoexist.bt_info.rpwm_val;
5880
}
5881
5882
u8 hal_btcoex_LpsVal(PADAPTER padapter)
5883
{
5884
return GLBtCoexist.bt_info.lps_val;
5885
}
5886
5887
u32 hal_btcoex_GetRaMask(PADAPTER padapter)
5888
{
5889
if (!hal_btcoex_IsBtExist(padapter))
5890
return 0;
5891
5892
if (GLBtCoexist.bt_info.bt_disabled)
5893
return 0;
5894
5895
/* Modify by YiWei , suggest by Cosa and Jenyu
5896
* Remove the limit antenna number , because 2 antenna case (ex: 8192eu)also want to get BT coex report rate mask.
5897
*/
5898
/*if (GLBtCoexist.board_info.btdm_ant_num != 1)
5899
return 0;*/
5900
5901
return GLBtCoexist.bt_info.ra_mask;
5902
}
5903
5904
u8 hal_btcoex_query_reduced_wl_pwr_lvl(PADAPTER padapter)
5905
{
5906
return GLBtCoexist.coex_dm.cur_wl_pwr_lvl;
5907
}
5908
5909
void hal_btcoex_set_reduced_wl_pwr_lvl(PADAPTER padapter, u8 val)
5910
{
5911
GLBtCoexist.coex_dm.cur_wl_pwr_lvl = val;
5912
}
5913
5914
void hal_btcoex_do_reduce_wl_pwr_lvl(PADAPTER padapter)
5915
{
5916
halbtcoutsrc_reduce_wl_tx_power(&GLBtCoexist, 0);
5917
}
5918
5919
void hal_btcoex_RecordPwrMode(PADAPTER padapter, u8 *pCmdBuf, u8 cmdLen)
5920
{
5921
5922
_rtw_memcpy(GLBtCoexist.pwrModeVal, pCmdBuf, cmdLen);
5923
}
5924
5925
void hal_btcoex_DisplayBtCoexInfo(PADAPTER padapter, u8 *pbuf, u32 bufsize)
5926
{
5927
PBTCDBGINFO pinfo;
5928
5929
5930
pinfo = &GLBtcDbgInfo;
5931
DBG_BT_INFO_INIT(pinfo, pbuf, bufsize);
5932
EXhalbtcoutsrc_DisplayBtCoexInfo(&GLBtCoexist);
5933
DBG_BT_INFO_INIT(pinfo, NULL, 0);
5934
}
5935
5936
void hal_btcoex_SetDBG(PADAPTER padapter, u32 *pDbgModule)
5937
{
5938
u32 i;
5939
5940
5941
if (NULL == pDbgModule)
5942
return;
5943
5944
for (i = 0; i < COMP_MAX; i++)
5945
GLBtcDbgType[i] = pDbgModule[i];
5946
}
5947
5948
u32 hal_btcoex_GetDBG(PADAPTER padapter, u8 *pStrBuf, u32 bufSize)
5949
{
5950
s32 count;
5951
u8 *pstr;
5952
u32 leftSize;
5953
5954
5955
if ((NULL == pStrBuf) || (0 == bufSize))
5956
return 0;
5957
5958
count = 0;
5959
pstr = pStrBuf;
5960
leftSize = bufSize;
5961
/* RTW_INFO(FUNC_ADPT_FMT ": bufsize=%d\n", FUNC_ADPT_ARG(padapter), bufSize); */
5962
5963
count = rtw_sprintf(pstr, leftSize, "#define DBG\t%d\n", DBG);
5964
if ((count < 0) || (count >= leftSize))
5965
goto exit;
5966
pstr += count;
5967
leftSize -= count;
5968
5969
count = rtw_sprintf(pstr, leftSize, "BTCOEX Debug Setting:\n");
5970
if ((count < 0) || (count >= leftSize))
5971
goto exit;
5972
pstr += count;
5973
leftSize -= count;
5974
5975
count = rtw_sprintf(pstr, leftSize,
5976
"COMP_COEX: 0x%08X\n\n",
5977
GLBtcDbgType[COMP_COEX]);
5978
if ((count < 0) || (count >= leftSize))
5979
goto exit;
5980
pstr += count;
5981
leftSize -= count;
5982
5983
#if 0
5984
count = rtw_sprintf(pstr, leftSize, "INTERFACE Debug Setting Definition:\n");
5985
if ((count < 0) || (count >= leftSize))
5986
goto exit;
5987
pstr += count;
5988
leftSize -= count;
5989
count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for INTF_INIT\n",
5990
GLBtcDbgType[BTC_MSG_INTERFACE] & INTF_INIT ? 1 : 0);
5991
if ((count < 0) || (count >= leftSize))
5992
goto exit;
5993
pstr += count;
5994
leftSize -= count;
5995
count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for INTF_NOTIFY\n\n",
5996
GLBtcDbgType[BTC_MSG_INTERFACE] & INTF_NOTIFY ? 1 : 0);
5997
if ((count < 0) || (count >= leftSize))
5998
goto exit;
5999
pstr += count;
6000
leftSize -= count;
6001
6002
count = rtw_sprintf(pstr, leftSize, "ALGORITHM Debug Setting Definition:\n");
6003
if ((count < 0) || (count >= leftSize))
6004
goto exit;
6005
pstr += count;
6006
leftSize -= count;
6007
count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for BT_RSSI_STATE\n",
6008
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_BT_RSSI_STATE ? 1 : 0);
6009
if ((count < 0) || (count >= leftSize))
6010
goto exit;
6011
pstr += count;
6012
leftSize -= count;
6013
count = rtw_sprintf(pstr, leftSize, "\tbit[1]=%d for WIFI_RSSI_STATE\n",
6014
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_WIFI_RSSI_STATE ? 1 : 0);
6015
if ((count < 0) || (count >= leftSize))
6016
goto exit;
6017
pstr += count;
6018
leftSize -= count;
6019
count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for BT_MONITOR\n",
6020
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_BT_MONITOR ? 1 : 0);
6021
if ((count < 0) || (count >= leftSize))
6022
goto exit;
6023
pstr += count;
6024
leftSize -= count;
6025
count = rtw_sprintf(pstr, leftSize, "\tbit[3]=%d for TRACE\n",
6026
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE ? 1 : 0);
6027
if ((count < 0) || (count >= leftSize))
6028
goto exit;
6029
pstr += count;
6030
leftSize -= count;
6031
count = rtw_sprintf(pstr, leftSize, "\tbit[4]=%d for TRACE_FW\n",
6032
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_FW ? 1 : 0);
6033
if ((count < 0) || (count >= leftSize))
6034
goto exit;
6035
pstr += count;
6036
leftSize -= count;
6037
count = rtw_sprintf(pstr, leftSize, "\tbit[5]=%d for TRACE_FW_DETAIL\n",
6038
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_FW_DETAIL ? 1 : 0);
6039
if ((count < 0) || (count >= leftSize))
6040
goto exit;
6041
pstr += count;
6042
leftSize -= count;
6043
count = rtw_sprintf(pstr, leftSize, "\tbit[6]=%d for TRACE_FW_EXEC\n",
6044
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_FW_EXEC ? 1 : 0);
6045
if ((count < 0) || (count >= leftSize))
6046
goto exit;
6047
pstr += count;
6048
leftSize -= count;
6049
count = rtw_sprintf(pstr, leftSize, "\tbit[7]=%d for TRACE_SW\n",
6050
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_SW ? 1 : 0);
6051
if ((count < 0) || (count >= leftSize))
6052
goto exit;
6053
pstr += count;
6054
leftSize -= count;
6055
count = rtw_sprintf(pstr, leftSize, "\tbit[8]=%d for TRACE_SW_DETAIL\n",
6056
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_SW_DETAIL ? 1 : 0);
6057
if ((count < 0) || (count >= leftSize))
6058
goto exit;
6059
pstr += count;
6060
leftSize -= count;
6061
count = rtw_sprintf(pstr, leftSize, "\tbit[9]=%d for TRACE_SW_EXEC\n",
6062
GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_SW_EXEC ? 1 : 0);
6063
if ((count < 0) || (count >= leftSize))
6064
goto exit;
6065
pstr += count;
6066
leftSize -= count;
6067
#endif
6068
6069
exit:
6070
count = pstr - pStrBuf;
6071
/* RTW_INFO(FUNC_ADPT_FMT ": usedsize=%d\n", FUNC_ADPT_ARG(padapter), count); */
6072
6073
return count;
6074
}
6075
6076
u8 hal_btcoex_IncreaseScanDeviceNum(PADAPTER padapter)
6077
{
6078
if (!hal_btcoex_IsBtExist(padapter))
6079
return _FALSE;
6080
6081
if (GLBtCoexist.bt_info.increase_scan_dev_num)
6082
return _TRUE;
6083
6084
return _FALSE;
6085
}
6086
6087
u8 hal_btcoex_IsBtLinkExist(PADAPTER padapter)
6088
{
6089
if (GLBtCoexist.bt_link_info.bt_link_exist)
6090
return _TRUE;
6091
6092
return _FALSE;
6093
}
6094
6095
void hal_btcoex_SetBtPatchVersion(PADAPTER padapter, u16 btHciVer, u16 btPatchVer)
6096
{
6097
EXhalbtcoutsrc_SetBtPatchVersion(btHciVer, btPatchVer);
6098
}
6099
6100
void hal_btcoex_SetHciVersion(PADAPTER padapter, u16 hciVersion)
6101
{
6102
EXhalbtcoutsrc_SetHciVersion(hciVersion);
6103
}
6104
6105
void hal_btcoex_StackUpdateProfileInfo(void)
6106
{
6107
EXhalbtcoutsrc_StackUpdateProfileInfo();
6108
}
6109
6110
void hal_btcoex_pta_off_on_notify(PADAPTER padapter, u8 bBTON)
6111
{
6112
ex_halbtcoutsrc_pta_off_on_notify(&GLBtCoexist, bBTON);
6113
}
6114
6115
/*
6116
* Description:
6117
* Setting BT coex antenna isolation type .
6118
* coex mechanisn/ spital stream/ best throughput
6119
* anttype = 0 , PSTDMA / 2SS / 0.5T , bad isolation , WiFi/BT ANT Distance<15cm , (<20dB) for 2,3 antenna
6120
* anttype = 1 , PSTDMA / 1SS / 0.5T , normal isolaiton , 50cm>WiFi/BT ANT Distance>15cm , (>20dB) for 2 antenna
6121
* anttype = 2 , TDMA / 2SS / T , normal isolaiton , 50cm>WiFi/BT ANT Distance>15cm , (>20dB) for 3 antenna
6122
* anttype = 3 , no TDMA / 1SS / 0.5T , good isolation , WiFi/BT ANT Distance >50cm , (>40dB) for 2 antenna
6123
* anttype = 4 , no TDMA / 2SS / T , good isolation , WiFi/BT ANT Distance >50cm , (>40dB) for 3 antenna
6124
* wifi only throughput ~ T
6125
* wifi/BT share one antenna with SPDT
6126
*/
6127
void hal_btcoex_SetAntIsolationType(PADAPTER padapter, u8 anttype)
6128
{
6129
PHAL_DATA_TYPE pHalData;
6130
PBTC_COEXIST pBtCoexist = &GLBtCoexist;
6131
6132
/*RTW_INFO("####%s , anttype = %d , %d\n" , __func__ , anttype , __LINE__); */
6133
pHalData = GET_HAL_DATA(padapter);
6134
6135
6136
pHalData->bt_coexist.btAntisolation = anttype;
6137
6138
switch (pHalData->bt_coexist.btAntisolation) {
6139
case 0:
6140
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_0;
6141
break;
6142
case 1:
6143
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_1;
6144
break;
6145
case 2:
6146
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_2;
6147
break;
6148
case 3:
6149
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_3;
6150
break;
6151
case 4:
6152
pBtCoexist->board_info.ant_type = (u8)BTC_ANT_TYPE_4;
6153
break;
6154
}
6155
6156
}
6157
6158
#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
6159
int
6160
hal_btcoex_ParseAntIsolationConfigFile(
6161
PADAPTER Adapter,
6162
char *buffer
6163
)
6164
{
6165
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
6166
u32 i = 0 , j = 0;
6167
char *szLine , *ptmp;
6168
int rtStatus = _SUCCESS;
6169
char param_value_string[10];
6170
u8 param_value;
6171
u8 anttype = 4;
6172
6173
u8 ant_num = 3 , ant_distance = 50 , rfe_type = 1;
6174
6175
typedef struct ant_isolation {
6176
char *param_name; /* antenna isolation config parameter name */
6177
u8 *value; /* antenna isolation config parameter value */
6178
} ANT_ISOLATION;
6179
6180
ANT_ISOLATION ant_isolation_param[] = {
6181
{"ANT_NUMBER" , &ant_num},
6182
{"ANT_DISTANCE" , &ant_distance},
6183
{"RFE_TYPE" , &rfe_type},
6184
{NULL , 0}
6185
};
6186
6187
6188
6189
/* RTW_INFO("===>Hal_ParseAntIsolationConfigFile()\n" ); */
6190
6191
ptmp = buffer;
6192
for (szLine = GetLineFromBuffer(ptmp) ; szLine != NULL; szLine = GetLineFromBuffer(ptmp)) {
6193
/* skip comment */
6194
if (IsCommentString(szLine))
6195
continue;
6196
6197
/* RTW_INFO("%s : szLine = %s , strlen(szLine) = %d\n" , __func__ , szLine , strlen(szLine));*/
6198
for (j = 0 ; ant_isolation_param[j].param_name != NULL ; j++) {
6199
if (strstr(szLine , ant_isolation_param[j].param_name) != NULL) {
6200
i = 0;
6201
while (i < strlen(szLine)) {
6202
if (szLine[i] != '"')
6203
++i;
6204
else {
6205
/* skip only has one " */
6206
if (strpbrk(szLine , "\"") == strrchr(szLine , '"')) {
6207
RTW_INFO("Fail to parse parameters , format error!\n");
6208
break;
6209
}
6210
_rtw_memset((void *)param_value_string , 0 , 10);
6211
if (!ParseQualifiedString(szLine , &i , param_value_string , '"' , '"')) {
6212
RTW_INFO("Fail to parse parameters\n");
6213
return _FAIL;
6214
} else if (!GetU1ByteIntegerFromStringInDecimal(param_value_string , ant_isolation_param[j].value))
6215
RTW_INFO("Fail to GetU1ByteIntegerFromStringInDecimal\n");
6216
6217
break;
6218
}
6219
}
6220
}
6221
}
6222
}
6223
6224
/* YiWei 20140716 , for BT coex antenna isolation control */
6225
/* rfe_type = 0 was SPDT , rfe_type = 1 was coupler */
6226
if (ant_num == 3 && ant_distance >= 50)
6227
anttype = 3;
6228
else if (ant_num == 2 && ant_distance >= 50 && rfe_type == 1)
6229
anttype = 2;
6230
else if (ant_num == 3 && ant_distance >= 15 && ant_distance < 50)
6231
anttype = 2;
6232
else if (ant_num == 2 && ant_distance >= 15 && ant_distance < 50 && rfe_type == 1)
6233
anttype = 2;
6234
else if ((ant_num == 2 && ant_distance < 15 && rfe_type == 1) || (ant_num == 3 && ant_distance < 15))
6235
anttype = 1;
6236
else if (ant_num == 2 && rfe_type == 0)
6237
anttype = 0;
6238
else
6239
anttype = 0;
6240
6241
hal_btcoex_SetAntIsolationType(Adapter, anttype);
6242
6243
RTW_INFO("%s : ant_num = %d\n" , __func__ , ant_num);
6244
RTW_INFO("%s : ant_distance = %d\n" , __func__ , ant_distance);
6245
RTW_INFO("%s : rfe_type = %d\n" , __func__ , rfe_type);
6246
/* RTW_INFO("<===Hal_ParseAntIsolationConfigFile()\n"); */
6247
return rtStatus;
6248
}
6249
6250
6251
int
6252
hal_btcoex_AntIsolationConfig_ParaFile(
6253
PADAPTER Adapter,
6254
char *pFileName
6255
)
6256
{
6257
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
6258
int rlen = 0 , rtStatus = _FAIL;
6259
6260
_rtw_memset(pHalData->para_file_buf , 0 , MAX_PARA_FILE_BUF_LEN);
6261
6262
rtw_get_phy_file_path(Adapter, pFileName);
6263
if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) {
6264
rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
6265
if (rlen > 0)
6266
rtStatus = _SUCCESS;
6267
}
6268
6269
6270
if (rtStatus == _SUCCESS) {
6271
/*RTW_INFO("%s(): read %s ok\n", __func__ , pFileName);*/
6272
rtStatus = hal_btcoex_ParseAntIsolationConfigFile(Adapter , pHalData->para_file_buf);
6273
} else
6274
RTW_INFO("%s(): No File %s, Load from *** Array!\n" , __func__ , pFileName);
6275
6276
return rtStatus;
6277
}
6278
#endif /* CONFIG_LOAD_PHY_PARA_FROM_FILE */
6279
6280
u16 hal_btcoex_btreg_read(PADAPTER padapter, u8 type, u16 addr, u32 *data)
6281
{
6282
u16 ret = 0;
6283
6284
halbtcoutsrc_LeaveLowPower(&GLBtCoexist);
6285
6286
ret = halbtcoutsrc_GetBtReg_with_status(&GLBtCoexist, type, addr, data);
6287
6288
halbtcoutsrc_NormalLowPower(&GLBtCoexist);
6289
6290
return ret;
6291
}
6292
6293
u16 hal_btcoex_btreg_write(PADAPTER padapter, u8 type, u16 addr, u16 val)
6294
{
6295
u16 ret = 0;
6296
6297
halbtcoutsrc_LeaveLowPower(&GLBtCoexist);
6298
6299
ret = halbtcoutsrc_SetBtReg(&GLBtCoexist, type, addr, val);
6300
6301
halbtcoutsrc_NormalLowPower(&GLBtCoexist);
6302
6303
return ret;
6304
}
6305
6306
void hal_btcoex_set_rfe_type(u8 type)
6307
{
6308
EXhalbtcoutsrc_set_rfe_type(type);
6309
}
6310
6311
#ifdef CONFIG_RF4CE_COEXIST
6312
void hal_btcoex_set_rf4ce_link_state(u8 state)
6313
{
6314
EXhalbtcoutsrc_set_rf4ce_link_state(state);
6315
}
6316
6317
u8 hal_btcoex_get_rf4ce_link_state(void)
6318
{
6319
return EXhalbtcoutsrc_get_rf4ce_link_state();
6320
}
6321
#endif /* CONFIG_RF4CE_COEXIST */
6322
6323
void hal_btcoex_switchband_notify(u8 under_scan, u8 band_type)
6324
{
6325
switch (band_type) {
6326
case BAND_ON_2_4G:
6327
if (under_scan)
6328
EXhalbtcoutsrc_switchband_notify(&GLBtCoexist, BTC_SWITCH_TO_24G);
6329
else
6330
EXhalbtcoutsrc_switchband_notify(&GLBtCoexist, BTC_SWITCH_TO_24G_NOFORSCAN);
6331
break;
6332
case BAND_ON_5G:
6333
EXhalbtcoutsrc_switchband_notify(&GLBtCoexist, BTC_SWITCH_TO_5G);
6334
break;
6335
default:
6336
RTW_INFO("[BTCOEX] unkown switch band type\n");
6337
break;
6338
}
6339
}
6340
6341
void hal_btcoex_WlFwDbgInfoNotify(PADAPTER padapter, u8* tmpBuf, u8 length)
6342
{
6343
EXhalbtcoutsrc_WlFwDbgInfoNotify(&GLBtCoexist, tmpBuf, length);
6344
}
6345
6346
void hal_btcoex_rx_rate_change_notify(PADAPTER padapter, u8 is_data_frame, u8 rate_id)
6347
{
6348
EXhalbtcoutsrc_rx_rate_change_notify(&GLBtCoexist, is_data_frame, EXhalbtcoutsrc_rate_id_to_btc_rate_id(rate_id));
6349
}
6350
6351
u16 hal_btcoex_btset_testode(PADAPTER padapter, u8 type)
6352
{
6353
u16 ret = 0;
6354
6355
halbtcoutsrc_LeaveLowPower(&GLBtCoexist);
6356
6357
ret = halbtcoutsrc_setbttestmode(&GLBtCoexist, type);
6358
6359
halbtcoutsrc_NormalLowPower(&GLBtCoexist);
6360
6361
return ret;
6362
}
6363
6364
#endif /* CONFIG_BT_COEXIST */
6365
6366