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 */
15 static const char *const BtProfileString[] = {
23 static const char *const BtSpecString[] = {
33 static const char *const BtLinkRoleString[] = {
38 static const char *const h2cStaString[] = {
45 static const char *const ioStaString[] = {
59 BTC_COEXIST GLBtCoexist;
60 static u8 GLBtcWiFiInScanState;
61 static u8 GLBtcWiFiInIQKState;
63 u32 GLBtcDbgType[BTC_MSG_MAX];
64 static u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE];
66 typedef struct _btcoexdbginfo {
68 u32 size; /* buffer total size */
69 u32 len; /* now used length */
70 } BTCDBGINFO, *PBTCDBGINFO;
72 static BTCDBGINFO GLBtcDbgInfo;
74 #define BT_Operation(Adapter) false
76 static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size)
81 memset(pinfo, 0, sizeof(BTCDBGINFO));
89 void DBG_BT_INFO(u8 *dbgmsg)
96 pinfo = &GLBtcDbgInfo;
101 msglen = strlen(dbgmsg);
102 if (pinfo->len + msglen > pinfo->size)
105 pbuf = pinfo->info + pinfo->len;
106 memcpy(pbuf, dbgmsg, msglen);
107 pinfo->len += msglen;
111 /* Debug related function */
113 static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist)
115 if (!pBtCoexist->bBinded || !pBtCoexist->Adapter)
121 static void halbtcoutsrc_DbgInit(void)
125 for (i = 0; i < BTC_MSG_MAX; i++)
128 GLBtcDbgType[BTC_MSG_INTERFACE] = \
133 GLBtcDbgType[BTC_MSG_ALGORITHM] = \
134 /* ALGO_BT_RSSI_STATE | */
135 /* ALGO_WIFI_RSSI_STATE | */
136 /* ALGO_BT_MONITOR | */
138 /* ALGO_TRACE_FW | */
139 /* ALGO_TRACE_FW_DETAIL | */
140 /* ALGO_TRACE_FW_EXEC | */
141 /* ALGO_TRACE_SW | */
142 /* ALGO_TRACE_SW_DETAIL | */
143 /* ALGO_TRACE_SW_EXEC | */
147 static void halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist)
149 struct adapter *padapter;
152 padapter = pBtCoexist->Adapter;
154 pBtCoexist->btInfo.bBtCtrlLps = true;
155 pBtCoexist->btInfo.bBtLpsOn = false;
157 rtw_btcoex_LPS_Leave(padapter);
160 static void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist)
162 struct adapter *padapter;
165 padapter = pBtCoexist->Adapter;
167 pBtCoexist->btInfo.bBtCtrlLps = true;
168 pBtCoexist->btInfo.bBtLpsOn = true;
170 rtw_btcoex_LPS_Enter(padapter);
173 static void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist)
175 struct adapter *padapter;
178 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Normal LPS behavior!!!\n"));
180 padapter = pBtCoexist->Adapter;
182 if (pBtCoexist->btInfo.bBtCtrlLps) {
183 pBtCoexist->btInfo.bBtLpsOn = false;
184 rtw_btcoex_LPS_Leave(padapter);
185 pBtCoexist->btInfo.bBtCtrlLps = false;
187 /* recover the LPS state to the original */
193 * 1. this function will request pwrctrl->lock
195 static void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist)
197 struct adapter *padapter;
201 u32 timeout; /* unit: ms */
204 padapter = pBtCoexist->Adapter;
206 #ifdef LPS_RPWM_WAIT_MS
207 timeout = LPS_RPWM_WAIT_MS;
208 #else /* !LPS_RPWM_WAIT_MS */
210 #endif /* !LPS_RPWM_WAIT_MS */
214 ready = rtw_register_task_alive(padapter, BTCOEX_ALIVE);
215 if (_SUCCESS == ready)
218 utime = jiffies_to_msecs(jiffies - stime);
228 * 1. this function will request pwrctrl->lock
230 static void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist)
232 struct adapter *padapter;
235 padapter = pBtCoexist->Adapter;
236 rtw_unregister_task_alive(padapter, BTCOEX_ALIVE);
239 static void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisable)
241 pBtCoexist->btInfo.bBtDisableLowPwr = bLowPwrDisable;
243 halbtcoutsrc_LeaveLowPower(pBtCoexist); /* leave 32k low power. */
245 halbtcoutsrc_NormalLowPower(pBtCoexist); /* original 32k low power behavior. */
248 static void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist)
250 struct adapter *padapter;
254 padapter = pBtCoexist->Adapter;
257 if (pBtCoexist->btInfo.bRejectAggPkt) {
258 rtw_btcoex_RejectApAggregatedPacket(padapter, true);
260 if (pBtCoexist->btInfo.bPreBtCtrlAggBufSize !=
261 pBtCoexist->btInfo.bBtCtrlAggBufSize) {
263 pBtCoexist->btInfo.bPreBtCtrlAggBufSize = pBtCoexist->btInfo.bBtCtrlAggBufSize;
266 if (pBtCoexist->btInfo.bBtCtrlAggBufSize) {
267 if (pBtCoexist->btInfo.preAggBufSize !=
268 pBtCoexist->btInfo.aggBufSize){
271 pBtCoexist->btInfo.preAggBufSize = pBtCoexist->btInfo.aggBufSize;
275 rtw_btcoex_RejectApAggregatedPacket(padapter, true);
276 rtw_btcoex_RejectApAggregatedPacket(padapter, false);
281 static u8 halbtcoutsrc_IsWifiBusy(struct adapter *padapter)
283 struct mlme_priv *pmlmepriv;
286 pmlmepriv = &padapter->mlmepriv;
288 if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) {
289 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
291 if (pmlmepriv->LinkDetectInfo.bBusyTraffic)
298 static u32 _halbtcoutsrc_GetWifiLinkStatus(struct adapter *padapter)
300 struct mlme_priv *pmlmepriv;
302 u32 portConnectedStatus;
305 pmlmepriv = &padapter->mlmepriv;
307 portConnectedStatus = 0;
309 if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) {
310 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
312 portConnectedStatus |= WIFI_P2P_GO_CONNECTED;
314 portConnectedStatus |= WIFI_AP_CONNECTED;
317 portConnectedStatus |= WIFI_P2P_GC_CONNECTED;
319 portConnectedStatus |= WIFI_STA_CONNECTED;
323 return portConnectedStatus;
326 static u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
330 /* [31:16]=> connected port number */
331 /* [15:0]=> port connected bit define */
334 struct adapter *padapter;
336 u32 portConnectedStatus, numOfConnectedPort;
339 padapter = pBtCoexist->Adapter;
340 portConnectedStatus = 0;
341 numOfConnectedPort = 0;
343 retVal = _halbtcoutsrc_GetWifiLinkStatus(padapter);
345 portConnectedStatus |= retVal;
346 numOfConnectedPort++;
349 retVal = (numOfConnectedPort << 16) | portConnectedStatus;
354 static u32 halbtcoutsrc_GetBtPatchVer(PBTC_COEXIST pBtCoexist)
356 return pBtCoexist->btInfo.btRealFwVer;
359 static s32 halbtcoutsrc_GetWifiRssi(struct adapter *padapter)
361 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
363 return pHalData->dmpriv.EntryMinUndecoratedSmoothedPWDB;
366 static u8 halbtcoutsrc_GetWifiScanAPNum(struct adapter *padapter)
368 struct mlme_ext_priv *pmlmeext;
369 static u8 scan_AP_num;
371 pmlmeext = &padapter->mlmeextpriv;
373 if (!GLBtcWiFiInScanState) {
374 if (pmlmeext->sitesurvey_res.bss_cnt > 0xFF)
377 scan_AP_num = (u8)pmlmeext->sitesurvey_res.bss_cnt;
383 static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
385 PBTC_COEXIST pBtCoexist;
386 struct adapter *padapter;
387 struct hal_com_data *pHalData;
388 struct mlme_ext_priv *mlmeext;
396 pBtCoexist = (PBTC_COEXIST)pBtcContext;
397 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
400 padapter = pBtCoexist->Adapter;
401 pHalData = GET_HAL_DATA(padapter);
402 mlmeext = &padapter->mlmeextpriv;
410 case BTC_GET_BL_HS_OPERATION:
415 case BTC_GET_BL_HS_CONNECTING:
420 case BTC_GET_BL_WIFI_CONNECTED:
421 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE);
424 case BTC_GET_BL_WIFI_BUSY:
425 *pu8 = halbtcoutsrc_IsWifiBusy(padapter);
428 case BTC_GET_BL_WIFI_SCAN:
429 /* Use the value of the new variable GLBtcWiFiInScanState to judge whether WiFi is in scan state or not, since the originally used flag
430 WIFI_SITE_MONITOR in fwstate may not be cleared in time */
431 *pu8 = GLBtcWiFiInScanState;
434 case BTC_GET_BL_WIFI_LINK:
435 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING);
438 case BTC_GET_BL_WIFI_ROAM:
439 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING);
442 case BTC_GET_BL_WIFI_4_WAY_PROGRESS:
446 case BTC_GET_BL_WIFI_UNDER_5G:
447 *pu8 = pHalData->CurrentBandType == 1;
450 case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
451 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE);
454 case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
455 *pu8 = padapter->securitypriv.dot11PrivacyAlgrthm == 0 ? false : true;
458 case BTC_GET_BL_WIFI_UNDER_B_MODE:
459 if (mlmeext->cur_wireless_mode == WIRELESS_11B)
465 case BTC_GET_BL_WIFI_IS_IN_MP_MODE:
469 case BTC_GET_BL_EXT_SWITCH:
473 case BTC_GET_S4_WIFI_RSSI:
474 *pS4Tmp = halbtcoutsrc_GetWifiRssi(padapter);
477 case BTC_GET_S4_HS_RSSI:
482 case BTC_GET_U4_WIFI_BW:
483 if (IsLegacyOnly(mlmeext->cur_wireless_mode))
484 *pU4Tmp = BTC_WIFI_BW_LEGACY;
485 else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_20)
486 *pU4Tmp = BTC_WIFI_BW_HT20;
487 else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40)
488 *pU4Tmp = BTC_WIFI_BW_HT40;
490 *pU4Tmp = BTC_WIFI_BW_HT40; /* todo */
493 case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
495 PRT_LINK_DETECT_T plinkinfo;
496 plinkinfo = &padapter->mlmepriv.LinkDetectInfo;
498 if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod)
499 *pU4Tmp = BTC_WIFI_TRAFFIC_TX;
501 *pU4Tmp = BTC_WIFI_TRAFFIC_RX;
505 case BTC_GET_U4_WIFI_FW_VER:
506 *pU4Tmp = pHalData->FirmwareVersion << 16;
507 *pU4Tmp |= pHalData->FirmwareSubVersion;
510 case BTC_GET_U4_WIFI_LINK_STATUS:
511 *pU4Tmp = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist);
514 case BTC_GET_U4_BT_PATCH_VER:
515 *pU4Tmp = halbtcoutsrc_GetBtPatchVer(pBtCoexist);
518 case BTC_GET_U1_WIFI_DOT11_CHNL:
519 *pU1Tmp = padapter->mlmeextpriv.cur_channel;
522 case BTC_GET_U1_WIFI_CENTRAL_CHNL:
523 *pU1Tmp = pHalData->CurrentChannel;
526 case BTC_GET_U1_WIFI_HS_CHNL:
531 case BTC_GET_U1_MAC_PHY_MODE:
533 /* *pU1Tmp = BTC_DMSP; */
534 /* *pU1Tmp = BTC_DMDP; */
535 /* *pU1Tmp = BTC_MP_UNKNOWN; */
538 case BTC_GET_U1_AP_NUM:
539 *pU1Tmp = halbtcoutsrc_GetWifiScanAPNum(padapter);
542 /* 1Ant =========== */
543 case BTC_GET_U1_LPS_MODE:
544 *pU1Tmp = padapter->dvobj->pwrctl_priv.pwr_mode;
555 static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
557 PBTC_COEXIST pBtCoexist;
558 struct adapter *padapter;
564 pBtCoexist = (PBTC_COEXIST)pBtcContext;
565 padapter = pBtCoexist->Adapter;
570 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
574 /* set some u8 type variables. */
575 case BTC_SET_BL_BT_DISABLE:
576 pBtCoexist->btInfo.bBtDisabled = *pu8;
579 case BTC_SET_BL_BT_TRAFFIC_BUSY:
580 pBtCoexist->btInfo.bBtBusy = *pu8;
583 case BTC_SET_BL_BT_LIMITED_DIG:
584 pBtCoexist->btInfo.bLimitedDig = *pu8;
587 case BTC_SET_BL_FORCE_TO_ROAM:
588 pBtCoexist->btInfo.bForceToRoam = *pu8;
591 case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
592 pBtCoexist->btInfo.bRejectAggPkt = *pu8;
595 case BTC_SET_BL_BT_CTRL_AGG_SIZE:
596 pBtCoexist->btInfo.bBtCtrlAggBufSize = *pu8;
599 case BTC_SET_BL_INC_SCAN_DEV_NUM:
600 pBtCoexist->btInfo.bIncreaseScanDevNum = *pu8;
603 case BTC_SET_BL_BT_TX_RX_MASK:
604 pBtCoexist->btInfo.bBtTxRxMask = *pu8;
607 /* set some u8 type variables. */
608 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
609 pBtCoexist->btInfo.rssiAdjustForAgcTableOn = *pu8;
612 case BTC_SET_U1_AGG_BUF_SIZE:
613 pBtCoexist->btInfo.aggBufSize = *pu8;
616 /* the following are some action which will be triggered */
617 case BTC_SET_ACT_GET_BT_RSSI:
621 case BTC_SET_ACT_AGGREGATE_CTRL:
622 halbtcoutsrc_AggregationCheck(pBtCoexist);
625 /* 1Ant =========== */
626 /* set some u8 type variables. */
627 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
628 pBtCoexist->btInfo.rssiAdjustFor1AntCoexType = *pu8;
631 case BTC_SET_U1_LPS_VAL:
632 pBtCoexist->btInfo.lpsVal = *pu8;
635 case BTC_SET_U1_RPWM_VAL:
636 pBtCoexist->btInfo.rpwmVal = *pu8;
639 /* the following are some action which will be triggered */
640 case BTC_SET_ACT_LEAVE_LPS:
641 halbtcoutsrc_LeaveLps(pBtCoexist);
644 case BTC_SET_ACT_ENTER_LPS:
645 halbtcoutsrc_EnterLps(pBtCoexist);
648 case BTC_SET_ACT_NORMAL_LPS:
649 halbtcoutsrc_NormalLps(pBtCoexist);
652 case BTC_SET_ACT_DISABLE_LOW_POWER:
653 halbtcoutsrc_DisableLowPower(pBtCoexist, *pu8);
656 case BTC_SET_ACT_UPDATE_RAMASK:
657 pBtCoexist->btInfo.raMask = *pU4Tmp;
659 if (check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE) == true) {
660 struct sta_info *psta;
661 struct wlan_bssid_ex *cur_network;
663 cur_network = &padapter->mlmeextpriv.mlmext_info.network;
664 psta = rtw_get_stainfo(&padapter->stapriv, cur_network->MacAddress);
665 rtw_hal_update_ra_mask(psta, 0);
669 case BTC_SET_ACT_SEND_MIMO_PS:
673 case BTC_SET_ACT_CTRL_BT_INFO:
677 case BTC_SET_ACT_CTRL_BT_COEX:
680 case BTC_SET_ACT_CTRL_8723B_ANT:
692 static void halbtcoutsrc_DisplayFwPwrModeCmd(PBTC_COEXIST pBtCoexist)
694 u8 *cliBuf = pBtCoexist->cliBuf;
696 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x ", "Power mode cmd ", \
697 pBtCoexist->pwrModeVal[0], pBtCoexist->pwrModeVal[1],
698 pBtCoexist->pwrModeVal[2], pBtCoexist->pwrModeVal[3],
699 pBtCoexist->pwrModeVal[4], pBtCoexist->pwrModeVal[5]);
704 /* IO related function */
706 static u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
708 PBTC_COEXIST pBtCoexist;
709 struct adapter *padapter;
712 pBtCoexist = (PBTC_COEXIST)pBtcContext;
713 padapter = pBtCoexist->Adapter;
715 return rtw_read8(padapter, RegAddr);
718 static u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
720 PBTC_COEXIST pBtCoexist;
721 struct adapter *padapter;
724 pBtCoexist = (PBTC_COEXIST)pBtcContext;
725 padapter = pBtCoexist->Adapter;
727 return rtw_read16(padapter, RegAddr);
730 static u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
732 PBTC_COEXIST pBtCoexist;
733 struct adapter *padapter;
736 pBtCoexist = (PBTC_COEXIST)pBtcContext;
737 padapter = pBtCoexist->Adapter;
739 return rtw_read32(padapter, RegAddr);
742 static void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
744 PBTC_COEXIST pBtCoexist;
745 struct adapter *padapter;
748 pBtCoexist = (PBTC_COEXIST)pBtcContext;
749 padapter = pBtCoexist->Adapter;
751 rtw_write8(padapter, RegAddr, Data);
754 static void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b)
756 PBTC_COEXIST pBtCoexist;
757 struct adapter *padapter;
758 u8 originalValue, bitShift;
762 pBtCoexist = (PBTC_COEXIST)pBtcContext;
763 padapter = pBtCoexist->Adapter;
767 if (bitMask != 0xFF) {
768 originalValue = rtw_read8(padapter, regAddr);
770 for (i = 0; i <= 7; i++) {
771 if ((bitMask>>i)&0x1)
776 data1b = (originalValue & ~bitMask) | ((data1b << bitShift) & bitMask);
779 rtw_write8(padapter, regAddr, data1b);
782 static void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
784 PBTC_COEXIST pBtCoexist;
785 struct adapter *padapter;
788 pBtCoexist = (PBTC_COEXIST)pBtcContext;
789 padapter = pBtCoexist->Adapter;
791 rtw_write16(padapter, RegAddr, Data);
794 static void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
796 PBTC_COEXIST pBtCoexist;
797 struct adapter *padapter;
800 pBtCoexist = (PBTC_COEXIST)pBtcContext;
801 padapter = pBtCoexist->Adapter;
803 rtw_write32(padapter, RegAddr, Data);
806 static void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
808 PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext;
809 struct adapter *Adapter = pBtCoexist->Adapter;
811 if (BTC_INTF_SDIO == pBtCoexist->chipInterface)
812 rtw_write8(Adapter, SDIO_LOCAL_BASE | RegAddr, Data);
814 rtw_write8(Adapter, RegAddr, Data);
817 static void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data)
819 PBTC_COEXIST pBtCoexist;
820 struct adapter *padapter;
823 pBtCoexist = (PBTC_COEXIST)pBtcContext;
824 padapter = pBtCoexist->Adapter;
826 PHY_SetBBReg(padapter, RegAddr, BitMask, Data);
830 static u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
832 PBTC_COEXIST pBtCoexist;
833 struct adapter *padapter;
836 pBtCoexist = (PBTC_COEXIST)pBtcContext;
837 padapter = pBtCoexist->Adapter;
839 return PHY_QueryBBReg(padapter, RegAddr, BitMask);
842 static void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
844 PBTC_COEXIST pBtCoexist;
845 struct adapter *padapter;
848 pBtCoexist = (PBTC_COEXIST)pBtcContext;
849 padapter = pBtCoexist->Adapter;
851 PHY_SetRFReg(padapter, eRFPath, RegAddr, BitMask, Data);
854 static u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask)
856 PBTC_COEXIST pBtCoexist;
857 struct adapter *padapter;
860 pBtCoexist = (PBTC_COEXIST)pBtcContext;
861 padapter = pBtCoexist->Adapter;
863 return PHY_QueryRFReg(padapter, eRFPath, RegAddr, BitMask);
866 static void halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 Data)
868 PBTC_COEXIST pBtCoexist;
869 struct adapter *padapter;
870 u8 CmdBuffer1[4] = {0};
871 u8 CmdBuffer2[4] = {0};
872 u8 *AddrToSet = (u8 *)&RegAddr;
873 u8 *ValueToSet = (u8 *)&Data;
877 pBtCoexist = (PBTC_COEXIST)pBtcContext;
878 padapter = pBtCoexist->Adapter;
880 CmdBuffer1[0] |= (OperVer & 0x0f); /* Set OperVer */
881 CmdBuffer1[0] |= ((ReqNum << 4) & 0xf0); /* Set ReqNum */
882 CmdBuffer1[1] = 0x0d; /* Set OpCode to BT_LO_OP_WRITE_REG_VALUE */
883 CmdBuffer1[2] = ValueToSet[0]; /* Set WriteRegValue */
884 rtw_hal_fill_h2c_cmd(padapter, 0x67, 4, &(CmdBuffer1[0]));
889 CmdBuffer2[0] |= (OperVer & 0x0f); /* Set OperVer */
890 CmdBuffer2[0] |= ((ReqNum << 4) & 0xf0); /* Set ReqNum */
891 CmdBuffer2[1] = 0x0c; /* Set OpCode of BT_LO_OP_WRITE_REG_ADDR */
892 CmdBuffer2[3] = AddrToSet[0]; /* Set WriteRegAddr */
893 rtw_hal_fill_h2c_cmd(padapter, 0x67, 4, &(CmdBuffer2[0]));
896 static u32 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr)
898 /* To be implemented. Always return 0 temporarily */
902 static void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer)
904 PBTC_COEXIST pBtCoexist;
905 struct adapter *padapter;
908 pBtCoexist = (PBTC_COEXIST)pBtcContext;
909 padapter = pBtCoexist->Adapter;
911 rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer);
914 static void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType)
916 PBTC_COEXIST pBtCoexist;
919 pBtCoexist = (PBTC_COEXIST)pBtcContext;
921 case BTC_DBG_DISP_COEX_STATISTICS:
923 case BTC_DBG_DISP_BT_LINK_INFO:
925 case BTC_DBG_DISP_FW_PWR_MODE_CMD:
926 halbtcoutsrc_DisplayFwPwrModeCmd(pBtCoexist);
934 /* Extern functions called by other module */
936 static u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter)
938 PBTC_COEXIST pBtCoexist = &GLBtCoexist;
940 if (pBtCoexist->bBinded)
943 pBtCoexist->bBinded = true;
945 pBtCoexist->statistics.cntBind++;
947 pBtCoexist->Adapter = padapter;
949 pBtCoexist->stackInfo.bProfileNotified = false;
951 pBtCoexist->btInfo.bBtCtrlAggBufSize = false;
952 pBtCoexist->btInfo.aggBufSize = 5;
954 pBtCoexist->btInfo.bIncreaseScanDevNum = false;
956 /* set default antenna position to main port */
957 pBtCoexist->boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
962 u8 EXhalbtcoutsrc_InitlizeVariables(void *padapter)
964 PBTC_COEXIST pBtCoexist = &GLBtCoexist;
966 /* pBtCoexist->statistics.cntBind++; */
968 halbtcoutsrc_DbgInit();
970 pBtCoexist->chipInterface = BTC_INTF_SDIO;
972 EXhalbtcoutsrc_BindBtCoexWithAdapter(padapter);
974 pBtCoexist->fBtcRead1Byte = halbtcoutsrc_Read1Byte;
975 pBtCoexist->fBtcWrite1Byte = halbtcoutsrc_Write1Byte;
976 pBtCoexist->fBtcWrite1ByteBitMask = halbtcoutsrc_BitMaskWrite1Byte;
977 pBtCoexist->fBtcRead2Byte = halbtcoutsrc_Read2Byte;
978 pBtCoexist->fBtcWrite2Byte = halbtcoutsrc_Write2Byte;
979 pBtCoexist->fBtcRead4Byte = halbtcoutsrc_Read4Byte;
980 pBtCoexist->fBtcWrite4Byte = halbtcoutsrc_Write4Byte;
981 pBtCoexist->fBtcWriteLocalReg1Byte = halbtcoutsrc_WriteLocalReg1Byte;
983 pBtCoexist->fBtcSetBbReg = halbtcoutsrc_SetBbReg;
984 pBtCoexist->fBtcGetBbReg = halbtcoutsrc_GetBbReg;
986 pBtCoexist->fBtcSetRfReg = halbtcoutsrc_SetRfReg;
987 pBtCoexist->fBtcGetRfReg = halbtcoutsrc_GetRfReg;
989 pBtCoexist->fBtcFillH2c = halbtcoutsrc_FillH2cCmd;
990 pBtCoexist->fBtcDispDbgMsg = halbtcoutsrc_DisplayDbgMsg;
992 pBtCoexist->fBtcGet = halbtcoutsrc_Get;
993 pBtCoexist->fBtcSet = halbtcoutsrc_Set;
994 pBtCoexist->fBtcGetBtReg = halbtcoutsrc_GetBtReg;
995 pBtCoexist->fBtcSetBtReg = halbtcoutsrc_SetBtReg;
997 pBtCoexist->cliBuf = &GLBtcDbgBuf[0];
999 pBtCoexist->boardInfo.singleAntPath = 0;
1001 GLBtcWiFiInScanState = false;
1003 GLBtcWiFiInIQKState = false;
1008 void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist)
1010 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1013 /* Power on setting function is only added in 8723B currently */
1014 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1015 EXhalbtc8723b2ant_PowerOnSetting(pBtCoexist);
1016 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1017 EXhalbtc8723b1ant_PowerOnSetting(pBtCoexist);
1020 void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly)
1022 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1025 pBtCoexist->statistics.cntInitHwConfig++;
1027 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1028 EXhalbtc8723b2ant_InitHwConfig(pBtCoexist, bWifiOnly);
1029 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1030 EXhalbtc8723b1ant_InitHwConfig(pBtCoexist, bWifiOnly);
1033 void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist)
1035 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1038 pBtCoexist->statistics.cntInitCoexDm++;
1040 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1041 EXhalbtc8723b2ant_InitCoexDm(pBtCoexist);
1042 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1043 EXhalbtc8723b1ant_InitCoexDm(pBtCoexist);
1045 pBtCoexist->bInitilized = true;
1048 void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
1052 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1055 pBtCoexist->statistics.cntIpsNotify++;
1056 if (pBtCoexist->bManualControl)
1059 if (IPS_NONE == type)
1060 ipsType = BTC_IPS_LEAVE;
1062 ipsType = BTC_IPS_ENTER;
1064 /* All notify is called in cmd thread, don't need to leave low power again */
1065 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1067 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1068 EXhalbtc8723b2ant_IpsNotify(pBtCoexist, ipsType);
1069 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1070 EXhalbtc8723b1ant_IpsNotify(pBtCoexist, ipsType);
1072 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1075 void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
1080 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1083 pBtCoexist->statistics.cntLpsNotify++;
1084 if (pBtCoexist->bManualControl)
1087 if (PS_MODE_ACTIVE == type)
1088 lpsType = BTC_LPS_DISABLE;
1090 lpsType = BTC_LPS_ENABLE;
1092 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1093 EXhalbtc8723b2ant_LpsNotify(pBtCoexist, lpsType);
1094 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1095 EXhalbtc8723b1ant_LpsNotify(pBtCoexist, lpsType);
1098 void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
1102 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1104 pBtCoexist->statistics.cntScanNotify++;
1105 if (pBtCoexist->bManualControl)
1109 scanType = BTC_SCAN_START;
1110 GLBtcWiFiInScanState = true;
1112 scanType = BTC_SCAN_FINISH;
1113 GLBtcWiFiInScanState = false;
1116 /* All notify is called in cmd thread, don't need to leave low power again */
1117 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1119 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1120 EXhalbtc8723b2ant_ScanNotify(pBtCoexist, scanType);
1121 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1122 EXhalbtc8723b1ant_ScanNotify(pBtCoexist, scanType);
1124 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1127 void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action)
1131 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1133 pBtCoexist->statistics.cntConnectNotify++;
1134 if (pBtCoexist->bManualControl)
1138 assoType = BTC_ASSOCIATE_START;
1140 assoType = BTC_ASSOCIATE_FINISH;
1142 /* All notify is called in cmd thread, don't need to leave low power again */
1143 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1145 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1146 EXhalbtc8723b2ant_ConnectNotify(pBtCoexist, assoType);
1147 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1148 EXhalbtc8723b1ant_ConnectNotify(pBtCoexist, assoType);
1150 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1153 void EXhalbtcoutsrc_MediaStatusNotify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus)
1157 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1160 pBtCoexist->statistics.cntMediaStatusNotify++;
1161 if (pBtCoexist->bManualControl)
1164 if (RT_MEDIA_CONNECT == mediaStatus)
1165 mStatus = BTC_MEDIA_CONNECT;
1167 mStatus = BTC_MEDIA_DISCONNECT;
1169 /* All notify is called in cmd thread, don't need to leave low power again */
1170 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1172 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1173 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, mStatus);
1174 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1175 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, mStatus);
1177 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1180 void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType)
1184 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1186 pBtCoexist->statistics.cntSpecialPacketNotify++;
1187 if (pBtCoexist->bManualControl)
1190 if (PACKET_DHCP == pktType) {
1191 packetType = BTC_PACKET_DHCP;
1192 } else if (PACKET_EAPOL == pktType) {
1193 packetType = BTC_PACKET_EAPOL;
1194 } else if (PACKET_ARP == pktType) {
1195 packetType = BTC_PACKET_ARP;
1200 /* All notify is called in cmd thread, don't need to leave low power again */
1201 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1203 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1204 EXhalbtc8723b2ant_SpecialPacketNotify(pBtCoexist, packetType);
1205 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1206 EXhalbtc8723b1ant_SpecialPacketNotify(pBtCoexist, packetType);
1208 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1211 void EXhalbtcoutsrc_BtInfoNotify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length)
1213 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1216 pBtCoexist->statistics.cntBtInfoNotify++;
1218 /* All notify is called in cmd thread, don't need to leave low power again */
1219 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1221 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1222 EXhalbtc8723b2ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
1223 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1224 EXhalbtc8723b1ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
1226 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1229 void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist)
1231 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1234 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1235 EXhalbtc8723b2ant_HaltNotify(pBtCoexist);
1236 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1237 EXhalbtc8723b1ant_HaltNotify(pBtCoexist);
1239 pBtCoexist->bBinded = false;
1242 void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
1244 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1248 /* currently only 1ant we have to do the notification, */
1249 /* once pnp is notified to sleep state, we have to leave LPS that we can sleep normally. */
1252 if (pBtCoexist->boardInfo.btdmAntNum == 1)
1253 EXhalbtc8723b1ant_PnpNotify(pBtCoexist, pnpState);
1254 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
1255 EXhalbtc8723b2ant_PnpNotify(pBtCoexist, pnpState);
1258 void EXhalbtcoutsrc_Periodical(PBTC_COEXIST pBtCoexist)
1260 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1262 pBtCoexist->statistics.cntPeriodical++;
1264 /* Periodical should be called in cmd thread, */
1265 /* don't need to leave low power again */
1266 /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
1268 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1269 EXhalbtc8723b2ant_Periodical(pBtCoexist);
1270 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1271 EXhalbtc8723b1ant_Periodical(pBtCoexist);
1273 /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
1276 void EXhalbtcoutsrc_SetChipType(u8 chipType)
1278 GLBtCoexist.boardInfo.btChipType = BTC_CHIP_RTL8723B;
1281 void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum)
1283 if (BT_COEX_ANT_TYPE_PG == type) {
1284 GLBtCoexist.boardInfo.pgAntNum = antNum;
1285 GLBtCoexist.boardInfo.btdmAntNum = antNum;
1286 } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
1287 GLBtCoexist.boardInfo.btdmAntNum = antNum;
1288 /* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */
1289 } else if (BT_COEX_ANT_TYPE_DETECTED == type) {
1290 GLBtCoexist.boardInfo.btdmAntNum = antNum;
1291 /* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */
1296 /* Currently used by 8723b only, S0 or S1 */
1298 void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath)
1300 GLBtCoexist.boardInfo.singleAntPath = singleAntPath;
1303 void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist)
1305 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1308 halbtcoutsrc_LeaveLowPower(pBtCoexist);
1310 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1311 EXhalbtc8723b2ant_DisplayCoexInfo(pBtCoexist);
1312 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1313 EXhalbtc8723b1ant_DisplayCoexInfo(pBtCoexist);
1315 halbtcoutsrc_NormalLowPower(pBtCoexist);
1320 *Run BT-Coexist mechansim or not
1323 void hal_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist)
1325 struct hal_com_data *pHalData;
1328 pHalData = GET_HAL_DATA(padapter);
1329 pHalData->bt_coexist.bBtExist = bBtExist;
1334 *Check is co-exist mechanism enabled or not
1337 *true Enable BT co-exist mechanism
1338 *false Disable BT co-exist mechanism
1340 u8 hal_btcoex_IsBtExist(struct adapter *padapter)
1342 struct hal_com_data *pHalData;
1345 pHalData = GET_HAL_DATA(padapter);
1346 return pHalData->bt_coexist.bBtExist;
1349 bool hal_btcoex_IsBtDisabled(struct adapter *padapter)
1351 if (!hal_btcoex_IsBtExist(padapter))
1354 if (GLBtCoexist.btInfo.bBtDisabled)
1360 void hal_btcoex_SetChipType(struct adapter *padapter, u8 chipType)
1362 struct hal_com_data *pHalData;
1365 pHalData = GET_HAL_DATA(padapter);
1366 pHalData->bt_coexist.btChipType = chipType;
1368 EXhalbtcoutsrc_SetChipType(chipType);
1371 void hal_btcoex_SetPgAntNum(struct adapter *padapter, u8 antNum)
1373 struct hal_com_data *pHalData;
1376 pHalData = GET_HAL_DATA(padapter);
1378 pHalData->bt_coexist.btTotalAntNum = antNum;
1379 EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_PG, antNum);
1382 void hal_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath)
1384 EXhalbtcoutsrc_SetSingleAntPath(singleAntPath);
1387 u8 hal_btcoex_Initialize(struct adapter *padapter)
1389 memset(&GLBtCoexist, 0, sizeof(GLBtCoexist));
1390 return EXhalbtcoutsrc_InitlizeVariables((void *)padapter);
1393 void hal_btcoex_PowerOnSetting(struct adapter *padapter)
1395 EXhalbtcoutsrc_PowerOnSetting(&GLBtCoexist);
1398 void hal_btcoex_InitHwConfig(struct adapter *padapter, u8 bWifiOnly)
1400 if (!hal_btcoex_IsBtExist(padapter))
1403 EXhalbtcoutsrc_InitHwConfig(&GLBtCoexist, bWifiOnly);
1404 EXhalbtcoutsrc_InitCoexDm(&GLBtCoexist);
1407 void hal_btcoex_IpsNotify(struct adapter *padapter, u8 type)
1409 EXhalbtcoutsrc_IpsNotify(&GLBtCoexist, type);
1412 void hal_btcoex_LpsNotify(struct adapter *padapter, u8 type)
1414 EXhalbtcoutsrc_LpsNotify(&GLBtCoexist, type);
1417 void hal_btcoex_ScanNotify(struct adapter *padapter, u8 type)
1419 EXhalbtcoutsrc_ScanNotify(&GLBtCoexist, type);
1422 void hal_btcoex_ConnectNotify(struct adapter *padapter, u8 action)
1424 EXhalbtcoutsrc_ConnectNotify(&GLBtCoexist, action);
1427 void hal_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus)
1429 EXhalbtcoutsrc_MediaStatusNotify(&GLBtCoexist, mediaStatus);
1432 void hal_btcoex_SpecialPacketNotify(struct adapter *padapter, u8 pktType)
1434 EXhalbtcoutsrc_SpecialPacketNotify(&GLBtCoexist, pktType);
1437 void hal_btcoex_IQKNotify(struct adapter *padapter, u8 state)
1439 GLBtcWiFiInIQKState = state;
1442 void hal_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf)
1444 if (GLBtcWiFiInIQKState)
1447 EXhalbtcoutsrc_BtInfoNotify(&GLBtCoexist, tmpBuf, length);
1450 void hal_btcoex_SuspendNotify(struct adapter *padapter, u8 state)
1453 state = BTC_WIFI_PNP_SLEEP;
1455 state = BTC_WIFI_PNP_WAKE_UP;
1457 EXhalbtcoutsrc_PnpNotify(&GLBtCoexist, state);
1460 void hal_btcoex_HaltNotify(struct adapter *padapter)
1462 EXhalbtcoutsrc_HaltNotify(&GLBtCoexist);
1465 void hal_btcoex_Handler(struct adapter *padapter)
1467 EXhalbtcoutsrc_Periodical(&GLBtCoexist);
1470 s32 hal_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter)
1472 return (s32)GLBtCoexist.btInfo.bBtCtrlAggBufSize;
1475 void hal_btcoex_SetManualControl(struct adapter *padapter, u8 bmanual)
1477 GLBtCoexist.bManualControl = bmanual;
1480 u8 hal_btcoex_IsBtControlLps(struct adapter *padapter)
1482 if (hal_btcoex_IsBtExist(padapter) == false)
1485 if (GLBtCoexist.btInfo.bBtDisabled)
1488 if (GLBtCoexist.btInfo.bBtCtrlLps)
1494 u8 hal_btcoex_IsLpsOn(struct adapter *padapter)
1496 if (hal_btcoex_IsBtExist(padapter) == false)
1499 if (GLBtCoexist.btInfo.bBtDisabled)
1502 if (GLBtCoexist.btInfo.bBtLpsOn)
1508 u8 hal_btcoex_RpwmVal(struct adapter *padapter)
1510 return GLBtCoexist.btInfo.rpwmVal;
1513 u8 hal_btcoex_LpsVal(struct adapter *padapter)
1515 return GLBtCoexist.btInfo.lpsVal;
1518 u32 hal_btcoex_GetRaMask(struct adapter *padapter)
1520 if (!hal_btcoex_IsBtExist(padapter))
1523 if (GLBtCoexist.btInfo.bBtDisabled)
1526 if (GLBtCoexist.boardInfo.btdmAntNum != 1)
1529 return GLBtCoexist.btInfo.raMask;
1532 void hal_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen)
1534 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write pwrModeCmd = 0x%04x%08x\n",
1535 pCmdBuf[0]<<8|pCmdBuf[1],
1536 pCmdBuf[2]<<24|pCmdBuf[3]<<16|pCmdBuf[4]<<8|pCmdBuf[5]));
1538 memcpy(GLBtCoexist.pwrModeVal, pCmdBuf, cmdLen);
1541 void hal_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize)
1546 pinfo = &GLBtcDbgInfo;
1547 DBG_BT_INFO_INIT(pinfo, pbuf, bufsize);
1548 EXhalbtcoutsrc_DisplayBtCoexInfo(&GLBtCoexist);
1549 DBG_BT_INFO_INIT(pinfo, NULL, 0);
1552 void hal_btcoex_SetDBG(struct adapter *padapter, u32 *pDbgModule)
1560 for (i = 0; i < BTC_MSG_MAX; i++)
1561 GLBtcDbgType[i] = pDbgModule[i];
1564 u32 hal_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
1571 if (!pStrBuf || bufSize == 0)
1576 /* DBG_871X(FUNC_ADPT_FMT ": bufsize =%d\n", FUNC_ADPT_ARG(padapter), bufSize); */
1578 count = rtw_sprintf(pstr, leftSize, "#define DBG\t%d\n", DBG);
1579 if ((count < 0) || (count >= leftSize))
1584 count = rtw_sprintf(pstr, leftSize, "BTCOEX Debug Setting:\n");
1585 if ((count < 0) || (count >= leftSize))
1590 count = rtw_sprintf(pstr, leftSize,
1591 "INTERFACE / ALGORITHM: 0x%08X / 0x%08X\n\n",
1592 GLBtcDbgType[BTC_MSG_INTERFACE],
1593 GLBtcDbgType[BTC_MSG_ALGORITHM]);
1594 if ((count < 0) || (count >= leftSize))
1599 count = rtw_sprintf(pstr, leftSize, "INTERFACE Debug Setting Definition:\n");
1600 if ((count < 0) || (count >= leftSize))
1604 count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for INTF_INIT\n",
1605 (GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_INIT)?1:0);
1606 if ((count < 0) || (count >= leftSize))
1610 count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for INTF_NOTIFY\n\n",
1611 (GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_NOTIFY)?1:0);
1612 if ((count < 0) || (count >= leftSize))
1617 count = rtw_sprintf(pstr, leftSize, "ALGORITHM Debug Setting Definition:\n");
1618 if ((count < 0) || (count >= leftSize))
1622 count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for BT_RSSI_STATE\n",
1623 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_RSSI_STATE)?1:0);
1624 if ((count < 0) || (count >= leftSize))
1628 count = rtw_sprintf(pstr, leftSize, "\tbit[1]=%d for WIFI_RSSI_STATE\n",
1629 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_WIFI_RSSI_STATE)?1:0);
1630 if ((count < 0) || (count >= leftSize))
1634 count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for BT_MONITOR\n",
1635 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_MONITOR)?1:0);
1636 if ((count < 0) || (count >= leftSize))
1640 count = rtw_sprintf(pstr, leftSize, "\tbit[3]=%d for TRACE\n",
1641 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE)?1:0);
1642 if ((count < 0) || (count >= leftSize))
1646 count = rtw_sprintf(pstr, leftSize, "\tbit[4]=%d for TRACE_FW\n",
1647 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW)?1:0);
1648 if ((count < 0) || (count >= leftSize))
1652 count = rtw_sprintf(pstr, leftSize, "\tbit[5]=%d for TRACE_FW_DETAIL\n",
1653 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_DETAIL)?1:0);
1654 if ((count < 0) || (count >= leftSize))
1658 count = rtw_sprintf(pstr, leftSize, "\tbit[6]=%d for TRACE_FW_EXEC\n",
1659 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_EXEC)?1:0);
1660 if ((count < 0) || (count >= leftSize))
1664 count = rtw_sprintf(pstr, leftSize, "\tbit[7]=%d for TRACE_SW\n",
1665 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW)?1:0);
1666 if ((count < 0) || (count >= leftSize))
1670 count = rtw_sprintf(pstr, leftSize, "\tbit[8]=%d for TRACE_SW_DETAIL\n",
1671 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_DETAIL)?1:0);
1672 if ((count < 0) || (count >= leftSize))
1676 count = rtw_sprintf(pstr, leftSize, "\tbit[9]=%d for TRACE_SW_EXEC\n",
1677 (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_EXEC)?1:0);
1678 if ((count < 0) || (count >= leftSize))
1684 count = pstr - pStrBuf;
1685 /* DBG_871X(FUNC_ADPT_FMT ": usedsize =%d\n", FUNC_ADPT_ARG(padapter), count); */