Skip to content

Commit baa1702

Browse files
lwfingerKalle Valo
authored and
Kalle Valo
committed
rtlwifi: btcoexist: Implement antenna selection
The previous patch added an option to rtl8723be to manually select the antenna for those cases when only a single antenna is present, and the on-board EEPROM is incorrectly programmed. This patch implements the necessary changes in the Bluetooth coexistence driver. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Cc: Stable <stable@vger.kernel.org> [V4.0+] Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
1 parent c18d8f5 commit baa1702

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -1203,27 +1203,32 @@ static void btc8723b2ant_set_ant_path(struct btc_coexist *btcoexist,
12031203

12041204
/* Force GNT_BT to low */
12051205
btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0);
1206-
btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
12071206

12081207
if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) {
12091208
/* tell firmware "no antenna inverse" */
12101209
h2c_parameter[0] = 0;
12111210
h2c_parameter[1] = 1; /* ext switch type */
12121211
btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
12131212
h2c_parameter);
1213+
btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
12141214
} else {
12151215
/* tell firmware "antenna inverse" */
12161216
h2c_parameter[0] = 1;
12171217
h2c_parameter[1] = 1; /* ext switch type */
12181218
btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
12191219
h2c_parameter);
1220+
btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
12201221
}
12211222
}
12221223

12231224
/* ext switch setting */
12241225
if (use_ext_switch) {
12251226
/* fixed internal switch S1->WiFi, S0->BT */
1226-
btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
1227+
if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
1228+
btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
1229+
else
1230+
btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
1231+
12271232
switch (antpos_type) {
12281233
case BTC_ANT_WIFI_AT_MAIN:
12291234
/* ext switch main at wifi */

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

+26-1
Original file line numberDiff line numberDiff line change
@@ -965,13 +965,38 @@ void exhalbtc_set_chip_type(u8 chip_type)
965965
}
966966
}
967967

968-
void exhalbtc_set_ant_num(u8 type, u8 ant_num)
968+
void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
969969
{
970970
if (BT_COEX_ANT_TYPE_PG == type) {
971971
gl_bt_coexist.board_info.pg_ant_num = ant_num;
972972
gl_bt_coexist.board_info.btdm_ant_num = ant_num;
973+
/* The antenna position:
974+
* Main (default) or Aux for pgAntNum=2 && btdmAntNum =1.
975+
* The antenna position should be determined by
976+
* auto-detect mechanism.
977+
* The following is assumed to main,
978+
* and those must be modified
979+
* if y auto-detect mechanism is ready
980+
*/
981+
if ((gl_bt_coexist.board_info.pg_ant_num == 2) &&
982+
(gl_bt_coexist.board_info.btdm_ant_num == 1))
983+
gl_bt_coexist.board_info.btdm_ant_pos =
984+
BTC_ANTENNA_AT_MAIN_PORT;
985+
else
986+
gl_bt_coexist.board_info.btdm_ant_pos =
987+
BTC_ANTENNA_AT_MAIN_PORT;
973988
} else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
974989
gl_bt_coexist.board_info.btdm_ant_num = ant_num;
990+
gl_bt_coexist.board_info.btdm_ant_pos =
991+
BTC_ANTENNA_AT_MAIN_PORT;
992+
} else if (type == BT_COEX_ANT_TYPE_DETECTED) {
993+
gl_bt_coexist.board_info.btdm_ant_num = ant_num;
994+
if (rtlpriv->cfg->mod_params->ant_sel == 1)
995+
gl_bt_coexist.board_info.btdm_ant_pos =
996+
BTC_ANTENNA_AT_AUX_PORT;
997+
else
998+
gl_bt_coexist.board_info.btdm_ant_pos =
999+
BTC_ANTENNA_AT_MAIN_PORT;
9751000
}
9761001
}
9771002

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version);
535535
void exhalbtc_update_min_bt_rssi(char bt_rssi);
536536
void exhalbtc_set_bt_exist(bool bt_exist);
537537
void exhalbtc_set_chip_type(u8 chip_type);
538-
void exhalbtc_set_ant_num(u8 type, u8 ant_num);
538+
void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
539539
void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist);
540540
void exhalbtc_signal_compensation(struct btc_coexist *btcoexist,
541541
u8 *rssi_wifi, u8 *rssi_bt);

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
7272
__func__, bt_type);
7373
exhalbtc_set_chip_type(bt_type);
7474

75-
exhalbtc_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
75+
if (rtlpriv->cfg->mod_params->ant_sel == 1)
76+
exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_DETECTED, 1);
77+
else
78+
exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num);
7679
}
7780

7881
void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)

0 commit comments

Comments
 (0)