halbtc8703b1ant.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)
  2. #if (RTL8703B_SUPPORT == 1)
  3. /* *******************************************
  4. * The following is for 8703B 1ANT BT Co-exist definition
  5. * ******************************************* */
  6. #define BT_AUTO_REPORT_ONLY_8703B_1ANT 1
  7. #define BT_8703B_1ANT_ENABLE_GNTBT_TO_GPIO14 0
  8. #define BT_INFO_8703B_1ANT_B_FTP BIT(7)
  9. #define BT_INFO_8703B_1ANT_B_A2DP BIT(6)
  10. #define BT_INFO_8703B_1ANT_B_HID BIT(5)
  11. #define BT_INFO_8703B_1ANT_B_SCO_BUSY BIT(4)
  12. #define BT_INFO_8703B_1ANT_B_ACL_BUSY BIT(3)
  13. #define BT_INFO_8703B_1ANT_B_INQ_PAGE BIT(2)
  14. #define BT_INFO_8703B_1ANT_B_SCO_ESCO BIT(1)
  15. #define BT_INFO_8703B_1ANT_B_CONNECTION BIT(0)
  16. #define BT_INFO_8703B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \
  17. (((_BT_INFO_EXT_&BIT(0))) ? true : false)
  18. #define BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT 2
  19. #define BT_8703B_1ANT_WIFI_NOISY_THRESH 50 /* max: 255 */
  20. /* for Antenna detection */
  21. #define BT_8703B_1ANT_ANTDET_PSDTHRES_BACKGROUND 50
  22. #define BT_8703B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION 70
  23. #define BT_8703B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION 55
  24. #define BT_8703B_1ANT_ANTDET_PSDTHRES_1ANT 35
  25. #define BT_8703B_1ANT_ANTDET_RETRY_INTERVAL 10 /* retry timer if ant det is fail, unit: second */
  26. #define BT_8703B_1ANT_ANTDET_SWEEPPOINT_DELAY 40000
  27. #define BT_8703B_1ANT_ANTDET_ENABLE 0
  28. #define BT_8703B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE 0
  29. #define BT_8703B_1ANT_LTECOEX_INDIRECTREG_ACCESS_TIMEOUT 30000
  30. enum bt_8703b_1ant_signal_state {
  31. BT_8703B_1ANT_SIG_STA_SET_TO_LOW = 0x0,
  32. BT_8703B_1ANT_SIG_STA_SET_BY_HW = 0x0,
  33. BT_8703B_1ANT_SIG_STA_SET_TO_HIGH = 0x1,
  34. BT_8703B_1ANT_SIG_STA_MAX
  35. };
  36. enum bt_8703b_1ant_path_ctrl_owner {
  37. BT_8703B_1ANT_PCO_BTSIDE = 0x0,
  38. BT_8703B_1ANT_PCO_WLSIDE = 0x1,
  39. BT_8703B_1ANT_PCO_MAX
  40. };
  41. enum bt_8703b_1ant_gnt_ctrl_type {
  42. BT_8703B_1ANT_GNT_TYPE_CTRL_BY_PTA = 0x0,
  43. BT_8703B_1ANT_GNT_TYPE_CTRL_BY_SW = 0x1,
  44. BT_8703B_1ANT_GNT_TYPE_MAX
  45. };
  46. enum bt_8703b_1ant_gnt_ctrl_block {
  47. BT_8703B_1ANT_GNT_BLOCK_RFC_BB = 0x0,
  48. BT_8703B_1ANT_GNT_BLOCK_RFC = 0x1,
  49. BT_8703B_1ANT_GNT_BLOCK_BB = 0x2,
  50. BT_8703B_1ANT_GNT_BLOCK_MAX
  51. };
  52. enum bt_8703b_1ant_lte_coex_table_type {
  53. BT_8703B_1ANT_CTT_WL_VS_LTE = 0x0,
  54. BT_8703B_1ANT_CTT_BT_VS_LTE = 0x1,
  55. BT_8703B_1ANT_CTT_MAX
  56. };
  57. enum bt_8703b_1ant_lte_break_table_type {
  58. BT_8703B_1ANT_LBTT_WL_BREAK_LTE = 0x0,
  59. BT_8703B_1ANT_LBTT_BT_BREAK_LTE = 0x1,
  60. BT_8703B_1ANT_LBTT_LTE_BREAK_WL = 0x2,
  61. BT_8703B_1ANT_LBTT_LTE_BREAK_BT = 0x3,
  62. BT_8703B_1ANT_LBTT_MAX
  63. };
  64. enum bt_info_src_8703b_1ant {
  65. BT_INFO_SRC_8703B_1ANT_WIFI_FW = 0x0,
  66. BT_INFO_SRC_8703B_1ANT_BT_RSP = 0x1,
  67. BT_INFO_SRC_8703B_1ANT_BT_ACTIVE_SEND = 0x2,
  68. BT_INFO_SRC_8703B_1ANT_MAX
  69. };
  70. enum bt_8703b_1ant_bt_status {
  71. BT_8703B_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
  72. BT_8703B_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
  73. BT_8703B_1ANT_BT_STATUS_INQ_PAGE = 0x2,
  74. BT_8703B_1ANT_BT_STATUS_ACL_BUSY = 0x3,
  75. BT_8703B_1ANT_BT_STATUS_SCO_BUSY = 0x4,
  76. BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
  77. BT_8703B_1ANT_BT_STATUS_MAX
  78. };
  79. enum bt_8703b_1ant_wifi_status {
  80. BT_8703B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0,
  81. BT_8703B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1,
  82. BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2,
  83. BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SPECIFIC_PKT = 0x3,
  84. BT_8703B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4,
  85. BT_8703B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5,
  86. BT_8703B_1ANT_WIFI_STATUS_MAX
  87. };
  88. enum bt_8703b_1ant_coex_algo {
  89. BT_8703B_1ANT_COEX_ALGO_UNDEFINED = 0x0,
  90. BT_8703B_1ANT_COEX_ALGO_SCO = 0x1,
  91. BT_8703B_1ANT_COEX_ALGO_HID = 0x2,
  92. BT_8703B_1ANT_COEX_ALGO_A2DP = 0x3,
  93. BT_8703B_1ANT_COEX_ALGO_A2DP_PANHS = 0x4,
  94. BT_8703B_1ANT_COEX_ALGO_PANEDR = 0x5,
  95. BT_8703B_1ANT_COEX_ALGO_PANHS = 0x6,
  96. BT_8703B_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7,
  97. BT_8703B_1ANT_COEX_ALGO_PANEDR_HID = 0x8,
  98. BT_8703B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
  99. BT_8703B_1ANT_COEX_ALGO_HID_A2DP = 0xa,
  100. BT_8703B_1ANT_COEX_ALGO_MAX = 0xb,
  101. };
  102. enum bt_8703b_1ant_phase {
  103. BT_8703B_1ANT_PHASE_COEX_INIT = 0x0,
  104. BT_8703B_1ANT_PHASE_WLANONLY_INIT = 0x1,
  105. BT_8703B_1ANT_PHASE_WLAN_OFF = 0x2,
  106. BT_8703B_1ANT_PHASE_2G_RUNTIME = 0x3,
  107. BT_8703B_1ANT_PHASE_5G_RUNTIME = 0x4,
  108. BT_8703B_1ANT_PHASE_BTMPMODE = 0x5,
  109. BT_8703B_1ANT_PHASE_ANTENNA_DET = 0x6,
  110. BT_8703B_1ANT_PHASE_MAX
  111. };
  112. enum bt_8703b_1ant_Scoreboard {
  113. BT_8703B_1ANT_SCOREBOARD_ACTIVE = BIT(0),
  114. BT_8703B_1ANT_SCOREBOARD_ONOFF = BIT(1),
  115. BT_8703B_1ANT_SCOREBOARD_SCAN = BIT(2),
  116. BT_8703B_1ANT_SCOREBOARD_UNDERTEST = BIT(3),
  117. BT_8703B_1ANT_SCOREBOARD_WLBUSY = BIT(6)
  118. };
  119. struct coex_dm_8703b_1ant {
  120. /* hw setting */
  121. u8 pre_ant_pos_type;
  122. u8 cur_ant_pos_type;
  123. /* fw mechanism */
  124. boolean cur_ignore_wlan_act;
  125. boolean pre_ignore_wlan_act;
  126. u8 pre_ps_tdma;
  127. u8 cur_ps_tdma;
  128. u8 ps_tdma_para[5];
  129. u8 ps_tdma_du_adj_type;
  130. boolean auto_tdma_adjust;
  131. boolean pre_ps_tdma_on;
  132. boolean cur_ps_tdma_on;
  133. boolean pre_bt_auto_report;
  134. boolean cur_bt_auto_report;
  135. u8 pre_lps;
  136. u8 cur_lps;
  137. u8 pre_rpwm;
  138. u8 cur_rpwm;
  139. /* sw mechanism */
  140. boolean pre_low_penalty_ra;
  141. boolean cur_low_penalty_ra;
  142. u32 pre_val0x6c0;
  143. u32 cur_val0x6c0;
  144. u32 pre_val0x6c4;
  145. u32 cur_val0x6c4;
  146. u32 pre_val0x6c8;
  147. u32 cur_val0x6c8;
  148. u8 pre_val0x6cc;
  149. u8 cur_val0x6cc;
  150. boolean limited_dig;
  151. u32 backup_arfr_cnt1; /* Auto Rate Fallback Retry cnt */
  152. u32 backup_arfr_cnt2; /* Auto Rate Fallback Retry cnt */
  153. u16 backup_retry_limit;
  154. u8 backup_ampdu_max_time;
  155. /* algorithm related */
  156. u8 pre_algorithm;
  157. u8 cur_algorithm;
  158. u8 bt_status;
  159. u8 wifi_chnl_info[3];
  160. u32 pre_ra_mask;
  161. u32 cur_ra_mask;
  162. u8 pre_arfr_type;
  163. u8 cur_arfr_type;
  164. u8 pre_retry_limit_type;
  165. u8 cur_retry_limit_type;
  166. u8 pre_ampdu_time_type;
  167. u8 cur_ampdu_time_type;
  168. u32 arp_cnt;
  169. u8 error_condition;
  170. };
  171. struct coex_sta_8703b_1ant {
  172. boolean bt_disabled;
  173. boolean bt_link_exist;
  174. boolean sco_exist;
  175. boolean a2dp_exist;
  176. boolean hid_exist;
  177. boolean pan_exist;
  178. boolean bt_hi_pri_link_exist;
  179. u8 num_of_profile;
  180. boolean under_lps;
  181. boolean under_ips;
  182. u32 specific_pkt_period_cnt;
  183. u32 high_priority_tx;
  184. u32 high_priority_rx;
  185. u32 low_priority_tx;
  186. u32 low_priority_rx;
  187. boolean is_hiPri_rx_overhead;
  188. s8 bt_rssi;
  189. boolean bt_tx_rx_mask;
  190. u8 pre_bt_rssi_state;
  191. u8 pre_wifi_rssi_state[4];
  192. u8 bt_info_c2h[BT_INFO_SRC_8703B_1ANT_MAX][10];
  193. u32 bt_info_c2h_cnt[BT_INFO_SRC_8703B_1ANT_MAX];
  194. boolean bt_whck_test;
  195. boolean c2h_bt_inquiry_page;
  196. boolean c2h_bt_remote_name_req;
  197. boolean c2h_bt_page; /* Add for win8.1 page out issue */
  198. boolean wifi_is_high_pri_task; /* Add for win8.1 page out issue */
  199. u8 bt_retry_cnt;
  200. u8 bt_info_ext;
  201. u8 bt_info_ext2;
  202. u32 pop_event_cnt;
  203. u8 scan_ap_num;
  204. u32 crc_ok_cck;
  205. u32 crc_ok_11g;
  206. u32 crc_ok_11n;
  207. u32 crc_ok_11n_vht;
  208. u32 crc_err_cck;
  209. u32 crc_err_11g;
  210. u32 crc_err_11n;
  211. u32 crc_err_11n_vht;
  212. boolean cck_lock;
  213. boolean pre_ccklock;
  214. boolean cck_ever_lock;
  215. u8 coex_table_type;
  216. boolean force_lps_on;
  217. boolean concurrent_rx_mode_on;
  218. u16 score_board;
  219. u8 isolation_btween_wb; /* 0~ 50 */
  220. u8 a2dp_bit_pool;
  221. u8 cut_version;
  222. boolean acl_busy;
  223. boolean bt_create_connection;
  224. u32 bt_coex_supported_feature;
  225. u32 bt_coex_supported_version;
  226. u8 bt_ble_scan_type;
  227. u32 bt_ble_scan_para[3];
  228. boolean run_time_state;
  229. boolean freeze_coexrun_by_btinfo;
  230. boolean is_A2DP_3M;
  231. boolean voice_over_HOGP;
  232. u8 bt_info;
  233. boolean is_autoslot;
  234. u8 forbidden_slot;
  235. u8 hid_busy_num;
  236. u8 hid_pair_cnt;
  237. u32 cnt_RemoteNameReq;
  238. u32 cnt_setupLink;
  239. u32 cnt_ReInit;
  240. u32 cnt_IgnWlanAct;
  241. u32 cnt_Page;
  242. u16 bt_reg_vendor_ac;
  243. u16 bt_reg_vendor_ae;
  244. boolean is_setupLink;
  245. u8 wl_noisy_level;
  246. u32 gnt_error_cnt;
  247. };
  248. #define BT_8703B_1ANT_ANTDET_PSD_POINTS 256 /* MAX:1024 */
  249. #define BT_8703B_1ANT_ANTDET_PSD_AVGNUM 1 /* MAX:3 */
  250. #define BT_8703B_1ANT_ANTDET_BUF_LEN 16
  251. struct psdscan_sta_8703b_1ant {
  252. u32 ant_det_bt_le_channel; /* BT LE Channel ex:2412 */
  253. u32 ant_det_bt_tx_time;
  254. u32 ant_det_pre_psdscan_peak_val;
  255. boolean ant_det_is_ant_det_available;
  256. u32 ant_det_psd_scan_peak_val;
  257. boolean ant_det_is_btreply_available;
  258. u32 ant_det_psd_scan_peak_freq;
  259. u8 ant_det_result;
  260. u8 ant_det_peak_val[BT_8703B_1ANT_ANTDET_BUF_LEN];
  261. u8 ant_det_peak_freq[BT_8703B_1ANT_ANTDET_BUF_LEN];
  262. u32 ant_det_try_count;
  263. u32 ant_det_fail_count;
  264. u32 ant_det_inteval_count;
  265. u32 ant_det_thres_offset;
  266. u32 real_cent_freq;
  267. s32 real_offset;
  268. u32 real_span;
  269. u32 psd_band_width; /* unit: Hz */
  270. u32 psd_point; /* 128/256/512/1024 */
  271. u32 psd_report[1024]; /* unit:dB (20logx), 0~255 */
  272. u32 psd_report_max_hold[1024]; /* unit:dB (20logx), 0~255 */
  273. u32 psd_start_point;
  274. u32 psd_stop_point;
  275. u32 psd_max_value_point;
  276. u32 psd_max_value;
  277. u32 psd_start_base;
  278. u32 psd_avg_num; /* 1/8/16/32 */
  279. u32 psd_gen_count;
  280. boolean is_psd_running;
  281. boolean is_psd_show_max_only;
  282. };
  283. /* *******************************************
  284. * The following is interface which will notify coex module.
  285. * ******************************************* */
  286. void ex_halbtc8703b1ant_power_on_setting(IN struct btc_coexist *btcoexist);
  287. void ex_halbtc8703b1ant_pre_load_firmware(IN struct btc_coexist *btcoexist);
  288. void ex_halbtc8703b1ant_init_hw_config(IN struct btc_coexist *btcoexist,
  289. IN boolean wifi_only);
  290. void ex_halbtc8703b1ant_init_coex_dm(IN struct btc_coexist *btcoexist);
  291. void ex_halbtc8703b1ant_ips_notify(IN struct btc_coexist *btcoexist,
  292. IN u8 type);
  293. void ex_halbtc8703b1ant_lps_notify(IN struct btc_coexist *btcoexist,
  294. IN u8 type);
  295. void ex_halbtc8703b1ant_scan_notify(IN struct btc_coexist *btcoexist,
  296. IN u8 type);
  297. void ex_halbtc8703b1ant_connect_notify(IN struct btc_coexist *btcoexist,
  298. IN u8 type);
  299. void ex_halbtc8703b1ant_media_status_notify(IN struct btc_coexist *btcoexist,
  300. IN u8 type);
  301. void ex_halbtc8703b1ant_specific_packet_notify(IN struct btc_coexist *btcoexist,
  302. IN u8 type);
  303. void ex_halbtc8703b1ant_bt_info_notify(IN struct btc_coexist *btcoexist,
  304. IN u8 *tmp_buf, IN u8 length);
  305. void ex_halbtc8703b1ant_rf_status_notify(IN struct btc_coexist *btcoexist,
  306. IN u8 type);
  307. void ex_halbtc8703b1ant_halt_notify(IN struct btc_coexist *btcoexist);
  308. void ex_halbtc8703b1ant_pnp_notify(IN struct btc_coexist *btcoexist,
  309. IN u8 pnp_state);
  310. void ex_halbtc8703b1ant_coex_dm_reset(IN struct btc_coexist *btcoexist);
  311. void ex_halbtc8703b1ant_periodical(IN struct btc_coexist *btcoexist);
  312. void ex_halbtc8703b1ant_display_coex_info(IN struct btc_coexist *btcoexist);
  313. void ex_halbtc8703b1ant_antenna_detection(IN struct btc_coexist *btcoexist,
  314. IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds);
  315. void ex_halbtc8703b1ant_antenna_isolation(IN struct btc_coexist *btcoexist,
  316. IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds);
  317. void ex_halbtc8703b1ant_psd_scan(IN struct btc_coexist *btcoexist,
  318. IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds);
  319. void ex_halbtc8703b1ant_display_ant_detection(IN struct btc_coexist *btcoexist);
  320. #else
  321. #define ex_halbtc8703b1ant_power_on_setting(btcoexist)
  322. #define ex_halbtc8703b1ant_pre_load_firmware(btcoexist)
  323. #define ex_halbtc8703b1ant_init_hw_config(btcoexist, wifi_only)
  324. #define ex_halbtc8703b1ant_init_coex_dm(btcoexist)
  325. #define ex_halbtc8703b1ant_ips_notify(btcoexist, type)
  326. #define ex_halbtc8703b1ant_lps_notify(btcoexist, type)
  327. #define ex_halbtc8703b1ant_scan_notify(btcoexist, type)
  328. #define ex_halbtc8703b1ant_connect_notify(btcoexist, type)
  329. #define ex_halbtc8703b1ant_media_status_notify(btcoexist, type)
  330. #define ex_halbtc8703b1ant_specific_packet_notify(btcoexist, type)
  331. #define ex_halbtc8703b1ant_bt_info_notify(btcoexist, tmp_buf, length)
  332. #define ex_halbtc8703b1ant_rf_status_notify(btcoexist, type)
  333. #define ex_halbtc8703b1ant_halt_notify(btcoexist)
  334. #define ex_halbtc8703b1ant_pnp_notify(btcoexist, pnp_state)
  335. #define ex_halbtc8703b1ant_coex_dm_reset(btcoexist)
  336. #define ex_halbtc8703b1ant_periodical(btcoexist)
  337. #define ex_halbtc8703b1ant_display_coex_info(btcoexist)
  338. #define ex_halbtc8703b1ant_antenna_detection(btcoexist, cent_freq, offset, span, seconds)
  339. #define ex_halbtc8703b1ant_antenna_isolation(btcoexist, cent_freq, offset, span, seconds)
  340. #define ex_halbtc8703b1ant_psd_scan(btcoexist, cent_freq, offset, span, seconds)
  341. #define ex_halbtc8703b1ant_display_ant_detection(btcoexist)
  342. #endif
  343. #endif