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