|
@@ -31,6 +31,7 @@
|
|
|
|
|
|
static struct rtl_btc_ops rtl_btc_operation = {
|
|
|
.btc_init_variables = rtl_btc_init_variables,
|
|
|
+ .btc_deinit_variables = rtl_btc_deinit_variables,
|
|
|
.btc_init_hal_vars = rtl_btc_init_hal_vars,
|
|
|
.btc_power_on_setting = rtl_btc_power_on_setting,
|
|
|
.btc_init_hw_config = rtl_btc_init_hw_config,
|
|
@@ -58,58 +59,116 @@ static struct rtl_btc_ops rtl_btc_operation = {
|
|
|
|
|
|
void rtl_btc_display_bt_coex_info(struct rtl_priv *rtlpriv, struct seq_file *m)
|
|
|
{
|
|
|
- exhalbtc_display_bt_coex_info(&gl_bt_coexist, m);
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist) {
|
|
|
+ seq_puts(m, "btc_coexist context is NULL!\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ exhalbtc_display_bt_coex_info(btcoexist, m);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_record_pwr_mode(struct rtl_priv *rtlpriv, u8 *buf, u8 len)
|
|
|
{
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
u8 safe_len;
|
|
|
|
|
|
- safe_len = sizeof(gl_bt_coexist.pwr_mode_val);
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ safe_len = sizeof(btcoexist->pwr_mode_val);
|
|
|
|
|
|
if (safe_len > len)
|
|
|
safe_len = len;
|
|
|
|
|
|
- memcpy(gl_bt_coexist.pwr_mode_val, buf, safe_len);
|
|
|
+ memcpy(btcoexist->pwr_mode_val, buf, safe_len);
|
|
|
}
|
|
|
|
|
|
u8 rtl_btc_get_lps_val(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
- return gl_bt_coexist.bt_info.lps_val;
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ return btcoexist->bt_info.lps_val;
|
|
|
}
|
|
|
|
|
|
u8 rtl_btc_get_rpwm_val(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
- return gl_bt_coexist.bt_info.rpwm_val;
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ return btcoexist->bt_info.rpwm_val;
|
|
|
}
|
|
|
|
|
|
bool rtl_btc_is_bt_ctrl_lps(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
- return gl_bt_coexist.bt_info.bt_ctrl_lps;
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ return btcoexist->bt_info.bt_ctrl_lps;
|
|
|
}
|
|
|
|
|
|
bool rtl_btc_is_bt_lps_on(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
- return gl_bt_coexist.bt_info.bt_lps_on;
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ return btcoexist->bt_info.bt_lps_on;
|
|
|
}
|
|
|
|
|
|
void rtl_btc_get_ampdu_cfg(struct rtl_priv *rtlpriv, u8 *reject_agg,
|
|
|
u8 *ctrl_agg_size, u8 *agg_size)
|
|
|
{
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist) {
|
|
|
+ *reject_agg = false;
|
|
|
+ *ctrl_agg_size = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (reject_agg)
|
|
|
- *reject_agg = gl_bt_coexist.bt_info.reject_agg_pkt;
|
|
|
+ *reject_agg = btcoexist->bt_info.reject_agg_pkt;
|
|
|
if (ctrl_agg_size)
|
|
|
- *ctrl_agg_size = gl_bt_coexist.bt_info.bt_ctrl_agg_buf_size;
|
|
|
+ *ctrl_agg_size = btcoexist->bt_info.bt_ctrl_agg_buf_size;
|
|
|
if (agg_size)
|
|
|
- *agg_size = gl_bt_coexist.bt_info.agg_buf_size;
|
|
|
+ *agg_size = btcoexist->bt_info.agg_buf_size;
|
|
|
+}
|
|
|
+
|
|
|
+static void rtl_btc_alloc_variable(struct rtl_priv *rtlpriv, bool wifi_only)
|
|
|
+{
|
|
|
+ rtlpriv->btcoexist.btc_context =
|
|
|
+ kzalloc(sizeof(struct btc_coexist), GFP_KERNEL);
|
|
|
+}
|
|
|
+
|
|
|
+static void rtl_btc_free_variable(struct rtl_priv *rtlpriv)
|
|
|
+{
|
|
|
+ kfree(rtlpriv->btcoexist.btc_context);
|
|
|
+ rtlpriv->btcoexist.btc_context = NULL;
|
|
|
}
|
|
|
|
|
|
void rtl_btc_init_variables(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
- exhalbtc_initlize_variables();
|
|
|
+ rtl_btc_alloc_variable(rtlpriv, false);
|
|
|
+
|
|
|
+ exhalbtc_initlize_variables(rtlpriv);
|
|
|
exhalbtc_bind_bt_coex_withadapter(rtlpriv);
|
|
|
}
|
|
|
|
|
|
+void rtl_btc_deinit_variables(struct rtl_priv *rtlpriv)
|
|
|
+{
|
|
|
+ rtl_btc_free_variable(rtlpriv);
|
|
|
+}
|
|
|
+
|
|
|
void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
/* move ant_num, bt_type and single_ant_path to
|
|
@@ -119,71 +178,123 @@ void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
|
|
|
|
|
|
void rtl_btc_power_on_setting(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
- exhalbtc_power_on_setting(&gl_bt_coexist);
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ exhalbtc_power_on_setting(btcoexist);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
u8 bt_exist;
|
|
|
|
|
|
bt_exist = rtl_get_hwpg_bt_exist(rtlpriv);
|
|
|
RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
|
|
|
"%s, bt_exist is %d\n", __func__, bt_exist);
|
|
|
|
|
|
- exhalbtc_init_hw_config(&gl_bt_coexist, !bt_exist);
|
|
|
- exhalbtc_init_coex_dm(&gl_bt_coexist);
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ exhalbtc_init_hw_config(btcoexist, !bt_exist);
|
|
|
+ exhalbtc_init_coex_dm(btcoexist);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type)
|
|
|
{
|
|
|
- exhalbtc_ips_notify(&gl_bt_coexist, type);
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ exhalbtc_ips_notify(btcoexist, type);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type)
|
|
|
{
|
|
|
- exhalbtc_lps_notify(&gl_bt_coexist, type);
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ exhalbtc_lps_notify(btcoexist, type);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype)
|
|
|
{
|
|
|
- exhalbtc_scan_notify(&gl_bt_coexist, scantype);
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ exhalbtc_scan_notify(btcoexist, scantype);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action)
|
|
|
{
|
|
|
- exhalbtc_connect_notify(&gl_bt_coexist, action);
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ exhalbtc_connect_notify(btcoexist, action);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv,
|
|
|
enum rt_media_status mstatus)
|
|
|
{
|
|
|
- exhalbtc_mediastatus_notify(&gl_bt_coexist, mstatus);
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ exhalbtc_mediastatus_notify(btcoexist, mstatus);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_periodical(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
/*rtl_bt_dm_monitor();*/
|
|
|
- exhalbtc_periodical(&gl_bt_coexist);
|
|
|
+ exhalbtc_periodical(btcoexist);
|
|
|
}
|
|
|
|
|
|
-void rtl_btc_halt_notify(void)
|
|
|
+void rtl_btc_halt_notify(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
- struct btc_coexist *btcoexist = &gl_bt_coexist;
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
|
|
|
exhalbtc_halt_notify(btcoexist);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
|
|
|
{
|
|
|
- exhalbtc_bt_info_notify(&gl_bt_coexist, tmp_buf, length);
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ exhalbtc_bt_info_notify(btcoexist, tmp_buf, length);
|
|
|
}
|
|
|
|
|
|
void rtl_btc_btmpinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
|
|
|
{
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
u8 extid, seq, len;
|
|
|
u16 bt_real_fw_ver;
|
|
|
u8 bt_fw_ver;
|
|
|
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
if ((length < 4) || (!tmp_buf))
|
|
|
return;
|
|
|
|
|
@@ -200,14 +311,19 @@ void rtl_btc_btmpinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
|
|
|
bt_real_fw_ver = tmp_buf[3] | (tmp_buf[4] << 8);
|
|
|
bt_fw_ver = tmp_buf[5];
|
|
|
|
|
|
- gl_bt_coexist.bt_info.bt_real_fw_ver = bt_real_fw_ver;
|
|
|
- gl_bt_coexist.bt_info.bt_fw_ver = bt_fw_ver;
|
|
|
+ btcoexist->bt_info.bt_real_fw_ver = bt_real_fw_ver;
|
|
|
+ btcoexist->bt_info.bt_fw_ver = bt_fw_ver;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
- return gl_bt_coexist.bt_info.limited_dig;
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ return btcoexist->bt_info.limited_dig;
|
|
|
}
|
|
|
|
|
|
bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv)
|
|
@@ -239,8 +355,13 @@ bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv)
|
|
|
|
|
|
bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv)
|
|
|
{
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return true;
|
|
|
+
|
|
|
/* It seems 'bt_disabled' is never be initialized or set. */
|
|
|
- if (gl_bt_coexist.bt_info.bt_disabled)
|
|
|
+ if (btcoexist->bt_info.bt_disabled)
|
|
|
return true;
|
|
|
else
|
|
|
return false;
|
|
@@ -248,7 +369,12 @@ bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv)
|
|
|
|
|
|
void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type)
|
|
|
{
|
|
|
- return exhalbtc_special_packet_notify(&gl_bt_coexist, pkt_type);
|
|
|
+ struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
|
|
|
+
|
|
|
+ if (!btcoexist)
|
|
|
+ return;
|
|
|
+
|
|
|
+ return exhalbtc_special_packet_notify(btcoexist, pkt_type);
|
|
|
}
|
|
|
|
|
|
struct rtl_btc_ops *rtl_btc_get_ops_pointer(void)
|