Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[linux/fpc-iii.git] / drivers / net / wireless / realtek / rtlwifi / btcoexist / halbtcoutsrc.c
blobb2791c893417b071782dbb317f6baae53c0ecf74
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
12 * more details.
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 /***********************************************
29 * Global variables
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)
42 return false;
44 return true;
47 static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv)
49 if (rtlpriv->link_info.busytraffic)
50 return true;
51 else
52 return false;
55 static void halbtc_dbg_init(void)
57 u8 i;
59 for (i = 0; i < BTC_MSG_MAX; i++)
60 btc_dbg_type[i] = 0;
62 btc_dbg_type[BTC_MSG_INTERFACE] =
63 /* INTF_INIT | */
64 /* INTF_NOTIFY | */
67 btc_dbg_type[BTC_MSG_ALGORITHM] =
68 /* ALGO_BT_RSSI_STATE | */
69 /* ALGO_WIFI_RSSI_STATE | */
70 /* ALGO_BT_MONITOR | */
71 /* ALGO_TRACE | */
72 /* ALGO_TRACE_FW | */
73 /* ALGO_TRACE_FW_DETAIL | */
74 /* ALGO_TRACE_FW_EXEC | */
75 /* ALGO_TRACE_SW | */
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);
85 bool is_ht40 = true;
86 enum ht_channel_width bw = rtlphy->current_chan_bw;
88 if (bw == HT_CHANNEL_WIDTH_20)
89 is_ht40 = false;
90 else if (bw == HT_CHANNEL_WIDTH_20_40)
91 is_ht40 = true;
93 return is_ht40;
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))
104 is_legacy = true;
106 return is_legacy;
109 bool halbtc_is_wifi_uplink(struct rtl_priv *adapter)
111 struct rtl_priv *rtlpriv = adapter;
113 if (rtlpriv->link_info.tx_busy_traffic)
114 return true;
115 else
116 return false;
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;
127 } else {
128 if (halbtc_legacy(rtlpriv))
129 wifi_bw = BTC_WIFI_BW_LEGACY;
130 else
131 wifi_bw = BTC_WIFI_BW_HT20;
133 return wifi_bw;
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);
140 u8 chnl = 1;
142 if (rtlphy->current_channel != 0)
143 chnl = rtlphy->current_channel;
144 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
145 "static halbtc_get_wifi_central_chnl:%d\n", chnl);
146 return 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,
159 &ap_enable);
161 if (ap_enable) {
162 pr_info("halbtc_leave_lps()<--dont leave lps under AP mode\n");
163 return;
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,
180 &ap_enable);
182 if (ap_enable) {
183 pr_info("halbtc_enter_lps()<--dont enter lps under AP mode\n");
184 return;
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)
217 return 0;
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;
243 bool tmp = false;
245 if (!halbtc_is_bt_coexist_available(btcoexist))
246 return false;
248 switch (get_type) {
249 case BTC_GET_BL_HS_OPERATION:
250 *bool_tmp = false;
251 break;
252 case BTC_GET_BL_HS_CONNECTING:
253 *bool_tmp = false;
254 break;
255 case BTC_GET_BL_WIFI_CONNECTED:
256 if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
257 tmp = true;
258 *bool_tmp = tmp;
259 break;
260 case BTC_GET_BL_WIFI_BUSY:
261 if (halbtc_is_wifi_busy(rtlpriv))
262 *bool_tmp = true;
263 else
264 *bool_tmp = false;
265 break;
266 case BTC_GET_BL_WIFI_SCAN:
267 if (mac->act_scanning)
268 *bool_tmp = true;
269 else
270 *bool_tmp = false;
271 break;
272 case BTC_GET_BL_WIFI_LINK:
273 if (mac->link_state == MAC80211_LINKING)
274 *bool_tmp = true;
275 else
276 *bool_tmp = false;
277 break;
278 case BTC_GET_BL_WIFI_ROAM: /*TODO*/
279 if (mac->link_state == MAC80211_LINKING)
280 *bool_tmp = true;
281 else
282 *bool_tmp = false;
283 break;
284 case BTC_GET_BL_WIFI_4_WAY_PROGRESS: /*TODO*/
285 *bool_tmp = false;
287 break;
288 case BTC_GET_BL_WIFI_UNDER_5G:
289 *bool_tmp = false; /*TODO*/
291 case BTC_GET_BL_WIFI_DHCP: /*TODO*/
292 break;
293 case BTC_GET_BL_WIFI_SOFTAP_IDLE:
294 *bool_tmp = true;
295 break;
296 case BTC_GET_BL_WIFI_SOFTAP_LINKING:
297 *bool_tmp = false;
298 break;
299 case BTC_GET_BL_WIFI_IN_EARLY_SUSPEND:
300 *bool_tmp = false;
301 break;
302 case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
303 *bool_tmp = false;
304 break;
305 case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
306 if (NO_ENCRYPTION == rtlpriv->sec.pairwise_enc_algorithm)
307 *bool_tmp = false;
308 else
309 *bool_tmp = true;
310 break;
311 case BTC_GET_BL_WIFI_UNDER_B_MODE:
312 *bool_tmp = false; /*TODO*/
313 break;
314 case BTC_GET_BL_EXT_SWITCH:
315 *bool_tmp = false;
316 break;
317 case BTC_GET_S4_WIFI_RSSI:
318 *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
319 break;
320 case BTC_GET_S4_HS_RSSI: /*TODO*/
321 *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
322 break;
323 case BTC_GET_U4_WIFI_BW:
324 *u32_tmp = halbtc_get_wifi_bw(btcoexist);
325 break;
326 case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
327 if (halbtc_is_wifi_uplink(rtlpriv))
328 *u32_tmp = BTC_WIFI_TRAFFIC_TX;
329 else
330 *u32_tmp = BTC_WIFI_TRAFFIC_RX;
331 break;
332 case BTC_GET_U4_WIFI_FW_VER:
333 *u32_tmp = rtlhal->fw_version;
334 break;
335 case BTC_GET_U4_BT_PATCH_VER:
336 *u32_tmp = halbtc_get_bt_patch_version(btcoexist);
337 break;
338 case BTC_GET_U1_WIFI_DOT11_CHNL:
339 *u8_tmp = rtlphy->current_channel;
340 break;
341 case BTC_GET_U1_WIFI_CENTRAL_CHNL:
342 *u8_tmp = halbtc_get_wifi_central_chnl(btcoexist);
343 break;
344 case BTC_GET_U1_WIFI_HS_CHNL:
345 *u8_tmp = 1;/*BT_OperateChnl(rtlpriv);*/
346 break;
347 case BTC_GET_U1_MAC_PHY_MODE:
348 *u8_tmp = BTC_MP_UNKNOWN;
349 break;
351 /************* 1Ant **************/
352 case BTC_GET_U1_LPS_MODE:
353 *u8_tmp = btcoexist->pwr_mode_val[0];
354 break;
356 default:
357 break;
360 return true;
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))
371 return false;
373 switch (set_type) {
374 /* set some bool type variables. */
375 case BTC_SET_BL_BT_DISABLE:
376 btcoexist->bt_info.bt_disabled = *bool_tmp;
377 break;
378 case BTC_SET_BL_BT_TRAFFIC_BUSY:
379 btcoexist->bt_info.bt_busy = *bool_tmp;
380 break;
381 case BTC_SET_BL_BT_LIMITED_DIG:
382 btcoexist->bt_info.limited_dig = *bool_tmp;
383 break;
384 case BTC_SET_BL_FORCE_TO_ROAM:
385 btcoexist->bt_info.force_to_roam = *bool_tmp;
386 break;
387 case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
388 btcoexist->bt_info.reject_agg_pkt = *bool_tmp;
389 break;
390 case BTC_SET_BL_BT_CTRL_AGG_SIZE:
391 btcoexist->bt_info.bt_ctrl_buf_size = *bool_tmp;
392 break;
393 case BTC_SET_BL_INC_SCAN_DEV_NUM:
394 btcoexist->bt_info.increase_scan_dev_num = *bool_tmp;
395 break;
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;
399 break;
400 case BTC_SET_U1_AGG_BUF_SIZE:
401 btcoexist->bt_info.agg_buf_size = *u8_tmp;
402 break;
403 /* the following are some action which will be triggered */
404 case BTC_SET_ACT_GET_BT_RSSI:
405 /*BTHCI_SendGetBtRssiEvent(rtlpriv);*/
406 break;
407 case BTC_SET_ACT_AGGREGATE_CTRL:
408 halbtc_aggregation_check();
409 break;
411 /* 1Ant */
412 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
413 btcoexist->bt_info.rssi_adjust_for_1ant_coex_type = *u8_tmp;
414 break;
415 case BTC_SET_UI_SCAN_SIG_COMPENSATION:
416 /* rtlpriv->mlmepriv.scan_compensation = *u8_tmp; */
417 break;
418 case BTC_SET_U1_1ANT_LPS:
419 btcoexist->bt_info.lps_val = *u8_tmp;
420 break;
421 case BTC_SET_U1_1ANT_RPWM:
422 btcoexist->bt_info.rpwm_val = *u8_tmp;
423 break;
424 /* the following are some action which will be triggered */
425 case BTC_SET_ACT_LEAVE_LPS:
426 halbtc_leave_lps(btcoexist);
427 break;
428 case BTC_SET_ACT_ENTER_LPS:
429 halbtc_enter_lps(btcoexist);
430 break;
431 case BTC_SET_ACT_NORMAL_LPS:
432 halbtc_normal_lps(btcoexist);
433 break;
434 case BTC_SET_ACT_DISABLE_LOW_POWER:
435 halbtc_disable_low_power();
436 break;
437 case BTC_SET_ACT_UPDATE_ra_mask:
438 btcoexist->bt_info.ra_mask = *u32_tmp;
439 break;
440 case BTC_SET_ACT_SEND_MIMO_PS:
441 break;
442 case BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT:
443 btcoexist->bt_info.force_exec_pwr_cmd_cnt++;
444 break;
445 case BTC_SET_ACT_CTRL_BT_INFO: /*wait for 8812/8821*/
446 break;
447 case BTC_SET_ACT_CTRL_BT_COEX:
448 break;
449 default:
450 break;
453 return true;
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;
513 u8 i;
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)
519 break;
521 bit_shift = i;
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,
546 u32 data)
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,
572 u32 bit_mask)
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,
587 cmd_len, cmd_buf);
590 static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type)
592 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
593 switch (disp_type) {
594 case BTC_DBG_DISP_COEX_STATISTICS:
595 halbtc_display_coex_statistics(btcoexist);
596 break;
597 case BTC_DBG_DISP_BT_LINK_INFO:
598 halbtc_display_bt_link_info(btcoexist);
599 break;
600 case BTC_DBG_DISP_BT_FW_VER:
601 halbtc_display_bt_fw_info(btcoexist);
602 break;
603 case BTC_DBG_DISP_FW_PWR_MODE_CMD:
604 halbtc_display_fw_pwr_mode_cmd(btcoexist);
605 break;
606 default:
607 break;
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++;
620 halbtc_dbg_init();
622 if (btcoexist->binded)
623 return false;
624 else
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;
658 return true;
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))
667 return;
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))
681 return;
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);
695 u8 ips_type;
697 if (!halbtc_is_bt_coexist_available(btcoexist))
698 return;
699 btcoexist->statistics.cnt_ips_notify++;
700 if (btcoexist->manual_control)
701 return;
703 if (ERFOFF == type)
704 ips_type = BTC_IPS_ENTER;
705 else
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);
720 u8 lps_type;
722 if (!halbtc_is_bt_coexist_available(btcoexist))
723 return;
724 btcoexist->statistics.cnt_lps_notify++;
725 if (btcoexist->manual_control)
726 return;
728 if (EACTIVE == type)
729 lps_type = BTC_LPS_DISABLE;
730 else
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);
741 u8 scan_type;
743 if (!halbtc_is_bt_coexist_available(btcoexist))
744 return;
745 btcoexist->statistics.cnt_scan_notify++;
746 if (btcoexist->manual_control)
747 return;
749 if (type)
750 scan_type = BTC_SCAN_START;
751 else
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);
766 u8 asso_type;
768 if (!halbtc_is_bt_coexist_available(btcoexist))
769 return;
770 btcoexist->statistics.cnt_connect_notify++;
771 if (btcoexist->manual_control)
772 return;
774 if (action)
775 asso_type = BTC_ASSOCIATE_START;
776 else
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)
788 u8 status;
790 if (!halbtc_is_bt_coexist_available(btcoexist))
791 return;
792 btcoexist->statistics.cnt_media_status_notify++;
793 if (btcoexist->manual_control)
794 return;
796 if (RT_MEDIA_CONNECT == media_status)
797 status = BTC_MEDIA_CONNECT;
798 else
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);
810 u8 packet_type;
812 if (!halbtc_is_bt_coexist_available(btcoexist))
813 return;
814 btcoexist->statistics.cnt_special_packet_notify++;
815 if (btcoexist->manual_control)
816 return;
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,
824 packet_type);
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))
835 return;
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)
844 u8 stack_op_type;
846 if (!halbtc_is_bt_coexist_available(btcoexist))
847 return;
848 btcoexist->statistics.cnt_stack_operation_notify++;
849 if (btcoexist->manual_control)
850 return;
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))
864 return;
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))
873 return;
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))
881 return;
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))
896 return;
897 btcoexist->statistics.cnt_dbg_ctrl++;
900 void exhalbtc_stack_update_profile_info(void)
904 void exhalbtc_update_min_bt_rssi(char bt_rssi)
906 struct btc_coexist *btcoexist = &gl_bt_coexist;
908 if (!halbtc_is_bt_coexist_available(btcoexist))
909 return;
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))
919 return;
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))
929 return;
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)
942 switch (chip_type) {
943 default:
944 case BT_2WIRE:
945 case BT_ISSC_3WIRE:
946 case BT_ACCEL:
947 case BT_RTL8756:
948 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_UNDEF;
949 break;
950 case BT_CSR_BC4:
951 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
952 break;
953 case BT_CSR_BC8:
954 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
955 break;
956 case BT_RTL8723A:
957 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A;
958 break;
959 case BT_RTL8821A:
960 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8821;
961 break;
962 case BT_RTL8723B:
963 gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B;
964 break;
968 void exhalbtc_set_ant_num(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 } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
974 gl_bt_coexist.board_info.btdm_ant_num = ant_num;
978 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist)
980 struct rtl_priv *rtlpriv = btcoexist->adapter;
981 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
982 if (!halbtc_is_bt_coexist_available(btcoexist))
983 return;
985 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
986 ex_btc8723b2ant_display_coex_info(btcoexist);