blob: ba705bd6c5f1c2cb9daeeedc74a9923151473f5e [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 *
Srinivasa Rao Uppalaacdebcc2011-12-23 14:31:38 +05303 * Copyright (c) 2011-2012 Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004 *
5 * This file is based on include/net/bluetooth/hci_core.h
6 *
7 * Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation;
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
16 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
17 * CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 *
22 * ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
23 * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
24 * SOFTWARE IS DISCLAIMED.
25 */
26
27#ifndef __RADIO_HCI_CORE_H
28#define __RADIO_HCI_CORE_H
29
30#include <linux/skbuff.h>
31#include <linux/interrupt.h>
32#include <linux/mutex.h>
33#include <linux/atomic.h>
34
35/* ---- HCI Packet structures ---- */
36#define RADIO_HCI_COMMAND_HDR_SIZE sizeof(struct radio_hci_command_hdr)
37#define RADIO_HCI_EVENT_HDR_SIZE sizeof(struct radio_hci_event_hdr)
38
39/* HCI data types */
40#define RADIO_HCI_COMMAND_PKT 0x11
41#define RADIO_HCI_EVENT_PKT 0x14
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -070042/*HCI reponce packets*/
43#define MAX_RIVA_PEEK_RSP_SIZE 251
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +053044/* default data access */
45#define DEFAULT_DATA_OFFSET 2
46#define DEFAULT_DATA_SIZE 249
Venkateshwarlu Domakonda71731d52012-04-04 12:30:51 +053047/* Power levels are 0-7, but SOC will expect values from 0-255
48 * So the each level step size will be 255/7 = 36 */
49#define FM_TX_PWR_LVL_STEP_SIZE 36
50#define FM_TX_PWR_LVL_0 0 /* Lowest power lvl that can be set for Tx */
51#define FM_TX_PWR_LVL_MAX 7 /* Max power lvl for Tx */
52#define FM_TX_PHY_CFG_MODE 0x3c
53#define FM_TX_PHY_CFG_LEN 0x10
54#define FM_TX_PWR_GAIN_OFFSET 14
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055/* HCI timeouts */
56#define RADIO_HCI_TIMEOUT (10000) /* 10 seconds */
57
58#define TUNE_PARAM 16
59struct radio_hci_command_hdr {
60 __le16 opcode; /* OCF & OGF */
61 __u8 plen;
62} __packed;
63
64struct radio_hci_event_hdr {
65 __u8 evt;
66 __u8 plen;
67} __packed;
68
69struct radio_hci_dev {
70 char name[8];
71 unsigned long flags;
72 __u16 id;
73 __u8 bus;
74 __u8 dev_type;
75 __u8 dev_name[248];
76 __u8 dev_class[3];
77 __u8 features[8];
78 __u8 commands[64];
79
80 unsigned int data_block_len;
81 unsigned long cmd_last_tx;
82
83 struct sk_buff *sent_cmd;
84
85 __u32 req_status;
86 __u32 req_result;
87 atomic_t cmd_cnt;
88
89 struct tasklet_struct cmd_task;
90 struct tasklet_struct rx_task;
91 struct tasklet_struct tx_task;
92
93 struct sk_buff_head rx_q;
94 struct sk_buff_head raw_q;
95 struct sk_buff_head cmd_q;
96
97 struct mutex req_lock;
98 wait_queue_head_t req_wait_q;
99
100 int (*open)(struct radio_hci_dev *hdev);
101 int (*close)(struct radio_hci_dev *hdev);
102 int (*flush)(struct radio_hci_dev *hdev);
103 int (*send)(struct sk_buff *skb);
104 void (*destruct)(struct radio_hci_dev *hdev);
105 void (*notify)(struct radio_hci_dev *hdev, unsigned int evt);
106};
107
108int radio_hci_register_dev(struct radio_hci_dev *hdev);
109int radio_hci_unregister_dev(struct radio_hci_dev *hdev);
110int radio_hci_recv_frame(struct sk_buff *skb);
111int radio_hci_send_cmd(struct radio_hci_dev *hdev, __u16 opcode, __u32 plen,
112 void *param);
113void radio_hci_event_packet(struct radio_hci_dev *hdev, struct sk_buff *skb);
114
115/* Opcode OCF */
116/* HCI recv control commands opcode */
117#define HCI_OCF_FM_ENABLE_RECV_REQ 0x0001
118#define HCI_OCF_FM_DISABLE_RECV_REQ 0x0002
119#define HCI_OCF_FM_GET_RECV_CONF_REQ 0x0003
120#define HCI_OCF_FM_SET_RECV_CONF_REQ 0x0004
121#define HCI_OCF_FM_SET_MUTE_MODE_REQ 0x0005
122#define HCI_OCF_FM_SET_STEREO_MODE_REQ 0x0006
123#define HCI_OCF_FM_SET_ANTENNA 0x0007
124#define HCI_OCF_FM_SET_SIGNAL_THRESHOLD 0x0008
125#define HCI_OCF_FM_GET_SIGNAL_THRESHOLD 0x0009
126#define HCI_OCF_FM_GET_STATION_PARAM_REQ 0x000A
127#define HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ 0x000B
128#define HCI_OCF_FM_GET_RADIO_TEXT_REQ 0x000C
129#define HCI_OCF_FM_GET_AF_LIST_REQ 0x000D
130#define HCI_OCF_FM_SEARCH_STATIONS 0x000E
131#define HCI_OCF_FM_SEARCH_RDS_STATIONS 0x000F
132#define HCI_OCF_FM_SEARCH_STATIONS_LIST 0x0010
133#define HCI_OCF_FM_CANCEL_SEARCH 0x0011
134#define HCI_OCF_FM_RDS_GRP 0x0012
135#define HCI_OCF_FM_RDS_GRP_PROCESS 0x0013
136#define HCI_OCF_FM_EN_WAN_AVD_CTRL 0x0014
137#define HCI_OCF_FM_EN_NOTCH_CTRL 0x0015
Srinivasa Rao Uppalaf856ae62011-10-17 18:43:26 +0530138#define HCI_OCF_FM_SET_EVENT_MASK 0x0016
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530139#define HCI_OCF_FM_SET_CH_DET_THRESHOLD 0x0017
140#define HCI_OCF_FM_GET_CH_DET_THRESHOLD 0x0018
Ankur Nandwanid928d542011-08-11 13:15:41 -0700141/* HCI trans control commans opcode*/
142#define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001
143#define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002
144#define HCI_OCF_FM_GET_TRANS_CONF_REQ 0x0003
145#define HCI_OCF_FM_SET_TRANS_CONF_REQ 0x0004
146#define HCI_OCF_FM_RDS_RT_REQ 0x0008
147#define HCI_OCF_FM_RDS_PS_REQ 0x0009
148
149
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150/* HCI common control commands opcode */
151#define HCI_OCF_FM_TUNE_STATION_REQ 0x0001
152#define HCI_OCF_FM_DEFAULT_DATA_READ 0x0002
153#define HCI_OCF_FM_DEFAULT_DATA_WRITE 0x0003
154#define HCI_OCF_FM_RESET 0x0004
155#define HCI_OCF_FM_GET_FEATURE_LIST 0x0005
156#define HCI_OCF_FM_DO_CALIBRATION 0x0006
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530157#define HCI_OCF_FM_SET_CALIBRATION 0x0007
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158
159/*HCI Status parameters commands*/
160#define HCI_OCF_FM_READ_GRP_COUNTERS 0x0001
161
162/*HCI Diagnostic commands*/
163#define HCI_OCF_FM_PEEK_DATA 0x0002
164#define HCI_OCF_FM_POKE_DATA 0x0003
165#define HCI_OCF_FM_SSBI_PEEK_REG 0x0004
166#define HCI_OCF_FM_SSBI_POKE_REG 0x0005
167#define HCI_OCF_FM_STATION_DBG_PARAM 0x0007
Ankur Nandwanid928d542011-08-11 13:15:41 -0700168#define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700169
170/* Opcode OGF */
171#define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013
Ankur Nandwanid928d542011-08-11 13:15:41 -0700172#define HCI_OGF_FM_TRANS_CTRL_CMD_REQ 0x0014
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700173#define HCI_OGF_FM_COMMON_CTRL_CMD_REQ 0x0015
174#define HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ 0x0016
175#define HCI_OGF_FM_TEST_CMD_REQ 0x0017
176#define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F
177
178/* Command opcode pack/unpack */
179#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
180#define hci_opcode_ogf(op) (op >> 10)
181#define hci_opcode_ocf(op) (op & 0x03ff)
182#define hci_recv_ctrl_cmd_op_pack(ocf) \
183 (__u16) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf)
Ankur Nandwanid928d542011-08-11 13:15:41 -0700184#define hci_trans_ctrl_cmd_op_pack(ocf) \
185 (__u16) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700186#define hci_common_cmd_op_pack(ocf) \
187 (__u16) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf)
188#define hci_status_param_op_pack(ocf) \
189 (__u16) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf)
190#define hci_diagnostic_cmd_op_pack(ocf) \
191 (__u16) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf)
192
193
194/* HCI commands with no arguments*/
195#define HCI_FM_ENABLE_RECV_CMD 1
196#define HCI_FM_DISABLE_RECV_CMD 2
197#define HCI_FM_GET_RECV_CONF_CMD 3
198#define HCI_FM_GET_STATION_PARAM_CMD 4
199#define HCI_FM_GET_SIGNAL_TH_CMD 5
200#define HCI_FM_GET_PROGRAM_SERVICE_CMD 6
201#define HCI_FM_GET_RADIO_TEXT_CMD 7
202#define HCI_FM_GET_AF_LIST_CMD 8
203#define HCI_FM_CANCEL_SEARCH_CMD 9
204#define HCI_FM_RESET_CMD 10
205#define HCI_FM_GET_FEATURES_CMD 11
206#define HCI_FM_STATION_DBG_PARAM_CMD 12
Ankur Nandwanid928d542011-08-11 13:15:41 -0700207#define HCI_FM_ENABLE_TRANS_CMD 13
208#define HCI_FM_DISABLE_TRANS_CMD 14
Srinivasa Rao Uppalac5320c22011-11-28 14:28:51 +0530209#define HCI_FM_GET_TX_CONFIG 15
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530210#define HCI_FM_GET_DET_CH_TH_CMD 16
Ankur Nandwanid928d542011-08-11 13:15:41 -0700211
212/* Defines for FM TX*/
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530213#define TX_PS_DATA_LENGTH 108
Ankur Nandwanid928d542011-08-11 13:15:41 -0700214#define TX_RT_DATA_LENGTH 64
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530215#define PS_STRING_LEN 9
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700216
217/* ----- HCI Command request ----- */
218struct hci_fm_recv_conf_req {
219 __u8 emphasis;
220 __u8 ch_spacing;
221 __u8 rds_std;
222 __u8 hlsi;
223 __u32 band_low_limit;
224 __u32 band_high_limit;
225} __packed;
226
Ankur Nandwanid928d542011-08-11 13:15:41 -0700227/* ----- HCI Command request ----- */
228struct hci_fm_trans_conf_req_struct {
229 __u8 emphasis;
230 __u8 rds_std;
231 __u32 band_low_limit;
232 __u32 band_high_limit;
233} __packed;
234
235
236/* ----- HCI Command request ----- */
237struct hci_fm_tx_ps {
238 __u8 ps_control;
239 __u16 pi;
240 __u8 pty;
241 __u8 ps_repeatcount;
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530242 __u8 ps_num;
Ankur Nandwanid928d542011-08-11 13:15:41 -0700243 __u8 ps_data[TX_PS_DATA_LENGTH];
244} __packed;
245
246struct hci_fm_tx_rt {
247 __u8 rt_control;
248 __u16 pi;
249 __u8 pty;
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530250 __u8 rt_len;
Ankur Nandwanid928d542011-08-11 13:15:41 -0700251 __u8 rt_data[TX_RT_DATA_LENGTH];
252} __packed;
253
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700254struct hci_fm_mute_mode_req {
255 __u8 hard_mute;
256 __u8 soft_mute;
257} __packed;
258
259struct hci_fm_stereo_mode_req {
260 __u8 stereo_mode;
261 __u8 sig_blend;
262 __u8 intf_blend;
263 __u8 most_switch;
264} __packed;
265
266struct hci_fm_search_station_req {
267 __u8 srch_mode;
268 __u8 scan_time;
269 __u8 srch_dir;
270} __packed;
271
272struct hci_fm_search_rds_station_req {
273 struct hci_fm_search_station_req srch_station;
274 __u8 srch_pty;
275 __u16 srch_pi;
276} __packed;
277
278struct hci_fm_search_station_list_req {
279 __u8 srch_list_mode;
280 __u8 srch_list_dir;
281 __u32 srch_list_max;
282 __u8 srch_pty;
283} __packed;
284
285struct hci_fm_rds_grp_req {
286 __u32 rds_grp_enable_mask;
287 __u32 rds_buf_size;
288 __u8 en_rds_change_filter;
289} __packed;
290
291struct hci_fm_en_avd_ctrl_req {
292 __u8 no_freqs;
293 __u8 freq_index;
294 __u8 lo_shft;
295 __u16 freq_min;
296 __u16 freq_max;
297} __packed;
298
299struct hci_fm_def_data_rd_req {
300 __u8 mode;
301 __u8 length;
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530302 __u8 param_len;
303 __u8 param;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700304} __packed;
305
306struct hci_fm_def_data_wr_req {
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530307 __u8 mode;
308 __u8 length;
309 __u8 data[DEFAULT_DATA_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310} __packed;
311
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700312struct hci_fm_riva_data {
313 __u8 subopcode;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700314 __u32 start_addr;
315 __u8 length;
316} __packed;
317
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700318struct hci_fm_riva_poke {
319 struct hci_fm_riva_data cmd_params;
320 __u8 data[MAX_RIVA_PEEK_RSP_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700321} __packed;
322
323struct hci_fm_ssbi_req {
324 __u16 start_addr;
325 __u8 data;
326} __packed;
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700327struct hci_fm_ssbi_peek {
328 __u16 start_address;
329} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530331struct hci_fm_ch_det_threshold {
332 char sinr;
333 __u8 sinr_samples;
334 __u8 low_th;
335 __u8 high_th;
336
337} __packed;
338
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700339/*HCI events*/
340#define HCI_EV_TUNE_STATUS 0x01
341#define HCI_EV_RDS_LOCK_STATUS 0x02
342#define HCI_EV_STEREO_STATUS 0x03
343#define HCI_EV_SERVICE_AVAILABLE 0x04
344#define HCI_EV_SEARCH_PROGRESS 0x05
345#define HCI_EV_SEARCH_RDS_PROGRESS 0x06
346#define HCI_EV_SEARCH_LIST_PROGRESS 0x07
347#define HCI_EV_RDS_RX_DATA 0x08
348#define HCI_EV_PROGRAM_SERVICE 0x09
349#define HCI_EV_RADIO_TEXT 0x0A
350#define HCI_EV_FM_AF_LIST 0x0B
351#define HCI_EV_TX_RDS_GRP_AVBLE 0x0C
352#define HCI_EV_TX_RDS_GRP_COMPL 0x0D
353#define HCI_EV_TX_RDS_CONT_GRP_COMPL 0x0E
354#define HCI_EV_CMD_COMPLETE 0x0F
355#define HCI_EV_CMD_STATUS 0x10
356#define HCI_EV_TUNE_COMPLETE 0x11
357#define HCI_EV_SEARCH_COMPLETE 0x12
358#define HCI_EV_SEARCH_RDS_COMPLETE 0x13
359#define HCI_EV_SEARCH_LIST_COMPLETE 0x14
360
361#define HCI_REQ_DONE 0
362#define HCI_REQ_PEND 1
363#define HCI_REQ_CANCELED 2
364#define HCI_REQ_STATUS 3
365
366struct hci_ev_tune_status {
367 __u8 sub_event;
368 __le32 station_freq;
369 __u8 serv_avble;
370 __u8 rssi;
371 __u8 stereo_prg;
372 __u8 rds_sync_status;
373 __u8 mute_mode;
Srinivasa Rao Uppalaacdebcc2011-12-23 14:31:38 +0530374 char sinr;
375 __u8 intf_det_th;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700376} __packed;
377
378struct hci_ev_rds_rx_data {
379 __u8 num_rds_grps;
380 __u8 rds_grp_data[12];
381} __packed;
382
383struct hci_ev_prg_service {
384 __le16 pi_prg_id;
385 __u8 pty_prg_type;
386 __u8 ta_prg_code_type;
387 __u8 ta_ann_code_flag;
388 __u8 ms_switch_code_flag;
389 __u8 dec_id_ctrl_code_flag;
390 __u8 ps_num;
391 __u8 prg_service_name[119];
392} __packed;
393
394struct hci_ev_radio_text {
395 __le16 pi_prg_id;
396 __u8 pty_prg_type;
397 __u8 ta_prg_code_type;
398 __u8 txt_ab_flag;
399 __u8 radio_txt[64];
400} __packed;
401
402struct hci_ev_af_list {
403 __le32 tune_freq;
404 __le16 pi_code;
405 __u8 af_size;
406 __u8 af_list[25];
407} __packed;
408
409struct hci_ev_cmd_complete {
410 __u8 num_hci_cmd_pkts;
411 __le16 cmd_opcode;
412} __packed;
413
414struct hci_ev_cmd_status {
415 __u8 status;
416 __u8 num_hci_cmd_pkts;
417 __le16 status_opcode;
418} __packed;
419
420struct hci_ev_srch_st {
421 __le32 station_freq;
422 __u8 rds_cap;
423 __u8 pty;
424 __le16 status_opcode;
425} __packed;
426
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700427struct hci_ev_rel_freq {
428 __u8 rel_freq_msb;
429 __u8 rel_freq_lsb;
430
431} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700432struct hci_ev_srch_list_compl {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700433 __u8 num_stations_found;
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700434 struct hci_ev_rel_freq rel_freq[20];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700435} __packed;
436
437/* ----- HCI Event Response ----- */
438struct hci_fm_conf_rsp {
439 __u8 status;
440 struct hci_fm_recv_conf_req recv_conf_rsp;
441} __packed;
442
Srinivasa Rao Uppalac5320c22011-11-28 14:28:51 +0530443struct hci_fm_get_trans_conf_rsp {
444 __u8 status;
445 struct hci_fm_trans_conf_req_struct trans_conf_rsp;
446} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700447struct hci_fm_sig_threshold_rsp {
448 __u8 status;
449 __u8 sig_threshold;
450} __packed;
451
452struct hci_fm_station_rsp {
453 struct hci_ev_tune_status station_rsp;
454} __packed;
455
456struct hci_fm_prgm_srv_rsp {
457 __u8 status;
458 struct hci_ev_prg_service prg_srv;
459} __packed;
460
461struct hci_fm_radio_txt_rsp {
462 __u8 status;
463 struct hci_ev_radio_text rd_txt;
464} __packed;
465
466struct hci_fm_af_list_rsp {
467 __u8 status;
468 struct hci_ev_af_list rd_txt;
469} __packed;
470
471struct hci_fm_data_rd_rsp {
472 __u8 status;
473 __u8 ret_data_len;
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530474 __u8 data[DEFAULT_DATA_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700475} __packed;
476
477struct hci_fm_feature_list_rsp {
478 __u8 status;
479 __u8 feature_mask;
480} __packed;
481
482struct hci_fm_dbg_param_rsp {
483 __u8 status;
484 __u8 blend;
485 __u8 soft_mute;
486 __u8 inf_blend;
487 __u8 inf_soft_mute;
488 __u8 pilot_pil;
489 __u8 io_verc;
490 __u8 in_det_out;
491} __packed;
492
Anantha Krishnanf950e322012-06-06 14:25:49 +0530493#define CLKSPURID_INDEX0 0
494#define CLKSPURID_INDEX1 5
495#define CLKSPURID_INDEX2 10
496#define CLKSPURID_INDEX3 15
497#define CLKSPURID_INDEX4 20
498#define CLKSPURID_INDEX5 25
499
500#define MAX_SPUR_FREQ_LIMIT 30
501#define CKK_SPUR 0x3B
502#define SPUR_DATA_SIZE 0x4
503#define SPUR_ENTRIES_PER_ID 0x5
504
505#define COMPUTE_SPUR(val) ((((val) - (76000)) / (50)))
506#define GET_FREQ(val, bit) ((bit == 1) ? ((val) >> 8) : ((val) & 0xFF))
507#define GET_SPUR_ENTRY_LEVEL(val) ((val) / (5))
508
509struct hci_fm_spur_data {
510 __u32 freq[MAX_SPUR_FREQ_LIMIT];
511 __s8 rmssi[MAX_SPUR_FREQ_LIMIT];
512 __u8 enable[MAX_SPUR_FREQ_LIMIT];
513} __packed;
514
515
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700516/* HCI dev events */
517#define RADIO_HCI_DEV_REG 1
518#define RADIO_HCI_DEV_WRITE 2
519
520#define hci_req_lock(d) mutex_lock(&d->req_lock)
521#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
522
Ankur Nandwani78a782b2011-07-07 21:11:21 -0700523/* FM RDS */
Ankur Nandwani42462512011-07-15 17:08:24 -0700524#define RDS_PTYPE 2
525#define RDS_PID_LOWER 1
526#define RDS_PID_HIGHER 0
Ankur Nandwani78a782b2011-07-07 21:11:21 -0700527#define RDS_OFFSET 5
528#define RDS_PS_LENGTH_OFFSET 7
529#define RDS_STRING 8
530#define RDS_PS_DATA_OFFSET 8
Srinivasa Rao Uppala58273f82011-08-10 19:07:45 -0700531#define RDS_CONFIG_OFFSET 3
Srinivasa Rao Uppala3c7a8eb2011-09-18 09:10:21 +0530532#define RDS_AF_JUMP_OFFSET 4
533#define PI_CODE_OFFSET 4
534#define AF_SIZE_OFFSET 6
535#define AF_LIST_OFFSET 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700536/*FM states*/
537
538enum radio_state_t {
539 FM_OFF,
540 FM_RECV,
541 FM_TRANS,
542 FM_RESET,
Ayaz Ahmadc1e6a952012-05-15 19:29:54 +0530543 FM_CALIB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700544};
545
546enum v4l2_cid_private_iris_t {
547 V4L2_CID_PRIVATE_IRIS_SRCHMODE = (0x08000000 + 1),
548 V4L2_CID_PRIVATE_IRIS_SCANDWELL,
549 V4L2_CID_PRIVATE_IRIS_SRCHON,
550 V4L2_CID_PRIVATE_IRIS_STATE,
551 V4L2_CID_PRIVATE_IRIS_TRANSMIT_MODE,
552 V4L2_CID_PRIVATE_IRIS_RDSGROUP_MASK,
553 V4L2_CID_PRIVATE_IRIS_REGION,
554 V4L2_CID_PRIVATE_IRIS_SIGNAL_TH,
555 V4L2_CID_PRIVATE_IRIS_SRCH_PTY,
556 V4L2_CID_PRIVATE_IRIS_SRCH_PI,
557 V4L2_CID_PRIVATE_IRIS_SRCH_CNT,
558 V4L2_CID_PRIVATE_IRIS_EMPHASIS,
559 V4L2_CID_PRIVATE_IRIS_RDS_STD,
560 V4L2_CID_PRIVATE_IRIS_SPACING,
561 V4L2_CID_PRIVATE_IRIS_RDSON,
562 V4L2_CID_PRIVATE_IRIS_RDSGROUP_PROC,
563 V4L2_CID_PRIVATE_IRIS_LP_MODE,
564 V4L2_CID_PRIVATE_IRIS_ANTENNA,
565 V4L2_CID_PRIVATE_IRIS_RDSD_BUF,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530566 V4L2_CID_PRIVATE_IRIS_PSALL, /*0x8000014*/
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700567
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700568 /*v4l2 Tx controls*/
569 V4L2_CID_PRIVATE_IRIS_TX_SETPSREPEATCOUNT,
570 V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_PS_NAME,
571 V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_RT,
572 V4L2_CID_PRIVATE_IRIS_IOVERC,
573 V4L2_CID_PRIVATE_IRIS_INTDET,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530574 V4L2_CID_PRIVATE_IRIS_MPX_DCC,
575 V4L2_CID_PRIVATE_IRIS_AF_JUMP,
576 V4L2_CID_PRIVATE_IRIS_RSSI_DELTA,
577 V4L2_CID_PRIVATE_IRIS_HLSI, /*0x800001d*/
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700578
579 /*Diagnostic commands*/
580 V4L2_CID_PRIVATE_IRIS_SOFT_MUTE,
581 V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR,
582 V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN,
583 V4L2_CID_PRIVATE_IRIS_RIVA_PEEK,
584 V4L2_CID_PRIVATE_IRIS_RIVA_POKE,
585 V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR,
586 V4L2_CID_PRIVATE_IRIS_SSBI_PEEK,
587 V4L2_CID_PRIVATE_IRIS_SSBI_POKE,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530588 V4L2_CID_PRIVATE_IRIS_TX_TONE,
589 V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS,
Anantha Krishnan61dc15e2011-12-06 11:39:02 +0530590 V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER, /* 0x8000028 */
591 V4L2_CID_PRIVATE_IRIS_SET_AUDIO_PATH, /* TAVARUA specific command */
592 V4L2_CID_PRIVATE_IRIS_DO_CALIBRATION,
593 V4L2_CID_PRIVATE_IRIS_SRCH_ALGORITHM, /* TAVARUA specific command */
Srinivasa Rao Uppalaacdebcc2011-12-23 14:31:38 +0530594 V4L2_CID_PRIVATE_IRIS_GET_SINR,
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530595 V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD,
596 V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD,
597 V4L2_CID_PRIVATE_SINR_THRESHOLD,
598 V4L2_CID_PRIVATE_SINR_SAMPLES,
Anantha Krishnanf950e322012-06-06 14:25:49 +0530599 V4L2_CID_PRIVATE_SPUR_FREQ,
600 V4L2_CID_PRIVATE_SPUR_FREQ_RMSSI,
601 V4L2_CID_PRIVATE_SPUR_SELECTION,
602 V4L2_CID_PRIVATE_UPDATE_SPUR_TABLE,
Ayaz Ahmad37294ba2012-07-10 16:38:11 +0530603 V4L2_CID_PRIVATE_VALID_CHANNEL,
Anantha Krishnan61dc15e2011-12-06 11:39:02 +0530604
605 /*using private CIDs under userclass*/
606 V4L2_CID_PRIVATE_IRIS_READ_DEFAULT = 0x00980928,
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530607 V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT,
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530608 V4L2_CID_PRIVATE_IRIS_SET_CALIBRATION,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700609};
610
Ankur Nandwanid928d542011-08-11 13:15:41 -0700611
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700612enum iris_evt_t {
613 IRIS_EVT_RADIO_READY,
614 IRIS_EVT_TUNE_SUCC,
615 IRIS_EVT_SEEK_COMPLETE,
616 IRIS_EVT_SCAN_NEXT,
617 IRIS_EVT_NEW_RAW_RDS,
618 IRIS_EVT_NEW_RT_RDS,
619 IRIS_EVT_NEW_PS_RDS,
620 IRIS_EVT_ERROR,
621 IRIS_EVT_BELOW_TH,
622 IRIS_EVT_ABOVE_TH,
623 IRIS_EVT_STEREO,
624 IRIS_EVT_MONO,
625 IRIS_EVT_RDS_AVAIL,
626 IRIS_EVT_RDS_NOT_AVAIL,
627 IRIS_EVT_NEW_SRCH_LIST,
628 IRIS_EVT_NEW_AF_LIST,
629 IRIS_EVT_TXRDSDAT,
Sunny Kapdi0f69eb42012-01-27 18:01:01 -0800630 IRIS_EVT_TXRDSDONE,
631 IRIS_EVT_RADIO_DISABLED
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700632};
Ankur Nandwanid928d542011-08-11 13:15:41 -0700633enum emphasis_type {
634 FM_RX_EMP75 = 0x0,
635 FM_RX_EMP50 = 0x1
636};
637
638enum channel_space_type {
639 FM_RX_SPACE_200KHZ = 0x0,
640 FM_RX_SPACE_100KHZ = 0x1,
641 FM_RX_SPACE_50KHZ = 0x2
642};
643
644enum high_low_injection {
645 AUTO_HI_LO_INJECTION = 0x0,
646 LOW_SIDE_INJECTION = 0x1,
647 HIGH_SIDE_INJECTION = 0x2
648};
649
650enum fm_rds_type {
651 FM_RX_RDBS_SYSTEM = 0x0,
652 FM_RX_RDS_SYSTEM = 0x1
653};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700654
655enum iris_region_t {
656 IRIS_REGION_US,
657 IRIS_REGION_EU,
658 IRIS_REGION_JAPAN,
659 IRIS_REGION_JAPAN_WIDE,
660 IRIS_REGION_OTHER
661};
662
663#define STD_BUF_SIZE (64)
664
665enum iris_buf_t {
666 IRIS_BUF_SRCH_LIST,
667 IRIS_BUF_EVENTS,
668 IRIS_BUF_RT_RDS,
669 IRIS_BUF_PS_RDS,
670 IRIS_BUF_RAW_RDS,
671 IRIS_BUF_AF_LIST,
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700672 IRIS_BUF_PEEK,
673 IRIS_BUF_SSBI_PEEK,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530674 IRIS_BUF_RDS_CNTRS,
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530675 IRIS_BUF_RD_DEFAULT,
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530676 IRIS_BUF_CAL_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700677 IRIS_BUF_MAX
678};
679
680enum iris_xfr_t {
681 IRIS_XFR_SYNC,
682 IRIS_XFR_ERROR,
683 IRIS_XFR_SRCH_LIST,
684 IRIS_XFR_RT_RDS,
685 IRIS_XFR_PS_RDS,
686 IRIS_XFR_AF_LIST,
687 IRIS_XFR_MAX
688};
689
690#undef FMDBG
691#ifdef FM_DEBUG
692#define FMDBG(fmt, args...) pr_info("iris_radio: " fmt, ##args)
693#else
694#define FMDBG(fmt, args...)
695#endif
696
697#undef FMDERR
698#define FMDERR(fmt, args...) pr_err("iris_radio: " fmt, ##args)
699
700/* Search options */
701enum search_t {
702 SEEK,
703 SCAN,
704 SCAN_FOR_STRONG,
705 SCAN_FOR_WEAK,
706 RDS_SEEK_PTY,
707 RDS_SCAN_PTY,
708 RDS_SEEK_PI,
709 RDS_AF_JUMP,
710};
711
Anantha Krishnanf950e322012-06-06 14:25:49 +0530712enum spur_entry_levels {
713 ENTRY_0,
714 ENTRY_1,
715 ENTRY_2,
716 ENTRY_3,
717 ENTRY_4,
718 ENTRY_5,
719};
Ankur Nandwanid928d542011-08-11 13:15:41 -0700720
721/* Band limits */
722#define REGION_US_EU_BAND_LOW 87500
Ayaz Ahmadb69202b2012-02-23 19:24:46 +0530723#define REGION_US_EU_BAND_HIGH 108000
Ankur Nandwanid928d542011-08-11 13:15:41 -0700724#define REGION_JAPAN_STANDARD_BAND_LOW 76000
725#define REGION_JAPAN_STANDARD_BAND_HIGH 90000
726#define REGION_JAPAN_WIDE_BAND_LOW 90000
727#define REGION_JAPAN_WIDE_BAND_HIGH 108000
728
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700729#define SRCH_MODE 0x07
730#define SRCH_DIR 0x08 /* 0-up 1-down */
731#define SCAN_DWELL 0x70
732#define SRCH_ON 0x80
733
734/* I/O Control */
735#define IOC_HRD_MUTE 0x03
736#define IOC_SFT_MUTE 0x01
737#define IOC_MON_STR 0x01
738#define IOC_SIG_BLND 0x01
739#define IOC_INTF_BLND 0x01
740#define IOC_ANTENNA 0x01
741
742/* RDS Control */
743#define RDS_ON 0x01
744#define RDS_BUF_SZ 100
745
Ankur Nandwanid928d542011-08-11 13:15:41 -0700746/* constants */
747#define RDS_BLOCKS_NUM (4)
748#define BYTES_PER_BLOCK (3)
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530749#define MAX_PS_LENGTH (108)
Ankur Nandwanid928d542011-08-11 13:15:41 -0700750#define MAX_RT_LENGTH (64)
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530751#define RDS_GRP_CNTR_LEN (36)
Srinivasa Rao Uppala69839842012-01-13 18:36:12 +0530752#define RX_RT_DATA_LENGTH (63)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700753/* Search direction */
754#define SRCH_DIR_UP (0)
755#define SRCH_DIR_DOWN (1)
756
Srinivasa Rao Uppala7bb22102011-07-14 11:27:30 -0700757/*Search RDS stations*/
758#define SEARCH_RDS_STNS_MODE_OFFSET 4
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700759
760/*Search Station list */
Srinivasa Rao Uppala4b92e4b2011-08-09 15:46:25 -0700761#define PARAMS_PER_STATION 0x08
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700762#define STN_NUM_OFFSET 0x01
763#define STN_FREQ_OFFSET 0x02
764#define KHZ_TO_MHZ 1000
765#define GET_MSB(x)((x >> 8) & 0xFF)
766#define GET_LSB(x)((x) & 0xFF)
767
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700768/* control options */
769#define CTRL_ON (1)
770#define CTRL_OFF (0)
771
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700772/*Diagnostic commands*/
773
774#define RIVA_PEEK_OPCODE 0x0D
775#define RIVA_POKE_OPCODE 0x0C
776
777#define PEEK_DATA_OFSET 0x1
778#define RIVA_PEEK_PARAM 0x6
779#define RIVA_PEEK_LEN_OFSET 0x6
780#define SSBI_PEEK_LEN 0x01
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530781/*Calibration data*/
782#define PROCS_CALIB_MODE 1
783#define PROCS_CALIB_SIZE 23
784#define DC_CALIB_MODE 2
785#define DC_CALIB_SIZE 48
786#define RSB_CALIB_MODE 3
787#define RSB_CALIB_SIZE 4
788#define CALIB_DATA_OFSET 2
789#define CALIB_MODE_OFSET 1
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530790#define MAX_CALIB_SIZE 75
Ayaz Ahmad37294ba2012-07-10 16:38:11 +0530791
792/* Channel validity */
793#define INVALID_CHANNEL (0)
794#define VALID_CHANNEL (1)
795
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530796struct hci_fm_set_cal_req_proc {
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530797 __u8 mode;
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530798 /*Max process calibration data size*/
799 __u8 data[PROCS_CALIB_SIZE];
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530800} __packed;
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530801
802struct hci_fm_set_cal_req_dc {
803 __u8 mode;
804 /*Max DC calibration data size*/
805 __u8 data[DC_CALIB_SIZE];
806} __packed;
807
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530808struct hci_cc_do_calibration_rsp {
809 __u8 status;
810 __u8 mode;
811 __u8 data[MAX_CALIB_SIZE];
812} __packed;
Srinivasa Rao Uppalaf856ae62011-10-17 18:43:26 +0530813
814/* Low Power mode*/
815#define SIG_LEVEL_INTR (1 << 0)
816#define RDS_SYNC_INTR (1 << 1)
817#define AUDIO_CTRL_INTR (1 << 2)
818#define AF_JUMP_ENABLE (1 << 4)
Anantha Krishnanf950e322012-06-06 14:25:49 +0530819
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700820int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
821 struct radio_hci_dev *hdev);
822int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
823 struct radio_hci_dev *hdev);
824int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
825int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700826
827#endif /* __RADIO_HCI_CORE_H */