Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 1 | /* |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 2 | Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 3 | |
| 4 | Redistribution and use in source and binary forms, with or without |
| 5 | modification, are permitted provided that the following conditions are |
| 6 | met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above |
| 10 | copyright notice, this list of conditions and the following |
| 11 | disclaimer in the documentation and/or other materials provided |
| 12 | with the distribution. |
| 13 | * Neither the name of The Linux Foundation nor the names of its |
| 14 | contributors may be used to endorse or promote products derived |
| 15 | from this software without specific prior written permission. |
| 16 | |
| 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 30 | #ifndef __RADIO_HELIUM_H__ |
| 31 | #define __RADIO_HELIUM_H__ |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 32 | |
| 33 | #include <stdbool.h> |
| 34 | |
Smriti Gupta | db534b0 | 2017-06-23 12:59:21 +0530 | [diff] [blame] | 35 | #define HELIUM_CMD_TIME_OUT (5) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 36 | #define MIN_TX_TONE_VAL 0x00 |
| 37 | #define MAX_TX_TONE_VAL 0x07 |
| 38 | #define MIN_HARD_MUTE_VAL 0x00 |
| 39 | #define MAX_HARD_MUTE_VAL 0x03 |
| 40 | #define MIN_SRCH_MODE 0x00 |
| 41 | #define MAX_SRCH_MODE 0x09 |
| 42 | #define MIN_SCAN_DWELL 0x00 |
| 43 | #define MAX_SCAN_DWELL 0x0F |
| 44 | #define MIN_SIG_TH 0x00 |
| 45 | #define MAX_SIG_TH 0x03 |
| 46 | #define MIN_PTY 0X00 |
| 47 | #define MAX_PTY 0x1F |
| 48 | #define MIN_PI 0x0000 |
| 49 | #define MAX_PI 0xFFFF |
| 50 | #define MIN_SRCH_STATIONS_CNT 0x00 |
| 51 | #define MAX_SRCH_STATIONS_CNT 0x14 |
| 52 | #define MIN_CHAN_SPACING 0x00 |
| 53 | #define MAX_CHAN_SPACING 0x02 |
| 54 | #define MIN_EMPHASIS 0x00 |
| 55 | #define MAX_EMPHASIS 0x01 |
| 56 | #define MIN_RDS_STD 0x00 |
| 57 | #define MAX_RDS_STD 0x02 |
| 58 | #define MIN_ANTENNA_VAL 0x00 |
| 59 | #define MAX_ANTENNA_VAL 0x01 |
| 60 | #define MIN_TX_PS_REPEAT_CNT 0x01 |
| 61 | #define MAX_TX_PS_REPEAT_CNT 0x0F |
| 62 | #define MIN_SOFT_MUTE 0x00 |
| 63 | #define MAX_SOFT_MUTE 0x01 |
| 64 | #define MIN_PEEK_ACCESS_LEN 0x01 |
| 65 | #define MAX_PEEK_ACCESS_LEN 0xF9 |
| 66 | #define MIN_RESET_CNTR 0x00 |
| 67 | #define MAX_RESET_CNTR 0x01 |
| 68 | #define MIN_HLSI 0x00 |
| 69 | #define MAX_HLSI 0x02 |
| 70 | #define MIN_NOTCH_FILTER 0x00 |
| 71 | #define MAX_NOTCH_FILTER 0x02 |
| 72 | #define MIN_INTF_DET_OUT_LW_TH 0x00 |
| 73 | #define MAX_INTF_DET_OUT_LW_TH 0xFF |
| 74 | #define MIN_INTF_DET_OUT_HG_TH 0x00 |
| 75 | #define MAX_INTF_DET_OUT_HG_TH 0xFF |
| 76 | #define MIN_SINR_TH -128 |
| 77 | #define MAX_SINR_TH 127 |
| 78 | #define MIN_SINR_SAMPLES 0x01 |
| 79 | #define MAX_SINR_SAMPLES 0xFF |
| 80 | #define MIN_BLEND_HI -128 |
| 81 | #define MAX_BLEND_HI 127 |
| 82 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 83 | /* HCI data types */ |
| 84 | #define RADIO_HCI_COMMAND_PKT 0x11 |
| 85 | #define RADIO_HCI_EVENT_PKT 0x14 |
| 86 | /*HCI reponce packets*/ |
| 87 | #define MAX_RIVA_PEEK_RSP_SIZE 251 |
| 88 | /* default data access */ |
| 89 | #define DEFAULT_DATA_OFFSET 2 |
| 90 | #define DEFAULT_DATA_SIZE 249 |
| 91 | /* Power levels are 0-7, but SOC will expect values from 0-255 |
| 92 | * So the each level step size will be 255/7 = 36 */ |
| 93 | #define FM_TX_PWR_LVL_STEP_SIZE 36 |
| 94 | #define FM_TX_PWR_LVL_0 0 /* Lowest power lvl that can be set for Tx */ |
| 95 | #define FM_TX_PWR_LVL_MAX 7 /* Max power lvl for Tx */ |
| 96 | #define FM_TX_PHY_CFG_MODE 0x3c |
| 97 | #define FM_TX_PHY_CFG_LEN 0x10 |
| 98 | #define FM_TX_PWR_GAIN_OFFSET 14 |
| 99 | /**RDS CONFIG MODE**/ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 100 | #define FM_RDS_CNFG_MODE 0x0f |
| 101 | #define FM_RDS_CNFG_LEN 0x10 |
Kamal Negi | 290c1e9 | 2017-05-16 11:52:53 +0530 | [diff] [blame] | 102 | |
| 103 | /**AF JUMP CONFIG MODE**/ |
| 104 | #define AF_ALGO_OFFSET 0 |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 105 | #define AF_RMSSI_TH_OFFSET 1 |
| 106 | #define AF_RMSSI_SAMPLES_OFFSET 2 |
Kamal Negi | 290c1e9 | 2017-05-16 11:52:53 +0530 | [diff] [blame] | 107 | #define AF_SINR_GD_CH_TH_OFFSET 4 |
| 108 | #define AF_SINR_TH_OFFSET 5 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 109 | /**RX CONFIG MODE**/ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 110 | #define FM_RX_CONFG_MODE 0x15 |
| 111 | #define FM_RX_CNFG_LEN 0x15 |
| 112 | #define GD_CH_RMSSI_TH_OFFSET 0x03 |
| 113 | #define MAX_GD_CH_RMSSI_TH 0x7F |
Smriti Gupta | 3264bf3 | 2017-04-21 11:45:39 +0530 | [diff] [blame] | 114 | #define SRCH_ALGO_TYPE_OFFSET 0x02 |
| 115 | #define SINRFIRSTSTAGE_OFFSET 0x03 |
| 116 | #define RMSSIFIRSTSTAGE_OFFSET 0x04 |
| 117 | #define CF0TH12_BYTE1_OFFSET 0x00 |
| 118 | #define CF0TH12_BYTE2_OFFSET 0x01 |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 119 | #define MAX_SINR_FIRSTSTAGE 0x7F |
| 120 | #define MAX_RMSSI_FIRSTSTAGE 0x7F |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 121 | #define RDS_PS0_XFR_MODE 0x01 |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 122 | #define RDS_PS0_LEN 0x06 |
| 123 | #define RX_REPEATE_BYTE_OFFSET 0x05 |
| 124 | #define FM_SPUR_TBL_SIZE 0xF0 |
| 125 | #define SPUR_DATA_LEN 0x10 |
| 126 | #define ENTRIES_EACH_CMD 0x0F |
| 127 | #define SPUR_DATA_INDEX 0x02 |
| 128 | #define FM_AF_LIST_MAX_SIZE 0xC8 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 129 | #define AF_LIST_MAX (FM_AF_LIST_MAX_SIZE / 4) /* Each AF frequency consist |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 130 | of sizeof(int) bytes */ |
| 131 | #define MAX_BLEND_INDEX 0x31 |
| 132 | |
| 133 | #define FM_SRCH_CONFG_MODE 0x41 |
| 134 | #define FM_AFJUMP_CONFG_MODE 0x42 |
| 135 | #define FM_SRCH_CNFG_LEN 0x08 |
| 136 | #define FM_AFJUMP_CNFG_LEN 0x06 |
himta ram | 5156eb1 | 2020-02-17 15:05:26 +0530 | [diff] [blame] | 137 | #define STD_BUF_SIZE 256 |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 138 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 139 | /* HCI timeouts */ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 140 | #define RADIO_HCI_TIMEOUT (10000) /* 10 seconds */ |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 141 | |
Satish kumar sugasi | bf9558e | 2016-05-10 14:30:17 -0700 | [diff] [blame] | 142 | #define ECC_EVENT_BUFSIZE 12 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 143 | typedef enum { |
| 144 | ASSOCIATE_JVM, |
| 145 | DISASSOCIATE_JVM |
| 146 | } bt_cb_thread_evt; |
| 147 | |
| 148 | #define TUNE_PARAM 16 |
| 149 | #define SIZE_ARRAY(x) (sizeof(x) / sizeof((x)[0])) |
himta ram | e8214df | 2019-12-09 20:30:01 +0530 | [diff] [blame] | 150 | typedef void (*enb_result_cb)(void); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 151 | typedef void (*tune_rsp_cb)(int Freq); |
| 152 | typedef void (*seek_rsp_cb)(int Freq); |
himta ram | e8214df | 2019-12-09 20:30:01 +0530 | [diff] [blame] | 153 | typedef void (*scan_rsp_cb)(void); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 154 | typedef void (*srch_list_rsp_cb)(uint16_t *scan_tbl); |
| 155 | typedef void (*stereo_mode_cb)(bool status); |
| 156 | typedef void (*rds_avl_sts_cb)(bool status); |
| 157 | typedef void (*af_list_cb)(uint16_t *af_list); |
| 158 | typedef void (*rt_cb)(char *rt); |
| 159 | typedef void (*ps_cb)(char *ps); |
himta ram | e8214df | 2019-12-09 20:30:01 +0530 | [diff] [blame] | 160 | typedef void (*oda_cb)(void); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 161 | typedef void (*rt_plus_cb)(char *rt_plus); |
| 162 | typedef void (*ert_cb)(char *ert); |
himta ram | e8214df | 2019-12-09 20:30:01 +0530 | [diff] [blame] | 163 | typedef void (*disable_cb)(void); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 164 | typedef void (*callback_thread_event)(unsigned int evt); |
Satish kumar sugasi | 84e51de | 2015-09-30 18:27:43 -0700 | [diff] [blame] | 165 | typedef void (*rds_grp_cntrs_cb)(char *rds_params); |
Satish kumar sugasi | 649b990 | 2016-04-28 17:55:29 -0700 | [diff] [blame] | 166 | typedef void (*rds_grp_cntrs_ext_cb)(char *rds_params); |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 167 | typedef void (*fm_peek_cb)(char *peek_rsp); |
| 168 | typedef void (*fm_ssbi_peek_cb)(char *ssbi_peek_rsp); |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 169 | typedef void (*fm_agc_gain_cb)(char *agc_gain_rsp); |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 170 | typedef void (*fm_ch_det_th_cb)(char *ch_det_rsp); |
Satish kumar sugasi | d8731b7 | 2016-01-27 14:45:45 -0800 | [diff] [blame] | 171 | typedef void (*fm_ecc_evt_cb)(char *ecc_rsp); |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 172 | typedef void (*fm_sig_thr_cb) (int val, int status); |
| 173 | typedef void (*fm_get_ch_det_thrs_cb) (int val, int status); |
| 174 | typedef void (*fm_def_data_rd_cb) (int val, int status); |
| 175 | typedef void (*fm_get_blnd_cb) (int val, int status); |
| 176 | typedef void (*fm_set_ch_det_thrs_cb) (int status); |
| 177 | typedef void (*fm_def_data_wrt_cb) (int status); |
| 178 | typedef void (*fm_set_blnd_cb) (int status); |
| 179 | typedef void (*fm_get_stn_prm_cb) (int val, int status); |
| 180 | typedef void (*fm_get_stn_dbg_prm_cb) (int val, int status); |
Rupesh Tatiya | 9917f92 | 2017-06-21 13:00:43 +0530 | [diff] [blame] | 181 | typedef void (*fm_enable_slimbus_cb) (int status); |
himta ram | 5698463 | 2018-03-19 13:07:29 +0530 | [diff] [blame] | 182 | typedef void (*fm_enable_softmute_cb) (int status); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 183 | |
| 184 | typedef struct { |
| 185 | size_t size; |
| 186 | |
| 187 | enb_result_cb enabled_cb; |
| 188 | tune_rsp_cb tune_cb; |
| 189 | seek_rsp_cb seek_cmpl_cb; |
| 190 | scan_rsp_cb scan_next_cb; |
| 191 | srch_list_rsp_cb srch_list_cb; |
| 192 | stereo_mode_cb stereo_status_cb; |
| 193 | rds_avl_sts_cb rds_avail_status_cb; |
| 194 | af_list_cb af_list_update_cb; |
| 195 | rt_cb rt_update_cb; |
| 196 | ps_cb ps_update_cb; |
| 197 | oda_cb oda_update_cb; |
| 198 | rt_plus_cb rt_plus_update_cb; |
| 199 | ert_cb ert_update_cb; |
| 200 | disable_cb disabled_cb; |
Satish kumar sugasi | 84e51de | 2015-09-30 18:27:43 -0700 | [diff] [blame] | 201 | rds_grp_cntrs_cb rds_grp_cntrs_rsp_cb; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 202 | rds_grp_cntrs_ext_cb rds_grp_cntrs_ext_rsp_cb; |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 203 | fm_peek_cb fm_peek_rsp_cb; |
| 204 | fm_ssbi_peek_cb fm_ssbi_peek_rsp_cb; |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 205 | fm_agc_gain_cb fm_agc_gain_rsp_cb; |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 206 | fm_ch_det_th_cb fm_ch_det_th_rsp_cb; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 207 | fm_ecc_evt_cb ext_country_code_cb; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 208 | callback_thread_event thread_evt_cb; |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 209 | fm_sig_thr_cb fm_get_sig_thres_cb; |
| 210 | fm_get_ch_det_thrs_cb fm_get_ch_det_thr_cb; |
| 211 | fm_def_data_rd_cb fm_def_data_read_cb; |
| 212 | fm_get_blnd_cb fm_get_blend_cb; |
| 213 | fm_set_ch_det_thrs_cb fm_set_ch_det_thr_cb; |
| 214 | fm_def_data_wrt_cb fm_def_data_write_cb; |
| 215 | fm_set_blnd_cb fm_set_blend_cb; |
| 216 | fm_get_stn_prm_cb fm_get_station_param_cb; |
| 217 | fm_get_stn_dbg_prm_cb fm_get_station_debug_param_cb; |
Rupesh Tatiya | 9917f92 | 2017-06-21 13:00:43 +0530 | [diff] [blame] | 218 | fm_enable_slimbus_cb enable_slimbus_cb; |
himta ram | 5698463 | 2018-03-19 13:07:29 +0530 | [diff] [blame] | 219 | fm_enable_softmute_cb enable_softmute_cb; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 220 | } fm_hal_callbacks_t; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 221 | |
| 222 | /* Opcode OCF */ |
| 223 | /* HCI recv control commands opcode */ |
| 224 | #define HCI_OCF_FM_ENABLE_RECV_REQ 0x0001 |
| 225 | #define HCI_OCF_FM_DISABLE_RECV_REQ 0x0002 |
| 226 | #define HCI_OCF_FM_GET_RECV_CONF_REQ 0x0003 |
| 227 | #define HCI_OCF_FM_SET_RECV_CONF_REQ 0x0004 |
| 228 | #define HCI_OCF_FM_SET_MUTE_MODE_REQ 0x0005 |
| 229 | #define HCI_OCF_FM_SET_STEREO_MODE_REQ 0x0006 |
| 230 | #define HCI_OCF_FM_SET_ANTENNA 0x0007 |
| 231 | #define HCI_OCF_FM_SET_SIGNAL_THRESHOLD 0x0008 |
| 232 | #define HCI_OCF_FM_GET_SIGNAL_THRESHOLD 0x0009 |
| 233 | #define HCI_OCF_FM_GET_STATION_PARAM_REQ 0x000A |
| 234 | #define HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ 0x000B |
| 235 | #define HCI_OCF_FM_GET_RADIO_TEXT_REQ 0x000C |
| 236 | #define HCI_OCF_FM_GET_AF_LIST_REQ 0x000D |
| 237 | #define HCI_OCF_FM_SEARCH_STATIONS 0x000E |
| 238 | #define HCI_OCF_FM_SEARCH_RDS_STATIONS 0x000F |
| 239 | #define HCI_OCF_FM_SEARCH_STATIONS_LIST 0x0010 |
| 240 | #define HCI_OCF_FM_CANCEL_SEARCH 0x0011 |
| 241 | #define HCI_OCF_FM_RDS_GRP 0x0012 |
| 242 | #define HCI_OCF_FM_RDS_GRP_PROCESS 0x0013 |
| 243 | #define HCI_OCF_FM_EN_WAN_AVD_CTRL 0x0014 |
| 244 | #define HCI_OCF_FM_EN_NOTCH_CTRL 0x0015 |
| 245 | #define HCI_OCF_FM_SET_EVENT_MASK 0x0016 |
| 246 | #define HCI_OCF_FM_SET_CH_DET_THRESHOLD 0x0017 |
| 247 | #define HCI_OCF_FM_GET_CH_DET_THRESHOLD 0x0018 |
| 248 | #define HCI_OCF_FM_SET_BLND_TBL 0x001B |
| 249 | #define HCI_OCF_FM_GET_BLND_TBL 0x001C |
Kiran Kelageri | cad7171 | 2016-04-27 16:54:22 -0700 | [diff] [blame] | 250 | #define HCI_OCF_FM_LOW_PASS_FILTER_CTRL 0x001F |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 251 | /* HCI trans control commans opcode*/ |
| 252 | #define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001 |
| 253 | #define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002 |
| 254 | #define HCI_OCF_FM_GET_TRANS_CONF_REQ 0x0003 |
| 255 | #define HCI_OCF_FM_SET_TRANS_CONF_REQ 0x0004 |
| 256 | #define HCI_OCF_FM_RDS_RT_REQ 0x0008 |
| 257 | #define HCI_OCF_FM_RDS_PS_REQ 0x0009 |
| 258 | |
Kamal Negi | ce09c30 | 2016-12-29 16:45:38 +0530 | [diff] [blame] | 259 | #define HCI_OCF_FM_ENABLE_SLIMBUS (0x000E) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 260 | |
| 261 | /* HCI common control commands opcode */ |
| 262 | #define HCI_OCF_FM_TUNE_STATION_REQ 0x0001 |
| 263 | #define HCI_OCF_FM_DEFAULT_DATA_READ 0x0002 |
| 264 | #define HCI_OCF_FM_DEFAULT_DATA_WRITE 0x0003 |
| 265 | #define HCI_OCF_FM_RESET 0x0004 |
| 266 | #define HCI_OCF_FM_GET_FEATURE_LIST 0x0005 |
| 267 | #define HCI_OCF_FM_DO_CALIBRATION 0x0006 |
| 268 | #define HCI_OCF_FM_SET_CALIBRATION 0x0007 |
| 269 | #define HCI_OCF_FM_SET_SPUR_TABLE 0x0008 |
| 270 | #define HCI_OCF_FM_GET_SPUR_TABLE 0x0009 |
| 271 | |
| 272 | /*HCI Status parameters commands*/ |
| 273 | #define HCI_OCF_FM_READ_GRP_COUNTERS 0x0001 |
| 274 | |
Satish kumar sugasi | 649b990 | 2016-04-28 17:55:29 -0700 | [diff] [blame] | 275 | #define HCI_OCF_FM_READ_GRP_COUNTERS_EXT 0x0002 |
| 276 | |
| 277 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 278 | /*HCI Diagnostic commands*/ |
| 279 | #define HCI_OCF_FM_PEEK_DATA 0x0002 |
| 280 | #define HCI_OCF_FM_POKE_DATA 0x0003 |
| 281 | #define HCI_OCF_FM_SSBI_PEEK_REG 0x0004 |
| 282 | #define HCI_OCF_FM_SSBI_POKE_REG 0x0005 |
| 283 | #define HCI_OCF_FM_STATION_DBG_PARAM 0x0007 |
| 284 | #define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008 |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 285 | #define HCI_FM_SET_GET_RESET_AGC 0x000D |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 286 | |
| 287 | /* Opcode OGF */ |
| 288 | #define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013 |
| 289 | #define HCI_OGF_FM_TRANS_CTRL_CMD_REQ 0x0014 |
| 290 | #define HCI_OGF_FM_COMMON_CTRL_CMD_REQ 0x0015 |
| 291 | #define HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ 0x0016 |
| 292 | #define HCI_OGF_FM_TEST_CMD_REQ 0x0017 |
| 293 | #define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F |
| 294 | |
| 295 | /* Command opcode pack/unpack */ |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 296 | #define hci_opcode_pack(ogf, ocf) (uint16_t) (((ocf) & 0x03ff)|((ogf) << 10)) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 297 | #define hci_opcode_ogf(op) (op >> 10) |
| 298 | #define hci_opcode_ocf(op) (op & 0x03ff) |
| 299 | #define hci_recv_ctrl_cmd_op_pack(ocf) \ |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 300 | (uint16_t) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 301 | #define hci_trans_ctrl_cmd_op_pack(ocf) \ |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 302 | (uint16_t) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf) |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 303 | #define hci_common_cmd_op_pack(ocf) \ |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 304 | (uint16_t) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf) |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 305 | #define hci_status_param_op_pack(ocf) \ |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 306 | (uint16_t) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf) |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 307 | #define hci_diagnostic_cmd_op_pack(ocf) \ |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 308 | (uint16_t) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 309 | |
| 310 | /* HCI commands with no arguments*/ |
| 311 | #define HCI_FM_ENABLE_RECV_CMD 1 |
| 312 | #define HCI_FM_DISABLE_RECV_CMD 2 |
| 313 | #define HCI_FM_GET_RECV_CONF_CMD 3 |
| 314 | #define HCI_FM_GET_STATION_PARAM_CMD 4 |
| 315 | #define HCI_FM_GET_SIGNAL_TH_CMD 5 |
| 316 | #define HCI_FM_GET_PROGRAM_SERVICE_CMD 6 |
| 317 | #define HCI_FM_GET_RADIO_TEXT_CMD 7 |
| 318 | #define HCI_FM_GET_AF_LIST_CMD 8 |
| 319 | #define HCI_FM_CANCEL_SEARCH_CMD 9 |
| 320 | #define HCI_FM_RESET_CMD 10 |
| 321 | #define HCI_FM_GET_FEATURES_CMD 11 |
| 322 | #define HCI_FM_STATION_DBG_PARAM_CMD 12 |
| 323 | #define HCI_FM_ENABLE_TRANS_CMD 13 |
| 324 | #define HCI_FM_DISABLE_TRANS_CMD 14 |
| 325 | #define HCI_FM_GET_TX_CONFIG 15 |
| 326 | #define HCI_FM_GET_DET_CH_TH_CMD 16 |
| 327 | #define HCI_FM_GET_BLND_TBL_CMD 17 |
| 328 | |
| 329 | /* Defines for FM TX*/ |
| 330 | #define TX_PS_DATA_LENGTH 108 |
| 331 | #define TX_RT_DATA_LENGTH 64 |
| 332 | #define PS_STRING_LEN 9 |
| 333 | |
| 334 | /* ----- HCI Command request ----- */ |
| 335 | struct hci_fm_recv_conf_req { |
| 336 | char emphasis; |
| 337 | char ch_spacing; |
| 338 | char rds_std; |
| 339 | char hlsi; |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 340 | int band_low_limit; |
| 341 | int band_high_limit; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 342 | } ; |
| 343 | |
| 344 | /* ----- HCI Command request ----- */ |
| 345 | struct hci_fm_trans_conf_req_struct { |
| 346 | char emphasis; |
| 347 | char rds_std; |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 348 | int band_low_limit; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 349 | int band_high_limit; |
| 350 | } ; |
| 351 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 352 | /* ----- HCI Command request ----- */ |
| 353 | struct hci_fm_tx_ps { |
| 354 | char ps_control; |
| 355 | short pi; |
| 356 | char pty; |
| 357 | char ps_repeatcount; |
| 358 | char ps_num; |
| 359 | char ps_data[TX_PS_DATA_LENGTH]; |
| 360 | } ; |
| 361 | |
| 362 | struct hci_fm_tx_rt { |
| 363 | char rt_control; |
| 364 | short pi; |
| 365 | char pty; |
| 366 | char rt_len; |
| 367 | char rt_data[TX_RT_DATA_LENGTH]; |
| 368 | } ; |
| 369 | |
| 370 | struct hci_fm_mute_mode_req { |
| 371 | char hard_mute; |
| 372 | char soft_mute; |
| 373 | } ; |
| 374 | |
| 375 | struct hci_fm_stereo_mode_req { |
| 376 | char stereo_mode; |
| 377 | char sig_blend; |
| 378 | char intf_blend; |
| 379 | char most_switch; |
| 380 | } ; |
| 381 | |
| 382 | struct hci_fm_search_station_req { |
| 383 | char srch_mode; |
| 384 | char scan_time; |
| 385 | char srch_dir; |
| 386 | } ; |
| 387 | |
| 388 | struct hci_fm_search_rds_station_req { |
| 389 | struct hci_fm_search_station_req srch_station; |
| 390 | char srch_pty; |
| 391 | short srch_pi; |
| 392 | } ; |
| 393 | |
Satish kumar sugasi | 84e51de | 2015-09-30 18:27:43 -0700 | [diff] [blame] | 394 | struct hci_fm_rds_grp_cntrs_params { |
| 395 | int totalRdsSBlockErrors; |
| 396 | int totalRdsGroups; |
| 397 | int totalRdsGroup0; |
| 398 | int totalRdsGroup2; |
| 399 | int totalRdsBlockB; |
| 400 | int totalRdsProcessedGroup0; |
| 401 | int totalRdsProcessedGroup2; |
| 402 | int totalRdsGroupFiltered; |
| 403 | int totalRdsChangeFiltered; |
| 404 | } ; |
| 405 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 406 | struct hci_fm_search_station_list_req { |
| 407 | char srch_list_mode; |
| 408 | char srch_list_dir; |
| 409 | int srch_list_max; |
| 410 | char srch_pty; |
| 411 | } ; |
| 412 | |
| 413 | struct hci_fm_rds_grp_req { |
| 414 | int rds_grp_enable_mask; |
| 415 | int rds_buf_size; |
| 416 | char en_rds_change_filter; |
| 417 | } ; |
| 418 | |
| 419 | struct hci_fm_en_avd_ctrl_req { |
| 420 | char no_freqs; |
| 421 | char freq_index; |
| 422 | char lo_shft; |
| 423 | short freq_min; |
| 424 | short freq_max; |
| 425 | } ; |
| 426 | |
| 427 | struct hci_fm_def_data_rd_req { |
| 428 | char mode; |
| 429 | char length; |
| 430 | char param_len; |
| 431 | char param; |
| 432 | } ; |
| 433 | |
| 434 | struct hci_fm_def_data_wr_req { |
| 435 | char mode; |
| 436 | char length; |
| 437 | char data[DEFAULT_DATA_SIZE]; |
| 438 | } ; |
| 439 | |
| 440 | struct hci_fm_riva_data { |
| 441 | char subopcode; |
| 442 | int start_addr; |
| 443 | char length; |
| 444 | } ; |
| 445 | |
| 446 | struct hci_fm_riva_poke { |
| 447 | struct hci_fm_riva_data cmd_params; |
| 448 | char data[MAX_RIVA_PEEK_RSP_SIZE]; |
| 449 | } ; |
| 450 | |
| 451 | struct hci_fm_ssbi_req { |
| 452 | short start_addr; |
| 453 | char data; |
| 454 | } ; |
| 455 | struct hci_fm_ssbi_peek { |
| 456 | short start_address; |
| 457 | } ; |
| 458 | |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 459 | struct hci_fm_set_get_reset_agc { |
| 460 | char ucctrl; |
| 461 | char ucgainstate; |
| 462 | } ; |
| 463 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 464 | struct hci_fm_ch_det_threshold { |
| 465 | char sinr; |
| 466 | char sinr_samples; |
| 467 | char low_th; |
| 468 | char high_th; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 469 | } ; |
| 470 | |
| 471 | struct hci_fm_blend_table { |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 472 | char BlendType; |
| 473 | char BlendRampRateUp; |
| 474 | char BlendDebounceNumSampleUp; |
| 475 | char BlendDebounceIdxUp; |
| 476 | char BlendSinrIdxSkipStep; |
| 477 | char BlendSinrHi; |
| 478 | char BlendRmssiHi; |
| 479 | char BlendIndexHi; |
| 480 | char BlendIndex[MAX_BLEND_INDEX]; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 481 | } ; |
| 482 | |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 483 | struct hci_fm_def_data_rd { |
| 484 | char mode; |
| 485 | char length; |
| 486 | char param_len; |
| 487 | char param; |
| 488 | }; |
| 489 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 490 | /*HCI events*/ |
| 491 | #define HCI_EV_TUNE_STATUS 0x01 |
| 492 | #define HCI_EV_RDS_LOCK_STATUS 0x02 |
| 493 | #define HCI_EV_STEREO_STATUS 0x03 |
| 494 | #define HCI_EV_SERVICE_AVAILABLE 0x04 |
| 495 | #define HCI_EV_SEARCH_PROGRESS 0x05 |
| 496 | #define HCI_EV_SEARCH_RDS_PROGRESS 0x06 |
| 497 | #define HCI_EV_SEARCH_LIST_PROGRESS 0x07 |
| 498 | #define HCI_EV_RDS_RX_DATA 0x08 |
| 499 | #define HCI_EV_PROGRAM_SERVICE 0x09 |
| 500 | #define HCI_EV_RADIO_TEXT 0x0A |
| 501 | #define HCI_EV_FM_AF_LIST 0x0B |
| 502 | #define HCI_EV_TX_RDS_GRP_AVBLE 0x0C |
| 503 | #define HCI_EV_TX_RDS_GRP_COMPL 0x0D |
| 504 | #define HCI_EV_TX_RDS_CONT_GRP_COMPL 0x0E |
| 505 | #define HCI_EV_CMD_COMPLETE 0x0F |
| 506 | #define HCI_EV_CMD_STATUS 0x10 |
| 507 | #define HCI_EV_TUNE_COMPLETE 0x11 |
| 508 | #define HCI_EV_SEARCH_COMPLETE 0x12 |
| 509 | #define HCI_EV_SEARCH_RDS_COMPLETE 0x13 |
| 510 | #define HCI_EV_SEARCH_LIST_COMPLETE 0x14 |
Satish kumar sugasi | d8731b7 | 2016-01-27 14:45:45 -0800 | [diff] [blame] | 511 | |
| 512 | #define HCI_EV_EXT_COUNTRY_CODE 0x17 |
Satish kumar sugasi | b0ba3c8 | 2016-05-04 20:18:23 -0700 | [diff] [blame] | 513 | #define HCI_EV_RADIO_TEXT_PLUS_ID 0x18 |
| 514 | #define HCI_EV_RADIO_TEXT_PLUS_TAG 0x19 |
Satish kumar sugasi | 8a34ad3 | 2015-10-19 18:09:49 -0700 | [diff] [blame] | 515 | #define HCI_EV_HW_ERR_EVENT 0x1A |
| 516 | |
himta ram | 5156eb1 | 2020-02-17 15:05:26 +0530 | [diff] [blame] | 517 | /*HCI event opcode for fm driver RDS support*/ |
| 518 | #define HCI_EV_DRIVER_RDS_EVENT 0x1B |
| 519 | #define HCI_EV_E_RADIO_TEXT 0x1C |
| 520 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 521 | #define HCI_REQ_DONE 0 |
| 522 | #define HCI_REQ_PEND 1 |
| 523 | #define HCI_REQ_CANCELED 2 |
| 524 | #define HCI_REQ_STATUS 3 |
| 525 | |
| 526 | #define MAX_RAW_RDS_GRPS 21 |
| 527 | |
| 528 | #define RDSGRP_DATA_OFFSET 0x1 |
| 529 | |
| 530 | /*RT PLUS*/ |
| 531 | #define DUMMY_CLASS 0 |
| 532 | #define RT_PLUS_LEN_1_TAG 3 |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 533 | #define RT_ERT_FLAG_BIT 5 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 534 | |
| 535 | /*TAG1*/ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 536 | #define TAG1_MSB_OFFSET 3 |
| 537 | #define TAG1_MSB_MASK 7 |
| 538 | #define TAG1_LSB_OFFSET 5 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 539 | #define TAG1_POS_MSB_MASK 31 |
| 540 | #define TAG1_POS_MSB_OFFSET 1 |
| 541 | #define TAG1_POS_LSB_OFFSET 7 |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 542 | #define TAG1_LEN_OFFSET 1 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 543 | #define TAG1_LEN_MASK 63 |
| 544 | |
| 545 | /*TAG2*/ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 546 | #define TAG2_MSB_OFFSET 5 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 547 | #define TAG2_MSB_MASK 1 |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 548 | #define TAG2_LSB_OFFSET 3 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 549 | #define TAG2_POS_MSB_MASK 7 |
| 550 | #define TAG2_POS_MSB_OFFSET 3 |
| 551 | #define TAG2_POS_LSB_OFFSET 5 |
| 552 | #define TAG2_LEN_MASK 31 |
| 553 | |
| 554 | #define AGT_MASK 31 |
| 555 | /*Extract 5 left most bits of lsb of 2nd block*/ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 556 | #define AGT(x) (x & AGT_MASK) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 557 | /*16 bits of 4th block*/ |
| 558 | #define AID(lsb, msb) ((msb << 8) | (lsb)) |
| 559 | /*Extract 5 right most bits of msb of 2nd block*/ |
| 560 | #define GTC(blk2msb) (blk2msb >> 3) |
| 561 | |
| 562 | #define GRP_3A 0x6 |
| 563 | #define RT_PLUS_AID 0x4bd7 |
| 564 | |
| 565 | /*ERT*/ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 566 | #define ERT_AID 0x6552 |
| 567 | #define CARRIAGE_RETURN 0x000D |
| 568 | #define MAX_ERT_SEGMENT 31 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 569 | #define ERT_FORMAT_DIR_BIT 1 |
| 570 | |
| 571 | #define EXTRACT_BIT(data, bit_pos) ((data & (1 << bit_pos)) >> bit_pos) |
| 572 | |
| 573 | struct hci_ev_tune_status { |
| 574 | char sub_event; |
| 575 | int station_freq; |
| 576 | char serv_avble; |
| 577 | char rssi; |
| 578 | char stereo_prg; |
| 579 | char rds_sync_status; |
| 580 | char mute_mode; |
| 581 | char sinr; |
| 582 | char intf_det_th; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 583 | }__attribute__((packed)) ; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 584 | |
| 585 | struct rds_blk_data { |
| 586 | char rdsMsb; |
| 587 | char rdsLsb; |
| 588 | char blockStatus; |
| 589 | } ; |
| 590 | |
| 591 | struct rds_grp_data { |
| 592 | struct rds_blk_data rdsBlk[4]; |
| 593 | } ; |
| 594 | |
| 595 | struct hci_ev_rds_rx_data { |
| 596 | char num_rds_grps; |
| 597 | struct rds_grp_data rds_grp_data[MAX_RAW_RDS_GRPS]; |
| 598 | } ; |
| 599 | |
| 600 | struct hci_ev_prg_service { |
| 601 | short pi_prg_id; |
| 602 | char pty_prg_type; |
| 603 | char ta_prg_code_type; |
| 604 | char ta_ann_code_flag; |
| 605 | char ms_switch_code_flag; |
| 606 | char dec_id_ctrl_code_flag; |
| 607 | char ps_num; |
| 608 | char prg_service_name[119]; |
| 609 | } ; |
| 610 | |
| 611 | struct hci_ev_radio_text { |
| 612 | short pi_prg_id; |
| 613 | char pty_prg_type; |
| 614 | char ta_prg_code_type; |
| 615 | char txt_ab_flag; |
| 616 | char radio_txt[64]; |
| 617 | } ; |
| 618 | |
| 619 | struct hci_ev_af_list { |
| 620 | int tune_freq; |
| 621 | short pi_code; |
| 622 | char af_size; |
| 623 | char af_list[FM_AF_LIST_MAX_SIZE]; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 624 | } __attribute__((packed)) ; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 625 | |
| 626 | struct hci_ev_cmd_complete { |
| 627 | char num_hci_cmd_pkts; |
| 628 | short cmd_opcode; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 629 | } __attribute((packed)); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 630 | |
| 631 | struct hci_ev_cmd_status { |
| 632 | char status; |
| 633 | char num_hci_cmd_pkts; |
| 634 | short status_opcode; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 635 | } __attribute__((packed)); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 636 | |
| 637 | struct hci_ev_srch_st { |
| 638 | int station_freq; |
| 639 | char rds_cap; |
| 640 | char pty; |
| 641 | short status_opcode; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 642 | } __attribute__((packed)); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 643 | |
| 644 | struct hci_ev_rel_freq { |
| 645 | char rel_freq_msb; |
| 646 | char rel_freq_lsb; |
| 647 | |
| 648 | } ; |
| 649 | struct hci_ev_srch_list_compl { |
| 650 | char num_stations_found; |
| 651 | struct hci_ev_rel_freq rel_freq[20]; |
| 652 | } ; |
| 653 | |
| 654 | /* ----- HCI Event Response ----- */ |
| 655 | struct hci_fm_conf_rsp { |
| 656 | char status; |
| 657 | struct hci_fm_recv_conf_req recv_conf_rsp; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 658 | } __attribute__((packed)); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 659 | |
Satish kumar sugasi | 84e51de | 2015-09-30 18:27:43 -0700 | [diff] [blame] | 660 | struct hci_fm_rds_grp_cntrs_rsp { |
| 661 | char status; |
| 662 | struct hci_fm_rds_grp_cntrs_params recv_rds_grp_cntrs_rsp; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 663 | } __attribute__((packed)); |
Satish kumar sugasi | 84e51de | 2015-09-30 18:27:43 -0700 | [diff] [blame] | 664 | |
| 665 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 666 | struct hci_fm_get_trans_conf_rsp { |
| 667 | char status; |
| 668 | struct hci_fm_trans_conf_req_struct trans_conf_rsp; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 669 | } __attribute__((packed)); |
| 670 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 671 | struct hci_fm_sig_threshold_rsp { |
| 672 | char status; |
| 673 | char sig_threshold; |
| 674 | } ; |
| 675 | |
| 676 | struct hci_fm_station_rsp { |
| 677 | struct hci_ev_tune_status station_rsp; |
| 678 | } ; |
| 679 | |
| 680 | struct hci_fm_prgm_srv_rsp { |
| 681 | char status; |
| 682 | struct hci_ev_prg_service prg_srv; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 683 | } __attribute__((packed)); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 684 | |
| 685 | struct hci_fm_radio_txt_rsp { |
| 686 | char status; |
| 687 | struct hci_ev_radio_text rd_txt; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 688 | } __attribute__((packed)); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 689 | |
| 690 | struct hci_fm_af_list_rsp { |
| 691 | char status; |
| 692 | struct hci_ev_af_list rd_txt; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 693 | } __attribute__((packed)); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 694 | |
| 695 | struct hci_fm_data_rd_rsp { |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 696 | char data_len; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 697 | char data[DEFAULT_DATA_SIZE]; |
| 698 | } ; |
| 699 | |
| 700 | struct hci_fm_feature_list_rsp { |
| 701 | char status; |
| 702 | char feature_mask; |
| 703 | } ; |
| 704 | |
| 705 | struct hci_fm_dbg_param_rsp { |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 706 | char blend; |
| 707 | char soft_mute; |
| 708 | char inf_blend; |
| 709 | char inf_soft_mute; |
| 710 | char pilot_pil; |
| 711 | char io_verc; |
| 712 | char in_det_out; |
| 713 | } ; |
| 714 | |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 715 | #define CLKSPURID_INDEX0 0 |
| 716 | #define CLKSPURID_INDEX1 5 |
| 717 | #define CLKSPURID_INDEX2 10 |
| 718 | #define CLKSPURID_INDEX3 15 |
| 719 | #define CLKSPURID_INDEX4 20 |
| 720 | #define CLKSPURID_INDEX5 25 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 721 | |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 722 | #define MAX_SPUR_FREQ_LIMIT 30 |
| 723 | #define CKK_SPUR 0x3B |
| 724 | #define SPUR_DATA_SIZE 0x4 |
| 725 | #define SPUR_ENTRIES_PER_ID 0x5 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 726 | |
| 727 | #define COMPUTE_SPUR(val) ((((val) - (76000)) / (50))) |
| 728 | #define GET_FREQ(val, bit) ((bit == 1) ? ((val) >> 8) : ((val) & 0xFF)) |
| 729 | #define GET_SPUR_ENTRY_LEVEL(val) ((val) / (5)) |
| 730 | |
| 731 | struct hci_fm_spur_data { |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 732 | int freq[MAX_SPUR_FREQ_LIMIT]; |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 733 | char rmssi[MAX_SPUR_FREQ_LIMIT]; |
| 734 | char enable[MAX_SPUR_FREQ_LIMIT]; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 735 | } __attribute__((packed)); |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 736 | |
| 737 | /* HCI dev events */ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 738 | #define RADIO_HCI_DEV_REG 1 |
| 739 | #define RADIO_HCI_DEV_WRITE 2 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 740 | |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 741 | #define hci_req_lock(d) mutex_lock(&d->req_lock) |
| 742 | #define hci_req_unlock(d) mutex_unlock(&d->req_lock) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 743 | |
| 744 | /* FM RDS */ |
| 745 | #define RDS_PTYPE 2 |
| 746 | #define RDS_PID_LOWER 1 |
| 747 | #define RDS_PID_HIGHER 0 |
| 748 | #define RDS_OFFSET 5 |
| 749 | #define RDS_PS_LENGTH_OFFSET 7 |
| 750 | #define RDS_STRING 8 |
| 751 | #define RDS_PS_DATA_OFFSET 8 |
| 752 | #define RDS_CONFIG_OFFSET 3 |
| 753 | #define RDS_AF_JUMP_OFFSET 4 |
| 754 | #define PI_CODE_OFFSET 4 |
| 755 | #define AF_SIZE_OFFSET 6 |
| 756 | #define AF_LIST_OFFSET 7 |
| 757 | #define RT_A_B_FLAG_OFFSET 4 |
| 758 | /*FM states*/ |
| 759 | |
| 760 | enum radio_state_t { |
| 761 | FM_OFF, |
| 762 | FM_RECV, |
| 763 | FM_TRANS, |
| 764 | FM_RESET, |
| 765 | FM_CALIB, |
| 766 | FM_TURNING_OFF, |
| 767 | FM_RECV_TURNING_ON, |
| 768 | FM_TRANS_TURNING_ON, |
| 769 | FM_MAX_NO_STATES, |
| 770 | }; |
| 771 | |
| 772 | enum emphasis_type { |
| 773 | FM_RX_EMP75 = 0x0, |
| 774 | FM_RX_EMP50 = 0x1 |
| 775 | }; |
| 776 | |
| 777 | enum channel_space_type { |
| 778 | FM_RX_SPACE_200KHZ = 0x0, |
| 779 | FM_RX_SPACE_100KHZ = 0x1, |
| 780 | FM_RX_SPACE_50KHZ = 0x2 |
| 781 | }; |
| 782 | |
| 783 | enum high_low_injection { |
| 784 | AUTO_HI_LO_INJECTION = 0x0, |
| 785 | LOW_SIDE_INJECTION = 0x1, |
| 786 | HIGH_SIDE_INJECTION = 0x2 |
| 787 | }; |
| 788 | |
| 789 | enum fm_rds_type { |
| 790 | FM_RX_RDBS_SYSTEM = 0x0, |
| 791 | FM_RX_RDS_SYSTEM = 0x1 |
| 792 | }; |
| 793 | |
| 794 | enum hlm_region_t { |
| 795 | HELIUM_REGION_US, |
| 796 | HELIUM_REGION_EU, |
| 797 | HELIUM_REGION_JAPAN, |
| 798 | HELIUM_REGION_JAPAN_WIDE, |
| 799 | HELIUM_REGION_OTHER |
| 800 | }; |
| 801 | |
| 802 | /* Search options */ |
| 803 | enum search_t { |
| 804 | SEEK, |
| 805 | SCAN, |
| 806 | SCAN_FOR_STRONG, |
| 807 | SCAN_FOR_WEAK, |
| 808 | RDS_SEEK_PTY, |
| 809 | RDS_SCAN_PTY, |
| 810 | RDS_SEEK_PI, |
| 811 | RDS_AF_JUMP, |
| 812 | }; |
| 813 | |
| 814 | enum spur_entry_levels { |
| 815 | ENTRY_0, |
| 816 | ENTRY_1, |
| 817 | ENTRY_2, |
| 818 | ENTRY_3, |
| 819 | ENTRY_4, |
| 820 | ENTRY_5, |
| 821 | }; |
| 822 | |
| 823 | /* Band limits */ |
| 824 | #define REGION_US_EU_BAND_LOW 87500 |
| 825 | #define REGION_US_EU_BAND_HIGH 108000 |
| 826 | #define REGION_JAPAN_STANDARD_BAND_LOW 76000 |
| 827 | #define REGION_JAPAN_STANDARD_BAND_HIGH 90000 |
| 828 | #define REGION_JAPAN_WIDE_BAND_LOW 90000 |
| 829 | #define REGION_JAPAN_WIDE_BAND_HIGH 108000 |
| 830 | |
| 831 | #define SRCH_MODE 0x07 |
| 832 | #define SRCH_DIR 0x08 /* 0-up 1-down */ |
| 833 | #define SCAN_DWELL 0x70 |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 834 | #define SRCH_ON 0x80 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 835 | |
| 836 | /* I/O Control */ |
| 837 | #define IOC_HRD_MUTE 0x03 |
| 838 | #define IOC_SFT_MUTE 0x01 |
| 839 | #define IOC_MON_STR 0x01 |
| 840 | #define IOC_SIG_BLND 0x01 |
| 841 | #define IOC_INTF_BLND 0x01 |
| 842 | #define IOC_ANTENNA 0x01 |
| 843 | |
| 844 | /* RDS Control */ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 845 | #define RDS_ON 0x01 |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 846 | #define RDS_BUF_SZ 100 |
| 847 | |
| 848 | /* constants */ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 849 | #define RDS_BLOCKS_NUM (4) |
| 850 | #define BYTES_PER_BLOCK (3) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 851 | #define MAX_PS_LENGTH (108) |
| 852 | #define MAX_RT_LENGTH (64) |
| 853 | #define RDS_GRP_CNTR_LEN (36) |
| 854 | #define RX_RT_DATA_LENGTH (63) |
| 855 | /* Search direction */ |
| 856 | #define SRCH_DIR_UP (0) |
| 857 | #define SRCH_DIR_DOWN (1) |
| 858 | |
| 859 | /*Search RDS stations*/ |
| 860 | #define SEARCH_RDS_STNS_MODE_OFFSET 4 |
| 861 | |
| 862 | /*Search Station list */ |
| 863 | #define PARAMS_PER_STATION 0x08 |
| 864 | #define STN_NUM_OFFSET 0x01 |
| 865 | #define STN_FREQ_OFFSET 0x02 |
| 866 | #define KHZ_TO_MHZ 1000 |
| 867 | #define GET_MSB(x)((x >> 8) & 0xFF) |
| 868 | #define GET_LSB(x)((x) & 0xFF) |
| 869 | |
| 870 | /* control options */ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 871 | #define CTRL_ON (1) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 872 | #define CTRL_OFF (0) |
| 873 | |
| 874 | /*Diagnostic commands*/ |
| 875 | |
| 876 | #define RIVA_PEEK_OPCODE 0x0D |
| 877 | #define RIVA_POKE_OPCODE 0x0C |
| 878 | |
| 879 | #define PEEK_DATA_OFSET 0x1 |
| 880 | #define RIVA_PEEK_PARAM 0x6 |
| 881 | #define RIVA_PEEK_LEN_OFSET 0x6 |
| 882 | #define SSBI_PEEK_LEN 0x01 |
| 883 | /*Calibration data*/ |
| 884 | #define PROCS_CALIB_MODE 1 |
| 885 | #define PROCS_CALIB_SIZE 23 |
| 886 | #define DC_CALIB_MODE 2 |
| 887 | #define DC_CALIB_SIZE 48 |
| 888 | #define RSB_CALIB_MODE 3 |
| 889 | #define RSB_CALIB_SIZE 4 |
| 890 | #define CALIB_DATA_OFSET 2 |
| 891 | #define CALIB_MODE_OFSET 1 |
| 892 | #define MAX_CALIB_SIZE 75 |
| 893 | |
| 894 | /* Channel validity */ |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 895 | #define INVALID_CHANNEL (0) |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 896 | #define VALID_CHANNEL (1) |
| 897 | |
| 898 | struct hci_fm_set_cal_req_proc { |
| 899 | char mode; |
| 900 | /*Max process calibration data size*/ |
| 901 | char data[PROCS_CALIB_SIZE]; |
| 902 | } ; |
| 903 | |
| 904 | struct hci_fm_set_cal_req_dc { |
| 905 | char mode; |
| 906 | /*Max DC calibration data size*/ |
| 907 | char data[DC_CALIB_SIZE]; |
| 908 | } ; |
| 909 | |
| 910 | struct hci_cc_do_calibration_rsp { |
| 911 | char status; |
| 912 | char mode; |
| 913 | char data[MAX_CALIB_SIZE]; |
| 914 | } ; |
| 915 | |
| 916 | struct hci_fm_set_spur_table_req { |
| 917 | char mode; |
| 918 | char no_of_freqs_entries; |
| 919 | char spur_data[FM_SPUR_TBL_SIZE]; |
| 920 | } ; |
| 921 | /* Low Power mode*/ |
| 922 | #define SIG_LEVEL_INTR (1 << 0) |
| 923 | #define RDS_SYNC_INTR (1 << 1) |
| 924 | #define AUDIO_CTRL_INTR (1 << 2) |
| 925 | #define AF_JUMP_ENABLE (1 << 4) |
| 926 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 927 | static inline int is_valid_tone(int tone) |
| 928 | { |
| 929 | if ((tone >= MIN_TX_TONE_VAL) && |
| 930 | (tone <= MAX_TX_TONE_VAL)) |
| 931 | return 1; |
| 932 | else |
| 933 | return 0; |
| 934 | } |
| 935 | |
| 936 | static inline int is_valid_hard_mute(int hard_mute) |
| 937 | { |
| 938 | if ((hard_mute >= MIN_HARD_MUTE_VAL) && |
| 939 | (hard_mute <= MAX_HARD_MUTE_VAL)) |
| 940 | return 1; |
| 941 | else |
| 942 | return 0; |
| 943 | } |
| 944 | |
| 945 | static inline int is_valid_srch_mode(int srch_mode) |
| 946 | { |
| 947 | if ((srch_mode >= MIN_SRCH_MODE) && |
| 948 | (srch_mode <= MAX_SRCH_MODE)) |
| 949 | return 1; |
| 950 | else |
| 951 | return 0; |
| 952 | } |
| 953 | |
| 954 | static inline int is_valid_scan_dwell_prd(int scan_dwell_prd) |
| 955 | { |
| 956 | if ((scan_dwell_prd >= MIN_SCAN_DWELL) && |
| 957 | (scan_dwell_prd <= MAX_SCAN_DWELL)) |
| 958 | return 1; |
| 959 | else |
| 960 | return 0; |
| 961 | } |
| 962 | |
| 963 | static inline int is_valid_sig_th(int sig_th) |
| 964 | { |
| 965 | if ((sig_th >= MIN_SIG_TH) && |
| 966 | (sig_th <= MAX_SIG_TH)) |
| 967 | return 1; |
| 968 | else |
| 969 | return 0; |
| 970 | } |
| 971 | |
| 972 | static inline int is_valid_pty(int pty) |
| 973 | { |
| 974 | if ((pty >= MIN_PTY) && |
| 975 | (pty <= MAX_PTY)) |
| 976 | return 1; |
| 977 | else |
| 978 | return 0; |
| 979 | } |
| 980 | |
| 981 | static inline int is_valid_pi(int pi) |
| 982 | { |
| 983 | if ((pi >= MIN_PI) && |
| 984 | (pi <= MAX_PI)) |
| 985 | return 1; |
| 986 | else |
| 987 | return 0; |
| 988 | } |
| 989 | |
| 990 | static inline int is_valid_srch_station_cnt(int cnt) |
| 991 | { |
| 992 | if ((cnt >= MIN_SRCH_STATIONS_CNT) && |
| 993 | (cnt <= MAX_SRCH_STATIONS_CNT)) |
| 994 | return 1; |
| 995 | else |
| 996 | return 0; |
| 997 | } |
| 998 | |
| 999 | static inline int is_valid_chan_spacing(int spacing) |
| 1000 | { |
| 1001 | if ((spacing >= MIN_CHAN_SPACING) && |
| 1002 | (spacing <= MAX_CHAN_SPACING)) |
| 1003 | return 1; |
| 1004 | else |
| 1005 | return 0; |
| 1006 | } |
| 1007 | |
| 1008 | static inline int is_valid_emphasis(int emphasis) |
| 1009 | { |
| 1010 | if ((emphasis >= MIN_EMPHASIS) && |
| 1011 | (emphasis <= MAX_EMPHASIS)) |
| 1012 | return 1; |
| 1013 | else |
| 1014 | return 0; |
| 1015 | } |
| 1016 | |
| 1017 | static inline int is_valid_rds_std(int rds_std) |
| 1018 | { |
| 1019 | if ((rds_std >= MIN_RDS_STD) && |
| 1020 | (rds_std <= MAX_RDS_STD)) |
| 1021 | return 1; |
| 1022 | else |
| 1023 | return 0; |
| 1024 | } |
| 1025 | |
| 1026 | static inline int is_valid_antenna(int antenna_type) |
| 1027 | { |
| 1028 | if ((antenna_type >= MIN_ANTENNA_VAL) && |
| 1029 | (antenna_type <= MAX_ANTENNA_VAL)) |
| 1030 | return 1; |
| 1031 | else |
| 1032 | return 0; |
| 1033 | } |
| 1034 | |
| 1035 | static inline int is_valid_ps_repeat_cnt(int cnt) |
| 1036 | { |
| 1037 | if ((cnt >= MIN_TX_PS_REPEAT_CNT) && |
| 1038 | (cnt <= MAX_TX_PS_REPEAT_CNT)) |
| 1039 | return 1; |
| 1040 | else |
| 1041 | return 0; |
| 1042 | } |
| 1043 | |
| 1044 | static inline int is_valid_soft_mute(int soft_mute) |
| 1045 | { |
| 1046 | if ((soft_mute >= MIN_SOFT_MUTE) && |
| 1047 | (soft_mute <= MAX_SOFT_MUTE)) |
| 1048 | return 1; |
| 1049 | else |
| 1050 | return 0; |
| 1051 | } |
| 1052 | |
| 1053 | static inline int is_valid_peek_len(int len) |
| 1054 | { |
| 1055 | if ((len >= MIN_PEEK_ACCESS_LEN) && |
| 1056 | (len <= MAX_PEEK_ACCESS_LEN)) |
| 1057 | return 1; |
| 1058 | else |
| 1059 | return 0; |
| 1060 | } |
| 1061 | |
| 1062 | static inline int is_valid_reset_cntr(int cntr) |
| 1063 | { |
| 1064 | if ((cntr >= MIN_RESET_CNTR) && |
| 1065 | (cntr <= MAX_RESET_CNTR)) |
| 1066 | return 1; |
| 1067 | else |
| 1068 | return 0; |
| 1069 | } |
| 1070 | |
| 1071 | static inline int is_valid_hlsi(int hlsi) |
| 1072 | { |
| 1073 | if ((hlsi >= MIN_HLSI) && |
| 1074 | (hlsi <= MAX_HLSI)) |
| 1075 | return 1; |
| 1076 | else |
| 1077 | return 0; |
| 1078 | } |
| 1079 | |
| 1080 | static inline int is_valid_notch_filter(int filter) |
| 1081 | { |
| 1082 | if ((filter >= MIN_NOTCH_FILTER) && |
| 1083 | (filter <= MAX_NOTCH_FILTER)) |
| 1084 | return 1; |
| 1085 | else |
| 1086 | return 0; |
| 1087 | } |
| 1088 | |
| 1089 | static inline int is_valid_intf_det_low_th(int th) |
| 1090 | { |
| 1091 | if ((th >= MIN_INTF_DET_OUT_LW_TH) && |
| 1092 | (th <= MAX_INTF_DET_OUT_LW_TH)) |
| 1093 | return 1; |
| 1094 | else |
| 1095 | return 0; |
| 1096 | } |
| 1097 | |
| 1098 | static inline int is_valid_intf_det_hgh_th(int th) |
| 1099 | { |
| 1100 | if ((th >= MIN_INTF_DET_OUT_HG_TH) && |
| 1101 | (th <= MAX_INTF_DET_OUT_HG_TH)) |
| 1102 | return 1; |
| 1103 | else |
| 1104 | return 0; |
| 1105 | } |
| 1106 | |
| 1107 | static inline int is_valid_sinr_th(int th) |
| 1108 | { |
| 1109 | if ((th >= MIN_SINR_TH) && |
| 1110 | (th <= MAX_SINR_TH)) |
| 1111 | return 1; |
| 1112 | else |
| 1113 | return 0; |
| 1114 | } |
| 1115 | |
| 1116 | static inline int is_valid_sinr_samples(int samples_cnt) |
| 1117 | { |
| 1118 | if ((samples_cnt >= MIN_SINR_SAMPLES) && |
| 1119 | (samples_cnt <= MAX_SINR_SAMPLES)) |
| 1120 | return 1; |
| 1121 | else |
| 1122 | return 0; |
| 1123 | } |
| 1124 | |
| 1125 | static inline int is_valid_fm_state(int state) |
| 1126 | { |
| 1127 | if ((state >= 0) && (state < FM_MAX_NO_STATES)) |
| 1128 | return 1; |
| 1129 | else |
| 1130 | return 0; |
| 1131 | } |
| 1132 | |
| 1133 | static inline int is_valid_blend_value(int val) |
| 1134 | { |
| 1135 | if ((val >= MIN_BLEND_HI) && (val <= MAX_BLEND_HI)) |
| 1136 | return 1; |
| 1137 | else |
| 1138 | return 0; |
| 1139 | } |
| 1140 | |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 1141 | struct radio_helium_device { |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 1142 | int tune_req; |
| 1143 | unsigned int mode; |
| 1144 | short pi; |
| 1145 | char pty; |
| 1146 | char ps_repeatcount; |
| 1147 | char prev_trans_rds; |
| 1148 | char af_jump_bit; |
| 1149 | struct hci_fm_mute_mode_req mute_mode; |
| 1150 | struct hci_fm_stereo_mode_req stereo_mode; |
| 1151 | struct hci_fm_station_rsp fm_st_rsp; |
| 1152 | struct hci_fm_search_station_req srch_st; |
| 1153 | struct hci_fm_search_rds_station_req srch_rds; |
| 1154 | struct hci_fm_search_station_list_req srch_st_list; |
| 1155 | struct hci_fm_recv_conf_req recv_conf; |
| 1156 | struct hci_fm_trans_conf_req_struct trans_conf; |
| 1157 | struct hci_fm_rds_grp_req rds_grp; |
| 1158 | unsigned char g_search_mode; |
| 1159 | unsigned char power_mode; |
| 1160 | int search_on; |
| 1161 | unsigned char spur_table_size; |
| 1162 | unsigned char g_scan_time; |
| 1163 | unsigned int g_antenna; |
| 1164 | unsigned int g_rds_grp_proc_ps; |
| 1165 | unsigned char event_mask; |
| 1166 | enum hlm_region_t region; |
| 1167 | struct hci_fm_dbg_param_rsp st_dbg_param; |
| 1168 | struct hci_ev_srch_list_compl srch_st_result; |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 1169 | struct hci_fm_riva_poke riva_data_req; |
| 1170 | struct hci_fm_ssbi_req ssbi_data_accs; |
| 1171 | struct hci_fm_ssbi_peek ssbi_peek_reg; |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 1172 | struct hci_fm_set_get_reset_agc set_get_reset_agc; |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 1173 | struct hci_fm_ch_det_threshold ch_det_threshold; |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 1174 | struct hci_fm_data_rd_rsp def_data; |
| 1175 | struct hci_fm_blend_table blend_tbl; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 1176 | } __attribute__((packed)); |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 1177 | |
| 1178 | #define set_bit(flag, bit_pos) ((flag) |= (1 << (bit_pos))) |
| 1179 | #define clear_bit(flag, bit_pos) ((flag) &= (~(1 << (bit_pos)))) |
| 1180 | #define test_bit(flag, bit_pos) ((flag) & (1 << (bit_pos))) |
| 1181 | #define clear_all_bit(flag) ((flag) &= (~0xFFFFFFFF)) |
| 1182 | #define CMD_CHDET_SINR_TH (1) |
| 1183 | #define CMD_CHDET_SINR_SAMPLE (2) |
| 1184 | #define CMD_CHDET_INTF_TH_LOW (3) |
| 1185 | #define CMD_CHDET_INTF_TH_HIGH (4) |
| 1186 | |
| 1187 | #define CMD_DEFRD_AF_RMSSI_TH (1) |
| 1188 | #define CMD_DEFRD_AF_RMSSI_SAMPLE (2) |
| 1189 | #define CMD_DEFRD_GD_CH_RMSSI_TH (3) |
| 1190 | #define CMD_DEFRD_SEARCH_ALGO (4) |
| 1191 | #define CMD_DEFRD_SINR_FIRST_STAGE (5) |
| 1192 | #define CMD_DEFRD_RMSSI_FIRST_STAGE (6) |
| 1193 | #define CMD_DEFRD_CF0TH12 (7) |
| 1194 | #define CMD_DEFRD_TUNE_POWER (8) |
| 1195 | #define CMD_DEFRD_REPEATCOUNT (9) |
Kamal Negi | 290c1e9 | 2017-05-16 11:52:53 +0530 | [diff] [blame] | 1196 | #define CMD_DEFRD_AF_ALGO (10) |
| 1197 | #define CMD_DEFRD_AF_SINR_GD_CH_TH (11) |
| 1198 | #define CMD_DEFRD_AF_SINR_TH (12) |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 1199 | |
| 1200 | #define CMD_STNPARAM_RSSI (1) |
| 1201 | #define CMD_STNPARAM_SINR (2) |
| 1202 | #define CMD_STNPARAM_INTF_DET_TH (3) |
| 1203 | |
| 1204 | #define CMD_STNDBGPARAM_BLEND (1) |
| 1205 | #define CMD_STNDBGPARAM_SOFTMUTE (2) |
| 1206 | #define CMD_STNDBGPARAM_INFBLEND (3) |
| 1207 | #define CMD_STNDBGPARAM_INFSOFTMUTE (4) |
| 1208 | #define CMD_STNDBGPARAM_PILOTPLL (5) |
| 1209 | #define CMD_STNDBGPARAM_IOVERC (6) |
| 1210 | #define CMD_STNDBGPARAM_INFDETOUT (7) |
| 1211 | |
| 1212 | #define CMD_BLENDTBL_SINR_HI (1) |
| 1213 | #define CMD_BLENDTBL_RMSSI_HI (2) |
| 1214 | |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 1215 | int hci_fm_disable_recv_req(); |
| 1216 | int helium_search_list(struct hci_fm_search_station_list_req *s_list); |
| 1217 | int helium_search_rds_stations(struct hci_fm_search_rds_station_req *rds_srch); |
| 1218 | int helium_search_stations(struct hci_fm_search_station_req *srch); |
| 1219 | int helium_cancel_search_req(); |
| 1220 | int hci_fm_set_recv_conf_req (struct hci_fm_recv_conf_req *conf); |
| 1221 | int hci_fm_get_program_service_req (); |
| 1222 | int hci_fm_get_rds_grpcounters_req (int val); |
Satish kumar sugasi | 649b990 | 2016-04-28 17:55:29 -0700 | [diff] [blame] | 1223 | int hci_fm_get_rds_grpcounters_ext_req (int val); |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 1224 | int hci_fm_set_notch_filter_req (int val); |
| 1225 | int helium_set_sig_threshold_req(char th); |
| 1226 | int helium_rds_grp_mask_req(struct hci_fm_rds_grp_req *rds_grp_msk); |
| 1227 | int helium_rds_grp_process_req(int rds_grp); |
| 1228 | int helium_set_event_mask_req(char e_mask); |
| 1229 | int helium_set_antenna_req(char ant); |
| 1230 | int helium_set_fm_mute_mode_req(struct hci_fm_mute_mode_req *mute); |
| 1231 | int hci_fm_tune_station_req(int param); |
| 1232 | int hci_set_fm_stereo_mode_req(struct hci_fm_stereo_mode_req *param); |
| 1233 | int hci_peek_data(struct hci_fm_riva_data *data); |
| 1234 | int hci_poke_data(struct hci_fm_riva_poke *data); |
| 1235 | int hci_ssbi_poke_reg(struct hci_fm_ssbi_req *data); |
| 1236 | int hci_ssbi_peek_reg(struct hci_fm_ssbi_peek *data); |
Smriti Gupta | 12ee331 | 2016-05-11 15:43:14 +0530 | [diff] [blame] | 1237 | int hci_get_set_reset_agc_req(struct hci_fm_set_get_reset_agc *data); |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 1238 | int hci_fm_get_ch_det_th(); |
| 1239 | int set_ch_det_thresholds_req(struct hci_fm_ch_det_threshold *ch_det_th); |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 1240 | int hci_fm_default_data_read_req(struct hci_fm_def_data_rd_req *def_data_rd); |
| 1241 | int hci_fm_get_blend_req(); |
| 1242 | int hci_fm_set_blend_tbl_req(struct hci_fm_blend_table *blnd_tbl); |
Kiran Kelageri | cad7171 | 2016-04-27 16:54:22 -0700 | [diff] [blame] | 1243 | int hci_fm_enable_lpf(int enable); |
Kamal Negi | 8813e0f | 2016-02-10 19:12:09 +0530 | [diff] [blame] | 1244 | int hci_fm_default_data_write_req(struct hci_fm_def_data_wr_req * data_wrt); |
| 1245 | int hci_fm_get_station_dbg_param_req(); |
| 1246 | int hci_fm_get_station_cmd_param_req(); |
Kamal Negi | ce09c30 | 2016-12-29 16:45:38 +0530 | [diff] [blame] | 1247 | int hci_fm_enable_slimbus(uint8_t enable); |
himta ram | 5698463 | 2018-03-19 13:07:29 +0530 | [diff] [blame] | 1248 | int hci_fm_enable_softmute(uint8_t enable); |
Satish kumar sugasi | 88832b9 | 2015-12-21 18:52:29 -0800 | [diff] [blame] | 1249 | |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 1250 | struct fm_hal_t { |
| 1251 | struct radio_helium_device *radio; |
himta ram | 65fd618 | 2019-03-27 19:48:18 +0530 | [diff] [blame] | 1252 | const fm_hal_callbacks_t *jni_cb; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 1253 | void *private_data; |
Smriti Gupta | db534b0 | 2017-06-23 12:59:21 +0530 | [diff] [blame] | 1254 | pthread_mutex_t cmd_lock; |
| 1255 | pthread_cond_t cmd_cond; |
| 1256 | bool set_cmd_sent; |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 1257 | }; |
| 1258 | |
| 1259 | struct fm_interface_t { |
himta ram | e8214df | 2019-12-09 20:30:01 +0530 | [diff] [blame] | 1260 | int (*hal_init)(const fm_hal_callbacks_t *p_cb); |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 1261 | int (*set_fm_ctrl)(int opcode, int val); |
himta ram | 65fd618 | 2019-03-27 19:48:18 +0530 | [diff] [blame] | 1262 | int (*get_fm_ctrl) (int opcode, int *val); |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 1263 | }; |
| 1264 | |
Satish kumar sugasi | 644b488 | 2016-05-04 20:15:31 -0700 | [diff] [blame] | 1265 | #endif /* __UAPI_RADIO_HCI_CORE_H */ |
Kamal Negi | 8a2a72a | 2016-06-30 11:43:32 +0530 | [diff] [blame] | 1266 | |