rtl8192ee: btcoexist: remove undefined Kconfig macros
[deliverable/linux.git] / drivers / staging / rtl8192ee / btcoexist / halbtcoutsrc.c
1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
4 *
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.
8 *
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.
13 *
14 *
15 ******************************************************************************/
16
17 #include "halbt_precomp.h"
18
19 /***********************************************
20 * Global variables
21 ***********************************************/
22 static const char *const bt_profile_string[] = {
23 "NONE",
24 "A2DP",
25 "PAN",
26 "HID",
27 "SCO",
28 };
29
30 static const char *const bt_spec_string[] = {
31 "1.0b",
32 "1.1",
33 "1.2",
34 "2.0+EDR",
35 "2.1+EDR",
36 "3.0+HS",
37 "4.0",
38 };
39
40 static const char *const bt_link_role_string[] = {
41 "Master",
42 "Slave",
43 };
44
45 static const char *const h2c_state_string[] = {
46 "successful",
47 "h2c busy",
48 "rf off",
49 "fw not read",
50 };
51
52 static const char *const io_state_string[] = {
53 "IO_STATUS_SUCCESS",
54 "IO_STATUS_FAIL_CANNOT_IO",
55 "IO_STATUS_FAIL_RF_OFF",
56 "IO_STATUS_FAIL_FW_READ_CLEAR_TIMEOUT",
57 "IO_STATUS_FAIL_WAIT_IO_EVENT_TIMEOUT",
58 "IO_STATUS_INVALID_LEN",
59 "IO_STATUS_IO_IDLE_QUEUE_EMPTY",
60 "IO_STATUS_IO_INSERT_WAIT_QUEUE_FAIL",
61 "IO_STATUS_UNKNOWN_FAIL",
62 "IO_STATUS_WRONG_LEVEL",
63 "IO_STATUS_H2C_STOPPED",
64 };
65
66 struct btc_coexist gl92e_bt_coexist;
67
68 u32 btc_92edbg_type[BTC_MSG_MAX];
69 static u8 btc_dbg_buf[100];
70
71 /***************************************************
72 * Debug related function
73 ***************************************************/
74 static bool is_any_client_connect_to_ap(struct btc_coexist *btcoexist)
75 {
76 struct rtl_priv *rtlpriv = btcoexist->adapter;
77 struct rtl_mac *mac = rtl_mac(rtlpriv);
78 struct rtl_sta_info *drv_priv;
79 u8 cnt = 0;
80
81 if (mac->opmode == NL80211_IFTYPE_ADHOC ||
82 mac->opmode == NL80211_IFTYPE_MESH_POINT ||
83 mac->opmode == NL80211_IFTYPE_AP) {
84 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
85 list_for_each_entry(drv_priv, &rtlpriv->entry_list, list) {
86 cnt++;
87 }
88 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
89 }
90 if (cnt > 0)
91 return true;
92 else
93 return false;
94 }
95
96 static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist)
97 {
98 if (!btcoexist->binded || NULL == btcoexist->adapter)
99 return false;
100
101 return true;
102 }
103
104 static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv)
105 {
106 if (rtlpriv->link_info.b_busytraffic)
107 return true;
108 else
109 return false;
110 }
111
112
113 static void halbtc_dbg_init(void)
114 {
115 u8 i;
116
117 for (i = 0; i < BTC_MSG_MAX; i++)
118 btc_92edbg_type[i] = 0;
119
120 btc_92edbg_type[BTC_MSG_INTERFACE] = 0;
121
122 btc_92edbg_type[BTC_MSG_ALGORITHM] = 0;
123 }
124
125 static bool halbtc_is_bt40(struct rtl_priv *adapter)
126 {
127 struct rtl_priv *rtlpriv = adapter;
128 struct rtl_phy *rtlphy = &(rtlpriv->phy);
129 bool is_ht40 = true;
130 enum ht_channel_width bw = rtlphy->current_chan_bw;
131
132
133 if (bw == HT_CHANNEL_WIDTH_20)
134 is_ht40 = false;
135 else if (bw == HT_CHANNEL_WIDTH_20_40)
136 is_ht40 = true;
137
138 return is_ht40;
139 }
140
141 static bool halbtc_legacy(struct rtl_priv *adapter)
142 {
143 struct rtl_priv *rtlpriv = adapter;
144 struct rtl_mac *mac = rtl_mac(rtlpriv);
145
146 bool is_legacy = false;
147
148 if ((mac->mode == WIRELESS_MODE_B) || (mac->mode == WIRELESS_MODE_G))
149 is_legacy = true;
150
151 return is_legacy;
152 }
153
154 bool halbtc92e_is_wifi_uplink(struct rtl_priv *adapter)
155 {
156 struct rtl_priv *rtlpriv = adapter;
157
158 if (rtlpriv->link_info.b_tx_busy_traffic)
159 return true;
160 else
161 return false;
162 }
163
164 static u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist)
165 {
166 struct rtl_priv *rtlpriv =
167 (struct rtl_priv *)btcoexist->adapter;
168 u32 wifi_bw = BTC_WIFI_BW_HT20;
169
170 if (halbtc_is_bt40(rtlpriv)) {
171 wifi_bw = BTC_WIFI_BW_HT40;
172 } else {
173 if (halbtc_legacy(rtlpriv))
174 wifi_bw = BTC_WIFI_BW_LEGACY;
175 else
176 wifi_bw = BTC_WIFI_BW_HT20;
177 }
178 return wifi_bw;
179 }
180
181 static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist)
182 {
183 struct rtl_priv *rtlpriv = btcoexist->adapter;
184 struct rtl_phy *rtlphy = &(rtlpriv->phy);
185 u8 chnl = 1;
186
187
188 if (rtlphy->current_channel != 0)
189 chnl = rtlphy->current_channel;
190 BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
191 "halbtc_get_wifi_central_chnl:%d\n", chnl);
192 return chnl;
193 }
194
195 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
196 {
197 struct rtl_priv *rtlpriv;
198 struct rtl_ps_ctl *ppsc;
199 bool ap_enable = false;
200
201 rtlpriv = btcoexist->adapter;
202 ppsc = rtl_psc(rtlpriv);
203
204 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
205 &ap_enable);
206
207 if (ap_enable) {
208 pr_debug("halbtc_leave_lps()<--dont leave lps under AP mode\n");
209 return;
210 }
211
212 btcoexist->bt_info.bt_ctrl_lps = true;
213 btcoexist->bt_info.bt_lps_on = false;
214 rtl92e_lps_leave(rtlpriv->mac80211.hw);
215 }
216
217 static void halbtc_enter_lps(struct btc_coexist *btcoexist)
218 {
219 struct rtl_priv *rtlpriv;
220 struct rtl_ps_ctl *ppsc;
221 bool ap_enable = false;
222
223 rtlpriv = btcoexist->adapter;
224 ppsc = rtl_psc(rtlpriv);
225
226 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
227 &ap_enable);
228
229 if (ap_enable) {
230 pr_debug("halbtc_enter_lps()<--dont enter lps under AP mode\n");
231 return;
232 }
233
234 btcoexist->bt_info.bt_ctrl_lps = true;
235 btcoexist->bt_info.bt_lps_on = false;
236 rtl92e_lps_enter(rtlpriv->mac80211.hw);
237 }
238
239 static void halbtc_normal_lps(struct btc_coexist *btcoexist)
240 {
241 if (btcoexist->bt_info.bt_ctrl_lps) {
242 btcoexist->bt_info.bt_lps_on = false;
243 btcoexist->bt_info.bt_ctrl_lps = false;
244 }
245 }
246
247 static void halbtc_aggregation_check(struct btc_coexist *btcoexist)
248 {
249 }
250
251 static u32 halbtcoutsrc_get_wifi_link_status(struct btc_coexist *btcoexist)
252 {
253 /*------------------------------------
254 * return value:
255 * [31:16] => connected port number
256 * [15:0] => port connected bit define
257 *------------------------------------
258 */
259
260 struct rtl_priv *rtlpriv = btcoexist->adapter;
261 struct rtl_mac *mac = rtl_mac(rtlpriv);
262 u32 ret_val = 0;
263 u32 port_connected_status = 0, num_of_connected_port = 0;
264
265 if (mac->opmode == NL80211_IFTYPE_STATION &&
266 mac->link_state >= MAC80211_LINKED) {
267 port_connected_status |= WIFI_STA_CONNECTED;
268 num_of_connected_port++;
269 }
270 /* AP & ADHOC & MESH */
271 if (is_any_client_connect_to_ap(btcoexist)) {
272 port_connected_status |= WIFI_AP_CONNECTED;
273 num_of_connected_port++;
274 }
275 /*if (BT_HsConnectionEstablished(Adapter))
276 {
277 port_connected_status |= WIFI_HS_CONNECTED;
278 num_of_connected_port++;
279 }*/
280 /* TODO:
281 * P2P Connected Status */
282
283 ret_val = (num_of_connected_port << 16) | port_connected_status;
284
285 return ret_val;
286 }
287
288
289 static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist)
290 {
291 return 0;
292 }
293
294 static s32 halbtc_get_wifi_rssi(struct rtl_priv *adapter)
295 {
296 struct rtl_priv *rtlpriv = adapter;
297 s32 undecorated_smoothed_pwdb = 0;
298
299 if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
300 undecorated_smoothed_pwdb =
301 rtlpriv->dm.undecorated_smoothed_pwdb;
302 else /* associated entry pwdb */
303 undecorated_smoothed_pwdb =
304 rtlpriv->dm.undecorated_smoothed_pwdb;
305 return undecorated_smoothed_pwdb;
306 }
307
308 static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf)
309 {
310 struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
311 struct rtl_priv *rtlpriv = btcoexist->adapter;
312 struct rtl_phy *rtlphy = &(rtlpriv->phy);
313 struct rtl_mac *mac = rtl_mac(rtlpriv);
314 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
315 bool *bool_tmp = (bool *)out_buf;
316 int *s32_tmp = (int *)out_buf;
317 u32 *u32_tmp = (u32 *)out_buf;
318 u8 *u8_tmp = (u8 *)out_buf;
319 bool tmp = false;
320
321
322 if (!halbtc_is_bt_coexist_available(btcoexist))
323 return false;
324
325
326 switch (get_type) {
327 case BTC_GET_BL_HS_OPERATION:
328 *bool_tmp = false;
329 break;
330 case BTC_GET_BL_HS_CONNECTING:
331 *bool_tmp = false;
332 break;
333 case BTC_GET_BL_WIFI_CONNECTED:
334 if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_STATION &&
335 rtlpriv->mac80211.link_state >= MAC80211_LINKED)
336 tmp = true;
337 if (is_any_client_connect_to_ap(btcoexist))
338 tmp = true;
339 *bool_tmp = tmp;
340 break;
341 case BTC_GET_BL_WIFI_BUSY:
342 if (halbtc_is_wifi_busy(rtlpriv))
343 *bool_tmp = true;
344 else
345 *bool_tmp = false;
346 break;
347 case BTC_GET_BL_WIFI_SCAN:
348 if (mac->act_scanning)
349 *bool_tmp = true;
350 else
351 *bool_tmp = false;
352 break;
353 case BTC_GET_BL_WIFI_LINK:
354 if (mac->link_state == MAC80211_LINKING)
355 *bool_tmp = true;
356 else
357 *bool_tmp = false;
358 break;
359 case BTC_GET_BL_WIFI_ROAM: /*TODO*/
360 *bool_tmp = false;
361 break;
362 case BTC_GET_BL_WIFI_4_WAY_PROGRESS: /*TODO*/
363 *bool_tmp = false;
364 break;
365 case BTC_GET_BL_WIFI_UNDER_5G:
366 *bool_tmp = false; /*TODO*/
367
368 case BTC_GET_BL_WIFI_DHCP: /*TODO*/
369 break;
370 case BTC_GET_BL_WIFI_SOFTAP_IDLE:
371 *bool_tmp = true;
372 break;
373 case BTC_GET_BL_WIFI_SOFTAP_LINKING:
374 *bool_tmp = false;
375 break;
376 case BTC_GET_BL_WIFI_IN_EARLY_SUSPEND:
377 *bool_tmp = false;
378 break;
379 case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
380 *bool_tmp = false;
381 break;
382 case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
383 if (NO_ENCRYPTION == rtlpriv->sec.pairwise_enc_algorithm)
384 *bool_tmp = false;
385 else
386 *bool_tmp = true;
387 break;
388 case BTC_GET_BL_WIFI_UNDER_B_MODE:
389 if (WIRELESS_MODE_B == rtlpriv->mac80211.mode)
390 *bool_tmp = true;
391 else
392 *bool_tmp = false;
393 break;
394 case BTC_GET_BL_EXT_SWITCH:
395 *bool_tmp = false;
396 break;
397 case BTC_GET_S4_WIFI_RSSI:
398 *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
399 break;
400 case BTC_GET_S4_HS_RSSI: /*TODO*/
401 *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
402 break;
403 case BTC_GET_U4_WIFI_BW:
404 *u32_tmp = halbtc_get_wifi_bw(btcoexist);
405 break;
406 case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
407 if (halbtc92e_is_wifi_uplink(rtlpriv))
408 *u32_tmp = BTC_WIFI_TRAFFIC_TX;
409 else
410 *u32_tmp = BTC_WIFI_TRAFFIC_RX;
411 break;
412 case BTC_GET_U4_WIFI_FW_VER:
413 *u32_tmp = (rtlhal->fw_version << 16) | rtlhal->fw_subversion;
414 break;
415 case BTC_GET_U4_WIFI_LINK_STATUS:
416 *u32_tmp = halbtcoutsrc_get_wifi_link_status(btcoexist);
417 break;
418 case BTC_GET_U4_BT_PATCH_VER:
419 *u32_tmp = halbtc_get_bt_patch_version(btcoexist);
420 break;
421 case BTC_GET_U1_WIFI_DOT11_CHNL:
422 *u8_tmp = rtlphy->current_channel;
423 break;
424 case BTC_GET_U1_WIFI_CENTRAL_CHNL:
425 *u8_tmp = halbtc_get_wifi_central_chnl(btcoexist);
426 break;
427 case BTC_GET_U1_WIFI_HS_CHNL:
428 *u8_tmp = 1;/* BT_OperateChnl(rtlpriv); */
429 break;
430 case BTC_GET_U1_MAC_PHY_MODE:
431 *u8_tmp = BTC_MP_UNKNOWN;
432 break;
433 case BTC_GET_U1_AP_NUM:
434 /* driver don't know AP num in Linux,
435 * So, the return value here is not right */
436 *u8_tmp = 1;/* pDefMgntInfo->NumBssDesc4Query; */
437 break;
438
439 /************* 1Ant **************/
440 case BTC_GET_U1_LPS_MODE:
441 *u8_tmp = btcoexist->pwr_mode_val[0];
442 break;
443
444 default:
445 break;
446 }
447
448 return true;
449 }
450
451 static bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf)
452 {
453 struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
454 bool *bool_tmp = (bool *)in_buf;
455 u8 *u8_tmp = (u8 *)in_buf;
456 u32 *u32_tmp = (u32 *)in_buf;
457
458
459 if (!halbtc_is_bt_coexist_available(btcoexist))
460 return false;
461
462 switch (set_type) {
463 /* set some bool type variables. */
464 case BTC_SET_BL_BT_DISABLE:
465 btcoexist->bt_info.bt_disabled = *bool_tmp;
466 break;
467 case BTC_SET_BL_BT_TRAFFIC_BUSY:
468 btcoexist->bt_info.bt_busy = *bool_tmp;
469 break;
470 case BTC_SET_BL_BT_LIMITED_DIG:
471 btcoexist->bt_info.limited_dig = *bool_tmp;
472 break;
473 case BTC_SET_BL_FORCE_TO_ROAM:
474 btcoexist->bt_info.force_to_roam = *bool_tmp;
475 break;
476 case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
477 btcoexist->bt_info.reject_agg_pkt = *bool_tmp;
478 break;
479 case BTC_SET_BL_BT_CTRL_AGG_SIZE:
480 btcoexist->bt_info.b_bt_ctrl_buf_size = *bool_tmp;
481 break;
482 case BTC_SET_BL_INC_SCAN_DEV_NUM:
483 btcoexist->bt_info.increase_scan_dev_num = *bool_tmp;
484 break;
485 /* set some u1Byte type variables. */
486 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
487 btcoexist->bt_info.rssi_adjust_for_agc_table_on = *u8_tmp;
488 break;
489 case BTC_SET_U1_AGG_BUF_SIZE:
490 btcoexist->bt_info.agg_buf_size = *u8_tmp;
491 break;
492 /* the following are some action which will be triggered */
493 case BTC_SET_ACT_GET_BT_RSSI:
494 /*BTHCI_SendGetBtRssiEvent(rtlpriv);*/
495 break;
496 case BTC_SET_ACT_AGGREGATE_CTRL:
497 halbtc_aggregation_check(btcoexist);
498 break;
499
500 /* 1Ant */
501 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
502 btcoexist->bt_info.rssi_adjust_for_1ant_coex_type = *u8_tmp;
503 break;
504 case BTC_SET_U1_LPS_VAL:
505 btcoexist->bt_info.lps_val = *u8_tmp;
506 break;
507 case BTC_SET_U1_RPWM_VAL:
508 btcoexist->bt_info.rpwm_val = *u8_tmp;
509 break;
510 /* the following are some action which will be triggered */
511 case BTC_SET_ACT_LEAVE_LPS:
512 halbtc_leave_lps(btcoexist);
513 break;
514 case BTC_SET_ACT_ENTER_LPS:
515 halbtc_enter_lps(btcoexist);
516 break;
517 case BTC_SET_ACT_NORMAL_LPS:
518 halbtc_normal_lps(btcoexist);
519 break;
520 case BTC_SET_ACT_DISABLE_LOW_POWER:
521 break;
522 case BTC_SET_ACT_UPDATE_ra_mask:
523 btcoexist->bt_info.ra_mask = *u32_tmp;
524 break;
525 case BTC_SET_ACT_SEND_MIMO_PS:
526 break;
527 case BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT:
528 btcoexist->bt_info.force_exec_pwr_cmd_cnt++;
529 break;
530 case BTC_SET_ACT_CTRL_BT_INFO: /*wait for 8812/8821*/
531 break;
532 case BTC_SET_ACT_CTRL_BT_COEX:
533 break;
534 default:
535 break;
536 }
537
538 return true;
539 }
540
541 static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist)
542 {
543 }
544
545 static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist)
546 {
547 }
548
549 static void halbtc_display_bt_fw_info(struct btc_coexist *btcoexist)
550 {
551 }
552
553 static void halbtc_display_fw_pwr_mode_cmd(struct btc_coexist *btcoexist)
554 {
555 }
556
557 /************************************************************
558 * IO related function
559 ************************************************************/
560 static u8 halbtc_read_1byte(void *bt_context, u32 reg_addr)
561 {
562 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
563 struct rtl_priv *rtlpriv = btcoexist->adapter;
564
565 return rtl_read_byte(rtlpriv, reg_addr);
566 }
567
568
569 static u16 halbtc_read_2byte(void *bt_context, u32 reg_addr)
570 {
571 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
572 struct rtl_priv *rtlpriv = btcoexist->adapter;
573
574 return rtl_read_word(rtlpriv, reg_addr);
575 }
576
577
578 static u32 halbtc_read_4byte(void *bt_context, u32 reg_addr)
579 {
580 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
581 struct rtl_priv *rtlpriv = btcoexist->adapter;
582
583 return rtl_read_dword(rtlpriv, reg_addr);
584 }
585
586
587 static void halbtc_write_1byte(void *bt_context, u32 reg_addr, u8 data)
588 {
589 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
590 struct rtl_priv *rtlpriv = btcoexist->adapter;
591
592 rtl_write_byte(rtlpriv, reg_addr, data);
593 }
594
595 static void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr,
596 u8 bit_mask, u8 data)
597 {
598 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
599 struct rtl_priv *rtlpriv = btcoexist->adapter;
600 u8 original_value, bit_shift = 0;
601 u8 i;
602
603 if (bit_mask != MASKBYTE0) {/*if not "byte" write*/
604 original_value = rtl_read_byte(rtlpriv, reg_addr);
605 for (i = 0; i <= 7; i++) {
606 if ((bit_mask>>i)&0x1)
607 break;
608 }
609 bit_shift = i;
610 data = (original_value & (~bit_mask)) |
611 ((data << bit_shift) & bit_mask);
612 }
613 rtl_write_byte(rtlpriv, reg_addr, data);
614 }
615
616
617 static void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data)
618 {
619 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
620 struct rtl_priv *rtlpriv = btcoexist->adapter;
621
622 rtl_write_word(rtlpriv, reg_addr, data);
623 }
624
625
626 static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data)
627 {
628 struct btc_coexist *btcoexist =
629 (struct btc_coexist *)bt_context;
630 struct rtl_priv *rtlpriv = btcoexist->adapter;
631
632 rtl_write_dword(rtlpriv, reg_addr, data);
633 }
634
635
636 static void halbtc_set_bbreg(void *bt_context, u32 reg_addr,
637 u32 bit_mask, u32 data)
638 {
639 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
640 struct rtl_priv *rtlpriv = btcoexist->adapter;
641
642 rtl_set_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask, data);
643 }
644
645
646 static u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask)
647 {
648 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
649 struct rtl_priv *rtlpriv = btcoexist->adapter;
650
651 return rtl_get_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask);
652 }
653
654
655 static void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr,
656 u32 bit_mask, u32 data)
657 {
658 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
659 struct rtl_priv *rtlpriv = btcoexist->adapter;
660
661 rtl_set_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask, data);
662 }
663
664
665 static u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, u32 reg_addr,
666 u32 bit_mask)
667 {
668 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
669 struct rtl_priv *rtlpriv = btcoexist->adapter;
670
671 return rtl_get_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask);
672 }
673
674
675 static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id,
676 u32 cmd_len, u8 *cmd_buf)
677 {
678 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
679 struct rtl_priv *rtlpriv = btcoexist->adapter;
680
681 rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, element_id,
682 cmd_len, cmd_buf);
683 }
684
685 static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type)
686 {
687 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
688 switch (disp_type) {
689 case BTC_DBG_DISP_COEX_STATISTICS:
690 halbtc_display_coex_statistics(btcoexist);
691 break;
692 case BTC_DBG_DISP_BT_LINK_INFO:
693 halbtc_display_bt_link_info(btcoexist);
694 break;
695 case BTC_DBG_DISP_BT_FW_VER:
696 halbtc_display_bt_fw_info(btcoexist);
697 break;
698 case BTC_DBG_DISP_FW_PWR_MODE_CMD:
699 halbtc_display_fw_pwr_mode_cmd(btcoexist);
700 break;
701 default:
702 break;
703 }
704 }
705
706 static bool halbtc_under_ips(struct btc_coexist *btcoexist)
707 {
708 struct rtl_priv *rtlpriv = btcoexist->adapter;
709 struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
710 enum rf_pwrstate rtstate;
711
712 if (ppsc->b_inactiveps) {
713 rtstate = ppsc->rfpwr_state;
714
715 if (rtstate != ERFON &&
716 ppsc->rfoff_reason == RF_CHANGE_BY_IPS)
717 return true;
718 }
719
720 return false;
721 }
722
723 /*****************************************************************
724 * Extern functions called by other module
725 *****************************************************************/
726 bool exhalbtc92e_initlize_variables(struct rtl_priv *adapter)
727 {
728 struct btc_coexist *btcoexist = &gl92e_bt_coexist;
729
730 btcoexist->statistics.cnt_bind++;
731
732 halbtc_dbg_init();
733
734 if (btcoexist->binded)
735 return false;
736 else
737 btcoexist->binded = true;
738
739 btcoexist->chip_interface = BTC_INTF_UNKNOWN;
740
741 if (NULL == btcoexist->adapter)
742 btcoexist->adapter = adapter;
743
744 btcoexist->stack_info.profile_notified = false;
745
746 btcoexist->btc_read_1byte = halbtc_read_1byte;
747 btcoexist->btc_write_1byte = halbtc_write_1byte;
748 btcoexist->btc_write_1byte_bitmask = halbtc_bitmask_write_1byte;
749 btcoexist->btc_read_2byte = halbtc_read_2byte;
750 btcoexist->btc_write_2byte = halbtc_write_2byte;
751 btcoexist->btc_read_4byte = halbtc_read_4byte;
752 btcoexist->btc_write_4byte = halbtc_write_4byte;
753
754 btcoexist->btc_set_bb_reg = halbtc_set_bbreg;
755 btcoexist->btc_get_bb_reg = halbtc_get_bbreg;
756
757 btcoexist->btc_set_rf_reg = halbtc_set_rfreg;
758 btcoexist->btc_get_rf_reg = halbtc_get_rfreg;
759
760 btcoexist->btc_fill_h2c = halbtc_fill_h2c_cmd;
761 btcoexist->btc_disp_dbg_msg = halbtc_display_dbg_msg;
762
763 btcoexist->btc_get = halbtc_get;
764 btcoexist->btc_set = halbtc_set;
765
766 btcoexist->cli_buf = &btc_dbg_buf[0];
767
768 btcoexist->bt_info.b_bt_ctrl_buf_size = false;
769 btcoexist->bt_info.agg_buf_size = 5;
770
771 btcoexist->bt_info.increase_scan_dev_num = false;
772 return true;
773 }
774
775 void exhalbtc92e_init_hw_config(struct btc_coexist *btcoexist)
776 {
777 struct rtl_priv *rtlpriv = btcoexist->adapter;
778 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
779
780 if (!halbtc_is_bt_coexist_available(btcoexist))
781 return;
782
783 btcoexist->statistics.cnt_init_hw_config++;
784
785 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
786 if (btcoexist->board_info.btdm_ant_num == 2)
787 ex92e_halbtc8723b2ant_init_hwconfig(btcoexist);
788 else if (btcoexist->board_info.btdm_ant_num == 1)
789 ex_halbtc8723b1ant_init_hwconfig(btcoexist);
790 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
791 ex_halbtc8192e2ant_init_hwconfig(btcoexist);
792 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
793 if (btcoexist->board_info.btdm_ant_num == 2)
794 ex_halbtc8821a2ant_init_hwconfig(btcoexist);
795 else if (btcoexist->board_info.btdm_ant_num == 1)
796 ex_halbtc8821a1ant_init_hwconfig(btcoexist);
797 }
798 }
799
800 void exhalbtc92e_init_coex_dm(struct btc_coexist *btcoexist)
801 {
802 struct rtl_priv *rtlpriv = btcoexist->adapter;
803 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
804
805 if (!halbtc_is_bt_coexist_available(btcoexist))
806 return;
807
808 btcoexist->statistics.cnt_init_coex_dm++;
809
810 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
811 if (btcoexist->board_info.btdm_ant_num == 2)
812 ex92e_halbtc8723b2ant_init_coex_dm(btcoexist);
813 else if (btcoexist->board_info.btdm_ant_num == 1)
814 ex_halbtc8723b1ant_init_coex_dm(btcoexist);
815 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
816 ex_halbtc8192e2ant_init_coex_dm(btcoexist);
817 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
818 if (btcoexist->board_info.btdm_ant_num == 2)
819 ex_halbtc8821a2ant_init_coex_dm(btcoexist);
820 else if (btcoexist->board_info.btdm_ant_num == 1)
821 ex_halbtc8821a1ant_init_coex_dm(btcoexist);
822 }
823
824 btcoexist->initilized = true;
825 }
826
827 void exhalbtc92e_ips_notify(struct btc_coexist *btcoexist, u8 type)
828 {
829 struct rtl_priv *rtlpriv = btcoexist->adapter;
830 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
831 u8 ips_type;
832
833 if (!halbtc_is_bt_coexist_available(btcoexist))
834 return;
835 btcoexist->statistics.cnt_ips_notify++;
836 if (btcoexist->manual_control)
837 return;
838
839 if (ERFOFF == type)
840 ips_type = BTC_IPS_ENTER;
841 else
842 ips_type = BTC_IPS_LEAVE;
843
844 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
845 if (btcoexist->board_info.btdm_ant_num == 2)
846 ex92e_halbtc8723b2ant_ips_notify(btcoexist, ips_type);
847 else if (btcoexist->board_info.btdm_ant_num == 1)
848 ex_halbtc8723b1ant_ips_notify(btcoexist, ips_type);
849 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
850 ex_halbtc8192e2ant_ips_notify(btcoexist, ips_type);
851 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
852 if (btcoexist->board_info.btdm_ant_num == 2)
853 ex_halbtc8821a2ant_ips_notify(btcoexist, ips_type);
854 else if (btcoexist->board_info.btdm_ant_num == 1)
855 ex_halbtc8821a1ant_ips_notify(btcoexist, ips_type);
856 }
857 }
858
859 void exhalbtc92e_lps_notify(struct btc_coexist *btcoexist, u8 type)
860 {
861 struct rtl_priv *rtlpriv = btcoexist->adapter;
862 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
863 u8 lps_type;
864
865 if (!halbtc_is_bt_coexist_available(btcoexist))
866 return;
867 btcoexist->statistics.cnt_lps_notify++;
868 if (btcoexist->manual_control)
869 return;
870
871 if (EACTIVE == type)
872 lps_type = BTC_LPS_DISABLE;
873 else
874 lps_type = BTC_LPS_ENABLE;
875
876 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
877 if (btcoexist->board_info.btdm_ant_num == 2)
878 ex92e_halbtc8723b2ant_lps_notify(btcoexist, lps_type);
879 else if (btcoexist->board_info.btdm_ant_num == 1)
880 ex_halbtc8723b1ant_lps_notify(btcoexist, lps_type);
881 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
882 ex_halbtc8192e2ant_lps_notify(btcoexist, lps_type);
883 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
884 if (btcoexist->board_info.btdm_ant_num == 2)
885 ex_halbtc8821a2ant_lps_notify(btcoexist, lps_type);
886 else if (btcoexist->board_info.btdm_ant_num == 1)
887 ex_halbtc8821a1ant_lps_notify(btcoexist, lps_type);
888 }
889 }
890
891 void exhalbtc92e_scan_notify(struct btc_coexist *btcoexist, u8 type)
892 {
893 struct rtl_priv *rtlpriv = btcoexist->adapter;
894 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
895 u8 scan_type;
896
897 if (!halbtc_is_bt_coexist_available(btcoexist))
898 return;
899 btcoexist->statistics.cnt_scan_notify++;
900 if (btcoexist->manual_control)
901 return;
902
903 if (type)
904 scan_type = BTC_SCAN_START;
905 else
906 scan_type = BTC_SCAN_FINISH;
907
908 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
909 if (btcoexist->board_info.btdm_ant_num == 2)
910 ex92e_halbtc8723b2ant_scan_notify(btcoexist, scan_type);
911 else if (btcoexist->board_info.btdm_ant_num == 1)
912 ex_halbtc8723b1ant_scan_notify(btcoexist, scan_type);
913 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
914 ex_halbtc8192e2ant_scan_notify(btcoexist, scan_type);
915 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
916 if (btcoexist->board_info.btdm_ant_num == 2)
917 ex_halbtc8821a2ant_scan_notify(btcoexist, scan_type);
918 else if (btcoexist->board_info.btdm_ant_num == 1)
919 ex_halbtc8821a1ant_scan_notify(btcoexist, scan_type);
920 }
921 }
922
923 void exhalbtc92e_connect_notify(struct btc_coexist *btcoexist, u8 action)
924 {
925 struct rtl_priv *rtlpriv = btcoexist->adapter;
926 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
927 u8 asso_type;
928
929 if (!halbtc_is_bt_coexist_available(btcoexist))
930 return;
931 btcoexist->statistics.cnt_connect_notify++;
932 if (btcoexist->manual_control)
933 return;
934
935 if (action)
936 asso_type = BTC_ASSOCIATE_START;
937 else
938 asso_type = BTC_ASSOCIATE_FINISH;
939
940 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
941 if (btcoexist->board_info.btdm_ant_num == 2)
942 ex92e_halbtc8723b2ant_connect_notify(btcoexist,
943 asso_type);
944 else if (btcoexist->board_info.btdm_ant_num == 1)
945 ex_halbtc8723b1ant_connect_notify(btcoexist, asso_type);
946 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
947 ex_halbtc8192e2ant_connect_notify(btcoexist, asso_type);
948 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
949 if (btcoexist->board_info.btdm_ant_num == 2)
950 ex_halbtc8821a2ant_connect_notify(btcoexist,
951 asso_type);
952 else if (btcoexist->board_info.btdm_ant_num == 1)
953 ex_halbtc8821a1ant_connect_notify(btcoexist,
954 asso_type);
955 }
956 }
957
958 void exhalbtc92e_mediastatus_notify(struct btc_coexist *btcoexist,
959 enum rt_media_status media_status)
960 {
961 struct rtl_priv *rtlpriv = btcoexist->adapter;
962 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
963 u8 status;
964
965 if (!halbtc_is_bt_coexist_available(btcoexist))
966 return;
967 btcoexist->statistics.cnt_media_status_notify++;
968 if (btcoexist->manual_control)
969 return;
970
971 if (RT_MEDIA_CONNECT == media_status)
972 status = BTC_MEDIA_CONNECT;
973 else
974 status = BTC_MEDIA_DISCONNECT;
975
976 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
977 if (btcoexist->board_info.btdm_ant_num == 2)
978 ex92e_halbtc8723b2ant_media_status_notify(btcoexist,
979 status);
980 else if (btcoexist->board_info.btdm_ant_num == 1)
981 ex_halbtc8723b1ant_media_status_notify(btcoexist,
982 status);
983 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
984 ex_halbtc8192e2ant_media_status_notify(btcoexist, status);
985 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
986 if (btcoexist->board_info.btdm_ant_num == 2)
987 ex_halbtc8821a2ant_media_status_notify(btcoexist,
988 status);
989 else if (btcoexist->board_info.btdm_ant_num == 1)
990 ex_halbtc8821a1ant_media_status_notify(btcoexist,
991 status);
992 }
993 }
994
995 void exhalbtc92e_special_packet_notify(struct btc_coexist *btcoexist,
996 u8 pkt_type)
997 {
998 struct rtl_priv *rtlpriv = btcoexist->adapter;
999 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1000 u8 packet_type;
1001
1002 if (!halbtc_is_bt_coexist_available(btcoexist))
1003 return;
1004 btcoexist->statistics.cnt_special_packet_notify++;
1005 if (btcoexist->manual_control)
1006 return;
1007
1008 if (PACKET_DHCP == pkt_type) {
1009 packet_type = BTC_PACKET_DHCP;
1010 } else if (PACKET_EAPOL == pkt_type) {
1011 packet_type = BTC_PACKET_EAPOL;
1012 } else if (PACKET_ARP == pkt_type) {
1013 packet_type = BTC_PACKET_ARP;
1014 } else {
1015 packet_type = BTC_PACKET_UNKNOWN;
1016 return;
1017 }
1018
1019 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
1020 if (btcoexist->board_info.btdm_ant_num == 2)
1021 ex92e_halbtc8723b2ant_special_packet_notify(btcoexist,
1022 packet_type);
1023 else if (btcoexist->board_info.btdm_ant_num == 1)
1024 ex_halbtc8723b1ant_special_packet_notify(btcoexist,
1025 packet_type);
1026 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
1027 if (btcoexist->board_info.btdm_ant_num == 2)
1028 ex_halbtc8821a2ant_special_packet_notify(btcoexist,
1029 packet_type);
1030 else if (btcoexist->board_info.btdm_ant_num == 1)
1031 ex_halbtc8821a1ant_special_packet_notify(btcoexist,
1032 packet_type);
1033 }
1034 }
1035
1036 void exhalbtc92e_bt_info_notify(struct btc_coexist *btcoexist,
1037 u8 *tmp_buf, u8 length)
1038 {
1039 struct rtl_priv *rtlpriv = btcoexist->adapter;
1040 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1041 if (!halbtc_is_bt_coexist_available(btcoexist))
1042 return;
1043 btcoexist->statistics.cnt_bt_info_notify++;
1044
1045 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
1046 if (btcoexist->board_info.btdm_ant_num == 2)
1047 ex92e_halbtc8723b2ant_bt_info_notify(btcoexist,
1048 tmp_buf, length);
1049 else if (btcoexist->board_info.btdm_ant_num == 1)
1050 ex_halbtc8723b1ant_bt_info_notify(btcoexist, tmp_buf,
1051 length);
1052 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
1053 /* ex_halbtc8192e2ant_bt_info_notify(btcoexist,
1054 tmp_buf, length); */
1055 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
1056 if (btcoexist->board_info.btdm_ant_num == 2)
1057 ex_halbtc8821a2ant_bt_info_notify(btcoexist,
1058 tmp_buf, length);
1059 else if (btcoexist->board_info.btdm_ant_num == 1)
1060 ex_halbtc8821a1ant_bt_info_notify(btcoexist,
1061 tmp_buf, length);
1062 }
1063 }
1064
1065 void exhalbtc92e_stack_operation_notify(struct btc_coexist *btcoexist, u8 type)
1066 {
1067 u8 stack_op_type;
1068
1069 if (!halbtc_is_bt_coexist_available(btcoexist))
1070 return;
1071 btcoexist->statistics.cnt_stack_operation_notify++;
1072 if (btcoexist->manual_control)
1073 return;
1074
1075 if ((HCI_BT_OP_INQUIRY_START == type) ||
1076 (HCI_BT_OP_PAGING_START == type) ||
1077 (HCI_BT_OP_PAIRING_START == type))
1078 stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_START;
1079 else if ((HCI_BT_OP_INQUIRY_FINISH == type) ||
1080 (HCI_BT_OP_PAGING_SUCCESS == type) ||
1081 (HCI_BT_OP_PAGING_UNSUCCESS == type) ||
1082 (HCI_BT_OP_PAIRING_FINISH == type))
1083 stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH;
1084 else
1085 stack_op_type = BTC_STACK_OP_NONE;
1086 }
1087
1088 void exhalbtc92e_halt_notify(struct btc_coexist *btcoexist)
1089 {
1090 struct rtl_priv *rtlpriv = btcoexist->adapter;
1091 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1092 if (!halbtc_is_bt_coexist_available(btcoexist))
1093 return;
1094
1095 btcoexist->binded = false;
1096
1097 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
1098 if (btcoexist->board_info.btdm_ant_num == 2)
1099 ex92e_halbtc8723b2ant_halt_notify(btcoexist);
1100 else if (btcoexist->board_info.btdm_ant_num == 1)
1101 ex_halbtc8723b1ant_halt_notify(btcoexist);
1102 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
1103 ex_halbtc8192e2ant_halt_notify(btcoexist);
1104 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
1105 if (btcoexist->board_info.btdm_ant_num == 2)
1106 ex_halbtc8821a2ant_halt_notify(btcoexist);
1107 else if (btcoexist->board_info.btdm_ant_num == 1)
1108 ex_halbtc8821a1ant_halt_notify(btcoexist);
1109 }
1110 }
1111
1112 void exhalbtc92e_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
1113 {
1114 struct rtl_priv *rtlpriv = btcoexist->adapter;
1115 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1116
1117 if (!halbtc_is_bt_coexist_available(btcoexist))
1118 return;
1119
1120 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
1121 if (btcoexist->board_info.btdm_ant_num == 1)
1122 ex_halbtc8723b1ant_pnp_notify(btcoexist, pnp_state);
1123 }
1124 }
1125
1126 void exhalbtc_coex_dm_switch(struct btc_coexist *btcoexist)
1127 {
1128 struct rtl_priv *rtlpriv = btcoexist->adapter;
1129 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1130 if (!halbtc_is_bt_coexist_available(btcoexist))
1131 return;
1132 btcoexist->statistics.cnt_coex_dm_switch++;
1133
1134 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
1135 if (btcoexist->board_info.btdm_ant_num == 1) {
1136 btcoexist->stop_coex_dm = true;
1137 ex_halbtc8723b1ant_coex_dm_reset(btcoexist);
1138 exhalbtc92e_set_ant_num(BT_COEX_ANT_TYPE_DETECTED, 2);
1139 ex92e_halbtc8723b2ant_init_hwconfig(btcoexist);
1140 ex92e_halbtc8723b2ant_init_coex_dm(btcoexist);
1141 btcoexist->stop_coex_dm = false;
1142 }
1143 }
1144 }
1145
1146 void exhalbtc92e_periodical(struct btc_coexist *btcoexist)
1147 {
1148 struct rtl_priv *rtlpriv = btcoexist->adapter;
1149 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1150 if (!halbtc_is_bt_coexist_available(btcoexist))
1151 return;
1152 btcoexist->statistics.cnt_periodical++;
1153
1154 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
1155 if (btcoexist->board_info.btdm_ant_num == 2)
1156 ex92e_halbtc8723b2ant_periodical(btcoexist);
1157 else if (btcoexist->board_info.btdm_ant_num == 1)
1158 ex_halbtc8723b1ant_periodical(btcoexist);
1159 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
1160 ex_halbtc8192e2ant_periodical(btcoexist);
1161 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
1162 if (btcoexist->board_info.btdm_ant_num == 2)
1163 ex_halbtc8821a2ant_periodical(btcoexist);
1164 else if (btcoexist->board_info.btdm_ant_num == 1)
1165 if (!halbtc_under_ips(btcoexist))
1166 ex_halbtc8821a1ant_periodical(btcoexist);
1167 }
1168 }
1169
1170 void exhalbtc92e_dbg_control(struct btc_coexist *btcoexist,
1171 u8 code, u8 len, u8 *data)
1172 {
1173 if (!halbtc_is_bt_coexist_available(btcoexist))
1174 return;
1175 btcoexist->statistics.cnt_dbg_ctrl++;
1176 }
1177
1178 void exhalbtc92e_stack_update_profile_info(void)
1179 {
1180 }
1181
1182 void exhalbtc92e_update_min_bt_rssi(char bt_rssi)
1183 {
1184 struct btc_coexist *btcoexist = &gl92e_bt_coexist;
1185
1186 if (!halbtc_is_bt_coexist_available(btcoexist))
1187 return;
1188
1189 btcoexist->stack_info.min_bt_rssi = bt_rssi;
1190 }
1191
1192
1193 void exhalbtc92e_set_hci_version(u16 hci_version)
1194 {
1195 struct btc_coexist *btcoexist = &gl92e_bt_coexist;
1196
1197 if (!halbtc_is_bt_coexist_available(btcoexist))
1198 return;
1199
1200 btcoexist->stack_info.hci_version = hci_version;
1201 }
1202
1203 void exhalbtc92e_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version)
1204 {
1205 struct btc_coexist *btcoexist = &gl92e_bt_coexist;
1206
1207 if (!halbtc_is_bt_coexist_available(btcoexist))
1208 return;
1209
1210 btcoexist->bt_info.bt_real_fw_ver = bt_patch_version;
1211 btcoexist->bt_info.bt_hci_ver = bt_hci_version;
1212 }
1213
1214 void exhalbtc92e_set_bt_exist(bool bt_exist)
1215 {
1216 gl92e_bt_coexist.board_info.bt_exist = bt_exist;
1217 }
1218
1219 void exhalbtc92e_set_chip_type(u8 chip_type)
1220 {
1221 switch (chip_type) {
1222 default:
1223 case BT_2WIRE:
1224 case BT_ISSC_3WIRE:
1225 case BT_ACCEL:
1226 case BT_RTL8756:
1227 gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_UNDEF;
1228 break;
1229 case BT_CSR_BC4:
1230 gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
1231 break;
1232 case BT_CSR_BC8:
1233 gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
1234 break;
1235 case BT_RTL8723A:
1236 gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A;
1237 break;
1238 case BT_RTL8821A:
1239 gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8821;
1240 break;
1241 case BT_RTL8723B:
1242 gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B;
1243 break;
1244 }
1245 }
1246
1247 void exhalbtc92e_set_ant_num(u8 type, u8 ant_num)
1248 {
1249 if (BT_COEX_ANT_TYPE_PG == type) {
1250 gl92e_bt_coexist.board_info.pg_ant_num = ant_num;
1251 gl92e_bt_coexist.board_info.btdm_ant_num = ant_num;
1252 /* The antenna position:
1253 * Main (default) or Aux for pgAntNum = 2 && btdmAntNum = 1.
1254 * The antenna position should be determined by
1255 * auto-detect mechanism.
1256 * The following is assumed to main,
1257 * and those must be modified
1258 * if y auto-detect mechanism is ready
1259 */
1260 if ((gl92e_bt_coexist.board_info.pg_ant_num == 2) &&
1261 (gl92e_bt_coexist.board_info.btdm_ant_num == 1))
1262 gl92e_bt_coexist.board_info.btdm_ant_pos =
1263 BTC_ANTENNA_AT_MAIN_PORT;
1264 else
1265 gl92e_bt_coexist.board_info.btdm_ant_pos =
1266 BTC_ANTENNA_AT_MAIN_PORT;
1267 } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
1268 gl92e_bt_coexist.board_info.btdm_ant_num = ant_num;
1269 gl92e_bt_coexist.board_info.btdm_ant_pos =
1270 BTC_ANTENNA_AT_MAIN_PORT;
1271 } else if (BT_COEX_ANT_TYPE_DETECTED == type) {
1272 gl92e_bt_coexist.board_info.btdm_ant_num = ant_num;
1273 gl92e_bt_coexist.board_info.btdm_ant_pos =
1274 BTC_ANTENNA_AT_MAIN_PORT;
1275 }
1276 }
1277
1278 void exhalbtc92e_display_bt_coex_info(struct btc_coexist *btcoexist)
1279 {
1280 struct rtl_priv *rtlpriv = btcoexist->adapter;
1281 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1282
1283 if (!halbtc_is_bt_coexist_available(btcoexist))
1284 return;
1285
1286 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
1287 if (btcoexist->board_info.btdm_ant_num == 2)
1288 ex_halbtc8723b2ant92e_display_coex_info(btcoexist);
1289 else if (btcoexist->board_info.btdm_ant_num == 1)
1290 ex_halbtc8723b1ant_display_coex_info(btcoexist);
1291 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
1292 if (btcoexist->board_info.btdm_ant_num == 2)
1293 ex_halbtc8821a2ant_display_coex_info(btcoexist);
1294 else if (btcoexist->board_info.btdm_ant_num == 1)
1295 ex_halbtc8821a1ant_display_coex_info(btcoexist);
1296 }
1297 }
This page took 0.071409 seconds and 5 git commands to generate.