halbtc8723b1ant.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)
  2. #if (RTL8723B_SUPPORT == 1)
  3. /* *******************************************
  4. * The following is for 8723B 1ANT BT Co-exist definition
  5. * ******************************************* */
  6. #define BT_AUTO_REPORT_ONLY_8723B_1ANT 1
  7. #define BT_INFO_8723B_1ANT_B_FTP BIT(7)
  8. #define BT_INFO_8723B_1ANT_B_A2DP BIT(6)
  9. #define BT_INFO_8723B_1ANT_B_HID BIT(5)
  10. #define BT_INFO_8723B_1ANT_B_SCO_BUSY BIT(4)
  11. #define BT_INFO_8723B_1ANT_B_ACL_BUSY BIT(3)
  12. #define BT_INFO_8723B_1ANT_B_INQ_PAGE BIT(2)
  13. #define BT_INFO_8723B_1ANT_B_SCO_ESCO BIT(1)
  14. #define BT_INFO_8723B_1ANT_B_CONNECTION BIT(0)
  15. #define BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \
  16. (((_BT_INFO_EXT_&BIT(0))) ? true : false)
  17. #define BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT 2
  18. #define BT_8723B_1ANT_WIFI_NOISY_THRESH 50 /* 30 /max: 255 */
  19. /* for Antenna detection */
  20. #define BT_8723B_1ANT_ANTDET_PSDTHRES_BACKGROUND 50
  21. #define BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION 70
  22. #define BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION 48
  23. #define BT_8723B_1ANT_ANTDET_PSDTHRES_1ANT 32
  24. #define BT_8723B_1ANT_ANTDET_RETRY_INTERVAL 10 /* retry timer if ant det is fail, unit: second */
  25. #define BT_8723B_1ANT_ANTDET_SWEEPPOINT_DELAY 40000
  26. #define BT_8723B_1ANT_ANTDET_ENABLE 1
  27. #define BT_8723B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE 1
  28. #define BT_8723B_1ANT_ANTDET_BTTXTIME 100
  29. #define BT_8723B_1ANT_ANTDET_BTTXCHANNEL 39
  30. enum bt_info_src_8723b_1ant {
  31. BT_INFO_SRC_8723B_1ANT_WIFI_FW = 0x0,
  32. BT_INFO_SRC_8723B_1ANT_BT_RSP = 0x1,
  33. BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND = 0x2,
  34. BT_INFO_SRC_8723B_1ANT_MAX
  35. };
  36. enum bt_8723b_1ant_bt_status {
  37. BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
  38. BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
  39. BT_8723B_1ANT_BT_STATUS_INQ_PAGE = 0x2,
  40. BT_8723B_1ANT_BT_STATUS_ACL_BUSY = 0x3,
  41. BT_8723B_1ANT_BT_STATUS_SCO_BUSY = 0x4,
  42. BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
  43. BT_8723B_1ANT_BT_STATUS_MAX
  44. };
  45. enum bt_8723b_1ant_wifi_status {
  46. BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0,
  47. BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1,
  48. BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2,
  49. BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIFIC_PKT = 0x3,
  50. BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4,
  51. BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5,
  52. BT_8723B_1ANT_WIFI_STATUS_MAX
  53. };
  54. enum bt_8723b_1ant_coex_algo {
  55. BT_8723B_1ANT_COEX_ALGO_UNDEFINED = 0x0,
  56. BT_8723B_1ANT_COEX_ALGO_SCO = 0x1,
  57. BT_8723B_1ANT_COEX_ALGO_HID = 0x2,
  58. BT_8723B_1ANT_COEX_ALGO_A2DP = 0x3,
  59. BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS = 0x4,
  60. BT_8723B_1ANT_COEX_ALGO_PANEDR = 0x5,
  61. BT_8723B_1ANT_COEX_ALGO_PANHS = 0x6,
  62. BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7,
  63. BT_8723B_1ANT_COEX_ALGO_PANEDR_HID = 0x8,
  64. BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
  65. BT_8723B_1ANT_COEX_ALGO_HID_A2DP = 0xa,
  66. BT_8723B_1ANT_COEX_ALGO_MAX = 0xb,
  67. };
  68. struct coex_dm_8723b_1ant {
  69. /* hw setting */
  70. u8 pre_ant_pos_type;
  71. u8 cur_ant_pos_type;
  72. /* fw mechanism */
  73. boolean cur_ignore_wlan_act;
  74. boolean pre_ignore_wlan_act;
  75. u8 pre_ps_tdma;
  76. u8 cur_ps_tdma;
  77. u8 ps_tdma_para[5];
  78. u8 ps_tdma_du_adj_type;
  79. boolean auto_tdma_adjust;
  80. boolean pre_ps_tdma_on;
  81. boolean cur_ps_tdma_on;
  82. boolean pre_bt_auto_report;
  83. boolean cur_bt_auto_report;
  84. u8 pre_lps;
  85. u8 cur_lps;
  86. u8 pre_rpwm;
  87. u8 cur_rpwm;
  88. /* sw mechanism */
  89. boolean pre_low_penalty_ra;
  90. boolean cur_low_penalty_ra;
  91. u32 pre_val0x6c0;
  92. u32 cur_val0x6c0;
  93. u32 pre_val0x6c4;
  94. u32 cur_val0x6c4;
  95. u32 pre_val0x6c8;
  96. u32 cur_val0x6c8;
  97. u8 pre_val0x6cc;
  98. u8 cur_val0x6cc;
  99. u32 backup_arfr_cnt1; /* Auto Rate Fallback Retry cnt */
  100. u32 backup_arfr_cnt2; /* Auto Rate Fallback Retry cnt */
  101. u16 backup_retry_limit;
  102. u8 backup_ampdu_max_time;
  103. /* algorithm related */
  104. u8 bt_status;
  105. u8 wifi_chnl_info[3];
  106. u32 pre_ra_mask;
  107. u32 cur_ra_mask;
  108. u8 pre_arfr_type;
  109. u8 cur_arfr_type;
  110. u8 pre_retry_limit_type;
  111. u8 cur_retry_limit_type;
  112. u8 pre_ampdu_time_type;
  113. u8 cur_ampdu_time_type;
  114. u32 arp_cnt;
  115. u8 error_condition;
  116. };
  117. struct coex_sta_8723b_1ant {
  118. boolean bt_disabled;
  119. boolean bt_enable_disable_change;
  120. boolean bt_link_exist;
  121. boolean sco_exist;
  122. boolean a2dp_exist;
  123. boolean hid_exist;
  124. boolean pan_exist;
  125. boolean bt_hi_pri_link_exist;
  126. u8 num_of_profile;
  127. boolean bt_abnormal_scan;
  128. boolean under_lps;
  129. boolean under_ips;
  130. u32 specific_pkt_period_cnt;
  131. u32 high_priority_tx;
  132. u32 high_priority_rx;
  133. u32 low_priority_tx;
  134. u32 low_priority_rx;
  135. s8 bt_rssi;
  136. boolean bt_tx_rx_mask;
  137. boolean c2h_bt_info_req_sent;
  138. u8 bt_info_c2h[BT_INFO_SRC_8723B_1ANT_MAX][10];
  139. u32 bt_info_c2h_cnt[BT_INFO_SRC_8723B_1ANT_MAX];
  140. boolean bt_whck_test;
  141. boolean c2h_bt_inquiry_page;
  142. boolean c2h_bt_remote_name_req;
  143. boolean wifi_is_high_pri_task; /* Add for win8.1 page out issue */
  144. u8 bt_retry_cnt;
  145. u8 bt_info_ext;
  146. u32 pop_event_cnt;
  147. u8 scan_ap_num;
  148. u32 crc_ok_cck;
  149. u32 crc_ok_11g;
  150. u32 crc_ok_11n;
  151. u32 crc_ok_11n_vht;
  152. u32 crc_err_cck;
  153. u32 crc_err_11g;
  154. u32 crc_err_11n;
  155. u32 crc_err_11n_vht;
  156. boolean cck_lock;
  157. boolean pre_ccklock;
  158. boolean cck_ever_lock;
  159. u8 coex_table_type;
  160. boolean force_lps_on;
  161. u32 wrong_profile_notification;
  162. u32 bt_coex_supported_version;
  163. u8 a2dp_bit_pool;
  164. u8 cut_version;
  165. };
  166. #define BT_8723B_1ANT_ANTDET_PSD_POINTS 256 /* MAX:1024 */
  167. #define BT_8723B_1ANT_ANTDET_PSD_AVGNUM 1 /* MAX:3 */
  168. #define BT_8723B_1ANT_ANTDET_BUF_LEN 16
  169. struct psdscan_sta_8723b_1ant {
  170. u32 ant_det_bt_le_channel; /* BT LE Channel ex:2412 */
  171. u32 ant_det_bt_tx_time;
  172. u32 ant_det_pre_psdscan_peak_val;
  173. boolean ant_det_is_ant_det_available;
  174. u32 ant_det_psd_scan_peak_val;
  175. boolean ant_det_is_btreply_available;
  176. u32 ant_det_psd_scan_peak_freq;
  177. u8 ant_det_result;
  178. u8 ant_det_peak_val[BT_8723B_1ANT_ANTDET_BUF_LEN];
  179. u8 ant_det_peak_freq[BT_8723B_1ANT_ANTDET_BUF_LEN];
  180. u32 ant_det_try_count;
  181. u32 ant_det_fail_count;
  182. u32 ant_det_inteval_count;
  183. u32 ant_det_thres_offset;
  184. u32 real_cent_freq;
  185. s32 real_offset;
  186. u32 real_span;
  187. u32 psd_band_width; /* unit: Hz */
  188. u32 psd_point; /* 128/256/512/1024 */
  189. u32 psd_report[1024]; /* unit:dB (20logx), 0~255 */
  190. u32 psd_report_max_hold[1024]; /* unit:dB (20logx), 0~255 */
  191. u32 psd_start_point;
  192. u32 psd_stop_point;
  193. u32 psd_max_value_point;
  194. u32 psd_max_value;
  195. u32 psd_start_base;
  196. u32 psd_avg_num; /* 1/8/16/32 */
  197. u32 psd_gen_count;
  198. boolean is_psd_running;
  199. boolean is_psd_show_max_only;
  200. };
  201. /* *******************************************
  202. * The following is interface which will notify coex module.
  203. * ******************************************* */
  204. void ex_halbtc8723b1ant_power_on_setting(IN struct btc_coexist *btcoexist);
  205. void ex_halbtc8723b1ant_pre_load_firmware(IN struct btc_coexist *btcoexist);
  206. void ex_halbtc8723b1ant_init_hw_config(IN struct btc_coexist *btcoexist,
  207. IN boolean wifi_only);
  208. void ex_halbtc8723b1ant_init_coex_dm(IN struct btc_coexist *btcoexist);
  209. void ex_halbtc8723b1ant_ips_notify(IN struct btc_coexist *btcoexist,
  210. IN u8 type);
  211. void ex_halbtc8723b1ant_lps_notify(IN struct btc_coexist *btcoexist,
  212. IN u8 type);
  213. void ex_halbtc8723b1ant_scan_notify(IN struct btc_coexist *btcoexist,
  214. IN u8 type);
  215. void ex_halbtc8723b1ant_set_antenna_notify(IN struct btc_coexist *btcoexist,
  216. IN u8 type);
  217. void ex_halbtc8723b1ant_connect_notify(IN struct btc_coexist *btcoexist,
  218. IN u8 type);
  219. void ex_halbtc8723b1ant_media_status_notify(IN struct btc_coexist *btcoexist,
  220. IN u8 type);
  221. void ex_halbtc8723b1ant_specific_packet_notify(IN struct btc_coexist *btcoexist,
  222. IN u8 type);
  223. void ex_halbtc8723b1ant_bt_info_notify(IN struct btc_coexist *btcoexist,
  224. IN u8 *tmp_buf, IN u8 length);
  225. void ex_halbtc8723b1ant_rf_status_notify(IN struct btc_coexist *btcoexist,
  226. IN u8 type);
  227. void ex_halbtc8723b1ant_halt_notify(IN struct btc_coexist *btcoexist);
  228. void ex_halbtc8723b1ant_pnp_notify(IN struct btc_coexist *btcoexist,
  229. IN u8 pnp_state);
  230. void ex_halbtc8723b1ant_coex_dm_reset(IN struct btc_coexist *btcoexist);
  231. void ex_halbtc8723b1ant_periodical(IN struct btc_coexist *btcoexist);
  232. void ex_halbtc8723b1ant_display_coex_info(IN struct btc_coexist *btcoexist);
  233. void ex_halbtc8723b1ant_antenna_detection(IN struct btc_coexist *btcoexist,
  234. IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds);
  235. void ex_halbtc8723b1ant_display_ant_detection(IN struct btc_coexist *btcoexist);
  236. #else
  237. #define ex_halbtc8723b1ant_power_on_setting(btcoexist)
  238. #define ex_halbtc8723b1ant_pre_load_firmware(btcoexist)
  239. #define ex_halbtc8723b1ant_init_hw_config(btcoexist, wifi_only)
  240. #define ex_halbtc8723b1ant_init_coex_dm(btcoexist)
  241. #define ex_halbtc8723b1ant_ips_notify(btcoexist, type)
  242. #define ex_halbtc8723b1ant_lps_notify(btcoexist, type)
  243. #define ex_halbtc8723b1ant_scan_notify(btcoexist, type)
  244. #define ex_halbtc8723b1ant_set_antenna_notify(btcoexist, type)
  245. #define ex_halbtc8723b1ant_connect_notify(btcoexist, type)
  246. #define ex_halbtc8723b1ant_media_status_notify(btcoexist, type)
  247. #define ex_halbtc8723b1ant_specific_packet_notify(btcoexist, type)
  248. #define ex_halbtc8723b1ant_bt_info_notify(btcoexist, tmp_buf, length)
  249. #define ex_halbtc8723b1ant_rf_status_notify(btcoexist, type)
  250. #define ex_halbtc8723b1ant_halt_notify(btcoexist)
  251. #define ex_halbtc8723b1ant_pnp_notify(btcoexist, pnp_state)
  252. #define ex_halbtc8723b1ant_coex_dm_reset(btcoexist)
  253. #define ex_halbtc8723b1ant_periodical(btcoexist)
  254. #define ex_halbtc8723b1ant_display_coex_info(btcoexist)
  255. #define ex_halbtc8723b1ant_antenna_detection(btcoexist, cent_freq, offset, span, seconds)
  256. #define ex_halbtc8723b1ant_display_ant_detection(btcoexist)
  257. #endif
  258. #endif