Commit 3506bc28 authored by Yan-Hsuan Chuang's avatar Yan-Hsuan Chuang Committed by Kalle Valo

rtlwifi: btcoex: 21a 2ant: action for wifi is idle/linking/common

Depending on the state of wifi, we need to set different tdma and coex
table parameters to make wfi and bt coexist smoothly. Otherwise the
bt may have low sound quality or mouse lag, which mean bad user
experience. The same problem may occur on wifi also, if could disconnect
or lose some important packets.
Signed-off-by: default avatarYan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: default avatarLarry 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>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 4b764919
...@@ -1517,76 +1517,111 @@ static void btc8821a2ant_action_bt_inquiry(struct btc_coexist *btcoexist) ...@@ -1517,76 +1517,111 @@ static void btc8821a2ant_action_bt_inquiry(struct btc_coexist *btcoexist)
btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
} }
static bool btc8821a2ant_is_common_action(struct btc_coexist *btcoexist) void btc8821a2ant_action_wifi_link_process(struct btc_coexist *btcoexist)
{ {
struct rtl_priv *rtlpriv = btcoexist->adapter; struct rtl_priv *rtlpriv = btcoexist->adapter;
bool common = false, wifi_connected = false, wifi_busy = false; u8 u8tmpa, u8tmpb;
bool low_pwr_disable = false;
btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 15);
&wifi_connected); btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, btc8821a2ant_sw_mechanism1(btcoexist, false, false, false, false);
0x5afa5afa, 0xffff, 0x3); btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
if (!wifi_connected && u8tmpa = btcoexist->btc_read_1byte(btcoexist, 0x765);
BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status) { u8tmpb = btcoexist->btc_read_1byte(btcoexist, 0x76e);
low_pwr_disable = false;
btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
&low_pwr_disable);
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], Wifi IPS + BT IPS!!\n"); "[BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u8tmpa, u8tmpb);
}
btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); static bool btc8821a2ant_action_wifi_idle_process(struct btc_coexist *btcoexist)
btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); {
btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); struct rtl_priv *rtlpriv = btcoexist->adapter;
u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
u8 ap_num = 0;
wifi_rssi_state =
btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
wifi_rssi_state1 = btc8821a2ant_wifi_rssi_state(btcoexist, 1, 2,
BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES - 20, 0);
bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist,
2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);
btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num);
/* define the 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");
btc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, true, 0x6);
btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
/* sw all off */
btc8821a2ant_sw_mechanism1(btcoexist, false, false, false, btc8821a2ant_sw_mechanism1(btcoexist, false, false, false,
false); false);
btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, btc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
0x18); 0x18);
common = true; btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
} else if (wifi_connected && btc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
(BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status)) { 0x0, 0x0);
low_pwr_disable = false; btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
&low_pwr_disable);
if (wifi_busy) { return true;
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, } else if (coex_sta->pan_exist) {
"[BTCoex], Wifi Busy + BT IPS!!\n");
btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
false, 1);
} else {
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], Wifi LPS + BT IPS!!\n"); "[BTCoex], Wifi idle process for BT PAN exist!!\n");
btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
false, 1);
}
btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); btc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, true, 0x6);
btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
/* sw all off */
btc8821a2ant_sw_mechanism1(btcoexist, false, false, false, btc8821a2ant_sw_mechanism1(btcoexist, false, false, false,
false); false);
btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, btc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
0x18); 0x18);
common = true; btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
} else if (!wifi_connected && btc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
(BT_8821A_2ANT_BT_STATUS_CON_IDLE == coex_dm->bt_status)) { 0x0, 0x0);
low_pwr_disable = true; btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
return true;
}
btc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, true, 0x18);
return false;
}
static bool btc8821a2ant_is_common_action(struct btc_coexist *btcoexist)
{
struct rtl_priv *rtlpriv = btcoexist->adapter;
bool common = false, wifi_connected = false, wifi_busy = false;
bool low_pwr_disable = false;
bool bt_hs_on = false;
btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
&wifi_connected);
btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
if (!wifi_connected) {
low_pwr_disable = false;
btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
&low_pwr_disable); &low_pwr_disable);
btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
0x8); 0x8);
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], Wifi IPS + BT LPS!!\n"); "[BTCoex], Wifi non-connected idle!!\n");
btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff,
0x0);
btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
btc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
0x0, 0x0);
btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0); btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
...@@ -1595,53 +1630,69 @@ static bool btc8821a2ant_is_common_action(struct btc_coexist *btcoexist) ...@@ -1595,53 +1630,69 @@ static bool btc8821a2ant_is_common_action(struct btc_coexist *btcoexist)
false); false);
btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, btc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
0x18); 0x18);
common = true; common = true;
} else if (wifi_connected && } else {
(BT_8821A_2ANT_BT_STATUS_CON_IDLE == coex_dm->bt_status)) { if (BT_8821A_2ANT_BT_STATUS_IDLE ==
low_pwr_disable = true; coex_dm->bt_status) {
low_pwr_disable = false;
btcoexist->btc_set(btcoexist, btcoexist->btc_set(btcoexist,
BTC_SET_ACT_DISABLE_LOW_POWER, &low_pwr_disable); BTC_SET_ACT_DISABLE_LOW_POWER,
&low_pwr_disable);
btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC,
false, false, 0x8);
if (wifi_busy) {
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], Wifi Busy + BT LPS!!\n"); "[BTCoex], Wifi connected + BT non connected-idle!!\n");
btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
false, 1);
} else {
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], Wifi LPS + BT LPS!!\n");
btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
false, 1);
}
btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); 0xfffff, 0x0);
btc8821a2ant_coex_table_with_type(btcoexist,
NORMAL_EXEC, 0);
btc8821a2ant_sw_mechanism1(btcoexist, true, true, true, true); btc8821a2ant_power_save_state(
btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
0x18); btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
0xb);
btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
btc8821a2ant_sw_mechanism1(btcoexist, false, false,
false, false);
btc8821a2ant_sw_mechanism2(btcoexist, false, false,
false, 0x18);
common = true; common = true;
} else if (!wifi_connected && } else if (BT_8821A_2ANT_BT_STATUS_CON_IDLE ==
(coex_dm->bt_status == BT_8821A_2ANT_BT_STATUS_NON_IDLE)) { coex_dm->bt_status) {
low_pwr_disable = false; low_pwr_disable = true;
btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, btcoexist->btc_set(btcoexist,
BTC_SET_ACT_DISABLE_LOW_POWER,
&low_pwr_disable); &low_pwr_disable);
if (bt_hs_on)
return false;
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], Wifi IPS + BT Busy!!\n"); "[BTCoex], Wifi connected + BT connected-idle!!\n");
btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC,
false, false, 0x8);
btc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
0x0, 0x0); 0xfffff, 0x0);
btc8821a2ant_coex_table_with_type(btcoexist,
NORMAL_EXEC, 0);
btc8821a2ant_power_save_state(
btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); 0xb);
btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, 0);
btc8821a2ant_sw_mechanism1(btcoexist, false, false, btc8821a2ant_sw_mechanism1(btcoexist, true, false,
false, false); false, false);
btc8821a2ant_sw_mechanism2(btcoexist, false, false, btc8821a2ant_sw_mechanism2(btcoexist, false, false,
false, 0x18); false, 0x18);
common = true; common = true;
} else { } else {
low_pwr_disable = true; low_pwr_disable = true;
...@@ -1651,17 +1702,16 @@ static bool btc8821a2ant_is_common_action(struct btc_coexist *btcoexist) ...@@ -1651,17 +1702,16 @@ static bool btc8821a2ant_is_common_action(struct btc_coexist *btcoexist)
if (wifi_busy) { if (wifi_busy) {
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], Wifi Busy + BT Busy!!\n"); "[BTCoex], Wifi Connected-Busy + BT Busy!!\n");
common = false; common = false;
} else { } else {
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], Wifi LPS + BT Busy!!\n"); "[BTCoex], Wifi Connected-Idle + BT Busy!!\n");
btc8821a2ant_ps_tdma(btcoexist, common =
NORMAL_EXEC, true, 21); btc8821a2ant_action_wifi_idle_process(
btcoexist);
common = true; }
} }
btc8821a2ant_sw_mechanism1(btcoexist, true, true, true, true);
} }
return common; return common;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment