blob: 8599316b494cb95e20f5bf12e007a383535784c8 [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);
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700162typedef void (*rds_grp_cntrs_cb)(char *rds_params);
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700163
164typedef struct {
165 size_t size;
166
167 enb_result_cb enabled_cb;
168 tune_rsp_cb tune_cb;
169 seek_rsp_cb seek_cmpl_cb;
170 scan_rsp_cb scan_next_cb;
171 srch_list_rsp_cb srch_list_cb;
172 stereo_mode_cb stereo_status_cb;
173 rds_avl_sts_cb rds_avail_status_cb;
174 af_list_cb af_list_update_cb;
175 rt_cb rt_update_cb;
176 ps_cb ps_update_cb;
177 oda_cb oda_update_cb;
178 rt_plus_cb rt_plus_update_cb;
179 ert_cb ert_update_cb;
180 disable_cb disabled_cb;
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700181 rds_grp_cntrs_cb rds_grp_cntrs_rsp_cb;
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700182 callback_thread_event thread_evt_cb;
183} fm_vendor_callbacks_t;
184
185pthread_mutex_t radio_fm_cmd;
186typedef struct {
187 int (*init)(const fm_vendor_callbacks_t *p_cb);
188 int (*set_fm_ctrl)(int opcode, int val);
189 void (*Get_fm_ctrl) (int opcode, int val);
190} fm_interface_t;
191
192typedef int (*fm_evt_notify_cb)(unsigned char *p_buf);
193
194typedef struct {
195 fm_evt_notify_cb fm_evt_notify;
196} fm_hal_cb;
197
198struct radio_hci_command_hdr {
199 short opcode; /* OCF & OGF */
200 char plen;
201} ;
202
203struct radio_hci_event_hdr {
204 char evt;
205 char plen;
206} ;
207
208struct radio_hci_dev {
209 char name[8];
210 unsigned long flags;
211 short id;
212 char bus;
213 char dev_type;
214 char dev_name[248];
215 char dev_class[3];
216 char features[8];
217 char commands[64];
218 unsigned int data_block_len;
219 unsigned long cmd_last_tx;
220 int req_status;
221 int req_result;
222};
223
224/* Opcode OCF */
225/* HCI recv control commands opcode */
226#define HCI_OCF_FM_ENABLE_RECV_REQ 0x0001
227#define HCI_OCF_FM_DISABLE_RECV_REQ 0x0002
228#define HCI_OCF_FM_GET_RECV_CONF_REQ 0x0003
229#define HCI_OCF_FM_SET_RECV_CONF_REQ 0x0004
230#define HCI_OCF_FM_SET_MUTE_MODE_REQ 0x0005
231#define HCI_OCF_FM_SET_STEREO_MODE_REQ 0x0006
232#define HCI_OCF_FM_SET_ANTENNA 0x0007
233#define HCI_OCF_FM_SET_SIGNAL_THRESHOLD 0x0008
234#define HCI_OCF_FM_GET_SIGNAL_THRESHOLD 0x0009
235#define HCI_OCF_FM_GET_STATION_PARAM_REQ 0x000A
236#define HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ 0x000B
237#define HCI_OCF_FM_GET_RADIO_TEXT_REQ 0x000C
238#define HCI_OCF_FM_GET_AF_LIST_REQ 0x000D
239#define HCI_OCF_FM_SEARCH_STATIONS 0x000E
240#define HCI_OCF_FM_SEARCH_RDS_STATIONS 0x000F
241#define HCI_OCF_FM_SEARCH_STATIONS_LIST 0x0010
242#define HCI_OCF_FM_CANCEL_SEARCH 0x0011
243#define HCI_OCF_FM_RDS_GRP 0x0012
244#define HCI_OCF_FM_RDS_GRP_PROCESS 0x0013
245#define HCI_OCF_FM_EN_WAN_AVD_CTRL 0x0014
246#define HCI_OCF_FM_EN_NOTCH_CTRL 0x0015
247#define HCI_OCF_FM_SET_EVENT_MASK 0x0016
248#define HCI_OCF_FM_SET_CH_DET_THRESHOLD 0x0017
249#define HCI_OCF_FM_GET_CH_DET_THRESHOLD 0x0018
250#define HCI_OCF_FM_SET_BLND_TBL 0x001B
251#define HCI_OCF_FM_GET_BLND_TBL 0x001C
252/* HCI trans control commans opcode*/
253#define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001
254#define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002
255#define HCI_OCF_FM_GET_TRANS_CONF_REQ 0x0003
256#define HCI_OCF_FM_SET_TRANS_CONF_REQ 0x0004
257#define HCI_OCF_FM_RDS_RT_REQ 0x0008
258#define HCI_OCF_FM_RDS_PS_REQ 0x0009
259
260
261/* HCI common control commands opcode */
262#define HCI_OCF_FM_TUNE_STATION_REQ 0x0001
263#define HCI_OCF_FM_DEFAULT_DATA_READ 0x0002
264#define HCI_OCF_FM_DEFAULT_DATA_WRITE 0x0003
265#define HCI_OCF_FM_RESET 0x0004
266#define HCI_OCF_FM_GET_FEATURE_LIST 0x0005
267#define HCI_OCF_FM_DO_CALIBRATION 0x0006
268#define HCI_OCF_FM_SET_CALIBRATION 0x0007
269#define HCI_OCF_FM_SET_SPUR_TABLE 0x0008
270#define HCI_OCF_FM_GET_SPUR_TABLE 0x0009
271
272/*HCI Status parameters commands*/
273#define HCI_OCF_FM_READ_GRP_COUNTERS 0x0001
274
275/*HCI Diagnostic commands*/
276#define HCI_OCF_FM_PEEK_DATA 0x0002
277#define HCI_OCF_FM_POKE_DATA 0x0003
278#define HCI_OCF_FM_SSBI_PEEK_REG 0x0004
279#define HCI_OCF_FM_SSBI_POKE_REG 0x0005
280#define HCI_OCF_FM_STATION_DBG_PARAM 0x0007
281#define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008
282
283/* Opcode OGF */
284#define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013
285#define HCI_OGF_FM_TRANS_CTRL_CMD_REQ 0x0014
286#define HCI_OGF_FM_COMMON_CTRL_CMD_REQ 0x0015
287#define HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ 0x0016
288#define HCI_OGF_FM_TEST_CMD_REQ 0x0017
289#define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F
290
291/* Command opcode pack/unpack */
292#define hci_opcode_pack(ogf, ocf) (short) ((ocf & 0x03ff)|(ogf << 10))
293#define hci_opcode_ogf(op) (op >> 10)
294#define hci_opcode_ocf(op) (op & 0x03ff)
295#define hci_recv_ctrl_cmd_op_pack(ocf) \
296 (short) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf)
297#define hci_trans_ctrl_cmd_op_pack(ocf) \
298 (short) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf)
299#define hci_common_cmd_op_pack(ocf) \
300 (short) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf)
301#define hci_status_param_op_pack(ocf) \
302 (short) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf)
303#define hci_diagnostic_cmd_op_pack(ocf) \
304 (short) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf)
305
306
307/* HCI commands with no arguments*/
308#define HCI_FM_ENABLE_RECV_CMD 1
309#define HCI_FM_DISABLE_RECV_CMD 2
310#define HCI_FM_GET_RECV_CONF_CMD 3
311#define HCI_FM_GET_STATION_PARAM_CMD 4
312#define HCI_FM_GET_SIGNAL_TH_CMD 5
313#define HCI_FM_GET_PROGRAM_SERVICE_CMD 6
314#define HCI_FM_GET_RADIO_TEXT_CMD 7
315#define HCI_FM_GET_AF_LIST_CMD 8
316#define HCI_FM_CANCEL_SEARCH_CMD 9
317#define HCI_FM_RESET_CMD 10
318#define HCI_FM_GET_FEATURES_CMD 11
319#define HCI_FM_STATION_DBG_PARAM_CMD 12
320#define HCI_FM_ENABLE_TRANS_CMD 13
321#define HCI_FM_DISABLE_TRANS_CMD 14
322#define HCI_FM_GET_TX_CONFIG 15
323#define HCI_FM_GET_DET_CH_TH_CMD 16
324#define HCI_FM_GET_BLND_TBL_CMD 17
325
326/* Defines for FM TX*/
327#define TX_PS_DATA_LENGTH 108
328#define TX_RT_DATA_LENGTH 64
329#define PS_STRING_LEN 9
330
331/* ----- HCI Command request ----- */
332struct hci_fm_recv_conf_req {
333 char emphasis;
334 char ch_spacing;
335 char rds_std;
336 char hlsi;
337 int band_low_limit;
338 int band_high_limit;
339} ;
340
341/* ----- HCI Command request ----- */
342struct hci_fm_trans_conf_req_struct {
343 char emphasis;
344 char rds_std;
345 int band_low_limit;
346 int band_high_limit;
347} ;
348
349
350/* ----- HCI Command request ----- */
351struct hci_fm_tx_ps {
352 char ps_control;
353 short pi;
354 char pty;
355 char ps_repeatcount;
356 char ps_num;
357 char ps_data[TX_PS_DATA_LENGTH];
358} ;
359
360struct hci_fm_tx_rt {
361 char rt_control;
362 short pi;
363 char pty;
364 char rt_len;
365 char rt_data[TX_RT_DATA_LENGTH];
366} ;
367
368struct hci_fm_mute_mode_req {
369 char hard_mute;
370 char soft_mute;
371} ;
372
373struct hci_fm_stereo_mode_req {
374 char stereo_mode;
375 char sig_blend;
376 char intf_blend;
377 char most_switch;
378} ;
379
380struct hci_fm_search_station_req {
381 char srch_mode;
382 char scan_time;
383 char srch_dir;
384} ;
385
386struct hci_fm_search_rds_station_req {
387 struct hci_fm_search_station_req srch_station;
388 char srch_pty;
389 short srch_pi;
390} ;
391
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700392struct hci_fm_rds_grp_cntrs_params {
393 int totalRdsSBlockErrors;
394 int totalRdsGroups;
395 int totalRdsGroup0;
396 int totalRdsGroup2;
397 int totalRdsBlockB;
398 int totalRdsProcessedGroup0;
399 int totalRdsProcessedGroup2;
400 int totalRdsGroupFiltered;
401 int totalRdsChangeFiltered;
402} ;
403
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700404struct hci_fm_search_station_list_req {
405 char srch_list_mode;
406 char srch_list_dir;
407 int srch_list_max;
408 char srch_pty;
409} ;
410
411struct hci_fm_rds_grp_req {
412 int rds_grp_enable_mask;
413 int rds_buf_size;
414 char en_rds_change_filter;
415} ;
416
417struct hci_fm_en_avd_ctrl_req {
418 char no_freqs;
419 char freq_index;
420 char lo_shft;
421 short freq_min;
422 short freq_max;
423} ;
424
425struct hci_fm_def_data_rd_req {
426 char mode;
427 char length;
428 char param_len;
429 char param;
430} ;
431
432struct hci_fm_def_data_wr_req {
433 char mode;
434 char length;
435 char data[DEFAULT_DATA_SIZE];
436} ;
437
438struct hci_fm_riva_data {
439 char subopcode;
440 int start_addr;
441 char length;
442} ;
443
444struct hci_fm_riva_poke {
445 struct hci_fm_riva_data cmd_params;
446 char data[MAX_RIVA_PEEK_RSP_SIZE];
447} ;
448
449struct hci_fm_ssbi_req {
450 short start_addr;
451 char data;
452} ;
453struct hci_fm_ssbi_peek {
454 short start_address;
455} ;
456
457struct hci_fm_ch_det_threshold {
458 char sinr;
459 char sinr_samples;
460 char low_th;
461 char high_th;
462
463} ;
464
465struct hci_fm_blend_table {
466 char ucBlendType;
467 char ucBlendRampRateUp;
468 char ucBlendDebounceNumSampleUp;
469 char ucBlendDebounceIdxUp;
470 char ucBlendSinrIdxSkipStep;
471 char scBlendSinrHi;
472 char scBlendRmssiHi;
473 char ucBlendIndexHi;
474 char ucBlendIndex[MAX_BLEND_INDEX];
475} ;
476
477/*HCI events*/
478#define HCI_EV_TUNE_STATUS 0x01
479#define HCI_EV_RDS_LOCK_STATUS 0x02
480#define HCI_EV_STEREO_STATUS 0x03
481#define HCI_EV_SERVICE_AVAILABLE 0x04
482#define HCI_EV_SEARCH_PROGRESS 0x05
483#define HCI_EV_SEARCH_RDS_PROGRESS 0x06
484#define HCI_EV_SEARCH_LIST_PROGRESS 0x07
485#define HCI_EV_RDS_RX_DATA 0x08
486#define HCI_EV_PROGRAM_SERVICE 0x09
487#define HCI_EV_RADIO_TEXT 0x0A
488#define HCI_EV_FM_AF_LIST 0x0B
489#define HCI_EV_TX_RDS_GRP_AVBLE 0x0C
490#define HCI_EV_TX_RDS_GRP_COMPL 0x0D
491#define HCI_EV_TX_RDS_CONT_GRP_COMPL 0x0E
492#define HCI_EV_CMD_COMPLETE 0x0F
493#define HCI_EV_CMD_STATUS 0x10
494#define HCI_EV_TUNE_COMPLETE 0x11
495#define HCI_EV_SEARCH_COMPLETE 0x12
496#define HCI_EV_SEARCH_RDS_COMPLETE 0x13
497#define HCI_EV_SEARCH_LIST_COMPLETE 0x14
Satish kumar sugasib0ba3c82016-05-04 20:18:23 -0700498#define HCI_EV_RADIO_TEXT_PLUS_ID 0x18
499#define HCI_EV_RADIO_TEXT_PLUS_TAG 0x19
Satish kumar sugasi8a34ad32015-10-19 18:09:49 -0700500#define HCI_EV_HW_ERR_EVENT 0x1A
501
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700502
503#define HCI_REQ_DONE 0
504#define HCI_REQ_PEND 1
505#define HCI_REQ_CANCELED 2
506#define HCI_REQ_STATUS 3
507
508#define MAX_RAW_RDS_GRPS 21
509
510#define RDSGRP_DATA_OFFSET 0x1
511
512/*RT PLUS*/
513#define DUMMY_CLASS 0
514#define RT_PLUS_LEN_1_TAG 3
515#define RT_ERT_FLAG_BIT 5
516
517/*TAG1*/
518#define TAG1_MSB_OFFSET 3
519#define TAG1_MSB_MASK 7
520#define TAG1_LSB_OFFSET 5
521#define TAG1_POS_MSB_MASK 31
522#define TAG1_POS_MSB_OFFSET 1
523#define TAG1_POS_LSB_OFFSET 7
524#define TAG1_LEN_OFFSET 1
525#define TAG1_LEN_MASK 63
526
527/*TAG2*/
528#define TAG2_MSB_OFFSET 5
529#define TAG2_MSB_MASK 1
530#define TAG2_LSB_OFFSET 3
531#define TAG2_POS_MSB_MASK 7
532#define TAG2_POS_MSB_OFFSET 3
533#define TAG2_POS_LSB_OFFSET 5
534#define TAG2_LEN_MASK 31
535
536#define AGT_MASK 31
537/*Extract 5 left most bits of lsb of 2nd block*/
538#define AGT(x) (x & AGT_MASK)
539/*16 bits of 4th block*/
540#define AID(lsb, msb) ((msb << 8) | (lsb))
541/*Extract 5 right most bits of msb of 2nd block*/
542#define GTC(blk2msb) (blk2msb >> 3)
543
544#define GRP_3A 0x6
545#define RT_PLUS_AID 0x4bd7
546
547/*ERT*/
548#define ERT_AID 0x6552
549#define CARRIAGE_RETURN 0x000D
550#define MAX_ERT_SEGMENT 31
551#define ERT_FORMAT_DIR_BIT 1
552
553#define EXTRACT_BIT(data, bit_pos) ((data & (1 << bit_pos)) >> bit_pos)
554
555struct hci_ev_tune_status {
556 char sub_event;
557 int station_freq;
558 char serv_avble;
559 char rssi;
560 char stereo_prg;
561 char rds_sync_status;
562 char mute_mode;
563 char sinr;
564 char intf_det_th;
565} ;
566
567struct rds_blk_data {
568 char rdsMsb;
569 char rdsLsb;
570 char blockStatus;
571} ;
572
573struct rds_grp_data {
574 struct rds_blk_data rdsBlk[4];
575} ;
576
577struct hci_ev_rds_rx_data {
578 char num_rds_grps;
579 struct rds_grp_data rds_grp_data[MAX_RAW_RDS_GRPS];
580} ;
581
582struct hci_ev_prg_service {
583 short pi_prg_id;
584 char pty_prg_type;
585 char ta_prg_code_type;
586 char ta_ann_code_flag;
587 char ms_switch_code_flag;
588 char dec_id_ctrl_code_flag;
589 char ps_num;
590 char prg_service_name[119];
591} ;
592
593struct hci_ev_radio_text {
594 short pi_prg_id;
595 char pty_prg_type;
596 char ta_prg_code_type;
597 char txt_ab_flag;
598 char radio_txt[64];
599} ;
600
601struct hci_ev_af_list {
602 int tune_freq;
603 short pi_code;
604 char af_size;
605 char af_list[FM_AF_LIST_MAX_SIZE];
606} ;
607
608struct hci_ev_cmd_complete {
609 char num_hci_cmd_pkts;
610 short cmd_opcode;
611} ;
612
613struct hci_ev_cmd_status {
614 char status;
615 char num_hci_cmd_pkts;
616 short status_opcode;
617} ;
618
619struct hci_ev_srch_st {
620 int station_freq;
621 char rds_cap;
622 char pty;
623 short status_opcode;
624} ;
625
626struct hci_ev_rel_freq {
627 char rel_freq_msb;
628 char rel_freq_lsb;
629
630} ;
631struct hci_ev_srch_list_compl {
632 char num_stations_found;
633 struct hci_ev_rel_freq rel_freq[20];
634} ;
635
636/* ----- HCI Event Response ----- */
637struct hci_fm_conf_rsp {
638 char status;
639 struct hci_fm_recv_conf_req recv_conf_rsp;
640} ;
641
Satish kumar sugasi84e51de2015-09-30 18:27:43 -0700642struct hci_fm_rds_grp_cntrs_rsp {
643 char status;
644 struct hci_fm_rds_grp_cntrs_params recv_rds_grp_cntrs_rsp;
645} ;
646
647
Satish kumar sugasi644b4882016-05-04 20:15:31 -0700648struct hci_fm_get_trans_conf_rsp {
649 char status;
650 struct hci_fm_trans_conf_req_struct trans_conf_rsp;
651} ;
652struct hci_fm_sig_threshold_rsp {
653 char status;
654 char sig_threshold;
655} ;
656
657struct hci_fm_station_rsp {
658 struct hci_ev_tune_status station_rsp;
659} ;
660
661struct hci_fm_prgm_srv_rsp {
662 char status;
663 struct hci_ev_prg_service prg_srv;
664} ;
665
666struct hci_fm_radio_txt_rsp {
667 char status;
668 struct hci_ev_radio_text rd_txt;
669} ;
670
671struct hci_fm_af_list_rsp {
672 char status;
673 struct hci_ev_af_list rd_txt;
674} ;
675
676struct hci_fm_data_rd_rsp {
677 char status;
678 char ret_data_len;
679 char data[DEFAULT_DATA_SIZE];
680} ;
681
682struct hci_fm_feature_list_rsp {
683 char status;
684 char feature_mask;
685} ;
686
687struct hci_fm_dbg_param_rsp {
688 char status;
689 char blend;
690 char soft_mute;
691 char inf_blend;
692 char inf_soft_mute;
693 char pilot_pil;
694 char io_verc;
695 char in_det_out;
696} ;
697
698#define CLKSPURID_INDEX0 0
699#define CLKSPURID_INDEX1 5
700#define CLKSPURID_INDEX2 10
701#define CLKSPURID_INDEX3 15
702#define CLKSPURID_INDEX4 20
703#define CLKSPURID_INDEX5 25
704
705#define MAX_SPUR_FREQ_LIMIT 30
706#define CKK_SPUR 0x3B
707#define SPUR_DATA_SIZE 0x4
708#define SPUR_ENTRIES_PER_ID 0x5
709
710#define COMPUTE_SPUR(val) ((((val) - (76000)) / (50)))
711#define GET_FREQ(val, bit) ((bit == 1) ? ((val) >> 8) : ((val) & 0xFF))
712#define GET_SPUR_ENTRY_LEVEL(val) ((val) / (5))
713
714struct hci_fm_spur_data {
715 int freq[MAX_SPUR_FREQ_LIMIT];
716 char rmssi[MAX_SPUR_FREQ_LIMIT];
717 char enable[MAX_SPUR_FREQ_LIMIT];
718} ;
719
720
721/* HCI dev events */
722#define RADIO_HCI_DEV_REG 1
723#define RADIO_HCI_DEV_WRITE 2
724
725#define hci_req_lock(d) mutex_lock(&d->req_lock)
726#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
727
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
818#define SRCH_ON 0x80
819
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 */
829#define RDS_ON 0x01
830#define RDS_BUF_SZ 100
831
832/* constants */
833#define RDS_BLOCKS_NUM (4)
834#define BYTES_PER_BLOCK (3)
835#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 */
855#define CTRL_ON (1)
856#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 */
879#define INVALID_CHANNEL (0)
880#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);
916int hci_fm_do_calibration(char *arg, struct radio_hci_dev *hdev);
917
918static inline int is_valid_tone(int tone)
919{
920 if ((tone >= MIN_TX_TONE_VAL) &&
921 (tone <= MAX_TX_TONE_VAL))
922 return 1;
923 else
924 return 0;
925}
926
927static inline int is_valid_hard_mute(int hard_mute)
928{
929 if ((hard_mute >= MIN_HARD_MUTE_VAL) &&
930 (hard_mute <= MAX_HARD_MUTE_VAL))
931 return 1;
932 else
933 return 0;
934}
935
936static inline int is_valid_srch_mode(int srch_mode)
937{
938 if ((srch_mode >= MIN_SRCH_MODE) &&
939 (srch_mode <= MAX_SRCH_MODE))
940 return 1;
941 else
942 return 0;
943}
944
945static inline int is_valid_scan_dwell_prd(int scan_dwell_prd)
946{
947 if ((scan_dwell_prd >= MIN_SCAN_DWELL) &&
948 (scan_dwell_prd <= MAX_SCAN_DWELL))
949 return 1;
950 else
951 return 0;
952}
953
954static inline int is_valid_sig_th(int sig_th)
955{
956 if ((sig_th >= MIN_SIG_TH) &&
957 (sig_th <= MAX_SIG_TH))
958 return 1;
959 else
960 return 0;
961}
962
963static inline int is_valid_pty(int pty)
964{
965 if ((pty >= MIN_PTY) &&
966 (pty <= MAX_PTY))
967 return 1;
968 else
969 return 0;
970}
971
972static inline int is_valid_pi(int pi)
973{
974 if ((pi >= MIN_PI) &&
975 (pi <= MAX_PI))
976 return 1;
977 else
978 return 0;
979}
980
981static inline int is_valid_srch_station_cnt(int cnt)
982{
983 if ((cnt >= MIN_SRCH_STATIONS_CNT) &&
984 (cnt <= MAX_SRCH_STATIONS_CNT))
985 return 1;
986 else
987 return 0;
988}
989
990static inline int is_valid_chan_spacing(int spacing)
991{
992 if ((spacing >= MIN_CHAN_SPACING) &&
993 (spacing <= MAX_CHAN_SPACING))
994 return 1;
995 else
996 return 0;
997}
998
999static inline int is_valid_emphasis(int emphasis)
1000{
1001 if ((emphasis >= MIN_EMPHASIS) &&
1002 (emphasis <= MAX_EMPHASIS))
1003 return 1;
1004 else
1005 return 0;
1006}
1007
1008static inline int is_valid_rds_std(int rds_std)
1009{
1010 if ((rds_std >= MIN_RDS_STD) &&
1011 (rds_std <= MAX_RDS_STD))
1012 return 1;
1013 else
1014 return 0;
1015}
1016
1017static inline int is_valid_antenna(int antenna_type)
1018{
1019 if ((antenna_type >= MIN_ANTENNA_VAL) &&
1020 (antenna_type <= MAX_ANTENNA_VAL))
1021 return 1;
1022 else
1023 return 0;
1024}
1025
1026static inline int is_valid_ps_repeat_cnt(int cnt)
1027{
1028 if ((cnt >= MIN_TX_PS_REPEAT_CNT) &&
1029 (cnt <= MAX_TX_PS_REPEAT_CNT))
1030 return 1;
1031 else
1032 return 0;
1033}
1034
1035static inline int is_valid_soft_mute(int soft_mute)
1036{
1037 if ((soft_mute >= MIN_SOFT_MUTE) &&
1038 (soft_mute <= MAX_SOFT_MUTE))
1039 return 1;
1040 else
1041 return 0;
1042}
1043
1044static inline int is_valid_peek_len(int len)
1045{
1046 if ((len >= MIN_PEEK_ACCESS_LEN) &&
1047 (len <= MAX_PEEK_ACCESS_LEN))
1048 return 1;
1049 else
1050 return 0;
1051}
1052
1053static inline int is_valid_reset_cntr(int cntr)
1054{
1055 if ((cntr >= MIN_RESET_CNTR) &&
1056 (cntr <= MAX_RESET_CNTR))
1057 return 1;
1058 else
1059 return 0;
1060}
1061
1062static inline int is_valid_hlsi(int hlsi)
1063{
1064 if ((hlsi >= MIN_HLSI) &&
1065 (hlsi <= MAX_HLSI))
1066 return 1;
1067 else
1068 return 0;
1069}
1070
1071static inline int is_valid_notch_filter(int filter)
1072{
1073 if ((filter >= MIN_NOTCH_FILTER) &&
1074 (filter <= MAX_NOTCH_FILTER))
1075 return 1;
1076 else
1077 return 0;
1078}
1079
1080static inline int is_valid_intf_det_low_th(int th)
1081{
1082 if ((th >= MIN_INTF_DET_OUT_LW_TH) &&
1083 (th <= MAX_INTF_DET_OUT_LW_TH))
1084 return 1;
1085 else
1086 return 0;
1087}
1088
1089static inline int is_valid_intf_det_hgh_th(int th)
1090{
1091 if ((th >= MIN_INTF_DET_OUT_HG_TH) &&
1092 (th <= MAX_INTF_DET_OUT_HG_TH))
1093 return 1;
1094 else
1095 return 0;
1096}
1097
1098static inline int is_valid_sinr_th(int th)
1099{
1100 if ((th >= MIN_SINR_TH) &&
1101 (th <= MAX_SINR_TH))
1102 return 1;
1103 else
1104 return 0;
1105}
1106
1107static inline int is_valid_sinr_samples(int samples_cnt)
1108{
1109 if ((samples_cnt >= MIN_SINR_SAMPLES) &&
1110 (samples_cnt <= MAX_SINR_SAMPLES))
1111 return 1;
1112 else
1113 return 0;
1114}
1115
1116static inline int is_valid_fm_state(int state)
1117{
1118 if ((state >= 0) && (state < FM_MAX_NO_STATES))
1119 return 1;
1120 else
1121 return 0;
1122}
1123
1124static inline int is_valid_blend_value(int val)
1125{
1126 if ((val >= MIN_BLEND_HI) && (val <= MAX_BLEND_HI))
1127 return 1;
1128 else
1129 return 0;
1130}
1131
1132struct helium_device {
1133 int tune_req;
1134 unsigned int mode;
1135 short pi;
1136 char pty;
1137 char ps_repeatcount;
1138 char prev_trans_rds;
1139 char af_jump_bit;
1140 struct hci_fm_mute_mode_req mute_mode;
1141 struct hci_fm_stereo_mode_req stereo_mode;
1142 struct hci_fm_station_rsp fm_st_rsp;
1143 struct hci_fm_search_station_req srch_st;
1144 struct hci_fm_search_rds_station_req srch_rds;
1145 struct hci_fm_search_station_list_req srch_st_list;
1146 struct hci_fm_recv_conf_req recv_conf;
1147 struct hci_fm_trans_conf_req_struct trans_conf;
1148 struct hci_fm_rds_grp_req rds_grp;
1149 unsigned char g_search_mode;
1150 unsigned char power_mode;
1151 int search_on;
1152 unsigned char spur_table_size;
1153 unsigned char g_scan_time;
1154 unsigned int g_antenna;
1155 unsigned int g_rds_grp_proc_ps;
1156 unsigned char event_mask;
1157 enum hlm_region_t region;
1158 struct hci_fm_dbg_param_rsp st_dbg_param;
1159 struct hci_ev_srch_list_compl srch_st_result;
1160};
1161#endif /* __UAPI_RADIO_HCI_CORE_H */