2017-04-06 20:20:03

by Larry Finger

[permalink] [raw]
Subject: [PATCH 00/11] rtlwifi: btcoex: More update to btcoex

This set of patches completes the updates for btcoex for the RTL8723BE
device. These patches follow the 13-patch set previously submitted.

Signed-off-by: Larry Finger <[email protected]>
Cc: Yan-Hsuan Chuang <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>


Yan-Hsuan Chuang (11):
btcoex: 23b 2ant: set coex table when wifi is idle
btcoex: 23b 2ant: treat too many low prio packets as retry
btcoex: 23b 2ant: remove debugging code for 0x948
btcoex: 23b 2ant: need those information when scan
btcoex: 23b 2ant: wifi is not actually off in mp mode
btcoex: 23b 2ant: power on settings for coex
btcoex: 23b 2ant: before firmware ready settings
btcoex: 23b 2ant: fine tune for bt pan_edr_a2dp
btcoex: 23b 2ant: fine tune for bt hid_a2dp
rtlwifi: btcoex: 23b 2ant: notify more bt information
rtlwifi: btcoex: 23b 2ant: some hi-prio pkt will cause hid_exist

.../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 194 ++++++++++++++++++---
.../realtek/rtlwifi/btcoexist/halbtc8723b2ant.h | 4 +-
.../realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 19 ++
3 files changed, 189 insertions(+), 28 deletions(-)

--
2.12.0


2017-04-06 20:20:10

by Larry Finger

[permalink] [raw]
Subject: [PATCH 07/11] rtlwifi: btcoex: 23b 2ant: before firmware ready settings

From: Yan-Hsuan Chuang <[email protected]>

Before firmware is ready, set GNT_BT to high to let bt transmit

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
.../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 38 ++++++++++++++++++++++
.../realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 2 ++
2 files changed, 40 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 0f3d04529ff2..06f70944bdac 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -3700,6 +3700,44 @@ void ex_btc8723b2ant_power_on_setting(struct btc_coexist *btcoexist)
}
}

+void ex_btc8723b2ant_pre_load_firmware(struct btc_coexist *btcoexist)
+{
+ struct btc_board_info *board_info = &btcoexist->board_info;
+ u8 u8tmp = 0x4; /* Set BIT2 by default since it's 2ant case */
+
+ /**
+ * S0 or S1 setting and Local register setting(By this fw can get
+ * ant number, S0/S1, ... info)
+ *
+ * Local setting bit define
+ * BIT0: "0" : no antenna inverse; "1" : antenna inverse
+ * BIT1: "0" : internal switch; "1" : external switch
+ * BIT2: "0" : one antenna; "1" : two antennas
+ *
+ * NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and
+ * BIT2 = 0
+ */
+ if (btcoexist->chip_interface == BTC_INTF_USB) {
+ /* fixed at S0 for USB interface */
+ u8tmp |= 0x1; /* antenna inverse */
+ btcoexist->btc_write_local_reg_1byte(btcoexist, 0xfe08, u8tmp);
+ } else {
+ /* for PCIE and SDIO interface, we check efuse 0xc3[6] */
+ if (board_info->single_ant_path == 0) {
+ } else if (board_info->single_ant_path == 1) {
+ /* set to S0 */
+ u8tmp |= 0x1; /* antenna inverse */
+ }
+
+ if (btcoexist->chip_interface == BTC_INTF_PCI)
+ btcoexist->btc_write_local_reg_1byte(btcoexist, 0x384,
+ u8tmp);
+ else if (btcoexist->chip_interface == BTC_INTF_SDIO)
+ btcoexist->btc_write_local_reg_1byte(btcoexist, 0x60,
+ u8tmp);
+ }
+}
+
void ex_btc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist)
{
struct rtl_priv *rtlpriv = btcoexist->adapter;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index 5a34cd895e44..d31e6df5b1bf 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -369,6 +369,7 @@ typedef void (*bfp_btc_w2)(void *btc_context, u32 reg_addr, u16 data);

typedef void (*bfp_btc_w4)(void *btc_context, u32 reg_addr, u32 data);

+typedef void (*bfp_btc_local_reg_w1)(void *btc_context, u32 reg_addr, u8 data);
typedef void (*bfp_btc_wr_1byte_bit_mask)(void *btc_context, u32 reg_addr,
u8 bit_mask, u8 data);

@@ -496,6 +497,7 @@ struct btc_coexist {
bfp_btc_w2 btc_write_2byte;
bfp_btc_r4 btc_read_4byte;
bfp_btc_w4 btc_write_4byte;
+ bfp_btc_local_reg_w1 btc_write_local_reg_1byte;

bfp_btc_set_bb_reg btc_set_bb_reg;
bfp_btc_get_bb_reg btc_get_bb_reg;
--
2.12.0

2017-04-13 14:10:14

by Kalle Valo

[permalink] [raw]
Subject: Re: [01/11] rtlwifi: btcoex: 23b 2ant: set coex table when wifi is idle

Larry Finger <[email protected]> wrote:
> From: Yan-Hsuan Chuang <[email protected]>
>
> When wifi is idle, the bt should have more resource to transmit.
>
> Signed-off-by: Yan-Hsuan Chuang <[email protected]>
> Signed-off-by: Larry Finger <[email protected]>
> Cc: Pkshih <[email protected]>
> Cc: Birming Chiu <[email protected]>
> Cc: Shaofu <[email protected]>
> Cc: Steven Ting <[email protected]>

11 patches applied to wireless-drivers-next.git, thanks.

470eec1a3d0a rtlwifi: btcoex: 23b 2ant: set coex table when wifi is idle
2037b83c12d1 rtlwifi: btcoex: 23b 2ant: treat too many low prio packets as retry
acb9c779ecc5 rtlwifi: btcoex: 23b 2ant: remove debugging code for 0x948
ae889ebc76c9 rtlwifi: btcoex: 23b 2ant: need those information when scan
7558668d0536 rtlwifi: btcoex: 23b 2ant: wifi is not actually off in mp mode
4e6becc0448b rtlwifi: btcoex: 23b 2ant: power on settings for coex
6dcf041eabd1 rtlwifi: btcoex: 23b 2ant: before firmware ready settings
2e6689824a4c rtlwifi: btcoex: 23b 2ant: fine tune for bt pan_edr_a2dp
110944027627 rtlwifi: btcoex: 23b 2ant: fine tune for bt hid_a2dp
588a290b4642 rtlwifi: btcoex: 23b 2ant: notify more bt information
f4a23e194ef3 rtlwifi: btcoex: 23b 2ant: some hi-prio pkt will cause hid_exist

--
https://patchwork.kernel.org/patch/9668357/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2017-04-06 20:20:10

by Larry Finger

[permalink] [raw]
Subject: [PATCH 06/11] rtlwifi: btcoex: 23b 2ant: power on settings for coex

From: Yan-Hsuan Chuang <[email protected]>

When power on, the wifi could be initiating, force the antenna to
transmit bt packets to avoid bt unstable problems

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
.../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 31 ++++++++++++++++++++++
.../realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 1 +
2 files changed, 32 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 70f21059ddc3..0f3d04529ff2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -3669,6 +3669,37 @@ void ex_btc8723b2ant_init_hwconfig(struct btc_coexist *btcoexist)
btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1);
}

+void ex_btc8723b2ant_power_on_setting(struct btc_coexist *btcoexist)
+{
+ struct btc_board_info *board_info = &btcoexist->board_info;
+ u16 u16tmp = 0x0;
+ u32 value = 0;
+
+ btcoexist->btc_write_1byte(btcoexist, 0x67, 0x20);
+
+ /* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly */
+ u16tmp = btcoexist->btc_read_2byte(btcoexist, 0x2);
+ btcoexist->btc_write_2byte(btcoexist, 0x2, u16tmp | BIT0 | BIT1);
+
+ btcoexist->btc_write_4byte(btcoexist, 0x948, 0x0);
+
+ if (btcoexist->chip_interface == BTC_INTF_USB) {
+ /* fixed at S0 for USB interface */
+ board_info->btdm_ant_pos = BTC_ANTENNA_AT_AUX_PORT;
+ } else {
+ /* for PCIE and SDIO interface, we check efuse 0xc3[6] */
+ if (board_info->single_ant_path == 0) {
+ /* set to S1 */
+ board_info->btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
+ } else if (board_info->single_ant_path == 1) {
+ /* set to S0 */
+ board_info->btdm_ant_pos = BTC_ANTENNA_AT_AUX_PORT;
+ }
+ btcoexist->btc_set(btcoexist, BTC_SET_ACT_ANTPOSREGRISTRY_CTRL,
+ &value);
+ }
+}
+
void ex_btc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist)
{
struct rtl_priv *rtlpriv = btcoexist->adapter;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index 0b90e7f0b722..5a34cd895e44 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -139,6 +139,7 @@ struct btc_board_info {
u8 pg_ant_num; /* pg ant number */
u8 btdm_ant_num; /* ant number for btdm */
u8 btdm_ant_pos;
+ u8 single_ant_path; /* current used for 8723b only, 1=>s0, 0=>s1 */
bool bt_exist;
};

--
2.12.0

2017-04-06 20:20:04

by Larry Finger

[permalink] [raw]
Subject: [PATCH 01/11] rtlwifi: btcoex: 23b 2ant: set coex table when wifi is idle

From: Yan-Hsuan Chuang <[email protected]>

When wifi is idle, the bt should have more resource to transmit.

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
.../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 61 ++++++++++++++++------
1 file changed, 44 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index c9f04454b19b..327609e3a309 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -1613,6 +1613,47 @@ static void btc8723b2ant_action_wifi_link_process(struct btc_coexist
u32tmp, u8tmpa, u8tmpb);
}

+static bool btc8723b2ant_action_wifi_idle_process(struct btc_coexist *btcoexist)
+{
+ struct rtl_priv *rtlpriv = btcoexist->adapter;
+ u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
+ u8 ap_num = 0;
+ u8 tmp = BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES -
+ coex_dm->switch_thres_offset - coex_dm->switch_thres_offset;
+
+ wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
+ wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2,
+ tmp, 0);
+ tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES -
+ coex_dm->switch_thres_offset - coex_dm->switch_thres_offset;
+ bt_rssi_state = btc8723b2ant_bt_rssi_state(btcoexist, 2, tmp, 0);
+
+ btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num);
+
+ /* office environment */
+ if (BTC_RSSI_HIGH(wifi_rssi_state1) && (coex_sta->hid_exist) &&
+ (coex_sta->a2dp_exist)) {
+ RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+ "[BTCoex], Wifi idle process for BT HID+A2DP exist!!\n");
+
+ btc8723b2ant_dac_swing(btcoexist, NORMAL_EXEC, true, 0x6);
+ btc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
+
+ /* sw all off */
+ btc8723b2ant_sw_mechanism(btcoexist, false, false, false,
+ false);
+ btc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
+ btc8723b2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
+ 0x0, 0x0);
+ btc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
+
+ return true;
+ }
+
+ btc8723b2ant_dac_swing(btcoexist, NORMAL_EXEC, true, 0x18);
+ return false;
+}
+
static bool btc8723b2ant_is_common_action(struct btc_coexist *btcoexist)
{
struct rtl_priv *rtlpriv = btcoexist->adapter;
@@ -1710,26 +1751,12 @@ static bool btc8723b2ant_is_common_action(struct btc_coexist *btcoexist)
"[BTCoex], Wifi Connected-Busy + BT Busy!!\n");
common = false;
} else {
- if (bt_hs_on)
- return false;
-
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], Wifi Connected-Idle + BT Busy!!\n");

- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A,
- 0x1, 0xfffff, 0x0);
- btc8723b2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC,
- 7);
- btc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 21);
- btc8723b2ant_fw_dac_swing_lvl(btcoexist,
- NORMAL_EXEC,
- 0xb);
- btc8723b2ant_sw_mechanism(btcoexist, false,
- false, false,
- false);
- common = true;
+ common =
+ btc8723b2ant_action_wifi_idle_process(
+ btcoexist);
}
}
}
--
2.12.0

2017-04-06 20:20:11

by Larry Finger

[permalink] [raw]
Subject: [PATCH 08/11] rtlwifi: btcoex: 23b 2ant: fine tune for bt pan_edr_a2dp

From: Yan-Hsuan Chuang <[email protected]>

If we don't limit the rx aggregation size, and set tdma instead, the bt profile can
get more stable.

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 06f70944bdac..a76c8d20e093 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -3140,7 +3140,6 @@ static void btc8723b2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)

btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);

- btc8723b2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
btc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);

if (BTC_RSSI_HIGH(bt_rssi_state))
@@ -3167,7 +3166,7 @@ static void btc8723b2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)
false, 3);
} else {
btc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
- btc8723b2ant_tdma_duration_adjust(btcoexist, false, true, 3);
+ btc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3);
}

/* sw mechanism */
--
2.12.0

2017-04-06 20:20:08

by Larry Finger

[permalink] [raw]
Subject: [PATCH 05/11] rtlwifi: btcoex: 23b 2ant: wifi is not actually off in mp mode

From: Yan-Hsuan Chuang <[email protected]>

In mp mode, the wifi will not turn off and still has control of the PTA,
so the driver needs to distinguish whether it is mp mode or not

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
.../net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 10 ++++++++++
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 1 +
2 files changed, 11 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 93dbbc507ba1..70f21059ddc3 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -3606,6 +3606,7 @@ static void btc8723b2ant_run_coexist_mechanism(struct btc_coexist *btcoexist)

static void btc8723b2ant_wifioff_hwcfg(struct btc_coexist *btcoexist)
{
+ bool is_in_mp_mode = false;
u8 h2c_parameter[2] = {0};
u32 fw_ver = 0;

@@ -3623,6 +3624,15 @@ static void btc8723b2ant_wifioff_hwcfg(struct btc_coexist *btcoexist)
} else {
btcoexist->btc_write_1byte(btcoexist, 0x765, 0x18);
}
+
+ btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE,
+ &is_in_mp_mode);
+ if (!is_in_mp_mode)
+ /* BT select s0/s1 is controlled by BT */
+ btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x0);
+ else
+ /* BT select s0/s1 is controlled by WiFi */
+ btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x1);
}

/*********************************************************************
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index 022658cafbca..0b90e7f0b722 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -205,6 +205,7 @@ enum btc_get_type {
BTC_GET_BL_WIFI_ENABLE_ENCRYPTION,
BTC_GET_BL_WIFI_UNDER_B_MODE,
BTC_GET_BL_EXT_SWITCH,
+ BTC_GET_BL_WIFI_IS_IN_MP_MODE,

/* type s4Byte */
BTC_GET_S4_WIFI_RSSI,
--
2.12.0

2017-04-06 20:20:12

by Larry Finger

[permalink] [raw]
Subject: [PATCH 09/11] rtlwifi: btcoex: 23b 2ant: fine tune for bt hid_a2dp

From: Yan-Hsuan Chuang <[email protected]>

Let bt control the aggregation size to improve stability.

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index a76c8d20e093..9092de2d2c7c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -3355,7 +3355,7 @@ static void btc8723b2ant_action_hid_a2dp(struct btc_coexist *btcoexist)

btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);

- btc8723b2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
+ btc8723b2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true, 0x5);
btc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);

btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
--
2.12.0

2017-04-06 20:20:05

by Larry Finger

[permalink] [raw]
Subject: [PATCH 02/11] rtlwifi: btcoex: 23b 2ant: treat too many low prio packets as retry

From: Yan-Hsuan Chuang <[email protected]>

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 327609e3a309..82a5e5357cb7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -1884,6 +1884,11 @@ static void btc8723b2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
} else {
/*accquire the BT TRx retry count from BT_Info byte2*/
retry_count = coex_sta->bt_retry_cnt;
+
+ if ((coex_sta->low_priority_tx) > 1050 ||
+ (coex_sta->low_priority_rx) > 1250)
+ retry_count++;
+
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], retry_count = %d\n", retry_count);
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
--
2.12.0

2017-04-06 20:20:13

by Larry Finger

[permalink] [raw]
Subject: [PATCH 11/11] rtlwifi: btcoex: 23b 2ant: some hi-prio pkt will cause hid_exist

From: Yan-Hsuan Chuang <[email protected]>

Clear the hid_exist flag by monitoring the packet counter.

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 1c823a71ce9f..2f3946be4ce2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -4329,6 +4329,7 @@ void ex_btc8723b2ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
void ex_btc8723b2ant_periodical(struct btc_coexist *btcoexist)
{
struct rtl_priv *rtlpriv = btcoexist->adapter;
+ struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;

RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], ==========================Periodical===========================\n");
@@ -4352,6 +4353,13 @@ void ex_btc8723b2ant_periodical(struct btc_coexist *btcoexist)
btc8723b2ant_monitor_bt_ctr(btcoexist);
btc8723b2ant_monitor_wifi_ctr(btcoexist);

+ /* for some BT speakers that High-Priority pkts appear before
+ * playing, this will cause HID exist
+ */
+ if ((coex_sta->high_priority_tx + coex_sta->high_priority_rx < 50) &&
+ (bt_link_info->hid_exist))
+ bt_link_info->hid_exist = false;
+
if (btc8723b2ant_is_wifi_status_changed(btcoexist) ||
coex_dm->auto_tdma_adjust)
btc8723b2ant_run_coexist_mechanism(btcoexist);
--
2.12.0

2017-04-06 20:20:13

by Larry Finger

[permalink] [raw]
Subject: [PATCH 10/11] rtlwifi: btcoex: 23b 2ant: notify more bt information

From: Yan-Hsuan Chuang <[email protected]>

These bt information are displayed in display coex

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
.../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 20 ++++++++++++++++++++
.../realtek/rtlwifi/btcoexist/halbtc8723b2ant.h | 2 ++
.../realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 15 +++++++++++++++
3 files changed, 37 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 9092de2d2c7c..1c823a71ce9f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -4145,9 +4145,19 @@ void ex_btc8723b2ant_bt_info_notify(struct btc_coexist *btcoexist,
coex_sta->bt_retry_cnt =
coex_sta->bt_info_c2h[rsp_source][2] & 0xf;

+ if (coex_sta->bt_retry_cnt >= 1)
+ coex_sta->pop_event_cnt++;
+
coex_sta->bt_rssi =
coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10;

+ coex_sta->bt_info_ext = coex_sta->bt_info_c2h[rsp_source][4];
+
+ if (coex_sta->bt_info_c2h[rsp_source][2] & 0x20)
+ coex_sta->c2h_bt_remote_name_req = true;
+ else
+ coex_sta->c2h_bt_remote_name_req = false;
+
if (coex_sta->bt_info_c2h[rsp_source][1] == 0x49)
coex_sta->a2dp_bit_pool =
coex_sta->bt_info_c2h[rsp_source][6];
@@ -4222,6 +4232,16 @@ void ex_btc8723b2ant_bt_info_notify(struct btc_coexist *btcoexist,
coex_sta->sco_exist = true;
else
coex_sta->sco_exist = false;
+
+ if ((!coex_sta->hid_exist) &&
+ (!coex_sta->c2h_bt_inquiry_page) &&
+ (!coex_sta->sco_exist)) {
+ if (coex_sta->high_priority_tx +
+ coex_sta->high_priority_rx >= 160) {
+ coex_sta->hid_exist = true;
+ bt_info = bt_info | 0x28;
+ }
+ }
}

btc8723b2ant_update_bt_link_info(btcoexist);
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
index 9e29f85304cc..18a35c7faba9 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
@@ -151,12 +151,14 @@ struct coex_sta_8723b_2ant {
u32 low_priority_tx;
u32 low_priority_rx;
u8 bt_rssi;
+ bool bt_tx_rx_mask;
u8 pre_bt_rssi_state;
u8 pre_wifi_rssi_state[4];
bool c2h_bt_info_req_sent;
u8 bt_info_c2h[BT_INFO_SRC_8723B_2ANT_MAX][10];
u32 bt_info_c2h_cnt[BT_INFO_SRC_8723B_2ANT_MAX];
bool c2h_bt_inquiry_page;
+ bool c2h_bt_remote_name_req;
u8 bt_retry_cnt;
u8 bt_info_ext;
u32 pop_event_cnt;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index d31e6df5b1bf..c8271135aaaa 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -66,6 +66,15 @@
#define BTC_ANT_WIFI_AT_CPL_MAIN 0
#define BTC_ANT_WIFI_AT_CPL_AUX 1

+enum btc_bt_reg_type {
+ BTC_BT_REG_RF = 0,
+ BTC_BT_REG_MODEM = 1,
+ BTC_BT_REG_BLUEWIZE = 2,
+ BTC_BT_REG_VENDOR = 3,
+ BTC_BT_REG_LE = 4,
+ BTC_BT_REG_MAX
+};
+
enum btc_chip_interface {
BTC_INTF_UNKNOWN = 0,
BTC_INTF_PCI = 1,
@@ -251,6 +260,7 @@ enum btc_set_type {
BTC_SET_BL_TO_REJ_AP_AGG_PKT,
BTC_SET_BL_BT_CTRL_AGG_SIZE,
BTC_SET_BL_INC_SCAN_DEV_NUM,
+ BTC_SET_BL_BT_TX_RX_MASK,
BTC_SET_BL_MIRACAST_PLUS_BT,

/* type u1Byte */
@@ -392,6 +402,9 @@ typedef bool (*bfp_btc_get)(void *btcoexist, u8 get_type, void *out_buf);

typedef bool (*bfp_btc_set)(void *btcoexist, u8 set_type, void *in_buf);

+typedef void (*bfp_btc_set_bt_reg)(void *btc_context, u8 reg_type, u32 offset,
+ u32 value);
+
typedef void (*bfp_btc_disp_dbg_msg)(void *btcoexist, u8 disp_type);

struct btc_bt_info {
@@ -511,6 +524,8 @@ struct btc_coexist {

bfp_btc_get btc_get;
bfp_btc_set btc_set;
+
+ bfp_btc_set_bt_reg btc_set_bt_reg;
};

bool halbtc_is_wifi_uplink(struct rtl_priv *adapter);
--
2.12.0

2017-04-06 20:20:06

by Larry Finger

[permalink] [raw]
Subject: [PATCH 03/11] rtlwifi: btcoex: 23b 2ant: remove debugging code for 0x948

From: Yan-Hsuan Chuang <[email protected]>

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 6 ------
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h | 2 --
2 files changed, 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 82a5e5357cb7..9c169d094b51 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -3486,12 +3486,6 @@ static void btc8723b2ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
"[BTCoex], BT is under inquiry/page scan !!\n");
btc8723b2ant_action_bt_inquiry(btcoexist);
return;
- } else {
- if (coex_dm->need_recover_0x948) {
- coex_dm->need_recover_0x948 = false;
- btcoexist->btc_write_2byte(btcoexist, 0x948,
- coex_dm->backup_0x948);
- }
}

btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
index 2c2113482481..9e29f85304cc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
@@ -134,8 +134,6 @@ struct coex_dm_8723b_2ant {

bool is_switch_to_1dot5_ant;
u8 switch_thres_offset;
- bool need_recover_0x948;
- u16 backup_0x948;
};

struct coex_sta_8723b_2ant {
--
2.12.0

2017-04-06 20:20:07

by Larry Finger

[permalink] [raw]
Subject: [PATCH 04/11] rtlwifi: btcoex: 23b 2ant: need those information when scan

From: Yan-Hsuan Chuang <[email protected]>

For scan notify, we need to supervise some registers to make sure that
coexistence is operating as we expected.

Signed-off-by: Yan-Hsuan Chuang <[email protected]>
Signed-off-by: Larry Finger <[email protected]>
Cc: Pkshih <[email protected]>
Cc: Birming Chiu <[email protected]>
Cc: Shaofu <[email protected]>
Cc: Steven Ting <[email protected]>
---
.../net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 9c169d094b51..93dbbc507ba1 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -3934,6 +3934,12 @@ void ex_btc8723b2ant_lps_notify(struct btc_coexist *btcoexist, u8 type)
void ex_btc8723b2ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
{
struct rtl_priv *rtlpriv = btcoexist->adapter;
+ u32 u32tmp;
+ u8 u8tmpa, u8tmpb;
+
+ u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x948);
+ u8tmpa = btcoexist->btc_read_1byte(btcoexist, 0x765);
+ u8tmpb = btcoexist->btc_read_1byte(btcoexist, 0x76e);

if (BTC_SCAN_START == type)
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
@@ -3943,6 +3949,10 @@ void ex_btc8723b2ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
"[BTCoex], SCAN FINISH notify\n");
btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM,
&coex_sta->scan_ap_num);
+
+ RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+ "############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x76e=0x%x\n",
+ u32tmp, u8tmpa, u8tmpb);
}

void ex_btc8723b2ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
--
2.12.0