diff options
Diffstat (limited to 'drivers/net/wireless/rtlwifi/rtl8723ae/hal_bt_coexist.c')
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8723ae/hal_bt_coexist.c | 542 |
1 files changed, 542 insertions, 0 deletions
diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/hal_bt_coexist.c b/drivers/net/wireless/rtlwifi/rtl8723ae/hal_bt_coexist.c new file mode 100644 index 000000000000..3d092e4b0b7f --- /dev/null +++ b/drivers/net/wireless/rtlwifi/rtl8723ae/hal_bt_coexist.c | |||
@@ -0,0 +1,542 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Copyright(c) 2009-2012 Realtek Corporation. | ||
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 | * 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 | ||
17 | * | ||
18 | * The full GNU General Public License is included in this distribution in the | ||
19 | * file called LICENSE. | ||
20 | * | ||
21 | * Contact Information: | ||
22 | * wlanfae <wlanfae@realtek.com> | ||
23 | * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||
24 | * Hsinchu 300, Taiwan. | ||
25 | * | ||
26 | * Larry Finger <Larry.Finger@lwfinger.net> | ||
27 | * | ||
28 | *****************************************************************************/ | ||
29 | |||
30 | #include "hal_bt_coexist.h" | ||
31 | #include "../pci.h" | ||
32 | #include "dm.h" | ||
33 | #include "fw.h" | ||
34 | #include "phy.h" | ||
35 | #include "reg.h" | ||
36 | #include "hal_btc.h" | ||
37 | |||
38 | void rtl8723ae_dm_bt_reject_ap_aggregated_packet(struct ieee80211_hw *hw, | ||
39 | bool reject) | ||
40 | { | ||
41 | } | ||
42 | |||
43 | void _rtl8723_dm_bt_check_wifi_state(struct ieee80211_hw *hw) | ||
44 | { | ||
45 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
46 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
47 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
48 | |||
49 | if (rtlpriv->link_info.busytraffic) { | ||
50 | rtlpcipriv->bt_coexist.cstate &= ~BT_COEX_STATE_WIFI_IDLE; | ||
51 | |||
52 | if (rtlpriv->link_info.tx_busy_traffic) | ||
53 | rtlpcipriv->bt_coexist.cstate |= | ||
54 | BT_COEX_STATE_WIFI_UPLINK; | ||
55 | else | ||
56 | rtlpcipriv->bt_coexist.cstate &= | ||
57 | ~BT_COEX_STATE_WIFI_UPLINK; | ||
58 | |||
59 | if (rtlpriv->link_info.rx_busy_traffic) | ||
60 | rtlpcipriv->bt_coexist.cstate |= | ||
61 | BT_COEX_STATE_WIFI_DOWNLINK; | ||
62 | else | ||
63 | rtlpcipriv->bt_coexist.cstate &= | ||
64 | ~BT_COEX_STATE_WIFI_DOWNLINK; | ||
65 | } else { | ||
66 | rtlpcipriv->bt_coexist.cstate |= BT_COEX_STATE_WIFI_IDLE; | ||
67 | rtlpcipriv->bt_coexist.cstate &= ~BT_COEX_STATE_WIFI_UPLINK; | ||
68 | rtlpcipriv->bt_coexist.cstate &= ~BT_COEX_STATE_WIFI_DOWNLINK; | ||
69 | } | ||
70 | |||
71 | if (rtlpriv->mac80211.mode == WIRELESS_MODE_G || | ||
72 | rtlpriv->mac80211.mode == WIRELESS_MODE_B) { | ||
73 | rtlpcipriv->bt_coexist.cstate |= BT_COEX_STATE_WIFI_LEGACY; | ||
74 | rtlpcipriv->bt_coexist.cstate &= ~BT_COEX_STATE_WIFI_HT20; | ||
75 | rtlpcipriv->bt_coexist.cstate &= ~BT_COEX_STATE_WIFI_HT40; | ||
76 | } else { | ||
77 | rtlpcipriv->bt_coexist.cstate &= ~BT_COEX_STATE_WIFI_LEGACY; | ||
78 | if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { | ||
79 | rtlpcipriv->bt_coexist.cstate |= | ||
80 | BT_COEX_STATE_WIFI_HT40; | ||
81 | rtlpcipriv->bt_coexist.cstate &= | ||
82 | ~BT_COEX_STATE_WIFI_HT20; | ||
83 | } else { | ||
84 | rtlpcipriv->bt_coexist.cstate |= | ||
85 | BT_COEX_STATE_WIFI_HT20; | ||
86 | rtlpcipriv->bt_coexist.cstate &= | ||
87 | ~BT_COEX_STATE_WIFI_HT40; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | if (rtlpriv->bt_operation_on) | ||
92 | rtlpcipriv->bt_coexist.cstate |= BT_COEX_STATE_BT30; | ||
93 | else | ||
94 | rtlpcipriv->bt_coexist.cstate &= ~BT_COEX_STATE_BT30; | ||
95 | } | ||
96 | |||
97 | u8 rtl8723ae_dm_bt_check_coex_rssi_state1(struct ieee80211_hw *hw, | ||
98 | u8 level_num, u8 rssi_thresh, | ||
99 | u8 rssi_thresh1) | ||
100 | |||
101 | { | ||
102 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
103 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
104 | long smooth; | ||
105 | u8 bt_rssi_state = 0; | ||
106 | |||
107 | smooth = rtl8723ae_dm_bt_get_rx_ss(hw); | ||
108 | |||
109 | if (level_num == 2) { | ||
110 | rtlpcipriv->bt_coexist.cstate &= | ||
111 | ~BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||
112 | |||
113 | if ((rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
114 | BT_RSSI_STATE_LOW) || | ||
115 | (rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
116 | BT_RSSI_STATE_STAY_LOW)) { | ||
117 | if (smooth >= (rssi_thresh + | ||
118 | BT_FW_COEX_THRESH_TOL)) { | ||
119 | bt_rssi_state = BT_RSSI_STATE_HIGH; | ||
120 | rtlpcipriv->bt_coexist.cstate |= | ||
121 | BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||
122 | rtlpcipriv->bt_coexist.cstate &= | ||
123 | ~BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||
124 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
125 | "[DM][BT], RSSI_1 state switch to High\n"); | ||
126 | } else { | ||
127 | bt_rssi_state = BT_RSSI_STATE_STAY_LOW; | ||
128 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
129 | "[DM][BT], RSSI_1 state stay at Low\n"); | ||
130 | } | ||
131 | } else { | ||
132 | if (smooth < rssi_thresh) { | ||
133 | bt_rssi_state = BT_RSSI_STATE_LOW; | ||
134 | rtlpcipriv->bt_coexist.cstate |= | ||
135 | BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||
136 | rtlpcipriv->bt_coexist.cstate &= | ||
137 | ~BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||
138 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
139 | "[DM][BT], RSSI_1 state switch to Low\n"); | ||
140 | } else { | ||
141 | bt_rssi_state = BT_RSSI_STATE_STAY_HIGH; | ||
142 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
143 | "[DM][BT], RSSI_1 state stay at High\n"); | ||
144 | } | ||
145 | } | ||
146 | } else if (level_num == 3) { | ||
147 | if (rssi_thresh > rssi_thresh1) { | ||
148 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
149 | "[DM][BT], RSSI_1 thresh error!!\n"); | ||
150 | return rtlpcipriv->bt_coexist.bt_pre_rssi_state; | ||
151 | } | ||
152 | |||
153 | if ((rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
154 | BT_RSSI_STATE_LOW) || | ||
155 | (rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
156 | BT_RSSI_STATE_STAY_LOW)) { | ||
157 | if (smooth >= | ||
158 | (rssi_thresh+BT_FW_COEX_THRESH_TOL)) { | ||
159 | bt_rssi_state = BT_RSSI_STATE_MEDIUM; | ||
160 | rtlpcipriv->bt_coexist.cstate |= | ||
161 | BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||
162 | rtlpcipriv->bt_coexist.cstate &= | ||
163 | ~BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||
164 | rtlpcipriv->bt_coexist.cstate &= | ||
165 | ~BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||
166 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
167 | "[DM][BT], RSSI_1 state switch to Medium\n"); | ||
168 | } else { | ||
169 | bt_rssi_state = BT_RSSI_STATE_STAY_LOW; | ||
170 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
171 | "[DM][BT], RSSI_1 state stay at Low\n"); | ||
172 | } | ||
173 | } else if ((rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
174 | BT_RSSI_STATE_MEDIUM) || | ||
175 | (rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
176 | BT_RSSI_STATE_STAY_MEDIUM)) { | ||
177 | if (smooth >= (rssi_thresh1 + | ||
178 | BT_FW_COEX_THRESH_TOL)) { | ||
179 | bt_rssi_state = BT_RSSI_STATE_HIGH; | ||
180 | rtlpcipriv->bt_coexist.cstate |= | ||
181 | BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||
182 | rtlpcipriv->bt_coexist.cstate &= | ||
183 | ~BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||
184 | rtlpcipriv->bt_coexist.cstate &= | ||
185 | ~BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||
186 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
187 | "[DM][BT], RSSI_1 state switch to High\n"); | ||
188 | } else if (smooth < rssi_thresh) { | ||
189 | bt_rssi_state = BT_RSSI_STATE_LOW; | ||
190 | rtlpcipriv->bt_coexist.cstate |= | ||
191 | BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||
192 | rtlpcipriv->bt_coexist.cstate &= | ||
193 | ~BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||
194 | rtlpcipriv->bt_coexist.cstate &= | ||
195 | ~BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||
196 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
197 | "[DM][BT], RSSI_1 state switch to Low\n"); | ||
198 | } else { | ||
199 | bt_rssi_state = BT_RSSI_STATE_STAY_MEDIUM; | ||
200 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
201 | "[DM][BT], RSSI_1 state stay at Medium\n"); | ||
202 | } | ||
203 | } else { | ||
204 | if (smooth < rssi_thresh1) { | ||
205 | bt_rssi_state = BT_RSSI_STATE_MEDIUM; | ||
206 | rtlpcipriv->bt_coexist.cstate |= | ||
207 | BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||
208 | rtlpcipriv->bt_coexist.cstate &= | ||
209 | ~BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||
210 | rtlpcipriv->bt_coexist.cstate &= | ||
211 | ~BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||
212 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
213 | "[DM][BT], RSSI_1 state switch to Medium\n"); | ||
214 | } else { | ||
215 | bt_rssi_state = BT_RSSI_STATE_STAY_HIGH; | ||
216 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
217 | "[DM][BT], RSSI_1 state stay at High\n"); | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | |||
222 | rtlpcipriv->bt_coexist.bt_pre_rssi_state1 = bt_rssi_state; | ||
223 | |||
224 | return bt_rssi_state; | ||
225 | } | ||
226 | |||
227 | u8 rtl8723ae_dm_bt_check_coex_rssi_state(struct ieee80211_hw *hw, | ||
228 | u8 level_num, u8 rssi_thresh, | ||
229 | u8 rssi_thresh1) | ||
230 | { | ||
231 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
232 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
233 | long smooth; | ||
234 | u8 bt_rssi_state = 0; | ||
235 | |||
236 | smooth = rtl8723ae_dm_bt_get_rx_ss(hw); | ||
237 | |||
238 | if (level_num == 2) { | ||
239 | rtlpcipriv->bt_coexist.cstate &= | ||
240 | ~BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||
241 | |||
242 | if ((rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
243 | BT_RSSI_STATE_LOW) || | ||
244 | (rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
245 | BT_RSSI_STATE_STAY_LOW)){ | ||
246 | if (smooth >= | ||
247 | (rssi_thresh + BT_FW_COEX_THRESH_TOL)) { | ||
248 | bt_rssi_state = BT_RSSI_STATE_HIGH; | ||
249 | rtlpcipriv->bt_coexist.cstate |= | ||
250 | BT_COEX_STATE_WIFI_RSSI_HIGH; | ||
251 | rtlpcipriv->bt_coexist.cstate &= | ||
252 | ~BT_COEX_STATE_WIFI_RSSI_LOW; | ||
253 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
254 | "[DM][BT], RSSI state switch to High\n"); | ||
255 | } else { | ||
256 | bt_rssi_state = BT_RSSI_STATE_STAY_LOW; | ||
257 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
258 | "[DM][BT], RSSI state stay at Low\n"); | ||
259 | } | ||
260 | } else { | ||
261 | if (smooth < rssi_thresh) { | ||
262 | bt_rssi_state = BT_RSSI_STATE_LOW; | ||
263 | rtlpcipriv->bt_coexist.cstate |= | ||
264 | BT_COEX_STATE_WIFI_RSSI_LOW; | ||
265 | rtlpcipriv->bt_coexist.cstate &= | ||
266 | ~BT_COEX_STATE_WIFI_RSSI_HIGH; | ||
267 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
268 | "[DM][BT], RSSI state switch to Low\n"); | ||
269 | } else { | ||
270 | bt_rssi_state = BT_RSSI_STATE_STAY_HIGH; | ||
271 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
272 | "[DM][BT], RSSI state stay at High\n"); | ||
273 | } | ||
274 | } | ||
275 | } else if (level_num == 3) { | ||
276 | if (rssi_thresh > rssi_thresh1) { | ||
277 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
278 | "[DM][BT], RSSI thresh error!!\n"); | ||
279 | return rtlpcipriv->bt_coexist.bt_pre_rssi_state; | ||
280 | } | ||
281 | if ((rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
282 | BT_RSSI_STATE_LOW) || | ||
283 | (rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
284 | BT_RSSI_STATE_STAY_LOW)) { | ||
285 | if (smooth >= | ||
286 | (rssi_thresh + BT_FW_COEX_THRESH_TOL)) { | ||
287 | bt_rssi_state = BT_RSSI_STATE_MEDIUM; | ||
288 | rtlpcipriv->bt_coexist.cstate | ||
289 | |= BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||
290 | rtlpcipriv->bt_coexist.cstate | ||
291 | &= ~BT_COEX_STATE_WIFI_RSSI_LOW; | ||
292 | rtlpcipriv->bt_coexist.cstate | ||
293 | &= ~BT_COEX_STATE_WIFI_RSSI_HIGH; | ||
294 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
295 | "[DM][BT], RSSI state switch to Medium\n"); | ||
296 | } else { | ||
297 | bt_rssi_state = BT_RSSI_STATE_STAY_LOW; | ||
298 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
299 | "[DM][BT], RSSI state stay at Low\n"); | ||
300 | } | ||
301 | } else if ((rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
302 | BT_RSSI_STATE_MEDIUM) || | ||
303 | (rtlpcipriv->bt_coexist.bt_pre_rssi_state == | ||
304 | BT_RSSI_STATE_STAY_MEDIUM)) { | ||
305 | if (smooth >= | ||
306 | (rssi_thresh1 + BT_FW_COEX_THRESH_TOL)) { | ||
307 | bt_rssi_state = BT_RSSI_STATE_HIGH; | ||
308 | rtlpcipriv->bt_coexist.cstate | ||
309 | |= BT_COEX_STATE_WIFI_RSSI_HIGH; | ||
310 | rtlpcipriv->bt_coexist.cstate | ||
311 | &= ~BT_COEX_STATE_WIFI_RSSI_LOW; | ||
312 | rtlpcipriv->bt_coexist.cstate | ||
313 | &= ~BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||
314 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
315 | "[DM][BT], RSSI state switch to High\n"); | ||
316 | } else if (smooth < rssi_thresh) { | ||
317 | bt_rssi_state = BT_RSSI_STATE_LOW; | ||
318 | rtlpcipriv->bt_coexist.cstate | ||
319 | |= BT_COEX_STATE_WIFI_RSSI_LOW; | ||
320 | rtlpcipriv->bt_coexist.cstate | ||
321 | &= ~BT_COEX_STATE_WIFI_RSSI_HIGH; | ||
322 | rtlpcipriv->bt_coexist.cstate | ||
323 | &= ~BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||
324 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
325 | "[DM][BT], RSSI state switch to Low\n"); | ||
326 | } else { | ||
327 | bt_rssi_state = BT_RSSI_STATE_STAY_MEDIUM; | ||
328 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
329 | "[DM][BT], RSSI state stay at Medium\n"); | ||
330 | } | ||
331 | } else { | ||
332 | if (smooth < rssi_thresh1) { | ||
333 | bt_rssi_state = BT_RSSI_STATE_MEDIUM; | ||
334 | rtlpcipriv->bt_coexist.cstate | ||
335 | |= BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||
336 | rtlpcipriv->bt_coexist.cstate | ||
337 | &= ~BT_COEX_STATE_WIFI_RSSI_HIGH; | ||
338 | rtlpcipriv->bt_coexist.cstate | ||
339 | &= ~BT_COEX_STATE_WIFI_RSSI_LOW; | ||
340 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
341 | "[DM][BT], RSSI state switch to Medium\n"); | ||
342 | } else { | ||
343 | bt_rssi_state = BT_RSSI_STATE_STAY_HIGH; | ||
344 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
345 | "[DM][BT], RSSI state stay at High\n"); | ||
346 | } | ||
347 | } | ||
348 | } | ||
349 | |||
350 | rtlpcipriv->bt_coexist.bt_pre_rssi_state = bt_rssi_state; | ||
351 | return bt_rssi_state; | ||
352 | } | ||
353 | |||
354 | long rtl8723ae_dm_bt_get_rx_ss(struct ieee80211_hw *hw) | ||
355 | { | ||
356 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
357 | long smooth = 0; | ||
358 | |||
359 | if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) | ||
360 | smooth = GET_UNDECORATED_AVERAGE_RSSI(rtlpriv); | ||
361 | else | ||
362 | smooth = rtlpriv->dm.entry_min_undec_sm_pwdb; | ||
363 | |||
364 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
365 | "rtl8723ae_dm_bt_get_rx_ss() = %ld\n", smooth); | ||
366 | |||
367 | return smooth; | ||
368 | } | ||
369 | |||
370 | void rtl8723ae_dm_bt_balance(struct ieee80211_hw *hw, | ||
371 | bool balance_on, u8 ms0, u8 ms1) | ||
372 | { | ||
373 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
374 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
375 | u8 h2c_parameter[3] = {0}; | ||
376 | |||
377 | if (balance_on) { | ||
378 | h2c_parameter[2] = 1; | ||
379 | h2c_parameter[1] = ms1; | ||
380 | h2c_parameter[0] = ms0; | ||
381 | rtlpcipriv->bt_coexist.fw_coexist_all_off = false; | ||
382 | } else { | ||
383 | h2c_parameter[2] = 0; | ||
384 | h2c_parameter[1] = 0; | ||
385 | h2c_parameter[0] = 0; | ||
386 | } | ||
387 | rtlpcipriv->bt_coexist.balance_on = balance_on; | ||
388 | |||
389 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
390 | "[DM][BT], Balance=[%s:%dms:%dms], write 0xc=0x%x\n", | ||
391 | balance_on ? "ON" : "OFF", ms0, ms1, | ||
392 | h2c_parameter[0]<<16 | h2c_parameter[1]<<8 | h2c_parameter[2]); | ||
393 | |||
394 | rtl8723ae_fill_h2c_cmd(hw, 0xc, 3, h2c_parameter); | ||
395 | } | ||
396 | |||
397 | |||
398 | void rtl8723ae_dm_bt_agc_table(struct ieee80211_hw *hw, u8 type) | ||
399 | { | ||
400 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
401 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
402 | |||
403 | if (type == BT_AGCTABLE_OFF) { | ||
404 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
405 | "[BT]AGCTable Off!\n"); | ||
406 | rtl_write_dword(rtlpriv, 0xc78, 0x641c0001); | ||
407 | rtl_write_dword(rtlpriv, 0xc78, 0x631d0001); | ||
408 | rtl_write_dword(rtlpriv, 0xc78, 0x621e0001); | ||
409 | rtl_write_dword(rtlpriv, 0xc78, 0x611f0001); | ||
410 | rtl_write_dword(rtlpriv, 0xc78, 0x60200001); | ||
411 | |||
412 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
413 | RF_RX_AGC_HP, 0xfffff, 0x32000); | ||
414 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
415 | RF_RX_AGC_HP, 0xfffff, 0x71000); | ||
416 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
417 | RF_RX_AGC_HP, 0xfffff, 0xb0000); | ||
418 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
419 | RF_RX_AGC_HP, 0xfffff, 0xfc000); | ||
420 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
421 | RF_RX_G1, 0xfffff, 0x30355); | ||
422 | } else if (type == BT_AGCTABLE_ON) { | ||
423 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
424 | "[BT]AGCTable On!\n"); | ||
425 | rtl_write_dword(rtlpriv, 0xc78, 0x4e1c0001); | ||
426 | rtl_write_dword(rtlpriv, 0xc78, 0x4d1d0001); | ||
427 | rtl_write_dword(rtlpriv, 0xc78, 0x4c1e0001); | ||
428 | rtl_write_dword(rtlpriv, 0xc78, 0x4b1f0001); | ||
429 | rtl_write_dword(rtlpriv, 0xc78, 0x4a200001); | ||
430 | |||
431 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
432 | RF_RX_AGC_HP, 0xfffff, 0xdc000); | ||
433 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
434 | RF_RX_AGC_HP, 0xfffff, 0x90000); | ||
435 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
436 | RF_RX_AGC_HP, 0xfffff, 0x51000); | ||
437 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
438 | RF_RX_AGC_HP, 0xfffff, 0x12000); | ||
439 | rtl8723ae_phy_set_rf_reg(hw, RF90_PATH_A, | ||
440 | RF_RX_G1, 0xfffff, 0x00355); | ||
441 | |||
442 | rtlpcipriv->bt_coexist.sw_coexist_all_off = false; | ||
443 | } | ||
444 | } | ||
445 | |||
446 | void rtl8723ae_dm_bt_bback_off_level(struct ieee80211_hw *hw, u8 type) | ||
447 | { | ||
448 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
449 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
450 | |||
451 | if (type == BT_BB_BACKOFF_OFF) { | ||
452 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
453 | "[BT]BBBackOffLevel Off!\n"); | ||
454 | rtl_write_dword(rtlpriv, 0xc04, 0x3a05611); | ||
455 | } else if (type == BT_BB_BACKOFF_ON) { | ||
456 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
457 | "[BT]BBBackOffLevel On!\n"); | ||
458 | rtl_write_dword(rtlpriv, 0xc04, 0x3a07611); | ||
459 | rtlpcipriv->bt_coexist.sw_coexist_all_off = false; | ||
460 | } | ||
461 | } | ||
462 | |||
463 | void rtl8723ae_dm_bt_fw_coex_all_off(struct ieee80211_hw *hw) | ||
464 | { | ||
465 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
466 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
467 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
468 | "rtl8723ae_dm_bt_fw_coex_all_off()\n"); | ||
469 | |||
470 | if (rtlpcipriv->bt_coexist.fw_coexist_all_off) | ||
471 | return; | ||
472 | |||
473 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
474 | "rtl8723ae_dm_bt_fw_coex_all_off(), real Do\n"); | ||
475 | rtl8723ae_dm_bt_fw_coex_all_off_8723a(hw); | ||
476 | rtlpcipriv->bt_coexist.fw_coexist_all_off = true; | ||
477 | } | ||
478 | |||
479 | void rtl8723ae_dm_bt_sw_coex_all_off(struct ieee80211_hw *hw) | ||
480 | { | ||
481 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
482 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
483 | |||
484 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
485 | "rtl8723ae_dm_bt_sw_coex_all_off()\n"); | ||
486 | |||
487 | if (rtlpcipriv->bt_coexist.sw_coexist_all_off) | ||
488 | return; | ||
489 | |||
490 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
491 | "rtl8723ae_dm_bt_sw_coex_all_off(), real Do\n"); | ||
492 | rtl8723ae_dm_bt_sw_coex_all_off_8723a(hw); | ||
493 | rtlpcipriv->bt_coexist.sw_coexist_all_off = true; | ||
494 | } | ||
495 | |||
496 | void rtl8723ae_dm_bt_hw_coex_all_off(struct ieee80211_hw *hw) | ||
497 | { | ||
498 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
499 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
500 | |||
501 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
502 | "rtl8723ae_dm_bt_hw_coex_all_off()\n"); | ||
503 | |||
504 | if (rtlpcipriv->bt_coexist.hw_coexist_all_off) | ||
505 | return; | ||
506 | RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||
507 | "rtl8723ae_dm_bt_hw_coex_all_off(), real Do\n"); | ||
508 | |||
509 | rtl8723ae_dm_bt_hw_coex_all_off_8723a(hw); | ||
510 | |||
511 | rtlpcipriv->bt_coexist.hw_coexist_all_off = true; | ||
512 | } | ||
513 | |||
514 | void rtl8723ae_btdm_coex_all_off(struct ieee80211_hw *hw) | ||
515 | { | ||
516 | rtl8723ae_dm_bt_fw_coex_all_off(hw); | ||
517 | rtl8723ae_dm_bt_sw_coex_all_off(hw); | ||
518 | rtl8723ae_dm_bt_hw_coex_all_off(hw); | ||
519 | } | ||
520 | |||
521 | bool rtl8723ae_dm_bt_is_coexist_state_changed(struct ieee80211_hw *hw) | ||
522 | { | ||
523 | struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); | ||
524 | |||
525 | if ((rtlpcipriv->bt_coexist.previous_state == | ||
526 | rtlpcipriv->bt_coexist.cstate) && | ||
527 | (rtlpcipriv->bt_coexist.previous_state_h == | ||
528 | rtlpcipriv->bt_coexist.cstate_h)) | ||
529 | return false; | ||
530 | else | ||
531 | return true; | ||
532 | } | ||
533 | |||
534 | bool rtl8723ae_dm_bt_is_wifi_up_link(struct ieee80211_hw *hw) | ||
535 | { | ||
536 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
537 | |||
538 | if (rtlpriv->link_info.tx_busy_traffic) | ||
539 | return true; | ||
540 | else | ||
541 | return false; | ||
542 | } | ||