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