1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
4 * Copyright(c) 2013 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
7 #define __HAL_BTCOEX_C__
10 #include <rtw_debug.h>
11 #include <hal_btcoex.h>
12 #include <Mp_Precomp.h>
14 /* Global variables */
16 BTC_COEXIST GLBtCoexist;
17 static u8 GLBtcWiFiInScanState;
18 static u8 GLBtcWiFiInIQKState;
20 u32 GLBtcDbgType[BTC_MSG_MAX];
21 static u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE];
23 typedef struct _btcoexdbginfo {
25 u32 size; /* buffer total size */
26 u32 len; /* now used length */
27 } BTCDBGINFO, *PBTCDBGINFO;
29 static BTCDBGINFO GLBtcDbgInfo;
31 #define BT_Operation(Adapter) false
33 static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size)
38 memset(pinfo, 0, sizeof(BTCDBGINFO));
46 void DBG_BT_INFO(u8 *dbgmsg)
53 pinfo = &GLBtcDbgInfo;
58 msglen = strlen(dbgmsg);
59 if (pinfo->len + msglen > pinfo->size)
62 pbuf = pinfo->info + pinfo->len;
63 memcpy(pbuf, dbgmsg, msglen);
68 /* Debug related function */
70 static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist)
72 if (!pBtCoexist->bBinded || !pBtCoexist->Adapter)
78 static void halbtcoutsrc_DbgInit(void)
82 for (i = 0; i < BTC_MSG_MAX; i++)
85 GLBtcDbgType[BTC_MSG_INTERFACE] = \
90 GLBtcDbgType[BTC_MSG_ALGORITHM] = \
91 /* ALGO_BT_RSSI_STATE | */
92 /* ALGO_WIFI_RSSI_STATE | */
93 /* ALGO_BT_MONITOR | */
96 /* ALGO_TRACE_FW_DETAIL | */
97 /* ALGO_TRACE_FW_EXEC | */
99 /* ALGO_TRACE_SW_DETAIL | */
100 /* ALGO_TRACE_SW_EXEC | */
104 static void halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist)
106 struct adapter *padapter;
109 padapter = pBtCoexist->Adapter;
111 pBtCoexist->btInfo.bBtCtrlLps = true;
112 pBtCoexist->btInfo.bBtLpsOn = false;
114 rtw_btcoex_LPS_Leave(padapter);
117 static void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist)
119 struct adapter *padapter;
122 padapter = pBtCoexist->Adapter;
124 pBtCoexist->btInfo.bBtCtrlLps = true;
125 pBtCoexist->btInfo.bBtLpsOn = true;
127 rtw_btcoex_LPS_Enter(padapter);
130 static void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist)
132 struct adapter *padapter;
135 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Normal LPS behavior!!!\n"));
137 padapter = pBtCoexist->Adapter;
139 if (pBtCoexist->btInfo.bBtCtrlLps) {
140 pBtCoexist->btInfo.bBtLpsOn = false;
141 rtw_btcoex_LPS_Leave(padapter);
142 pBtCoexist->btInfo.bBtCtrlLps = false;
144 /* recover the LPS state to the original */
150 * 1. this function will request pwrctrl->lock
152 static void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist)
154 struct adapter *padapter;
158 u32 timeout; /* unit: ms */
161 padapter = pBtCoexist->Adapter;
163 #ifdef LPS_RPWM_WAIT_MS
164 timeout = LPS_RPWM_WAIT_MS;
165 #else /* !LPS_RPWM_WAIT_MS */
167 #endif /* !LPS_RPWM_WAIT_MS */
171 ready = rtw_register_task_alive(padapter, BTCOEX_ALIVE);
172 if (_SUCCESS == ready)
175 utime = jiffies_to_msecs(jiffies - stime);
185 * 1. this function will request pwrctrl->lock
187 static void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist)
189 struct adapter *padapter;
192 padapter = pBtCoexist->Adapter;
193 rtw_unregister_task_alive(padapter, BTCOEX_ALIVE);
196 static void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisable)
198 pBtCoexist->btInfo.bBtDisableLowPwr = bLowPwrDisable;
200 halbtcoutsrc_LeaveLowPower(pBtCoexist); /* leave 32k low power. */
202 halbtcoutsrc_NormalLowPower(pBtCoexist); /* original 32k low power behavior. */
205 static void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist)
207 struct adapter *padapter;
211 padapter = pBtCoexist->Adapter;
214 if (pBtCoexist->btInfo.bRejectAggPkt) {
215 rtw_btcoex_RejectApAggregatedPacket(padapter, true);
217 if (pBtCoexist->btInfo.bPreBtCtrlAggBufSize !=
218 pBtCoexist->btInfo.bBtCtrlAggBufSize) {
220 pBtCoexist->btInfo.bPreBtCtrlAggBufSize = pBtCoexist->btInfo.bBtCtrlAggBufSize;
223 if (pBtCoexist->btInfo.bBtCtrlAggBufSize) {
224 if (pBtCoexist->btInfo.preAggBufSize !=
225 pBtCoexist->btInfo.aggBufSize){
228 pBtCoexist->btInfo.preAggBufSize = pBtCoexist->btInfo.aggBufSize;
232 rtw_btcoex_RejectApAggregatedPacket(padapter, true);
233 rtw_btcoex_RejectApAggregatedPacket(padapter, false);
238 static u8 halbtcoutsrc_IsWifiBusy(struct adapter *padapter)
240 struct mlme_priv *pmlmepriv;
243 pmlmepriv = &padapter->mlmepriv;
245 if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) {
246 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
248 if (pmlmepriv->LinkDetectInfo.bBusyTraffic)
255 static u32 _halbtcoutsrc_GetWifiLinkStatus(struct adapter *padapter)
257 struct mlme_priv *pmlmepriv;
259 u32 portConnectedStatus;
262 pmlmepriv = &padapter->mlmepriv;
264 portConnectedStatus = 0;
266 if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) {
267 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
269 portConnectedStatus |= WIFI_P2P_GO_CONNECTED;
271 portConnectedStatus |= WIFI_AP_CONNECTED;
274 portConnectedStatus |= WIFI_P2P_GC_CONNECTED;
276 portConnectedStatus |= WIFI_STA_CONNECTED;
280 return portConnectedStatus;
283 static u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
287 /* [31:16]=> connected port number */
288 /* [15:0]=> port connected bit define */
291 struct adapter *padapter;
293 u32 portConnectedStatus, numOfConnectedPort;
296 padapter = pBtCoexist->Adapter;
297 portConnectedStatus = 0;
298 numOfConnectedPort = 0;
300 retVal = _halbtcoutsrc_GetWifiLinkStatus(padapter);
302 portConnectedStatus |= retVal;
303 numOfConnectedPort++;
306 retVal = (numOfConnectedPort << 16) | portConnectedStatus;
311 static u32 halbtcoutsrc_GetBtPatchVer(PBTC_COEXIST pBtCoexist)
313 return pBtCoexist->btInfo.btRealFwVer;
316 static s32 halbtcoutsrc_GetWifiRssi(struct adapter *padapter)
318 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
320 return pHalData->dmpriv.EntryMinUndecoratedSmoothedPWDB;
323 static u8 halbtcoutsrc_GetWifiScanAPNum(struct adapter *padapter)
325 struct mlme_ext_priv *pmlmeext;
326 static u8 scan_AP_num;
328 pmlmeext = &padapter->mlmeextpriv;
330 if (!GLBtcWiFiInScanState) {
331 if (pmlmeext->sitesurvey_res.bss_cnt > 0xFF)
334 scan_AP_num = (u8)pmlmeext->sitesurvey_res.bss_cnt;
340 static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
342 PBTC_COEXIST pBtCoexist;
343 struct adapter *padapter;
344 struct hal_com_data *pHalData;
345 struct mlme_ext_priv *mlmeext;
352 pBtCoexist = (PBTC_COEXIST)pBtcContext;
353 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
356 padapter = pBtCoexist->Adapter;
357 pHalData = GET_HAL_DATA(padapter);
358 mlmeext = &padapter->mlmeextpriv;
365 case BTC_GET_BL_HS_OPERATION:
370 case BTC_GET_BL_HS_CONNECTING:
375 case BTC_GET_BL_WIFI_CONNECTED:
376 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE);
379 case BTC_GET_BL_WIFI_BUSY:
380 *pu8 = halbtcoutsrc_IsWifiBusy(padapter);
383 case BTC_GET_BL_WIFI_SCAN:
384 /* Use the value of the new variable GLBtcWiFiInScanState to judge whether WiFi is in scan state or not, since the originally used flag
385 WIFI_SITE_MONITOR in fwstate may not be cleared in time */
386 *pu8 = GLBtcWiFiInScanState;
389 case BTC_GET_BL_WIFI_LINK:
390 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING);
393 case BTC_GET_BL_WIFI_ROAM:
394 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING);
397 case BTC_GET_BL_WIFI_4_WAY_PROGRESS:
401 case BTC_GET_BL_WIFI_UNDER_5G:
402 *pu8 = pHalData->CurrentBandType == 1;
405 case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
406 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE);
409 case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
410 *pu8 = padapter->securitypriv.dot11PrivacyAlgrthm != 0;
413 case BTC_GET_BL_WIFI_UNDER_B_MODE:
414 if (mlmeext->cur_wireless_mode == WIRELESS_11B)
420 case BTC_GET_BL_WIFI_IS_IN_MP_MODE:
424 case BTC_GET_BL_EXT_SWITCH:
428 case BTC_GET_S4_WIFI_RSSI:
429 *pS4Tmp = halbtcoutsrc_GetWifiRssi(padapter);
432 case BTC_GET_S4_HS_RSSI:
437 case BTC_GET_U4_WIFI_BW:
438 if (IsLegacyOnly(mlmeext->cur_wireless_mode))
439 *pU4Tmp = BTC_WIFI_BW_LEGACY;
440 else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_20)
441 *pU4Tmp = BTC_WIFI_BW_HT20;
443 *pU4Tmp = BTC_WIFI_BW_HT40;
446 case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
448 PRT_LINK_DETECT_T plinkinfo;
449 plinkinfo = &padapter->mlmepriv.LinkDetectInfo;
451 if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod)
452 *pU4Tmp = BTC_WIFI_TRAFFIC_TX;
454 *pU4Tmp = BTC_WIFI_TRAFFIC_RX;
458 case BTC_GET_U4_WIFI_FW_VER:
459 *pU4Tmp = pHalData->FirmwareVersion << 16;
460 *pU4Tmp |= pHalData->FirmwareSubVersion;
463 case BTC_GET_U4_WIFI_LINK_STATUS:
464 *pU4Tmp = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist);
467 case BTC_GET_U4_BT_PATCH_VER:
468 *pU4Tmp = halbtcoutsrc_GetBtPatchVer(pBtCoexist);
471 case BTC_GET_U1_WIFI_DOT11_CHNL:
472 *pu8 = padapter->mlmeextpriv.cur_channel;
475 case BTC_GET_U1_WIFI_CENTRAL_CHNL:
476 *pu8 = pHalData->CurrentChannel;
479 case BTC_GET_U1_WIFI_HS_CHNL:
484 case BTC_GET_U1_MAC_PHY_MODE:
486 /* *pU1Tmp = BTC_DMSP; */
487 /* *pU1Tmp = BTC_DMDP; */
488 /* *pU1Tmp = BTC_MP_UNKNOWN; */
491 case BTC_GET_U1_AP_NUM:
492 *pu8 = halbtcoutsrc_GetWifiScanAPNum(padapter);
495 /* 1Ant =========== */
496 case BTC_GET_U1_LPS_MODE:
497 *pu8 = padapter->dvobj->pwrctl_priv.pwr_mode;
508 static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
510 PBTC_COEXIST pBtCoexist;
511 struct adapter *padapter;
517 pBtCoexist = (PBTC_COEXIST)pBtcContext;
518 padapter = pBtCoexist->Adapter;
523 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
527 /* set some u8 type variables. */
528 case BTC_SET_BL_BT_DISABLE:
529 pBtCoexist->btInfo.bBtDisabled = *pu8;
532 case BTC_SET_BL_BT_TRAFFIC_BUSY:
533 pBtCoexist->btInfo.bBtBusy = *pu8;
536 case BTC_SET_BL_BT_LIMITED_DIG:
537 pBtCoexist->btInfo.bLimitedDig = *pu8;
540 case BTC_SET_BL_FORCE_TO_ROAM:
541 pBtCoexist->btInfo.bForceToRoam = *pu8;
544 case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
545 pBtCoexist->btInfo.bRejectAggPkt = *pu8;
548 case BTC_SET_BL_BT_CTRL_AGG_SIZE:
549 pBtCoexist->btInfo.bBtCtrlAggBufSize = *pu8;
552 case BTC_SET_BL_INC_SCAN_DEV_NUM:
553 pBtCoexist->btInfo.bIncreaseScanDevNum = *pu8;
556 case BTC_SET_BL_BT_TX_RX_MASK:
557 pBtCoexist->btInfo.bBtTxRxMask = *pu8;
560 /* set some u8 type variables. */
561 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
562 pBtCoexist->btInfo.rssiAdjustForAgcTableOn = *pu8;
565 case BTC_SET_U1_AGG_BUF_SIZE:
566 pBtCoexist->btInfo.aggBufSize = *pu8;
569 /* the following are some action which will be triggered */
570 case BTC_SET_ACT_GET_BT_RSSI:
574 case BTC_SET_ACT_AGGREGATE_CTRL:
575 halbtcoutsrc_AggregationCheck(pBtCoexist);
578 /* 1Ant =========== */
579 /* set some u8 type variables. */
580 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
581 pBtCoexist->btInfo.rssiAdjustFor1AntCoexType = *pu8;
584 case BTC_SET_U1_LPS_VAL:
585 pBtCoexist->btInfo.lpsVal = *pu8;
588 case BTC_SET_U1_RPWM_VAL:
589 pBtCoexist->btInfo.rpwmVal = *pu8;
592 /* the following are some action which will be triggered */
593 case BTC_SET_ACT_LEAVE_LPS:
594 halbtcoutsrc_LeaveLps(pBtCoexist);
597 case BTC_SET_ACT_ENTER_LPS:
598 halbtcoutsrc_EnterLps(pBtCoexist);
601 case BTC_SET_ACT_NORMAL_LPS:
602 halbtcoutsrc_NormalLps(pBtCoexist);
605 case BTC_SET_ACT_DISABLE_LOW_POWER:
606 halbtcoutsrc_DisableLowPower(pBtCoexist, *pu8);
609 case BTC_SET_ACT_UPDATE_RAMASK:
610 pBtCoexist->btInfo.raMask = *pU4Tmp;
612 if (check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE) == true) {
613 struct sta_info *psta;
614 struct wlan_bssid_ex *cur_network;
616 cur_network = &padapter->mlmeextpriv.mlmext_info.network;
617 psta = rtw_get_stainfo(&padapter->stapriv, cur_network->MacAddress);
618 rtw_hal_update_ra_mask(psta, 0);
622 case BTC_SET_ACT_SEND_MIMO_PS:
626 case BTC_SET_ACT_CTRL_BT_INFO:
630 case BTC_SET_ACT_CTRL_BT_COEX:
633 case BTC_SET_ACT_CTRL_8723B_ANT:
645 static void halbtcoutsrc_DisplayFwPwrModeCmd(PBTC_COEXIST pBtCoexist)
647 u8 *cliBuf = pBtCoexist->cliBuf;
649 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x ", "Power mode cmd ", \
650 pBtCoexist->pwrModeVal[0], pBtCoexist->pwrModeVal[1],
651 pBtCoexist->pwrModeVal[2], pBtCoexist->pwrModeVal[3],
652 pBtCoexist->pwrModeVal[4], pBtCoexist->pwrModeVal[5]);
657 /* IO related function */
659 static u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
661 PBTC_COEXIST pBtCoexist;
662 struct adapter *padapter;
665 pBtCoexist = (PBTC_COEXIST)pBtcContext;
666 padapter = pBtCoexist->Adapter;
668 return rtw_read8(padapter, RegAddr);
671 static u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
673 PBTC_COEXIST pBtCoexist;
674 struct adapter *padapter;
677 pBtCoexist = (PBTC_COEXIST)pBtcContext;
678 padapter = pBtCoexist->Adapter;
680 return rtw_read16(padapter, RegAddr);
683 static u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
685 PBTC_COEXIST pBtCoexist;
686 struct adapter *padapter;
689 pBtCoexist = (PBTC_COEXIST)pBtcContext;
690 padapter = pBtCoexist->Adapter;
692 return rtw_read32(padapter, RegAddr);
695 static void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
697 PBTC_COEXIST pBtCoexist;
698 struct adapter *padapter;
701 pBtCoexist = (PBTC_COEXIST)pBtcContext;
702 padapter = pBtCoexist->Adapter;
704 rtw_write8(padapter, RegAddr, Data);
707 static void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b)
709 PBTC_COEXIST pBtCoexist;
710 struct adapter *padapter;
711 u8 originalValue, bitShift;
715 pBtCoexist = (PBTC_COEXIST)pBtcContext;
716 padapter = pBtCoexist->Adapter;
720 if (bitMask != 0xFF) {
721 originalValue = rtw_read8(padapter, regAddr);
723 for (i = 0; i <= 7; i++) {
724 if ((bitMask>>i)&0x1)
729 data1b = (originalValue & ~bitMask) | ((data1b << bitShift) & bitMask);
732 rtw_write8(padapter, regAddr, data1b);
735 static void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
737 PBTC_COEXIST pBtCoexist;
738 struct adapter *padapter;
741 pBtCoexist = (PBTC_COEXIST)pBtcContext;
742 padapter = pBtCoexist->Adapter;
744 rtw_write16(padapter, RegAddr, Data);
747 static void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
749 PBTC_COEXIST pBtCoexist;
750 struct adapter *padapter;
753 pBtCoexist = (PBTC_COEXIST)pBtcContext;
754 padapter = pBtCoexist->Adapter;
756 rtw_write32(padapter, RegAddr, Data);
759 static void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
761 PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext;
762 struct adapter *Adapter = pBtCoexist->Adapter;
764 if (BTC_INTF_SDIO == pBtCoexist->chipInterface)
765 rtw_write8(Adapter, SDIO_LOCAL_BASE | RegAddr, Data);
767 rtw_write8(Adapter, RegAddr, Data);
770 static void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data)
772 PBTC_COEXIST pBtCoexist;
773 struct adapter *padapter;
776 pBtCoexist = (PBTC_COEXIST)pBtcContext;
777 padapter = pBtCoexist->Adapter;
779 PHY_SetBBReg(padapter, RegAddr, BitMask, Data);
783 static u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
785 PBTC_COEXIST pBtCoexist;
786 struct adapter *padapter;
789 pBtCoexist = (PBTC_COEXIST)pBtcContext;
790 padapter = pBtCoexist->Adapter;
792 return PHY_QueryBBReg(padapter, RegAddr, BitMask);
795 static void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
797 PBTC_COEXIST pBtCoexist;
798 struct adapter *padapter;
801 pBtCoexist = (PBTC_COEXIST)pBtcContext;
802 padapter = pBtCoexist->Adapter;
804 PHY_SetRFReg(padapter, eRFPath, RegAddr, BitMask, Data);
807 static u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask)
809 PBTC_COEXIST pBtCoexist;
810 struct adapter *padapter;
813 pBtCoexist = (PBTC_COEXIST)pBtcContext;
814 padapter = pBtCoexist->Adapter;
816 return PHY_QueryRFReg(padapter, eRFPath, RegAddr, BitMask);
819 static void halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 Data)
821 PBTC_COEXIST pBtCoexist;
822 struct adapter *padapter;
823 u8 CmdBuffer1[4] = {0};
824 u8 CmdBuffer2[4] = {0};
825 u8 *AddrToSet = (u8 *)&RegAddr;
826 u8 *ValueToSet = (u8 *)&Data;
830 pBtCoexist = (PBTC_COEXIST)pBtcContext;
831 padapter = pBtCoexist->Adapter;
833 CmdBuffer1[0] |= (OperVer & 0x0f); /* Set OperVer */
834 CmdBuffer1[0] |= ((ReqNum << 4) & 0xf0); /* Set ReqNum */
835 CmdBuffer1[1] = 0x0d; /* Set OpCode to BT_LO_OP_WRITE_REG_VALUE */
836 CmdBuffer1[2] = ValueToSet[0]; /* Set WriteRegValue */
837 rtw_hal_fill_h2c_cmd(padapter, 0x67, 4, &(CmdBuffer1[0]));
842 CmdBuffer2[0] |= (OperVer & 0x0f); /* Set OperVer */
843 CmdBuffer2[0] |= ((ReqNum << 4) & 0xf0); /* Set ReqNum */
844 CmdBuffer2[1] = 0x0c; /* Set OpCode of BT_LO_OP_WRITE_REG_ADDR */
845 CmdBuffer2[3] = AddrToSet[0]; /* Set WriteRegAddr */
846 rtw_hal_fill_h2c_cmd(padapter, 0x67, 4, &(CmdBuffer2[0]));
849 static u32 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr)
851 /* To be implemented. Always return 0 temporarily */
855 static void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer)
857 PBTC_COEXIST pBtCoexist;
858 struct adapter *padapter;
861 pBtCoexist = (PBTC_COEXIST)pBtcContext;
862 padapter = pBtCoexist->Adapter;
864 rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer);
867 static void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType)
869 PBTC_COEXIST pBtCoexist;
872 pBtCoexist = (PBTC_COEXIST)pBtcContext;
874 case BTC_DBG_DISP_COEX_STATISTICS:
876 case BTC_DBG_DISP_BT_LINK_INFO:
878 case BTC_DBG_DISP_FW_PWR_MODE_CMD:
879 halbtcoutsrc_DisplayFwPwrModeCmd(pBtCoexist);
887 /* Extern functions called by other module */
889 static u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter)
891 PBTC_COEXIST pBtCoexist = &GLBtCoexist;
893 if (pBtCoexist->bBinded)
896 pBtCoexist->bBinded = true;
898 pBtCoexist->statistics.cntBind++;
900 pBtCoexist->Adapter = padapter;
902 pBtCoexist->stackInfo.bProfileNotified = false;
904 pBtCoexist->btInfo.bBtCtrlAggBufSize = false;
905 pBtCoexist->btInfo.aggBufSize = 5;
907 pBtCoexist->btInfo.bIncreaseScanDevNum = false;
909 /* set default antenna position to main port */
910 pBtCoexist->boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
915 void hal_btcoex_Initialize(void *padapter)
917 PBTC_COEXIST pBtCoexist;
919 memset(&GLBtCoexist, 0, sizeof(GLBtCoexist));
921 pBtCoexist = &GLBtCoexist;
923 /* pBtCoexist->statistics.cntBind++; */
925 halbtcoutsrc_DbgInit();
927 pBtCoexist->chipInterface = BTC_INTF_SDIO;
929 EXhalbtcoutsrc_BindBtCoexWithAdapter(padapter);
931 pBtCoexist->fBtcRead1Byte = halbtcoutsrc_Read1Byte;
932 pBtCoexist->fBtcWrite1Byte = halbtcoutsrc_Write1Byte;
933 pBtCoexist->fBtcWrite1ByteBitMask = halbtcoutsrc_BitMaskWrite1Byte;
934 pBtCoexist->fBtcRead2Byte = halbtcoutsrc_Read2Byte;
935 pBtCoexist->fBtcWrite2Byte = halbtcoutsrc_Write2Byte;
936 pBtCoexist->fBtcRead4Byte = halbtcoutsrc_Read4Byte;
937 pBtCoexist->fBtcWrite4Byte = halbtcoutsrc_Write4Byte;
938 pBtCoexist->fBtcWriteLocalReg1Byte = halbtcoutsrc_WriteLocalReg1Byte;
940 pBtCoexist->fBtcSetBbReg = halbtcoutsrc_SetBbReg;
941 pBtCoexist->fBtcGetBbReg = halbtcoutsrc_GetBbReg;
943 pBtCoexist->fBtcSetRfReg = halbtcoutsrc_SetRfReg;
944 pBtCoexist->fBtcGetRfReg = halbtcoutsrc_GetRfReg;
946 pBtCoexist->fBtcFillH2c = halbtcoutsrc_FillH2cCmd;
947 pBtCoexist->fBtcDispDbgMsg = halbtcoutsrc_DisplayDbgMsg;
949 pBtCoexist->fBtcGet = halbtcoutsrc_Get;
950 pBtCoexist->fBtcSet = halbtcoutsrc_Set;
951 pBtCoexist->fBtcGetBtReg = halbtcoutsrc_GetBtReg;
952 pBtCoexist->fBtcSetBtReg = halbtcoutsrc_SetBtReg;
954 pBtCoexist->cliBuf = &GLBtcDbgBuf[0];
956 pBtCoexist->boardInfo.singleAntPath = 0;
958 GLBtcWiFiInScanState = false;
960 GLBtcWiFiInIQKState = false;
963 void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist)
965 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
968 /* Power on setting function is only added in 8723B currently */
969 if (pBtCoexist->boardInfo.btdmAntNum == 2)
970 EXhalbtc8723b2ant_PowerOnSetting(pBtCoexist);
971 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
972 EXhalbtc8723b1ant_PowerOnSetting(pBtCoexist);
975 void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly)
977 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
980 pBtCoexist->statistics.cntInitHwConfig++;
982 if (pBtCoexist->boardInfo.btdmAntNum == 2)
983 EXhalbtc8723b2ant_InitHwConfig(pBtCoexist, bWifiOnly);
984 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
985 EXhalbtc8723b1ant_InitHwConfig(pBtCoexist, bWifiOnly);
988 void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist)
990 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
993 pBtCoexist->statistics.cntInitCoexDm++;
995 if (pBtCoexist->boardInfo.btdmAntNum == 2)
996 EXhalbtc8723b2ant_InitCoexDm(pBtCoexist);
997 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
998 EXhalbtc8723b1ant_InitCoexDm(pBtCoexist);
1000 pBtCoexist->bInitilized = true;
1003 void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
1007 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1010 pBtCoexist->statistics.cntIpsNotify++;
1011 if (pBtCoexist->bManualControl)
1014 if (IPS_NONE == type)
1015 ipsType = BTC_IPS_LEAVE;
1017 ipsType = BTC_IPS_ENTER;
1019 /* All notify is called in cmd thread, don't need to leave low power again */
1020 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1022 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1023 EXhalbtc8723b2ant_IpsNotify(pBtCoexist, ipsType);
1024 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1025 EXhalbtc8723b1ant_IpsNotify(pBtCoexist, ipsType);
1027 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1030 void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
1035 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1038 pBtCoexist->statistics.cntLpsNotify++;
1039 if (pBtCoexist->bManualControl)
1042 if (PS_MODE_ACTIVE == type)
1043 lpsType = BTC_LPS_DISABLE;
1045 lpsType = BTC_LPS_ENABLE;
1047 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1048 EXhalbtc8723b2ant_LpsNotify(pBtCoexist, lpsType);
1049 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1050 EXhalbtc8723b1ant_LpsNotify(pBtCoexist, lpsType);
1053 void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
1057 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1059 pBtCoexist->statistics.cntScanNotify++;
1060 if (pBtCoexist->bManualControl)
1064 scanType = BTC_SCAN_START;
1065 GLBtcWiFiInScanState = true;
1067 scanType = BTC_SCAN_FINISH;
1068 GLBtcWiFiInScanState = false;
1071 /* All notify is called in cmd thread, don't need to leave low power again */
1072 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1074 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1075 EXhalbtc8723b2ant_ScanNotify(pBtCoexist, scanType);
1076 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1077 EXhalbtc8723b1ant_ScanNotify(pBtCoexist, scanType);
1079 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1082 void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action)
1086 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1088 pBtCoexist->statistics.cntConnectNotify++;
1089 if (pBtCoexist->bManualControl)
1093 assoType = BTC_ASSOCIATE_START;
1095 assoType = BTC_ASSOCIATE_FINISH;
1097 /* All notify is called in cmd thread, don't need to leave low power again */
1098 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1100 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1101 EXhalbtc8723b2ant_ConnectNotify(pBtCoexist, assoType);
1102 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1103 EXhalbtc8723b1ant_ConnectNotify(pBtCoexist, assoType);
1105 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1108 void EXhalbtcoutsrc_MediaStatusNotify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus)
1112 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1115 pBtCoexist->statistics.cntMediaStatusNotify++;
1116 if (pBtCoexist->bManualControl)
1119 if (RT_MEDIA_CONNECT == mediaStatus)
1120 mStatus = BTC_MEDIA_CONNECT;
1122 mStatus = BTC_MEDIA_DISCONNECT;
1124 /* All notify is called in cmd thread, don't need to leave low power again */
1125 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1127 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1128 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, mStatus);
1129 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1130 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, mStatus);
1132 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1135 void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType)
1139 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1141 pBtCoexist->statistics.cntSpecialPacketNotify++;
1142 if (pBtCoexist->bManualControl)
1145 if (PACKET_DHCP == pktType) {
1146 packetType = BTC_PACKET_DHCP;
1147 } else if (PACKET_EAPOL == pktType) {
1148 packetType = BTC_PACKET_EAPOL;
1149 } else if (PACKET_ARP == pktType) {
1150 packetType = BTC_PACKET_ARP;
1155 /* All notify is called in cmd thread, don't need to leave low power again */
1156 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1158 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1159 EXhalbtc8723b2ant_SpecialPacketNotify(pBtCoexist, packetType);
1160 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1161 EXhalbtc8723b1ant_SpecialPacketNotify(pBtCoexist, packetType);
1163 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1166 void EXhalbtcoutsrc_BtInfoNotify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length)
1168 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1171 pBtCoexist->statistics.cntBtInfoNotify++;
1173 /* All notify is called in cmd thread, don't need to leave low power again */
1174 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1176 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1177 EXhalbtc8723b2ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
1178 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1179 EXhalbtc8723b1ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
1181 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1184 void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist)
1186 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1189 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1190 EXhalbtc8723b2ant_HaltNotify(pBtCoexist);
1191 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1192 EXhalbtc8723b1ant_HaltNotify(pBtCoexist);
1194 pBtCoexist->bBinded = false;
1197 void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
1199 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1203 /* currently only 1ant we have to do the notification, */
1204 /* once pnp is notified to sleep state, we have to leave LPS that we can sleep normally. */
1207 if (pBtCoexist->boardInfo.btdmAntNum == 1)
1208 EXhalbtc8723b1ant_PnpNotify(pBtCoexist, pnpState);
1209 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
1210 EXhalbtc8723b2ant_PnpNotify(pBtCoexist, pnpState);
1213 void EXhalbtcoutsrc_Periodical(PBTC_COEXIST pBtCoexist)
1215 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1217 pBtCoexist->statistics.cntPeriodical++;
1219 /* Periodical should be called in cmd thread, */
1220 /* don't need to leave low power again */
1221 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1223 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1224 EXhalbtc8723b2ant_Periodical(pBtCoexist);
1225 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1226 EXhalbtc8723b1ant_Periodical(pBtCoexist);
1228 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1231 void EXhalbtcoutsrc_SetChipType(u8 chipType)
1233 GLBtCoexist.boardInfo.btChipType = BTC_CHIP_RTL8723B;
1236 void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum)
1238 if (BT_COEX_ANT_TYPE_PG == type) {
1239 GLBtCoexist.boardInfo.pgAntNum = antNum;
1240 GLBtCoexist.boardInfo.btdmAntNum = antNum;
1241 } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
1242 GLBtCoexist.boardInfo.btdmAntNum = antNum;
1243 /* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */
1244 } else if (BT_COEX_ANT_TYPE_DETECTED == type) {
1245 GLBtCoexist.boardInfo.btdmAntNum = antNum;
1246 /* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */
1251 /* Currently used by 8723b only, S0 or S1 */
1253 void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath)
1255 GLBtCoexist.boardInfo.singleAntPath = singleAntPath;
1258 void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist)
1260 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1263 halbtcoutsrc_LeaveLowPower(pBtCoexist);
1265 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1266 EXhalbtc8723b2ant_DisplayCoexInfo(pBtCoexist);
1267 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1268 EXhalbtc8723b1ant_DisplayCoexInfo(pBtCoexist);
1270 halbtcoutsrc_NormalLowPower(pBtCoexist);
1275 *Run BT-Coexist mechanism or not
1278 void hal_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist)
1280 struct hal_com_data *pHalData;
1283 pHalData = GET_HAL_DATA(padapter);
1284 pHalData->bt_coexist.bBtExist = bBtExist;
1289 *Check is co-exist mechanism enabled or not
1292 *true Enable BT co-exist mechanism
1293 *false Disable BT co-exist mechanism
1295 bool hal_btcoex_IsBtExist(struct adapter *padapter)
1297 struct hal_com_data *pHalData;
1300 pHalData = GET_HAL_DATA(padapter);
1301 return pHalData->bt_coexist.bBtExist;
1304 bool hal_btcoex_IsBtDisabled(struct adapter *padapter)
1306 if (!hal_btcoex_IsBtExist(padapter))
1309 if (GLBtCoexist.btInfo.bBtDisabled)
1315 void hal_btcoex_SetChipType(struct adapter *padapter, u8 chipType)
1317 struct hal_com_data *pHalData;
1320 pHalData = GET_HAL_DATA(padapter);
1321 pHalData->bt_coexist.btChipType = chipType;
1323 EXhalbtcoutsrc_SetChipType(chipType);
1326 void hal_btcoex_SetPgAntNum(struct adapter *padapter, u8 antNum)
1328 struct hal_com_data *pHalData;
1331 pHalData = GET_HAL_DATA(padapter);
1333 pHalData->bt_coexist.btTotalAntNum = antNum;
1334 EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_PG, antNum);
1337 void hal_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath)
1339 EXhalbtcoutsrc_SetSingleAntPath(singleAntPath);
1342 void hal_btcoex_PowerOnSetting(struct adapter *padapter)
1344 EXhalbtcoutsrc_PowerOnSetting(&GLBtCoexist);
1347 void hal_btcoex_InitHwConfig(struct adapter *padapter, u8 bWifiOnly)
1349 if (!hal_btcoex_IsBtExist(padapter))
1352 EXhalbtcoutsrc_InitHwConfig(&GLBtCoexist, bWifiOnly);
1353 EXhalbtcoutsrc_InitCoexDm(&GLBtCoexist);
1356 void hal_btcoex_IpsNotify(struct adapter *padapter, u8 type)
1358 EXhalbtcoutsrc_IpsNotify(&GLBtCoexist, type);
1361 void hal_btcoex_LpsNotify(struct adapter *padapter, u8 type)
1363 EXhalbtcoutsrc_LpsNotify(&GLBtCoexist, type);
1366 void hal_btcoex_ScanNotify(struct adapter *padapter, u8 type)
1368 EXhalbtcoutsrc_ScanNotify(&GLBtCoexist, type);
1371 void hal_btcoex_ConnectNotify(struct adapter *padapter, u8 action)
1373 EXhalbtcoutsrc_ConnectNotify(&GLBtCoexist, action);
1376 void hal_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus)
1378 EXhalbtcoutsrc_MediaStatusNotify(&GLBtCoexist, mediaStatus);
1381 void hal_btcoex_SpecialPacketNotify(struct adapter *padapter, u8 pktType)
1383 EXhalbtcoutsrc_SpecialPacketNotify(&GLBtCoexist, pktType);
1386 void hal_btcoex_IQKNotify(struct adapter *padapter, u8 state)
1388 GLBtcWiFiInIQKState = state;
1391 void hal_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf)
1393 if (GLBtcWiFiInIQKState)
1396 EXhalbtcoutsrc_BtInfoNotify(&GLBtCoexist, tmpBuf, length);
1399 void hal_btcoex_SuspendNotify(struct adapter *padapter, u8 state)
1402 state = BTC_WIFI_PNP_SLEEP;
1404 state = BTC_WIFI_PNP_WAKE_UP;
1406 EXhalbtcoutsrc_PnpNotify(&GLBtCoexist, state);
1409 void hal_btcoex_HaltNotify(struct adapter *padapter)
1411 EXhalbtcoutsrc_HaltNotify(&GLBtCoexist);
1414 void hal_btcoex_Handler(struct adapter *padapter)
1416 EXhalbtcoutsrc_Periodical(&GLBtCoexist);
1419 s32 hal_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter)
1421 return (s32)GLBtCoexist.btInfo.bBtCtrlAggBufSize;
1424 void hal_btcoex_SetManualControl(struct adapter *padapter, u8 bmanual)
1426 GLBtCoexist.bManualControl = bmanual;
1429 bool hal_btcoex_IsBtControlLps(struct adapter *padapter)
1431 if (!hal_btcoex_IsBtExist(padapter))
1434 if (GLBtCoexist.btInfo.bBtDisabled)
1437 if (GLBtCoexist.btInfo.bBtCtrlLps)
1443 bool hal_btcoex_IsLpsOn(struct adapter *padapter)
1445 if (!hal_btcoex_IsBtExist(padapter))
1448 if (GLBtCoexist.btInfo.bBtDisabled)
1451 if (GLBtCoexist.btInfo.bBtLpsOn)
1457 u8 hal_btcoex_RpwmVal(struct adapter *padapter)
1459 return GLBtCoexist.btInfo.rpwmVal;
1462 u8 hal_btcoex_LpsVal(struct adapter *padapter)
1464 return GLBtCoexist.btInfo.lpsVal;
1467 u32 hal_btcoex_GetRaMask(struct adapter *padapter)
1469 if (!hal_btcoex_IsBtExist(padapter))
1472 if (GLBtCoexist.btInfo.bBtDisabled)
1475 if (GLBtCoexist.boardInfo.btdmAntNum != 1)
1478 return GLBtCoexist.btInfo.raMask;
1481 void hal_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen)
1483 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write pwrModeCmd = 0x%04x%08x\n",
1484 pCmdBuf[0]<<8|pCmdBuf[1],
1485 pCmdBuf[2]<<24|pCmdBuf[3]<<16|pCmdBuf[4]<<8|pCmdBuf[5]));
1487 memcpy(GLBtCoexist.pwrModeVal, pCmdBuf, cmdLen);
1490 void hal_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize)
1495 pinfo = &GLBtcDbgInfo;
1496 DBG_BT_INFO_INIT(pinfo, pbuf, bufsize);
1497 EXhalbtcoutsrc_DisplayBtCoexInfo(&GLBtCoexist);
1498 DBG_BT_INFO_INIT(pinfo, NULL, 0);
1501 void hal_btcoex_SetDBG(struct adapter *padapter, u32 *pDbgModule)
1509 for (i = 0; i < BTC_MSG_MAX; i++)
1510 GLBtcDbgType[i] = pDbgModule[i];
1513 u32 hal_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
1520 if (!pStrBuf || bufSize == 0)
1525 /* DBG_871X(FUNC_ADPT_FMT ": bufsize =%d\n", FUNC_ADPT_ARG(padapter), bufSize); */
1527 count = rtw_sprintf(pstr, leftSize, "#define DBG\t%d\n", DBG);
1528 if ((count < 0) || (count >= leftSize))
1533 count = rtw_sprintf(pstr, leftSize, "BTCOEX Debug Setting:\n");
1534 if ((count < 0) || (count >= leftSize))
1539 count = rtw_sprintf(pstr, leftSize,
1540 "INTERFACE / ALGORITHM: 0x%08X / 0x%08X\n\n",
1541 GLBtcDbgType[BTC_MSG_INTERFACE],
1542 GLBtcDbgType[BTC_MSG_ALGORITHM]);
1543 if ((count < 0) || (count >= leftSize))
1548 count = rtw_sprintf(pstr, leftSize, "INTERFACE Debug Setting Definition:\n");
1549 if ((count < 0) || (count >= leftSize))
1553 count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for INTF_INIT\n",
1554 (GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_INIT)?1:0);
1555 if ((count < 0) || (count >= leftSize))
1559 count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for INTF_NOTIFY\n\n",
1560 (GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_NOTIFY)?1:0);
1561 if ((count < 0) || (count >= leftSize))
1566 count = rtw_sprintf(pstr, leftSize, "ALGORITHM Debug Setting Definition:\n");
1567 if ((count < 0) || (count >= leftSize))
1571 count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for BT_RSSI_STATE\n",
1572 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_RSSI_STATE)?1:0);
1573 if ((count < 0) || (count >= leftSize))
1577 count = rtw_sprintf(pstr, leftSize, "\tbit[1]=%d for WIFI_RSSI_STATE\n",
1578 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_WIFI_RSSI_STATE)?1:0);
1579 if ((count < 0) || (count >= leftSize))
1583 count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for BT_MONITOR\n",
1584 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_MONITOR)?1:0);
1585 if ((count < 0) || (count >= leftSize))
1589 count = rtw_sprintf(pstr, leftSize, "\tbit[3]=%d for TRACE\n",
1590 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE)?1:0);
1591 if ((count < 0) || (count >= leftSize))
1595 count = rtw_sprintf(pstr, leftSize, "\tbit[4]=%d for TRACE_FW\n",
1596 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW)?1:0);
1597 if ((count < 0) || (count >= leftSize))
1601 count = rtw_sprintf(pstr, leftSize, "\tbit[5]=%d for TRACE_FW_DETAIL\n",
1602 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_DETAIL)?1:0);
1603 if ((count < 0) || (count >= leftSize))
1607 count = rtw_sprintf(pstr, leftSize, "\tbit[6]=%d for TRACE_FW_EXEC\n",
1608 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_EXEC)?1:0);
1609 if ((count < 0) || (count >= leftSize))
1613 count = rtw_sprintf(pstr, leftSize, "\tbit[7]=%d for TRACE_SW\n",
1614 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW)?1:0);
1615 if ((count < 0) || (count >= leftSize))
1619 count = rtw_sprintf(pstr, leftSize, "\tbit[8]=%d for TRACE_SW_DETAIL\n",
1620 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_DETAIL)?1:0);
1621 if ((count < 0) || (count >= leftSize))
1625 count = rtw_sprintf(pstr, leftSize, "\tbit[9]=%d for TRACE_SW_EXEC\n",
1626 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_EXEC)?1:0);
1627 if ((count < 0) || (count >= leftSize))
1633 count = pstr - pStrBuf;
1634 /* DBG_871X(FUNC_ADPT_FMT ": usedsize =%d\n", FUNC_ADPT_ARG(padapter), count); */