rtlwifi: btcoex: 23b 2ant: detect if bt is slave, and modify tdma

if the bt is slave, it may receive packet at any time, so we
need to mark them as high priority packets to avoid packet loss.

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>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
Yan-Hsuan Chuang 2017-04-03 13:41:34 -05:00 committed by Kalle Valo
parent 155305f5b0
commit 61d802619b
2 changed files with 62 additions and 30 deletions

View File

@ -266,6 +266,7 @@ void btc8723b2ant_limited_rx(struct btc_coexist *btcoexist, bool force_exec,
static void btc8723b2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) static void btc8723b2ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
{ {
struct rtl_priv *rtlpriv = btcoexist->adapter; struct rtl_priv *rtlpriv = btcoexist->adapter;
struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
u32 reg_hp_txrx, reg_lp_txrx, u32tmp; u32 reg_hp_txrx, reg_lp_txrx, u32tmp;
u32 reg_hp_tx = 0, reg_hp_rx = 0; u32 reg_hp_tx = 0, reg_hp_rx = 0;
u32 reg_lp_tx = 0, reg_lp_rx = 0; u32 reg_lp_tx = 0, reg_lp_rx = 0;
@ -286,6 +287,17 @@ static void btc8723b2ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
coex_sta->low_priority_tx = reg_lp_tx; coex_sta->low_priority_tx = reg_lp_tx;
coex_sta->low_priority_rx = reg_lp_rx; coex_sta->low_priority_rx = reg_lp_rx;
if ((coex_sta->low_priority_tx > 1050) &&
(!coex_sta->c2h_bt_inquiry_page))
coex_sta->pop_event_cnt++;
if ((coex_sta->low_priority_rx >= 950) &&
(coex_sta->low_priority_rx >= coex_sta->low_priority_tx) &&
(!coex_sta->under_ips))
bt_link_info->slave_role = true;
else
bt_link_info->slave_role = false;
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], High Priority Tx/Rx(reg 0x%x)=0x%x(%d)/0x%x(%d)\n", "[BTCoex], High Priority Tx/Rx(reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx); reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx);
@ -1084,6 +1096,8 @@ static void btc8723b2ant_ps_tdma(struct btc_coexist *btcoexist, bool force_exec,
bool turn_on, u8 type) bool turn_on, u8 type)
{ {
struct rtl_priv *rtlpriv = btcoexist->adapter; struct rtl_priv *rtlpriv = btcoexist->adapter;
struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
u8 tdma_byte4_modify = 0x0;
RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
"[BTCoex], %s turn %s PS TDMA, type=%d\n", "[BTCoex], %s turn %s PS TDMA, type=%d\n",
@ -1104,75 +1118,92 @@ static void btc8723b2ant_ps_tdma(struct btc_coexist *btcoexist, bool force_exec,
(coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma))
return; return;
} }
if ((bt_link_info->slave_role) && (bt_link_info->a2dp_exist))
/* 0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) */
tdma_byte4_modify = 0x1;
if (turn_on) { if (turn_on) {
switch (type) { switch (type) {
case 1: case 1:
default: default:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a, btc8723b2ant_set_fw_ps_tdma(
0x1a, 0xe1, 0x90); btcoexist, 0xe3, 0x3c,
0x03, 0xf1, 0x90 | tdma_byte4_modify);
break; break;
case 2: case 2:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12, btc8723b2ant_set_fw_ps_tdma(
0x12, 0xe1, 0x90); btcoexist, 0xe3, 0x2d,
0x03, 0xf1, 0x90 | tdma_byte4_modify);
break; break;
case 3: case 3:
/* This call breaks BT when wireless is active - btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c,
* comment it out for now until a better fix is found: 0x3, 0xf1,
* btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c, 0x90 | tdma_byte4_modify);
* 0x3, 0xf1, 0x90);
*/
break; break;
case 4: case 4:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x10, btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x10,
0x03, 0xf1, 0x90); 0x03, 0xf1,
0x90 | tdma_byte4_modify);
break; break;
case 5: case 5:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a, btc8723b2ant_set_fw_ps_tdma(
0x1a, 0x60, 0x90); btcoexist, 0xe3, 0x3c,
0x3, 0x70, 0x90 | tdma_byte4_modify);
break; break;
case 6: case 6:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12, btc8723b2ant_set_fw_ps_tdma(
0x12, 0x60, 0x90); btcoexist, 0xe3, 0x2d,
0x3, 0x70, 0x90 | tdma_byte4_modify);
break; break;
case 7: case 7:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c, btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c,
0x3, 0x70, 0x90); 0x3, 0x70,
0x90 | tdma_byte4_modify);
break; break;
case 8: case 8:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x10, btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x10,
0x3, 0x70, 0x90); 0x3, 0x70,
0x90 | tdma_byte4_modify);
break; break;
case 9: case 9:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a, btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
0x1a, 0xe1, 0x90); 0x1a, 0xe1, 0x90);
break; break;
case 10: case 10:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12, btc8723b2ant_set_fw_ps_tdma(
0x12, 0xe1, 0x90); btcoexist, 0xe3, 0x2d,
0x03, 0xf1, 0x90 | tdma_byte4_modify);
break; break;
case 11: case 11:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa, btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c,
0xa, 0xe1, 0x90); 0x3, 0xf1,
0x90 | tdma_byte4_modify);
break; break;
case 12: case 12:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x5, btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x10,
0x5, 0xe1, 0x90); 0x3, 0xf1,
0x90 | tdma_byte4_modify);
break; break;
case 13: case 13:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a, btc8723b2ant_set_fw_ps_tdma(
0x1a, 0x60, 0x90); btcoexist, 0xe3, 0x3c,
0x3, 0x70, 0x90 | tdma_byte4_modify);
break; break;
case 14: case 14:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12, btc8723b2ant_set_fw_ps_tdma(
0x12, 0x60, 0x90); btcoexist, 0xe3, 0x2d,
0x3, 0x70, 0x90 | tdma_byte4_modify);
break; break;
case 15: case 15:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa, btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c,
0xa, 0x60, 0x90); 0x3, 0x70,
0x90 | tdma_byte4_modify);
break; break;
case 16: case 16:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x5, btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x10,
0x5, 0x60, 0x90); 0x3, 0x70,
0x90 | tdma_byte4_modify);
break; break;
case 17: case 17:
btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x2f, btc8723b2ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x2f,

View File

@ -459,6 +459,7 @@ struct btc_bt_link_info {
bool hid_only; bool hid_only;
bool pan_exist; bool pan_exist;
bool pan_only; bool pan_only;
bool slave_role;
}; };
enum btc_antenna_pos { enum btc_antenna_pos {