All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code
@ 2017-04-10 16:22 Larry Finger
  2017-04-10 16:22 ` [PATCH 01/14] rtlwifi: btcoex: 21a 1ant: fw settings for softap mode Larry Finger
                   ` (13 more replies)
  0 siblings, 14 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:22 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Larry Finger, Yan-Hsuan Chuang, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

These patches update the BT coexistence routines for the RTL8821AE 1ant
routines.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>


Yan-Hsuan Chuang (14):
  rtlwifi: btcoex: 21a 1ant: fw settings for softap mode
  rtlwifi: btcoex: 21a 1ant: add function to check wifi status
  rtlwifi: btcoex: 21a 1ant: coex table setting for new fw
  rtlwifi: btcoex: 21a 1ant: mask profile bit for connect-ilde
  rtlwifi: btcoex: 21a 1ant: remove setting for 2 antennas
  rtlwifi: btcoex: 21a 1ant: set antenna control path for PTA
  rtlwifi: btcoex: 21a 1ant: add multi port action for miracast and P2P
  rtlwifi: btcoex: 21a 1ant: action when associating/authenticating
  rtlwifi: btcoex: 21a 1ant: If wifi only, do not initiate coex
    mechanism
  rtlwifi: btcoex: 21a 1ant: move bt_disabled to global struct
  rtlwifi: btcoex: 21a 1ant: consider more cases when bt inquiry
  rtlwifi: btcoex: 21a 1ant: monitor bt profiling when scan
  rtlwifi: btcoex: 21a 1ant: do not switch antenna when wifi is under 5G
    channel
  rtlwifi: btcoex: 21a 1ant: avoid LPS/IPS mismatch for pnp notify

 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 408 ++++++++++++++++++---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h    |   2 +
 2 files changed, 351 insertions(+), 59 deletions(-)

-- 
2.12.0

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/14] rtlwifi: btcoex: 21a 1ant: fw settings for softap mode
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
@ 2017-04-10 16:22 ` Larry Finger
  2017-04-13 14:11   ` [01/14] " Kalle Valo
  2017-04-10 16:22 ` [PATCH 02/14] rtlwifi: btcoex: 21a 1ant: add function to check wifi status Larry Finger
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:22 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

For ap mode, adjust fw settings to operate properly.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 25 ++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 6f6ab0738fbb..5b8f4ed5ce62 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -843,18 +843,35 @@ static void btc8821a1ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, u8 byte1,
 {
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
 	u8 h2c_parameter[5] = {0};
+	u8 real_byte1 = byte1, real_byte5 = byte5;
+	bool ap_enable = false;
 
-	h2c_parameter[0] = byte1;
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
+			   &ap_enable);
+
+	if (ap_enable) {
+		if (byte1 & BIT4 && !(byte1 & BIT5)) {
+			RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+				 "[BTCoex], FW for 1Ant AP mode\n");
+			real_byte1 &= ~BIT4;
+			real_byte1 |= BIT5;
+
+			real_byte5 |= BIT5;
+			real_byte5 &= ~BIT6;
+		}
+	}
+
+	h2c_parameter[0] = real_byte1;
 	h2c_parameter[1] = byte2;
 	h2c_parameter[2] = byte3;
 	h2c_parameter[3] = byte4;
-	h2c_parameter[4] = byte5;
+	h2c_parameter[4] = real_byte5;
 
-	coex_dm->ps_tdma_para[0] = byte1;
+	coex_dm->ps_tdma_para[0] = real_byte1;
 	coex_dm->ps_tdma_para[1] = byte2;
 	coex_dm->ps_tdma_para[2] = byte3;
 	coex_dm->ps_tdma_para[3] = byte4;
-	coex_dm->ps_tdma_para[4] = byte5;
+	coex_dm->ps_tdma_para[4] = real_byte5;
 
 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 		 "[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n",
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/14] rtlwifi: btcoex: 21a 1ant: add function to check wifi status
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
  2017-04-10 16:22 ` [PATCH 01/14] rtlwifi: btcoex: 21a 1ant: fw settings for softap mode Larry Finger
@ 2017-04-10 16:22 ` Larry Finger
  2017-04-10 16:22 ` [PATCH 03/14] rtlwifi: btcoex: 21a 1ant: coex table setting for new fw Larry Finger
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:22 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

This function checks if wifi has changed its statusi. It will be needed
in the future.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 5b8f4ed5ce62..65c455bfd8fb 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -424,6 +424,39 @@ static void btc8821a1ant_query_bt_info(struct btc_coexist *btcoexist)
 	btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
 }
 
+bool btc8821a1ant_is_wifi_status_changed(struct btc_coexist *btcoexist)
+{
+	static bool pre_wifi_busy = true;
+	static bool pre_under_4way = true;
+	static bool pre_bt_hs_on = true;
+	bool wifi_busy = false, under_4way = false, bt_hs_on = false;
+	bool wifi_connected = false;
+
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
+			   &wifi_connected);
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
+			   &under_4way);
+
+	if (wifi_connected) {
+		if (wifi_busy != pre_wifi_busy) {
+			pre_wifi_busy = wifi_busy;
+			return true;
+		}
+		if (under_4way != pre_under_4way) {
+			pre_under_4way = under_4way;
+			return true;
+		}
+		if (bt_hs_on != pre_bt_hs_on) {
+			pre_bt_hs_on = bt_hs_on;
+			return true;
+		}
+	}
+
+	return false;
+}
+
 static void btc8821a1ant_update_bt_link_info(struct btc_coexist *btcoexist)
 {
 	struct btc_bt_link_info	*bt_link_info = &btcoexist->bt_link_info;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/14] rtlwifi: btcoex: 21a 1ant: coex table setting for new fw
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
  2017-04-10 16:22 ` [PATCH 01/14] rtlwifi: btcoex: 21a 1ant: fw settings for softap mode Larry Finger
  2017-04-10 16:22 ` [PATCH 02/14] rtlwifi: btcoex: 21a 1ant: add function to check wifi status Larry Finger
@ 2017-04-10 16:22 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 04/14] rtlwifi: btcoex: 21a 1ant: mask profile bit for connect-ilde Larry Finger
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:22 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

For newer fw, the coex table setting needs to be modified to operate
correctly.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c        | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 65c455bfd8fb..3a117eaf1b21 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -806,24 +806,24 @@ static void btc8821a1ant_coex_table_with_type(struct btc_coexist *btcoexist,
 					0x5a5a5a5a, 0xffffff, 0x3);
 		break;
 	case 3:
-		btc8821a1ant_coex_table(btcoexist, force_exec, 0x55555555,
+		btc8821a1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
 					0xaaaaaaaa, 0xffffff, 0x3);
 		break;
 	case 4:
-		btc8821a1ant_coex_table(btcoexist, force_exec, 0xffffffff,
-					0xffffffff, 0xffffff, 0x3);
+		btc8821a1ant_coex_table(btcoexist, force_exec, 0x55555555,
+					0x5a5a5a5a, 0xffffff, 0x3);
 		break;
 	case 5:
-		btc8821a1ant_coex_table(btcoexist, force_exec, 0x5fff5fff,
-					0x5fff5fff, 0xffffff, 0x3);
+		btc8821a1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
+					0xaaaa5a5a, 0xffffff, 0x3);
 		break;
 	case 6:
-		btc8821a1ant_coex_table(btcoexist, force_exec, 0x55ff55ff,
-					0x5a5a5a5a, 0xffffff, 0x3);
+		btc8821a1ant_coex_table(btcoexist, force_exec, 0x55555555,
+					0xaaaa5a5a, 0xffffff, 0x3);
 		break;
 	case 7:
-		btc8821a1ant_coex_table(btcoexist, force_exec, 0x5afa5afa,
-					0x5afa5afa, 0xffffff, 0x3);
+		btc8821a1ant_coex_table(btcoexist, force_exec, 0xaaaaaaaa,
+					0xaaaaaaaa, 0xffffff, 0x3);
 		break;
 	default:
 		break;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/14] rtlwifi: btcoex: 21a 1ant: mask profile bit for connect-ilde
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (2 preceding siblings ...)
  2017-04-10 16:22 ` [PATCH 03/14] rtlwifi: btcoex: 21a 1ant: coex table setting for new fw Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 05/14] rtlwifi: btcoex: 21a 1ant: remove setting for 2 antennas Larry Finger
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Mask out the connect-idle bit.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 3a117eaf1b21..88bf70f27669 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2606,7 +2606,12 @@ void ex_btc8821a1ant_bt_info_notify(struct btc_coexist *btcoexist,
 
 	btc8821a1ant_update_bt_link_info(btcoexist);
 
-	if (!(bt_info&BT_INFO_8821A_1ANT_B_CONNECTION)) {
+	/* mask profile bit for connect-ilde identification
+	 * (for CSR case: A2DP idle --> 0x41)
+	 */
+	bt_info = bt_info & 0x1f;
+
+	if (!(bt_info & BT_INFO_8821A_1ANT_B_CONNECTION)) {
 		coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n");
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/14] rtlwifi: btcoex: 21a 1ant: remove setting for 2 antennas
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (3 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 04/14] rtlwifi: btcoex: 21a 1ant: mask profile bit for connect-ilde Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 06/14] rtlwifi: btcoex: 21a 1ant: set antenna control path for PTA Larry Finger
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

The antenna position setting is useless for 1 antenna chip.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 88bf70f27669..b84c1a5be40a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -994,9 +994,6 @@ static void btc8821a1ant_set_ant_path(struct btc_coexist *btcoexist,
 			h2c_parameter[1] = 1;
 			btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
 						h2c_parameter);
-			/* Main Ant to  BT for IPS case 0x4c[23] = 1 */
-			btcoexist->btc_write_1byte_bitmask(btcoexist, 0x64,
-							   0x1, 0x1);
 		} else {
 			/* tell firmware "no antenna inverse"
 			 * WRONG firmware antenna control code, need fw to fix
@@ -1005,9 +1002,6 @@ static void btc8821a1ant_set_ant_path(struct btc_coexist *btcoexist,
 			h2c_parameter[1] = 1;
 			btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
 						h2c_parameter);
-			/* Aux Ant to BT for IPS case 0x4c[23] = 1 */
-			btcoexist->btc_write_1byte_bitmask(btcoexist, 0x64,
-							   0x1, 0x0);
 		}
 	} else if (wifi_off) {
 		/* 0x4c[24:23] = 00, Set Antenna control
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/14] rtlwifi: btcoex: 21a 1ant: set antenna control path for PTA
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (4 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 05/14] rtlwifi: btcoex: 21a 1ant: remove setting for 2 antennas Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 07/14] rtlwifi: btcoex: 21a 1ant: add multi port action for miracast and P2P Larry Finger
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Set antenna control path if PTA is in control of the packet path of wifi
and bt. If wifi is turned off, tell the PTA about it.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index b84c1a5be40a..5b374c7728ba 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1011,11 +1011,18 @@ static void btc8821a1ant_set_ant_path(struct btc_coexist *btcoexist,
 		u4_tmp &= ~BIT23;
 		u4_tmp &= ~BIT24;
 		btcoexist->btc_write_4byte(btcoexist, 0x4c, u4_tmp);
+
+		/* 0x765 = 0x18 */
+		btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x3);
+	} else {
+		/* 0x765 = 0x0 */
+		btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0);
 	}
 
 	/* ext switch setting */
 	switch (ant_pos_type) {
 	case BTC_ANT_PATH_WIFI:
+		btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77);
 		if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
 			btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
 							   0x30, 0x1);
@@ -1024,6 +1031,7 @@ static void btc8821a1ant_set_ant_path(struct btc_coexist *btcoexist,
 							   0x30, 0x2);
 		break;
 	case BTC_ANT_PATH_BT:
+		btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77);
 		if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
 			btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
 							   0x30, 0x2);
@@ -1033,6 +1041,7 @@ static void btc8821a1ant_set_ant_path(struct btc_coexist *btcoexist,
 		break;
 	default:
 	case BTC_ANT_PATH_PTA:
+		btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x66);
 		if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
 			btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
 							   0x30, 0x1);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/14] rtlwifi: btcoex: 21a 1ant: add multi port action for miracast and P2P
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (5 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 06/14] rtlwifi: btcoex: 21a 1ant: set antenna control path for PTA Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 08/14] rtlwifi: btcoex: 21a 1ant: action when associating/authenticating Larry Finger
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

To support miracast and P2P, the chip may operate under concurrent mode,
In this situation, do not aggregate tx packet and properly set the rx
aggregation size.

We detect it by monitoring the number of link established.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 5b374c7728ba..cadc0f91af41 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1478,6 +1478,14 @@ static void btc8821a1ant_action_hid_a2dp(struct btc_coexist *btcoexist)
  *	Non-Software Coex Mechanism start
  *
  ***********************************************/
+static
+void btc8821a1ant_action_wifi_multi_port(struct btc_coexist *btcoexist)
+{
+	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
+	btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+	btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
+}
+
 
 static void btc8821a1ant_action_hs(struct btc_coexist *btcoexist)
 {
@@ -1820,6 +1828,8 @@ static void btc8821a1ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
 	bool bt_ctrl_agg_buf_size = false;
 	u8 agg_buf_size = 5;
 	u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
+	u32 wifi_link_status = 0;
+	u32 num_of_wifi_link = 0;
 	bool wifi_under_5g = false;
 
 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
@@ -1862,6 +1872,18 @@ static void btc8821a1ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
 	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
 			   &wifi_connected);
 
+	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
+			   &wifi_link_status);
+	num_of_wifi_link = wifi_link_status >> 16;
+	if ((num_of_wifi_link >= 2) ||
+	    (wifi_link_status & WIFI_P2P_GO_CONNECTED)) {
+		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
+		btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
+					bt_ctrl_agg_buf_size, agg_buf_size);
+		btc8821a1ant_action_wifi_multi_port(btcoexist);
+		return;
+	}
+
 	if (!bt_link_info->sco_exist && !bt_link_info->hid_exist) {
 		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
 	} else {
@@ -2337,6 +2359,10 @@ void ex_btc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
 {
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
 	bool wifi_connected = false, bt_hs_on = false;
+	bool bt_ctrl_agg_buf_size = false;
+	u32 wifi_link_status = 0;
+	u32 num_of_wifi_link = 0;
+	u8 agg_buf_size = 5;
 
 	if (btcoexist->manual_control ||
 	    btcoexist->stop_coex_dm ||
@@ -2350,6 +2376,17 @@ void ex_btc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
 
 	btc8821a1ant_query_bt_info(btcoexist);
 
+	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
+			   &wifi_link_status);
+	num_of_wifi_link = wifi_link_status >> 16;
+	if (num_of_wifi_link >= 2) {
+		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
+		btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
+					bt_ctrl_agg_buf_size, agg_buf_size);
+		btc8821a1ant_action_wifi_multi_port(btcoexist);
+		return;
+	}
+
 	if (coex_sta->c2h_bt_inquiry_page) {
 		btc8821a1ant_action_bt_inquiry(btcoexist);
 		return;
@@ -2384,12 +2421,27 @@ void ex_btc8821a1ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
 {
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
 	bool	wifi_connected = false, bt_hs_on = false;
+	u32 wifi_link_status = 0;
+	u32 num_of_wifi_link = 0;
+	bool bt_ctrl_agg_buf_size = false;
+	u8 agg_buf_size = 5;
 
 	if (btcoexist->manual_control ||
 	    btcoexist->stop_coex_dm ||
 	    btcoexist->bt_info.bt_disabled)
 		return;
 
+	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
+			   &wifi_link_status);
+	num_of_wifi_link = wifi_link_status >> 16;
+	if (num_of_wifi_link >= 2) {
+		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
+		btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
+					bt_ctrl_agg_buf_size, agg_buf_size);
+		btc8821a1ant_action_wifi_multi_port(btcoexist);
+		return;
+	}
+
 	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
 	if (coex_sta->c2h_bt_inquiry_page) {
 		btc8821a1ant_action_bt_inquiry(btcoexist);
@@ -2472,6 +2524,10 @@ void ex_btc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist,
 {
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
 	bool bt_hs_on = false;
+	bool bt_ctrl_agg_buf_size = false;
+	u32 wifi_link_status = 0;
+	u32 num_of_wifi_link = 0;
+	u8 agg_buf_size = 5;
 
 	if (btcoexist->manual_control ||
 	    btcoexist->stop_coex_dm ||
@@ -2480,6 +2536,17 @@ void ex_btc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist,
 
 	coex_sta->special_pkt_period_cnt = 0;
 
+	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
+			   &wifi_link_status);
+	num_of_wifi_link = wifi_link_status >> 16;
+	if (num_of_wifi_link >= 2) {
+		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
+		btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
+					bt_ctrl_agg_buf_size, agg_buf_size);
+		btc8821a1ant_action_wifi_multi_port(btcoexist);
+		return;
+	}
+
 	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
 	if (coex_sta->c2h_bt_inquiry_page) {
 		btc8821a1ant_action_bt_inquiry(btcoexist);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/14] rtlwifi: btcoex: 21a 1ant: action when associating/authenticating
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (6 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 07/14] rtlwifi: btcoex: 21a 1ant: add multi port action for miracast and P2P Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 09/14] rtlwifi: btcoex: 21a 1ant: If wifi only, do not initiate coex mechanism Larry Finger
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

When wifi is associating or authenticating, set the coex table for wifi
to establish link. These packets should have higher priority.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 33 ++++++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index cadc0f91af41..05e33d38d49c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1486,6 +1486,28 @@ void btc8821a1ant_action_wifi_multi_port(struct btc_coexist *btcoexist)
 	btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
 }
 
+static
+void btc8821a1ant_action_wifi_not_connected_asso_auth(
+					struct btc_coexist *btcoexist)
+{
+	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
+
+	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
+				      0x0);
+
+	/* tdma and coex table */
+	if ((bt_link_info->sco_exist) || (bt_link_info->hid_exist)) {
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+	} else if ((bt_link_info->a2dp_exist) || (bt_link_info->pan_exist)) {
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
+	} else {
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
+	}
+}
+
 
 static void btc8821a1ant_action_hs(struct btc_coexist *btcoexist)
 {
@@ -1941,10 +1963,15 @@ static void btc8821a1ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
 		btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
 		btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
 
-		if (scan || link || roam)
-			btc8821a1ant_act_wifi_not_conn_scan(btcoexist);
-		else
+		if (scan || link || roam) {
+			if (scan)
+				btc8821a1ant_act_wifi_not_conn_scan(btcoexist);
+			else
+				btc8821a1ant_action_wifi_not_connected_asso_auth(
+					btcoexist);
+		} else {
 			btc8821a1ant_action_wifi_not_connected(btcoexist);
+		}
 	} else {
 		/* wifi LPS/Busy */
 		btc8821a1ant_action_wifi_connected(btcoexist);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/14] rtlwifi: btcoex: 21a 1ant: If wifi only, do not initiate coex mechanism
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (7 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 08/14] rtlwifi: btcoex: 21a 1ant: action when associating/authenticating Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 10/14] rtlwifi: btcoex: 21a 1ant: move bt_disabled to global struct Larry Finger
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

If the device has wifi mode only, there is no need to initiate the
hardware for wifi and bt coexistence, so just return to avoid it.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c  | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 05e33d38d49c..86eab6a4ada2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1990,7 +1990,7 @@ static void btc8821a1ant_init_coex_dm(struct btc_coexist *btcoexist)
 }
 
 static void btc8821a1ant_init_hw_config(struct btc_coexist *btcoexist,
-					bool back_up)
+					bool back_up, bool wifi_only)
 {
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
 	u8 u1_tmp = 0;
@@ -1999,6 +1999,9 @@ static void btc8821a1ant_init_hw_config(struct btc_coexist *btcoexist,
 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 		 "[BTCoex], 1Ant Init HW Config!!\n");
 
+	if (wifi_only)
+		return;
+
 	if (back_up) {
 		coex_dm->backup_arfr_cnt1 = btcoexist->btc_read_4byte(btcoexist,
 								      0x430);
@@ -2039,9 +2042,9 @@ static void btc8821a1ant_init_hw_config(struct btc_coexist *btcoexist,
 /**************************************************************
  * extern function start with ex_btc8821a1ant_
  **************************************************************/
-void ex_btc8821a1ant_init_hwconfig(struct btc_coexist *btcoexist)
+void ex_btc8821a1ant_init_hwconfig(struct btc_coexist *btcoexist, bool wifionly)
 {
-	btc8821a1ant_init_hw_config(btcoexist, true);
+	btc8821a1ant_init_hw_config(btcoexist, true, wifionly);
 }
 
 void ex_btc8821a1ant_init_coex_dm(struct btc_coexist *btcoexist)
@@ -2783,7 +2786,7 @@ void ex_btc8821a1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], Pnp notify to WAKE UP\n");
 		btcoexist->stop_coex_dm = false;
-		btc8821a1ant_init_hw_config(btcoexist, false);
+		btc8821a1ant_init_hw_config(btcoexist, false, false);
 		btc8821a1ant_init_coex_dm(btcoexist);
 		btc8821a1ant_query_bt_info(btcoexist);
 	}
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/14] rtlwifi: btcoex: 21a 1ant: move bt_disabled to global struct
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (8 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 09/14] rtlwifi: btcoex: 21a 1ant: If wifi only, do not initiate coex mechanism Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 11/14] rtlwifi: btcoex: 21a 1ant: consider more cases when bt inquiry Larry Finger
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Move the bt disable flag to a global structure to indicate that bt is
turned off.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 24 ++++++++++------------
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h    |  1 +
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 86eab6a4ada2..c6114b32c0ca 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2168,7 +2168,7 @@ void ex_btc8821a1ant_display_coex_info(struct btc_coexist *btcoexist)
 		 "uplink" : "downlink")));
 	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
 		   "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]",
-		   ((btcoexist->bt_info.bt_disabled) ? ("disabled") :
+		   ((coex_sta->bt_disabled) ? ("disabled") :
 		   ((coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan") :
 		   ((BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
 		     coex_dm->bt_status) ?
@@ -2394,9 +2394,10 @@ void ex_btc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
 	u32 num_of_wifi_link = 0;
 	u8 agg_buf_size = 5;
 
-	if (btcoexist->manual_control ||
-	    btcoexist->stop_coex_dm ||
-	    btcoexist->bt_info.bt_disabled)
+	if (btcoexist->manual_control || btcoexist->stop_coex_dm)
+		return;
+
+	if (coex_sta->bt_disabled)
 		return;
 
 	btcoexist->btc_get(btcoexist,
@@ -2456,9 +2457,8 @@ void ex_btc8821a1ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
 	bool bt_ctrl_agg_buf_size = false;
 	u8 agg_buf_size = 5;
 
-	if (btcoexist->manual_control ||
-	    btcoexist->stop_coex_dm ||
-	    btcoexist->bt_info.bt_disabled)
+	if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
+	    coex_sta->bt_disabled)
 		return;
 
 	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
@@ -2508,9 +2508,8 @@ void ex_btc8821a1ant_media_status_notify(struct btc_coexist *btcoexist,
 	u32 wifi_bw;
 	u8 wifi_central_chnl;
 
-	if (btcoexist->manual_control ||
-	    btcoexist->stop_coex_dm ||
-	    btcoexist->bt_info.bt_disabled)
+	if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
+	    coex_sta->bt_disabled)
 		return;
 
 	if (BTC_MEDIA_CONNECT == type) {
@@ -2559,9 +2558,8 @@ void ex_btc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist,
 	u32 num_of_wifi_link = 0;
 	u8 agg_buf_size = 5;
 
-	if (btcoexist->manual_control ||
-	    btcoexist->stop_coex_dm ||
-	    btcoexist->bt_info.bt_disabled)
+	if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
+	    coex_sta->bt_disabled)
 		return;
 
 	coex_sta->special_pkt_period_cnt = 0;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
index 9f50a1427388..2dec38ab7746 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
@@ -140,6 +140,7 @@ struct coex_dm_8821a_1ant {
 };
 
 struct coex_sta_8821a_1ant {
+	bool	bt_disabled;
 	bool	bt_link_exist;
 	bool	sco_exist;
 	bool	a2dp_exist;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 11/14] rtlwifi: btcoex: 21a 1ant: consider more cases when bt inquiry
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (9 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 10/14] rtlwifi: btcoex: 21a 1ant: move bt_disabled to global struct Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 12/14] rtlwifi: btcoex: 21a 1ant: monitor bt profiling when scan Larry Finger
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

With bt inquiry, the wifi may start as a softap or the wifi and bt are
busy, we take these scenarios into consider to avoid bt inquiry to
degrade the performance of the network

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 75 +++++++++++++++++-----
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h    |  1 +
 2 files changed, 60 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index c6114b32c0ca..6b08051614eb 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1139,8 +1139,8 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
 						    0x18, 0x0, 0x10);
 			break;
 		case 14:
-			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x21,
-						    0x3, 0x10, 0x10);
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1e,
+						    0x3, 0x10, 0x14);
 			break;
 		case 15:
 			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa,
@@ -1519,27 +1519,46 @@ static void btc8821a1ant_action_bt_inquiry(struct btc_coexist *btcoexist)
 {
 	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
 	bool wifi_connected = false;
+	bool ap_enable = false;
+	bool wifi_busy = false, bt_busy = false;
 
-	btcoexist->btc_get(btcoexist,
-		 BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
+			   &wifi_connected);
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
+			   &ap_enable);
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
+	btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
 
-	if (!wifi_connected) {
+	if (!wifi_connected && !coex_sta->wifi_is_high_pri_task) {
 		btc8821a1ant_power_save_state(btcoexist,
 					      BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
-		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
-	} else if ((bt_link_info->sco_exist) ||
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
+	} else if ((bt_link_info->sco_exist) || (bt_link_info->a2dp_exist) ||
 		   (bt_link_info->hid_only)) {
 		/* SCO/HID-only busy */
 		btc8821a1ant_power_save_state(btcoexist,
 					      BTC_PS_WIFI_NATIVE, 0x0, 0x0);
 		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
+	} else if ((bt_link_info->a2dp_exist) && (bt_link_info->hid_exist)) {
+		/* A2DP+HID busy */
+		btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
+					      0x0, 0x0);
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
+
 		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+	} else if ((bt_link_info->pan_exist) || (wifi_busy)) {
+		btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
+					      0x0, 0x0);
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
+
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
 	} else {
-		btc8821a1ant_power_save_state(btcoexist, BTC_PS_LPS_ON,
-					      0x50, 0x4);
-		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 30);
-		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+		btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
+					      0x0, 0x0);
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
 	}
 }
 
@@ -1629,11 +1648,35 @@ void btc8821a1ant_action_wifi_not_connected(struct btc_coexist *btcoexist)
 
 static void btc8821a1ant_act_wifi_not_conn_scan(struct btc_coexist *btcoexist)
 {
-	btc8821a1ant_power_save_state(btcoexist,
-				      BTC_PS_WIFI_NATIVE, 0x0, 0x0);
+	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
+
+	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
 
-	btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
-	btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+	/* tdma and coex table */
+	if (coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_ACL_BUSY) {
+		if (bt_link_info->a2dp_exist) {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 1);
+		} else if (bt_link_info->a2dp_exist &&
+			   bt_link_info->pan_exist) {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 4);
+		} else {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 4);
+		}
+	} else if ((coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_SCO_BUSY) ||
+		   (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY ==
+		    coex_dm->bt_status)) {
+		btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
+				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
+	} else {
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
+	}
 }
 
 static
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
index 2dec38ab7746..1bd1ebe3364e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
@@ -161,6 +161,7 @@ struct coex_sta_8821a_1ant {
 	u8	bt_info_c2h[BT_INFO_SRC_8821A_1ANT_MAX][10];
 	u32	bt_info_c2h_cnt[BT_INFO_SRC_8821A_1ANT_MAX];
 	bool	c2h_bt_inquiry_page;
+	bool	wifi_is_high_pri_task;
 	u8	bt_retry_cnt;
 	u8	bt_info_ext;
 };
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 12/14] rtlwifi: btcoex: 21a 1ant: monitor bt profiling when scan
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (10 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 11/14] rtlwifi: btcoex: 21a 1ant: consider more cases when bt inquiry Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 13/14] rtlwifi: btcoex: 21a 1ant: do not switch antenna when wifi is under 5G channel Larry Finger
  2017-04-10 16:23 ` [PATCH 14/14] rtlwifi: btcoex: 21a 1ant: avoid LPS/IPS mismatch for pnp notify Larry Finger
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

When wifi is scanning and not connected, set the tdma and coex table
properly to control the priority of the packets to make the wifi bt
coexistence operate smoothly

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 6b08051614eb..eab04c2bdd3d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1481,9 +1481,34 @@ static void btc8821a1ant_action_hid_a2dp(struct btc_coexist *btcoexist)
 static
 void btc8821a1ant_action_wifi_multi_port(struct btc_coexist *btcoexist)
 {
+	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
+
 	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-	btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
-	btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
+	/* tdma and coex table */
+	if (coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_ACL_BUSY) {
+		if (bt_link_info->a2dp_exist) {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 1);
+		} else if (bt_link_info->a2dp_exist &&
+			   bt_link_info->pan_exist) {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 4);
+		} else {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 4);
+		}
+	} else if ((coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_SCO_BUSY) ||
+		   (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY ==
+		    coex_dm->bt_status)) {
+		btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
+				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
+	} else {
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
+	}
 }
 
 static
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 13/14] rtlwifi: btcoex: 21a 1ant: do not switch antenna when wifi is under 5G channel
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (11 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 12/14] rtlwifi: btcoex: 21a 1ant: monitor bt profiling when scan Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  2017-04-10 16:23 ` [PATCH 14/14] rtlwifi: btcoex: 21a 1ant: avoid LPS/IPS mismatch for pnp notify Larry Finger
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

When wifi is on a 5G channel, the 5G signal will not interfere bt 2.4G
signal, and they can transmit simultaneously, hence there is no need to
switch antenna between wifi and bt.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 64 +++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index eab04c2bdd3d..0509ffab9e6f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -44,6 +44,8 @@ static struct coex_dm_8821a_1ant glcoex_dm_8821a_1ant;
 static struct coex_dm_8821a_1ant *coex_dm = &glcoex_dm_8821a_1ant;
 static struct coex_sta_8821a_1ant glcoex_sta_8821a_1ant;
 static struct coex_sta_8821a_1ant *coex_sta = &glcoex_sta_8821a_1ant;
+static void btc8821a1ant_act_bt_sco_hid_only_busy(struct btc_coexist *btcoexist,
+						  u8 wifi_status);
 
 static const char *const glbt_info_src_8821a_1ant[] = {
 	  "BT Info[wifi fw]",
@@ -1588,7 +1590,8 @@ static void btc8821a1ant_action_bt_inquiry(struct btc_coexist *btcoexist)
 }
 
 static void btc8821a1ant_act_bt_sco_hid_only_busy(struct btc_coexist *btcoexist,
-						  u8 wifi_status) {
+						  u8 wifi_status)
+{
 	/* tdma and coex table */
 	btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
 
@@ -2412,9 +2415,17 @@ void ex_btc8821a1ant_display_coex_info(struct btc_coexist *btcoexist)
 void ex_btc8821a1ant_ips_notify(struct btc_coexist *btcoexist, u8 type)
 {
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
+	bool wifi_under_5g = false;
 
 	if (btcoexist->manual_control || btcoexist->stop_coex_dm)
 		return;
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
+	if (wifi_under_5g) {
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
+		btc8821a1ant_coex_under_5g(btcoexist);
+		return;
+	}
 
 	if (BTC_IPS_ENTER == type) {
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
@@ -2458,12 +2469,20 @@ void ex_btc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
 	bool wifi_connected = false, bt_hs_on = false;
 	bool bt_ctrl_agg_buf_size = false;
+	bool wifi_under_5g = false;
 	u32 wifi_link_status = 0;
 	u32 num_of_wifi_link = 0;
 	u8 agg_buf_size = 5;
 
 	if (btcoexist->manual_control || btcoexist->stop_coex_dm)
 		return;
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
+	if (wifi_under_5g) {
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
+		btc8821a1ant_coex_under_5g(btcoexist);
+		return;
+	}
 
 	if (coex_sta->bt_disabled)
 		return;
@@ -2523,11 +2542,19 @@ void ex_btc8821a1ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
 	u32 wifi_link_status = 0;
 	u32 num_of_wifi_link = 0;
 	bool bt_ctrl_agg_buf_size = false;
+	bool wifi_under_5g = false;
 	u8 agg_buf_size = 5;
 
 	if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
 	    coex_sta->bt_disabled)
 		return;
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
+	if (wifi_under_5g) {
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
+		btc8821a1ant_coex_under_5g(btcoexist);
+		return;
+	}
 
 	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
 			   &wifi_link_status);
@@ -2575,10 +2602,18 @@ void ex_btc8821a1ant_media_status_notify(struct btc_coexist *btcoexist,
 	u8 h2c_parameter[3] = {0};
 	u32 wifi_bw;
 	u8 wifi_central_chnl;
+	bool wifi_under_5g = false;
 
 	if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
 	    coex_sta->bt_disabled)
 		return;
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
+	if (wifi_under_5g) {
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
+		btc8821a1ant_coex_under_5g(btcoexist);
+		return;
+	}
 
 	if (BTC_MEDIA_CONNECT == type) {
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
@@ -2622,6 +2657,7 @@ void ex_btc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist,
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
 	bool bt_hs_on = false;
 	bool bt_ctrl_agg_buf_size = false;
+	bool wifi_under_5g = false;
 	u32 wifi_link_status = 0;
 	u32 num_of_wifi_link = 0;
 	u8 agg_buf_size = 5;
@@ -2630,6 +2666,14 @@ void ex_btc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist,
 	    coex_sta->bt_disabled)
 		return;
 
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
+	if (wifi_under_5g) {
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
+		btc8821a1ant_coex_under_5g(btcoexist);
+		return;
+	}
+
 	coex_sta->special_pkt_period_cnt = 0;
 
 	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
@@ -2818,9 +2862,18 @@ void ex_btc8821a1ant_bt_info_notify(struct btc_coexist *btcoexist,
 void ex_btc8821a1ant_halt_notify(struct btc_coexist *btcoexist)
 {
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
+	bool wifi_under_5g = false;
 
 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 		 "[BTCoex], Halt notify\n");
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
+	if (wifi_under_5g) {
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
+		btc8821a1ant_coex_under_5g(btcoexist);
+		return;
+	}
+
 
 	btcoexist->stop_coex_dm = true;
 
@@ -2836,6 +2889,15 @@ void ex_btc8821a1ant_halt_notify(struct btc_coexist *btcoexist)
 void ex_btc8821a1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
 {
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
+	bool wifi_under_5g = false;
+
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
+	if (wifi_under_5g) {
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
+		btc8821a1ant_coex_under_5g(btcoexist);
+		return;
+	}
 
 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 		 "[BTCoex], Pnp notify\n");
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 14/14] rtlwifi: btcoex: 21a 1ant: avoid LPS/IPS mismatch for pnp notify
  2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
                   ` (12 preceding siblings ...)
  2017-04-10 16:23 ` [PATCH 13/14] rtlwifi: btcoex: 21a 1ant: do not switch antenna when wifi is under 5G channel Larry Finger
@ 2017-04-10 16:23 ` Larry Finger
  13 siblings, 0 replies; 16+ messages in thread
From: Larry Finger @ 2017-04-10 16:23 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

When driver is going to sleep, it does not leave LPS/IPS, thus the
BTCoex may have mismatch when driver wakes up. To avoid that, BTCoex
needs to clear the IPS/LPS state when it receives a pnp notify, then
it can properly set up the hw when driver wakes up.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c  | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 0509ffab9e6f..5e9f3b0f7a25 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2905,11 +2905,18 @@ void ex_btc8821a1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
 	if (BTC_WIFI_PNP_SLEEP == pnp_state) {
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], Pnp notify to SLEEP\n");
+		/* BT should clear UnderIPS/UnderLPS state to avoid mismatch
+		 * state after wakeup.
+		 */
+		coex_sta->under_ips = false;
+		coex_sta->under_lps = false;
 		btcoexist->stop_coex_dm = true;
-		btc8821a1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
 		btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
 					      0x0, 0x0);
-		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 9);
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
+		btc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, false,
+					  true);
 	} else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) {
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], Pnp notify to WAKE UP\n");
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [01/14] rtlwifi: btcoex: 21a 1ant: fw settings for softap mode
  2017-04-10 16:22 ` [PATCH 01/14] rtlwifi: btcoex: 21a 1ant: fw settings for softap mode Larry Finger
@ 2017-04-13 14:11   ` Kalle Valo
  0 siblings, 0 replies; 16+ messages in thread
From: Kalle Valo @ 2017-04-13 14:11 UTC (permalink / raw)
  To: Larry Finger
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

Larry Finger <Larry.Finger@lwfinger.net> wrote:
> From: Yan-Hsuan Chuang <yhchuang@realtek.com>
> 
> For ap mode, adjust fw settings to operate properly.
> 
> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> Cc: Pkshih <pkshih@realtek.com>
> Cc: Birming Chiu <birming@realtek.com>
> Cc: Shaofu <shaofu@realtek.com>
> Cc: Steven Ting <steventing@realtek.com>

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

1bdd83392f7f rtlwifi: btcoex: 21a 1ant: fw settings for softap mode
19baccc4561f rtlwifi: btcoex: 21a 1ant: add function to check wifi status
3121b4ddd181 rtlwifi: btcoex: 21a 1ant: coex table setting for new fw
f0c40cf09dd1 rtlwifi: btcoex: 21a 1ant: mask profile bit for connect-ilde
e605103c443e rtlwifi: btcoex: 21a 1ant: remove setting for 2 antennas
4f78287e5ed9 rtlwifi: btcoex: 21a 1ant: set antenna control path for PTA
06a75324d543 rtlwifi: btcoex: 21a 1ant: add multi port action for miracast and P2P
edf8fa7b66f0 rtlwifi: btcoex: 21a 1ant: action when associating/authenticating
bcdffd050c80 rtlwifi: btcoex: 21a 1ant: If wifi only, do not initiate coex mechanism
19afb92222af rtlwifi: btcoex: 21a 1ant: move bt_disabled to global struct
ee828085176e rtlwifi: btcoex: 21a 1ant: consider more cases when bt inquiry
cb52b1185947 rtlwifi: btcoex: 21a 1ant: monitor bt profiling when scan
da0fd9ccb432 rtlwifi: btcoex: 21a 1ant: do not switch antenna when wifi is under 5G channel
4da5e7ea1352 rtlwifi: btcoex: 21a 1ant: avoid LPS/IPS mismatch for pnp notify

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

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-04-13 14:11 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-10 16:22 [PATCH 00/14] rtlwifi: btcoex: Fixes for rtl8821ae 1ant code Larry Finger
2017-04-10 16:22 ` [PATCH 01/14] rtlwifi: btcoex: 21a 1ant: fw settings for softap mode Larry Finger
2017-04-13 14:11   ` [01/14] " Kalle Valo
2017-04-10 16:22 ` [PATCH 02/14] rtlwifi: btcoex: 21a 1ant: add function to check wifi status Larry Finger
2017-04-10 16:22 ` [PATCH 03/14] rtlwifi: btcoex: 21a 1ant: coex table setting for new fw Larry Finger
2017-04-10 16:23 ` [PATCH 04/14] rtlwifi: btcoex: 21a 1ant: mask profile bit for connect-ilde Larry Finger
2017-04-10 16:23 ` [PATCH 05/14] rtlwifi: btcoex: 21a 1ant: remove setting for 2 antennas Larry Finger
2017-04-10 16:23 ` [PATCH 06/14] rtlwifi: btcoex: 21a 1ant: set antenna control path for PTA Larry Finger
2017-04-10 16:23 ` [PATCH 07/14] rtlwifi: btcoex: 21a 1ant: add multi port action for miracast and P2P Larry Finger
2017-04-10 16:23 ` [PATCH 08/14] rtlwifi: btcoex: 21a 1ant: action when associating/authenticating Larry Finger
2017-04-10 16:23 ` [PATCH 09/14] rtlwifi: btcoex: 21a 1ant: If wifi only, do not initiate coex mechanism Larry Finger
2017-04-10 16:23 ` [PATCH 10/14] rtlwifi: btcoex: 21a 1ant: move bt_disabled to global struct Larry Finger
2017-04-10 16:23 ` [PATCH 11/14] rtlwifi: btcoex: 21a 1ant: consider more cases when bt inquiry Larry Finger
2017-04-10 16:23 ` [PATCH 12/14] rtlwifi: btcoex: 21a 1ant: monitor bt profiling when scan Larry Finger
2017-04-10 16:23 ` [PATCH 13/14] rtlwifi: btcoex: 21a 1ant: do not switch antenna when wifi is under 5G channel Larry Finger
2017-04-10 16:23 ` [PATCH 14/14] rtlwifi: btcoex: 21a 1ant: avoid LPS/IPS mismatch for pnp notify Larry Finger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.