Skip to content

Commit af8a41c

Browse files
Ping-Ke ShihKalle Valo
authored andcommitted
rtlwifi: cleanup 8723be ant_sel definition
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]>
1 parent a083429 commit af8a41c

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,6 @@ static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist)
158158

159159
static u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
160160
{
161-
struct rtl_mod_params *mod_params = rtlpriv->cfg->mod_params;
162-
163-
/* override ant_num / ant_path */
164-
if (mod_params->ant_sel) {
165-
rtlpriv->btcoexist.btc_info.ant_num =
166-
(mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1);
167-
168-
rtlpriv->btcoexist.btc_info.single_ant_path =
169-
(mod_params->ant_sel == 1 ? 0 : 1);
170-
}
171161
return rtlpriv->btcoexist.btc_info.single_ant_path;
172162
}
173163

@@ -178,18 +168,13 @@ static u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
178168

179169
static u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
180170
{
181-
struct rtl_mod_params *mod_params = rtlpriv->cfg->mod_params;
182171
u8 num;
183172

184173
if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
185174
num = 2;
186175
else
187176
num = 1;
188177

189-
/* override ant_num / ant_path */
190-
if (mod_params->ant_sel)
191-
num = (mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1) + 1;
192-
193178
return num;
194179
}
195180

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,9 @@ static bool _rtl8723be_init_mac(struct ieee80211_hw *hw)
848848
return false;
849849
}
850850

851+
if (rtlpriv->cfg->ops->get_btc_status())
852+
rtlpriv->btcoexist.btc_ops->btc_power_on_setting(rtlpriv);
853+
851854
bytetmp = rtl_read_byte(rtlpriv, REG_MULTI_FUNC_CTRL);
852855
rtl_write_byte(rtlpriv, REG_MULTI_FUNC_CTRL, bytetmp | BIT(3));
853856

@@ -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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,6 +2823,11 @@ enum bt_ant_num {
28232823
ANT_X1 = 1,
28242824
};
28252825

2826+
enum bt_ant_path {
2827+
ANT_MAIN = 0,
2828+
ANT_AUX = 1,
2829+
};
2830+
28262831
enum bt_co_type {
28272832
BT_2WIRE = 0,
28282833
BT_ISSC_3WIRE = 1,

0 commit comments

Comments
 (0)