1 /******************************************************************************
3 * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 ******************************************************************************/
26 #include "halbt_precomp.h"
28 /***********************************************
30 ***********************************************/
32 struct btc_coexist gl_bt_coexist;
34 u32 btc_dbg_type[BTC_MSG_MAX];
36 /***************************************************
37 * Debug related function
38 ***************************************************/
39 static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist)
41 if (!btcoexist->binded || NULL == btcoexist->adapter)
47 static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv)
49 if (rtlpriv->link_info.busytraffic)
55 static void halbtc_dbg_init(void)
59 for (i = 0; i < BTC_MSG_MAX; i++)
62 btc_dbg_type[BTC_MSG_INTERFACE] =
67 btc_dbg_type[BTC_MSG_ALGORITHM] =
68 /* ALGO_BT_RSSI_STATE | */
69 /* ALGO_WIFI_RSSI_STATE | */
70 /* ALGO_BT_MONITOR | */
73 /* ALGO_TRACE_FW_DETAIL | */
74 /* ALGO_TRACE_FW_EXEC | */
76 /* ALGO_TRACE_SW_DETAIL | */
77 /* ALGO_TRACE_SW_EXEC | */
81 static bool halbtc_is_bt40(struct rtl_priv *adapter)
83 struct rtl_priv *rtlpriv = adapter;
84 struct rtl_phy *rtlphy = &(rtlpriv->phy);
86 enum ht_channel_width bw = rtlphy->current_chan_bw;
88 if (bw == HT_CHANNEL_WIDTH_20)
90 else if (bw == HT_CHANNEL_WIDTH_20_40)
96 static bool halbtc_legacy(struct rtl_priv *adapter)
98 struct rtl_priv *rtlpriv = adapter;
99 struct rtl_mac *mac = rtl_mac(rtlpriv);
101 bool is_legacy = false;
103 if ((mac->mode == WIRELESS_MODE_B) || (mac->mode == WIRELESS_MODE_G))
109 bool halbtc_is_wifi_uplink(struct rtl_priv *adapter)
111 struct rtl_priv *rtlpriv = adapter;
113 if (rtlpriv->link_info.tx_busy_traffic)
119 static u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist)
121 struct rtl_priv *rtlpriv =
122 (struct rtl_priv *)btcoexist->adapter;
123 u32 wifi_bw = BTC_WIFI_BW_HT20;
125 if (halbtc_is_bt40(rtlpriv)) {
126 wifi_bw = BTC_WIFI_BW_HT40;
128 if (halbtc_legacy(rtlpriv))
129 wifi_bw = BTC_WIFI_BW_LEGACY;
131 wifi_bw = BTC_WIFI_BW_HT20;
136 static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist)
138 struct rtl_priv *rtlpriv = btcoexist->adapter;
139 struct rtl_phy *rtlphy = &(rtlpriv->phy);
142 if (rtlphy->current_channel != 0)
143 chnl = rtlphy->current_channel;
144 btc_alg_dbg(ALGO_TRACE,
145 "static halbtc_get_wifi_central_chnl:%d\n", chnl);
149 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
151 struct rtl_priv *rtlpriv;
152 struct rtl_ps_ctl *ppsc;
153 bool ap_enable = false;
155 rtlpriv = btcoexist->adapter;
156 ppsc = rtl_psc(rtlpriv);
158 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
162 pr_info("halbtc_leave_lps()<--dont leave lps under AP mode\n");
166 btcoexist->bt_info.bt_ctrl_lps = true;
167 btcoexist->bt_info.bt_lps_on = false;
170 static void halbtc_enter_lps(struct btc_coexist *btcoexist)
172 struct rtl_priv *rtlpriv;
173 struct rtl_ps_ctl *ppsc;
174 bool ap_enable = false;
176 rtlpriv = btcoexist->adapter;
177 ppsc = rtl_psc(rtlpriv);
179 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
183 pr_info("halbtc_enter_lps()<--dont enter lps under AP mode\n");
187 btcoexist->bt_info.bt_ctrl_lps = true;
188 btcoexist->bt_info.bt_lps_on = false;
191 static void halbtc_normal_lps(struct btc_coexist *btcoexist)
193 if (btcoexist->bt_info.bt_ctrl_lps) {
194 btcoexist->bt_info.bt_lps_on = false;
195 btcoexist->bt_info.bt_ctrl_lps = false;
199 static void halbtc_leave_low_power(void)
203 static void halbtc_nomal_low_power(void)
207 static void halbtc_disable_low_power(void)
211 static void halbtc_aggregation_check(void)
215 static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist)
220 static s32 halbtc_get_wifi_rssi(struct rtl_priv *adapter)
222 struct rtl_priv *rtlpriv = adapter;
223 s32 undec_sm_pwdb = 0;
225 if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
226 undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
227 else /* associated entry pwdb */
228 undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
229 return undec_sm_pwdb;
232 static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf)
234 struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
235 struct rtl_priv *rtlpriv = btcoexist->adapter;
236 struct rtl_phy *rtlphy = &(rtlpriv->phy);
237 struct rtl_mac *mac = rtl_mac(rtlpriv);
238 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
239 bool *bool_tmp = (bool *)out_buf;
240 int *s32_tmp = (int *)out_buf;
241 u32 *u32_tmp = (u32 *)out_buf;
242 u8 *u8_tmp = (u8 *)out_buf;
245 if (!halbtc_is_bt_coexist_available(btcoexist))
249 case BTC_GET_BL_HS_OPERATION:
252 case BTC_GET_BL_HS_CONNECTING:
255 case BTC_GET_BL_WIFI_CONNECTED:
256 if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
260 case BTC_GET_BL_WIFI_BUSY:
261 if (halbtc_is_wifi_busy(rtlpriv))
266 case BTC_GET_BL_WIFI_SCAN:
267 if (mac->act_scanning)
272 case BTC_GET_BL_WIFI_LINK:
273 if (mac->link_state == MAC80211_LINKING)
278 case BTC_GET_BL_WIFI_ROAM: /*TODO*/
279 if (mac->link_state == MAC80211_LINKING)
284 case BTC_GET_BL_WIFI_4_WAY_PROGRESS: /*TODO*/
288 case BTC_GET_BL_WIFI_UNDER_5G:
289 *bool_tmp = false; /*TODO*/
291 case BTC_GET_BL_WIFI_DHCP: /*TODO*/
293 case BTC_GET_BL_WIFI_SOFTAP_IDLE:
296 case BTC_GET_BL_WIFI_SOFTAP_LINKING:
299 case BTC_GET_BL_WIFI_IN_EARLY_SUSPEND:
302 case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
305 case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
306 if (NO_ENCRYPTION == rtlpriv->sec.pairwise_enc_algorithm)
311 case BTC_GET_BL_WIFI_UNDER_B_MODE:
312 *bool_tmp = false; /*TODO*/
314 case BTC_GET_BL_EXT_SWITCH:
317 case BTC_GET_S4_WIFI_RSSI:
318 *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
320 case BTC_GET_S4_HS_RSSI: /*TODO*/
321 *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
323 case BTC_GET_U4_WIFI_BW:
324 *u32_tmp = halbtc_get_wifi_bw(btcoexist);
326 case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
327 if (halbtc_is_wifi_uplink(rtlpriv))
328 *u32_tmp = BTC_WIFI_TRAFFIC_TX;
330 *u32_tmp = BTC_WIFI_TRAFFIC_RX;
332 case BTC_GET_U4_WIFI_FW_VER:
333 *u32_tmp = rtlhal->fw_version;
335 case BTC_GET_U4_BT_PATCH_VER:
336 *u32_tmp = halbtc_get_bt_patch_version(btcoexist);
338 case BTC_GET_U1_WIFI_DOT11_CHNL:
339 *u8_tmp = rtlphy->current_channel;
341 case BTC_GET_U1_WIFI_CENTRAL_CHNL:
342 *u8_tmp = halbtc_get_wifi_central_chnl(btcoexist);
344 case BTC_GET_U1_WIFI_HS_CHNL:
345 *u8_tmp = 1;/*BT_OperateChnl(rtlpriv);*/
347 case BTC_GET_U1_MAC_PHY_MODE:
348 *u8_tmp = BTC_MP_UNKNOWN;
351 /************* 1Ant **************/
352 case BTC_GET_U1_LPS_MODE:
353 *u8_tmp = btcoexist->pwr_mode_val[0];
363 static bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf)
365 struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
366 bool *bool_tmp = (bool *)in_buf;
367 u8 *u8_tmp = (u8 *)in_buf;
368 u32 *u32_tmp = (u32 *)in_buf;
370 if (!halbtc_is_bt_coexist_available(btcoexist))
374 /* set some bool type variables. */
375 case BTC_SET_BL_BT_DISABLE:
376 btcoexist->bt_info.bt_disabled = *bool_tmp;
378 case BTC_SET_BL_BT_TRAFFIC_BUSY:
379 btcoexist->bt_info.bt_busy = *bool_tmp;
381 case BTC_SET_BL_BT_LIMITED_DIG:
382 btcoexist->bt_info.limited_dig = *bool_tmp;
384 case BTC_SET_BL_FORCE_TO_ROAM:
385 btcoexist->bt_info.force_to_roam = *bool_tmp;
387 case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
388 btcoexist->bt_info.reject_agg_pkt = *bool_tmp;
390 case BTC_SET_BL_BT_CTRL_AGG_SIZE:
391 btcoexist->bt_info.bt_ctrl_buf_size = *bool_tmp;
393 case BTC_SET_BL_INC_SCAN_DEV_NUM:
394 btcoexist->bt_info.increase_scan_dev_num = *bool_tmp;
396 /* set some u1Byte type variables. */
397 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
398 btcoexist->bt_info.rssi_adjust_for_agc_table_on = *u8_tmp;
400 case BTC_SET_U1_AGG_BUF_SIZE:
401 btcoexist->bt_info.agg_buf_size = *u8_tmp;
403 /* the following are some action which will be triggered */
404 case BTC_SET_ACT_GET_BT_RSSI:
405 /*BTHCI_SendGetBtRssiEvent(rtlpriv);*/
407 case BTC_SET_ACT_AGGREGATE_CTRL:
408 halbtc_aggregation_check();
412 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
413 btcoexist->bt_info.rssi_adjust_for_1ant_coex_type = *u8_tmp;
415 case BTC_SET_UI_SCAN_SIG_COMPENSATION:
416 /* rtlpriv->mlmepriv.scan_compensation = *u8_tmp; */
418 case BTC_SET_U1_1ANT_LPS:
419 btcoexist->bt_info.lps_val = *u8_tmp;
421 case BTC_SET_U1_1ANT_RPWM:
422 btcoexist->bt_info.rpwm_val = *u8_tmp;
424 /* the following are some action which will be triggered */
425 case BTC_SET_ACT_LEAVE_LPS:
426 halbtc_leave_lps(btcoexist);
428 case BTC_SET_ACT_ENTER_LPS:
429 halbtc_enter_lps(btcoexist);
431 case BTC_SET_ACT_NORMAL_LPS:
432 halbtc_normal_lps(btcoexist);
434 case BTC_SET_ACT_DISABLE_LOW_POWER:
435 halbtc_disable_low_power();
437 case BTC_SET_ACT_UPDATE_ra_mask:
438 btcoexist->bt_info.ra_mask = *u32_tmp;
440 case BTC_SET_ACT_SEND_MIMO_PS:
442 case BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT:
443 btcoexist->bt_info.force_exec_pwr_cmd_cnt++;
445 case BTC_SET_ACT_CTRL_BT_INFO: /*wait for 8812/8821*/
447 case BTC_SET_ACT_CTRL_BT_COEX:
456 static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist)
460 static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist)
464 static void halbtc_display_bt_fw_info(struct btc_coexist *btcoexist)
468 static void halbtc_display_fw_pwr_mode_cmd(struct btc_coexist *btcoexist)
472 /************************************************************
473 * IO related function
474 ************************************************************/
475 static u8 halbtc_read_1byte(void *bt_context, u32 reg_addr)
477 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
478 struct rtl_priv *rtlpriv = btcoexist->adapter;
480 return rtl_read_byte(rtlpriv, reg_addr);
483 static u16 halbtc_read_2byte(void *bt_context, u32 reg_addr)
485 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
486 struct rtl_priv *rtlpriv = btcoexist->adapter;
488 return rtl_read_word(rtlpriv, reg_addr);
491 static u32 halbtc_read_4byte(void *bt_context, u32 reg_addr)
493 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
494 struct rtl_priv *rtlpriv = btcoexist->adapter;
496 return rtl_read_dword(rtlpriv, reg_addr);
499 static void halbtc_write_1byte(void *bt_context, u32 reg_addr, u32 data)
501 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
502 struct rtl_priv *rtlpriv = btcoexist->adapter;
504 rtl_write_byte(rtlpriv, reg_addr, data);
507 static void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr,
508 u32 bit_mask, u8 data)
510 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
511 struct rtl_priv *rtlpriv = btcoexist->adapter;
512 u8 original_value, bit_shift = 0;
515 if (bit_mask != MASKDWORD) {/*if not "double word" write*/
516 original_value = rtl_read_byte(rtlpriv, reg_addr);
517 for (i = 0; i <= 7; i++) {
518 if ((bit_mask>>i) & 0x1)
522 data = (original_value & (~bit_mask)) |
523 ((data << bit_shift) & bit_mask);
525 rtl_write_byte(rtlpriv, reg_addr, data);
528 static void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data)
530 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
531 struct rtl_priv *rtlpriv = btcoexist->adapter;
533 rtl_write_word(rtlpriv, reg_addr, data);
536 static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data)
538 struct btc_coexist *btcoexist =
539 (struct btc_coexist *)bt_context;
540 struct rtl_priv *rtlpriv = btcoexist->adapter;
542 rtl_write_dword(rtlpriv, reg_addr, data);
545 static void halbtc_set_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask,
548 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
549 struct rtl_priv *rtlpriv = btcoexist->adapter;
551 rtl_set_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask, data);
554 static u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask)
556 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
557 struct rtl_priv *rtlpriv = btcoexist->adapter;
559 return rtl_get_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask);
562 static void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr,
563 u32 bit_mask, u32 data)
565 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
566 struct rtl_priv *rtlpriv = btcoexist->adapter;
568 rtl_set_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask, data);
571 static u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, u32 reg_addr,
574 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
575 struct rtl_priv *rtlpriv = btcoexist->adapter;
577 return rtl_get_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask);
580 static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id,
581 u32 cmd_len, u8 *cmd_buf)
583 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
584 struct rtl_priv *rtlpriv = btcoexist->adapter;
586 rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, element_id,
590 static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type)
592 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
594 case BTC_DBG_DISP_COEX_STATISTICS:
595 halbtc_display_coex_statistics(btcoexist);
597 case BTC_DBG_DISP_BT_LINK_INFO:
598 halbtc_display_bt_link_info(btcoexist);
600 case BTC_DBG_DISP_BT_FW_VER:
601 halbtc_display_bt_fw_info(btcoexist);
603 case BTC_DBG_DISP_FW_PWR_MODE_CMD:
604 halbtc_display_fw_pwr_mode_cmd(btcoexist);
611 /*****************************************************************
612 * Extern functions called by other module
613 *****************************************************************/
614 bool exhalbtc_initlize_variables(struct rtl_priv *adapter)
616 struct btc_coexist *btcoexist = &gl_bt_coexist;
618 btcoexist->statistics.cnt_bind++;
622 if (btcoexist->binded)
625 btcoexist->binded = true;
627 btcoexist->chip_interface = BTC_INTF_UNKNOWN;
629 if (NULL == btcoexist->adapter)
630 btcoexist->adapter = adapter;
632 btcoexist->stack_info.profile_notified = false;
634 btcoexist->btc_read_1byte = halbtc_read_1byte;
635 btcoexist->btc_write_1byte = halbtc_write_1byte;
636 btcoexist->btc_write_1byte_bitmask = halbtc_bitmask_write_1byte;
637 btcoexist->btc_read_2byte = halbtc_read_2byte;
638 btcoexist->btc_write_2byte = halbtc_write_2byte;
639 btcoexist->btc_read_4byte = halbtc_read_4byte;
640 btcoexist->btc_write_4byte = halbtc_write_4byte;
642 btcoexist->btc_set_bb_reg = halbtc_set_bbreg;
643 btcoexist->btc_get_bb_reg = halbtc_get_bbreg;
645 btcoexist->btc_set_rf_reg = halbtc_set_rfreg;
646 btcoexist->btc_get_rf_reg = halbtc_get_rfreg;
648 btcoexist->btc_fill_h2c = halbtc_fill_h2c_cmd;
649 btcoexist->btc_disp_dbg_msg = halbtc_display_dbg_msg;
651 btcoexist->btc_get = halbtc_get;
652 btcoexist->btc_set = halbtc_set;
654 btcoexist->bt_info.bt_ctrl_buf_size = false;
655 btcoexist->bt_info.agg_buf_size = 5;
657 btcoexist->bt_info.increase_scan_dev_num = false;
661 void exhalbtc_init_hw_config(struct btc_coexist *btcoexist)
663 struct rtl_priv *rtlpriv = btcoexist->adapter;
664 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
666 if (!halbtc_is_bt_coexist_available(btcoexist))
669 btcoexist->statistics.cnt_init_hw_config++;
671 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
672 ex_btc8723b2ant_init_hwconfig(btcoexist);
675 void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist)
677 struct rtl_priv *rtlpriv = btcoexist->adapter;
678 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
680 if (!halbtc_is_bt_coexist_available(btcoexist))
683 btcoexist->statistics.cnt_init_coex_dm++;
685 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
686 ex_btc8723b2ant_init_coex_dm(btcoexist);
688 btcoexist->initilized = true;
691 void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type)
693 struct rtl_priv *rtlpriv = btcoexist->adapter;
694 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
697 if (!halbtc_is_bt_coexist_available(btcoexist))
699 btcoexist->statistics.cnt_ips_notify++;
700 if (btcoexist->manual_control)
704 ips_type = BTC_IPS_ENTER;
706 ips_type = BTC_IPS_LEAVE;
708 halbtc_leave_low_power();
710 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
711 ex_btc8723b2ant_ips_notify(btcoexist, ips_type);
713 halbtc_nomal_low_power();
716 void exhalbtc_lps_notify(struct btc_coexist *btcoexist, u8 type)
718 struct rtl_priv *rtlpriv = btcoexist->adapter;
719 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
722 if (!halbtc_is_bt_coexist_available(btcoexist))
724 btcoexist->statistics.cnt_lps_notify++;
725 if (btcoexist->manual_control)
729 lps_type = BTC_LPS_DISABLE;
731 lps_type = BTC_LPS_ENABLE;
733 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
734 ex_btc8723b2ant_lps_notify(btcoexist, lps_type);
737 void exhalbtc_scan_notify(struct btc_coexist *btcoexist, u8 type)
739 struct rtl_priv *rtlpriv = btcoexist->adapter;
740 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
743 if (!halbtc_is_bt_coexist_available(btcoexist))
745 btcoexist->statistics.cnt_scan_notify++;
746 if (btcoexist->manual_control)
750 scan_type = BTC_SCAN_START;
752 scan_type = BTC_SCAN_FINISH;
754 halbtc_leave_low_power();
756 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
757 ex_btc8723b2ant_scan_notify(btcoexist, scan_type);
759 halbtc_nomal_low_power();
762 void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action)
764 struct rtl_priv *rtlpriv = btcoexist->adapter;
765 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
768 if (!halbtc_is_bt_coexist_available(btcoexist))
770 btcoexist->statistics.cnt_connect_notify++;
771 if (btcoexist->manual_control)
775 asso_type = BTC_ASSOCIATE_START;
777 asso_type = BTC_ASSOCIATE_FINISH;
779 halbtc_leave_low_power();
781 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
782 ex_btc8723b2ant_connect_notify(btcoexist, asso_type);
785 void exhalbtc_mediastatus_notify(struct btc_coexist *btcoexist,
786 enum rt_media_status media_status)
790 if (!halbtc_is_bt_coexist_available(btcoexist))
792 btcoexist->statistics.cnt_media_status_notify++;
793 if (btcoexist->manual_control)
796 if (RT_MEDIA_CONNECT == media_status)
797 status = BTC_MEDIA_CONNECT;
799 status = BTC_MEDIA_DISCONNECT;
801 halbtc_leave_low_power();
803 halbtc_nomal_low_power();
806 void exhalbtc_special_packet_notify(struct btc_coexist *btcoexist, u8 pkt_type)
808 struct rtl_priv *rtlpriv = btcoexist->adapter;
809 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
812 if (!halbtc_is_bt_coexist_available(btcoexist))
814 btcoexist->statistics.cnt_special_packet_notify++;
815 if (btcoexist->manual_control)
818 packet_type = BTC_PACKET_DHCP;
820 halbtc_leave_low_power();
822 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
823 ex_btc8723b2ant_special_packet_notify(btcoexist,
826 halbtc_nomal_low_power();
829 void exhalbtc_bt_info_notify(struct btc_coexist *btcoexist,
830 u8 *tmp_buf, u8 length)
832 struct rtl_priv *rtlpriv = btcoexist->adapter;
833 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
834 if (!halbtc_is_bt_coexist_available(btcoexist))
836 btcoexist->statistics.cnt_bt_info_notify++;
838 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
839 ex_btc8723b2ant_bt_info_notify(btcoexist, tmp_buf, length);
842 void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type)
846 if (!halbtc_is_bt_coexist_available(btcoexist))
848 btcoexist->statistics.cnt_stack_operation_notify++;
849 if (btcoexist->manual_control)
852 stack_op_type = BTC_STACK_OP_NONE;
854 halbtc_leave_low_power();
856 halbtc_nomal_low_power();
859 void exhalbtc_halt_notify(struct btc_coexist *btcoexist)
861 struct rtl_priv *rtlpriv = btcoexist->adapter;
862 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
863 if (!halbtc_is_bt_coexist_available(btcoexist))
866 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
867 ex_btc8723b2ant_halt_notify(btcoexist);
870 void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
872 if (!halbtc_is_bt_coexist_available(btcoexist))
876 void exhalbtc_periodical(struct btc_coexist *btcoexist)
878 struct rtl_priv *rtlpriv = btcoexist->adapter;
879 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
880 if (!halbtc_is_bt_coexist_available(btcoexist))
882 btcoexist->statistics.cnt_periodical++;
884 halbtc_leave_low_power();
886 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
887 ex_btc8723b2ant_periodical(btcoexist);
889 halbtc_nomal_low_power();
892 void exhalbtc_dbg_control(struct btc_coexist *btcoexist,
893 u8 code, u8 len, u8 *data)
895 if (!halbtc_is_bt_coexist_available(btcoexist))
897 btcoexist->statistics.cnt_dbg_ctrl++;
900 void exhalbtc_stack_update_profile_info(void)
904 void exhalbtc_update_min_bt_rssi(s8 bt_rssi)
906 struct btc_coexist *btcoexist = &gl_bt_coexist;
908 if (!halbtc_is_bt_coexist_available(btcoexist))
911 btcoexist->stack_info.min_bt_rssi = bt_rssi;
914 void exhalbtc_set_hci_version(u16 hci_version)
916 struct btc_coexist *btcoexist = &gl_bt_coexist;
918 if (!halbtc_is_bt_coexist_available(btcoexist))
921 btcoexist->stack_info.hci_version = hci_version;
924 void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version)
926 struct btc_coexist *btcoexist = &gl_bt_coexist;
928 if (!halbtc_is_bt_coexist_available(btcoexist))
931 btcoexist->bt_info.bt_real_fw_ver = bt_patch_version;
932 btcoexist->bt_info.bt_hci_ver = bt_hci_version;
935 void exhalbtc_set_bt_exist(bool bt_exist)
937 gl_bt_coexist.board_info.bt_exist = bt_exist;
940 void exhalbtc_set_chip_type(u8 chip_type)
948 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_UNDEF;
951 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
954 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
957 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A;
960 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8821;
963 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B;
968 void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
970 if (BT_COEX_ANT_TYPE_PG == type) {
971 gl_bt_coexist.board_info.pg_ant_num = ant_num;
972 gl_bt_coexist.board_info.btdm_ant_num = ant_num;
973 /* The antenna position:
974 * Main (default) or Aux for pgAntNum=2 && btdmAntNum =1.
975 * The antenna position should be determined by
976 * auto-detect mechanism.
977 * The following is assumed to main,
978 * and those must be modified
979 * if y auto-detect mechanism is ready
981 if ((gl_bt_coexist.board_info.pg_ant_num == 2) &&
982 (gl_bt_coexist.board_info.btdm_ant_num == 1))
983 gl_bt_coexist.board_info.btdm_ant_pos =
984 BTC_ANTENNA_AT_MAIN_PORT;
986 gl_bt_coexist.board_info.btdm_ant_pos =
987 BTC_ANTENNA_AT_MAIN_PORT;
988 } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
989 gl_bt_coexist.board_info.btdm_ant_num = ant_num;
990 gl_bt_coexist.board_info.btdm_ant_pos =
991 BTC_ANTENNA_AT_MAIN_PORT;
992 } else if (type == BT_COEX_ANT_TYPE_DETECTED) {
993 gl_bt_coexist.board_info.btdm_ant_num = ant_num;
994 if (rtlpriv->cfg->mod_params->ant_sel == 1)
995 gl_bt_coexist.board_info.btdm_ant_pos =
996 BTC_ANTENNA_AT_AUX_PORT;
998 gl_bt_coexist.board_info.btdm_ant_pos =
999 BTC_ANTENNA_AT_MAIN_PORT;
1003 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist)
1005 struct rtl_priv *rtlpriv = btcoexist->adapter;
1006 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1007 if (!halbtc_is_bt_coexist_available(btcoexist))
1010 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
1011 ex_btc8723b2ant_display_coex_info(btcoexist);