blob: cb85bcc06f097e6646d125087e0d640d357ef059 [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**/
107#define FM_RDS_CNFG_MODE 0x0f
108#define FM_RDS_CNFG_LEN 0x10
109#define AF_RMSSI_TH_LSB_OFFSET 10
110#define AF_RMSSI_TH_MSB_OFFSET 11
111#define AF_RMSSI_SAMPLES_OFFSET 15
112/**RX CONFIG MODE**/
113#define FM_RX_CONFG_MODE 0x15
114#define FM_RX_CNFG_LEN 0x20
115#define GD_CH_RMSSI_TH_OFFSET 12
116#define MAX_GD_CH_RMSSI_TH 127
117#define SRCH_ALGO_TYPE_OFFSET 25
118#define SINRFIRSTSTAGE_OFFSET 26
119#define RMSSIFIRSTSTAGE_OFFSET 27
120#define CF0TH12_BYTE1_OFFSET 8
121#define CF0TH12_BYTE2_OFFSET 9
122#define CF0TH12_BYTE3_OFFSET 10
123#define CF0TH12_BYTE4_OFFSET 11
124#define MAX_SINR_FIRSTSTAGE 127
125#define MAX_RMSSI_FIRSTSTAGE 127
126#define RDS_PS0_XFR_MODE 0x01
127#define RDS_PS0_LEN 6
128#define RX_REPEATE_BYTE_OFFSET 5
129#define FM_SPUR_TBL_SIZE 240
130#define SPUR_DATA_LEN 16
131#define ENTRIES_EACH_CMD 15
132#define SPUR_DATA_INDEX 2
133#define FM_AF_LIST_MAX_SIZE 200
134#define AF_LIST_MAX (FM_AF_LIST_MAX_SIZE / 4) /* Each AF frequency consist
135 of sizeof(int) bytes */
136#define MAX_BLEND_INDEX 49
137/* HCI timeouts */
138#define RADIO_HCI_TIMEOUT (10000) /* 10 seconds */
139
140typedef enum {
141 ASSOCIATE_JVM,
142 DISASSOCIATE_JVM
143} bt_cb_thread_evt;
144
145#define TUNE_PARAM 16
146#define SIZE_ARRAY(x) (sizeof(x) / sizeof((x)[0]))
147typedef void (*enb_result_cb)();
148typedef void (*tune_rsp_cb)(int Freq);
149typedef void (*seek_rsp_cb)(int Freq);
150typedef void (*scan_rsp_cb)();
151typedef void (*srch_list_rsp_cb)(uint16_t *scan_tbl);
152typedef void (*stereo_mode_cb)(bool status);
153typedef void (*rds_avl_sts_cb)(bool status);
154typedef void (*af_list_cb)(uint16_t *af_list);
155typedef void (*rt_cb)(char *rt);
156typedef void (*ps_cb)(char *ps);
157typedef void (*oda_cb)();
158typedef void (*rt_plus_cb)(char *rt_plus);
159typedef void (*ert_cb)(char *ert);
160typedef void (*disable_cb)();
161typedef void (*callback_thread_event)(unsigned int evt);
162
163typedef struct {
164 size_t size;
165
166 enb_result_cb enabled_cb;
167 tune_rsp_cb tune_cb;
168 seek_rsp_cb seek_cmpl_cb;
169 scan_rsp_cb scan_next_cb;
170 srch_list_rsp_cb srch_list_cb;
171 stereo_mode_cb stereo_status_cb;
172 rds_avl_sts_cb rds_avail_status_cb;
173 af_list_cb af_list_update_cb;
174 rt_cb rt_update_cb;
175 ps_cb ps_update_cb;
176 oda_cb oda_update_cb;
177 rt_plus_cb rt_plus_update_cb;
178 ert_cb ert_update_cb;
179 disable_cb disabled_cb;
180 callback_thread_event thread_evt_cb;
181} fm_vendor_callbacks_t;
182
183pthread_mutex_t radio_fm_cmd;
184typedef struct {
185 int (*init)(const fm_vendor_callbacks_t *p_cb);
186 int (*set_fm_ctrl)(int opcode, int val);
187 void (*Get_fm_ctrl) (int opcode, int val);
188} fm_interface_t;
189
190typedef int (*fm_evt_notify_cb)(unsigned char *p_buf);
191
192typedef struct {
193 fm_evt_notify_cb fm_evt_notify;
194} fm_hal_cb;
195
196struct radio_hci_command_hdr {
197 short opcode; /* OCF & OGF */
198 char plen;
199} ;
200
201struct radio_hci_event_hdr {
202 char evt;
203 char plen;
204} ;
205
206struct radio_hci_dev {
207 char name[8];
208 unsigned long flags;
209 short id;
210 char bus;
211 char dev_type;
212 char dev_name[248];
213 char dev_class[3];
214 char features[8];
215 char commands[64];
216 unsigned int data_block_len;
217 unsigned long cmd_last_tx;
218 int req_status;
219 int req_result;
220};
221
222/* Opcode OCF */
223/* HCI recv control commands opcode */
224#define HCI_OCF_FM_ENABLE_RECV_REQ 0x0001
225#define HCI_OCF_FM_DISABLE_RECV_REQ 0x0002
226#define HCI_OCF_FM_GET_RECV_CONF_REQ 0x0003
227#define HCI_OCF_FM_SET_RECV_CONF_REQ 0x0004
228#define HCI_OCF_FM_SET_MUTE_MODE_REQ 0x0005
229#define HCI_OCF_FM_SET_STEREO_MODE_REQ 0x0006
230#define HCI_OCF_FM_SET_ANTENNA 0x0007
231#define HCI_OCF_FM_SET_SIGNAL_THRESHOLD 0x0008
232#define HCI_OCF_FM_GET_SIGNAL_THRESHOLD 0x0009
233#define HCI_OCF_FM_GET_STATION_PARAM_REQ 0x000A
234#define HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ 0x000B
235#define HCI_OCF_FM_GET_RADIO_TEXT_REQ 0x000C
236#define HCI_OCF_FM_GET_AF_LIST_REQ 0x000D
237#define HCI_OCF_FM_SEARCH_STATIONS 0x000E
238#define HCI_OCF_FM_SEARCH_RDS_STATIONS 0x000F
239#define HCI_OCF_FM_SEARCH_STATIONS_LIST 0x0010
240#define HCI_OCF_FM_CANCEL_SEARCH 0x0011
241#define HCI_OCF_FM_RDS_GRP 0x0012
242#define HCI_OCF_FM_RDS_GRP_PROCESS 0x0013
243#define HCI_OCF_FM_EN_WAN_AVD_CTRL 0x0014
244#define HCI_OCF_FM_EN_NOTCH_CTRL 0x0015
245#define HCI_OCF_FM_SET_EVENT_MASK 0x0016
246#define HCI_OCF_FM_SET_CH_DET_THRESHOLD 0x0017
247#define HCI_OCF_FM_GET_CH_DET_THRESHOLD 0x0018
248#define HCI_OCF_FM_SET_BLND_TBL 0x001B
249#define HCI_OCF_FM_GET_BLND_TBL 0x001C
250/* HCI trans control commans opcode*/
251#define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001
252#define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002
253#define HCI_OCF_FM_GET_TRANS_CONF_REQ 0x0003
254#define HCI_OCF_FM_SET_TRANS_CONF_REQ 0x0004
255#define HCI_OCF_FM_RDS_RT_REQ 0x0008
256#define HCI_OCF_FM_RDS_PS_REQ 0x0009
257
258
259/* HCI common control commands opcode */
260#define HCI_OCF_FM_TUNE_STATION_REQ 0x0001
261#define HCI_OCF_FM_DEFAULT_DATA_READ 0x0002
262#define HCI_OCF_FM_DEFAULT_DATA_WRITE 0x0003
263#define HCI_OCF_FM_RESET 0x0004
264#define HCI_OCF_FM_GET_FEATURE_LIST 0x0005
265#define HCI_OCF_FM_DO_CALIBRATION 0x0006
266#define HCI_OCF_FM_SET_CALIBRATION 0x0007
267#define HCI_OCF_FM_SET_SPUR_TABLE 0x0008
268#define HCI_OCF_FM_GET_SPUR_TABLE 0x0009
269
270/*HCI Status parameters commands*/
271#define HCI_OCF_FM_READ_GRP_COUNTERS 0x0001
272
273/*HCI Diagnostic commands*/
274#define HCI_OCF_FM_PEEK_DATA 0x0002
275#define HCI_OCF_FM_POKE_DATA 0x0003
276#define HCI_OCF_FM_SSBI_PEEK_REG 0x0004
277#define HCI_OCF_FM_SSBI_POKE_REG 0x0005
278#define HCI_OCF_FM_STATION_DBG_PARAM 0x0007
279#define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008
280
281/* Opcode OGF */
282#define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013
283#define HCI_OGF_FM_TRANS_CTRL_CMD_REQ 0x0014
284#define HCI_OGF_FM_COMMON_CTRL_CMD_REQ 0x0015
285#define HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ 0x0016
286#define HCI_OGF_FM_TEST_CMD_REQ 0x0017
287#define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F
288
289/* Command opcode pack/unpack */
290#define hci_opcode_pack(ogf, ocf) (short) ((ocf & 0x03ff)|(ogf << 10))
291#define hci_opcode_ogf(op) (op >> 10)
292#define hci_opcode_ocf(op) (op & 0x03ff)
293#define hci_recv_ctrl_cmd_op_pack(ocf) \
294 (short) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf)
295#define hci_trans_ctrl_cmd_op_pack(ocf) \
296 (short) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf)
297#define hci_common_cmd_op_pack(ocf) \
298 (short) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf)
299#define hci_status_param_op_pack(ocf) \
300 (short) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf)
301#define hci_diagnostic_cmd_op_pack(ocf) \
302 (short) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf)
303
304
305/* HCI commands with no arguments*/
306#define HCI_FM_ENABLE_RECV_CMD 1
307#define HCI_FM_DISABLE_RECV_CMD 2
308#define HCI_FM_GET_RECV_CONF_CMD 3
309#define HCI_FM_GET_STATION_PARAM_CMD 4
310#define HCI_FM_GET_SIGNAL_TH_CMD 5
311#define HCI_FM_GET_PROGRAM_SERVICE_CMD 6
312#define HCI_FM_GET_RADIO_TEXT_CMD 7
313#define HCI_FM_GET_AF_LIST_CMD 8
314#define HCI_FM_CANCEL_SEARCH_CMD 9
315#define HCI_FM_RESET_CMD 10
316#define HCI_FM_GET_FEATURES_CMD 11
317#define HCI_FM_STATION_DBG_PARAM_CMD 12
318#define HCI_FM_ENABLE_TRANS_CMD 13
319#define HCI_FM_DISABLE_TRANS_CMD 14
320#define HCI_FM_GET_TX_CONFIG 15
321#define HCI_FM_GET_DET_CH_TH_CMD 16
322#define HCI_FM_GET_BLND_TBL_CMD 17
323
324/* Defines for FM TX*/
325#define TX_PS_DATA_LENGTH 108
326#define TX_RT_DATA_LENGTH 64
327#define PS_STRING_LEN 9
328
329/* ----- HCI Command request ----- */
330struct hci_fm_recv_conf_req {
331 char emphasis;
332 char ch_spacing;
333 char rds_std;
334 char hlsi;
335 int band_low_limit;
336 int band_high_limit;
337} ;
338
339/* ----- HCI Command request ----- */
340struct hci_fm_trans_conf_req_struct {
341 char emphasis;
342 char rds_std;
343 int band_low_limit;
344 int band_high_limit;
345} ;
346
347
348/* ----- HCI Command request ----- */
349struct hci_fm_tx_ps {
350 char ps_control;
351 short pi;
352 char pty;
353 char ps_repeatcount;
354 char ps_num;
355 char ps_data[TX_PS_DATA_LENGTH];
356} ;
357
358struct hci_fm_tx_rt {
359 char rt_control;
360 short pi;
361 char pty;
362 char rt_len;
363 char rt_data[TX_RT_DATA_LENGTH];
364} ;
365
366struct hci_fm_mute_mode_req {
367 char hard_mute;
368 char soft_mute;
369} ;
370
371struct hci_fm_stereo_mode_req {
372 char stereo_mode;
373 char sig_blend;
374 char intf_blend;
375 char most_switch;
376} ;
377
378struct hci_fm_search_station_req {
379 char srch_mode;
380 char scan_time;
381 char srch_dir;
382} ;
383
384struct hci_fm_search_rds_station_req {
385 struct hci_fm_search_station_req srch_station;
386 char srch_pty;
387 short srch_pi;
388} ;
389
390struct hci_fm_search_station_list_req {
391 char srch_list_mode;
392 char srch_list_dir;
393 int srch_list_max;
394 char srch_pty;
395} ;
396
397struct hci_fm_rds_grp_req {
398 int rds_grp_enable_mask;
399 int rds_buf_size;
400 char en_rds_change_filter;
401} ;
402
403struct hci_fm_en_avd_ctrl_req {
404 char no_freqs;
405 char freq_index;
406 char lo_shft;
407 short freq_min;
408 short freq_max;
409} ;
410
411struct hci_fm_def_data_rd_req {
412 char mode;
413 char length;
414 char param_len;
415 char param;
416} ;
417
418struct hci_fm_def_data_wr_req {
419 char mode;
420 char length;
421 char data[DEFAULT_DATA_SIZE];
422} ;
423
424struct hci_fm_riva_data {
425 char subopcode;
426 int start_addr;
427 char length;
428} ;
429
430struct hci_fm_riva_poke {
431 struct hci_fm_riva_data cmd_params;
432 char data[MAX_RIVA_PEEK_RSP_SIZE];
433} ;
434
435struct hci_fm_ssbi_req {
436 short start_addr;
437 char data;
438} ;
439struct hci_fm_ssbi_peek {
440 short start_address;
441} ;
442
443struct hci_fm_ch_det_threshold {
444 char sinr;
445 char sinr_samples;
446 char low_th;
447 char high_th;
448
449} ;
450
451struct hci_fm_blend_table {
452 char ucBlendType;
453 char ucBlendRampRateUp;
454 char ucBlendDebounceNumSampleUp;
455 char ucBlendDebounceIdxUp;
456 char ucBlendSinrIdxSkipStep;
457 char scBlendSinrHi;
458 char scBlendRmssiHi;
459 char ucBlendIndexHi;
460 char ucBlendIndex[MAX_BLEND_INDEX];
461} ;
462
463/*HCI events*/
464#define HCI_EV_TUNE_STATUS 0x01
465#define HCI_EV_RDS_LOCK_STATUS 0x02
466#define HCI_EV_STEREO_STATUS 0x03
467#define HCI_EV_SERVICE_AVAILABLE 0x04
468#define HCI_EV_SEARCH_PROGRESS 0x05
469#define HCI_EV_SEARCH_RDS_PROGRESS 0x06
470#define HCI_EV_SEARCH_LIST_PROGRESS 0x07
471#define HCI_EV_RDS_RX_DATA 0x08
472#define HCI_EV_PROGRAM_SERVICE 0x09
473#define HCI_EV_RADIO_TEXT 0x0A
474#define HCI_EV_FM_AF_LIST 0x0B
475#define HCI_EV_TX_RDS_GRP_AVBLE 0x0C
476#define HCI_EV_TX_RDS_GRP_COMPL 0x0D
477#define HCI_EV_TX_RDS_CONT_GRP_COMPL 0x0E
478#define HCI_EV_CMD_COMPLETE 0x0F
479#define HCI_EV_CMD_STATUS 0x10
480#define HCI_EV_TUNE_COMPLETE 0x11
481#define HCI_EV_SEARCH_COMPLETE 0x12
482#define HCI_EV_SEARCH_RDS_COMPLETE 0x13
483#define HCI_EV_SEARCH_LIST_COMPLETE 0x14
484
485#define HCI_REQ_DONE 0
486#define HCI_REQ_PEND 1
487#define HCI_REQ_CANCELED 2
488#define HCI_REQ_STATUS 3
489
490#define MAX_RAW_RDS_GRPS 21
491
492#define RDSGRP_DATA_OFFSET 0x1
493
494/*RT PLUS*/
495#define DUMMY_CLASS 0
496#define RT_PLUS_LEN_1_TAG 3
497#define RT_ERT_FLAG_BIT 5
498
499/*TAG1*/
500#define TAG1_MSB_OFFSET 3
501#define TAG1_MSB_MASK 7
502#define TAG1_LSB_OFFSET 5
503#define TAG1_POS_MSB_MASK 31
504#define TAG1_POS_MSB_OFFSET 1
505#define TAG1_POS_LSB_OFFSET 7
506#define TAG1_LEN_OFFSET 1
507#define TAG1_LEN_MASK 63
508
509/*TAG2*/
510#define TAG2_MSB_OFFSET 5
511#define TAG2_MSB_MASK 1
512#define TAG2_LSB_OFFSET 3
513#define TAG2_POS_MSB_MASK 7
514#define TAG2_POS_MSB_OFFSET 3
515#define TAG2_POS_LSB_OFFSET 5
516#define TAG2_LEN_MASK 31
517
518#define AGT_MASK 31
519/*Extract 5 left most bits of lsb of 2nd block*/
520#define AGT(x) (x & AGT_MASK)
521/*16 bits of 4th block*/
522#define AID(lsb, msb) ((msb << 8) | (lsb))
523/*Extract 5 right most bits of msb of 2nd block*/
524#define GTC(blk2msb) (blk2msb >> 3)
525
526#define GRP_3A 0x6
527#define RT_PLUS_AID 0x4bd7
528
529/*ERT*/
530#define ERT_AID 0x6552
531#define CARRIAGE_RETURN 0x000D
532#define MAX_ERT_SEGMENT 31
533#define ERT_FORMAT_DIR_BIT 1
534
535#define EXTRACT_BIT(data, bit_pos) ((data & (1 << bit_pos)) >> bit_pos)
536
537struct hci_ev_tune_status {
538 char sub_event;
539 int station_freq;
540 char serv_avble;
541 char rssi;
542 char stereo_prg;
543 char rds_sync_status;
544 char mute_mode;
545 char sinr;
546 char intf_det_th;
547} ;
548
549struct rds_blk_data {
550 char rdsMsb;
551 char rdsLsb;
552 char blockStatus;
553} ;
554
555struct rds_grp_data {
556 struct rds_blk_data rdsBlk[4];
557} ;
558
559struct hci_ev_rds_rx_data {
560 char num_rds_grps;
561 struct rds_grp_data rds_grp_data[MAX_RAW_RDS_GRPS];
562} ;
563
564struct hci_ev_prg_service {
565 short pi_prg_id;
566 char pty_prg_type;
567 char ta_prg_code_type;
568 char ta_ann_code_flag;
569 char ms_switch_code_flag;
570 char dec_id_ctrl_code_flag;
571 char ps_num;
572 char prg_service_name[119];
573} ;
574
575struct hci_ev_radio_text {
576 short pi_prg_id;
577 char pty_prg_type;
578 char ta_prg_code_type;
579 char txt_ab_flag;
580 char radio_txt[64];
581} ;
582
583struct hci_ev_af_list {
584 int tune_freq;
585 short pi_code;
586 char af_size;
587 char af_list[FM_AF_LIST_MAX_SIZE];
588} ;
589
590struct hci_ev_cmd_complete {
591 char num_hci_cmd_pkts;
592 short cmd_opcode;
593} ;
594
595struct hci_ev_cmd_status {
596 char status;
597 char num_hci_cmd_pkts;
598 short status_opcode;
599} ;
600
601struct hci_ev_srch_st {
602 int station_freq;
603 char rds_cap;
604 char pty;
605 short status_opcode;
606} ;
607
608struct hci_ev_rel_freq {
609 char rel_freq_msb;
610 char rel_freq_lsb;
611
612} ;
613struct hci_ev_srch_list_compl {
614 char num_stations_found;
615 struct hci_ev_rel_freq rel_freq[20];
616} ;
617
618/* ----- HCI Event Response ----- */
619struct hci_fm_conf_rsp {
620 char status;
621 struct hci_fm_recv_conf_req recv_conf_rsp;
622} ;
623
624struct hci_fm_get_trans_conf_rsp {
625 char status;
626 struct hci_fm_trans_conf_req_struct trans_conf_rsp;
627} ;
628struct hci_fm_sig_threshold_rsp {
629 char status;
630 char sig_threshold;
631} ;
632
633struct hci_fm_station_rsp {
634 struct hci_ev_tune_status station_rsp;
635} ;
636
637struct hci_fm_prgm_srv_rsp {
638 char status;
639 struct hci_ev_prg_service prg_srv;
640} ;
641
642struct hci_fm_radio_txt_rsp {
643 char status;
644 struct hci_ev_radio_text rd_txt;
645} ;
646
647struct hci_fm_af_list_rsp {
648 char status;
649 struct hci_ev_af_list rd_txt;
650} ;
651
652struct hci_fm_data_rd_rsp {
653 char status;
654 char ret_data_len;
655 char data[DEFAULT_DATA_SIZE];
656} ;
657
658struct hci_fm_feature_list_rsp {
659 char status;
660 char feature_mask;
661} ;
662
663struct hci_fm_dbg_param_rsp {
664 char status;
665 char blend;
666 char soft_mute;
667 char inf_blend;
668 char inf_soft_mute;
669 char pilot_pil;
670 char io_verc;
671 char in_det_out;
672} ;
673
674#define CLKSPURID_INDEX0 0
675#define CLKSPURID_INDEX1 5
676#define CLKSPURID_INDEX2 10
677#define CLKSPURID_INDEX3 15
678#define CLKSPURID_INDEX4 20
679#define CLKSPURID_INDEX5 25
680
681#define MAX_SPUR_FREQ_LIMIT 30
682#define CKK_SPUR 0x3B
683#define SPUR_DATA_SIZE 0x4
684#define SPUR_ENTRIES_PER_ID 0x5
685
686#define COMPUTE_SPUR(val) ((((val) - (76000)) / (50)))
687#define GET_FREQ(val, bit) ((bit == 1) ? ((val) >> 8) : ((val) & 0xFF))
688#define GET_SPUR_ENTRY_LEVEL(val) ((val) / (5))
689
690struct hci_fm_spur_data {
691 int freq[MAX_SPUR_FREQ_LIMIT];
692 char rmssi[MAX_SPUR_FREQ_LIMIT];
693 char enable[MAX_SPUR_FREQ_LIMIT];
694} ;
695
696
697/* HCI dev events */
698#define RADIO_HCI_DEV_REG 1
699#define RADIO_HCI_DEV_WRITE 2
700
701#define hci_req_lock(d) mutex_lock(&d->req_lock)
702#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
703
704/* FM RDS */
705#define RDS_PTYPE 2
706#define RDS_PID_LOWER 1
707#define RDS_PID_HIGHER 0
708#define RDS_OFFSET 5
709#define RDS_PS_LENGTH_OFFSET 7
710#define RDS_STRING 8
711#define RDS_PS_DATA_OFFSET 8
712#define RDS_CONFIG_OFFSET 3
713#define RDS_AF_JUMP_OFFSET 4
714#define PI_CODE_OFFSET 4
715#define AF_SIZE_OFFSET 6
716#define AF_LIST_OFFSET 7
717#define RT_A_B_FLAG_OFFSET 4
718/*FM states*/
719
720enum radio_state_t {
721 FM_OFF,
722 FM_RECV,
723 FM_TRANS,
724 FM_RESET,
725 FM_CALIB,
726 FM_TURNING_OFF,
727 FM_RECV_TURNING_ON,
728 FM_TRANS_TURNING_ON,
729 FM_MAX_NO_STATES,
730};
731
732enum emphasis_type {
733 FM_RX_EMP75 = 0x0,
734 FM_RX_EMP50 = 0x1
735};
736
737enum channel_space_type {
738 FM_RX_SPACE_200KHZ = 0x0,
739 FM_RX_SPACE_100KHZ = 0x1,
740 FM_RX_SPACE_50KHZ = 0x2
741};
742
743enum high_low_injection {
744 AUTO_HI_LO_INJECTION = 0x0,
745 LOW_SIDE_INJECTION = 0x1,
746 HIGH_SIDE_INJECTION = 0x2
747};
748
749enum fm_rds_type {
750 FM_RX_RDBS_SYSTEM = 0x0,
751 FM_RX_RDS_SYSTEM = 0x1
752};
753
754enum hlm_region_t {
755 HELIUM_REGION_US,
756 HELIUM_REGION_EU,
757 HELIUM_REGION_JAPAN,
758 HELIUM_REGION_JAPAN_WIDE,
759 HELIUM_REGION_OTHER
760};
761
762/* Search options */
763enum search_t {
764 SEEK,
765 SCAN,
766 SCAN_FOR_STRONG,
767 SCAN_FOR_WEAK,
768 RDS_SEEK_PTY,
769 RDS_SCAN_PTY,
770 RDS_SEEK_PI,
771 RDS_AF_JUMP,
772};
773
774enum spur_entry_levels {
775 ENTRY_0,
776 ENTRY_1,
777 ENTRY_2,
778 ENTRY_3,
779 ENTRY_4,
780 ENTRY_5,
781};
782
783/* Band limits */
784#define REGION_US_EU_BAND_LOW 87500
785#define REGION_US_EU_BAND_HIGH 108000
786#define REGION_JAPAN_STANDARD_BAND_LOW 76000
787#define REGION_JAPAN_STANDARD_BAND_HIGH 90000
788#define REGION_JAPAN_WIDE_BAND_LOW 90000
789#define REGION_JAPAN_WIDE_BAND_HIGH 108000
790
791#define SRCH_MODE 0x07
792#define SRCH_DIR 0x08 /* 0-up 1-down */
793#define SCAN_DWELL 0x70
794#define SRCH_ON 0x80
795
796/* I/O Control */
797#define IOC_HRD_MUTE 0x03
798#define IOC_SFT_MUTE 0x01
799#define IOC_MON_STR 0x01
800#define IOC_SIG_BLND 0x01
801#define IOC_INTF_BLND 0x01
802#define IOC_ANTENNA 0x01
803
804/* RDS Control */
805#define RDS_ON 0x01
806#define RDS_BUF_SZ 100
807
808/* constants */
809#define RDS_BLOCKS_NUM (4)
810#define BYTES_PER_BLOCK (3)
811#define MAX_PS_LENGTH (108)
812#define MAX_RT_LENGTH (64)
813#define RDS_GRP_CNTR_LEN (36)
814#define RX_RT_DATA_LENGTH (63)
815/* Search direction */
816#define SRCH_DIR_UP (0)
817#define SRCH_DIR_DOWN (1)
818
819/*Search RDS stations*/
820#define SEARCH_RDS_STNS_MODE_OFFSET 4
821
822/*Search Station list */
823#define PARAMS_PER_STATION 0x08
824#define STN_NUM_OFFSET 0x01
825#define STN_FREQ_OFFSET 0x02
826#define KHZ_TO_MHZ 1000
827#define GET_MSB(x)((x >> 8) & 0xFF)
828#define GET_LSB(x)((x) & 0xFF)
829
830/* control options */
831#define CTRL_ON (1)
832#define CTRL_OFF (0)
833
834/*Diagnostic commands*/
835
836#define RIVA_PEEK_OPCODE 0x0D
837#define RIVA_POKE_OPCODE 0x0C
838
839#define PEEK_DATA_OFSET 0x1
840#define RIVA_PEEK_PARAM 0x6
841#define RIVA_PEEK_LEN_OFSET 0x6
842#define SSBI_PEEK_LEN 0x01
843/*Calibration data*/
844#define PROCS_CALIB_MODE 1
845#define PROCS_CALIB_SIZE 23
846#define DC_CALIB_MODE 2
847#define DC_CALIB_SIZE 48
848#define RSB_CALIB_MODE 3
849#define RSB_CALIB_SIZE 4
850#define CALIB_DATA_OFSET 2
851#define CALIB_MODE_OFSET 1
852#define MAX_CALIB_SIZE 75
853
854/* Channel validity */
855#define INVALID_CHANNEL (0)
856#define VALID_CHANNEL (1)
857
858struct hci_fm_set_cal_req_proc {
859 char mode;
860 /*Max process calibration data size*/
861 char data[PROCS_CALIB_SIZE];
862} ;
863
864struct hci_fm_set_cal_req_dc {
865 char mode;
866 /*Max DC calibration data size*/
867 char data[DC_CALIB_SIZE];
868} ;
869
870struct hci_cc_do_calibration_rsp {
871 char status;
872 char mode;
873 char data[MAX_CALIB_SIZE];
874} ;
875
876struct hci_fm_set_spur_table_req {
877 char mode;
878 char no_of_freqs_entries;
879 char spur_data[FM_SPUR_TBL_SIZE];
880} ;
881/* Low Power mode*/
882#define SIG_LEVEL_INTR (1 << 0)
883#define RDS_SYNC_INTR (1 << 1)
884#define AUDIO_CTRL_INTR (1 << 2)
885#define AF_JUMP_ENABLE (1 << 4)
886
887int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
888 struct radio_hci_dev *hdev);
889int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
890 struct radio_hci_dev *hdev);
891int hci_fm_do_calibration(char *arg, struct radio_hci_dev *hdev);
892int hci_fm_do_calibration(char *arg, struct radio_hci_dev *hdev);
893
894static inline int is_valid_tone(int tone)
895{
896 if ((tone >= MIN_TX_TONE_VAL) &&
897 (tone <= MAX_TX_TONE_VAL))
898 return 1;
899 else
900 return 0;
901}
902
903static inline int is_valid_hard_mute(int hard_mute)
904{
905 if ((hard_mute >= MIN_HARD_MUTE_VAL) &&
906 (hard_mute <= MAX_HARD_MUTE_VAL))
907 return 1;
908 else
909 return 0;
910}
911
912static inline int is_valid_srch_mode(int srch_mode)
913{
914 if ((srch_mode >= MIN_SRCH_MODE) &&
915 (srch_mode <= MAX_SRCH_MODE))
916 return 1;
917 else
918 return 0;
919}
920
921static inline int is_valid_scan_dwell_prd(int scan_dwell_prd)
922{
923 if ((scan_dwell_prd >= MIN_SCAN_DWELL) &&
924 (scan_dwell_prd <= MAX_SCAN_DWELL))
925 return 1;
926 else
927 return 0;
928}
929
930static inline int is_valid_sig_th(int sig_th)
931{
932 if ((sig_th >= MIN_SIG_TH) &&
933 (sig_th <= MAX_SIG_TH))
934 return 1;
935 else
936 return 0;
937}
938
939static inline int is_valid_pty(int pty)
940{
941 if ((pty >= MIN_PTY) &&
942 (pty <= MAX_PTY))
943 return 1;
944 else
945 return 0;
946}
947
948static inline int is_valid_pi(int pi)
949{
950 if ((pi >= MIN_PI) &&
951 (pi <= MAX_PI))
952 return 1;
953 else
954 return 0;
955}
956
957static inline int is_valid_srch_station_cnt(int cnt)
958{
959 if ((cnt >= MIN_SRCH_STATIONS_CNT) &&
960 (cnt <= MAX_SRCH_STATIONS_CNT))
961 return 1;
962 else
963 return 0;
964}
965
966static inline int is_valid_chan_spacing(int spacing)
967{
968 if ((spacing >= MIN_CHAN_SPACING) &&
969 (spacing <= MAX_CHAN_SPACING))
970 return 1;
971 else
972 return 0;
973}
974
975static inline int is_valid_emphasis(int emphasis)
976{
977 if ((emphasis >= MIN_EMPHASIS) &&
978 (emphasis <= MAX_EMPHASIS))
979 return 1;
980 else
981 return 0;
982}
983
984static inline int is_valid_rds_std(int rds_std)
985{
986 if ((rds_std >= MIN_RDS_STD) &&
987 (rds_std <= MAX_RDS_STD))
988 return 1;
989 else
990 return 0;
991}
992
993static inline int is_valid_antenna(int antenna_type)
994{
995 if ((antenna_type >= MIN_ANTENNA_VAL) &&
996 (antenna_type <= MAX_ANTENNA_VAL))
997 return 1;
998 else
999 return 0;
1000}
1001
1002static inline int is_valid_ps_repeat_cnt(int cnt)
1003{
1004 if ((cnt >= MIN_TX_PS_REPEAT_CNT) &&
1005 (cnt <= MAX_TX_PS_REPEAT_CNT))
1006 return 1;
1007 else
1008 return 0;
1009}
1010
1011static inline int is_valid_soft_mute(int soft_mute)
1012{
1013 if ((soft_mute >= MIN_SOFT_MUTE) &&
1014 (soft_mute <= MAX_SOFT_MUTE))
1015 return 1;
1016 else
1017 return 0;
1018}
1019
1020static inline int is_valid_peek_len(int len)
1021{
1022 if ((len >= MIN_PEEK_ACCESS_LEN) &&
1023 (len <= MAX_PEEK_ACCESS_LEN))
1024 return 1;
1025 else
1026 return 0;
1027}
1028
1029static inline int is_valid_reset_cntr(int cntr)
1030{
1031 if ((cntr >= MIN_RESET_CNTR) &&
1032 (cntr <= MAX_RESET_CNTR))
1033 return 1;
1034 else
1035 return 0;
1036}
1037
1038static inline int is_valid_hlsi(int hlsi)
1039{
1040 if ((hlsi >= MIN_HLSI) &&
1041 (hlsi <= MAX_HLSI))
1042 return 1;
1043 else
1044 return 0;
1045}
1046
1047static inline int is_valid_notch_filter(int filter)
1048{
1049 if ((filter >= MIN_NOTCH_FILTER) &&
1050 (filter <= MAX_NOTCH_FILTER))
1051 return 1;
1052 else
1053 return 0;
1054}
1055
1056static inline int is_valid_intf_det_low_th(int th)
1057{
1058 if ((th >= MIN_INTF_DET_OUT_LW_TH) &&
1059 (th <= MAX_INTF_DET_OUT_LW_TH))
1060 return 1;
1061 else
1062 return 0;
1063}
1064
1065static inline int is_valid_intf_det_hgh_th(int th)
1066{
1067 if ((th >= MIN_INTF_DET_OUT_HG_TH) &&
1068 (th <= MAX_INTF_DET_OUT_HG_TH))
1069 return 1;
1070 else
1071 return 0;
1072}
1073
1074static inline int is_valid_sinr_th(int th)
1075{
1076 if ((th >= MIN_SINR_TH) &&
1077 (th <= MAX_SINR_TH))
1078 return 1;
1079 else
1080 return 0;
1081}
1082
1083static inline int is_valid_sinr_samples(int samples_cnt)
1084{
1085 if ((samples_cnt >= MIN_SINR_SAMPLES) &&
1086 (samples_cnt <= MAX_SINR_SAMPLES))
1087 return 1;
1088 else
1089 return 0;
1090}
1091
1092static inline int is_valid_fm_state(int state)
1093{
1094 if ((state >= 0) && (state < FM_MAX_NO_STATES))
1095 return 1;
1096 else
1097 return 0;
1098}
1099
1100static inline int is_valid_blend_value(int val)
1101{
1102 if ((val >= MIN_BLEND_HI) && (val <= MAX_BLEND_HI))
1103 return 1;
1104 else
1105 return 0;
1106}
1107
1108struct helium_device {
1109 int tune_req;
1110 unsigned int mode;
1111 short pi;
1112 char pty;
1113 char ps_repeatcount;
1114 char prev_trans_rds;
1115 char af_jump_bit;
1116 struct hci_fm_mute_mode_req mute_mode;
1117 struct hci_fm_stereo_mode_req stereo_mode;
1118 struct hci_fm_station_rsp fm_st_rsp;
1119 struct hci_fm_search_station_req srch_st;
1120 struct hci_fm_search_rds_station_req srch_rds;
1121 struct hci_fm_search_station_list_req srch_st_list;
1122 struct hci_fm_recv_conf_req recv_conf;
1123 struct hci_fm_trans_conf_req_struct trans_conf;
1124 struct hci_fm_rds_grp_req rds_grp;
1125 unsigned char g_search_mode;
1126 unsigned char power_mode;
1127 int search_on;
1128 unsigned char spur_table_size;
1129 unsigned char g_scan_time;
1130 unsigned int g_antenna;
1131 unsigned int g_rds_grp_proc_ps;
1132 unsigned char event_mask;
1133 enum hlm_region_t region;
1134 struct hci_fm_dbg_param_rsp st_dbg_param;
1135 struct hci_ev_srch_list_compl srch_st_result;
1136};
1137#endif /* __UAPI_RADIO_HCI_CORE_H */