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 ******************************************************************************/
15 #include <drv_types.h>
16 #include <rtw_debug.h>
17 #include <rtw_btcoex.h>
18 #include <hal_btcoex.h>
21 void rtw_btcoex_Initialize(struct adapter *padapter)
23 hal_btcoex_Initialize(padapter);
26 void rtw_btcoex_PowerOnSetting(struct adapter *padapter)
28 hal_btcoex_PowerOnSetting(padapter);
31 void rtw_btcoex_HAL_Initialize(struct adapter *padapter, u8 bWifiOnly)
33 hal_btcoex_InitHwConfig(padapter, bWifiOnly);
36 void rtw_btcoex_IpsNotify(struct adapter *padapter, u8 type)
38 hal_btcoex_IpsNotify(padapter, type);
41 void rtw_btcoex_LpsNotify(struct adapter *padapter, u8 type)
43 hal_btcoex_LpsNotify(padapter, type);
46 void rtw_btcoex_ScanNotify(struct adapter *padapter, u8 type)
48 hal_btcoex_ScanNotify(padapter, type);
51 void rtw_btcoex_ConnectNotify(struct adapter *padapter, u8 action)
53 hal_btcoex_ConnectNotify(padapter, action);
56 void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus)
58 if ((mediaStatus == RT_MEDIA_CONNECT)
59 && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true)) {
60 rtw_hal_set_hwreg(padapter, HW_VAR_DL_RSVD_PAGE, NULL);
63 hal_btcoex_MediaStatusNotify(padapter, mediaStatus);
66 void rtw_btcoex_SpecialPacketNotify(struct adapter *padapter, u8 pktType)
68 hal_btcoex_SpecialPacketNotify(padapter, pktType);
71 void rtw_btcoex_IQKNotify(struct adapter *padapter, u8 state)
73 hal_btcoex_IQKNotify(padapter, state);
76 void rtw_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf)
78 hal_btcoex_BtInfoNotify(padapter, length, tmpBuf);
81 void rtw_btcoex_SuspendNotify(struct adapter *padapter, u8 state)
83 hal_btcoex_SuspendNotify(padapter, state);
86 void rtw_btcoex_HaltNotify(struct adapter *padapter)
88 if (false == padapter->bup) {
89 DBG_871X(FUNC_ADPT_FMT ": bup =%d Skip!\n",
90 FUNC_ADPT_ARG(padapter), padapter->bup);
95 if (true == padapter->bSurpriseRemoved) {
96 DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n",
97 FUNC_ADPT_ARG(padapter), padapter->bSurpriseRemoved);
102 hal_btcoex_HaltNotify(padapter);
105 u8 rtw_btcoex_IsBtDisabled(struct adapter *padapter)
107 return hal_btcoex_IsBtDisabled(padapter);
110 void rtw_btcoex_Handler(struct adapter *padapter)
112 hal_btcoex_Hanlder(padapter);
115 s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter)
119 coexctrl = hal_btcoex_IsBTCoexCtrlAMPDUSize(padapter);
124 void rtw_btcoex_SetManualControl(struct adapter *padapter, u8 manual)
126 if (true == manual) {
127 hal_btcoex_SetManualControl(padapter, true);
129 hal_btcoex_SetManualControl(padapter, false);
133 u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter)
135 return hal_btcoex_IsBtControlLps(padapter);
138 u8 rtw_btcoex_IsLpsOn(struct adapter *padapter)
140 return hal_btcoex_IsLpsOn(padapter);
143 u8 rtw_btcoex_RpwmVal(struct adapter *padapter)
145 return hal_btcoex_RpwmVal(padapter);
148 u8 rtw_btcoex_LpsVal(struct adapter *padapter)
150 return hal_btcoex_LpsVal(padapter);
153 void rtw_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist)
155 hal_btcoex_SetBTCoexist(padapter, bBtExist);
158 void rtw_btcoex_SetChipType(struct adapter *padapter, u8 chipType)
160 hal_btcoex_SetChipType(padapter, chipType);
163 void rtw_btcoex_SetPGAntNum(struct adapter *padapter, u8 antNum)
165 hal_btcoex_SetPgAntNum(padapter, antNum);
168 void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath)
170 hal_btcoex_SetSingleAntPath(padapter, singleAntPath);
173 u32 rtw_btcoex_GetRaMask(struct adapter *padapter)
175 return hal_btcoex_GetRaMask(padapter);
178 void rtw_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen)
180 hal_btcoex_RecordPwrMode(padapter, pCmdBuf, cmdLen);
183 void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize)
185 hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize);
188 void rtw_btcoex_SetDBG(struct adapter *padapter, u32 *pDbgModule)
190 hal_btcoex_SetDBG(padapter, pDbgModule);
193 u32 rtw_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
195 return hal_btcoex_GetDBG(padapter, pStrBuf, bufSize);
198 /* ================================================== */
199 /* Below Functions are called by BT-Coex */
200 /* ================================================== */
201 void rtw_btcoex_RejectApAggregatedPacket(struct adapter *padapter, u8 enable)
203 struct mlme_ext_info *pmlmeinfo;
204 struct sta_info *psta;
206 pmlmeinfo = &padapter->mlmeextpriv.mlmext_info;
207 psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
209 if (true == enable) {
210 pmlmeinfo->bAcceptAddbaReq = false;
212 send_delba(padapter, 0, psta->hwaddr);
214 pmlmeinfo->bAcceptAddbaReq = true;
218 void rtw_btcoex_LPS_Enter(struct adapter *padapter)
220 struct pwrctrl_priv *pwrpriv;
224 pwrpriv = adapter_to_pwrctl(padapter);
226 pwrpriv->bpower_saving = true;
227 lpsVal = rtw_btcoex_LpsVal(padapter);
228 rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, lpsVal, "BTCOEX");
231 void rtw_btcoex_LPS_Leave(struct adapter *padapter)
233 struct pwrctrl_priv *pwrpriv;
236 pwrpriv = adapter_to_pwrctl(padapter);
238 if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) {
239 rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "BTCOEX");
240 LPS_RF_ON_check(padapter, 100);
241 pwrpriv->bpower_saving = false;