blob: a67c981b837aa8fb03cdbd9142cee9bb81f295e6 [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);
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700174
175typedef struct {
176 size_t size;
177
178 enb_result_cb enabled_cb;
179 tune_rsp_cb tune_cb;
180 seek_rsp_cb seek_cmpl_cb;
181 scan_rsp_cb scan_next_cb;
182 srch_list_rsp_cb srch_list_cb;
183 stereo_mode_cb stereo_status_cb;
184 rds_avl_sts_cb rds_avail_status_cb;
185 af_list_cb af_list_update_cb;
186 rt_cb rt_update_cb;
187 ps_cb ps_update_cb;
188 oda_cb oda_update_cb;
189 rt_plus_cb rt_plus_update_cb;
190 ert_cb ert_update_cb;
191 disable_cb disabled_cb;
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700192 rds_grp_cntrs_cb rds_grp_cntrs_rsp_cb;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530193 rds_grp_cntrs_ext_cb rds_grp_cntrs_ext_rsp_cb;
Satish kumar sugasi88832b92015-12-21 18:52:29 -0800194 fm_peek_cb fm_peek_rsp_cb;
195 fm_ssbi_peek_cb fm_ssbi_peek_rsp_cb;
Smriti Gupta12ee3312016-05-11 15:43:14 +0530196 fm_agc_gain_cb fm_agc_gain_rsp_cb;
Satish kumar sugasi88832b92015-12-21 18:52:29 -0800197 fm_ch_det_th_cb fm_ch_det_th_rsp_cb;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530198 fm_ecc_evt_cb ext_country_code_cb;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700199 callback_thread_event thread_evt_cb;
Kamal Negi8813e0f2016-02-10 19:12:09 +0530200 fm_sig_thr_cb fm_get_sig_thres_cb;
201 fm_get_ch_det_thrs_cb fm_get_ch_det_thr_cb;
202 fm_def_data_rd_cb fm_def_data_read_cb;
203 fm_get_blnd_cb fm_get_blend_cb;
204 fm_set_ch_det_thrs_cb fm_set_ch_det_thr_cb;
205 fm_def_data_wrt_cb fm_def_data_write_cb;
206 fm_set_blnd_cb fm_set_blend_cb;
207 fm_get_stn_prm_cb fm_get_station_param_cb;
208 fm_get_stn_dbg_prm_cb fm_get_station_debug_param_cb;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530209} fm_hal_callbacks_t;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700210
211/* Opcode OCF */
212/* HCI recv control commands opcode */
213#define HCI_OCF_FM_ENABLE_RECV_REQ 0x0001
214#define HCI_OCF_FM_DISABLE_RECV_REQ 0x0002
215#define HCI_OCF_FM_GET_RECV_CONF_REQ 0x0003
216#define HCI_OCF_FM_SET_RECV_CONF_REQ 0x0004
217#define HCI_OCF_FM_SET_MUTE_MODE_REQ 0x0005
218#define HCI_OCF_FM_SET_STEREO_MODE_REQ 0x0006
219#define HCI_OCF_FM_SET_ANTENNA 0x0007
220#define HCI_OCF_FM_SET_SIGNAL_THRESHOLD 0x0008
221#define HCI_OCF_FM_GET_SIGNAL_THRESHOLD 0x0009
222#define HCI_OCF_FM_GET_STATION_PARAM_REQ 0x000A
223#define HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ 0x000B
224#define HCI_OCF_FM_GET_RADIO_TEXT_REQ 0x000C
225#define HCI_OCF_FM_GET_AF_LIST_REQ 0x000D
226#define HCI_OCF_FM_SEARCH_STATIONS 0x000E
227#define HCI_OCF_FM_SEARCH_RDS_STATIONS 0x000F
228#define HCI_OCF_FM_SEARCH_STATIONS_LIST 0x0010
229#define HCI_OCF_FM_CANCEL_SEARCH 0x0011
230#define HCI_OCF_FM_RDS_GRP 0x0012
231#define HCI_OCF_FM_RDS_GRP_PROCESS 0x0013
232#define HCI_OCF_FM_EN_WAN_AVD_CTRL 0x0014
233#define HCI_OCF_FM_EN_NOTCH_CTRL 0x0015
234#define HCI_OCF_FM_SET_EVENT_MASK 0x0016
235#define HCI_OCF_FM_SET_CH_DET_THRESHOLD 0x0017
236#define HCI_OCF_FM_GET_CH_DET_THRESHOLD 0x0018
237#define HCI_OCF_FM_SET_BLND_TBL 0x001B
238#define HCI_OCF_FM_GET_BLND_TBL 0x001C
Kiran Kelagericad71712016-04-27 16:54:22 -0700239#define HCI_OCF_FM_LOW_PASS_FILTER_CTRL 0x001F
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700240/* HCI trans control commans opcode*/
241#define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001
242#define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002
243#define HCI_OCF_FM_GET_TRANS_CONF_REQ 0x0003
244#define HCI_OCF_FM_SET_TRANS_CONF_REQ 0x0004
245#define HCI_OCF_FM_RDS_RT_REQ 0x0008
246#define HCI_OCF_FM_RDS_PS_REQ 0x0009
247
248
249/* HCI common control commands opcode */
250#define HCI_OCF_FM_TUNE_STATION_REQ 0x0001
251#define HCI_OCF_FM_DEFAULT_DATA_READ 0x0002
252#define HCI_OCF_FM_DEFAULT_DATA_WRITE 0x0003
253#define HCI_OCF_FM_RESET 0x0004
254#define HCI_OCF_FM_GET_FEATURE_LIST 0x0005
255#define HCI_OCF_FM_DO_CALIBRATION 0x0006
256#define HCI_OCF_FM_SET_CALIBRATION 0x0007
257#define HCI_OCF_FM_SET_SPUR_TABLE 0x0008
258#define HCI_OCF_FM_GET_SPUR_TABLE 0x0009
259
260/*HCI Status parameters commands*/
261#define HCI_OCF_FM_READ_GRP_COUNTERS 0x0001
262
Satish kumar sugasi649b9902016-04-28 17:55:29 -0700263#define HCI_OCF_FM_READ_GRP_COUNTERS_EXT 0x0002
264
265
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700266/*HCI Diagnostic commands*/
267#define HCI_OCF_FM_PEEK_DATA 0x0002
268#define HCI_OCF_FM_POKE_DATA 0x0003
269#define HCI_OCF_FM_SSBI_PEEK_REG 0x0004
270#define HCI_OCF_FM_SSBI_POKE_REG 0x0005
271#define HCI_OCF_FM_STATION_DBG_PARAM 0x0007
272#define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008
Smriti Gupta12ee3312016-05-11 15:43:14 +0530273#define HCI_FM_SET_GET_RESET_AGC 0x000D
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700274
275/* Opcode OGF */
276#define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013
277#define HCI_OGF_FM_TRANS_CTRL_CMD_REQ 0x0014
278#define HCI_OGF_FM_COMMON_CTRL_CMD_REQ 0x0015
279#define HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ 0x0016
280#define HCI_OGF_FM_TEST_CMD_REQ 0x0017
281#define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F
282
283/* Command opcode pack/unpack */
Smriti Gupta12ee3312016-05-11 15:43:14 +0530284#define hci_opcode_pack(ogf, ocf) (uint16_t) (((ocf) & 0x03ff)|((ogf) << 10))
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700285#define hci_opcode_ogf(op) (op >> 10)
286#define hci_opcode_ocf(op) (op & 0x03ff)
287#define hci_recv_ctrl_cmd_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530288 (uint16_t) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700289#define hci_trans_ctrl_cmd_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530290 (uint16_t) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf)
Kamal Negi8813e0f2016-02-10 19:12:09 +0530291#define hci_common_cmd_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530292 (uint16_t) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf)
Kamal Negi8813e0f2016-02-10 19:12:09 +0530293#define hci_status_param_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530294 (uint16_t) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf)
Kamal Negi8813e0f2016-02-10 19:12:09 +0530295#define hci_diagnostic_cmd_op_pack(ocf) \
Smriti Gupta12ee3312016-05-11 15:43:14 +0530296 (uint16_t) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700297
298/* HCI commands with no arguments*/
299#define HCI_FM_ENABLE_RECV_CMD 1
300#define HCI_FM_DISABLE_RECV_CMD 2
301#define HCI_FM_GET_RECV_CONF_CMD 3
302#define HCI_FM_GET_STATION_PARAM_CMD 4
303#define HCI_FM_GET_SIGNAL_TH_CMD 5
304#define HCI_FM_GET_PROGRAM_SERVICE_CMD 6
305#define HCI_FM_GET_RADIO_TEXT_CMD 7
306#define HCI_FM_GET_AF_LIST_CMD 8
307#define HCI_FM_CANCEL_SEARCH_CMD 9
308#define HCI_FM_RESET_CMD 10
309#define HCI_FM_GET_FEATURES_CMD 11
310#define HCI_FM_STATION_DBG_PARAM_CMD 12
311#define HCI_FM_ENABLE_TRANS_CMD 13
312#define HCI_FM_DISABLE_TRANS_CMD 14
313#define HCI_FM_GET_TX_CONFIG 15
314#define HCI_FM_GET_DET_CH_TH_CMD 16
315#define HCI_FM_GET_BLND_TBL_CMD 17
316
317/* Defines for FM TX*/
318#define TX_PS_DATA_LENGTH 108
319#define TX_RT_DATA_LENGTH 64
320#define PS_STRING_LEN 9
321
322/* ----- HCI Command request ----- */
323struct hci_fm_recv_conf_req {
324 char emphasis;
325 char ch_spacing;
326 char rds_std;
327 char hlsi;
Kamal Negi8813e0f2016-02-10 19:12:09 +0530328 int band_low_limit;
329 int band_high_limit;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700330} ;
331
332/* ----- HCI Command request ----- */
333struct hci_fm_trans_conf_req_struct {
334 char emphasis;
335 char rds_std;
Kamal Negi8813e0f2016-02-10 19:12:09 +0530336 int band_low_limit;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700337 int band_high_limit;
338} ;
339
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700340/* ----- HCI Command request ----- */
341struct hci_fm_tx_ps {
342 char ps_control;
343 short pi;
344 char pty;
345 char ps_repeatcount;
346 char ps_num;
347 char ps_data[TX_PS_DATA_LENGTH];
348} ;
349
350struct hci_fm_tx_rt {
351 char rt_control;
352 short pi;
353 char pty;
354 char rt_len;
355 char rt_data[TX_RT_DATA_LENGTH];
356} ;
357
358struct hci_fm_mute_mode_req {
359 char hard_mute;
360 char soft_mute;
361} ;
362
363struct hci_fm_stereo_mode_req {
364 char stereo_mode;
365 char sig_blend;
366 char intf_blend;
367 char most_switch;
368} ;
369
370struct hci_fm_search_station_req {
371 char srch_mode;
372 char scan_time;
373 char srch_dir;
374} ;
375
376struct hci_fm_search_rds_station_req {
377 struct hci_fm_search_station_req srch_station;
378 char srch_pty;
379 short srch_pi;
380} ;
381
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700382struct hci_fm_rds_grp_cntrs_params {
383 int totalRdsSBlockErrors;
384 int totalRdsGroups;
385 int totalRdsGroup0;
386 int totalRdsGroup2;
387 int totalRdsBlockB;
388 int totalRdsProcessedGroup0;
389 int totalRdsProcessedGroup2;
390 int totalRdsGroupFiltered;
391 int totalRdsChangeFiltered;
392} ;
393
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700394struct hci_fm_search_station_list_req {
395 char srch_list_mode;
396 char srch_list_dir;
397 int srch_list_max;
398 char srch_pty;
399} ;
400
401struct hci_fm_rds_grp_req {
402 int rds_grp_enable_mask;
403 int rds_buf_size;
404 char en_rds_change_filter;
405} ;
406
407struct hci_fm_en_avd_ctrl_req {
408 char no_freqs;
409 char freq_index;
410 char lo_shft;
411 short freq_min;
412 short freq_max;
413} ;
414
415struct hci_fm_def_data_rd_req {
416 char mode;
417 char length;
418 char param_len;
419 char param;
420} ;
421
422struct hci_fm_def_data_wr_req {
423 char mode;
424 char length;
425 char data[DEFAULT_DATA_SIZE];
426} ;
427
428struct hci_fm_riva_data {
429 char subopcode;
430 int start_addr;
431 char length;
432} ;
433
434struct hci_fm_riva_poke {
435 struct hci_fm_riva_data cmd_params;
436 char data[MAX_RIVA_PEEK_RSP_SIZE];
437} ;
438
439struct hci_fm_ssbi_req {
440 short start_addr;
441 char data;
442} ;
443struct hci_fm_ssbi_peek {
444 short start_address;
445} ;
446
Smriti Gupta12ee3312016-05-11 15:43:14 +0530447struct hci_fm_set_get_reset_agc {
448 char ucctrl;
449 char ucgainstate;
450} ;
451
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700452struct hci_fm_ch_det_threshold {
453 char sinr;
454 char sinr_samples;
455 char low_th;
456 char high_th;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700457} ;
458
459struct hci_fm_blend_table {
Kamal Negi8813e0f2016-02-10 19:12:09 +0530460 char BlendType;
461 char BlendRampRateUp;
462 char BlendDebounceNumSampleUp;
463 char BlendDebounceIdxUp;
464 char BlendSinrIdxSkipStep;
465 char BlendSinrHi;
466 char BlendRmssiHi;
467 char BlendIndexHi;
468 char BlendIndex[MAX_BLEND_INDEX];
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700469} ;
470
Kamal Negi8813e0f2016-02-10 19:12:09 +0530471struct hci_fm_def_data_rd {
472 char mode;
473 char length;
474 char param_len;
475 char param;
476};
477
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700478/*HCI events*/
479#define HCI_EV_TUNE_STATUS 0x01
480#define HCI_EV_RDS_LOCK_STATUS 0x02
481#define HCI_EV_STEREO_STATUS 0x03
482#define HCI_EV_SERVICE_AVAILABLE 0x04
483#define HCI_EV_SEARCH_PROGRESS 0x05
484#define HCI_EV_SEARCH_RDS_PROGRESS 0x06
485#define HCI_EV_SEARCH_LIST_PROGRESS 0x07
486#define HCI_EV_RDS_RX_DATA 0x08
487#define HCI_EV_PROGRAM_SERVICE 0x09
488#define HCI_EV_RADIO_TEXT 0x0A
489#define HCI_EV_FM_AF_LIST 0x0B
490#define HCI_EV_TX_RDS_GRP_AVBLE 0x0C
491#define HCI_EV_TX_RDS_GRP_COMPL 0x0D
492#define HCI_EV_TX_RDS_CONT_GRP_COMPL 0x0E
493#define HCI_EV_CMD_COMPLETE 0x0F
494#define HCI_EV_CMD_STATUS 0x10
495#define HCI_EV_TUNE_COMPLETE 0x11
496#define HCI_EV_SEARCH_COMPLETE 0x12
497#define HCI_EV_SEARCH_RDS_COMPLETE 0x13
498#define HCI_EV_SEARCH_LIST_COMPLETE 0x14
Satish kumar sugasid8731b72016-01-27 14:45:45 -0800499
500#define HCI_EV_EXT_COUNTRY_CODE 0x17
Satish kumar sugasib0ba3c82016-05-04 20:18:23 -0700501#define HCI_EV_RADIO_TEXT_PLUS_ID 0x18
502#define HCI_EV_RADIO_TEXT_PLUS_TAG 0x19
Satish kumar sugasi8a34ad32015-10-19 18:09:49 -0700503#define HCI_EV_HW_ERR_EVENT 0x1A
504
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700505#define HCI_REQ_DONE 0
506#define HCI_REQ_PEND 1
507#define HCI_REQ_CANCELED 2
508#define HCI_REQ_STATUS 3
509
510#define MAX_RAW_RDS_GRPS 21
511
512#define RDSGRP_DATA_OFFSET 0x1
513
514/*RT PLUS*/
515#define DUMMY_CLASS 0
516#define RT_PLUS_LEN_1_TAG 3
Kamal Negi8813e0f2016-02-10 19:12:09 +0530517#define RT_ERT_FLAG_BIT 5
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700518
519/*TAG1*/
Kamal Negi8813e0f2016-02-10 19:12:09 +0530520#define TAG1_MSB_OFFSET 3
521#define TAG1_MSB_MASK 7
522#define TAG1_LSB_OFFSET 5
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700523#define TAG1_POS_MSB_MASK 31
524#define TAG1_POS_MSB_OFFSET 1
525#define TAG1_POS_LSB_OFFSET 7
Kamal Negi8813e0f2016-02-10 19:12:09 +0530526#define TAG1_LEN_OFFSET 1
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700527#define TAG1_LEN_MASK 63
528
529/*TAG2*/
Kamal Negi8813e0f2016-02-10 19:12:09 +0530530#define TAG2_MSB_OFFSET 5
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700531#define TAG2_MSB_MASK 1
Kamal Negi8813e0f2016-02-10 19:12:09 +0530532#define TAG2_LSB_OFFSET 3
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700533#define TAG2_POS_MSB_MASK 7
534#define TAG2_POS_MSB_OFFSET 3
535#define TAG2_POS_LSB_OFFSET 5
536#define TAG2_LEN_MASK 31
537
538#define AGT_MASK 31
539/*Extract 5 left most bits of lsb of 2nd block*/
Kamal Negi8813e0f2016-02-10 19:12:09 +0530540#define AGT(x) (x & AGT_MASK)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700541/*16 bits of 4th block*/
542#define AID(lsb, msb) ((msb << 8) | (lsb))
543/*Extract 5 right most bits of msb of 2nd block*/
544#define GTC(blk2msb) (blk2msb >> 3)
545
546#define GRP_3A 0x6
547#define RT_PLUS_AID 0x4bd7
548
549/*ERT*/
Kamal Negi8813e0f2016-02-10 19:12:09 +0530550#define ERT_AID 0x6552
551#define CARRIAGE_RETURN 0x000D
552#define MAX_ERT_SEGMENT 31
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700553#define ERT_FORMAT_DIR_BIT 1
554
555#define EXTRACT_BIT(data, bit_pos) ((data & (1 << bit_pos)) >> bit_pos)
556
557struct hci_ev_tune_status {
558 char sub_event;
559 int station_freq;
560 char serv_avble;
561 char rssi;
562 char stereo_prg;
563 char rds_sync_status;
564 char mute_mode;
565 char sinr;
566 char intf_det_th;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530567}__attribute__((packed)) ;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700568
569struct rds_blk_data {
570 char rdsMsb;
571 char rdsLsb;
572 char blockStatus;
573} ;
574
575struct rds_grp_data {
576 struct rds_blk_data rdsBlk[4];
577} ;
578
579struct hci_ev_rds_rx_data {
580 char num_rds_grps;
581 struct rds_grp_data rds_grp_data[MAX_RAW_RDS_GRPS];
582} ;
583
584struct hci_ev_prg_service {
585 short pi_prg_id;
586 char pty_prg_type;
587 char ta_prg_code_type;
588 char ta_ann_code_flag;
589 char ms_switch_code_flag;
590 char dec_id_ctrl_code_flag;
591 char ps_num;
592 char prg_service_name[119];
593} ;
594
595struct hci_ev_radio_text {
596 short pi_prg_id;
597 char pty_prg_type;
598 char ta_prg_code_type;
599 char txt_ab_flag;
600 char radio_txt[64];
601} ;
602
603struct hci_ev_af_list {
604 int tune_freq;
605 short pi_code;
606 char af_size;
607 char af_list[FM_AF_LIST_MAX_SIZE];
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530608} __attribute__((packed)) ;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700609
610struct hci_ev_cmd_complete {
611 char num_hci_cmd_pkts;
612 short cmd_opcode;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530613} __attribute((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700614
615struct hci_ev_cmd_status {
616 char status;
617 char num_hci_cmd_pkts;
618 short status_opcode;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530619} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700620
621struct hci_ev_srch_st {
622 int station_freq;
623 char rds_cap;
624 char pty;
625 short status_opcode;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530626} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700627
628struct hci_ev_rel_freq {
629 char rel_freq_msb;
630 char rel_freq_lsb;
631
632} ;
633struct hci_ev_srch_list_compl {
634 char num_stations_found;
635 struct hci_ev_rel_freq rel_freq[20];
636} ;
637
638/* ----- HCI Event Response ----- */
639struct hci_fm_conf_rsp {
640 char status;
641 struct hci_fm_recv_conf_req recv_conf_rsp;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530642} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700643
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700644struct hci_fm_rds_grp_cntrs_rsp {
645 char status;
646 struct hci_fm_rds_grp_cntrs_params recv_rds_grp_cntrs_rsp;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530647} __attribute__((packed));
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700648
649
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700650struct hci_fm_get_trans_conf_rsp {
651 char status;
652 struct hci_fm_trans_conf_req_struct trans_conf_rsp;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530653} __attribute__((packed));
654
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700655struct hci_fm_sig_threshold_rsp {
656 char status;
657 char sig_threshold;
658} ;
659
660struct hci_fm_station_rsp {
661 struct hci_ev_tune_status station_rsp;
662} ;
663
664struct hci_fm_prgm_srv_rsp {
665 char status;
666 struct hci_ev_prg_service prg_srv;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530667} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700668
669struct hci_fm_radio_txt_rsp {
670 char status;
671 struct hci_ev_radio_text rd_txt;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530672} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700673
674struct hci_fm_af_list_rsp {
675 char status;
676 struct hci_ev_af_list rd_txt;
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530677} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700678
679struct hci_fm_data_rd_rsp {
Kamal Negi8813e0f2016-02-10 19:12:09 +0530680 char data_len;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700681 char data[DEFAULT_DATA_SIZE];
682} ;
683
684struct hci_fm_feature_list_rsp {
685 char status;
686 char feature_mask;
687} ;
688
689struct hci_fm_dbg_param_rsp {
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700690 char blend;
691 char soft_mute;
692 char inf_blend;
693 char inf_soft_mute;
694 char pilot_pil;
695 char io_verc;
696 char in_det_out;
697} ;
698
Kamal Negi8813e0f2016-02-10 19:12:09 +0530699#define CLKSPURID_INDEX0 0
700#define CLKSPURID_INDEX1 5
701#define CLKSPURID_INDEX2 10
702#define CLKSPURID_INDEX3 15
703#define CLKSPURID_INDEX4 20
704#define CLKSPURID_INDEX5 25
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700705
Kamal Negi8813e0f2016-02-10 19:12:09 +0530706#define MAX_SPUR_FREQ_LIMIT 30
707#define CKK_SPUR 0x3B
708#define SPUR_DATA_SIZE 0x4
709#define SPUR_ENTRIES_PER_ID 0x5
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700710
711#define COMPUTE_SPUR(val) ((((val) - (76000)) / (50)))
712#define GET_FREQ(val, bit) ((bit == 1) ? ((val) >> 8) : ((val) & 0xFF))
713#define GET_SPUR_ENTRY_LEVEL(val) ((val) / (5))
714
715struct hci_fm_spur_data {
Kamal Negi8813e0f2016-02-10 19:12:09 +0530716 int freq[MAX_SPUR_FREQ_LIMIT];
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700717 char rmssi[MAX_SPUR_FREQ_LIMIT];
718 char enable[MAX_SPUR_FREQ_LIMIT];
Kamal Negi8a2a72a2016-06-30 11:43:32 +0530719} __attribute__((packed));
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700720
721/* HCI dev events */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530722#define RADIO_HCI_DEV_REG 1
723#define RADIO_HCI_DEV_WRITE 2
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700724
Kamal Negi8813e0f2016-02-10 19:12:09 +0530725#define hci_req_lock(d) mutex_lock(&d->req_lock)
726#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700727
728/* FM RDS */
729#define RDS_PTYPE 2
730#define RDS_PID_LOWER 1
731#define RDS_PID_HIGHER 0
732#define RDS_OFFSET 5
733#define RDS_PS_LENGTH_OFFSET 7
734#define RDS_STRING 8
735#define RDS_PS_DATA_OFFSET 8
736#define RDS_CONFIG_OFFSET 3
737#define RDS_AF_JUMP_OFFSET 4
738#define PI_CODE_OFFSET 4
739#define AF_SIZE_OFFSET 6
740#define AF_LIST_OFFSET 7
741#define RT_A_B_FLAG_OFFSET 4
742/*FM states*/
743
744enum radio_state_t {
745 FM_OFF,
746 FM_RECV,
747 FM_TRANS,
748 FM_RESET,
749 FM_CALIB,
750 FM_TURNING_OFF,
751 FM_RECV_TURNING_ON,
752 FM_TRANS_TURNING_ON,
753 FM_MAX_NO_STATES,
754};
755
756enum emphasis_type {
757 FM_RX_EMP75 = 0x0,
758 FM_RX_EMP50 = 0x1
759};
760
761enum channel_space_type {
762 FM_RX_SPACE_200KHZ = 0x0,
763 FM_RX_SPACE_100KHZ = 0x1,
764 FM_RX_SPACE_50KHZ = 0x2
765};
766
767enum high_low_injection {
768 AUTO_HI_LO_INJECTION = 0x0,
769 LOW_SIDE_INJECTION = 0x1,
770 HIGH_SIDE_INJECTION = 0x2
771};
772
773enum fm_rds_type {
774 FM_RX_RDBS_SYSTEM = 0x0,
775 FM_RX_RDS_SYSTEM = 0x1
776};
777
778enum hlm_region_t {
779 HELIUM_REGION_US,
780 HELIUM_REGION_EU,
781 HELIUM_REGION_JAPAN,
782 HELIUM_REGION_JAPAN_WIDE,
783 HELIUM_REGION_OTHER
784};
785
786/* Search options */
787enum search_t {
788 SEEK,
789 SCAN,
790 SCAN_FOR_STRONG,
791 SCAN_FOR_WEAK,
792 RDS_SEEK_PTY,
793 RDS_SCAN_PTY,
794 RDS_SEEK_PI,
795 RDS_AF_JUMP,
796};
797
798enum spur_entry_levels {
799 ENTRY_0,
800 ENTRY_1,
801 ENTRY_2,
802 ENTRY_3,
803 ENTRY_4,
804 ENTRY_5,
805};
806
807/* Band limits */
808#define REGION_US_EU_BAND_LOW 87500
809#define REGION_US_EU_BAND_HIGH 108000
810#define REGION_JAPAN_STANDARD_BAND_LOW 76000
811#define REGION_JAPAN_STANDARD_BAND_HIGH 90000
812#define REGION_JAPAN_WIDE_BAND_LOW 90000
813#define REGION_JAPAN_WIDE_BAND_HIGH 108000
814
815#define SRCH_MODE 0x07
816#define SRCH_DIR 0x08 /* 0-up 1-down */
817#define SCAN_DWELL 0x70
Kamal Negi8813e0f2016-02-10 19:12:09 +0530818#define SRCH_ON 0x80
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700819
820/* I/O Control */
821#define IOC_HRD_MUTE 0x03
822#define IOC_SFT_MUTE 0x01
823#define IOC_MON_STR 0x01
824#define IOC_SIG_BLND 0x01
825#define IOC_INTF_BLND 0x01
826#define IOC_ANTENNA 0x01
827
828/* RDS Control */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530829#define RDS_ON 0x01
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700830#define RDS_BUF_SZ 100
831
832/* constants */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530833#define RDS_BLOCKS_NUM (4)
834#define BYTES_PER_BLOCK (3)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700835#define MAX_PS_LENGTH (108)
836#define MAX_RT_LENGTH (64)
837#define RDS_GRP_CNTR_LEN (36)
838#define RX_RT_DATA_LENGTH (63)
839/* Search direction */
840#define SRCH_DIR_UP (0)
841#define SRCH_DIR_DOWN (1)
842
843/*Search RDS stations*/
844#define SEARCH_RDS_STNS_MODE_OFFSET 4
845
846/*Search Station list */
847#define PARAMS_PER_STATION 0x08
848#define STN_NUM_OFFSET 0x01
849#define STN_FREQ_OFFSET 0x02
850#define KHZ_TO_MHZ 1000
851#define GET_MSB(x)((x >> 8) & 0xFF)
852#define GET_LSB(x)((x) & 0xFF)
853
854/* control options */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530855#define CTRL_ON (1)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700856#define CTRL_OFF (0)
857
858/*Diagnostic commands*/
859
860#define RIVA_PEEK_OPCODE 0x0D
861#define RIVA_POKE_OPCODE 0x0C
862
863#define PEEK_DATA_OFSET 0x1
864#define RIVA_PEEK_PARAM 0x6
865#define RIVA_PEEK_LEN_OFSET 0x6
866#define SSBI_PEEK_LEN 0x01
867/*Calibration data*/
868#define PROCS_CALIB_MODE 1
869#define PROCS_CALIB_SIZE 23
870#define DC_CALIB_MODE 2
871#define DC_CALIB_SIZE 48
872#define RSB_CALIB_MODE 3
873#define RSB_CALIB_SIZE 4
874#define CALIB_DATA_OFSET 2
875#define CALIB_MODE_OFSET 1
876#define MAX_CALIB_SIZE 75
877
878/* Channel validity */
Kamal Negi8813e0f2016-02-10 19:12:09 +0530879#define INVALID_CHANNEL (0)
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700880#define VALID_CHANNEL (1)
881
882struct hci_fm_set_cal_req_proc {
883 char mode;
884 /*Max process calibration data size*/
885 char data[PROCS_CALIB_SIZE];
886} ;
887
888struct hci_fm_set_cal_req_dc {
889 char mode;
890 /*Max DC calibration data size*/
891 char data[DC_CALIB_SIZE];
892} ;
893
894struct hci_cc_do_calibration_rsp {
895 char status;
896 char mode;
897 char data[MAX_CALIB_SIZE];
898} ;
899
900struct hci_fm_set_spur_table_req {
901 char mode;
902 char no_of_freqs_entries;
903 char spur_data[FM_SPUR_TBL_SIZE];
904} ;
905/* Low Power mode*/
906#define SIG_LEVEL_INTR (1 << 0)
907#define RDS_SYNC_INTR (1 << 1)
908#define AUDIO_CTRL_INTR (1 << 2)
909#define AF_JUMP_ENABLE (1 << 4)
910
911int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
912 struct radio_hci_dev *hdev);
913int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
914 struct radio_hci_dev *hdev);
915int hci_fm_do_calibration(char *arg, struct radio_hci_dev *hdev);
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700916
917static inline int is_valid_tone(int tone)
918{
919 if ((tone >= MIN_TX_TONE_VAL) &&
920 (tone <= MAX_TX_TONE_VAL))
921 return 1;
922 else
923 return 0;
924}
925
926static inline int is_valid_hard_mute(int hard_mute)
927{
928 if ((hard_mute >= MIN_HARD_MUTE_VAL) &&
929 (hard_mute <= MAX_HARD_MUTE_VAL))
930 return 1;
931 else
932 return 0;
933}
934
935static inline int is_valid_srch_mode(int srch_mode)
936{
937 if ((srch_mode >= MIN_SRCH_MODE) &&
938 (srch_mode <= MAX_SRCH_MODE))
939 return 1;
940 else
941 return 0;
942}
943
944static inline int is_valid_scan_dwell_prd(int scan_dwell_prd)
945{
946 if ((scan_dwell_prd >= MIN_SCAN_DWELL) &&
947 (scan_dwell_prd <= MAX_SCAN_DWELL))
948 return 1;
949 else
950 return 0;
951}
952
953static inline int is_valid_sig_th(int sig_th)
954{
955 if ((sig_th >= MIN_SIG_TH) &&
956 (sig_th <= MAX_SIG_TH))
957 return 1;
958 else
959 return 0;
960}
961
962static inline int is_valid_pty(int pty)
963{
964 if ((pty >= MIN_PTY) &&
965 (pty <= MAX_PTY))
966 return 1;
967 else
968 return 0;
969}
970
971static inline int is_valid_pi(int pi)
972{
973 if ((pi >= MIN_PI) &&
974 (pi <= MAX_PI))
975 return 1;
976 else
977 return 0;
978}
979
980static inline int is_valid_srch_station_cnt(int cnt)
981{
982 if ((cnt >= MIN_SRCH_STATIONS_CNT) &&
983 (cnt <= MAX_SRCH_STATIONS_CNT))
984 return 1;
985 else
986 return 0;
987}
988
989static inline int is_valid_chan_spacing(int spacing)
990{
991 if ((spacing >= MIN_CHAN_SPACING) &&
992 (spacing <= MAX_CHAN_SPACING))
993 return 1;
994 else
995 return 0;
996}
997
998static inline int is_valid_emphasis(int emphasis)
999{
1000 if ((emphasis >= MIN_EMPHASIS) &&
1001 (emphasis <= MAX_EMPHASIS))
1002 return 1;
1003 else
1004 return 0;
1005}
1006
1007static inline int is_valid_rds_std(int rds_std)
1008{
1009 if ((rds_std >= MIN_RDS_STD) &&
1010 (rds_std <= MAX_RDS_STD))
1011 return 1;
1012 else
1013 return 0;
1014}
1015
1016static inline int is_valid_antenna(int antenna_type)
1017{
1018 if ((antenna_type >= MIN_ANTENNA_VAL) &&
1019 (antenna_type <= MAX_ANTENNA_VAL))
1020 return 1;
1021 else
1022 return 0;
1023}
1024
1025static inline int is_valid_ps_repeat_cnt(int cnt)
1026{
1027 if ((cnt >= MIN_TX_PS_REPEAT_CNT) &&
1028 (cnt <= MAX_TX_PS_REPEAT_CNT))
1029 return 1;
1030 else
1031 return 0;
1032}
1033
1034static inline int is_valid_soft_mute(int soft_mute)
1035{
1036 if ((soft_mute >= MIN_SOFT_MUTE) &&
1037 (soft_mute <= MAX_SOFT_MUTE))
1038 return 1;
1039 else
1040 return 0;
1041}
1042
1043static inline int is_valid_peek_len(int len)
1044{
1045 if ((len >= MIN_PEEK_ACCESS_LEN) &&
1046 (len <= MAX_PEEK_ACCESS_LEN))
1047 return 1;
1048 else
1049 return 0;
1050}
1051
1052static inline int is_valid_reset_cntr(int cntr)
1053{
1054 if ((cntr >= MIN_RESET_CNTR) &&
1055 (cntr <= MAX_RESET_CNTR))
1056 return 1;
1057 else
1058 return 0;
1059}
1060
1061static inline int is_valid_hlsi(int hlsi)
1062{
1063 if ((hlsi >= MIN_HLSI) &&
1064 (hlsi <= MAX_HLSI))
1065 return 1;
1066 else
1067 return 0;
1068}
1069
1070static inline int is_valid_notch_filter(int filter)
1071{
1072 if ((filter >= MIN_NOTCH_FILTER) &&
1073 (filter <= MAX_NOTCH_FILTER))
1074 return 1;
1075 else
1076 return 0;
1077}
1078
1079static inline int is_valid_intf_det_low_th(int th)
1080{
1081 if ((th >= MIN_INTF_DET_OUT_LW_TH) &&
1082 (th <= MAX_INTF_DET_OUT_LW_TH))
1083 return 1;
1084 else
1085 return 0;
1086}
1087
1088static inline int is_valid_intf_det_hgh_th(int th)
1089{
1090 if ((th >= MIN_INTF_DET_OUT_HG_TH) &&
1091 (th <= MAX_INTF_DET_OUT_HG_TH))
1092 return 1;
1093 else
1094 return 0;
1095}
1096
1097static inline int is_valid_sinr_th(int th)
1098{
1099 if ((th >= MIN_SINR_TH) &&
1100 (th <= MAX_SINR_TH))
1101 return 1;
1102 else
1103 return 0;
1104}
1105
1106static inline int is_valid_sinr_samples(int samples_cnt)
1107{
1108 if ((samples_cnt >= MIN_SINR_SAMPLES) &&
1109 (samples_cnt <= MAX_SINR_SAMPLES))
1110 return 1;
1111 else
1112 return 0;
1113}
1114
1115static inline int is_valid_fm_state(int state)
1116{
1117 if ((state >= 0) && (state < FM_MAX_NO_STATES))
1118 return 1;
1119 else
1120 return 0;
1121}
1122
1123static inline int is_valid_blend_value(int val)
1124{
1125 if ((val >= MIN_BLEND_HI) && (val <= MAX_BLEND_HI))
1126 return 1;
1127 else
1128 return 0;
1129}
1130
Kamal Negi8a2a72a2016-06-30 11:43:32 +05301131struct radio_helium_device {
Satish kumar sugasi644b4882016-05-04 20:15:31 -07001132 int tune_req;
1133 unsigned int mode;
1134 short pi;
1135 char pty;
1136 char ps_repeatcount;
1137 char prev_trans_rds;
1138 char af_jump_bit;
1139 struct hci_fm_mute_mode_req mute_mode;
1140 struct hci_fm_stereo_mode_req stereo_mode;
1141 struct hci_fm_station_rsp fm_st_rsp;
1142 struct hci_fm_search_station_req srch_st;
1143 struct hci_fm_search_rds_station_req srch_rds;
1144 struct hci_fm_search_station_list_req srch_st_list;
1145 struct hci_fm_recv_conf_req recv_conf;
1146 struct hci_fm_trans_conf_req_struct trans_conf;
1147 struct hci_fm_rds_grp_req rds_grp;
1148 unsigned char g_search_mode;
1149 unsigned char power_mode;
1150 int search_on;
1151 unsigned char spur_table_size;
1152 unsigned char g_scan_time;
1153 unsigned int g_antenna;
1154 unsigned int g_rds_grp_proc_ps;
1155 unsigned char event_mask;
1156 enum hlm_region_t region;
1157 struct hci_fm_dbg_param_rsp st_dbg_param;
1158 struct hci_ev_srch_list_compl srch_st_result;
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001159 struct hci_fm_riva_poke riva_data_req;
1160 struct hci_fm_ssbi_req ssbi_data_accs;
1161 struct hci_fm_ssbi_peek ssbi_peek_reg;
Smriti Gupta12ee3312016-05-11 15:43:14 +05301162 struct hci_fm_set_get_reset_agc set_get_reset_agc;
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001163 struct hci_fm_ch_det_threshold ch_det_threshold;
Kamal Negi8813e0f2016-02-10 19:12:09 +05301164 struct hci_fm_data_rd_rsp def_data;
1165 struct hci_fm_blend_table blend_tbl;
Kamal Negi8a2a72a2016-06-30 11:43:32 +05301166} __attribute__((packed));
Kamal Negi8813e0f2016-02-10 19:12:09 +05301167
1168#define set_bit(flag, bit_pos) ((flag) |= (1 << (bit_pos)))
1169#define clear_bit(flag, bit_pos) ((flag) &= (~(1 << (bit_pos))))
1170#define test_bit(flag, bit_pos) ((flag) & (1 << (bit_pos)))
1171#define clear_all_bit(flag) ((flag) &= (~0xFFFFFFFF))
1172#define CMD_CHDET_SINR_TH (1)
1173#define CMD_CHDET_SINR_SAMPLE (2)
1174#define CMD_CHDET_INTF_TH_LOW (3)
1175#define CMD_CHDET_INTF_TH_HIGH (4)
1176
1177#define CMD_DEFRD_AF_RMSSI_TH (1)
1178#define CMD_DEFRD_AF_RMSSI_SAMPLE (2)
1179#define CMD_DEFRD_GD_CH_RMSSI_TH (3)
1180#define CMD_DEFRD_SEARCH_ALGO (4)
1181#define CMD_DEFRD_SINR_FIRST_STAGE (5)
1182#define CMD_DEFRD_RMSSI_FIRST_STAGE (6)
1183#define CMD_DEFRD_CF0TH12 (7)
1184#define CMD_DEFRD_TUNE_POWER (8)
1185#define CMD_DEFRD_REPEATCOUNT (9)
1186
1187#define CMD_STNPARAM_RSSI (1)
1188#define CMD_STNPARAM_SINR (2)
1189#define CMD_STNPARAM_INTF_DET_TH (3)
1190
1191#define CMD_STNDBGPARAM_BLEND (1)
1192#define CMD_STNDBGPARAM_SOFTMUTE (2)
1193#define CMD_STNDBGPARAM_INFBLEND (3)
1194#define CMD_STNDBGPARAM_INFSOFTMUTE (4)
1195#define CMD_STNDBGPARAM_PILOTPLL (5)
1196#define CMD_STNDBGPARAM_IOVERC (6)
1197#define CMD_STNDBGPARAM_INFDETOUT (7)
1198
1199#define CMD_BLENDTBL_SINR_HI (1)
1200#define CMD_BLENDTBL_RMSSI_HI (2)
1201
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001202int hci_fm_disable_recv_req();
1203int helium_search_list(struct hci_fm_search_station_list_req *s_list);
1204int helium_search_rds_stations(struct hci_fm_search_rds_station_req *rds_srch);
1205int helium_search_stations(struct hci_fm_search_station_req *srch);
1206int helium_cancel_search_req();
1207int hci_fm_set_recv_conf_req (struct hci_fm_recv_conf_req *conf);
1208int hci_fm_get_program_service_req ();
1209int hci_fm_get_rds_grpcounters_req (int val);
Satish kumar sugasi649b9902016-04-28 17:55:29 -07001210int hci_fm_get_rds_grpcounters_ext_req (int val);
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001211int hci_fm_set_notch_filter_req (int val);
1212int helium_set_sig_threshold_req(char th);
1213int helium_rds_grp_mask_req(struct hci_fm_rds_grp_req *rds_grp_msk);
1214int helium_rds_grp_process_req(int rds_grp);
1215int helium_set_event_mask_req(char e_mask);
1216int helium_set_antenna_req(char ant);
1217int helium_set_fm_mute_mode_req(struct hci_fm_mute_mode_req *mute);
1218int hci_fm_tune_station_req(int param);
1219int hci_set_fm_stereo_mode_req(struct hci_fm_stereo_mode_req *param);
1220int hci_peek_data(struct hci_fm_riva_data *data);
1221int hci_poke_data(struct hci_fm_riva_poke *data);
1222int hci_ssbi_poke_reg(struct hci_fm_ssbi_req *data);
1223int hci_ssbi_peek_reg(struct hci_fm_ssbi_peek *data);
Smriti Gupta12ee3312016-05-11 15:43:14 +05301224int hci_get_set_reset_agc_req(struct hci_fm_set_get_reset_agc *data);
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001225int hci_fm_get_ch_det_th();
1226int set_ch_det_thresholds_req(struct hci_fm_ch_det_threshold *ch_det_th);
Kamal Negi8813e0f2016-02-10 19:12:09 +05301227int hci_fm_default_data_read_req(struct hci_fm_def_data_rd_req *def_data_rd);
1228int hci_fm_get_blend_req();
1229int hci_fm_set_blend_tbl_req(struct hci_fm_blend_table *blnd_tbl);
Kiran Kelagericad71712016-04-27 16:54:22 -07001230int hci_fm_enable_lpf(int enable);
Kamal Negi8813e0f2016-02-10 19:12:09 +05301231int hci_fm_default_data_write_req(struct hci_fm_def_data_wr_req * data_wrt);
1232int hci_fm_get_station_dbg_param_req();
1233int hci_fm_get_station_cmd_param_req();
Satish kumar sugasi88832b92015-12-21 18:52:29 -08001234
Kamal Negi8a2a72a2016-06-30 11:43:32 +05301235struct fm_hal_t {
1236 struct radio_helium_device *radio;
1237 fm_hal_callbacks_t *jni_cb;
1238 void *private_data;
1239};
1240
1241struct fm_interface_t {
1242 int (*init)(const fm_hal_callbacks_t *p_cb);
1243 int (*set_fm_ctrl)(int opcode, int val);
1244 void (*Get_fm_ctrl) (int opcode, int val);
1245};
1246
Satish kumar sugasi644b4882016-05-04 20:15:31 -07001247#endif /* __UAPI_RADIO_HCI_CORE_H */
Kamal Negi8a2a72a2016-06-30 11:43:32 +05301248