blob: 79f61bdd4038b5532632a69a1ea7a95c245191d4 [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
101#define AF_RMSSI_TH_OFFSET 1
102#define AF_RMSSI_SAMPLES_OFFSET 2
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700103/**RX CONFIG MODE**/
Kamal Negi8813e0f2016-02-10 19:12:09 +0530104#define FM_RX_CONFG_MODE 0x15
105#define FM_RX_CNFG_LEN 0x15
106#define GD_CH_RMSSI_TH_OFFSET 0x03
107#define MAX_GD_CH_RMSSI_TH 0x7F
108#define SRCH_ALGO_TYPE_OFFSET 0x00
109#define SINRFIRSTSTAGE_OFFSET 0x01
110#define RMSSIFIRSTSTAGE_OFFSET 0x02
111#define CF0TH12_BYTE1_OFFSET 0x03
112#define CF0TH12_BYTE2_OFFSET 0x04
113#define MAX_SINR_FIRSTSTAGE 0x7F
114#define MAX_RMSSI_FIRSTSTAGE 0x7F
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700115#define RDS_PS0_XFR_MODE 0x01
Kamal Negi8813e0f2016-02-10 19:12:09 +0530116#define RDS_PS0_LEN 0x06
117#define RX_REPEATE_BYTE_OFFSET 0x05
118#define FM_SPUR_TBL_SIZE 0xF0
119#define SPUR_DATA_LEN 0x10
120#define ENTRIES_EACH_CMD 0x0F
121#define SPUR_DATA_INDEX 0x02
122#define FM_AF_LIST_MAX_SIZE 0xC8
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700123#define AF_LIST_MAX (FM_AF_LIST_MAX_SIZE / 4) /* Each AF frequency consist
Kamal Negi8813e0f2016-02-10 19:12:09 +0530124 of sizeof(int) bytes */
125#define MAX_BLEND_INDEX 0x31
126
127#define FM_SRCH_CONFG_MODE 0x41
128#define FM_AFJUMP_CONFG_MODE 0x42
129#define FM_SRCH_CNFG_LEN 0x08
130#define FM_AFJUMP_CNFG_LEN 0x06
131
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700132/* HCI timeouts */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530133#define RADIO_HCI_TIMEOUT (10000) /* 10 seconds */
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700134
Satish kumar sugasibf9558e2016-05-10 14:30:17 -0700135#define ECC_EVENT_BUFSIZE 12
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700136typedef enum {
137 ASSOCIATE_JVM,
138 DISASSOCIATE_JVM
139} bt_cb_thread_evt;
140
141#define TUNE_PARAM 16
142#define SIZE_ARRAY(x) (sizeof(x) / sizeof((x)[0]))
143typedef void (*enb_result_cb)();
144typedef void (*tune_rsp_cb)(int Freq);
145typedef void (*seek_rsp_cb)(int Freq);
146typedef void (*scan_rsp_cb)();
147typedef void (*srch_list_rsp_cb)(uint16_t *scan_tbl);
148typedef void (*stereo_mode_cb)(bool status);
149typedef void (*rds_avl_sts_cb)(bool status);
150typedef void (*af_list_cb)(uint16_t *af_list);
151typedef void (*rt_cb)(char *rt);
152typedef void (*ps_cb)(char *ps);
153typedef void (*oda_cb)();
154typedef void (*rt_plus_cb)(char *rt_plus);
155typedef void (*ert_cb)(char *ert);
156typedef void (*disable_cb)();
157typedef void (*callback_thread_event)(unsigned int evt);
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700158typedef void (*rds_grp_cntrs_cb)(char *rds_params);
Satish kumar sugasi649b9902016-04-28 17:55:29 -0700159typedef void (*rds_grp_cntrs_ext_cb)(char *rds_params);
Satish kumar sugasi88832b92015-12-21 18:52:29 -0800160typedef void (*fm_peek_cb)(char *peek_rsp);
161typedef void (*fm_ssbi_peek_cb)(char *ssbi_peek_rsp);
Smriti Gupta12ee3312016-05-11 15:43:14 +0530162typedef void (*fm_agc_gain_cb)(char *agc_gain_rsp);
Satish kumar sugasi88832b92015-12-21 18:52:29 -0800163typedef void (*fm_ch_det_th_cb)(char *ch_det_rsp);
Satish kumar sugasid8731b72016-01-27 14:45:45 -0800164typedef void (*fm_ecc_evt_cb)(char *ecc_rsp);
Kamal Negi8813e0f2016-02-10 19:12:09 +0530165typedef void (*fm_sig_thr_cb) (int val, int status);
166typedef void (*fm_get_ch_det_thrs_cb) (int val, int status);
167typedef void (*fm_def_data_rd_cb) (int val, int status);
168typedef void (*fm_get_blnd_cb) (int val, int status);
169typedef void (*fm_set_ch_det_thrs_cb) (int status);
170typedef void (*fm_def_data_wrt_cb) (int status);
171typedef void (*fm_set_blnd_cb) (int status);
172typedef void (*fm_get_stn_prm_cb) (int val, int status);
173typedef void (*fm_get_stn_dbg_prm_cb) (int val, int status);
Rupesh Tatiya9917f922017-06-21 13:00:43 +0530174typedef void (*fm_enable_slimbus_cb) (int status);
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700175
176typedef struct {
177 size_t size;
178
179 enb_result_cb enabled_cb;
180 tune_rsp_cb tune_cb;
181 seek_rsp_cb seek_cmpl_cb;
182 scan_rsp_cb scan_next_cb;
183 srch_list_rsp_cb srch_list_cb;
184 stereo_mode_cb stereo_status_cb;
185 rds_avl_sts_cb rds_avail_status_cb;
186 af_list_cb af_list_update_cb;
187 rt_cb rt_update_cb;
188 ps_cb ps_update_cb;
189 oda_cb oda_update_cb;
190 rt_plus_cb rt_plus_update_cb;
191 ert_cb ert_update_cb;
192 disable_cb disabled_cb;
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700193 rds_grp_cntrs_cb rds_grp_cntrs_rsp_cb;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530194 rds_grp_cntrs_ext_cb rds_grp_cntrs_ext_rsp_cb;
Satish kumar sugasi88832b92015-12-21 18:52:29 -0800195 fm_peek_cb fm_peek_rsp_cb;
196 fm_ssbi_peek_cb fm_ssbi_peek_rsp_cb;
Smriti Gupta12ee3312016-05-11 15:43:14 +0530197 fm_agc_gain_cb fm_agc_gain_rsp_cb;
Satish kumar sugasi88832b92015-12-21 18:52:29 -0800198 fm_ch_det_th_cb fm_ch_det_th_rsp_cb;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530199 fm_ecc_evt_cb ext_country_code_cb;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700200 callback_thread_event thread_evt_cb;
Kamal Negi8813e0f2016-02-10 19:12:09 +0530201 fm_sig_thr_cb fm_get_sig_thres_cb;
202 fm_get_ch_det_thrs_cb fm_get_ch_det_thr_cb;
203 fm_def_data_rd_cb fm_def_data_read_cb;
204 fm_get_blnd_cb fm_get_blend_cb;
205 fm_set_ch_det_thrs_cb fm_set_ch_det_thr_cb;
206 fm_def_data_wrt_cb fm_def_data_write_cb;
207 fm_set_blnd_cb fm_set_blend_cb;
208 fm_get_stn_prm_cb fm_get_station_param_cb;
209 fm_get_stn_dbg_prm_cb fm_get_station_debug_param_cb;
Rupesh Tatiya9917f922017-06-21 13:00:43 +0530210 fm_enable_slimbus_cb enable_slimbus_cb;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530211} fm_hal_callbacks_t;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700212
213/* Opcode OCF */
214/* HCI recv control commands opcode */
215#define HCI_OCF_FM_ENABLE_RECV_REQ 0x0001
216#define HCI_OCF_FM_DISABLE_RECV_REQ 0x0002
217#define HCI_OCF_FM_GET_RECV_CONF_REQ 0x0003
218#define HCI_OCF_FM_SET_RECV_CONF_REQ 0x0004
219#define HCI_OCF_FM_SET_MUTE_MODE_REQ 0x0005
220#define HCI_OCF_FM_SET_STEREO_MODE_REQ 0x0006
221#define HCI_OCF_FM_SET_ANTENNA 0x0007
222#define HCI_OCF_FM_SET_SIGNAL_THRESHOLD 0x0008
223#define HCI_OCF_FM_GET_SIGNAL_THRESHOLD 0x0009
224#define HCI_OCF_FM_GET_STATION_PARAM_REQ 0x000A
225#define HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ 0x000B
226#define HCI_OCF_FM_GET_RADIO_TEXT_REQ 0x000C
227#define HCI_OCF_FM_GET_AF_LIST_REQ 0x000D
228#define HCI_OCF_FM_SEARCH_STATIONS 0x000E
229#define HCI_OCF_FM_SEARCH_RDS_STATIONS 0x000F
230#define HCI_OCF_FM_SEARCH_STATIONS_LIST 0x0010
231#define HCI_OCF_FM_CANCEL_SEARCH 0x0011
232#define HCI_OCF_FM_RDS_GRP 0x0012
233#define HCI_OCF_FM_RDS_GRP_PROCESS 0x0013
234#define HCI_OCF_FM_EN_WAN_AVD_CTRL 0x0014
235#define HCI_OCF_FM_EN_NOTCH_CTRL 0x0015
236#define HCI_OCF_FM_SET_EVENT_MASK 0x0016
237#define HCI_OCF_FM_SET_CH_DET_THRESHOLD 0x0017
238#define HCI_OCF_FM_GET_CH_DET_THRESHOLD 0x0018
239#define HCI_OCF_FM_SET_BLND_TBL 0x001B
240#define HCI_OCF_FM_GET_BLND_TBL 0x001C
Kiran Kelagericad71712016-04-27 16:54:22 -0700241#define HCI_OCF_FM_LOW_PASS_FILTER_CTRL 0x001F
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700242/* HCI trans control commans opcode*/
243#define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001
244#define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002
245#define HCI_OCF_FM_GET_TRANS_CONF_REQ 0x0003
246#define HCI_OCF_FM_SET_TRANS_CONF_REQ 0x0004
247#define HCI_OCF_FM_RDS_RT_REQ 0x0008
248#define HCI_OCF_FM_RDS_PS_REQ 0x0009
249
Kamal Negice09c302016-12-29 16:45:38 +0530250#define HCI_OCF_FM_ENABLE_SLIMBUS (0x000E)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700251
252/* HCI common control commands opcode */
253#define HCI_OCF_FM_TUNE_STATION_REQ 0x0001
254#define HCI_OCF_FM_DEFAULT_DATA_READ 0x0002
255#define HCI_OCF_FM_DEFAULT_DATA_WRITE 0x0003
256#define HCI_OCF_FM_RESET 0x0004
257#define HCI_OCF_FM_GET_FEATURE_LIST 0x0005
258#define HCI_OCF_FM_DO_CALIBRATION 0x0006
259#define HCI_OCF_FM_SET_CALIBRATION 0x0007
260#define HCI_OCF_FM_SET_SPUR_TABLE 0x0008
261#define HCI_OCF_FM_GET_SPUR_TABLE 0x0009
262
263/*HCI Status parameters commands*/
264#define HCI_OCF_FM_READ_GRP_COUNTERS 0x0001
265
Satish kumar sugasi649b9902016-04-28 17:55:29 -0700266#define HCI_OCF_FM_READ_GRP_COUNTERS_EXT 0x0002
267
268
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700269/*HCI Diagnostic commands*/
270#define HCI_OCF_FM_PEEK_DATA 0x0002
271#define HCI_OCF_FM_POKE_DATA 0x0003
272#define HCI_OCF_FM_SSBI_PEEK_REG 0x0004
273#define HCI_OCF_FM_SSBI_POKE_REG 0x0005
274#define HCI_OCF_FM_STATION_DBG_PARAM 0x0007
275#define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008
Smriti Gupta12ee3312016-05-11 15:43:14 +0530276#define HCI_FM_SET_GET_RESET_AGC 0x000D
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700277
278/* Opcode OGF */
279#define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013
280#define HCI_OGF_FM_TRANS_CTRL_CMD_REQ 0x0014
281#define HCI_OGF_FM_COMMON_CTRL_CMD_REQ 0x0015
282#define HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ 0x0016
283#define HCI_OGF_FM_TEST_CMD_REQ 0x0017
284#define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F
285
286/* Command opcode pack/unpack */
Smriti Gupta12ee3312016-05-11 15:43:14 +0530287#define hci_opcode_pack(ogf, ocf) (uint16_t) (((ocf) & 0x03ff)|((ogf) << 10))
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700288#define hci_opcode_ogf(op) (op >> 10)
289#define hci_opcode_ocf(op) (op & 0x03ff)
290#define hci_recv_ctrl_cmd_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530291 (uint16_t) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700292#define hci_trans_ctrl_cmd_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530293 (uint16_t) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf)
Kamal Negi8813e0f2016-02-10 19:12:09 +0530294#define hci_common_cmd_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530295 (uint16_t) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf)
Kamal Negi8813e0f2016-02-10 19:12:09 +0530296#define hci_status_param_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530297 (uint16_t) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf)
Kamal Negi8813e0f2016-02-10 19:12:09 +0530298#define hci_diagnostic_cmd_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530299 (uint16_t) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700300
301/* HCI commands with no arguments*/
302#define HCI_FM_ENABLE_RECV_CMD 1
303#define HCI_FM_DISABLE_RECV_CMD 2
304#define HCI_FM_GET_RECV_CONF_CMD 3
305#define HCI_FM_GET_STATION_PARAM_CMD 4
306#define HCI_FM_GET_SIGNAL_TH_CMD 5
307#define HCI_FM_GET_PROGRAM_SERVICE_CMD 6
308#define HCI_FM_GET_RADIO_TEXT_CMD 7
309#define HCI_FM_GET_AF_LIST_CMD 8
310#define HCI_FM_CANCEL_SEARCH_CMD 9
311#define HCI_FM_RESET_CMD 10
312#define HCI_FM_GET_FEATURES_CMD 11
313#define HCI_FM_STATION_DBG_PARAM_CMD 12
314#define HCI_FM_ENABLE_TRANS_CMD 13
315#define HCI_FM_DISABLE_TRANS_CMD 14
316#define HCI_FM_GET_TX_CONFIG 15
317#define HCI_FM_GET_DET_CH_TH_CMD 16
318#define HCI_FM_GET_BLND_TBL_CMD 17
319
320/* Defines for FM TX*/
321#define TX_PS_DATA_LENGTH 108
322#define TX_RT_DATA_LENGTH 64
323#define PS_STRING_LEN 9
324
325/* ----- HCI Command request ----- */
326struct hci_fm_recv_conf_req {
327 char emphasis;
328 char ch_spacing;
329 char rds_std;
330 char hlsi;
Kamal Negi8813e0f2016-02-10 19:12:09 +0530331 int band_low_limit;
332 int band_high_limit;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700333} ;
334
335/* ----- HCI Command request ----- */
336struct hci_fm_trans_conf_req_struct {
337 char emphasis;
338 char rds_std;
Kamal Negi8813e0f2016-02-10 19:12:09 +0530339 int band_low_limit;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700340 int band_high_limit;
341} ;
342
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700343/* ----- HCI Command request ----- */
344struct hci_fm_tx_ps {
345 char ps_control;
346 short pi;
347 char pty;
348 char ps_repeatcount;
349 char ps_num;
350 char ps_data[TX_PS_DATA_LENGTH];
351} ;
352
353struct hci_fm_tx_rt {
354 char rt_control;
355 short pi;
356 char pty;
357 char rt_len;
358 char rt_data[TX_RT_DATA_LENGTH];
359} ;
360
361struct hci_fm_mute_mode_req {
362 char hard_mute;
363 char soft_mute;
364} ;
365
366struct hci_fm_stereo_mode_req {
367 char stereo_mode;
368 char sig_blend;
369 char intf_blend;
370 char most_switch;
371} ;
372
373struct hci_fm_search_station_req {
374 char srch_mode;
375 char scan_time;
376 char srch_dir;
377} ;
378
379struct hci_fm_search_rds_station_req {
380 struct hci_fm_search_station_req srch_station;
381 char srch_pty;
382 short srch_pi;
383} ;
384
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700385struct hci_fm_rds_grp_cntrs_params {
386 int totalRdsSBlockErrors;
387 int totalRdsGroups;
388 int totalRdsGroup0;
389 int totalRdsGroup2;
390 int totalRdsBlockB;
391 int totalRdsProcessedGroup0;
392 int totalRdsProcessedGroup2;
393 int totalRdsGroupFiltered;
394 int totalRdsChangeFiltered;
395} ;
396
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700397struct hci_fm_search_station_list_req {
398 char srch_list_mode;
399 char srch_list_dir;
400 int srch_list_max;
401 char srch_pty;
402} ;
403
404struct hci_fm_rds_grp_req {
405 int rds_grp_enable_mask;
406 int rds_buf_size;
407 char en_rds_change_filter;
408} ;
409
410struct hci_fm_en_avd_ctrl_req {
411 char no_freqs;
412 char freq_index;
413 char lo_shft;
414 short freq_min;
415 short freq_max;
416} ;
417
418struct hci_fm_def_data_rd_req {
419 char mode;
420 char length;
421 char param_len;
422 char param;
423} ;
424
425struct hci_fm_def_data_wr_req {
426 char mode;
427 char length;
428 char data[DEFAULT_DATA_SIZE];
429} ;
430
431struct hci_fm_riva_data {
432 char subopcode;
433 int start_addr;
434 char length;
435} ;
436
437struct hci_fm_riva_poke {
438 struct hci_fm_riva_data cmd_params;
439 char data[MAX_RIVA_PEEK_RSP_SIZE];
440} ;
441
442struct hci_fm_ssbi_req {
443 short start_addr;
444 char data;
445} ;
446struct hci_fm_ssbi_peek {
447 short start_address;
448} ;
449
Smriti Gupta12ee3312016-05-11 15:43:14 +0530450struct hci_fm_set_get_reset_agc {
451 char ucctrl;
452 char ucgainstate;
453} ;
454
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700455struct hci_fm_ch_det_threshold {
456 char sinr;
457 char sinr_samples;
458 char low_th;
459 char high_th;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700460} ;
461
462struct hci_fm_blend_table {
Kamal Negi8813e0f2016-02-10 19:12:09 +0530463 char BlendType;
464 char BlendRampRateUp;
465 char BlendDebounceNumSampleUp;
466 char BlendDebounceIdxUp;
467 char BlendSinrIdxSkipStep;
468 char BlendSinrHi;
469 char BlendRmssiHi;
470 char BlendIndexHi;
471 char BlendIndex[MAX_BLEND_INDEX];
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700472} ;
473
Kamal Negi8813e0f2016-02-10 19:12:09 +0530474struct hci_fm_def_data_rd {
475 char mode;
476 char length;
477 char param_len;
478 char param;
479};
480
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700481/*HCI events*/
482#define HCI_EV_TUNE_STATUS 0x01
483#define HCI_EV_RDS_LOCK_STATUS 0x02
484#define HCI_EV_STEREO_STATUS 0x03
485#define HCI_EV_SERVICE_AVAILABLE 0x04
486#define HCI_EV_SEARCH_PROGRESS 0x05
487#define HCI_EV_SEARCH_RDS_PROGRESS 0x06
488#define HCI_EV_SEARCH_LIST_PROGRESS 0x07
489#define HCI_EV_RDS_RX_DATA 0x08
490#define HCI_EV_PROGRAM_SERVICE 0x09
491#define HCI_EV_RADIO_TEXT 0x0A
492#define HCI_EV_FM_AF_LIST 0x0B
493#define HCI_EV_TX_RDS_GRP_AVBLE 0x0C
494#define HCI_EV_TX_RDS_GRP_COMPL 0x0D
495#define HCI_EV_TX_RDS_CONT_GRP_COMPL 0x0E
496#define HCI_EV_CMD_COMPLETE 0x0F
497#define HCI_EV_CMD_STATUS 0x10
498#define HCI_EV_TUNE_COMPLETE 0x11
499#define HCI_EV_SEARCH_COMPLETE 0x12
500#define HCI_EV_SEARCH_RDS_COMPLETE 0x13
501#define HCI_EV_SEARCH_LIST_COMPLETE 0x14
Satish kumar sugasid8731b72016-01-27 14:45:45 -0800502
503#define HCI_EV_EXT_COUNTRY_CODE 0x17
Satish kumar sugasib0ba3c82016-05-04 20:18:23 -0700504#define HCI_EV_RADIO_TEXT_PLUS_ID 0x18
505#define HCI_EV_RADIO_TEXT_PLUS_TAG 0x19
Satish kumar sugasi8a34ad32015-10-19 18:09:49 -0700506#define HCI_EV_HW_ERR_EVENT 0x1A
507
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700508#define HCI_REQ_DONE 0
509#define HCI_REQ_PEND 1
510#define HCI_REQ_CANCELED 2
511#define HCI_REQ_STATUS 3
512
513#define MAX_RAW_RDS_GRPS 21
514
515#define RDSGRP_DATA_OFFSET 0x1
516
517/*RT PLUS*/
518#define DUMMY_CLASS 0
519#define RT_PLUS_LEN_1_TAG 3
Kamal Negi8813e0f2016-02-10 19:12:09 +0530520#define RT_ERT_FLAG_BIT 5
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700521
522/*TAG1*/
Kamal Negi8813e0f2016-02-10 19:12:09 +0530523#define TAG1_MSB_OFFSET 3
524#define TAG1_MSB_MASK 7
525#define TAG1_LSB_OFFSET 5
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700526#define TAG1_POS_MSB_MASK 31
527#define TAG1_POS_MSB_OFFSET 1
528#define TAG1_POS_LSB_OFFSET 7
Kamal Negi8813e0f2016-02-10 19:12:09 +0530529#define TAG1_LEN_OFFSET 1
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700530#define TAG1_LEN_MASK 63
531
532/*TAG2*/
Kamal Negi8813e0f2016-02-10 19:12:09 +0530533#define TAG2_MSB_OFFSET 5
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700534#define TAG2_MSB_MASK 1
Kamal Negi8813e0f2016-02-10 19:12:09 +0530535#define TAG2_LSB_OFFSET 3
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700536#define TAG2_POS_MSB_MASK 7
537#define TAG2_POS_MSB_OFFSET 3
538#define TAG2_POS_LSB_OFFSET 5
539#define TAG2_LEN_MASK 31
540
541#define AGT_MASK 31
542/*Extract 5 left most bits of lsb of 2nd block*/
Kamal Negi8813e0f2016-02-10 19:12:09 +0530543#define AGT(x) (x & AGT_MASK)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700544/*16 bits of 4th block*/
545#define AID(lsb, msb) ((msb << 8) | (lsb))
546/*Extract 5 right most bits of msb of 2nd block*/
547#define GTC(blk2msb) (blk2msb >> 3)
548
549#define GRP_3A 0x6
550#define RT_PLUS_AID 0x4bd7
551
552/*ERT*/
Kamal Negi8813e0f2016-02-10 19:12:09 +0530553#define ERT_AID 0x6552
554#define CARRIAGE_RETURN 0x000D
555#define MAX_ERT_SEGMENT 31
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700556#define ERT_FORMAT_DIR_BIT 1
557
558#define EXTRACT_BIT(data, bit_pos) ((data & (1 << bit_pos)) >> bit_pos)
559
560struct hci_ev_tune_status {
561 char sub_event;
562 int station_freq;
563 char serv_avble;
564 char rssi;
565 char stereo_prg;
566 char rds_sync_status;
567 char mute_mode;
568 char sinr;
569 char intf_det_th;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530570}__attribute__((packed)) ;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700571
572struct rds_blk_data {
573 char rdsMsb;
574 char rdsLsb;
575 char blockStatus;
576} ;
577
578struct rds_grp_data {
579 struct rds_blk_data rdsBlk[4];
580} ;
581
582struct hci_ev_rds_rx_data {
583 char num_rds_grps;
584 struct rds_grp_data rds_grp_data[MAX_RAW_RDS_GRPS];
585} ;
586
587struct hci_ev_prg_service {
588 short pi_prg_id;
589 char pty_prg_type;
590 char ta_prg_code_type;
591 char ta_ann_code_flag;
592 char ms_switch_code_flag;
593 char dec_id_ctrl_code_flag;
594 char ps_num;
595 char prg_service_name[119];
596} ;
597
598struct hci_ev_radio_text {
599 short pi_prg_id;
600 char pty_prg_type;
601 char ta_prg_code_type;
602 char txt_ab_flag;
603 char radio_txt[64];
604} ;
605
606struct hci_ev_af_list {
607 int tune_freq;
608 short pi_code;
609 char af_size;
610 char af_list[FM_AF_LIST_MAX_SIZE];
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530611} __attribute__((packed)) ;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700612
613struct hci_ev_cmd_complete {
614 char num_hci_cmd_pkts;
615 short cmd_opcode;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530616} __attribute((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700617
618struct hci_ev_cmd_status {
619 char status;
620 char num_hci_cmd_pkts;
621 short status_opcode;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530622} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700623
624struct hci_ev_srch_st {
625 int station_freq;
626 char rds_cap;
627 char pty;
628 short status_opcode;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530629} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700630
631struct hci_ev_rel_freq {
632 char rel_freq_msb;
633 char rel_freq_lsb;
634
635} ;
636struct hci_ev_srch_list_compl {
637 char num_stations_found;
638 struct hci_ev_rel_freq rel_freq[20];
639} ;
640
641/* ----- HCI Event Response ----- */
642struct hci_fm_conf_rsp {
643 char status;
644 struct hci_fm_recv_conf_req recv_conf_rsp;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530645} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700646
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700647struct hci_fm_rds_grp_cntrs_rsp {
648 char status;
649 struct hci_fm_rds_grp_cntrs_params recv_rds_grp_cntrs_rsp;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530650} __attribute__((packed));
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700651
652
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700653struct hci_fm_get_trans_conf_rsp {
654 char status;
655 struct hci_fm_trans_conf_req_struct trans_conf_rsp;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530656} __attribute__((packed));
657
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700658struct hci_fm_sig_threshold_rsp {
659 char status;
660 char sig_threshold;
661} ;
662
663struct hci_fm_station_rsp {
664 struct hci_ev_tune_status station_rsp;
665} ;
666
667struct hci_fm_prgm_srv_rsp {
668 char status;
669 struct hci_ev_prg_service prg_srv;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530670} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700671
672struct hci_fm_radio_txt_rsp {
673 char status;
674 struct hci_ev_radio_text rd_txt;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530675} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700676
677struct hci_fm_af_list_rsp {
678 char status;
679 struct hci_ev_af_list rd_txt;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530680} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700681
682struct hci_fm_data_rd_rsp {
Kamal Negi8813e0f2016-02-10 19:12:09 +0530683 char data_len;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700684 char data[DEFAULT_DATA_SIZE];
685} ;
686
687struct hci_fm_feature_list_rsp {
688 char status;
689 char feature_mask;
690} ;
691
692struct hci_fm_dbg_param_rsp {
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700693 char blend;
694 char soft_mute;
695 char inf_blend;
696 char inf_soft_mute;
697 char pilot_pil;
698 char io_verc;
699 char in_det_out;
700} ;
701
Kamal Negi8813e0f2016-02-10 19:12:09 +0530702#define CLKSPURID_INDEX0 0
703#define CLKSPURID_INDEX1 5
704#define CLKSPURID_INDEX2 10
705#define CLKSPURID_INDEX3 15
706#define CLKSPURID_INDEX4 20
707#define CLKSPURID_INDEX5 25
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700708
Kamal Negi8813e0f2016-02-10 19:12:09 +0530709#define MAX_SPUR_FREQ_LIMIT 30
710#define CKK_SPUR 0x3B
711#define SPUR_DATA_SIZE 0x4
712#define SPUR_ENTRIES_PER_ID 0x5
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700713
714#define COMPUTE_SPUR(val) ((((val) - (76000)) / (50)))
715#define GET_FREQ(val, bit) ((bit == 1) ? ((val) >> 8) : ((val) & 0xFF))
716#define GET_SPUR_ENTRY_LEVEL(val) ((val) / (5))
717
718struct hci_fm_spur_data {
Kamal Negi8813e0f2016-02-10 19:12:09 +0530719 int freq[MAX_SPUR_FREQ_LIMIT];
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700720 char rmssi[MAX_SPUR_FREQ_LIMIT];
721 char enable[MAX_SPUR_FREQ_LIMIT];
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530722} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700723
724/* HCI dev events */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530725#define RADIO_HCI_DEV_REG 1
726#define RADIO_HCI_DEV_WRITE 2
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700727
Kamal Negi8813e0f2016-02-10 19:12:09 +0530728#define hci_req_lock(d) mutex_lock(&d->req_lock)
729#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700730
731/* FM RDS */
732#define RDS_PTYPE 2
733#define RDS_PID_LOWER 1
734#define RDS_PID_HIGHER 0
735#define RDS_OFFSET 5
736#define RDS_PS_LENGTH_OFFSET 7
737#define RDS_STRING 8
738#define RDS_PS_DATA_OFFSET 8
739#define RDS_CONFIG_OFFSET 3
740#define RDS_AF_JUMP_OFFSET 4
741#define PI_CODE_OFFSET 4
742#define AF_SIZE_OFFSET 6
743#define AF_LIST_OFFSET 7
744#define RT_A_B_FLAG_OFFSET 4
745/*FM states*/
746
747enum radio_state_t {
748 FM_OFF,
749 FM_RECV,
750 FM_TRANS,
751 FM_RESET,
752 FM_CALIB,
753 FM_TURNING_OFF,
754 FM_RECV_TURNING_ON,
755 FM_TRANS_TURNING_ON,
756 FM_MAX_NO_STATES,
757};
758
759enum emphasis_type {
760 FM_RX_EMP75 = 0x0,
761 FM_RX_EMP50 = 0x1
762};
763
764enum channel_space_type {
765 FM_RX_SPACE_200KHZ = 0x0,
766 FM_RX_SPACE_100KHZ = 0x1,
767 FM_RX_SPACE_50KHZ = 0x2
768};
769
770enum high_low_injection {
771 AUTO_HI_LO_INJECTION = 0x0,
772 LOW_SIDE_INJECTION = 0x1,
773 HIGH_SIDE_INJECTION = 0x2
774};
775
776enum fm_rds_type {
777 FM_RX_RDBS_SYSTEM = 0x0,
778 FM_RX_RDS_SYSTEM = 0x1
779};
780
781enum hlm_region_t {
782 HELIUM_REGION_US,
783 HELIUM_REGION_EU,
784 HELIUM_REGION_JAPAN,
785 HELIUM_REGION_JAPAN_WIDE,
786 HELIUM_REGION_OTHER
787};
788
789/* Search options */
790enum search_t {
791 SEEK,
792 SCAN,
793 SCAN_FOR_STRONG,
794 SCAN_FOR_WEAK,
795 RDS_SEEK_PTY,
796 RDS_SCAN_PTY,
797 RDS_SEEK_PI,
798 RDS_AF_JUMP,
799};
800
801enum spur_entry_levels {
802 ENTRY_0,
803 ENTRY_1,
804 ENTRY_2,
805 ENTRY_3,
806 ENTRY_4,
807 ENTRY_5,
808};
809
810/* Band limits */
811#define REGION_US_EU_BAND_LOW 87500
812#define REGION_US_EU_BAND_HIGH 108000
813#define REGION_JAPAN_STANDARD_BAND_LOW 76000
814#define REGION_JAPAN_STANDARD_BAND_HIGH 90000
815#define REGION_JAPAN_WIDE_BAND_LOW 90000
816#define REGION_JAPAN_WIDE_BAND_HIGH 108000
817
818#define SRCH_MODE 0x07
819#define SRCH_DIR 0x08 /* 0-up 1-down */
820#define SCAN_DWELL 0x70
Kamal Negi8813e0f2016-02-10 19:12:09 +0530821#define SRCH_ON 0x80
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700822
823/* I/O Control */
824#define IOC_HRD_MUTE 0x03
825#define IOC_SFT_MUTE 0x01
826#define IOC_MON_STR 0x01
827#define IOC_SIG_BLND 0x01
828#define IOC_INTF_BLND 0x01
829#define IOC_ANTENNA 0x01
830
831/* RDS Control */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530832#define RDS_ON 0x01
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700833#define RDS_BUF_SZ 100
834
835/* constants */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530836#define RDS_BLOCKS_NUM (4)
837#define BYTES_PER_BLOCK (3)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700838#define MAX_PS_LENGTH (108)
839#define MAX_RT_LENGTH (64)
840#define RDS_GRP_CNTR_LEN (36)
841#define RX_RT_DATA_LENGTH (63)
842/* Search direction */
843#define SRCH_DIR_UP (0)
844#define SRCH_DIR_DOWN (1)
845
846/*Search RDS stations*/
847#define SEARCH_RDS_STNS_MODE_OFFSET 4
848
849/*Search Station list */
850#define PARAMS_PER_STATION 0x08
851#define STN_NUM_OFFSET 0x01
852#define STN_FREQ_OFFSET 0x02
853#define KHZ_TO_MHZ 1000
854#define GET_MSB(x)((x >> 8) & 0xFF)
855#define GET_LSB(x)((x) & 0xFF)
856
857/* control options */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530858#define CTRL_ON (1)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700859#define CTRL_OFF (0)
860
861/*Diagnostic commands*/
862
863#define RIVA_PEEK_OPCODE 0x0D
864#define RIVA_POKE_OPCODE 0x0C
865
866#define PEEK_DATA_OFSET 0x1
867#define RIVA_PEEK_PARAM 0x6
868#define RIVA_PEEK_LEN_OFSET 0x6
869#define SSBI_PEEK_LEN 0x01
870/*Calibration data*/
871#define PROCS_CALIB_MODE 1
872#define PROCS_CALIB_SIZE 23
873#define DC_CALIB_MODE 2
874#define DC_CALIB_SIZE 48
875#define RSB_CALIB_MODE 3
876#define RSB_CALIB_SIZE 4
877#define CALIB_DATA_OFSET 2
878#define CALIB_MODE_OFSET 1
879#define MAX_CALIB_SIZE 75
880
881/* Channel validity */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530882#define INVALID_CHANNEL (0)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700883#define VALID_CHANNEL (1)
884
885struct hci_fm_set_cal_req_proc {
886 char mode;
887 /*Max process calibration data size*/
888 char data[PROCS_CALIB_SIZE];
889} ;
890
891struct hci_fm_set_cal_req_dc {
892 char mode;
893 /*Max DC calibration data size*/
894 char data[DC_CALIB_SIZE];
895} ;
896
897struct hci_cc_do_calibration_rsp {
898 char status;
899 char mode;
900 char data[MAX_CALIB_SIZE];
901} ;
902
903struct hci_fm_set_spur_table_req {
904 char mode;
905 char no_of_freqs_entries;
906 char spur_data[FM_SPUR_TBL_SIZE];
907} ;
908/* Low Power mode*/
909#define SIG_LEVEL_INTR (1 << 0)
910#define RDS_SYNC_INTR (1 << 1)
911#define AUDIO_CTRL_INTR (1 << 2)
912#define AF_JUMP_ENABLE (1 << 4)
913
914int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
915 struct radio_hci_dev *hdev);
916int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
917 struct radio_hci_dev *hdev);
918int hci_fm_do_calibration(char *arg, struct radio_hci_dev *hdev);
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700919
920static inline int is_valid_tone(int tone)
921{
922 if ((tone >= MIN_TX_TONE_VAL) &&
923 (tone <= MAX_TX_TONE_VAL))
924 return 1;
925 else
926 return 0;
927}
928
929static inline int is_valid_hard_mute(int hard_mute)
930{
931 if ((hard_mute >= MIN_HARD_MUTE_VAL) &&
932 (hard_mute <= MAX_HARD_MUTE_VAL))
933 return 1;
934 else
935 return 0;
936}
937
938static inline int is_valid_srch_mode(int srch_mode)
939{
940 if ((srch_mode >= MIN_SRCH_MODE) &&
941 (srch_mode <= MAX_SRCH_MODE))
942 return 1;
943 else
944 return 0;
945}
946
947static inline int is_valid_scan_dwell_prd(int scan_dwell_prd)
948{
949 if ((scan_dwell_prd >= MIN_SCAN_DWELL) &&
950 (scan_dwell_prd <= MAX_SCAN_DWELL))
951 return 1;
952 else
953 return 0;
954}
955
956static inline int is_valid_sig_th(int sig_th)
957{
958 if ((sig_th >= MIN_SIG_TH) &&
959 (sig_th <= MAX_SIG_TH))
960 return 1;
961 else
962 return 0;
963}
964
965static inline int is_valid_pty(int pty)
966{
967 if ((pty >= MIN_PTY) &&
968 (pty <= MAX_PTY))
969 return 1;
970 else
971 return 0;
972}
973
974static inline int is_valid_pi(int pi)
975{
976 if ((pi >= MIN_PI) &&
977 (pi <= MAX_PI))
978 return 1;
979 else
980 return 0;
981}
982
983static inline int is_valid_srch_station_cnt(int cnt)
984{
985 if ((cnt >= MIN_SRCH_STATIONS_CNT) &&
986 (cnt <= MAX_SRCH_STATIONS_CNT))
987 return 1;
988 else
989 return 0;
990}
991
992static inline int is_valid_chan_spacing(int spacing)
993{
994 if ((spacing >= MIN_CHAN_SPACING) &&
995 (spacing <= MAX_CHAN_SPACING))
996 return 1;
997 else
998 return 0;
999}
1000
1001static inline int is_valid_emphasis(int emphasis)
1002{
1003 if ((emphasis >= MIN_EMPHASIS) &&
1004 (emphasis <= MAX_EMPHASIS))
1005 return 1;
1006 else
1007 return 0;
1008}
1009
1010static inline int is_valid_rds_std(int rds_std)
1011{
1012 if ((rds_std >= MIN_RDS_STD) &&
1013 (rds_std <= MAX_RDS_STD))
1014 return 1;
1015 else
1016 return 0;
1017}
1018
1019static inline int is_valid_antenna(int antenna_type)
1020{
1021 if ((antenna_type >= MIN_ANTENNA_VAL) &&
1022 (antenna_type <= MAX_ANTENNA_VAL))
1023 return 1;
1024 else
1025 return 0;
1026}
1027
1028static inline int is_valid_ps_repeat_cnt(int cnt)
1029{
1030 if ((cnt >= MIN_TX_PS_REPEAT_CNT) &&
1031 (cnt <= MAX_TX_PS_REPEAT_CNT))
1032 return 1;
1033 else
1034 return 0;
1035}
1036
1037static inline int is_valid_soft_mute(int soft_mute)
1038{
1039 if ((soft_mute >= MIN_SOFT_MUTE) &&
1040 (soft_mute <= MAX_SOFT_MUTE))
1041 return 1;
1042 else
1043 return 0;
1044}
1045
1046static inline int is_valid_peek_len(int len)
1047{
1048 if ((len >= MIN_PEEK_ACCESS_LEN) &&
1049 (len <= MAX_PEEK_ACCESS_LEN))
1050 return 1;
1051 else
1052 return 0;
1053}
1054
1055static inline int is_valid_reset_cntr(int cntr)
1056{
1057 if ((cntr >= MIN_RESET_CNTR) &&
1058 (cntr <= MAX_RESET_CNTR))
1059 return 1;
1060 else
1061 return 0;
1062}
1063
1064static inline int is_valid_hlsi(int hlsi)
1065{
1066 if ((hlsi >= MIN_HLSI) &&
1067 (hlsi <= MAX_HLSI))
1068 return 1;
1069 else
1070 return 0;
1071}
1072
1073static inline int is_valid_notch_filter(int filter)
1074{
1075 if ((filter >= MIN_NOTCH_FILTER) &&
1076 (filter <= MAX_NOTCH_FILTER))
1077 return 1;
1078 else
1079 return 0;
1080}
1081
1082static inline int is_valid_intf_det_low_th(int th)
1083{
1084 if ((th >= MIN_INTF_DET_OUT_LW_TH) &&
1085 (th <= MAX_INTF_DET_OUT_LW_TH))
1086 return 1;
1087 else
1088 return 0;
1089}
1090
1091static inline int is_valid_intf_det_hgh_th(int th)
1092{
1093 if ((th >= MIN_INTF_DET_OUT_HG_TH) &&
1094 (th <= MAX_INTF_DET_OUT_HG_TH))
1095 return 1;
1096 else
1097 return 0;
1098}
1099
1100static inline int is_valid_sinr_th(int th)
1101{
1102 if ((th >= MIN_SINR_TH) &&
1103 (th <= MAX_SINR_TH))
1104 return 1;
1105 else
1106 return 0;
1107}
1108
1109static inline int is_valid_sinr_samples(int samples_cnt)
1110{
1111 if ((samples_cnt >= MIN_SINR_SAMPLES) &&
1112 (samples_cnt <= MAX_SINR_SAMPLES))
1113 return 1;
1114 else
1115 return 0;
1116}
1117
1118static inline int is_valid_fm_state(int state)
1119{
1120 if ((state >= 0) && (state < FM_MAX_NO_STATES))
1121 return 1;
1122 else
1123 return 0;
1124}
1125
1126static inline int is_valid_blend_value(int val)
1127{
1128 if ((val >= MIN_BLEND_HI) && (val <= MAX_BLEND_HI))
1129 return 1;
1130 else
1131 return 0;
1132}
1133
Kamal Negi8a2a72a2016-06-30 11:43:32 +05301134struct radio_helium_device {
Satish kumar sugasi644b4882016-05-04 20:15:31 -07001135 int tune_req;
1136 unsigned int mode;
1137 short pi;
1138 char pty;
1139 char ps_repeatcount;
1140 char prev_trans_rds;
1141 char af_jump_bit;
1142 struct hci_fm_mute_mode_req mute_mode;
1143 struct hci_fm_stereo_mode_req stereo_mode;
1144 struct hci_fm_station_rsp fm_st_rsp;
1145 struct hci_fm_search_station_req srch_st;
1146 struct hci_fm_search_rds_station_req srch_rds;
1147 struct hci_fm_search_station_list_req srch_st_list;
1148 struct hci_fm_recv_conf_req recv_conf;
1149 struct hci_fm_trans_conf_req_struct trans_conf;
1150 struct hci_fm_rds_grp_req rds_grp;
1151 unsigned char g_search_mode;
1152 unsigned char power_mode;
1153 int search_on;
1154 unsigned char spur_table_size;
1155 unsigned char g_scan_time;
1156 unsigned int g_antenna;
1157 unsigned int g_rds_grp_proc_ps;
1158 unsigned char event_mask;
1159 enum hlm_region_t region;
1160 struct hci_fm_dbg_param_rsp st_dbg_param;
1161 struct hci_ev_srch_list_compl srch_st_result;
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001162 struct hci_fm_riva_poke riva_data_req;
1163 struct hci_fm_ssbi_req ssbi_data_accs;
1164 struct hci_fm_ssbi_peek ssbi_peek_reg;
Smriti Gupta12ee3312016-05-11 15:43:14 +05301165 struct hci_fm_set_get_reset_agc set_get_reset_agc;
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001166 struct hci_fm_ch_det_threshold ch_det_threshold;
Kamal Negi8813e0f2016-02-10 19:12:09 +05301167 struct hci_fm_data_rd_rsp def_data;
1168 struct hci_fm_blend_table blend_tbl;
Kamal Negi8a2a72a2016-06-30 11:43:32 +05301169} __attribute__((packed));
Kamal Negi8813e0f2016-02-10 19:12:09 +05301170
1171#define set_bit(flag, bit_pos) ((flag) |= (1 << (bit_pos)))
1172#define clear_bit(flag, bit_pos) ((flag) &= (~(1 << (bit_pos))))
1173#define test_bit(flag, bit_pos) ((flag) & (1 << (bit_pos)))
1174#define clear_all_bit(flag) ((flag) &= (~0xFFFFFFFF))
1175#define CMD_CHDET_SINR_TH (1)
1176#define CMD_CHDET_SINR_SAMPLE (2)
1177#define CMD_CHDET_INTF_TH_LOW (3)
1178#define CMD_CHDET_INTF_TH_HIGH (4)
1179
1180#define CMD_DEFRD_AF_RMSSI_TH (1)
1181#define CMD_DEFRD_AF_RMSSI_SAMPLE (2)
1182#define CMD_DEFRD_GD_CH_RMSSI_TH (3)
1183#define CMD_DEFRD_SEARCH_ALGO (4)
1184#define CMD_DEFRD_SINR_FIRST_STAGE (5)
1185#define CMD_DEFRD_RMSSI_FIRST_STAGE (6)
1186#define CMD_DEFRD_CF0TH12 (7)
1187#define CMD_DEFRD_TUNE_POWER (8)
1188#define CMD_DEFRD_REPEATCOUNT (9)
1189
1190#define CMD_STNPARAM_RSSI (1)
1191#define CMD_STNPARAM_SINR (2)
1192#define CMD_STNPARAM_INTF_DET_TH (3)
1193
1194#define CMD_STNDBGPARAM_BLEND (1)
1195#define CMD_STNDBGPARAM_SOFTMUTE (2)
1196#define CMD_STNDBGPARAM_INFBLEND (3)
1197#define CMD_STNDBGPARAM_INFSOFTMUTE (4)
1198#define CMD_STNDBGPARAM_PILOTPLL (5)
1199#define CMD_STNDBGPARAM_IOVERC (6)
1200#define CMD_STNDBGPARAM_INFDETOUT (7)
1201
1202#define CMD_BLENDTBL_SINR_HI (1)
1203#define CMD_BLENDTBL_RMSSI_HI (2)
1204
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001205int hci_fm_disable_recv_req();
1206int helium_search_list(struct hci_fm_search_station_list_req *s_list);
1207int helium_search_rds_stations(struct hci_fm_search_rds_station_req *rds_srch);
1208int helium_search_stations(struct hci_fm_search_station_req *srch);
1209int helium_cancel_search_req();
1210int hci_fm_set_recv_conf_req (struct hci_fm_recv_conf_req *conf);
1211int hci_fm_get_program_service_req ();
1212int hci_fm_get_rds_grpcounters_req (int val);
Satish kumar sugasi649b9902016-04-28 17:55:29 -07001213int hci_fm_get_rds_grpcounters_ext_req (int val);
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001214int hci_fm_set_notch_filter_req (int val);
1215int helium_set_sig_threshold_req(char th);
1216int helium_rds_grp_mask_req(struct hci_fm_rds_grp_req *rds_grp_msk);
1217int helium_rds_grp_process_req(int rds_grp);
1218int helium_set_event_mask_req(char e_mask);
1219int helium_set_antenna_req(char ant);
1220int helium_set_fm_mute_mode_req(struct hci_fm_mute_mode_req *mute);
1221int hci_fm_tune_station_req(int param);
1222int hci_set_fm_stereo_mode_req(struct hci_fm_stereo_mode_req *param);
1223int hci_peek_data(struct hci_fm_riva_data *data);
1224int hci_poke_data(struct hci_fm_riva_poke *data);
1225int hci_ssbi_poke_reg(struct hci_fm_ssbi_req *data);
1226int hci_ssbi_peek_reg(struct hci_fm_ssbi_peek *data);
Smriti Gupta12ee3312016-05-11 15:43:14 +05301227int hci_get_set_reset_agc_req(struct hci_fm_set_get_reset_agc *data);
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001228int hci_fm_get_ch_det_th();
1229int set_ch_det_thresholds_req(struct hci_fm_ch_det_threshold *ch_det_th);
Kamal Negi8813e0f2016-02-10 19:12:09 +05301230int hci_fm_default_data_read_req(struct hci_fm_def_data_rd_req *def_data_rd);
1231int hci_fm_get_blend_req();
1232int hci_fm_set_blend_tbl_req(struct hci_fm_blend_table *blnd_tbl);
Kiran Kelagericad71712016-04-27 16:54:22 -07001233int hci_fm_enable_lpf(int enable);
Kamal Negi8813e0f2016-02-10 19:12:09 +05301234int hci_fm_default_data_write_req(struct hci_fm_def_data_wr_req * data_wrt);
1235int hci_fm_get_station_dbg_param_req();
1236int hci_fm_get_station_cmd_param_req();
Kamal Negice09c302016-12-29 16:45:38 +05301237int hci_fm_enable_slimbus(uint8_t enable);
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001238
Kamal Negi8a2a72a2016-06-30 11:43:32 +05301239struct fm_hal_t {
1240 struct radio_helium_device *radio;
1241 fm_hal_callbacks_t *jni_cb;
1242 void *private_data;
1243};
1244
1245struct fm_interface_t {
1246 int (*init)(const fm_hal_callbacks_t *p_cb);
1247 int (*set_fm_ctrl)(int opcode, int val);
Kamal Negi31bed2c2016-10-06 10:47:19 +05301248 void (*get_fm_ctrl) (int opcode, int *val);
Kamal Negi8a2a72a2016-06-30 11:43:32 +05301249};
1250
Satish kumar sugasi644b4882016-05-04 20:15:31 -07001251#endif /* __UAPI_RADIO_HCI_CORE_H */
Kamal Negi8a2a72a2016-06-30 11:43:32 +05301252