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