Skip to content

Commit b68c7af

Browse files
Ping-Ke Shihgregkh
Ping-Ke Shih
authored andcommitted
rtlwifi: cleanup 8723be ant_sel definition
commit af8a41c upstream. Some HP laptops have only a single wifi antenna. This would not be a problem except that they were shipped with an incorrectly encoded EFUSE. It should have been possible to open the computer and transfer the antenna connection to the other terminal except that such action might void the warranty, and moving the antenna broke the Windows driver. The fix was to add a module option that would override the EFUSE encoding. That was done with commit c18d8f5 ("rtlwifi: rtl8723be: Add antenna select module parameter"). There was still a problem with Bluetooth coexistence, which was addressed with commit baa1702 ("rtlwifi: btcoexist: Implement antenna selection"). There were still problems, thus there were commit 0ff78ad ("rtlwifi: rtl8723be: fix ant_sel code") and commit 6d62269 ("rtlwifi: btcoexist: Fix antenna selection code"). Despite all these attempts at fixing the problem, the code is not yet right. A proper fix is important as there are now instances of laptops having RTL8723DE chips with the same problem. The module parameter ant_sel is used to control antenna number and path. At present enum ANT_{X2,X1} is used to define the antenna number, but this choice is not intuitive, thus change to a new enum ANT_{MAIN,AUX} to make it more readable. This change showed examples where incorrect values were used. It was also possible to remove a workaround in halbtcoutsrc.c. The experimental results with single antenna connected to specific path are now as follows: ant_sel ANT_MAIN(#1) ANT_AUX(#2) 0 -8 -62 1 -62 -10 2 -6 -60 Signed-off-by: Ping-Ke Shih <[email protected]> Fixes: c18d8f5 ("rtlwifi: rtl8723be: Add antenna select module parameter") Fixes: baa1702 ("rtlwifi: btcoexist: Implement antenna selection") Fixes: 0ff78ad ("rtlwifi: rtl8723be: fix ant_sel code") Fixes: 6d62269 ("rtlwifi: btcoexist: Fix antenna selection code") Cc: Stable <[email protected]> # 4.7+ Reviewed-by: Larry Finger <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fcd835b commit b68c7af

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c

-15
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,6 @@ static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist)
173173

174174
u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
175175
{
176-
struct rtl_mod_params *mod_params = rtlpriv->cfg->mod_params;
177-
178-
/* override ant_num / ant_path */
179-
if (mod_params->ant_sel) {
180-
rtlpriv->btcoexist.btc_info.ant_num =
181-
(mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1);
182-
183-
rtlpriv->btcoexist.btc_info.single_ant_path =
184-
(mod_params->ant_sel == 1 ? 0 : 1);
185-
}
186176
return rtlpriv->btcoexist.btc_info.single_ant_path;
187177
}
188178

@@ -193,18 +183,13 @@ u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
193183

194184
u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
195185
{
196-
struct rtl_mod_params *mod_params = rtlpriv->cfg->mod_params;
197186
u8 num;
198187

199188
if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
200189
num = 2;
201190
else
202191
num = 1;
203192

204-
/* override ant_num / ant_path */
205-
if (mod_params->ant_sel)
206-
num = (mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1) + 1;
207-
208193
return num;
209194
}
210195

drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,9 @@ static bool _rtl8723be_init_mac(struct ieee80211_hw *hw)
846846
return false;
847847
}
848848

849+
if (rtlpriv->cfg->ops->get_btc_status())
850+
rtlpriv->btcoexist.btc_ops->btc_power_on_setting(rtlpriv);
851+
849852
bytetmp = rtl_read_byte(rtlpriv, REG_MULTI_FUNC_CTRL);
850853
rtl_write_byte(rtlpriv, REG_MULTI_FUNC_CTRL, bytetmp | BIT(3));
851854

@@ -2696,21 +2699,21 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw,
26962699
rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8723B;
26972700
rtlpriv->btcoexist.btc_info.ant_num = (value & 0x1);
26982701
rtlpriv->btcoexist.btc_info.single_ant_path =
2699-
(value & 0x40); /*0xc3[6]*/
2702+
(value & 0x40 ? ANT_AUX : ANT_MAIN); /*0xc3[6]*/
27002703
} else {
27012704
rtlpriv->btcoexist.btc_info.btcoexist = 0;
27022705
rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8723B;
27032706
rtlpriv->btcoexist.btc_info.ant_num = ANT_X2;
2704-
rtlpriv->btcoexist.btc_info.single_ant_path = 0;
2707+
rtlpriv->btcoexist.btc_info.single_ant_path = ANT_MAIN;
27052708
}
27062709

27072710
/* override ant_num / ant_path */
27082711
if (mod_params->ant_sel) {
27092712
rtlpriv->btcoexist.btc_info.ant_num =
2710-
(mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1);
2713+
(mod_params->ant_sel == 1 ? ANT_X1 : ANT_X2);
27112714

27122715
rtlpriv->btcoexist.btc_info.single_ant_path =
2713-
(mod_params->ant_sel == 1 ? 0 : 1);
2716+
(mod_params->ant_sel == 1 ? ANT_AUX : ANT_MAIN);
27142717
}
27152718
}
27162719

drivers/net/wireless/realtek/rtlwifi/wifi.h

+5
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,11 @@ enum bt_ant_num {
27082708
ANT_X1 = 1,
27092709
};
27102710

2711+
enum bt_ant_path {
2712+
ANT_MAIN = 0,
2713+
ANT_AUX = 1,
2714+
};
2715+
27112716
enum bt_co_type {
27122717
BT_2WIRE = 0,
27132718
BT_ISSC_3WIRE = 1,

0 commit comments

Comments
 (0)