1 /******************************************************************************
3 * Copyright(c) 2013 Realtek Corporation. All rights reserved.
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.
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
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
20 #define __HAL_BTCOEX_C__
22 #ifdef CONFIG_BT_COEXIST
25 #include <hal_btcoex.h>
26 #include <Mp_Precomp.h>
28 //====================================
30 //====================================
31 const char *const BtProfileString[] =
40 const char *const BtSpecString[] =
51 const char *const BtLinkRoleString[] =
57 const char *const h2cStaString[] =
65 const char *const ioStaString[] =
80 const char *const GLBtcWifiBwString[]={
88 const char *const GLBtcWifiFreqString[]={
93 const char *const GLBtcIotPeerString[] = {
103 "REALTEK_SOFTAP", /* peer is RealTek SOFT_AP, by Bohn, 2009.12.17 */
104 "SELF_SOFTAP", /* Self is SoftAP */
110 "REALTEK_JAGUAR_BCUTAP",
111 "REALTEK_JAGUAR_CCUTAP"
114 #define HALBTCOUTSRC_AGG_CHK_WINDOW_IN_MS 8000
116 BTC_COEXIST GLBtCoexist;
117 u8 GLBtcWiFiInScanState;
118 u8 GLBtcWiFiInIQKState;
121 u8 GLBtcBtCoexAliveRegistered;
123 u32 GLBtcDbgType[COMP_MAX];
124 u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE];
126 typedef struct _btcoexdbginfo
129 u32 size; // buffer total size
130 u32 len; // now used length
131 } BTCDBGINFO, *PBTCDBGINFO;
133 BTCDBGINFO GLBtcDbgInfo;
135 #define BT_Operation(Adapter) _FALSE
137 static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size)
139 if (NULL == pinfo) return;
141 _rtw_memset(pinfo, 0, sizeof(BTCDBGINFO));
149 void DBG_BT_INFO(u8 *dbgmsg)
156 pinfo = &GLBtcDbgInfo;
158 if (NULL == pinfo->info)
161 msglen = strlen(dbgmsg);
162 if (pinfo->len + msglen > pinfo->size)
165 pbuf = pinfo->info + pinfo->len;
166 _rtw_memcpy(pbuf, dbgmsg, msglen);
167 pinfo->len += msglen;
170 //====================================
171 // Debug related function
172 //====================================
173 static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist)
175 if (!pBtCoexist->bBinded ||
176 NULL == pBtCoexist->Adapter)
183 static void halbtcoutsrc_DbgInit(void)
187 for (i = 0; i < COMP_MAX; i++)
191 static u8 halbtcoutsrc_IsCsrBtCoex(PBTC_COEXIST pBtCoexist)
193 if (pBtCoexist->boardInfo.btChipType == BTC_CHIP_CSR_BC4
194 || pBtCoexist->boardInfo.btChipType == BTC_CHIP_CSR_BC8
201 static u8 halbtcoutsrc_IsHwMailboxExist(PBTC_COEXIST pBtCoexist)
203 if (pBtCoexist->boardInfo.btChipType == BTC_CHIP_CSR_BC4
204 || pBtCoexist->boardInfo.btChipType == BTC_CHIP_CSR_BC8
208 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
216 static void halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist)
221 padapter = pBtCoexist->Adapter;
223 pBtCoexist->btInfo.bBtCtrlLps = _TRUE;
224 pBtCoexist->btInfo.bBtLpsOn = _FALSE;
226 rtw_btcoex_LPS_Leave(padapter);
229 void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist)
234 padapter = pBtCoexist->Adapter;
236 pBtCoexist->btInfo.bBtCtrlLps = _TRUE;
237 pBtCoexist->btInfo.bBtLpsOn = _TRUE;
239 rtw_btcoex_LPS_Enter(padapter);
242 void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist)
247 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Normal LPS behavior!!!\n"));
249 padapter = pBtCoexist->Adapter;
251 if (pBtCoexist->btInfo.bBtCtrlLps)
253 pBtCoexist->btInfo.bBtLpsOn = _FALSE;
254 rtw_btcoex_LPS_Leave(padapter);
255 pBtCoexist->btInfo.bBtCtrlLps = _FALSE;
257 // recover the LPS state to the original
259 padapter->HalFunc.UpdateLPSStatusHandler(
261 pPSC->RegLeisurePsMode,
262 pPSC->RegPowerSaveMode);
269 * 1. this function will request pwrctrl->lock
271 void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist)
273 #ifdef CONFIG_LPS_LCLK
275 PHAL_DATA_TYPE pHalData;
276 struct pwrctrl_priv *pwrctrl;
280 u32 timeout; // unit: ms
283 padapter = pBtCoexist->Adapter;
284 pHalData = GET_HAL_DATA(padapter);
285 pwrctrl = adapter_to_pwrctl(padapter);
287 #ifdef LPS_RPWM_WAIT_MS
288 timeout = LPS_RPWM_WAIT_MS;
289 #else // !LPS_RPWM_WAIT_MS
291 #endif // !LPS_RPWM_WAIT_MS
293 if (GLBtcBtCoexAliveRegistered == _TRUE)
296 stime = rtw_get_current_time();
298 ready = rtw_register_task_alive(padapter, BTCOEX_ALIVE);
299 if (_SUCCESS == ready)
302 utime = rtw_get_passing_time_ms(stime);
309 GLBtcBtCoexAliveRegistered = _TRUE;
310 #endif // CONFIG_LPS_LCLK
315 * 1. this function will request pwrctrl->lock
317 void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist)
319 #ifdef CONFIG_LPS_LCLK
322 if (GLBtcBtCoexAliveRegistered == _FALSE)
325 padapter = pBtCoexist->Adapter;
326 rtw_unregister_task_alive(padapter, BTCOEX_ALIVE);
328 GLBtcBtCoexAliveRegistered = _FALSE;
329 #endif // CONFIG_LPS_LCLK
332 void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisable)
334 pBtCoexist->btInfo.bBtDisableLowPwr = bLowPwrDisable;
336 halbtcoutsrc_LeaveLowPower(pBtCoexist); // leave 32k low power.
338 halbtcoutsrc_NormalLowPower(pBtCoexist); // original 32k low power behavior.
341 void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist)
344 BOOLEAN bNeedToAct = _FALSE;
345 static u32 preTime = 0;
348 padapter = pBtCoexist->Adapter;
350 //=====================================
351 // To void continuous deleteBA=>addBA=>deleteBA=>addBA
352 // This function is not allowed to continuous called.
353 // It can only be called after 8 seconds.
354 //=====================================
356 curTime = rtw_systime_to_ms(rtw_get_current_time());
357 if((curTime - preTime) < HALBTCOUTSRC_AGG_CHK_WINDOW_IN_MS) // over 8 seconds you can execute this function again.
366 if (pBtCoexist->btInfo.bRejectAggPkt)
369 pBtCoexist->btInfo.bPreRejectAggPkt = pBtCoexist->btInfo.bRejectAggPkt;
373 if(pBtCoexist->btInfo.bPreRejectAggPkt)
376 pBtCoexist->btInfo.bPreRejectAggPkt = pBtCoexist->btInfo.bRejectAggPkt;
379 if (pBtCoexist->btInfo.bPreBtCtrlAggBufSize !=
380 pBtCoexist->btInfo.bBtCtrlAggBufSize)
383 pBtCoexist->btInfo.bPreBtCtrlAggBufSize = pBtCoexist->btInfo.bBtCtrlAggBufSize;
386 if (pBtCoexist->btInfo.bBtCtrlAggBufSize)
388 if (pBtCoexist->btInfo.preAggBufSize !=
389 pBtCoexist->btInfo.aggBufSize)
393 pBtCoexist->btInfo.preAggBufSize = pBtCoexist->btInfo.aggBufSize;
398 rtw_btcoex_rx_ampdu_apply(padapter);
401 u8 halbtcoutsrc_IsWifiBusy(PADAPTER padapter)
403 struct mlme_priv *pmlmepriv;
406 pmlmepriv = &padapter->mlmepriv;
408 if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE)
410 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
412 if (_TRUE == pmlmepriv->LinkDetectInfo.bBusyTraffic)
416 #if defined(CONFIG_CONCURRENT_MODE)
417 pmlmepriv = &padapter->pbuddy_adapter->mlmepriv;
419 if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE)
421 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
423 if (_TRUE == pmlmepriv->LinkDetectInfo.bBusyTraffic)
431 static u32 _halbtcoutsrc_GetWifiLinkStatus(PADAPTER padapter)
433 struct mlme_priv *pmlmepriv;
435 u32 portConnectedStatus;
438 pmlmepriv = &padapter->mlmepriv;
440 portConnectedStatus = 0;
443 if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE))
447 if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE)
449 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
452 portConnectedStatus |= WIFI_P2P_GO_CONNECTED;
454 portConnectedStatus |= WIFI_AP_CONNECTED;
459 portConnectedStatus |= WIFI_P2P_GC_CONNECTED;
461 portConnectedStatus |= WIFI_STA_CONNECTED;
465 return portConnectedStatus;
468 u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
470 //=================================
472 // [31:16]=> connected port number
473 // [15:0]=> port connected bit define
474 //================================
478 u32 portConnectedStatus, numOfConnectedPort;
481 padapter = pBtCoexist->Adapter;
483 portConnectedStatus = 0;
484 numOfConnectedPort = 0;
486 retVal = _halbtcoutsrc_GetWifiLinkStatus(padapter);
489 portConnectedStatus |= retVal;
490 numOfConnectedPort++;
493 #ifdef CONFIG_CONCURRENT_MODE
494 if (padapter->pbuddy_adapter)
496 retVal = _halbtcoutsrc_GetWifiLinkStatus(padapter->pbuddy_adapter);
499 portConnectedStatus |= retVal;
500 numOfConnectedPort++;
503 #endif // CONFIG_CONCURRENT_MODE
505 retVal = (numOfConnectedPort << 16) | portConnectedStatus;
510 u32 halbtcoutsrc_GetBtPatchVer(PBTC_COEXIST pBtCoexist)
512 u16 btRealFwVer = 0x0;
516 #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
517 if (!pBtCoexist->btInfo.btRealFwVer && cnt<=5)
520 if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist))
521 { // mailbox exists, through mailbox
522 if (NDBG_GetBtFwVersion(pBtCoexist->Adapter, &btRealFwVer, &btFwVer))
524 pBtCoexist->btInfo.btRealFwVer = btRealFwVer;
525 pBtCoexist->btInfo.btFwVer = btFwVer;
529 pBtCoexist->btInfo.btRealFwVer = 0x0;
530 pBtCoexist->btInfo.btFwVer = 0x0;
533 else // no mailbox, query bt patch version through stack.
535 // query bt patch version through socket.
539 buf[0] = 0x0; // OP_Code
540 buf[1] = 0x0; // OP_Code_Length
541 BT_SendEventExtBtCoexControl(pBtCoexist->Adapter, _FALSE, dataLen, &buf[0]);
545 #endif //CONFIG_BT_COEXIST_SOCKET_TRX
546 return pBtCoexist->btInfo.btRealFwVer;
549 s32 halbtcoutsrc_GetWifiRssi(PADAPTER padapter)
551 PHAL_DATA_TYPE pHalData;
552 s32 UndecoratedSmoothedPWDB = 0;
554 pHalData = GET_HAL_DATA(padapter);
556 UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
558 return UndecoratedSmoothedPWDB;
561 static u8 halbtcoutsrc_GetWifiScanAPNum(PADAPTER padapter)
563 struct mlme_priv *pmlmepriv;
564 struct mlme_ext_priv *pmlmeext;
565 static u8 scan_AP_num = 0;
568 pmlmepriv = &padapter->mlmepriv;
569 pmlmeext = &padapter->mlmeextpriv;
571 if (GLBtcWiFiInScanState == _FALSE) {
572 if (pmlmepriv->num_of_scanned > 0xFF)
575 scan_AP_num = (u8)pmlmepriv->num_of_scanned;
581 u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
583 PBTC_COEXIST pBtCoexist;
585 PHAL_DATA_TYPE pHalData;
586 struct mlme_ext_priv *mlmeext;
587 u8 bSoftApExist, bVwifiExist;
595 pBtCoexist = (PBTC_COEXIST)pBtcContext;
596 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
599 padapter = pBtCoexist->Adapter;
600 pHalData = GET_HAL_DATA(padapter);
601 mlmeext = &padapter->mlmeextpriv;
602 bSoftApExist = _FALSE;
603 bVwifiExist = _FALSE;
605 pS4Tmp = (s32*)pOutBuf;
606 pU4Tmp = (u32*)pOutBuf;
607 pU1Tmp = (u8*)pOutBuf;
612 case BTC_GET_BL_HS_OPERATION:
617 case BTC_GET_BL_HS_CONNECTING:
622 case BTC_GET_BL_WIFI_CONNECTED:
623 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE);
624 #ifdef CONFIG_CONCURRENT_MODE
625 if ((_FALSE == *pu8) && padapter->pbuddy_adapter)
627 *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_ASOC_STATE);
629 #endif // CONFIG_CONCURRENT_MODE
632 case BTC_GET_BL_WIFI_BUSY:
633 *pu8 = halbtcoutsrc_IsWifiBusy(padapter);
636 case BTC_GET_BL_WIFI_SCAN:
638 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_SITE_MONITOR);
639 #ifdef CONFIG_CONCURRENT_MODE
640 if ((_FALSE == *pu8) && padapter->pbuddy_adapter)
642 *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_SITE_MONITOR);
644 #endif // CONFIG_CONCURRENT_MODE
646 /* Use the value of the new variable GLBtcWiFiInScanState to judge whether WiFi is in scan state or not, since the originally used flag
647 WIFI_SITE_MONITOR in fwstate may not be cleared in time */
648 *pu8 = GLBtcWiFiInScanState;
652 case BTC_GET_BL_WIFI_LINK:
653 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING);
654 #ifdef CONFIG_CONCURRENT_MODE
655 if ((_FALSE == *pu8) && padapter->pbuddy_adapter)
657 *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_UNDER_LINKING);
659 #endif // CONFIG_CONCURRENT_MODE
662 case BTC_GET_BL_WIFI_ROAM:
663 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING);
664 #ifdef CONFIG_CONCURRENT_MODE
665 if ((_FALSE == *pu8) && padapter->pbuddy_adapter)
667 *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_UNDER_LINKING);
669 #endif // CONFIG_CONCURRENT_MODE
672 case BTC_GET_BL_WIFI_4_WAY_PROGRESS:
676 case BTC_GET_BL_WIFI_UNDER_5G:
677 *pu8 = (pHalData->CurrentBandType == 1)? _TRUE : _FALSE;
680 case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
681 *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE);
682 #ifdef CONFIG_CONCURRENT_MODE
683 if ((_FALSE == *pu8) && padapter->pbuddy_adapter)
685 *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_AP_STATE);
687 #endif // CONFIG_CONCURRENT_MODE
690 case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
691 *pu8 = padapter->securitypriv.dot11PrivacyAlgrthm == 0? _FALSE: _TRUE;
694 case BTC_GET_BL_WIFI_UNDER_B_MODE:
695 if (mlmeext->cur_wireless_mode == WIRELESS_11B)
701 case BTC_GET_BL_WIFI_IS_IN_MP_MODE:
702 if (padapter->registrypriv.mp_mode == 0)
712 case BTC_GET_BL_EXT_SWITCH:
715 case BTC_GET_BL_IS_ASUS_8723B:
716 /* Always return FALSE in linux driver since this case is added only for windows driver */
720 case BTC_GET_S4_WIFI_RSSI:
721 *pS4Tmp = halbtcoutsrc_GetWifiRssi(padapter);
724 case BTC_GET_S4_HS_RSSI:
729 case BTC_GET_U4_WIFI_BW:
730 if (IsLegacyOnly(mlmeext->cur_wireless_mode))
731 *pU4Tmp = BTC_WIFI_BW_LEGACY;
732 else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_20)
733 *pU4Tmp = BTC_WIFI_BW_HT20;
734 else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40)
735 *pU4Tmp = BTC_WIFI_BW_HT40;
737 *pU4Tmp = BTC_WIFI_BW_HT40; /* todo */
740 case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
742 PRT_LINK_DETECT_T plinkinfo;
743 plinkinfo = &padapter->mlmepriv.LinkDetectInfo;
745 if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod)
746 *pU4Tmp = BTC_WIFI_TRAFFIC_TX;
748 *pU4Tmp = BTC_WIFI_TRAFFIC_RX;
752 case BTC_GET_U4_WIFI_FW_VER:
753 *pU4Tmp = pHalData->FirmwareVersion << 16;
754 *pU4Tmp |= pHalData->FirmwareSubVersion;
757 case BTC_GET_U4_WIFI_LINK_STATUS:
758 *pU4Tmp = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist);
761 case BTC_GET_U4_BT_PATCH_VER:
762 *pU4Tmp = halbtcoutsrc_GetBtPatchVer(pBtCoexist);
765 case BTC_GET_U1_WIFI_DOT11_CHNL:
766 *pU1Tmp = padapter->mlmeextpriv.cur_channel;
769 case BTC_GET_U1_WIFI_CENTRAL_CHNL:
770 *pU1Tmp = pHalData->CurrentChannel;
773 case BTC_GET_U1_WIFI_HS_CHNL:
778 case BTC_GET_U1_MAC_PHY_MODE:
779 // *pU1Tmp = BTC_SMSP;
780 // *pU1Tmp = BTC_DMSP;
781 // *pU1Tmp = BTC_DMDP;
782 // *pU1Tmp = BTC_MP_UNKNOWN;
785 case BTC_GET_U1_AP_NUM:
786 *pU1Tmp = halbtcoutsrc_GetWifiScanAPNum(padapter);
788 case BTC_GET_U1_ANT_TYPE:
789 switch(pHalData->bt_coexist.btAntisolation)
792 *pU1Tmp = (u1Byte)BTC_ANT_TYPE_0;
793 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_0;
796 *pU1Tmp = (u1Byte)BTC_ANT_TYPE_1;
797 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_1;
800 *pU1Tmp = (u1Byte)BTC_ANT_TYPE_2;
801 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_2;
804 *pU1Tmp = (u1Byte)BTC_ANT_TYPE_3;
805 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_3;
808 *pU1Tmp = (u1Byte)BTC_ANT_TYPE_4;
809 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_4;
813 case BTC_GET_U1_IOT_PEER:
814 *pU1Tmp = mlmeext->mlmext_info.assoc_AP_vendor;
817 //=======1Ant===========
818 case BTC_GET_U1_LPS_MODE:
819 *pU1Tmp = padapter->dvobj->pwrctl_priv.pwr_mode;
830 u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
832 PBTC_COEXIST pBtCoexist;
834 PHAL_DATA_TYPE pHalData;
841 pBtCoexist = (PBTC_COEXIST)pBtcContext;
842 padapter = pBtCoexist->Adapter;
843 pHalData = GET_HAL_DATA(padapter);
845 pU1Tmp = (u8*)pInBuf;
846 pU4Tmp = (u32*)pInBuf;
849 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
854 // set some u8 type variables.
855 case BTC_SET_BL_BT_DISABLE:
856 pBtCoexist->btInfo.bBtDisabled = *pu8;
859 case BTC_SET_BL_BT_TRAFFIC_BUSY:
860 pBtCoexist->btInfo.bBtBusy = *pu8;
863 case BTC_SET_BL_BT_LIMITED_DIG:
864 pBtCoexist->btInfo.bLimitedDig = *pu8;
867 case BTC_SET_BL_FORCE_TO_ROAM:
868 pBtCoexist->btInfo.bForceToRoam = *pu8;
871 case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
872 pBtCoexist->btInfo.bRejectAggPkt = *pu8;
875 case BTC_SET_BL_BT_CTRL_AGG_SIZE:
876 pBtCoexist->btInfo.bBtCtrlAggBufSize = *pu8;
879 case BTC_SET_BL_INC_SCAN_DEV_NUM:
880 pBtCoexist->btInfo.bIncreaseScanDevNum = *pu8;
883 case BTC_SET_BL_BT_TX_RX_MASK:
884 pBtCoexist->btInfo.bBtTxRxMask = *pu8;
887 case BTC_SET_BL_MIRACAST_PLUS_BT:
888 pBtCoexist->btInfo.bMiracastPlusBt = *pu8;
891 // set some u8 type variables.
892 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
893 pBtCoexist->btInfo.rssiAdjustForAgcTableOn = *pU1Tmp;
896 case BTC_SET_U1_AGG_BUF_SIZE:
897 pBtCoexist->btInfo.aggBufSize = *pU1Tmp;
900 // the following are some action which will be triggered
901 case BTC_SET_ACT_GET_BT_RSSI:
903 BT_SendGetBtRssiEvent(padapter);
909 case BTC_SET_ACT_AGGREGATE_CTRL:
910 halbtcoutsrc_AggregationCheck(pBtCoexist);
913 //=======1Ant===========
914 // set some u8 type variables.
915 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
916 pBtCoexist->btInfo.rssiAdjustFor1AntCoexType = *pU1Tmp;
919 case BTC_SET_U1_LPS_VAL:
920 pBtCoexist->btInfo.lpsVal = *pU1Tmp;
923 case BTC_SET_U1_RPWM_VAL:
924 pBtCoexist->btInfo.rpwmVal = *pU1Tmp;
927 // the following are some action which will be triggered
928 case BTC_SET_ACT_LEAVE_LPS:
929 halbtcoutsrc_LeaveLps(pBtCoexist);
932 case BTC_SET_ACT_ENTER_LPS:
933 halbtcoutsrc_EnterLps(pBtCoexist);
936 case BTC_SET_ACT_NORMAL_LPS:
937 halbtcoutsrc_NormalLps(pBtCoexist);
940 case BTC_SET_ACT_DISABLE_LOW_POWER:
941 halbtcoutsrc_DisableLowPower(pBtCoexist, *pu8);
944 case BTC_SET_ACT_UPDATE_RAMASK:
945 pBtCoexist->btInfo.raMask = *pU4Tmp;
947 if (check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE) == _TRUE)
949 struct sta_info *psta;
950 PWLAN_BSSID_EX cur_network;
952 cur_network = &padapter->mlmeextpriv.mlmext_info.network;
953 psta = rtw_get_stainfo(&padapter->stapriv, cur_network->MacAddress);
954 rtw_hal_update_ra_mask(psta, 0);
958 case BTC_SET_ACT_SEND_MIMO_PS:
960 u8 newMimoPsMode = 3;
961 struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
962 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
964 /* *pU1Tmp = 0 use SM_PS static type */
965 /* *pU1Tmp = 1 disable SM_PS */
967 newMimoPsMode = WLAN_HT_CAP_SM_PS_STATIC;
968 else if (*pU1Tmp == 1)
969 newMimoPsMode = WLAN_HT_CAP_SM_PS_DISABLED;
971 if (check_fwstate(&padapter->mlmepriv , WIFI_ASOC_STATE) == _TRUE) {
972 /* issue_action_SM_PS(padapter, get_my_bssid(&(pmlmeinfo->network)), newMimoPsMode); */
973 issue_action_SM_PS_wait_ack(padapter , get_my_bssid(&(pmlmeinfo->network)) , newMimoPsMode, 3 , 1);
978 case BTC_SET_ACT_CTRL_BT_INFO:
979 #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
981 u8 dataLen = *pU1Tmp;
985 _rtw_memcpy(tmpBuf, pU1Tmp+1, dataLen);
987 BT_SendEventExtBtInfoControl(padapter, dataLen, &tmpBuf[0]);
989 #else //!CONFIG_BT_COEXIST_SOCKET_TRX
991 #endif //CONFIG_BT_COEXIST_SOCKET_TRX
994 case BTC_SET_ACT_CTRL_BT_COEX:
995 #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
997 u8 dataLen = *pU1Tmp;
1001 _rtw_memcpy(tmpBuf, pU1Tmp+1, dataLen);
1003 BT_SendEventExtBtCoexControl(padapter, _FALSE, dataLen, &tmpBuf[0]);
1005 #else //!CONFIG_BT_COEXIST_SOCKET_TRX
1007 #endif //CONFIG_BT_COEXIST_SOCKET_TRX
1009 case BTC_SET_ACT_CTRL_8723B_ANT:
1012 u1Byte dataLen=*pU1Tmp;
1016 PlatformMoveMemory(&tmpBuf[0], pU1Tmp+1, dataLen);
1018 BT_Set8723bAnt(Adapter, dataLen, &tmpBuf[0]);
1024 //=====================
1033 u8 halbtcoutsrc_UnderIps(PBTC_COEXIST pBtCoexist)
1036 struct pwrctrl_priv *pwrpriv;
1039 padapter = pBtCoexist->Adapter;
1040 pwrpriv = &padapter->dvobj->pwrctl_priv;
1041 bMacPwrCtrlOn = _FALSE;
1043 if ((_TRUE == pwrpriv->bips_processing)
1044 && (IPS_NONE != pwrpriv->ips_mode_req)
1050 if (rf_off == pwrpriv->rf_pwrstate)
1055 rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn);
1056 if (_FALSE == bMacPwrCtrlOn)
1064 u8 halbtcoutsrc_UnderLps(PBTC_COEXIST pBtCoexist)
1066 return GLBtcWiFiInLPS;
1069 u8 halbtcoutsrc_Under32K(PBTC_COEXIST pBtCoexist)
1071 /* todo: the method to check whether wifi is under 32K or not */
1075 void halbtcoutsrc_DisplayCoexStatistics(PBTC_COEXIST pBtCoexist)
1078 PADAPTER padapter = (PADAPTER)pBtCoexist->Adapter;
1079 PBT_MGNT pBtMgnt = &padapter->MgntInfo.BtInfo.BtMgnt;
1080 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter);
1081 u8 *cliBuf = pBtCoexist->cliBuf;
1084 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Statistics]============");
1087 #if (H2C_USE_IO_THREAD != 1)
1088 for(i=0; i<H2C_STATUS_MAX; i++)
1090 if (pHalData->h2cStatistics[i])
1092 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s] = %d", "H2C statistics", \
1093 h2cStaString[i], pHalData->h2cStatistics[i]);
1098 for(i=0; i<IO_STATUS_MAX; i++)
1100 if(Adapter->ioComStr.ioH2cStatistics[i])
1102 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s] = %d", "H2C statistics", \
1103 ioStaString[i], Adapter->ioComStr.ioH2cStatistics[i]);
1109 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "lastHMEBoxNum", \
1110 pHalData->LastHMEBoxNum);
1112 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x / 0x%x", "LastOkH2c/FirstFailH2c(fwNotRead)", \
1113 pHalData->lastSuccessH2cEid, pHalData->firstFailedH2cEid);
1116 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "c2hIsr/c2hIntr/clr1AF/noRdy/noBuf", \
1117 pHalData->InterruptLog.nIMR_C2HCMD, DBG_Var.c2hInterruptCnt, DBG_Var.c2hClrReadC2hCnt,
1118 DBG_Var.c2hNotReadyCnt, DBG_Var.c2hBufAlloFailCnt);
1121 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "c2hPacket", \
1122 DBG_Var.c2hPacketCnt);
1125 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Periodical/ DbgCtrl", \
1126 pBtCoexist->statistics.cntPeriodical, pBtCoexist->statistics.cntDbgCtrl);
1128 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "PowerOn/InitHw/InitCoexDm/RfStatus", \
1129 pBtCoexist->statistics.cntPowerOn, pBtCoexist->statistics.cntInitHwConfig, pBtCoexist->statistics.cntInitCoexDm,
1130 pBtCoexist->statistics.cntRfStatusNotify);
1132 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "Ips/Lps/Scan/Connect/Mstatus", \
1133 pBtCoexist->statistics.cntIpsNotify, pBtCoexist->statistics.cntLpsNotify,
1134 pBtCoexist->statistics.cntScanNotify, pBtCoexist->statistics.cntConnectNotify,
1135 pBtCoexist->statistics.cntMediaStatusNotify);
1137 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Special pkt/Bt info/ bind",
1138 pBtCoexist->statistics.cntSpecialPacketNotify, pBtCoexist->statistics.cntBtInfoNotify,
1139 pBtCoexist->statistics.cntBind);
1144 void halbtcoutsrc_DisplayBtLinkInfo(PBTC_COEXIST pBtCoexist)
1147 PADAPTER padapter = (PADAPTER)pBtCoexist->Adapter;
1148 PBT_MGNT pBtMgnt = &padapter->MgntInfo.BtInfo.BtMgnt;
1149 u8 *cliBuf = pBtCoexist->cliBuf;
1153 if (pBtCoexist->stackInfo.bProfileNotified)
1155 for (i=0; i<pBtMgnt->ExtConfig.NumberOfACL; i++)
1157 if (pBtMgnt->ExtConfig.HCIExtensionVer >= 1)
1159 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s", "Bt link type/spec/role", \
1160 BtProfileString[pBtMgnt->ExtConfig.aclLink[i].BTProfile],
1161 BtSpecString[pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec],
1162 BtLinkRoleString[pBtMgnt->ExtConfig.aclLink[i].linkRole]);
1163 CL_PRINTF(cliBuf); }
1166 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s", "Bt link type/spec", \
1167 BtProfileString[pBtMgnt->ExtConfig.aclLink[i].BTProfile],
1168 BtSpecString[pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec]);
1176 void halbtcoutsrc_DisplayWifiStatus(PBTC_COEXIST pBtCoexist)
1178 PADAPTER padapter = pBtCoexist->Adapter;
1179 struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
1180 u8* cliBuf=pBtCoexist->cliBuf;
1181 s32 wifiRssi=0, btHsRssi=0;
1182 BOOLEAN bScan=_FALSE, bLink=_FALSE, bRoam=_FALSE, bWifiBusy=_FALSE, bWifiUnderBMode=_FALSE;
1183 u32 wifiBw=BTC_WIFI_BW_HT20, wifiTrafficDir=BTC_WIFI_TRAFFIC_TX, wifiFreq=BTC_FREQ_2_4G;
1184 u32 wifiLinkStatus=0x0;
1185 BOOLEAN bBtHsOn=_FALSE, bLowPower=_FALSE;
1186 u8 wifiChnl=0, wifiHsChnl=0, nScanAPNum = 0, FwPSState;
1188 wifiLinkStatus = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist);
1189 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "STA/vWifi/HS/p2pGo/p2pGc", \
1190 ((wifiLinkStatus&WIFI_STA_CONNECTED)? 1:0), ((wifiLinkStatus&WIFI_AP_CONNECTED)? 1:0),
1191 ((wifiLinkStatus&WIFI_HS_CONNECTED)? 1:0), ((wifiLinkStatus&WIFI_P2P_GO_CONNECTED)? 1:0),
1192 ((wifiLinkStatus&WIFI_P2P_GC_CONNECTED)? 1:0) );
1195 if (wifiLinkStatus&WIFI_STA_CONNECTED) {
1196 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "IOT Peer", GLBtcIotPeerString[padapter->mlmeextpriv.mlmext_info.assoc_AP_vendor]);
1200 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
1201 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiChnl);
1202 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl); CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(High Speed)", \
1203 wifiChnl, wifiHsChnl, bBtHsOn);
1206 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
1207 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
1208 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
1209 wifiRssi-100, btHsRssi-100);
1213 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
1214 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
1215 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
1216 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
1217 bLink, bRoam, bScan);
1220 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifiFreq);
1221 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
1222 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
1223 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
1224 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
1225 pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &nScanAPNum);
1226 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s/ AP=%d ", "Wifi freq/ bw/ traffic", \
1227 GLBtcWifiFreqString[wifiFreq], ((bWifiUnderBMode)? "11b": GLBtcWifiBwString[wifiBw]),
1228 ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")),
1233 CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s%s%s", "Power Status", \
1234 ((halbtcoutsrc_UnderIps(pBtCoexist) == _TRUE)? "IPS ON":"IPS OFF"),
1235 ((halbtcoutsrc_UnderLps(pBtCoexist) == _TRUE)? ", LPS ON":", LPS OFF"),
1236 ((halbtcoutsrc_Under32K(pBtCoexist) == _TRUE)? ", 32k":""));
1239 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)", \
1240 pBtCoexist->pwrModeVal[0], pBtCoexist->pwrModeVal[1],
1241 pBtCoexist->pwrModeVal[2], pBtCoexist->pwrModeVal[3],
1242 pBtCoexist->pwrModeVal[4], pBtCoexist->pwrModeVal[5],
1243 pBtCoexist->btInfo.lpsVal,
1244 pBtCoexist->btInfo.rpwmVal);
1248 void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType)
1250 PBTC_COEXIST pBtCoexist;
1253 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1256 case BTC_DBG_DISP_COEX_STATISTICS:
1257 halbtcoutsrc_DisplayCoexStatistics(pBtCoexist);
1259 case BTC_DBG_DISP_BT_LINK_INFO:
1260 halbtcoutsrc_DisplayBtLinkInfo(pBtCoexist);
1262 case BTC_DBG_DISP_WIFI_STATUS:
1263 halbtcoutsrc_DisplayWifiStatus(pBtCoexist);
1270 //====================================
1271 // IO related function
1272 //====================================
1273 u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
1275 PBTC_COEXIST pBtCoexist;
1279 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1280 padapter = pBtCoexist->Adapter;
1282 return rtw_read8(padapter, RegAddr);
1285 u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
1287 PBTC_COEXIST pBtCoexist;
1291 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1292 padapter = pBtCoexist->Adapter;
1294 return rtw_read16(padapter, RegAddr);
1297 u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
1299 PBTC_COEXIST pBtCoexist;
1303 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1304 padapter = pBtCoexist->Adapter;
1306 return rtw_read32(padapter, RegAddr);
1309 void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
1311 PBTC_COEXIST pBtCoexist;
1315 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1316 padapter = pBtCoexist->Adapter;
1318 rtw_write8(padapter, RegAddr, Data);
1321 void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b)
1323 PBTC_COEXIST pBtCoexist;
1325 u8 originalValue, bitShift;
1329 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1330 padapter = pBtCoexist->Adapter;
1336 originalValue = rtw_read8(padapter, regAddr);
1338 for (i=0; i<=7; i++)
1340 if ((bitMask>>i)&0x1)
1345 data1b = (originalValue & ~bitMask) | ((data1b << bitShift) & bitMask);
1348 rtw_write8(padapter, regAddr, data1b);
1351 void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
1353 PBTC_COEXIST pBtCoexist;
1357 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1358 padapter = pBtCoexist->Adapter;
1360 rtw_write16(padapter, RegAddr, Data);
1363 void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
1365 PBTC_COEXIST pBtCoexist;
1369 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1370 padapter = pBtCoexist->Adapter;
1372 rtw_write32(padapter, RegAddr, Data);
1375 void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
1377 PBTC_COEXIST pBtCoexist=(PBTC_COEXIST)pBtcContext;
1378 PADAPTER Adapter=pBtCoexist->Adapter;
1380 if(BTC_INTF_SDIO == pBtCoexist->chipInterface)
1382 rtw_write8(Adapter, SDIO_LOCAL_BASE | RegAddr, Data);
1386 rtw_write8(Adapter, RegAddr, Data);
1390 void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data)
1392 PBTC_COEXIST pBtCoexist;
1396 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1397 padapter = pBtCoexist->Adapter;
1399 PHY_SetBBReg(padapter, RegAddr, BitMask, Data);
1403 u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
1405 PBTC_COEXIST pBtCoexist;
1409 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1410 padapter = pBtCoexist->Adapter;
1412 return PHY_QueryBBReg(padapter, RegAddr, BitMask);
1415 void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
1417 PBTC_COEXIST pBtCoexist;
1421 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1422 padapter = pBtCoexist->Adapter;
1424 PHY_SetRFReg(padapter, eRFPath, RegAddr, BitMask, Data);
1427 u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask)
1429 PBTC_COEXIST pBtCoexist;
1433 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1434 padapter = pBtCoexist->Adapter;
1436 return PHY_QueryRFReg(padapter, eRFPath, RegAddr, BitMask);
1439 void halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 Data)
1441 PBTC_COEXIST pBtCoexist;
1443 u8 CmdBuffer1[4] = {0};
1444 u8 CmdBuffer2[4] = {0};
1445 u8* AddrToSet = (u8*)&RegAddr;
1446 u8* ValueToSet = (u8*)&Data;
1450 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1451 padapter = pBtCoexist->Adapter;
1453 if (IS_HARDWARE_TYPE_8723B(padapter))
1455 CmdBuffer1[0] |= (OperVer & 0x0f); /* Set OperVer */
1456 CmdBuffer1[0] |= ((ReqNum << 4) & 0xf0); /* Set ReqNum */
1457 CmdBuffer1[1] = 0x0d; /* Set OpCode to BT_LO_OP_WRITE_REG_VALUE */
1458 CmdBuffer1[2] = ValueToSet[0]; /* Set WriteRegValue */
1459 rtw_hal_fill_h2c_cmd(padapter, 0x67, 4, &(CmdBuffer1[0]));
1464 CmdBuffer2[0] |= (OperVer & 0x0f); /* Set OperVer */
1465 CmdBuffer2[0] |= ((ReqNum << 4) & 0xf0); /* Set ReqNum */
1466 CmdBuffer2[1] = 0x0c; /* Set OpCode of BT_LO_OP_WRITE_REG_ADDR */
1467 CmdBuffer2[3] = AddrToSet[0]; /* Set WriteRegAddr */
1468 rtw_hal_fill_h2c_cmd(padapter, 0x67, 4, &(CmdBuffer2[0]));
1472 u8 halbtcoutsrc_SetBtAntDetection(void *pBtcContext, u8 txTime, u8 btChnl)
1474 /* Always return _FALSE since we don't implement this yet */
1476 PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext;
1477 PADAPTER Adapter = pBtCoexist->Adapter;
1479 BOOLEAN bStatus = FALSE;
1481 bStatus = NDBG_SetBtAntDetection(Adapter, txTime, btChnl, &btCanTx);
1482 if (bStatus && btCanTx)
1491 u32 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr)
1493 /* To be implemented. Always return 0 temporarily */
1497 void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer)
1499 PBTC_COEXIST pBtCoexist;
1503 pBtCoexist = (PBTC_COEXIST)pBtcContext;
1504 padapter = pBtCoexist->Adapter;
1506 rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer);
1509 //====================================
1510 // Extern functions called by other module
1511 //====================================
1512 u8 EXhalbtcoutsrc_IsTfbgaPackageType(PADAPTER padapter)
1514 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
1516 #ifdef CONFIG_RTL8723B
1517 if ((pHalData->PackageType == PACKAGE_TFBGA79) || (pHalData->PackageType == PACKAGE_TFBGA80)
1518 || (pHalData->PackageType == PACKAGE_TFBGA90)) {
1526 u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter)
1528 PBTC_COEXIST pBtCoexist=&GLBtCoexist;
1529 u1Byte antNum=2, chipType;
1531 if(pBtCoexist->bBinded)
1534 pBtCoexist->bBinded = _TRUE;
1536 pBtCoexist->statistics.cntBind++;
1538 pBtCoexist->Adapter = padapter;
1540 pBtCoexist->stackInfo.bProfileNotified = _FALSE;
1542 pBtCoexist->btInfo.bBtCtrlAggBufSize = _FALSE;
1543 pBtCoexist->btInfo.aggBufSize = 5;
1545 pBtCoexist->btInfo.bIncreaseScanDevNum = _FALSE;
1546 pBtCoexist->btInfo.bMiracastPlusBt = _FALSE;
1549 chipType = HALBT_GetBtChipType(Adapter);
1550 EXhalbtcoutsrc_SetChipType(chipType);
1551 antNum = HALBT_GetPgAntNum(Adapter);
1552 EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_PG, antNum);
1554 // set default antenna position to main port
1555 pBtCoexist->boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
1557 pBtCoexist->boardInfo.btdmAntDetFinish = _FALSE;
1558 pBtCoexist->boardInfo.btdmAntNumByAntDet = 1;
1560 pBtCoexist->boardInfo.bTfbgaPackage = EXhalbtcoutsrc_IsTfbgaPackageType((PADAPTER)padapter);
1562 if (pBtCoexist->boardInfo.bTfbgaPackage)
1563 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Package Type = TFBGA\n"));
1565 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Package Type = Non-TFBGA\n"));
1570 u8 EXhalbtcoutsrc_InitlizeVariables(void *padapter)
1572 PBTC_COEXIST pBtCoexist = &GLBtCoexist;
1574 //pBtCoexist->statistics.cntBind++;
1576 halbtcoutsrc_DbgInit();
1578 #ifdef CONFIG_PCI_HCI
1579 pBtCoexist->chipInterface = BTC_INTF_PCI;
1580 #elif defined(CONFIG_USB_HCI)
1581 pBtCoexist->chipInterface = BTC_INTF_USB;
1582 #elif defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
1583 pBtCoexist->chipInterface = BTC_INTF_SDIO;
1585 pBtCoexist->chipInterface = BTC_INTF_UNKNOWN;
1588 EXhalbtcoutsrc_BindBtCoexWithAdapter(padapter);
1590 pBtCoexist->fBtcRead1Byte = halbtcoutsrc_Read1Byte;
1591 pBtCoexist->fBtcWrite1Byte = halbtcoutsrc_Write1Byte;
1592 pBtCoexist->fBtcWrite1ByteBitMask = halbtcoutsrc_BitMaskWrite1Byte;
1593 pBtCoexist->fBtcRead2Byte = halbtcoutsrc_Read2Byte;
1594 pBtCoexist->fBtcWrite2Byte = halbtcoutsrc_Write2Byte;
1595 pBtCoexist->fBtcRead4Byte = halbtcoutsrc_Read4Byte;
1596 pBtCoexist->fBtcWrite4Byte = halbtcoutsrc_Write4Byte;
1597 pBtCoexist->fBtcWriteLocalReg1Byte = halbtcoutsrc_WriteLocalReg1Byte;
1599 pBtCoexist->fBtcSetBbReg = halbtcoutsrc_SetBbReg;
1600 pBtCoexist->fBtcGetBbReg = halbtcoutsrc_GetBbReg;
1602 pBtCoexist->fBtcSetRfReg = halbtcoutsrc_SetRfReg;
1603 pBtCoexist->fBtcGetRfReg = halbtcoutsrc_GetRfReg;
1605 pBtCoexist->fBtcFillH2c = halbtcoutsrc_FillH2cCmd;
1606 pBtCoexist->fBtcDispDbgMsg = halbtcoutsrc_DisplayDbgMsg;
1608 pBtCoexist->fBtcGet = halbtcoutsrc_Get;
1609 pBtCoexist->fBtcSet = halbtcoutsrc_Set;
1610 pBtCoexist->fBtcGetBtReg = halbtcoutsrc_GetBtReg;
1611 pBtCoexist->fBtcSetBtReg = halbtcoutsrc_SetBtReg;
1612 pBtCoexist->fBtcSetBtAntDetection = halbtcoutsrc_SetBtAntDetection;
1614 pBtCoexist->cliBuf = &GLBtcDbgBuf[0];
1616 pBtCoexist->boardInfo.singleAntPath = 0;
1618 GLBtcWiFiInScanState = _FALSE;
1620 GLBtcWiFiInIQKState = _FALSE;
1622 GLBtcWiFiInIPS = _FALSE;
1624 GLBtcWiFiInLPS = _FALSE;
1626 GLBtcBtCoexAliveRegistered = _FALSE;
1631 void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist)
1633 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1636 /* Power on setting function is only added in 8723B currently */
1637 if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
1639 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1640 EXhalbtc8723b2ant_PowerOnSetting(pBtCoexist);
1641 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1642 EXhalbtc8723b1ant_PowerOnSetting(pBtCoexist);
1646 void EXhalbtcoutsrc_PreLoadFirmware(PBTC_COEXIST pBtCoexist)
1648 if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1651 pBtCoexist->statistics.cntPreLoadFirmware++;
1653 if(IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
1655 if(pBtCoexist->boardInfo.btdmAntNum == 2)
1656 EXhalbtc8723b2ant_PreLoadFirmware(pBtCoexist);
1657 else if(pBtCoexist->boardInfo.btdmAntNum == 1)
1658 EXhalbtc8723b1ant_PreLoadFirmware(pBtCoexist);
1662 void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly)
1664 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1667 pBtCoexist->statistics.cntInitHwConfig++;
1669 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
1671 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
1672 EXhalbtc8821aCsr2ant_InitHwConfig(pBtCoexist, bWifiOnly);
1673 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
1674 EXhalbtc8821a2ant_InitHwConfig(pBtCoexist, bWifiOnly);
1675 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1676 EXhalbtc8821a1ant_InitHwConfig(pBtCoexist, bWifiOnly);
1678 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
1680 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1681 EXhalbtc8723b2ant_InitHwConfig(pBtCoexist, bWifiOnly);
1682 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1683 EXhalbtc8723b1ant_InitHwConfig(pBtCoexist, bWifiOnly);
1685 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
1687 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1688 EXhalbtc8192e2ant_InitHwConfig(pBtCoexist, bWifiOnly);
1689 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1690 EXhalbtc8192e1ant_InitHwConfig(pBtCoexist, bWifiOnly);
1692 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
1694 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1695 EXhalbtc8812a2ant_InitHwConfig(pBtCoexist, bWifiOnly);
1696 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1697 EXhalbtc8812a1ant_InitHwConfig(pBtCoexist, bWifiOnly);
1701 void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist)
1703 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1706 pBtCoexist->statistics.cntInitCoexDm++;
1708 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
1710 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
1711 EXhalbtc8821aCsr2ant_InitCoexDm(pBtCoexist);
1712 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
1713 EXhalbtc8821a2ant_InitCoexDm(pBtCoexist);
1714 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1715 EXhalbtc8821a1ant_InitCoexDm(pBtCoexist);
1717 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
1719 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1720 EXhalbtc8723b2ant_InitCoexDm(pBtCoexist);
1721 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1722 EXhalbtc8723b1ant_InitCoexDm(pBtCoexist);
1724 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
1726 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1727 EXhalbtc8192e2ant_InitCoexDm(pBtCoexist);
1728 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1729 EXhalbtc8192e1ant_InitCoexDm(pBtCoexist);
1731 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
1733 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1734 EXhalbtc8812a2ant_InitCoexDm(pBtCoexist);
1735 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1736 EXhalbtc8812a1ant_InitCoexDm(pBtCoexist);
1739 pBtCoexist->bInitilized = _TRUE;
1742 void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
1746 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1749 pBtCoexist->statistics.cntIpsNotify++;
1750 if (pBtCoexist->bManualControl)
1753 if (IPS_NONE == type)
1755 ipsType = BTC_IPS_LEAVE;
1756 GLBtcWiFiInIPS = _FALSE;
1760 ipsType = BTC_IPS_ENTER;
1761 GLBtcWiFiInIPS = _TRUE;
1764 // All notify is called in cmd thread, don't need to leave low power again
1765 // halbtcoutsrc_LeaveLowPower(pBtCoexist);
1767 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
1769 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
1770 EXhalbtc8821aCsr2ant_IpsNotify(pBtCoexist, ipsType);
1771 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
1772 EXhalbtc8821a2ant_IpsNotify(pBtCoexist, ipsType);
1773 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1774 EXhalbtc8821a1ant_IpsNotify(pBtCoexist, ipsType);
1776 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
1778 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1779 EXhalbtc8723b2ant_IpsNotify(pBtCoexist, ipsType);
1780 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1781 EXhalbtc8723b1ant_IpsNotify(pBtCoexist, ipsType);
1783 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
1785 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1786 EXhalbtc8192e2ant_IpsNotify(pBtCoexist, ipsType);
1787 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1788 EXhalbtc8192e1ant_IpsNotify(pBtCoexist, ipsType);
1790 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
1792 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1793 EXhalbtc8812a2ant_IpsNotify(pBtCoexist, ipsType);
1794 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1795 EXhalbtc8812a1ant_IpsNotify(pBtCoexist, ipsType);
1798 // halbtcoutsrc_NormalLowPower(pBtCoexist);
1801 void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
1806 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1809 pBtCoexist->statistics.cntLpsNotify++;
1810 if (pBtCoexist->bManualControl)
1813 if (PS_MODE_ACTIVE == type)
1815 lpsType = BTC_LPS_DISABLE;
1816 GLBtcWiFiInLPS = _FALSE;
1820 lpsType = BTC_LPS_ENABLE;
1821 GLBtcWiFiInLPS = _TRUE;
1824 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
1826 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
1827 EXhalbtc8821aCsr2ant_LpsNotify(pBtCoexist, lpsType);
1828 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
1829 EXhalbtc8821a2ant_LpsNotify(pBtCoexist, lpsType);
1830 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1831 EXhalbtc8821a1ant_LpsNotify(pBtCoexist, lpsType);
1833 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
1835 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1836 EXhalbtc8723b2ant_LpsNotify(pBtCoexist, lpsType);
1837 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1838 EXhalbtc8723b1ant_LpsNotify(pBtCoexist, lpsType);
1840 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
1842 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1843 EXhalbtc8192e2ant_LpsNotify(pBtCoexist, lpsType);
1844 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1845 EXhalbtc8192e1ant_LpsNotify(pBtCoexist, lpsType);
1847 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
1849 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1850 EXhalbtc8812a2ant_LpsNotify(pBtCoexist, lpsType);
1851 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1852 EXhalbtc8812a1ant_LpsNotify(pBtCoexist, lpsType);
1856 void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
1860 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1862 pBtCoexist->statistics.cntScanNotify++;
1863 if (pBtCoexist->bManualControl)
1868 scanType = BTC_SCAN_START;
1869 GLBtcWiFiInScanState = _TRUE;
1873 scanType = BTC_SCAN_FINISH;
1874 GLBtcWiFiInScanState = _FALSE;
1877 // All notify is called in cmd thread, don't need to leave low power again
1878 // halbtcoutsrc_LeaveLowPower(pBtCoexist);
1880 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
1882 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
1883 EXhalbtc8821aCsr2ant_ScanNotify(pBtCoexist, scanType);
1884 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
1885 EXhalbtc8821a2ant_ScanNotify(pBtCoexist, scanType);
1886 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1887 EXhalbtc8821a1ant_ScanNotify(pBtCoexist, scanType);
1889 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
1891 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1892 EXhalbtc8723b2ant_ScanNotify(pBtCoexist, scanType);
1893 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1894 EXhalbtc8723b1ant_ScanNotify(pBtCoexist, scanType);
1896 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
1898 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1899 EXhalbtc8192e2ant_ScanNotify(pBtCoexist, scanType);
1900 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1901 EXhalbtc8192e1ant_ScanNotify(pBtCoexist, scanType);
1903 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
1905 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1906 EXhalbtc8812a2ant_ScanNotify(pBtCoexist, scanType);
1907 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1908 EXhalbtc8812a1ant_ScanNotify(pBtCoexist, scanType);
1911 // halbtcoutsrc_NormalLowPower(pBtCoexist);
1914 void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action)
1918 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1920 pBtCoexist->statistics.cntConnectNotify++;
1921 if (pBtCoexist->bManualControl)
1925 assoType = BTC_ASSOCIATE_START;
1927 assoType = BTC_ASSOCIATE_FINISH;
1929 // All notify is called in cmd thread, don't need to leave low power again
1930 // halbtcoutsrc_LeaveLowPower(pBtCoexist);
1932 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
1934 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
1935 EXhalbtc8821aCsr2ant_ConnectNotify(pBtCoexist, assoType);
1936 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
1937 EXhalbtc8821a2ant_ConnectNotify(pBtCoexist, assoType);
1938 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1939 EXhalbtc8821a1ant_ConnectNotify(pBtCoexist, assoType);
1941 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
1943 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1944 EXhalbtc8723b2ant_ConnectNotify(pBtCoexist, assoType);
1945 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1946 EXhalbtc8723b1ant_ConnectNotify(pBtCoexist, assoType);
1948 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
1950 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1951 EXhalbtc8192e2ant_ConnectNotify(pBtCoexist, assoType);
1952 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1953 EXhalbtc8192e1ant_ConnectNotify(pBtCoexist, assoType);
1955 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
1957 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1958 EXhalbtc8812a2ant_ConnectNotify(pBtCoexist, assoType);
1959 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1960 EXhalbtc8812a1ant_ConnectNotify(pBtCoexist, assoType);
1963 // halbtcoutsrc_NormalLowPower(pBtCoexist);
1966 void EXhalbtcoutsrc_MediaStatusNotify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus)
1970 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
1973 pBtCoexist->statistics.cntMediaStatusNotify++;
1974 if (pBtCoexist->bManualControl)
1977 if (RT_MEDIA_CONNECT == mediaStatus)
1978 mStatus = BTC_MEDIA_CONNECT;
1980 mStatus = BTC_MEDIA_DISCONNECT;
1982 // All notify is called in cmd thread, don't need to leave low power again
1983 // halbtcoutsrc_LeaveLowPower(pBtCoexist);
1985 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
1987 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
1988 EXhalbtc8821aCsr2ant_MediaStatusNotify(pBtCoexist, mStatus);
1989 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
1990 EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, mStatus);
1991 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1992 EXhalbtc8821a1ant_MediaStatusNotify(pBtCoexist, mStatus);
1994 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
1996 if (pBtCoexist->boardInfo.btdmAntNum == 2)
1997 EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, mStatus);
1998 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
1999 EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, mStatus);
2001 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
2003 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2004 EXhalbtc8192e2ant_MediaStatusNotify(pBtCoexist, mStatus);
2005 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2006 EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, mStatus);
2008 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
2010 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2011 EXhalbtc8812a2ant_MediaStatusNotify(pBtCoexist, mStatus);
2012 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2013 EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, mStatus);
2016 // halbtcoutsrc_NormalLowPower(pBtCoexist);
2019 void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType)
2023 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2025 pBtCoexist->statistics.cntSpecialPacketNotify++;
2026 if (pBtCoexist->bManualControl)
2029 if (PACKET_DHCP == pktType)
2030 packetType = BTC_PACKET_DHCP;
2031 else if (PACKET_EAPOL == pktType)
2032 packetType = BTC_PACKET_EAPOL;
2033 else if (PACKET_ARP == pktType)
2034 packetType = BTC_PACKET_ARP;
2037 packetType = BTC_PACKET_UNKNOWN;
2041 // All notify is called in cmd thread, don't need to leave low power again
2042 // halbtcoutsrc_LeaveLowPower(pBtCoexist);
2044 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
2046 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
2047 EXhalbtc8821aCsr2ant_SpecialPacketNotify(pBtCoexist, packetType);
2048 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
2049 EXhalbtc8821a2ant_SpecialPacketNotify(pBtCoexist, packetType);
2050 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2051 EXhalbtc8821a1ant_SpecialPacketNotify(pBtCoexist, packetType);
2053 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2055 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2056 EXhalbtc8723b2ant_SpecialPacketNotify(pBtCoexist, packetType);
2057 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2058 EXhalbtc8723b1ant_SpecialPacketNotify(pBtCoexist, packetType);
2060 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
2062 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2063 EXhalbtc8192e2ant_SpecialPacketNotify(pBtCoexist, packetType);
2064 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2065 EXhalbtc8192e1ant_SpecialPacketNotify(pBtCoexist, packetType);
2067 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
2069 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2070 EXhalbtc8812a2ant_SpecialPacketNotify(pBtCoexist, packetType);
2071 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2072 EXhalbtc8812a1ant_SpecialPacketNotify(pBtCoexist, packetType);
2075 // halbtcoutsrc_NormalLowPower(pBtCoexist);
2078 void EXhalbtcoutsrc_BtInfoNotify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length)
2080 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2083 pBtCoexist->statistics.cntBtInfoNotify++;
2085 // All notify is called in cmd thread, don't need to leave low power again
2086 // halbtcoutsrc_LeaveLowPower(pBtCoexist);
2088 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
2090 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
2091 EXhalbtc8821aCsr2ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
2092 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
2093 EXhalbtc8821a2ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
2094 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2095 EXhalbtc8821a1ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
2097 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2099 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2100 EXhalbtc8723b2ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
2101 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2102 EXhalbtc8723b1ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
2104 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
2106 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2107 EXhalbtc8192e2ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
2108 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2109 EXhalbtc8192e1ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
2111 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
2113 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2114 EXhalbtc8812a2ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
2115 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2116 EXhalbtc8812a1ant_BtInfoNotify(pBtCoexist, tmpBuf, length);
2119 // halbtcoutsrc_NormalLowPower(pBtCoexist);
2123 EXhalbtcoutsrc_RfStatusNotify(
2124 IN PBTC_COEXIST pBtCoexist,
2128 if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2130 pBtCoexist->statistics.cntRfStatusNotify++;
2132 if(IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
2135 else if(IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2137 if(pBtCoexist->boardInfo.btdmAntNum == 1)
2138 EXhalbtc8723b1ant_RfStatusNotify(pBtCoexist, type);
2140 else if(IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
2143 else if(IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
2148 void EXhalbtcoutsrc_StackOperationNotify(PBTC_COEXIST pBtCoexist, u8 type)
2153 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2155 pBtCoexist->statistics.cntStackOperationNotify++;
2156 if (pBtCoexist->bManualControl)
2159 if ((HCI_BT_OP_INQUIRY_START == type) ||
2160 (HCI_BT_OP_PAGING_START == type) ||
2161 (HCI_BT_OP_PAIRING_START == type))
2163 stackOpType = BTC_STACK_OP_INQ_PAGE_PAIR_START;
2165 else if ((HCI_BT_OP_INQUIRY_FINISH == type) ||
2166 (HCI_BT_OP_PAGING_SUCCESS == type) ||
2167 (HCI_BT_OP_PAGING_UNSUCCESS == type) ||
2168 (HCI_BT_OP_PAIRING_FINISH == type) )
2170 stackOpType = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH;
2174 stackOpType = BTC_STACK_OP_NONE;
2180 void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist)
2182 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2185 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
2187 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
2188 EXhalbtc8821aCsr2ant_HaltNotify(pBtCoexist);
2189 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
2190 EXhalbtc8821a2ant_HaltNotify(pBtCoexist);
2191 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2192 EXhalbtc8821a1ant_HaltNotify(pBtCoexist);
2194 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2196 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2197 EXhalbtc8723b2ant_HaltNotify(pBtCoexist);
2198 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2199 EXhalbtc8723b1ant_HaltNotify(pBtCoexist);
2201 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
2203 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2204 EXhalbtc8192e2ant_HaltNotify(pBtCoexist);
2205 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2206 EXhalbtc8192e1ant_HaltNotify(pBtCoexist);
2208 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
2210 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2211 EXhalbtc8812a2ant_HaltNotify(pBtCoexist);
2212 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2213 EXhalbtc8812a1ant_HaltNotify(pBtCoexist);
2216 pBtCoexist->bBinded = FALSE;
2219 void EXhalbtcoutsrc_SwitchBtTRxMask(PBTC_COEXIST pBtCoexist)
2221 if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2223 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2225 halbtcoutsrc_SetBtReg(pBtCoexist, 0, 0x3c, 0x01); //BT goto standby while GNT_BT 1-->0
2227 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2229 halbtcoutsrc_SetBtReg(pBtCoexist, 0, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0
2234 void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
2236 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2240 // currently only 1ant we have to do the notification,
2241 // once pnp is notified to sleep state, we have to leave LPS that we can sleep normally.
2244 if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2246 if (pBtCoexist->boardInfo.btdmAntNum == 1)
2247 EXhalbtc8723b1ant_PnpNotify(pBtCoexist,pnpState);
2248 else if(pBtCoexist->boardInfo.btdmAntNum == 2)
2249 EXhalbtc8723b2ant_PnpNotify(pBtCoexist,pnpState);
2251 else if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
2253 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
2254 EXhalbtc8821aCsr2ant_PnpNotify(pBtCoexist, pnpState);
2255 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2256 EXhalbtc8821a1ant_PnpNotify(pBtCoexist,pnpState);
2257 else if(pBtCoexist->boardInfo.btdmAntNum == 2)
2258 EXhalbtc8821a2ant_PnpNotify(pBtCoexist,pnpState);
2260 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
2262 if (pBtCoexist->boardInfo.btdmAntNum == 1)
2263 EXhalbtc8192e1ant_PnpNotify(pBtCoexist, pnpState);
2265 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
2267 if (pBtCoexist->boardInfo.btdmAntNum == 1)
2268 EXhalbtc8812a1ant_PnpNotify(pBtCoexist, pnpState);
2272 void EXhalbtcoutsrc_CoexDmSwitch(PBTC_COEXIST pBtCoexist)
2274 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2276 pBtCoexist->statistics.cntCoexDmSwitch++;
2278 halbtcoutsrc_LeaveLowPower(pBtCoexist);
2280 if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2282 if (pBtCoexist->boardInfo.btdmAntNum == 1)
2284 pBtCoexist->bStopCoexDm = TRUE;
2285 EXhalbtc8723b1ant_CoexDmReset(pBtCoexist);
2286 EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_DETECTED, 2);
2287 EXhalbtc8723b2ant_InitHwConfig(pBtCoexist, FALSE);
2288 EXhalbtc8723b2ant_InitCoexDm(pBtCoexist);
2289 pBtCoexist->bStopCoexDm = FALSE;
2293 halbtcoutsrc_NormalLowPower(pBtCoexist);
2296 void EXhalbtcoutsrc_Periodical(PBTC_COEXIST pBtCoexist)
2298 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2300 pBtCoexist->statistics.cntPeriodical++;
2302 // Periodical should be called in cmd thread,
2303 // don't need to leave low power again
2304 // halbtcoutsrc_LeaveLowPower(pBtCoexist);
2306 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
2308 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
2309 EXhalbtc8821aCsr2ant_Periodical(pBtCoexist);
2310 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
2311 EXhalbtc8821a2ant_Periodical(pBtCoexist);
2312 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2314 if (!halbtcoutsrc_UnderIps(pBtCoexist))
2316 EXhalbtc8821a1ant_Periodical(pBtCoexist);
2320 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2322 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2323 EXhalbtc8723b2ant_Periodical(pBtCoexist);
2324 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2325 EXhalbtc8723b1ant_Periodical(pBtCoexist);
2327 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
2329 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2330 EXhalbtc8192e2ant_Periodical(pBtCoexist);
2331 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2332 EXhalbtc8192e1ant_Periodical(pBtCoexist);
2334 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
2336 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2337 EXhalbtc8812a2ant_Periodical(pBtCoexist);
2338 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2339 EXhalbtc8812a1ant_Periodical(pBtCoexist);
2342 // halbtcoutsrc_NormalLowPower(pBtCoexist);
2345 void EXhalbtcoutsrc_DbgControl(PBTC_COEXIST pBtCoexist, u8 opCode, u8 opLen, u8 *pData)
2347 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2350 pBtCoexist->statistics.cntDbgCtrl++;
2352 // This function doesn't be called yet,
2353 // default no need to leave low power to avoid deadlock
2354 // halbtcoutsrc_LeaveLowPower(pBtCoexist);
2356 if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
2358 if (pBtCoexist->boardInfo.btdmAntNum == 1)
2359 EXhalbtc8192e1ant_DbgControl(pBtCoexist, opCode, opLen, pData);
2361 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
2363 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2364 EXhalbtc8812a2ant_DbgControl(pBtCoexist, opCode, opLen, pData);
2365 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2366 EXhalbtc8812a1ant_DbgControl(pBtCoexist, opCode, opLen, pData);
2369 // halbtcoutsrc_NormalLowPower(pBtCoexist);
2374 EXhalbtcoutsrc_AntennaDetection(
2375 IN PBTC_COEXIST pBtCoexist,
2382 if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2385 /* Need to refine the following power save operations to enable this function in the future */
2387 IPSDisable(pBtCoexist->Adapter, FALSE, 0);
2388 LeisurePSLeave(pBtCoexist->Adapter, LPS_DISABLE_BT_COEX);
2391 if(IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2393 if(pBtCoexist->boardInfo.btdmAntNum == 1)
2394 EXhalbtc8723b1ant_AntennaDetection(pBtCoexist, centFreq, offset, span, seconds);
2397 //IPSReturn(pBtCoexist->Adapter, 0xff);
2401 void EXhalbtcoutsrc_StackUpdateProfileInfo(void)
2403 #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
2404 PBTC_COEXIST pBtCoexist = &GLBtCoexist;
2405 PADAPTER padapter = (PADAPTER)GLBtCoexist.Adapter;
2406 PBT_MGNT pBtMgnt = &padapter->coex_info.BtMgnt;
2409 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2412 pBtCoexist->stackInfo.bProfileNotified = _TRUE;
2414 pBtCoexist->stackInfo.numOfLink =
2415 pBtMgnt->ExtConfig.NumberOfACL+pBtMgnt->ExtConfig.NumberOfSCO;
2418 pBtCoexist->stackInfo.bBtLinkExist = _FALSE;
2419 pBtCoexist->stackInfo.bScoExist = _FALSE;
2420 pBtCoexist->stackInfo.bAclExist = _FALSE;
2421 pBtCoexist->stackInfo.bA2dpExist = _FALSE;
2422 pBtCoexist->stackInfo.bHidExist = _FALSE;
2423 pBtCoexist->stackInfo.numOfHid = 0;
2424 pBtCoexist->stackInfo.bPanExist = _FALSE;
2426 if (!pBtMgnt->ExtConfig.NumberOfACL)
2427 pBtCoexist->stackInfo.minBtRssi = 0;
2429 if (pBtCoexist->stackInfo.numOfLink)
2431 pBtCoexist->stackInfo.bBtLinkExist = _TRUE;
2432 if (pBtMgnt->ExtConfig.NumberOfSCO)
2433 pBtCoexist->stackInfo.bScoExist = _TRUE;
2434 if (pBtMgnt->ExtConfig.NumberOfACL)
2435 pBtCoexist->stackInfo.bAclExist = _TRUE;
2438 for (i=0; i<pBtMgnt->ExtConfig.NumberOfACL; i++)
2440 if (BT_PROFILE_A2DP == pBtMgnt->ExtConfig.aclLink[i].BTProfile)
2442 pBtCoexist->stackInfo.bA2dpExist = _TRUE;
2444 else if (BT_PROFILE_PAN == pBtMgnt->ExtConfig.aclLink[i].BTProfile)
2446 pBtCoexist->stackInfo.bPanExist = _TRUE;
2448 else if (BT_PROFILE_HID == pBtMgnt->ExtConfig.aclLink[i].BTProfile)
2450 pBtCoexist->stackInfo.bHidExist = _TRUE;
2451 pBtCoexist->stackInfo.numOfHid++;
2455 pBtCoexist->stackInfo.bUnknownAclExist = _TRUE;
2458 #endif //CONFIG_BT_COEXIST_SOCKET_TRX
2461 void EXhalbtcoutsrc_UpdateMinBtRssi(s8 btRssi)
2463 PBTC_COEXIST pBtCoexist = &GLBtCoexist;
2465 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2468 pBtCoexist->stackInfo.minBtRssi = btRssi;
2471 void EXhalbtcoutsrc_SetHciVersion(u16 hciVersion)
2473 PBTC_COEXIST pBtCoexist = &GLBtCoexist;
2475 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2478 pBtCoexist->stackInfo.hciVersion = hciVersion;
2481 void EXhalbtcoutsrc_SetBtPatchVersion(u16 btHciVersion, u16 btPatchVersion)
2483 PBTC_COEXIST pBtCoexist = &GLBtCoexist;
2485 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2488 pBtCoexist->btInfo.btRealFwVer = btPatchVersion;
2489 pBtCoexist->btInfo.btHciVer = btHciVersion;
2493 void EXhalbtcoutsrc_SetBtExist(u8 bBtExist)
2495 GLBtCoexist.boardInfo.bBtExist = bBtExist;
2498 void EXhalbtcoutsrc_SetChipType(u8 chipType)
2507 GLBtCoexist.boardInfo.btChipType = BTC_CHIP_UNDEF;
2510 GLBtCoexist.boardInfo.btChipType = BTC_CHIP_CSR_BC4;
2513 GLBtCoexist.boardInfo.btChipType = BTC_CHIP_CSR_BC8;
2516 GLBtCoexist.boardInfo.btChipType = BTC_CHIP_RTL8723A;
2519 GLBtCoexist.boardInfo.btChipType = BTC_CHIP_RTL8821;
2522 GLBtCoexist.boardInfo.btChipType = BTC_CHIP_RTL8723B;
2527 void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum)
2529 if (BT_COEX_ANT_TYPE_PG == type)
2531 GLBtCoexist.boardInfo.pgAntNum = antNum;
2532 GLBtCoexist.boardInfo.btdmAntNum = antNum;
2534 //The antenna position: Main (default) or Aux for pgAntNum=2 && btdmAntNum =1
2535 //The antenna position should be determined by auto-detect mechanism
2536 // The following is assumed to main, and those must be modified if y auto-detect mechanism is ready
2537 if ((GLBtCoexist.boardInfo.pgAntNum == 2) && (GLBtCoexist.boardInfo.btdmAntNum == 1) )
2538 GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
2540 GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
2543 else if (BT_COEX_ANT_TYPE_ANTDIV == type)
2545 GLBtCoexist.boardInfo.btdmAntNum = antNum;
2546 //GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
2548 else if (BT_COEX_ANT_TYPE_DETECTED == type)
2550 GLBtCoexist.boardInfo.btdmAntNum = antNum;
2551 //GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT;
2556 // Currently used by 8723b only, S0 or S1
2558 void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath)
2560 GLBtCoexist.boardInfo.singleAntPath = singleAntPath;
2563 void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist)
2565 if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2568 halbtcoutsrc_LeaveLowPower(pBtCoexist);
2570 if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter))
2572 if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
2573 EXhalbtc8821aCsr2ant_DisplayCoexInfo(pBtCoexist);
2574 else if (pBtCoexist->boardInfo.btdmAntNum == 2)
2575 EXhalbtc8821a2ant_DisplayCoexInfo(pBtCoexist);
2576 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2577 EXhalbtc8821a1ant_DisplayCoexInfo(pBtCoexist);
2579 else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2581 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2582 EXhalbtc8723b2ant_DisplayCoexInfo(pBtCoexist);
2583 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2584 EXhalbtc8723b1ant_DisplayCoexInfo(pBtCoexist);
2586 else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter))
2588 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2589 EXhalbtc8192e2ant_DisplayCoexInfo(pBtCoexist);
2590 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2591 EXhalbtc8192e1ant_DisplayCoexInfo(pBtCoexist);
2593 else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
2595 if (pBtCoexist->boardInfo.btdmAntNum == 2)
2596 EXhalbtc8812a2ant_DisplayCoexInfo(pBtCoexist);
2597 else if (pBtCoexist->boardInfo.btdmAntNum == 1)
2598 EXhalbtc8812a1ant_DisplayCoexInfo(pBtCoexist);
2601 halbtcoutsrc_NormalLowPower(pBtCoexist);
2604 void EXhalbtcoutsrc_DisplayAntDetection(PBTC_COEXIST pBtCoexist)
2606 if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
2609 halbtcoutsrc_LeaveLowPower(pBtCoexist);
2611 if(IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
2613 if(pBtCoexist->boardInfo.btdmAntNum == 1)
2614 EXhalbtc8723b1ant_DisplayAntDetection(pBtCoexist);
2617 halbtcoutsrc_NormalLowPower(pBtCoexist);
2620 static void halbt_InitHwConfig92C(PADAPTER padapter)
2622 PHAL_DATA_TYPE pHalData;
2626 pHalData = GET_HAL_DATA(padapter);
2627 if( (pHalData->bt_coexist.btChipType == BT_CSR_BC4) ||
2628 (pHalData->bt_coexist.btChipType == BT_CSR_BC8))
2630 if (pHalData->rf_type == RF_1T1R)
2633 u1Tmp = rtw_read8(padapter, rOFDM0_TRxPathEnable);
2635 rtw_write8(padapter, rOFDM0_TRxPathEnable, u1Tmp);
2636 RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xC04 = 0x%x\n", u1Tmp));
2638 u1Tmp = rtw_read8(padapter, rOFDM1_TRxPathEnable);
2640 rtw_write8(padapter, rOFDM1_TRxPathEnable, u1Tmp);
2641 RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xD04 = 0x%x\n", u1Tmp));
2646 static void halbt_InitHwConfig92D(PADAPTER padapter)
2648 PHAL_DATA_TYPE pHalData;
2651 pHalData = GET_HAL_DATA(padapter);
2652 if ((pHalData->bt_coexist.btChipType == BT_CSR_BC4) ||
2653 (pHalData->bt_coexist.btChipType == BT_CSR_BC8))
2655 if (pHalData->rf_type == RF_1T1R)
2658 u1Tmp = rtw_read8(padapter, rOFDM0_TRxPathEnable);
2660 rtw_write8(padapter, rOFDM0_TRxPathEnable, u1Tmp);
2661 RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xC04 = 0x%x\n", u1Tmp));
2663 u1Tmp = rtw_read8(padapter, rOFDM1_TRxPathEnable);
2665 rtw_write8(padapter, rOFDM1_TRxPathEnable, u1Tmp);
2666 RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xD04 = 0x%x\n", u1Tmp));
2673 * Run BT-Coexist mechansim or not
2676 void hal_btcoex_SetBTCoexist(PADAPTER padapter, u8 bBtExist)
2678 PHAL_DATA_TYPE pHalData;
2681 pHalData = GET_HAL_DATA(padapter);
2682 pHalData->bt_coexist.bBtExist = bBtExist;
2684 //EXhalbtcoutsrc_SetBtExist(bBtExist);
2689 * Check is co-exist mechanism enabled or not
2692 * _TRUE Enable BT co-exist mechanism
2693 * _FALSE Disable BT co-exist mechanism
2695 u8 hal_btcoex_IsBtExist(PADAPTER padapter)
2697 PHAL_DATA_TYPE pHalData;
2700 pHalData = GET_HAL_DATA(padapter);
2701 return pHalData->bt_coexist.bBtExist;
2704 u8 hal_btcoex_IsBtDisabled(PADAPTER padapter)
2706 if (!hal_btcoex_IsBtExist(padapter))
2709 if (GLBtCoexist.btInfo.bBtDisabled)
2715 void hal_btcoex_SetChipType(PADAPTER padapter, u8 chipType)
2717 PHAL_DATA_TYPE pHalData;
2720 pHalData = GET_HAL_DATA(padapter);
2721 pHalData->bt_coexist.btChipType = chipType;
2723 EXhalbtcoutsrc_SetChipType(chipType);
2726 u8 hal_btcoex_GetChipType(PADAPTER padapter)
2728 PHAL_DATA_TYPE pHalData;
2731 pHalData = GET_HAL_DATA(padapter);
2732 return pHalData->bt_coexist.btChipType;
2735 void hal_btcoex_SetPgAntNum(PADAPTER padapter, u8 antNum)
2737 PHAL_DATA_TYPE pHalData;
2740 pHalData = GET_HAL_DATA(padapter);
2742 pHalData->bt_coexist.btTotalAntNum = antNum;
2743 EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_PG, antNum);
2746 u8 hal_btcoex_GetPgAntNum(PADAPTER padapter)
2748 PHAL_DATA_TYPE pHalData;
2751 pHalData = GET_HAL_DATA(padapter);
2753 return pHalData->bt_coexist.btTotalAntNum;
2756 void hal_btcoex_SetSingleAntPath(PADAPTER padapter, u8 singleAntPath)
2758 EXhalbtcoutsrc_SetSingleAntPath(singleAntPath);
2761 u8 hal_btcoex_Initialize(PADAPTER padapter)
2767 _rtw_memset(&GLBtCoexist, 0, sizeof(GLBtCoexist));
2768 ret1 = EXhalbtcoutsrc_InitlizeVariables((void*)padapter);
2769 ret2 = (ret1==_TRUE) ? _TRUE : _FALSE;
2774 void hal_btcoex_PowerOnSetting(PADAPTER padapter)
2776 EXhalbtcoutsrc_PowerOnSetting(&GLBtCoexist);
2779 void hal_btcoex_PreLoadFirmware(PADAPTER padapter)
2781 EXhalbtcoutsrc_PreLoadFirmware(&GLBtCoexist);
2784 void hal_btcoex_InitHwConfig(PADAPTER padapter, u8 bWifiOnly)
2786 if (!hal_btcoex_IsBtExist(padapter))
2789 EXhalbtcoutsrc_InitHwConfig(&GLBtCoexist, bWifiOnly);
2790 EXhalbtcoutsrc_InitCoexDm(&GLBtCoexist);
2793 void hal_btcoex_IpsNotify(PADAPTER padapter, u8 type)
2795 EXhalbtcoutsrc_IpsNotify(&GLBtCoexist, type);
2798 void hal_btcoex_LpsNotify(PADAPTER padapter, u8 type)
2800 EXhalbtcoutsrc_LpsNotify(&GLBtCoexist, type);
2803 void hal_btcoex_ScanNotify(PADAPTER padapter, u8 type)
2805 EXhalbtcoutsrc_ScanNotify(&GLBtCoexist, type);
2808 void hal_btcoex_ConnectNotify(PADAPTER padapter, u8 action)
2810 EXhalbtcoutsrc_ConnectNotify(&GLBtCoexist, action);
2813 void hal_btcoex_MediaStatusNotify(PADAPTER padapter, u8 mediaStatus)
2815 EXhalbtcoutsrc_MediaStatusNotify(&GLBtCoexist, mediaStatus);
2818 void hal_btcoex_SpecialPacketNotify(PADAPTER padapter, u8 pktType)
2820 EXhalbtcoutsrc_SpecialPacketNotify(&GLBtCoexist, pktType);
2823 void hal_btcoex_IQKNotify(PADAPTER padapter, u8 state)
2825 GLBtcWiFiInIQKState = state;
2828 void hal_btcoex_BtInfoNotify(PADAPTER padapter, u8 length, u8 *tmpBuf)
2830 if (GLBtcWiFiInIQKState == _TRUE)
2833 EXhalbtcoutsrc_BtInfoNotify(&GLBtCoexist, tmpBuf, length);
2836 void hal_btcoex_SuspendNotify(PADAPTER padapter, u8 state)
2839 state = BTC_WIFI_PNP_SLEEP;
2841 state = BTC_WIFI_PNP_WAKE_UP;
2843 EXhalbtcoutsrc_PnpNotify(&GLBtCoexist, state);
2846 void hal_btcoex_HaltNotify(PADAPTER padapter)
2848 EXhalbtcoutsrc_HaltNotify(&GLBtCoexist);
2851 void hal_btcoex_SwitchBtTRxMask(PADAPTER padapter)
2853 EXhalbtcoutsrc_SwitchBtTRxMask(&GLBtCoexist);
2856 void hal_btcoex_Hanlder(PADAPTER padapter)
2858 EXhalbtcoutsrc_Periodical(&GLBtCoexist);
2861 s32 hal_btcoex_IsBTCoexRejectAMPDU(PADAPTER padapter)
2863 return (s32)GLBtCoexist.btInfo.bRejectAggPkt;
2866 s32 hal_btcoex_IsBTCoexCtrlAMPDUSize(PADAPTER padapter)
2868 return (s32)GLBtCoexist.btInfo.bBtCtrlAggBufSize;
2871 u32 hal_btcoex_GetAMPDUSize(PADAPTER padapter)
2873 return (u32)GLBtCoexist.btInfo.aggBufSize;
2876 void hal_btcoex_SetManualControl(PADAPTER padapter, u8 bmanual)
2878 GLBtCoexist.bManualControl = bmanual;
2881 u8 hal_btcoex_1Ant(PADAPTER padapter)
2883 if (hal_btcoex_IsBtExist(padapter) == _FALSE)
2886 if (GLBtCoexist.boardInfo.btdmAntNum == 1)
2892 u8 hal_btcoex_IsBtControlLps(PADAPTER padapter)
2894 if (hal_btcoex_IsBtExist(padapter) == _FALSE)
2897 if (GLBtCoexist.btInfo.bBtDisabled)
2900 if (GLBtCoexist.btInfo.bBtCtrlLps)
2906 u8 hal_btcoex_IsLpsOn(PADAPTER padapter)
2908 if (hal_btcoex_IsBtExist(padapter) == _FALSE)
2911 if (GLBtCoexist.btInfo.bBtDisabled)
2914 if (GLBtCoexist.btInfo.bBtLpsOn)
2920 u8 hal_btcoex_RpwmVal(PADAPTER padapter)
2922 return GLBtCoexist.btInfo.rpwmVal;
2925 u8 hal_btcoex_LpsVal(PADAPTER padapter)
2927 return GLBtCoexist.btInfo.lpsVal;
2930 u32 hal_btcoex_GetRaMask(PADAPTER padapter)
2932 if (!hal_btcoex_IsBtExist(padapter))
2935 if (GLBtCoexist.btInfo.bBtDisabled)
2938 /* Modify by YiWei , suggest by Cosa and Jenyu
2939 * Remove the limit antenna number , because 2 antenna case (ex: 8192eu)also want to get BT coex report rate mask.
2941 /*if (GLBtCoexist.boardInfo.btdmAntNum != 1)
2944 return GLBtCoexist.btInfo.raMask;
2947 void hal_btcoex_RecordPwrMode(PADAPTER padapter, u8 *pCmdBuf, u8 cmdLen)
2949 RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW write pwrModeCmd=0x%04x%08x\n",
2950 pCmdBuf[0]<<8|pCmdBuf[1],
2951 pCmdBuf[2]<<24|pCmdBuf[3]<<16|pCmdBuf[4]<<8|pCmdBuf[5]));
2953 _rtw_memcpy(GLBtCoexist.pwrModeVal, pCmdBuf, cmdLen);
2956 void hal_btcoex_DisplayBtCoexInfo(PADAPTER padapter, u8 *pbuf, u32 bufsize)
2961 pinfo = &GLBtcDbgInfo;
2962 DBG_BT_INFO_INIT(pinfo, pbuf, bufsize);
2963 EXhalbtcoutsrc_DisplayBtCoexInfo(&GLBtCoexist);
2964 DBG_BT_INFO_INIT(pinfo, NULL, 0);
2967 void hal_btcoex_SetDBG(PADAPTER padapter, u32 *pDbgModule)
2972 if (NULL == pDbgModule)
2975 for (i = 0; i < COMP_MAX; i++)
2976 GLBtcDbgType[i] = pDbgModule[i];
2979 u32 hal_btcoex_GetDBG(PADAPTER padapter, u8 *pStrBuf, u32 bufSize)
2986 if ((NULL == pStrBuf) || (0 == bufSize))
2992 // DBG_871X(FUNC_ADPT_FMT ": bufsize=%d\n", FUNC_ADPT_ARG(padapter), bufSize);
2994 count = rtw_sprintf(pstr, leftSize, "#define DBG\t%d\n", DBG);
2995 if ((count < 0) || (count >= leftSize))
3000 count = rtw_sprintf(pstr, leftSize, "BTCOEX Debug Setting:\n");
3001 if ((count < 0) || (count >= leftSize))
3006 count = rtw_sprintf(pstr, leftSize,
3007 "COMP_COEX: 0x%08X\n\n",
3008 GLBtcDbgType[COMP_COEX]);
3009 if ((count < 0) || (count >= leftSize))
3015 count = rtw_sprintf(pstr, leftSize, "INTERFACE Debug Setting Definition:\n");
3016 if ((count < 0) || (count >= leftSize))
3020 count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for INTF_INIT\n",
3021 GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_INIT?1:0);
3022 if ((count < 0) || (count >= leftSize))
3026 count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for INTF_NOTIFY\n\n",
3027 GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_NOTIFY?1:0);
3028 if ((count < 0) || (count >= leftSize))
3033 count = rtw_sprintf(pstr, leftSize, "ALGORITHM Debug Setting Definition:\n");
3034 if ((count < 0) || (count >= leftSize))
3038 count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for BT_RSSI_STATE\n",
3039 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_RSSI_STATE?1:0);
3040 if ((count < 0) || (count >= leftSize))
3044 count = rtw_sprintf(pstr, leftSize, "\tbit[1]=%d for WIFI_RSSI_STATE\n",
3045 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_WIFI_RSSI_STATE?1:0);
3046 if ((count < 0) || (count >= leftSize))
3050 count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for BT_MONITOR\n",
3051 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_MONITOR?1:0);
3052 if ((count < 0) || (count >= leftSize))
3056 count = rtw_sprintf(pstr, leftSize, "\tbit[3]=%d for TRACE\n",
3057 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE?1:0);
3058 if ((count < 0) || (count >= leftSize))
3062 count = rtw_sprintf(pstr, leftSize, "\tbit[4]=%d for TRACE_FW\n",
3063 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW?1:0);
3064 if ((count < 0) || (count >= leftSize))
3068 count = rtw_sprintf(pstr, leftSize, "\tbit[5]=%d for TRACE_FW_DETAIL\n",
3069 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_DETAIL?1:0);
3070 if ((count < 0) || (count >= leftSize))
3074 count = rtw_sprintf(pstr, leftSize, "\tbit[6]=%d for TRACE_FW_EXEC\n",
3075 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_EXEC?1:0);
3076 if ((count < 0) || (count >= leftSize))
3080 count = rtw_sprintf(pstr, leftSize, "\tbit[7]=%d for TRACE_SW\n",
3081 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW?1:0);
3082 if ((count < 0) || (count >= leftSize))
3086 count = rtw_sprintf(pstr, leftSize, "\tbit[8]=%d for TRACE_SW_DETAIL\n",
3087 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_DETAIL?1:0);
3088 if ((count < 0) || (count >= leftSize))
3092 count = rtw_sprintf(pstr, leftSize, "\tbit[9]=%d for TRACE_SW_EXEC\n",
3093 GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_EXEC?1:0);
3094 if ((count < 0) || (count >= leftSize))
3101 count = pstr - pStrBuf;
3102 // DBG_871X(FUNC_ADPT_FMT ": usedsize=%d\n", FUNC_ADPT_ARG(padapter), count);
3107 u8 hal_btcoex_IncreaseScanDeviceNum(PADAPTER padapter)
3109 if (!hal_btcoex_IsBtExist(padapter))
3112 if (GLBtCoexist.btInfo.bIncreaseScanDevNum)
3118 u8 hal_btcoex_IsBtLinkExist(PADAPTER padapter)
3120 if (GLBtCoexist.btLinkInfo.bBtLinkExist)
3126 void hal_btcoex_SetBtPatchVersion(PADAPTER padapter,u16 btHciVer,u16 btPatchVer)
3128 EXhalbtcoutsrc_SetBtPatchVersion(btHciVer,btPatchVer);
3131 void hal_btcoex_SetHciVersion(PADAPTER padapter, u16 hciVersion)
3133 EXhalbtcoutsrc_SetHciVersion(hciVersion);
3136 void hal_btcoex_StackUpdateProfileInfo(void)
3138 EXhalbtcoutsrc_StackUpdateProfileInfo();
3143 * Setting BT coex antenna isolation type .
3144 * coex mechanisn/ spital stream/ best throughput
3145 * anttype = 0 , PSTDMA / 2SS / 0.5T , bad isolation , WiFi/BT ANT Distance<15cm , (<20dB) for 2,3 antenna
3146 * anttype = 1 , PSTDMA / 1SS / 0.5T , normal isolaiton , 50cm>WiFi/BT ANT Distance>15cm , (>20dB) for 2 antenna
3147 * anttype = 2 , TDMA / 2SS / T , normal isolaiton , 50cm>WiFi/BT ANT Distance>15cm , (>20dB) for 3 antenna
3148 * anttype = 3 , no TDMA / 1SS / 0.5T , good isolation , WiFi/BT ANT Distance >50cm , (>40dB) for 2 antenna
3149 * anttype = 4 , no TDMA / 2SS / T , good isolation , WiFi/BT ANT Distance >50cm , (>40dB) for 3 antenna
3150 * wifi only throughput ~ T
3151 * wifi/BT share one antenna with SPDT
3153 void hal_btcoex_SetAntIsolationType(PADAPTER padapter, u8 anttype)
3155 PHAL_DATA_TYPE pHalData;
3156 PBTC_COEXIST pBtCoexist = &GLBtCoexist;
3158 /*DBG_871X("####%s , anttype = %d , %d\n" , __func__ , anttype , __LINE__); */
3159 pHalData = GET_HAL_DATA(padapter);
3162 pHalData->bt_coexist.btAntisolation = anttype;
3164 switch (pHalData->bt_coexist.btAntisolation) {
3166 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_0;
3169 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_1;
3172 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_2;
3175 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_3;
3178 pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_4;
3184 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
3186 hal_btcoex_ParseAntIsolationConfigFile(
3191 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
3193 char *szLine , *ptmp;
3194 int rtStatus = _SUCCESS;
3195 char param_value_string[10];
3199 u8 ant_num = 3 , ant_distance = 50 , rfe_type = 1;
3201 typedef struct ant_isolation {
3202 char *param_name; /* antenna isolation config parameter name */
3203 u8 *value; /* antenna isolation config parameter value */
3206 ANT_ISOLATION ant_isolation_param[] = {
3207 {"ANT_NUMBER" , &ant_num},
3208 {"ANT_DISTANCE" , &ant_distance},
3209 {"RFE_TYPE" , &rfe_type},
3215 /* DBG_871X("===>Hal_ParseAntIsolationConfigFile()\n" ); */
3218 for (szLine = GetLineFromBuffer(ptmp) ; szLine != NULL; szLine = GetLineFromBuffer(ptmp)) {
3220 if (IsCommentString(szLine))
3223 /* DBG_871X("%s : szLine = %s , strlen(szLine) = %d\n" , __func__ , szLine , strlen(szLine));*/
3224 for (j = 0 ; ant_isolation_param[j].param_name != NULL ; j++) {
3225 if (strstr(szLine , ant_isolation_param[j].param_name) != NULL) {
3227 while (i < strlen(szLine)) {
3228 if (szLine[i] != '"')
3231 /* skip only has one " */
3232 if (strpbrk(szLine , "\"") == strrchr(szLine , '"')) {
3233 DBG_871X("Fail to parse parameters , format error!\n");
3236 _rtw_memset((PVOID)param_value_string , 0 , 10);
3237 if (!ParseQualifiedString(szLine , &i , param_value_string , '"' , '"')) {
3238 DBG_871X("Fail to parse parameters\n");
3240 } else if (!GetU1ByteIntegerFromStringInDecimal(param_value_string , ant_isolation_param[j].value))
3241 DBG_871X("Fail to GetU1ByteIntegerFromStringInDecimal\n");
3250 /* YiWei 20140716 , for BT coex antenna isolation control */
3251 /* rfe_type = 0 was SPDT , rfe_type = 1 was coupler */
3252 if (ant_num == 3 && ant_distance >= 50)
3254 else if (ant_num == 2 && ant_distance >= 50 && rfe_type == 1)
3256 else if (ant_num == 3 && ant_distance >= 15 && ant_distance < 50)
3258 else if (ant_num == 2 && ant_distance >= 15 && ant_distance < 50 && rfe_type == 1)
3260 else if ((ant_num == 2 && ant_distance < 15 && rfe_type == 1) || (ant_num == 3 && ant_distance < 15))
3262 else if (ant_num == 2 && rfe_type == 0)
3267 hal_btcoex_SetAntIsolationType(Adapter, anttype);
3269 DBG_871X("%s : ant_num = %d\n" , __func__ , ant_num);
3270 DBG_871X("%s : ant_distance = %d\n" , __func__ , ant_distance);
3271 DBG_871X("%s : rfe_type = %d\n" , __func__ , rfe_type);
3272 /* DBG_871X("<===Hal_ParseAntIsolationConfigFile()\n"); */
3278 hal_btcoex_AntIsolationConfig_ParaFile(
3279 IN PADAPTER Adapter,
3283 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
3284 int rlen = 0 , rtStatus = _FAIL;
3286 _rtw_memset(pHalData->para_file_buf , 0 , MAX_PARA_FILE_BUF_LEN);
3289 rtw_merge_string(file_path, PATH_LENGTH_MAX, rtw_phy_file_path, pFileName);
3291 if (rtw_is_file_readable(file_path) == _TRUE)
3293 rlen = rtw_retrive_from_file(file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
3296 rtStatus = _SUCCESS;
3301 if (rtStatus == _SUCCESS) {
3302 /*DBG_871X("%s(): read %s ok\n", __func__ , pFileName);*/
3303 rtStatus = hal_btcoex_ParseAntIsolationConfigFile(Adapter , pHalData->para_file_buf);
3305 DBG_871X("%s(): No File %s, Load from *** Array!\n" , __func__ , pFileName);
3310 #endif // CONFIG_LOAD_PHY_PARA_FROM_FILE
3311 #endif // CONFIG_BT_COEXIST