blob: dbdb6515d4f4d0edba58c96d9b27eadf40bace55 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 *
3 * Copyright (c) 2011 Code Aurora Forum. All rights reserved.
4 *
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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047
48/* HCI timeouts */
49#define RADIO_HCI_TIMEOUT (10000) /* 10 seconds */
50
51#define TUNE_PARAM 16
52struct radio_hci_command_hdr {
53 __le16 opcode; /* OCF & OGF */
54 __u8 plen;
55} __packed;
56
57struct radio_hci_event_hdr {
58 __u8 evt;
59 __u8 plen;
60} __packed;
61
62struct radio_hci_dev {
63 char name[8];
64 unsigned long flags;
65 __u16 id;
66 __u8 bus;
67 __u8 dev_type;
68 __u8 dev_name[248];
69 __u8 dev_class[3];
70 __u8 features[8];
71 __u8 commands[64];
72
73 unsigned int data_block_len;
74 unsigned long cmd_last_tx;
75
76 struct sk_buff *sent_cmd;
77
78 __u32 req_status;
79 __u32 req_result;
80 atomic_t cmd_cnt;
81
82 struct tasklet_struct cmd_task;
83 struct tasklet_struct rx_task;
84 struct tasklet_struct tx_task;
85
86 struct sk_buff_head rx_q;
87 struct sk_buff_head raw_q;
88 struct sk_buff_head cmd_q;
89
90 struct mutex req_lock;
91 wait_queue_head_t req_wait_q;
92
93 int (*open)(struct radio_hci_dev *hdev);
94 int (*close)(struct radio_hci_dev *hdev);
95 int (*flush)(struct radio_hci_dev *hdev);
96 int (*send)(struct sk_buff *skb);
97 void (*destruct)(struct radio_hci_dev *hdev);
98 void (*notify)(struct radio_hci_dev *hdev, unsigned int evt);
99};
100
101int radio_hci_register_dev(struct radio_hci_dev *hdev);
102int radio_hci_unregister_dev(struct radio_hci_dev *hdev);
103int radio_hci_recv_frame(struct sk_buff *skb);
104int radio_hci_send_cmd(struct radio_hci_dev *hdev, __u16 opcode, __u32 plen,
105 void *param);
106void radio_hci_event_packet(struct radio_hci_dev *hdev, struct sk_buff *skb);
107
108/* Opcode OCF */
109/* HCI recv control commands opcode */
110#define HCI_OCF_FM_ENABLE_RECV_REQ 0x0001
111#define HCI_OCF_FM_DISABLE_RECV_REQ 0x0002
112#define HCI_OCF_FM_GET_RECV_CONF_REQ 0x0003
113#define HCI_OCF_FM_SET_RECV_CONF_REQ 0x0004
114#define HCI_OCF_FM_SET_MUTE_MODE_REQ 0x0005
115#define HCI_OCF_FM_SET_STEREO_MODE_REQ 0x0006
116#define HCI_OCF_FM_SET_ANTENNA 0x0007
117#define HCI_OCF_FM_SET_SIGNAL_THRESHOLD 0x0008
118#define HCI_OCF_FM_GET_SIGNAL_THRESHOLD 0x0009
119#define HCI_OCF_FM_GET_STATION_PARAM_REQ 0x000A
120#define HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ 0x000B
121#define HCI_OCF_FM_GET_RADIO_TEXT_REQ 0x000C
122#define HCI_OCF_FM_GET_AF_LIST_REQ 0x000D
123#define HCI_OCF_FM_SEARCH_STATIONS 0x000E
124#define HCI_OCF_FM_SEARCH_RDS_STATIONS 0x000F
125#define HCI_OCF_FM_SEARCH_STATIONS_LIST 0x0010
126#define HCI_OCF_FM_CANCEL_SEARCH 0x0011
127#define HCI_OCF_FM_RDS_GRP 0x0012
128#define HCI_OCF_FM_RDS_GRP_PROCESS 0x0013
129#define HCI_OCF_FM_EN_WAN_AVD_CTRL 0x0014
130#define HCI_OCF_FM_EN_NOTCH_CTRL 0x0015
Srinivasa Rao Uppalaf856ae62011-10-17 18:43:26 +0530131#define HCI_OCF_FM_SET_EVENT_MASK 0x0016
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700132
Ankur Nandwanid928d542011-08-11 13:15:41 -0700133/* HCI trans control commans opcode*/
134#define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001
135#define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002
136#define HCI_OCF_FM_GET_TRANS_CONF_REQ 0x0003
137#define HCI_OCF_FM_SET_TRANS_CONF_REQ 0x0004
138#define HCI_OCF_FM_RDS_RT_REQ 0x0008
139#define HCI_OCF_FM_RDS_PS_REQ 0x0009
140
141
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142/* HCI common control commands opcode */
143#define HCI_OCF_FM_TUNE_STATION_REQ 0x0001
144#define HCI_OCF_FM_DEFAULT_DATA_READ 0x0002
145#define HCI_OCF_FM_DEFAULT_DATA_WRITE 0x0003
146#define HCI_OCF_FM_RESET 0x0004
147#define HCI_OCF_FM_GET_FEATURE_LIST 0x0005
148#define HCI_OCF_FM_DO_CALIBRATION 0x0006
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530149#define HCI_OCF_FM_SET_CALIBRATION 0x0007
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150
151/*HCI Status parameters commands*/
152#define HCI_OCF_FM_READ_GRP_COUNTERS 0x0001
153
154/*HCI Diagnostic commands*/
155#define HCI_OCF_FM_PEEK_DATA 0x0002
156#define HCI_OCF_FM_POKE_DATA 0x0003
157#define HCI_OCF_FM_SSBI_PEEK_REG 0x0004
158#define HCI_OCF_FM_SSBI_POKE_REG 0x0005
159#define HCI_OCF_FM_STATION_DBG_PARAM 0x0007
Ankur Nandwanid928d542011-08-11 13:15:41 -0700160#define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700161
162/* Opcode OGF */
163#define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013
Ankur Nandwanid928d542011-08-11 13:15:41 -0700164#define HCI_OGF_FM_TRANS_CTRL_CMD_REQ 0x0014
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700165#define HCI_OGF_FM_COMMON_CTRL_CMD_REQ 0x0015
166#define HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ 0x0016
167#define HCI_OGF_FM_TEST_CMD_REQ 0x0017
168#define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F
169
170/* Command opcode pack/unpack */
171#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
172#define hci_opcode_ogf(op) (op >> 10)
173#define hci_opcode_ocf(op) (op & 0x03ff)
174#define hci_recv_ctrl_cmd_op_pack(ocf) \
175 (__u16) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf)
Ankur Nandwanid928d542011-08-11 13:15:41 -0700176#define hci_trans_ctrl_cmd_op_pack(ocf) \
177 (__u16) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700178#define hci_common_cmd_op_pack(ocf) \
179 (__u16) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf)
180#define hci_status_param_op_pack(ocf) \
181 (__u16) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf)
182#define hci_diagnostic_cmd_op_pack(ocf) \
183 (__u16) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf)
184
185
186/* HCI commands with no arguments*/
187#define HCI_FM_ENABLE_RECV_CMD 1
188#define HCI_FM_DISABLE_RECV_CMD 2
189#define HCI_FM_GET_RECV_CONF_CMD 3
190#define HCI_FM_GET_STATION_PARAM_CMD 4
191#define HCI_FM_GET_SIGNAL_TH_CMD 5
192#define HCI_FM_GET_PROGRAM_SERVICE_CMD 6
193#define HCI_FM_GET_RADIO_TEXT_CMD 7
194#define HCI_FM_GET_AF_LIST_CMD 8
195#define HCI_FM_CANCEL_SEARCH_CMD 9
196#define HCI_FM_RESET_CMD 10
197#define HCI_FM_GET_FEATURES_CMD 11
198#define HCI_FM_STATION_DBG_PARAM_CMD 12
Ankur Nandwanid928d542011-08-11 13:15:41 -0700199#define HCI_FM_ENABLE_TRANS_CMD 13
200#define HCI_FM_DISABLE_TRANS_CMD 14
201
202
203/* Defines for FM TX*/
204#define TX_PS_DATA_LENGTH 96
205#define TX_RT_DATA_LENGTH 64
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700206
207/* ----- HCI Command request ----- */
208struct hci_fm_recv_conf_req {
209 __u8 emphasis;
210 __u8 ch_spacing;
211 __u8 rds_std;
212 __u8 hlsi;
213 __u32 band_low_limit;
214 __u32 band_high_limit;
215} __packed;
216
Ankur Nandwanid928d542011-08-11 13:15:41 -0700217/* ----- HCI Command request ----- */
218struct hci_fm_trans_conf_req_struct {
219 __u8 emphasis;
220 __u8 rds_std;
221 __u32 band_low_limit;
222 __u32 band_high_limit;
223} __packed;
224
225
226/* ----- HCI Command request ----- */
227struct hci_fm_tx_ps {
228 __u8 ps_control;
229 __u16 pi;
230 __u8 pty;
231 __u8 ps_repeatcount;
232 __u8 ps_len;
233 __u8 ps_data[TX_PS_DATA_LENGTH];
234} __packed;
235
236struct hci_fm_tx_rt {
237 __u8 rt_control;
238 __u16 pi;
239 __u8 pty;
240 __u8 ps_len;
241 __u8 rt_data[TX_RT_DATA_LENGTH];
242} __packed;
243
244struct hci_fm_get_trans_conf_rsp {
245 __u8 status;
246 __u8 emphasis;
247 __u8 rds_std;
248 __u32 band_low_limit;
249 __u32 band_high_limit;
250} __packed;
251
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700252struct hci_fm_mute_mode_req {
253 __u8 hard_mute;
254 __u8 soft_mute;
255} __packed;
256
257struct hci_fm_stereo_mode_req {
258 __u8 stereo_mode;
259 __u8 sig_blend;
260 __u8 intf_blend;
261 __u8 most_switch;
262} __packed;
263
264struct hci_fm_search_station_req {
265 __u8 srch_mode;
266 __u8 scan_time;
267 __u8 srch_dir;
268} __packed;
269
270struct hci_fm_search_rds_station_req {
271 struct hci_fm_search_station_req srch_station;
272 __u8 srch_pty;
273 __u16 srch_pi;
274} __packed;
275
276struct hci_fm_search_station_list_req {
277 __u8 srch_list_mode;
278 __u8 srch_list_dir;
279 __u32 srch_list_max;
280 __u8 srch_pty;
281} __packed;
282
283struct hci_fm_rds_grp_req {
284 __u32 rds_grp_enable_mask;
285 __u32 rds_buf_size;
286 __u8 en_rds_change_filter;
287} __packed;
288
289struct hci_fm_en_avd_ctrl_req {
290 __u8 no_freqs;
291 __u8 freq_index;
292 __u8 lo_shft;
293 __u16 freq_min;
294 __u16 freq_max;
295} __packed;
296
297struct hci_fm_def_data_rd_req {
298 __u8 mode;
299 __u8 length;
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530300 __u8 param_len;
301 __u8 param;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700302} __packed;
303
304struct hci_fm_def_data_wr_req {
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530305 __u8 mode;
306 __u8 length;
307 __u8 data[DEFAULT_DATA_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700308} __packed;
309
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700310struct hci_fm_riva_data {
311 __u8 subopcode;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700312 __u32 start_addr;
313 __u8 length;
314} __packed;
315
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700316struct hci_fm_riva_poke {
317 struct hci_fm_riva_data cmd_params;
318 __u8 data[MAX_RIVA_PEEK_RSP_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700319} __packed;
320
321struct hci_fm_ssbi_req {
322 __u16 start_addr;
323 __u8 data;
324} __packed;
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700325struct hci_fm_ssbi_peek {
326 __u16 start_address;
327} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328
329/*HCI events*/
330#define HCI_EV_TUNE_STATUS 0x01
331#define HCI_EV_RDS_LOCK_STATUS 0x02
332#define HCI_EV_STEREO_STATUS 0x03
333#define HCI_EV_SERVICE_AVAILABLE 0x04
334#define HCI_EV_SEARCH_PROGRESS 0x05
335#define HCI_EV_SEARCH_RDS_PROGRESS 0x06
336#define HCI_EV_SEARCH_LIST_PROGRESS 0x07
337#define HCI_EV_RDS_RX_DATA 0x08
338#define HCI_EV_PROGRAM_SERVICE 0x09
339#define HCI_EV_RADIO_TEXT 0x0A
340#define HCI_EV_FM_AF_LIST 0x0B
341#define HCI_EV_TX_RDS_GRP_AVBLE 0x0C
342#define HCI_EV_TX_RDS_GRP_COMPL 0x0D
343#define HCI_EV_TX_RDS_CONT_GRP_COMPL 0x0E
344#define HCI_EV_CMD_COMPLETE 0x0F
345#define HCI_EV_CMD_STATUS 0x10
346#define HCI_EV_TUNE_COMPLETE 0x11
347#define HCI_EV_SEARCH_COMPLETE 0x12
348#define HCI_EV_SEARCH_RDS_COMPLETE 0x13
349#define HCI_EV_SEARCH_LIST_COMPLETE 0x14
350
351#define HCI_REQ_DONE 0
352#define HCI_REQ_PEND 1
353#define HCI_REQ_CANCELED 2
354#define HCI_REQ_STATUS 3
355
356struct hci_ev_tune_status {
357 __u8 sub_event;
358 __le32 station_freq;
359 __u8 serv_avble;
360 __u8 rssi;
361 __u8 stereo_prg;
362 __u8 rds_sync_status;
363 __u8 mute_mode;
364} __packed;
365
366struct hci_ev_rds_rx_data {
367 __u8 num_rds_grps;
368 __u8 rds_grp_data[12];
369} __packed;
370
371struct hci_ev_prg_service {
372 __le16 pi_prg_id;
373 __u8 pty_prg_type;
374 __u8 ta_prg_code_type;
375 __u8 ta_ann_code_flag;
376 __u8 ms_switch_code_flag;
377 __u8 dec_id_ctrl_code_flag;
378 __u8 ps_num;
379 __u8 prg_service_name[119];
380} __packed;
381
382struct hci_ev_radio_text {
383 __le16 pi_prg_id;
384 __u8 pty_prg_type;
385 __u8 ta_prg_code_type;
386 __u8 txt_ab_flag;
387 __u8 radio_txt[64];
388} __packed;
389
390struct hci_ev_af_list {
391 __le32 tune_freq;
392 __le16 pi_code;
393 __u8 af_size;
394 __u8 af_list[25];
395} __packed;
396
397struct hci_ev_cmd_complete {
398 __u8 num_hci_cmd_pkts;
399 __le16 cmd_opcode;
400} __packed;
401
402struct hci_ev_cmd_status {
403 __u8 status;
404 __u8 num_hci_cmd_pkts;
405 __le16 status_opcode;
406} __packed;
407
408struct hci_ev_srch_st {
409 __le32 station_freq;
410 __u8 rds_cap;
411 __u8 pty;
412 __le16 status_opcode;
413} __packed;
414
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700415struct hci_ev_rel_freq {
416 __u8 rel_freq_msb;
417 __u8 rel_freq_lsb;
418
419} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700420struct hci_ev_srch_list_compl {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700421 __u8 num_stations_found;
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700422 struct hci_ev_rel_freq rel_freq[20];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700423} __packed;
424
425/* ----- HCI Event Response ----- */
426struct hci_fm_conf_rsp {
427 __u8 status;
428 struct hci_fm_recv_conf_req recv_conf_rsp;
429} __packed;
430
431struct hci_fm_sig_threshold_rsp {
432 __u8 status;
433 __u8 sig_threshold;
434} __packed;
435
436struct hci_fm_station_rsp {
437 struct hci_ev_tune_status station_rsp;
438} __packed;
439
440struct hci_fm_prgm_srv_rsp {
441 __u8 status;
442 struct hci_ev_prg_service prg_srv;
443} __packed;
444
445struct hci_fm_radio_txt_rsp {
446 __u8 status;
447 struct hci_ev_radio_text rd_txt;
448} __packed;
449
450struct hci_fm_af_list_rsp {
451 __u8 status;
452 struct hci_ev_af_list rd_txt;
453} __packed;
454
455struct hci_fm_data_rd_rsp {
456 __u8 status;
457 __u8 ret_data_len;
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530458 __u8 data[DEFAULT_DATA_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700459} __packed;
460
461struct hci_fm_feature_list_rsp {
462 __u8 status;
463 __u8 feature_mask;
464} __packed;
465
466struct hci_fm_dbg_param_rsp {
467 __u8 status;
468 __u8 blend;
469 __u8 soft_mute;
470 __u8 inf_blend;
471 __u8 inf_soft_mute;
472 __u8 pilot_pil;
473 __u8 io_verc;
474 __u8 in_det_out;
475} __packed;
476
477/* HCI dev events */
478#define RADIO_HCI_DEV_REG 1
479#define RADIO_HCI_DEV_WRITE 2
480
481#define hci_req_lock(d) mutex_lock(&d->req_lock)
482#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
483
Ankur Nandwani78a782b2011-07-07 21:11:21 -0700484/* FM RDS */
Ankur Nandwani42462512011-07-15 17:08:24 -0700485#define RDS_PTYPE 2
486#define RDS_PID_LOWER 1
487#define RDS_PID_HIGHER 0
Ankur Nandwani78a782b2011-07-07 21:11:21 -0700488#define RDS_OFFSET 5
489#define RDS_PS_LENGTH_OFFSET 7
490#define RDS_STRING 8
491#define RDS_PS_DATA_OFFSET 8
Srinivasa Rao Uppala58273f82011-08-10 19:07:45 -0700492#define RDS_CONFIG_OFFSET 3
Srinivasa Rao Uppala3c7a8eb2011-09-18 09:10:21 +0530493#define RDS_AF_JUMP_OFFSET 4
494#define PI_CODE_OFFSET 4
495#define AF_SIZE_OFFSET 6
496#define AF_LIST_OFFSET 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700497/*FM states*/
498
499enum radio_state_t {
500 FM_OFF,
501 FM_RECV,
502 FM_TRANS,
503 FM_RESET,
504};
505
506enum v4l2_cid_private_iris_t {
507 V4L2_CID_PRIVATE_IRIS_SRCHMODE = (0x08000000 + 1),
508 V4L2_CID_PRIVATE_IRIS_SCANDWELL,
509 V4L2_CID_PRIVATE_IRIS_SRCHON,
510 V4L2_CID_PRIVATE_IRIS_STATE,
511 V4L2_CID_PRIVATE_IRIS_TRANSMIT_MODE,
512 V4L2_CID_PRIVATE_IRIS_RDSGROUP_MASK,
513 V4L2_CID_PRIVATE_IRIS_REGION,
514 V4L2_CID_PRIVATE_IRIS_SIGNAL_TH,
515 V4L2_CID_PRIVATE_IRIS_SRCH_PTY,
516 V4L2_CID_PRIVATE_IRIS_SRCH_PI,
517 V4L2_CID_PRIVATE_IRIS_SRCH_CNT,
518 V4L2_CID_PRIVATE_IRIS_EMPHASIS,
519 V4L2_CID_PRIVATE_IRIS_RDS_STD,
520 V4L2_CID_PRIVATE_IRIS_SPACING,
521 V4L2_CID_PRIVATE_IRIS_RDSON,
522 V4L2_CID_PRIVATE_IRIS_RDSGROUP_PROC,
523 V4L2_CID_PRIVATE_IRIS_LP_MODE,
524 V4L2_CID_PRIVATE_IRIS_ANTENNA,
525 V4L2_CID_PRIVATE_IRIS_RDSD_BUF,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530526 V4L2_CID_PRIVATE_IRIS_PSALL, /*0x8000014*/
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700527
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700528 /*v4l2 Tx controls*/
529 V4L2_CID_PRIVATE_IRIS_TX_SETPSREPEATCOUNT,
530 V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_PS_NAME,
531 V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_RT,
532 V4L2_CID_PRIVATE_IRIS_IOVERC,
533 V4L2_CID_PRIVATE_IRIS_INTDET,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530534 V4L2_CID_PRIVATE_IRIS_MPX_DCC,
535 V4L2_CID_PRIVATE_IRIS_AF_JUMP,
536 V4L2_CID_PRIVATE_IRIS_RSSI_DELTA,
537 V4L2_CID_PRIVATE_IRIS_HLSI, /*0x800001d*/
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700538
539 /*Diagnostic commands*/
540 V4L2_CID_PRIVATE_IRIS_SOFT_MUTE,
541 V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR,
542 V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN,
543 V4L2_CID_PRIVATE_IRIS_RIVA_PEEK,
544 V4L2_CID_PRIVATE_IRIS_RIVA_POKE,
545 V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR,
546 V4L2_CID_PRIVATE_IRIS_SSBI_PEEK,
547 V4L2_CID_PRIVATE_IRIS_SSBI_POKE,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530548 V4L2_CID_PRIVATE_IRIS_TX_TONE,
549 V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS,
550 V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER,/*0x8000028*/
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530551 /*0x8000029 is used for tavarua specific ioctl*/
552 V4L2_CID_PRIVATE_IRIS_DO_CALIBRATION = 0x800002a,
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530553 V4L2_CID_PRIVATE_IRIS_READ_DEFAULT = 0x00980928,/*using private CIDs
554 under userclass*/
555 V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT,
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530556 V4L2_CID_PRIVATE_IRIS_SET_CALIBRATION,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700557};
558
Ankur Nandwanid928d542011-08-11 13:15:41 -0700559
560
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700561enum iris_evt_t {
562 IRIS_EVT_RADIO_READY,
563 IRIS_EVT_TUNE_SUCC,
564 IRIS_EVT_SEEK_COMPLETE,
565 IRIS_EVT_SCAN_NEXT,
566 IRIS_EVT_NEW_RAW_RDS,
567 IRIS_EVT_NEW_RT_RDS,
568 IRIS_EVT_NEW_PS_RDS,
569 IRIS_EVT_ERROR,
570 IRIS_EVT_BELOW_TH,
571 IRIS_EVT_ABOVE_TH,
572 IRIS_EVT_STEREO,
573 IRIS_EVT_MONO,
574 IRIS_EVT_RDS_AVAIL,
575 IRIS_EVT_RDS_NOT_AVAIL,
576 IRIS_EVT_NEW_SRCH_LIST,
577 IRIS_EVT_NEW_AF_LIST,
578 IRIS_EVT_TXRDSDAT,
579 IRIS_EVT_TXRDSDONE
580};
Ankur Nandwanid928d542011-08-11 13:15:41 -0700581enum emphasis_type {
582 FM_RX_EMP75 = 0x0,
583 FM_RX_EMP50 = 0x1
584};
585
586enum channel_space_type {
587 FM_RX_SPACE_200KHZ = 0x0,
588 FM_RX_SPACE_100KHZ = 0x1,
589 FM_RX_SPACE_50KHZ = 0x2
590};
591
592enum high_low_injection {
593 AUTO_HI_LO_INJECTION = 0x0,
594 LOW_SIDE_INJECTION = 0x1,
595 HIGH_SIDE_INJECTION = 0x2
596};
597
598enum fm_rds_type {
599 FM_RX_RDBS_SYSTEM = 0x0,
600 FM_RX_RDS_SYSTEM = 0x1
601};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700602
603enum iris_region_t {
604 IRIS_REGION_US,
605 IRIS_REGION_EU,
606 IRIS_REGION_JAPAN,
607 IRIS_REGION_JAPAN_WIDE,
608 IRIS_REGION_OTHER
609};
610
611#define STD_BUF_SIZE (64)
612
613enum iris_buf_t {
614 IRIS_BUF_SRCH_LIST,
615 IRIS_BUF_EVENTS,
616 IRIS_BUF_RT_RDS,
617 IRIS_BUF_PS_RDS,
618 IRIS_BUF_RAW_RDS,
619 IRIS_BUF_AF_LIST,
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700620 IRIS_BUF_PEEK,
621 IRIS_BUF_SSBI_PEEK,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530622 IRIS_BUF_RDS_CNTRS,
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530623 IRIS_BUF_RD_DEFAULT,
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530624 IRIS_BUF_CAL_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700625 IRIS_BUF_MAX
626};
627
628enum iris_xfr_t {
629 IRIS_XFR_SYNC,
630 IRIS_XFR_ERROR,
631 IRIS_XFR_SRCH_LIST,
632 IRIS_XFR_RT_RDS,
633 IRIS_XFR_PS_RDS,
634 IRIS_XFR_AF_LIST,
635 IRIS_XFR_MAX
636};
637
638#undef FMDBG
639#ifdef FM_DEBUG
640#define FMDBG(fmt, args...) pr_info("iris_radio: " fmt, ##args)
641#else
642#define FMDBG(fmt, args...)
643#endif
644
645#undef FMDERR
646#define FMDERR(fmt, args...) pr_err("iris_radio: " fmt, ##args)
647
648/* Search options */
649enum search_t {
650 SEEK,
651 SCAN,
652 SCAN_FOR_STRONG,
653 SCAN_FOR_WEAK,
654 RDS_SEEK_PTY,
655 RDS_SCAN_PTY,
656 RDS_SEEK_PI,
657 RDS_AF_JUMP,
658};
659
Ankur Nandwanid928d542011-08-11 13:15:41 -0700660
661/* Band limits */
662#define REGION_US_EU_BAND_LOW 87500
663#define REGION_US_EU_BAND_HIGH 107900
664#define REGION_JAPAN_STANDARD_BAND_LOW 76000
665#define REGION_JAPAN_STANDARD_BAND_HIGH 90000
666#define REGION_JAPAN_WIDE_BAND_LOW 90000
667#define REGION_JAPAN_WIDE_BAND_HIGH 108000
668
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700669#define SRCH_MODE 0x07
670#define SRCH_DIR 0x08 /* 0-up 1-down */
671#define SCAN_DWELL 0x70
672#define SRCH_ON 0x80
673
674/* I/O Control */
675#define IOC_HRD_MUTE 0x03
676#define IOC_SFT_MUTE 0x01
677#define IOC_MON_STR 0x01
678#define IOC_SIG_BLND 0x01
679#define IOC_INTF_BLND 0x01
680#define IOC_ANTENNA 0x01
681
682/* RDS Control */
683#define RDS_ON 0x01
684#define RDS_BUF_SZ 100
685
Ankur Nandwanid928d542011-08-11 13:15:41 -0700686/* constants */
687#define RDS_BLOCKS_NUM (4)
688#define BYTES_PER_BLOCK (3)
689#define MAX_PS_LENGTH (96)
690#define MAX_RT_LENGTH (64)
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530691#define RDS_GRP_CNTR_LEN (36)
Ankur Nandwanid928d542011-08-11 13:15:41 -0700692
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700693/* Search direction */
694#define SRCH_DIR_UP (0)
695#define SRCH_DIR_DOWN (1)
696
Srinivasa Rao Uppala7bb22102011-07-14 11:27:30 -0700697/*Search RDS stations*/
698#define SEARCH_RDS_STNS_MODE_OFFSET 4
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700699
700/*Search Station list */
Srinivasa Rao Uppala4b92e4b2011-08-09 15:46:25 -0700701#define PARAMS_PER_STATION 0x08
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700702#define STN_NUM_OFFSET 0x01
703#define STN_FREQ_OFFSET 0x02
704#define KHZ_TO_MHZ 1000
705#define GET_MSB(x)((x >> 8) & 0xFF)
706#define GET_LSB(x)((x) & 0xFF)
707
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700708/* control options */
709#define CTRL_ON (1)
710#define CTRL_OFF (0)
711
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700712/*Diagnostic commands*/
713
714#define RIVA_PEEK_OPCODE 0x0D
715#define RIVA_POKE_OPCODE 0x0C
716
717#define PEEK_DATA_OFSET 0x1
718#define RIVA_PEEK_PARAM 0x6
719#define RIVA_PEEK_LEN_OFSET 0x6
720#define SSBI_PEEK_LEN 0x01
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530721/*Calibration data*/
722#define PROCS_CALIB_MODE 1
723#define PROCS_CALIB_SIZE 23
724#define DC_CALIB_MODE 2
725#define DC_CALIB_SIZE 48
726#define RSB_CALIB_MODE 3
727#define RSB_CALIB_SIZE 4
728#define CALIB_DATA_OFSET 2
729#define CALIB_MODE_OFSET 1
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530730#define MAX_CALIB_SIZE 75
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530731struct hci_fm_set_cal_req_proc {
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530732 __u8 mode;
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530733 /*Max process calibration data size*/
734 __u8 data[PROCS_CALIB_SIZE];
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530735} __packed;
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530736
737struct hci_fm_set_cal_req_dc {
738 __u8 mode;
739 /*Max DC calibration data size*/
740 __u8 data[DC_CALIB_SIZE];
741} __packed;
742
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530743struct hci_cc_do_calibration_rsp {
744 __u8 status;
745 __u8 mode;
746 __u8 data[MAX_CALIB_SIZE];
747} __packed;
Srinivasa Rao Uppalaf856ae62011-10-17 18:43:26 +0530748
749/* Low Power mode*/
750#define SIG_LEVEL_INTR (1 << 0)
751#define RDS_SYNC_INTR (1 << 1)
752#define AUDIO_CTRL_INTR (1 << 2)
753#define AF_JUMP_ENABLE (1 << 4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700754int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
755 struct radio_hci_dev *hdev);
756int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
757 struct radio_hci_dev *hdev);
758int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
759int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700760
761#endif /* __RADIO_HCI_CORE_H */