OSDN Git Service

staging: rtl8723bs: update to the latest driver
[android-x86/kernel.git] / drivers / staging / rtl8723bs / core / rtw_btcoex.c
1 /******************************************************************************
2  *
3  * Copyright(c) 2013 Realtek Corporation. All rights reserved.
4  *
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.
8  *
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
12  * more details.
13  *
14  ******************************************************************************/
15 #include <drv_types.h>
16 #include <rtw_debug.h>
17 #include <rtw_btcoex.h>
18 #include <hal_btcoex.h>
19
20
21 void rtw_btcoex_Initialize(struct adapter *padapter)
22 {
23         hal_btcoex_Initialize(padapter);
24 }
25
26 void rtw_btcoex_PowerOnSetting(struct adapter *padapter)
27 {
28         hal_btcoex_PowerOnSetting(padapter);
29 }
30
31 void rtw_btcoex_HAL_Initialize(struct adapter *padapter, u8 bWifiOnly)
32 {
33         hal_btcoex_InitHwConfig(padapter, bWifiOnly);
34 }
35
36 void rtw_btcoex_IpsNotify(struct adapter *padapter, u8 type)
37 {
38         hal_btcoex_IpsNotify(padapter, type);
39 }
40
41 void rtw_btcoex_LpsNotify(struct adapter *padapter, u8 type)
42 {
43         hal_btcoex_LpsNotify(padapter, type);
44 }
45
46 void rtw_btcoex_ScanNotify(struct adapter *padapter, u8 type)
47 {
48         hal_btcoex_ScanNotify(padapter, type);
49 }
50
51 void rtw_btcoex_ConnectNotify(struct adapter *padapter, u8 action)
52 {
53         hal_btcoex_ConnectNotify(padapter, action);
54 }
55
56 void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus)
57 {
58         if ((RT_MEDIA_CONNECT == mediaStatus)
59                 && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true))
60         {
61                 rtw_hal_set_hwreg(padapter, HW_VAR_DL_RSVD_PAGE, NULL);
62         }
63
64         hal_btcoex_MediaStatusNotify(padapter, mediaStatus);
65 }
66
67 void rtw_btcoex_SpecialPacketNotify(struct adapter *padapter, u8 pktType)
68 {
69         hal_btcoex_SpecialPacketNotify(padapter, pktType);
70 }
71
72 void rtw_btcoex_IQKNotify(struct adapter *padapter, u8 state)
73 {
74         hal_btcoex_IQKNotify(padapter, state);
75 }
76
77 void rtw_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf)
78 {
79         hal_btcoex_BtInfoNotify(padapter, length, tmpBuf);
80 }
81
82 void rtw_btcoex_SuspendNotify(struct adapter *padapter, u8 state)
83 {
84         hal_btcoex_SuspendNotify(padapter, state);
85 }
86
87 void rtw_btcoex_HaltNotify(struct adapter *padapter)
88 {
89         if (false == padapter->bup)
90         {
91                 DBG_871X(FUNC_ADPT_FMT ": bup =%d Skip!\n",
92                         FUNC_ADPT_ARG(padapter), padapter->bup);
93
94                 return;
95         }
96
97         if (true == padapter->bSurpriseRemoved)
98         {
99                 DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n",
100                         FUNC_ADPT_ARG(padapter), padapter->bSurpriseRemoved);
101
102                 return;
103         }
104
105         hal_btcoex_HaltNotify(padapter);
106 }
107
108 u8 rtw_btcoex_IsBtDisabled(struct adapter *padapter)
109 {
110         return hal_btcoex_IsBtDisabled(padapter);
111 }
112
113 void rtw_btcoex_Handler(struct adapter *padapter)
114 {
115         hal_btcoex_Hanlder(padapter);
116 }
117
118 s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter)
119 {
120         s32 coexctrl;
121
122         coexctrl = hal_btcoex_IsBTCoexCtrlAMPDUSize(padapter);
123
124         return coexctrl;
125 }
126
127 void rtw_btcoex_SetManualControl(struct adapter *padapter, u8 manual)
128 {
129         if (true == manual)
130         {
131                 hal_btcoex_SetManualControl(padapter, true);
132         }
133         else
134         {
135                 hal_btcoex_SetManualControl(padapter, false);
136         }
137 }
138
139 u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter)
140 {
141         return hal_btcoex_IsBtControlLps(padapter);
142 }
143
144 u8 rtw_btcoex_IsLpsOn(struct adapter *padapter)
145 {
146         return hal_btcoex_IsLpsOn(padapter);
147 }
148
149 u8 rtw_btcoex_RpwmVal(struct adapter *padapter)
150 {
151         return hal_btcoex_RpwmVal(padapter);
152 }
153
154 u8 rtw_btcoex_LpsVal(struct adapter *padapter)
155 {
156         return hal_btcoex_LpsVal(padapter);
157 }
158
159 void rtw_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist)
160 {
161         hal_btcoex_SetBTCoexist(padapter, bBtExist);
162 }
163
164 void rtw_btcoex_SetChipType(struct adapter *padapter, u8 chipType)
165 {
166         hal_btcoex_SetChipType(padapter, chipType);
167 }
168
169 void rtw_btcoex_SetPGAntNum(struct adapter *padapter, u8 antNum)
170 {
171         hal_btcoex_SetPgAntNum(padapter, antNum);
172 }
173
174 void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath)
175 {
176         hal_btcoex_SetSingleAntPath(padapter, singleAntPath);
177 }
178
179 u32 rtw_btcoex_GetRaMask(struct adapter *padapter)
180 {
181         return hal_btcoex_GetRaMask(padapter);
182 }
183
184 void rtw_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen)
185 {
186         hal_btcoex_RecordPwrMode(padapter, pCmdBuf, cmdLen);
187 }
188
189 void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize)
190 {
191         hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize);
192 }
193
194 void rtw_btcoex_SetDBG(struct adapter *padapter, u32 *pDbgModule)
195 {
196         hal_btcoex_SetDBG(padapter, pDbgModule);
197 }
198
199 u32 rtw_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
200 {
201         return hal_btcoex_GetDBG(padapter, pStrBuf, bufSize);
202 }
203
204 /*  ================================================== */
205 /*  Below Functions are called by BT-Coex */
206 /*  ================================================== */
207 void rtw_btcoex_RejectApAggregatedPacket(struct adapter *padapter, u8 enable)
208 {
209         struct mlme_ext_info *pmlmeinfo;
210         struct sta_info *psta;
211
212         pmlmeinfo = &padapter->mlmeextpriv.mlmext_info;
213         psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
214
215         if (true == enable)
216         {
217                 pmlmeinfo->bAcceptAddbaReq = false;
218                 if (psta)
219                         send_delba(padapter, 0, psta->hwaddr);
220         }
221         else
222         {
223                 pmlmeinfo->bAcceptAddbaReq = true;
224         }
225 }
226
227 void rtw_btcoex_LPS_Enter(struct adapter *padapter)
228 {
229         struct pwrctrl_priv *pwrpriv;
230         u8 lpsVal;
231
232
233         pwrpriv = adapter_to_pwrctl(padapter);
234
235         pwrpriv->bpower_saving = true;
236         lpsVal = rtw_btcoex_LpsVal(padapter);
237         rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, lpsVal, "BTCOEX");
238 }
239
240 void rtw_btcoex_LPS_Leave(struct adapter *padapter)
241 {
242         struct pwrctrl_priv *pwrpriv;
243
244
245         pwrpriv = adapter_to_pwrctl(padapter);
246
247         if (pwrpriv->pwr_mode != PS_MODE_ACTIVE)
248         {
249                 rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "BTCOEX");
250                 LPS_RF_ON_check(padapter, 100);
251                 pwrpriv->bpower_saving = false;
252         }
253 }