Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 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 | * The full GNU General Public License is included in this distribution in the |
| 15 | * file called LICENSE. |
| 16 | * |
| 17 | * Contact Information: |
| 18 | * wlanfae <wlanfae@realtek.com> |
| 19 | * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, |
| 20 | * Hsinchu 300, Taiwan. |
| 21 | * |
| 22 | * Larry Finger <Larry.Finger@lwfinger.net> |
| 23 | * |
| 24 | ******************************************************************************/ |
| 25 | |
| 26 | #include "halbt_precomp.h" |
| 27 | |
| 28 | /*********************************************** |
| 29 | * Global variables |
| 30 | ***********************************************/ |
| 31 | |
| 32 | struct btc_coexist gl_bt_coexist; |
| 33 | |
| 34 | u32 btc_dbg_type[BTC_MSG_MAX]; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 35 | |
| 36 | /*************************************************** |
| 37 | * Debug related function |
| 38 | ***************************************************/ |
| 39 | static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist) |
| 40 | { |
| 41 | if (!btcoexist->binded || NULL == btcoexist->adapter) |
| 42 | return false; |
| 43 | |
| 44 | return true; |
| 45 | } |
| 46 | |
| 47 | static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv) |
| 48 | { |
| 49 | if (rtlpriv->link_info.busytraffic) |
| 50 | return true; |
| 51 | else |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | static void halbtc_dbg_init(void) |
| 56 | { |
| 57 | u8 i; |
| 58 | |
| 59 | for (i = 0; i < BTC_MSG_MAX; i++) |
| 60 | btc_dbg_type[i] = 0; |
| 61 | |
| 62 | btc_dbg_type[BTC_MSG_INTERFACE] = |
| 63 | /* INTF_INIT | */ |
| 64 | /* INTF_NOTIFY | */ |
| 65 | 0; |
| 66 | |
| 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 | */ |
| 78 | 0; |
| 79 | } |
| 80 | |
| 81 | static bool halbtc_is_bt40(struct rtl_priv *adapter) |
| 82 | { |
| 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; |
| 87 | |
| 88 | if (bw == HT_CHANNEL_WIDTH_20) |
| 89 | is_ht40 = false; |
| 90 | else if (bw == HT_CHANNEL_WIDTH_20_40) |
| 91 | is_ht40 = true; |
| 92 | |
| 93 | return is_ht40; |
| 94 | } |
| 95 | |
| 96 | static bool halbtc_legacy(struct rtl_priv *adapter) |
| 97 | { |
| 98 | struct rtl_priv *rtlpriv = adapter; |
| 99 | struct rtl_mac *mac = rtl_mac(rtlpriv); |
| 100 | |
| 101 | bool is_legacy = false; |
| 102 | |
Himangi Saraogi | e5cd6ce | 2014-08-13 01:09:29 +0530 | [diff] [blame] | 103 | if ((mac->mode == WIRELESS_MODE_B) || (mac->mode == WIRELESS_MODE_G)) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 104 | is_legacy = true; |
| 105 | |
| 106 | return is_legacy; |
| 107 | } |
| 108 | |
| 109 | bool halbtc_is_wifi_uplink(struct rtl_priv *adapter) |
| 110 | { |
| 111 | struct rtl_priv *rtlpriv = adapter; |
| 112 | |
| 113 | if (rtlpriv->link_info.tx_busy_traffic) |
| 114 | return true; |
| 115 | else |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | static u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist) |
| 120 | { |
| 121 | struct rtl_priv *rtlpriv = |
| 122 | (struct rtl_priv *)btcoexist->adapter; |
| 123 | u32 wifi_bw = BTC_WIFI_BW_HT20; |
| 124 | |
| 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; |
| 132 | } |
| 133 | return wifi_bw; |
| 134 | } |
| 135 | |
| 136 | static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist) |
| 137 | { |
| 138 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 139 | struct rtl_phy *rtlphy = &(rtlpriv->phy); |
| 140 | u8 chnl = 1; |
| 141 | |
| 142 | if (rtlphy->current_channel != 0) |
| 143 | chnl = rtlphy->current_channel; |
Joe Perches | 466414a | 2016-03-17 17:00:21 -0700 | [diff] [blame] | 144 | btc_alg_dbg(ALGO_TRACE, |
| 145 | "static halbtc_get_wifi_central_chnl:%d\n", chnl); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 146 | return chnl; |
| 147 | } |
| 148 | |
| 149 | static void halbtc_leave_lps(struct btc_coexist *btcoexist) |
| 150 | { |
| 151 | struct rtl_priv *rtlpriv; |
| 152 | struct rtl_ps_ctl *ppsc; |
| 153 | bool ap_enable = false; |
| 154 | |
| 155 | rtlpriv = btcoexist->adapter; |
| 156 | ppsc = rtl_psc(rtlpriv); |
| 157 | |
| 158 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, |
| 159 | &ap_enable); |
| 160 | |
| 161 | if (ap_enable) { |
| 162 | pr_info("halbtc_leave_lps()<--dont leave lps under AP mode\n"); |
| 163 | return; |
| 164 | } |
| 165 | |
| 166 | btcoexist->bt_info.bt_ctrl_lps = true; |
| 167 | btcoexist->bt_info.bt_lps_on = false; |
| 168 | } |
| 169 | |
| 170 | static void halbtc_enter_lps(struct btc_coexist *btcoexist) |
| 171 | { |
| 172 | struct rtl_priv *rtlpriv; |
| 173 | struct rtl_ps_ctl *ppsc; |
| 174 | bool ap_enable = false; |
| 175 | |
| 176 | rtlpriv = btcoexist->adapter; |
| 177 | ppsc = rtl_psc(rtlpriv); |
| 178 | |
| 179 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, |
| 180 | &ap_enable); |
| 181 | |
| 182 | if (ap_enable) { |
| 183 | pr_info("halbtc_enter_lps()<--dont enter lps under AP mode\n"); |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | btcoexist->bt_info.bt_ctrl_lps = true; |
| 188 | btcoexist->bt_info.bt_lps_on = false; |
| 189 | } |
| 190 | |
| 191 | static void halbtc_normal_lps(struct btc_coexist *btcoexist) |
| 192 | { |
| 193 | if (btcoexist->bt_info.bt_ctrl_lps) { |
| 194 | btcoexist->bt_info.bt_lps_on = false; |
| 195 | btcoexist->bt_info.bt_ctrl_lps = false; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | static void halbtc_leave_low_power(void) |
| 200 | { |
| 201 | } |
| 202 | |
| 203 | static void halbtc_nomal_low_power(void) |
| 204 | { |
| 205 | } |
| 206 | |
| 207 | static void halbtc_disable_low_power(void) |
| 208 | { |
| 209 | } |
| 210 | |
| 211 | static void halbtc_aggregation_check(void) |
| 212 | { |
| 213 | } |
| 214 | |
| 215 | static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist) |
| 216 | { |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | static s32 halbtc_get_wifi_rssi(struct rtl_priv *adapter) |
| 221 | { |
| 222 | struct rtl_priv *rtlpriv = adapter; |
| 223 | s32 undec_sm_pwdb = 0; |
| 224 | |
| 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; |
| 230 | } |
| 231 | |
| 232 | static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) |
| 233 | { |
| 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; |
| 244 | |
| 245 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 246 | return false; |
| 247 | |
| 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; |
| 286 | |
| 287 | break; |
| 288 | case BTC_GET_BL_WIFI_UNDER_5G: |
| 289 | *bool_tmp = false; /*TODO*/ |
| 290 | |
| 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; |
| 350 | |
| 351 | /************* 1Ant **************/ |
| 352 | case BTC_GET_U1_LPS_MODE: |
| 353 | *u8_tmp = btcoexist->pwr_mode_val[0]; |
| 354 | break; |
| 355 | |
| 356 | default: |
| 357 | break; |
| 358 | } |
| 359 | |
| 360 | return true; |
| 361 | } |
| 362 | |
| 363 | static bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf) |
| 364 | { |
| 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; |
| 369 | |
| 370 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 371 | return false; |
| 372 | |
| 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: |
Larry Finger | ed364ab | 2014-09-04 16:03:46 -0500 | [diff] [blame] | 391 | btcoexist->bt_info.bt_ctrl_buf_size = *bool_tmp; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 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; |
| 410 | |
| 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: |
Larry Finger | ed364ab | 2014-09-04 16:03:46 -0500 | [diff] [blame] | 419 | btcoexist->bt_info.lps_val = *u8_tmp; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 420 | break; |
| 421 | case BTC_SET_U1_1ANT_RPWM: |
Larry Finger | ed364ab | 2014-09-04 16:03:46 -0500 | [diff] [blame] | 422 | btcoexist->bt_info.rpwm_val = *u8_tmp; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 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; |
| 451 | } |
| 452 | |
| 453 | return true; |
| 454 | } |
| 455 | |
| 456 | static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist) |
| 457 | { |
| 458 | } |
| 459 | |
| 460 | static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist) |
| 461 | { |
| 462 | } |
| 463 | |
| 464 | static void halbtc_display_bt_fw_info(struct btc_coexist *btcoexist) |
| 465 | { |
| 466 | } |
| 467 | |
| 468 | static void halbtc_display_fw_pwr_mode_cmd(struct btc_coexist *btcoexist) |
| 469 | { |
| 470 | } |
| 471 | |
| 472 | /************************************************************ |
| 473 | * IO related function |
| 474 | ************************************************************/ |
| 475 | static u8 halbtc_read_1byte(void *bt_context, u32 reg_addr) |
| 476 | { |
| 477 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 478 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 479 | |
| 480 | return rtl_read_byte(rtlpriv, reg_addr); |
| 481 | } |
| 482 | |
| 483 | static u16 halbtc_read_2byte(void *bt_context, u32 reg_addr) |
| 484 | { |
| 485 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 486 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 487 | |
| 488 | return rtl_read_word(rtlpriv, reg_addr); |
| 489 | } |
| 490 | |
| 491 | static u32 halbtc_read_4byte(void *bt_context, u32 reg_addr) |
| 492 | { |
| 493 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 494 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 495 | |
| 496 | return rtl_read_dword(rtlpriv, reg_addr); |
| 497 | } |
| 498 | |
Larry Finger | dbb30eb | 2014-09-09 15:57:46 -0500 | [diff] [blame] | 499 | static void halbtc_write_1byte(void *bt_context, u32 reg_addr, u32 data) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 500 | { |
| 501 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 502 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 503 | |
| 504 | rtl_write_byte(rtlpriv, reg_addr, data); |
| 505 | } |
| 506 | |
| 507 | static void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr, |
Larry Finger | 560e334 | 2014-09-22 09:39:17 -0500 | [diff] [blame] | 508 | u32 bit_mask, u8 data) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 509 | { |
| 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; |
| 514 | |
| 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; |
| 520 | } |
| 521 | bit_shift = i; |
| 522 | data = (original_value & (~bit_mask)) | |
| 523 | ((data << bit_shift) & bit_mask); |
| 524 | } |
| 525 | rtl_write_byte(rtlpriv, reg_addr, data); |
| 526 | } |
| 527 | |
| 528 | static void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data) |
| 529 | { |
| 530 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 531 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 532 | |
| 533 | rtl_write_word(rtlpriv, reg_addr, data); |
| 534 | } |
| 535 | |
| 536 | static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data) |
| 537 | { |
| 538 | struct btc_coexist *btcoexist = |
| 539 | (struct btc_coexist *)bt_context; |
| 540 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 541 | |
| 542 | rtl_write_dword(rtlpriv, reg_addr, data); |
| 543 | } |
| 544 | |
| 545 | static void halbtc_set_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask, |
| 546 | u32 data) |
| 547 | { |
| 548 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 549 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 550 | |
| 551 | rtl_set_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask, data); |
| 552 | } |
| 553 | |
| 554 | static u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask) |
| 555 | { |
| 556 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 557 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 558 | |
| 559 | return rtl_get_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask); |
| 560 | } |
| 561 | |
| 562 | static void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, |
| 563 | u32 bit_mask, u32 data) |
| 564 | { |
| 565 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 566 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 567 | |
| 568 | rtl_set_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask, data); |
| 569 | } |
| 570 | |
| 571 | static u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, |
| 572 | u32 bit_mask) |
| 573 | { |
| 574 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 575 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 576 | |
| 577 | return rtl_get_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask); |
| 578 | } |
| 579 | |
| 580 | static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id, |
| 581 | u32 cmd_len, u8 *cmd_buf) |
| 582 | { |
| 583 | struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; |
| 584 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 585 | |
| 586 | rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, element_id, |
| 587 | cmd_len, cmd_buf); |
| 588 | } |
| 589 | |
| 590 | static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type) |
| 591 | { |
| 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; |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | /***************************************************************** |
| 612 | * Extern functions called by other module |
| 613 | *****************************************************************/ |
| 614 | bool exhalbtc_initlize_variables(struct rtl_priv *adapter) |
| 615 | { |
| 616 | struct btc_coexist *btcoexist = &gl_bt_coexist; |
| 617 | |
| 618 | btcoexist->statistics.cnt_bind++; |
| 619 | |
| 620 | halbtc_dbg_init(); |
| 621 | |
| 622 | if (btcoexist->binded) |
| 623 | return false; |
| 624 | else |
| 625 | btcoexist->binded = true; |
| 626 | |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 627 | btcoexist->chip_interface = BTC_INTF_UNKNOWN; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 628 | |
| 629 | if (NULL == btcoexist->adapter) |
| 630 | btcoexist->adapter = adapter; |
| 631 | |
| 632 | btcoexist->stack_info.profile_notified = false; |
| 633 | |
| 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; |
| 641 | |
| 642 | btcoexist->btc_set_bb_reg = halbtc_set_bbreg; |
| 643 | btcoexist->btc_get_bb_reg = halbtc_get_bbreg; |
| 644 | |
| 645 | btcoexist->btc_set_rf_reg = halbtc_set_rfreg; |
| 646 | btcoexist->btc_get_rf_reg = halbtc_get_rfreg; |
| 647 | |
| 648 | btcoexist->btc_fill_h2c = halbtc_fill_h2c_cmd; |
| 649 | btcoexist->btc_disp_dbg_msg = halbtc_display_dbg_msg; |
| 650 | |
| 651 | btcoexist->btc_get = halbtc_get; |
| 652 | btcoexist->btc_set = halbtc_set; |
| 653 | |
Larry Finger | ed364ab | 2014-09-04 16:03:46 -0500 | [diff] [blame] | 654 | btcoexist->bt_info.bt_ctrl_buf_size = false; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 655 | btcoexist->bt_info.agg_buf_size = 5; |
| 656 | |
| 657 | btcoexist->bt_info.increase_scan_dev_num = false; |
| 658 | return true; |
| 659 | } |
| 660 | |
| 661 | void exhalbtc_init_hw_config(struct btc_coexist *btcoexist) |
| 662 | { |
| 663 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 664 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
| 665 | |
| 666 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 667 | return; |
| 668 | |
| 669 | btcoexist->statistics.cnt_init_hw_config++; |
| 670 | |
| 671 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 672 | ex_btc8723b2ant_init_hwconfig(btcoexist); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist) |
| 676 | { |
| 677 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 678 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
| 679 | |
| 680 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 681 | return; |
| 682 | |
| 683 | btcoexist->statistics.cnt_init_coex_dm++; |
| 684 | |
| 685 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 686 | ex_btc8723b2ant_init_coex_dm(btcoexist); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 687 | |
| 688 | btcoexist->initilized = true; |
| 689 | } |
| 690 | |
| 691 | void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type) |
| 692 | { |
| 693 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 694 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
| 695 | u8 ips_type; |
| 696 | |
| 697 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 698 | return; |
| 699 | btcoexist->statistics.cnt_ips_notify++; |
| 700 | if (btcoexist->manual_control) |
| 701 | return; |
| 702 | |
| 703 | if (ERFOFF == type) |
| 704 | ips_type = BTC_IPS_ENTER; |
| 705 | else |
| 706 | ips_type = BTC_IPS_LEAVE; |
| 707 | |
| 708 | halbtc_leave_low_power(); |
| 709 | |
| 710 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 711 | ex_btc8723b2ant_ips_notify(btcoexist, ips_type); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 712 | |
| 713 | halbtc_nomal_low_power(); |
| 714 | } |
| 715 | |
| 716 | void exhalbtc_lps_notify(struct btc_coexist *btcoexist, u8 type) |
| 717 | { |
| 718 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 719 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
| 720 | u8 lps_type; |
| 721 | |
| 722 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 723 | return; |
| 724 | btcoexist->statistics.cnt_lps_notify++; |
| 725 | if (btcoexist->manual_control) |
| 726 | return; |
| 727 | |
| 728 | if (EACTIVE == type) |
| 729 | lps_type = BTC_LPS_DISABLE; |
| 730 | else |
| 731 | lps_type = BTC_LPS_ENABLE; |
| 732 | |
| 733 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 734 | ex_btc8723b2ant_lps_notify(btcoexist, lps_type); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | void exhalbtc_scan_notify(struct btc_coexist *btcoexist, u8 type) |
| 738 | { |
| 739 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 740 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
| 741 | u8 scan_type; |
| 742 | |
| 743 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 744 | return; |
| 745 | btcoexist->statistics.cnt_scan_notify++; |
| 746 | if (btcoexist->manual_control) |
| 747 | return; |
| 748 | |
| 749 | if (type) |
| 750 | scan_type = BTC_SCAN_START; |
| 751 | else |
| 752 | scan_type = BTC_SCAN_FINISH; |
| 753 | |
| 754 | halbtc_leave_low_power(); |
| 755 | |
| 756 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 757 | ex_btc8723b2ant_scan_notify(btcoexist, scan_type); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 758 | |
| 759 | halbtc_nomal_low_power(); |
| 760 | } |
| 761 | |
| 762 | void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action) |
| 763 | { |
| 764 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 765 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
| 766 | u8 asso_type; |
| 767 | |
| 768 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 769 | return; |
| 770 | btcoexist->statistics.cnt_connect_notify++; |
| 771 | if (btcoexist->manual_control) |
| 772 | return; |
| 773 | |
| 774 | if (action) |
| 775 | asso_type = BTC_ASSOCIATE_START; |
| 776 | else |
| 777 | asso_type = BTC_ASSOCIATE_FINISH; |
| 778 | |
| 779 | halbtc_leave_low_power(); |
| 780 | |
| 781 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 782 | ex_btc8723b2ant_connect_notify(btcoexist, asso_type); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | void exhalbtc_mediastatus_notify(struct btc_coexist *btcoexist, |
Larry Finger | ed364ab | 2014-09-04 16:03:46 -0500 | [diff] [blame] | 786 | enum rt_media_status media_status) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 787 | { |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 788 | u8 status; |
| 789 | |
| 790 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 791 | return; |
| 792 | btcoexist->statistics.cnt_media_status_notify++; |
| 793 | if (btcoexist->manual_control) |
| 794 | return; |
| 795 | |
| 796 | if (RT_MEDIA_CONNECT == media_status) |
| 797 | status = BTC_MEDIA_CONNECT; |
| 798 | else |
| 799 | status = BTC_MEDIA_DISCONNECT; |
| 800 | |
| 801 | halbtc_leave_low_power(); |
| 802 | |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 803 | halbtc_nomal_low_power(); |
| 804 | } |
| 805 | |
| 806 | void exhalbtc_special_packet_notify(struct btc_coexist *btcoexist, u8 pkt_type) |
| 807 | { |
| 808 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 809 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
| 810 | u8 packet_type; |
| 811 | |
| 812 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 813 | return; |
| 814 | btcoexist->statistics.cnt_special_packet_notify++; |
| 815 | if (btcoexist->manual_control) |
| 816 | return; |
| 817 | |
| 818 | packet_type = BTC_PACKET_DHCP; |
| 819 | |
| 820 | halbtc_leave_low_power(); |
| 821 | |
| 822 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 823 | ex_btc8723b2ant_special_packet_notify(btcoexist, |
| 824 | packet_type); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 825 | |
| 826 | halbtc_nomal_low_power(); |
| 827 | } |
| 828 | |
| 829 | void exhalbtc_bt_info_notify(struct btc_coexist *btcoexist, |
| 830 | u8 *tmp_buf, u8 length) |
| 831 | { |
| 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++; |
| 837 | |
| 838 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 839 | ex_btc8723b2ant_bt_info_notify(btcoexist, tmp_buf, length); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 840 | } |
| 841 | |
| 842 | void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type) |
| 843 | { |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 844 | u8 stack_op_type; |
| 845 | |
| 846 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 847 | return; |
| 848 | btcoexist->statistics.cnt_stack_operation_notify++; |
| 849 | if (btcoexist->manual_control) |
| 850 | return; |
| 851 | |
| 852 | stack_op_type = BTC_STACK_OP_NONE; |
| 853 | |
| 854 | halbtc_leave_low_power(); |
| 855 | |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 856 | halbtc_nomal_low_power(); |
| 857 | } |
| 858 | |
| 859 | void exhalbtc_halt_notify(struct btc_coexist *btcoexist) |
| 860 | { |
| 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; |
| 865 | |
| 866 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 867 | ex_btc8723b2ant_halt_notify(btcoexist); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state) |
| 871 | { |
| 872 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 873 | return; |
| 874 | } |
| 875 | |
| 876 | void exhalbtc_periodical(struct btc_coexist *btcoexist) |
| 877 | { |
| 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++; |
| 883 | |
| 884 | halbtc_leave_low_power(); |
| 885 | |
| 886 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 887 | ex_btc8723b2ant_periodical(btcoexist); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 888 | |
| 889 | halbtc_nomal_low_power(); |
| 890 | } |
| 891 | |
| 892 | void exhalbtc_dbg_control(struct btc_coexist *btcoexist, |
| 893 | u8 code, u8 len, u8 *data) |
| 894 | { |
| 895 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 896 | return; |
| 897 | btcoexist->statistics.cnt_dbg_ctrl++; |
| 898 | } |
| 899 | |
| 900 | void exhalbtc_stack_update_profile_info(void) |
| 901 | { |
| 902 | } |
| 903 | |
Arnd Bergmann | 08aba42 | 2016-06-15 23:30:43 +0200 | [diff] [blame] | 904 | void exhalbtc_update_min_bt_rssi(s8 bt_rssi) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 905 | { |
| 906 | struct btc_coexist *btcoexist = &gl_bt_coexist; |
| 907 | |
| 908 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 909 | return; |
| 910 | |
| 911 | btcoexist->stack_info.min_bt_rssi = bt_rssi; |
| 912 | } |
| 913 | |
| 914 | void exhalbtc_set_hci_version(u16 hci_version) |
| 915 | { |
| 916 | struct btc_coexist *btcoexist = &gl_bt_coexist; |
| 917 | |
| 918 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 919 | return; |
| 920 | |
| 921 | btcoexist->stack_info.hci_version = hci_version; |
| 922 | } |
| 923 | |
| 924 | void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version) |
| 925 | { |
| 926 | struct btc_coexist *btcoexist = &gl_bt_coexist; |
| 927 | |
| 928 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 929 | return; |
| 930 | |
| 931 | btcoexist->bt_info.bt_real_fw_ver = bt_patch_version; |
| 932 | btcoexist->bt_info.bt_hci_ver = bt_hci_version; |
| 933 | } |
| 934 | |
| 935 | void exhalbtc_set_bt_exist(bool bt_exist) |
| 936 | { |
| 937 | gl_bt_coexist.board_info.bt_exist = bt_exist; |
| 938 | } |
| 939 | |
| 940 | void exhalbtc_set_chip_type(u8 chip_type) |
| 941 | { |
| 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; |
Larry Finger | f3355dd | 2014-03-04 16:53:47 -0600 | [diff] [blame] | 959 | case BT_RTL8821A: |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 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; |
| 965 | } |
| 966 | } |
| 967 | |
Larry Finger | baa1702 | 2016-03-16 13:33:35 -0500 | [diff] [blame] | 968 | void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 969 | { |
| 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; |
Larry Finger | baa1702 | 2016-03-16 13:33:35 -0500 | [diff] [blame] | 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 |
| 980 | */ |
| 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; |
| 985 | else |
| 986 | gl_bt_coexist.board_info.btdm_ant_pos = |
| 987 | BTC_ANTENNA_AT_MAIN_PORT; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 988 | } else if (BT_COEX_ANT_TYPE_ANTDIV == type) { |
| 989 | gl_bt_coexist.board_info.btdm_ant_num = ant_num; |
Larry Finger | baa1702 | 2016-03-16 13:33:35 -0500 | [diff] [blame] | 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; |
| 997 | else |
| 998 | gl_bt_coexist.board_info.btdm_ant_pos = |
| 999 | BTC_ANTENNA_AT_MAIN_PORT; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 1000 | } |
| 1001 | } |
| 1002 | |
| 1003 | void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist) |
| 1004 | { |
| 1005 | struct rtl_priv *rtlpriv = btcoexist->adapter; |
| 1006 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
| 1007 | if (!halbtc_is_bt_coexist_available(btcoexist)) |
| 1008 | return; |
| 1009 | |
| 1010 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) |
Larry Finger | e79fff2 | 2014-09-04 16:03:40 -0500 | [diff] [blame] | 1011 | ex_btc8723b2ant_display_coex_info(btcoexist); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 1012 | } |