forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
....@@ -1,27 +1,5 @@
1
-/******************************************************************************
2
- *
3
- * Copyright(c) 2007 - 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
- * The full GNU General Public License is included in this distribution in the
15
- * file called LICENSE.
16
- *
17
- * Contact Information:
18
- * wlanfae <wlanfae@realtek.com>
19
- * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20
- * Hsinchu 300, Taiwan.
21
- *
22
- * Larry Finger <Larry.Finger@lwfinger.net>
23
- *
24
- ******************************************************************************/
1
+// SPDX-License-Identifier: GPL-2.0
2
+/* Copyright(c) 2007-2013 Realtek Corporation.*/
253
264 #include "halbt_precomp.h"
275
....@@ -151,8 +129,8 @@
151129
152130 if (rtlphy->current_channel != 0)
153131 chnl = rtlphy->current_channel;
154
- RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
155
- "static halbtc_get_wifi_central_chnl:%d\n", chnl);
132
+ rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
133
+ "%s:%d\n", __func__, chnl);
156134 return chnl;
157135 }
158136
....@@ -272,16 +250,16 @@
272250 if (!wait_ms)
273251 return true;
274252
275
- RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
276
- "btmpinfo wait req_num=%d wait=%ld\n", req_num, wait_ms);
253
+ rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
254
+ "btmpinfo wait req_num=%d wait=%ld\n", req_num, wait_ms);
277255
278256 if (in_interrupt())
279257 return false;
280258
281259 if (wait_for_completion_timeout(&btcoexist->bt_mp_comp,
282260 msecs_to_jiffies(wait_ms)) == 0) {
283
- RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
284
- "btmpinfo wait (req_num=%d) timeout\n", req_num);
261
+ rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
262
+ "btmpinfo wait (req_num=%d) timeout\n", req_num);
285263
286264 return false; /* timeout */
287265 }
....@@ -292,47 +270,45 @@
292270 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
293271 {
294272 struct rtl_priv *rtlpriv;
295
- struct rtl_ps_ctl *ppsc;
296273 bool ap_enable = false;
297274
298275 rtlpriv = btcoexist->adapter;
299
- ppsc = rtl_psc(rtlpriv);
300276
301277 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
302278 &ap_enable);
303279
304280 if (ap_enable) {
305
- RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
306
- "%s()<--dont leave lps under AP mode\n", __func__);
281
+ rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
282
+ "%s()<--dont leave lps under AP mode\n", __func__);
307283 return;
308284 }
309285
310286 btcoexist->bt_info.bt_ctrl_lps = true;
311287 btcoexist->bt_info.bt_lps_on = false;
312
- rtl_lps_leave(rtlpriv->mac80211.hw);
288
+ /* FIXME: Context is unclear. Is it allowed to block? */
289
+ rtl_lps_leave(rtlpriv->mac80211.hw, false);
313290 }
314291
315292 static void halbtc_enter_lps(struct btc_coexist *btcoexist)
316293 {
317294 struct rtl_priv *rtlpriv;
318
- struct rtl_ps_ctl *ppsc;
319295 bool ap_enable = false;
320296
321297 rtlpriv = btcoexist->adapter;
322
- ppsc = rtl_psc(rtlpriv);
323298
324299 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
325300 &ap_enable);
326301
327302 if (ap_enable) {
328
- RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
329
- "%s()<--dont enter lps under AP mode\n", __func__);
303
+ rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
304
+ "%s()<--dont enter lps under AP mode\n", __func__);
330305 return;
331306 }
332307
333308 btcoexist->bt_info.bt_ctrl_lps = true;
334309 btcoexist->bt_info.bt_lps_on = true;
335
- rtl_lps_enter(rtlpriv->mac80211.hw);
310
+ /* FIXME: Context is unclear. Is it allowed to block? */
311
+ rtl_lps_enter(rtlpriv->mac80211.hw, false);
336312 }
337313
338314 static void halbtc_normal_lps(struct btc_coexist *btcoexist)
....@@ -343,7 +319,8 @@
343319
344320 if (btcoexist->bt_info.bt_ctrl_lps) {
345321 btcoexist->bt_info.bt_lps_on = false;
346
- rtl_lps_leave(rtlpriv->mac80211.hw);
322
+ /* FIXME: Context is unclear. Is it allowed to block? */
323
+ rtl_lps_leave(rtlpriv->mac80211.hw, false);
347324 btcoexist->bt_info.bt_ctrl_lps = false;
348325 }
349326 }
....@@ -354,7 +331,8 @@
354331
355332 if (btcoexist->bt_info.bt_ctrl_lps) {
356333 btcoexist->bt_info.bt_lps_on = false;
357
- rtl_lps_leave(rtlpriv->mac80211.hw);
334
+ /* FIXME: Context is unclear. Is it allowed to block? */
335
+ rtl_lps_leave(rtlpriv->mac80211.hw, false);
358336 }
359337 }
360338
....@@ -535,13 +513,7 @@
535513
536514 static s32 halbtc_get_wifi_rssi(struct rtl_priv *rtlpriv)
537515 {
538
- int undec_sm_pwdb = 0;
539
-
540
- if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
541
- undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
542
- else /* associated entry pwdb */
543
- undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
544
- return undec_sm_pwdb;
516
+ return rtlpriv->dm.undec_sm_pwdb;
545517 }
546518
547519 static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf)
....@@ -926,11 +898,9 @@
926898 (low_power ? ", 32k" : ""));
927899
928900 seq_printf(m,
929
- "\n %-35s = %02x %02x %02x %02x %02x %02x (0x%x/0x%x)",
901
+ "\n %-35s = %6ph (0x%x/0x%x)",
930902 "Power mode cmd(lps/rpwm)",
931
- btcoexist->pwr_mode_val[0], btcoexist->pwr_mode_val[1],
932
- btcoexist->pwr_mode_val[2], btcoexist->pwr_mode_val[3],
933
- btcoexist->pwr_mode_val[4], btcoexist->pwr_mode_val[5],
903
+ btcoexist->pwr_mode_val,
934904 btcoexist->bt_info.lps_val,
935905 btcoexist->bt_info.rpwm_val);
936906 }
....@@ -1350,7 +1320,7 @@
13501320 {
13511321 struct rtl_priv *rtlpriv = adapter;
13521322 struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
1353
- u8 ant_num = 2, chip_type, single_ant_path = 0;
1323
+ u8 ant_num, chip_type, single_ant_path;
13541324
13551325 if (!btcoexist)
13561326 return false;
....@@ -1402,11 +1372,11 @@
14021372 btcoexist->board_info.tfbga_package = true;
14031373
14041374 if (btcoexist->board_info.tfbga_package)
1405
- RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1406
- "[BTCoex], Package Type = TFBGA\n");
1375
+ rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1376
+ "[BTCoex], Package Type = TFBGA\n");
14071377 else
1408
- RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1409
- "[BTCoex], Package Type = Non-TFBGA\n");
1378
+ rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1379
+ "[BTCoex], Package Type = Non-TFBGA\n");
14101380
14111381 btcoexist->board_info.rfe_type = rtl_get_hwpg_rfe_type(rtlpriv);
14121382 btcoexist->board_info.ant_div_cfg = 0;
....@@ -1493,7 +1463,7 @@
14931463 ex_btc8192e2ant_init_coex_dm(btcoexist);
14941464 }
14951465
1496
- btcoexist->initilized = true;
1466
+ btcoexist->initialized = true;
14971467 }
14981468
14991469 void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type)
....@@ -1604,7 +1574,7 @@
16041574
16051575 void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action)
16061576 {
1607
- u8 asso_type, asso_type_v2;
1577
+ u8 asso_type;
16081578 bool wifi_under_5g;
16091579
16101580 if (!halbtc_is_bt_coexist_available(btcoexist))
....@@ -1615,15 +1585,10 @@
16151585
16161586 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
16171587
1618
- if (action) {
1588
+ if (action)
16191589 asso_type = BTC_ASSOCIATE_START;
1620
- asso_type_v2 = wifi_under_5g ? BTC_ASSOCIATE_5G_START :
1621
- BTC_ASSOCIATE_START;
1622
- } else {
1590
+ else
16231591 asso_type = BTC_ASSOCIATE_FINISH;
1624
- asso_type_v2 = wifi_under_5g ? BTC_ASSOCIATE_5G_FINISH :
1625
- BTC_ASSOCIATE_FINISH;
1626
- }
16271592
16281593 halbtc_leave_low_power(btcoexist);
16291594
....@@ -1769,30 +1734,6 @@
17691734 if (btcoexist->board_info.btdm_ant_num == 1)
17701735 ex_btc8723b1ant_rf_status_notify(btcoexist, type);
17711736 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1772
- }
1773
-}
1774
-
1775
-void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type)
1776
-{
1777
- u8 stack_op_type;
1778
-
1779
- if (!halbtc_is_bt_coexist_available(btcoexist))
1780
- return;
1781
- btcoexist->statistics.cnt_stack_operation_notify++;
1782
- if (btcoexist->manual_control)
1783
- return;
1784
-
1785
- if ((type == HCI_BT_OP_INQUIRY_START) ||
1786
- (type == HCI_BT_OP_PAGING_START) ||
1787
- (type == HCI_BT_OP_PAIRING_START)) {
1788
- stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_START;
1789
- } else if ((type == HCI_BT_OP_INQUIRY_FINISH) ||
1790
- (type == HCI_BT_OP_PAGING_SUCCESS) ||
1791
- (type == HCI_BT_OP_PAGING_UNSUCCESS) ||
1792
- (type == HCI_BT_OP_PAIRING_FINISH)) {
1793
- stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH;
1794
- } else {
1795
- stack_op_type = BTC_STACK_OP_NONE;
17961737 }
17971738 }
17981739