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 ((RT_MEDIA_CONNECT == mediaStatus)
59 && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true))
61 rtw_hal_set_hwreg(padapter, HW_VAR_DL_RSVD_PAGE, NULL);
64 hal_btcoex_MediaStatusNotify(padapter, mediaStatus);
67 void rtw_btcoex_SpecialPacketNotify(struct adapter *padapter, u8 pktType)
69 hal_btcoex_SpecialPacketNotify(padapter, pktType);
72 void rtw_btcoex_IQKNotify(struct adapter *padapter, u8 state)
74 hal_btcoex_IQKNotify(padapter, state);
77 void rtw_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf)
79 hal_btcoex_BtInfoNotify(padapter, length, tmpBuf);
82 void rtw_btcoex_SuspendNotify(struct adapter *padapter, u8 state)
84 hal_btcoex_SuspendNotify(padapter, state);
87 void rtw_btcoex_HaltNotify(struct adapter *padapter)
89 if (false == padapter->bup)
91 DBG_871X(FUNC_ADPT_FMT ": bup =%d Skip!\n",
92 FUNC_ADPT_ARG(padapter), padapter->bup);
97 if (true == padapter->bSurpriseRemoved)
99 DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n",
100 FUNC_ADPT_ARG(padapter), padapter->bSurpriseRemoved);
105 hal_btcoex_HaltNotify(padapter);
108 u8 rtw_btcoex_IsBtDisabled(struct adapter *padapter)
110 return hal_btcoex_IsBtDisabled(padapter);
113 void rtw_btcoex_Handler(struct adapter *padapter)
115 hal_btcoex_Hanlder(padapter);
118 s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter)
122 coexctrl = hal_btcoex_IsBTCoexCtrlAMPDUSize(padapter);
127 void rtw_btcoex_SetManualControl(struct adapter *padapter, u8 manual)
131 hal_btcoex_SetManualControl(padapter, true);
135 hal_btcoex_SetManualControl(padapter, false);
139 u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter)
141 return hal_btcoex_IsBtControlLps(padapter);
144 u8 rtw_btcoex_IsLpsOn(struct adapter *padapter)
146 return hal_btcoex_IsLpsOn(padapter);
149 u8 rtw_btcoex_RpwmVal(struct adapter *padapter)
151 return hal_btcoex_RpwmVal(padapter);
154 u8 rtw_btcoex_LpsVal(struct adapter *padapter)
156 return hal_btcoex_LpsVal(padapter);
159 void rtw_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist)
161 hal_btcoex_SetBTCoexist(padapter, bBtExist);
164 void rtw_btcoex_SetChipType(struct adapter *padapter, u8 chipType)
166 hal_btcoex_SetChipType(padapter, chipType);
169 void rtw_btcoex_SetPGAntNum(struct adapter *padapter, u8 antNum)
171 hal_btcoex_SetPgAntNum(padapter, antNum);
174 void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath)
176 hal_btcoex_SetSingleAntPath(padapter, singleAntPath);
179 u32 rtw_btcoex_GetRaMask(struct adapter *padapter)
181 return hal_btcoex_GetRaMask(padapter);
184 void rtw_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen)
186 hal_btcoex_RecordPwrMode(padapter, pCmdBuf, cmdLen);
189 void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize)
191 hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize);
194 void rtw_btcoex_SetDBG(struct adapter *padapter, u32 *pDbgModule)
196 hal_btcoex_SetDBG(padapter, pDbgModule);
199 u32 rtw_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
201 return hal_btcoex_GetDBG(padapter, pStrBuf, bufSize);
204 /* ================================================== */
205 /* Below Functions are called by BT-Coex */
206 /* ================================================== */
207 void rtw_btcoex_RejectApAggregatedPacket(struct adapter *padapter, u8 enable)
209 struct mlme_ext_info *pmlmeinfo;
210 struct sta_info *psta;
212 pmlmeinfo = &padapter->mlmeextpriv.mlmext_info;
213 psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
217 pmlmeinfo->bAcceptAddbaReq = false;
219 send_delba(padapter, 0, psta->hwaddr);
223 pmlmeinfo->bAcceptAddbaReq = true;
227 void rtw_btcoex_LPS_Enter(struct adapter *padapter)
229 struct pwrctrl_priv *pwrpriv;
233 pwrpriv = adapter_to_pwrctl(padapter);
235 pwrpriv->bpower_saving = true;
236 lpsVal = rtw_btcoex_LpsVal(padapter);
237 rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, lpsVal, "BTCOEX");
240 void rtw_btcoex_LPS_Leave(struct adapter *padapter)
242 struct pwrctrl_priv *pwrpriv;
245 pwrpriv = adapter_to_pwrctl(padapter);
247 if (pwrpriv->pwr_mode != PS_MODE_ACTIVE)
249 rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "BTCOEX");
250 LPS_RF_ON_check(padapter, 100);
251 pwrpriv->bpower_saving = false;