]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
rtlwifi: btcoexist: Implement antenna selection
authorLarry Finger <Larry.Finger@lwfinger.net>
Wed, 16 Mar 2016 18:33:35 +0000 (13:33 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jun 2016 01:14:33 +0000 (18:14 -0700)
commit baa1702290953295e421f0f433e2b1ff4815827c upstream.

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>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c

index f2b9d11adc9eadca0d1cc833614c4c7cc69536c0..e85f1652ce55b7741b2b8bcfdeb66ca73ddde346 100644 (file)
@@ -1203,7 +1203,6 @@ static void btc8723b2ant_set_ant_path(struct btc_coexist *btcoexist,
 
                /* Force GNT_BT to low */
                btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0);
-               btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
 
                if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) {
                        /* tell firmware "no antenna inverse" */
@@ -1211,19 +1210,25 @@ static void btc8723b2ant_set_ant_path(struct btc_coexist *btcoexist,
                        h2c_parameter[1] = 1;  /* ext switch type */
                        btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
                                                h2c_parameter);
+                       btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
                } else {
                        /* tell firmware "antenna inverse" */
                        h2c_parameter[0] = 1;
                        h2c_parameter[1] = 1;  /* ext switch type */
                        btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
                                                h2c_parameter);
+                       btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
                }
        }
 
        /* ext switch setting */
        if (use_ext_switch) {
                /* fixed internal switch S1->WiFi, S0->BT */
-               btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
+               if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
+                       btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
+               else
+                       btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
+
                switch (antpos_type) {
                case BTC_ANT_WIFI_AT_MAIN:
                        /* ext switch main at wifi */
index b2791c893417b071782dbb317f6baae53c0ecf74..babd1490f20c075b410c159794a144ff2a09b340 100644 (file)
@@ -965,13 +965,38 @@ void exhalbtc_set_chip_type(u8 chip_type)
        }
 }
 
-void exhalbtc_set_ant_num(u8 type, u8 ant_num)
+void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
 {
        if (BT_COEX_ANT_TYPE_PG == type) {
                gl_bt_coexist.board_info.pg_ant_num = ant_num;
                gl_bt_coexist.board_info.btdm_ant_num = ant_num;
+               /* The antenna position:
+                * Main (default) or Aux for pgAntNum=2 && btdmAntNum =1.
+                * The antenna position should be determined by
+                * auto-detect mechanism.
+                * The following is assumed to main,
+                * and those must be modified
+                * if y auto-detect mechanism is ready
+                */
+               if ((gl_bt_coexist.board_info.pg_ant_num == 2) &&
+                   (gl_bt_coexist.board_info.btdm_ant_num == 1))
+                       gl_bt_coexist.board_info.btdm_ant_pos =
+                                                      BTC_ANTENNA_AT_MAIN_PORT;
+               else
+                       gl_bt_coexist.board_info.btdm_ant_pos =
+                                                      BTC_ANTENNA_AT_MAIN_PORT;
        } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
                gl_bt_coexist.board_info.btdm_ant_num = ant_num;
+               gl_bt_coexist.board_info.btdm_ant_pos =
+                                                      BTC_ANTENNA_AT_MAIN_PORT;
+       } else if (type == BT_COEX_ANT_TYPE_DETECTED) {
+               gl_bt_coexist.board_info.btdm_ant_num = ant_num;
+               if (rtlpriv->cfg->mod_params->ant_sel == 1)
+                       gl_bt_coexist.board_info.btdm_ant_pos =
+                               BTC_ANTENNA_AT_AUX_PORT;
+               else
+                       gl_bt_coexist.board_info.btdm_ant_pos =
+                               BTC_ANTENNA_AT_MAIN_PORT;
        }
 }
 
index 0a903ea179ef5df67954b1c33c97a57a5c82eebe..f41ca57dd8a79bc65e1e0c0657a3f618343bbeef 100644 (file)
@@ -535,7 +535,7 @@ void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version);
 void exhalbtc_update_min_bt_rssi(char bt_rssi);
 void exhalbtc_set_bt_exist(bool bt_exist);
 void exhalbtc_set_chip_type(u8 chip_type);
-void exhalbtc_set_ant_num(u8 type, u8 ant_num);
+void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist);
 void exhalbtc_signal_compensation(struct btc_coexist *btcoexist,
                                  u8 *rssi_wifi, u8 *rssi_bt);
index b9b0cb7af8eace6e357378729e5d8d8628cb282a..d3fd9211b3a48fd1c8b495069fccbb0085dbb140 100644 (file)
@@ -72,7 +72,10 @@ void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
                 __func__, bt_type);
        exhalbtc_set_chip_type(bt_type);
 
-       exhalbtc_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
+       if (rtlpriv->cfg->mod_params->ant_sel == 1)
+               exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_DETECTED, 1);
+       else
+               exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num);
 }
 
 void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)