blob: d6151c013247efd4190c9a5c86ddc92b33a56f1a [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 *
Venkateshwarlu Domakondaac31b782013-04-05 15:12:32 +05303 * Copyright (c) 2011-2013 The Linux Foundation. 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>
Venkateshwarlu Domakondaac31b782013-04-05 15:12:32 +053034#include "radio-iris-commands.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070035
36/* ---- HCI Packet structures ---- */
37#define RADIO_HCI_COMMAND_HDR_SIZE sizeof(struct radio_hci_command_hdr)
38#define RADIO_HCI_EVENT_HDR_SIZE sizeof(struct radio_hci_event_hdr)
39
40/* HCI data types */
41#define RADIO_HCI_COMMAND_PKT 0x11
42#define RADIO_HCI_EVENT_PKT 0x14
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -070043/*HCI reponce packets*/
44#define MAX_RIVA_PEEK_RSP_SIZE 251
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +053045/* default data access */
46#define DEFAULT_DATA_OFFSET 2
47#define DEFAULT_DATA_SIZE 249
Venkateshwarlu Domakonda71731d52012-04-04 12:30:51 +053048/* Power levels are 0-7, but SOC will expect values from 0-255
49 * So the each level step size will be 255/7 = 36 */
50#define FM_TX_PWR_LVL_STEP_SIZE 36
51#define FM_TX_PWR_LVL_0 0 /* Lowest power lvl that can be set for Tx */
52#define FM_TX_PWR_LVL_MAX 7 /* Max power lvl for Tx */
53#define FM_TX_PHY_CFG_MODE 0x3c
54#define FM_TX_PHY_CFG_LEN 0x10
55#define FM_TX_PWR_GAIN_OFFSET 14
Ayaz Ahmaddb04b0c2013-02-01 17:18:34 +053056/**RDS CONFIG MODE**/
57#define FM_RDS_CNFG_MODE 0x0f
58#define FM_RDS_CNFG_LEN 0x10
59#define AF_RMSSI_TH_LSB_OFFSET 10
60#define AF_RMSSI_TH_MSB_OFFSET 11
61#define AF_RMSSI_SAMPLES_OFFSET 15
62/**RX CONFIG MODE**/
63#define FM_RX_CONFG_MODE 0x15
64#define FM_RX_CNFG_LEN 0x20
65#define GD_CH_RMSSI_TH_OFFSET 12
66#define MAX_GD_CH_RMSSI_TH 127
67#define SRCH_ALGO_TYPE_OFFSET 25
68#define SINRFIRSTSTAGE_OFFSET 26
69#define RMSSIFIRSTSTAGE_OFFSET 27
70#define CF0TH12_BYTE1_OFFSET 8
71#define CF0TH12_BYTE2_OFFSET 9
72#define CF0TH12_BYTE3_OFFSET 10
73#define CF0TH12_BYTE4_OFFSET 11
74#define MAX_SINR_FIRSTSTAGE 127
75#define MAX_RMSSI_FIRSTSTAGE 127
Venkateshwarlu Domakonda70e47162013-04-30 14:12:13 +053076#define RDS_PS0_XFR_MODE 0x01
77#define RDS_PS0_LEN 6
78#define RX_REPEATE_BYTE_OFFSET 5
Ayaz Ahmaddb04b0c2013-02-01 17:18:34 +053079
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070080/* HCI timeouts */
81#define RADIO_HCI_TIMEOUT (10000) /* 10 seconds */
82
83#define TUNE_PARAM 16
84struct radio_hci_command_hdr {
85 __le16 opcode; /* OCF & OGF */
86 __u8 plen;
87} __packed;
88
89struct radio_hci_event_hdr {
90 __u8 evt;
91 __u8 plen;
92} __packed;
93
94struct radio_hci_dev {
95 char name[8];
96 unsigned long flags;
97 __u16 id;
98 __u8 bus;
99 __u8 dev_type;
100 __u8 dev_name[248];
101 __u8 dev_class[3];
102 __u8 features[8];
103 __u8 commands[64];
104
105 unsigned int data_block_len;
106 unsigned long cmd_last_tx;
107
108 struct sk_buff *sent_cmd;
109
110 __u32 req_status;
111 __u32 req_result;
112 atomic_t cmd_cnt;
113
114 struct tasklet_struct cmd_task;
115 struct tasklet_struct rx_task;
116 struct tasklet_struct tx_task;
117
118 struct sk_buff_head rx_q;
119 struct sk_buff_head raw_q;
120 struct sk_buff_head cmd_q;
121
122 struct mutex req_lock;
123 wait_queue_head_t req_wait_q;
124
125 int (*open)(struct radio_hci_dev *hdev);
126 int (*close)(struct radio_hci_dev *hdev);
127 int (*flush)(struct radio_hci_dev *hdev);
128 int (*send)(struct sk_buff *skb);
129 void (*destruct)(struct radio_hci_dev *hdev);
130 void (*notify)(struct radio_hci_dev *hdev, unsigned int evt);
131};
132
133int radio_hci_register_dev(struct radio_hci_dev *hdev);
134int radio_hci_unregister_dev(struct radio_hci_dev *hdev);
135int radio_hci_recv_frame(struct sk_buff *skb);
136int radio_hci_send_cmd(struct radio_hci_dev *hdev, __u16 opcode, __u32 plen,
137 void *param);
138void radio_hci_event_packet(struct radio_hci_dev *hdev, struct sk_buff *skb);
139
140/* Opcode OCF */
141/* HCI recv control commands opcode */
142#define HCI_OCF_FM_ENABLE_RECV_REQ 0x0001
143#define HCI_OCF_FM_DISABLE_RECV_REQ 0x0002
144#define HCI_OCF_FM_GET_RECV_CONF_REQ 0x0003
145#define HCI_OCF_FM_SET_RECV_CONF_REQ 0x0004
146#define HCI_OCF_FM_SET_MUTE_MODE_REQ 0x0005
147#define HCI_OCF_FM_SET_STEREO_MODE_REQ 0x0006
148#define HCI_OCF_FM_SET_ANTENNA 0x0007
149#define HCI_OCF_FM_SET_SIGNAL_THRESHOLD 0x0008
150#define HCI_OCF_FM_GET_SIGNAL_THRESHOLD 0x0009
151#define HCI_OCF_FM_GET_STATION_PARAM_REQ 0x000A
152#define HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ 0x000B
153#define HCI_OCF_FM_GET_RADIO_TEXT_REQ 0x000C
154#define HCI_OCF_FM_GET_AF_LIST_REQ 0x000D
155#define HCI_OCF_FM_SEARCH_STATIONS 0x000E
156#define HCI_OCF_FM_SEARCH_RDS_STATIONS 0x000F
157#define HCI_OCF_FM_SEARCH_STATIONS_LIST 0x0010
158#define HCI_OCF_FM_CANCEL_SEARCH 0x0011
159#define HCI_OCF_FM_RDS_GRP 0x0012
160#define HCI_OCF_FM_RDS_GRP_PROCESS 0x0013
161#define HCI_OCF_FM_EN_WAN_AVD_CTRL 0x0014
162#define HCI_OCF_FM_EN_NOTCH_CTRL 0x0015
Srinivasa Rao Uppalaf856ae62011-10-17 18:43:26 +0530163#define HCI_OCF_FM_SET_EVENT_MASK 0x0016
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530164#define HCI_OCF_FM_SET_CH_DET_THRESHOLD 0x0017
165#define HCI_OCF_FM_GET_CH_DET_THRESHOLD 0x0018
Ankur Nandwanid928d542011-08-11 13:15:41 -0700166/* HCI trans control commans opcode*/
167#define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001
168#define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002
169#define HCI_OCF_FM_GET_TRANS_CONF_REQ 0x0003
170#define HCI_OCF_FM_SET_TRANS_CONF_REQ 0x0004
171#define HCI_OCF_FM_RDS_RT_REQ 0x0008
172#define HCI_OCF_FM_RDS_PS_REQ 0x0009
173
174
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700175/* HCI common control commands opcode */
176#define HCI_OCF_FM_TUNE_STATION_REQ 0x0001
177#define HCI_OCF_FM_DEFAULT_DATA_READ 0x0002
178#define HCI_OCF_FM_DEFAULT_DATA_WRITE 0x0003
179#define HCI_OCF_FM_RESET 0x0004
180#define HCI_OCF_FM_GET_FEATURE_LIST 0x0005
181#define HCI_OCF_FM_DO_CALIBRATION 0x0006
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530182#define HCI_OCF_FM_SET_CALIBRATION 0x0007
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700183
184/*HCI Status parameters commands*/
185#define HCI_OCF_FM_READ_GRP_COUNTERS 0x0001
186
187/*HCI Diagnostic commands*/
188#define HCI_OCF_FM_PEEK_DATA 0x0002
189#define HCI_OCF_FM_POKE_DATA 0x0003
190#define HCI_OCF_FM_SSBI_PEEK_REG 0x0004
191#define HCI_OCF_FM_SSBI_POKE_REG 0x0005
192#define HCI_OCF_FM_STATION_DBG_PARAM 0x0007
Ankur Nandwanid928d542011-08-11 13:15:41 -0700193#define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700194
195/* Opcode OGF */
196#define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013
Ankur Nandwanid928d542011-08-11 13:15:41 -0700197#define HCI_OGF_FM_TRANS_CTRL_CMD_REQ 0x0014
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700198#define HCI_OGF_FM_COMMON_CTRL_CMD_REQ 0x0015
199#define HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ 0x0016
200#define HCI_OGF_FM_TEST_CMD_REQ 0x0017
201#define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F
202
203/* Command opcode pack/unpack */
204#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
205#define hci_opcode_ogf(op) (op >> 10)
206#define hci_opcode_ocf(op) (op & 0x03ff)
207#define hci_recv_ctrl_cmd_op_pack(ocf) \
208 (__u16) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf)
Ankur Nandwanid928d542011-08-11 13:15:41 -0700209#define hci_trans_ctrl_cmd_op_pack(ocf) \
210 (__u16) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700211#define hci_common_cmd_op_pack(ocf) \
212 (__u16) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf)
213#define hci_status_param_op_pack(ocf) \
214 (__u16) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf)
215#define hci_diagnostic_cmd_op_pack(ocf) \
216 (__u16) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf)
217
218
219/* HCI commands with no arguments*/
220#define HCI_FM_ENABLE_RECV_CMD 1
221#define HCI_FM_DISABLE_RECV_CMD 2
222#define HCI_FM_GET_RECV_CONF_CMD 3
223#define HCI_FM_GET_STATION_PARAM_CMD 4
224#define HCI_FM_GET_SIGNAL_TH_CMD 5
225#define HCI_FM_GET_PROGRAM_SERVICE_CMD 6
226#define HCI_FM_GET_RADIO_TEXT_CMD 7
227#define HCI_FM_GET_AF_LIST_CMD 8
228#define HCI_FM_CANCEL_SEARCH_CMD 9
229#define HCI_FM_RESET_CMD 10
230#define HCI_FM_GET_FEATURES_CMD 11
231#define HCI_FM_STATION_DBG_PARAM_CMD 12
Ankur Nandwanid928d542011-08-11 13:15:41 -0700232#define HCI_FM_ENABLE_TRANS_CMD 13
233#define HCI_FM_DISABLE_TRANS_CMD 14
Srinivasa Rao Uppalac5320c22011-11-28 14:28:51 +0530234#define HCI_FM_GET_TX_CONFIG 15
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530235#define HCI_FM_GET_DET_CH_TH_CMD 16
Ankur Nandwanid928d542011-08-11 13:15:41 -0700236
237/* Defines for FM TX*/
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530238#define TX_PS_DATA_LENGTH 108
Ankur Nandwanid928d542011-08-11 13:15:41 -0700239#define TX_RT_DATA_LENGTH 64
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530240#define PS_STRING_LEN 9
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700241
242/* ----- HCI Command request ----- */
243struct hci_fm_recv_conf_req {
244 __u8 emphasis;
245 __u8 ch_spacing;
246 __u8 rds_std;
247 __u8 hlsi;
248 __u32 band_low_limit;
249 __u32 band_high_limit;
250} __packed;
251
Ankur Nandwanid928d542011-08-11 13:15:41 -0700252/* ----- HCI Command request ----- */
253struct hci_fm_trans_conf_req_struct {
254 __u8 emphasis;
255 __u8 rds_std;
256 __u32 band_low_limit;
257 __u32 band_high_limit;
258} __packed;
259
260
261/* ----- HCI Command request ----- */
262struct hci_fm_tx_ps {
263 __u8 ps_control;
264 __u16 pi;
265 __u8 pty;
266 __u8 ps_repeatcount;
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530267 __u8 ps_num;
Ankur Nandwanid928d542011-08-11 13:15:41 -0700268 __u8 ps_data[TX_PS_DATA_LENGTH];
269} __packed;
270
271struct hci_fm_tx_rt {
272 __u8 rt_control;
273 __u16 pi;
274 __u8 pty;
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530275 __u8 rt_len;
Ankur Nandwanid928d542011-08-11 13:15:41 -0700276 __u8 rt_data[TX_RT_DATA_LENGTH];
277} __packed;
278
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700279struct hci_fm_mute_mode_req {
280 __u8 hard_mute;
281 __u8 soft_mute;
282} __packed;
283
284struct hci_fm_stereo_mode_req {
285 __u8 stereo_mode;
286 __u8 sig_blend;
287 __u8 intf_blend;
288 __u8 most_switch;
289} __packed;
290
291struct hci_fm_search_station_req {
292 __u8 srch_mode;
293 __u8 scan_time;
294 __u8 srch_dir;
295} __packed;
296
297struct hci_fm_search_rds_station_req {
298 struct hci_fm_search_station_req srch_station;
299 __u8 srch_pty;
300 __u16 srch_pi;
301} __packed;
302
303struct hci_fm_search_station_list_req {
304 __u8 srch_list_mode;
305 __u8 srch_list_dir;
306 __u32 srch_list_max;
307 __u8 srch_pty;
308} __packed;
309
310struct hci_fm_rds_grp_req {
311 __u32 rds_grp_enable_mask;
312 __u32 rds_buf_size;
313 __u8 en_rds_change_filter;
314} __packed;
315
316struct hci_fm_en_avd_ctrl_req {
317 __u8 no_freqs;
318 __u8 freq_index;
319 __u8 lo_shft;
320 __u16 freq_min;
321 __u16 freq_max;
322} __packed;
323
324struct hci_fm_def_data_rd_req {
325 __u8 mode;
326 __u8 length;
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530327 __u8 param_len;
328 __u8 param;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700329} __packed;
330
331struct hci_fm_def_data_wr_req {
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530332 __u8 mode;
333 __u8 length;
334 __u8 data[DEFAULT_DATA_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700335} __packed;
336
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700337struct hci_fm_riva_data {
338 __u8 subopcode;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700339 __u32 start_addr;
340 __u8 length;
341} __packed;
342
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700343struct hci_fm_riva_poke {
344 struct hci_fm_riva_data cmd_params;
345 __u8 data[MAX_RIVA_PEEK_RSP_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700346} __packed;
347
348struct hci_fm_ssbi_req {
349 __u16 start_addr;
350 __u8 data;
351} __packed;
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700352struct hci_fm_ssbi_peek {
353 __u16 start_address;
354} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700355
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530356struct hci_fm_ch_det_threshold {
357 char sinr;
358 __u8 sinr_samples;
359 __u8 low_th;
360 __u8 high_th;
361
362} __packed;
363
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700364/*HCI events*/
365#define HCI_EV_TUNE_STATUS 0x01
366#define HCI_EV_RDS_LOCK_STATUS 0x02
367#define HCI_EV_STEREO_STATUS 0x03
368#define HCI_EV_SERVICE_AVAILABLE 0x04
369#define HCI_EV_SEARCH_PROGRESS 0x05
370#define HCI_EV_SEARCH_RDS_PROGRESS 0x06
371#define HCI_EV_SEARCH_LIST_PROGRESS 0x07
372#define HCI_EV_RDS_RX_DATA 0x08
373#define HCI_EV_PROGRAM_SERVICE 0x09
374#define HCI_EV_RADIO_TEXT 0x0A
375#define HCI_EV_FM_AF_LIST 0x0B
376#define HCI_EV_TX_RDS_GRP_AVBLE 0x0C
377#define HCI_EV_TX_RDS_GRP_COMPL 0x0D
378#define HCI_EV_TX_RDS_CONT_GRP_COMPL 0x0E
379#define HCI_EV_CMD_COMPLETE 0x0F
380#define HCI_EV_CMD_STATUS 0x10
381#define HCI_EV_TUNE_COMPLETE 0x11
382#define HCI_EV_SEARCH_COMPLETE 0x12
383#define HCI_EV_SEARCH_RDS_COMPLETE 0x13
384#define HCI_EV_SEARCH_LIST_COMPLETE 0x14
385
386#define HCI_REQ_DONE 0
387#define HCI_REQ_PEND 1
388#define HCI_REQ_CANCELED 2
389#define HCI_REQ_STATUS 3
390
Ayaz Ahmad89265112012-10-05 19:39:11 +0530391#define MAX_RAW_RDS_GRPS 21
392
393#define RDSGRP_DATA_OFFSET 0x1
394
395/*RT PLUS*/
396#define DUMMY_CLASS 0
397#define RT_PLUS_LEN_1_TAG 3
398#define RT_ERT_FLAG_BIT 5
399
400/*TAG1*/
401#define TAG1_MSB_OFFSET 3
402#define TAG1_MSB_MASK 7
403#define TAG1_LSB_OFFSET 5
404#define TAG1_POS_MSB_MASK 31
405#define TAG1_POS_MSB_OFFSET 1
406#define TAG1_POS_LSB_OFFSET 7
407#define TAG1_LEN_OFFSET 1
408#define TAG1_LEN_MASK 63
409
410/*TAG2*/
411#define TAG2_MSB_OFFSET 5
412#define TAG2_MSB_MASK 1
413#define TAG2_LSB_OFFSET 3
414#define TAG2_POS_MSB_MASK 7
415#define TAG2_POS_MSB_OFFSET 3
416#define TAG2_POS_LSB_OFFSET 5
417#define TAG2_LEN_MASK 31
418
419#define AGT_MASK 31
420/*Extract 5 left most bits of lsb of 2nd block*/
421#define AGT(x) (x & AGT_MASK)
422/*16 bits of 4th block*/
423#define AID(lsb, msb) ((msb << 8) | (lsb))
424/*Extract 5 right most bits of msb of 2nd block*/
425#define GTC(blk2msb) (blk2msb >> 3)
426
427#define GRP_3A 0x6
428#define RT_PLUS_AID 0x4bd7
429
430/*ERT*/
431#define ERT_AID 0x6552
432#define CARRIAGE_RETURN 0x000D
433#define MAX_ERT_SEGMENT 31
434#define ERT_FORMAT_DIR_BIT 1
435
436#define EXTRACT_BIT(data, bit_pos) ((data & (1 << bit_pos)) >> bit_pos)
437
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700438struct hci_ev_tune_status {
439 __u8 sub_event;
440 __le32 station_freq;
441 __u8 serv_avble;
442 __u8 rssi;
443 __u8 stereo_prg;
444 __u8 rds_sync_status;
445 __u8 mute_mode;
Srinivasa Rao Uppalaacdebcc2011-12-23 14:31:38 +0530446 char sinr;
447 __u8 intf_det_th;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700448} __packed;
449
Ayaz Ahmad89265112012-10-05 19:39:11 +0530450struct rds_blk_data {
451 __u8 rdsMsb;
452 __u8 rdsLsb;
453 __u8 blockStatus;
454} __packed;
455
456struct rds_grp_data {
457 struct rds_blk_data rdsBlk[4];
458} __packed;
459
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700460struct hci_ev_rds_rx_data {
461 __u8 num_rds_grps;
Ayaz Ahmad89265112012-10-05 19:39:11 +0530462 struct rds_grp_data rds_grp_data[MAX_RAW_RDS_GRPS];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700463} __packed;
464
465struct hci_ev_prg_service {
466 __le16 pi_prg_id;
467 __u8 pty_prg_type;
468 __u8 ta_prg_code_type;
469 __u8 ta_ann_code_flag;
470 __u8 ms_switch_code_flag;
471 __u8 dec_id_ctrl_code_flag;
472 __u8 ps_num;
473 __u8 prg_service_name[119];
474} __packed;
475
476struct hci_ev_radio_text {
477 __le16 pi_prg_id;
478 __u8 pty_prg_type;
479 __u8 ta_prg_code_type;
480 __u8 txt_ab_flag;
481 __u8 radio_txt[64];
482} __packed;
483
484struct hci_ev_af_list {
485 __le32 tune_freq;
486 __le16 pi_code;
487 __u8 af_size;
488 __u8 af_list[25];
489} __packed;
490
491struct hci_ev_cmd_complete {
492 __u8 num_hci_cmd_pkts;
493 __le16 cmd_opcode;
494} __packed;
495
496struct hci_ev_cmd_status {
497 __u8 status;
498 __u8 num_hci_cmd_pkts;
499 __le16 status_opcode;
500} __packed;
501
502struct hci_ev_srch_st {
503 __le32 station_freq;
504 __u8 rds_cap;
505 __u8 pty;
506 __le16 status_opcode;
507} __packed;
508
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700509struct hci_ev_rel_freq {
510 __u8 rel_freq_msb;
511 __u8 rel_freq_lsb;
512
513} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700514struct hci_ev_srch_list_compl {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700515 __u8 num_stations_found;
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700516 struct hci_ev_rel_freq rel_freq[20];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700517} __packed;
518
519/* ----- HCI Event Response ----- */
520struct hci_fm_conf_rsp {
521 __u8 status;
522 struct hci_fm_recv_conf_req recv_conf_rsp;
523} __packed;
524
Srinivasa Rao Uppalac5320c22011-11-28 14:28:51 +0530525struct hci_fm_get_trans_conf_rsp {
526 __u8 status;
527 struct hci_fm_trans_conf_req_struct trans_conf_rsp;
528} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700529struct hci_fm_sig_threshold_rsp {
530 __u8 status;
531 __u8 sig_threshold;
532} __packed;
533
534struct hci_fm_station_rsp {
535 struct hci_ev_tune_status station_rsp;
536} __packed;
537
538struct hci_fm_prgm_srv_rsp {
539 __u8 status;
540 struct hci_ev_prg_service prg_srv;
541} __packed;
542
543struct hci_fm_radio_txt_rsp {
544 __u8 status;
545 struct hci_ev_radio_text rd_txt;
546} __packed;
547
548struct hci_fm_af_list_rsp {
549 __u8 status;
550 struct hci_ev_af_list rd_txt;
551} __packed;
552
553struct hci_fm_data_rd_rsp {
554 __u8 status;
555 __u8 ret_data_len;
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530556 __u8 data[DEFAULT_DATA_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700557} __packed;
558
559struct hci_fm_feature_list_rsp {
560 __u8 status;
561 __u8 feature_mask;
562} __packed;
563
564struct hci_fm_dbg_param_rsp {
565 __u8 status;
566 __u8 blend;
567 __u8 soft_mute;
568 __u8 inf_blend;
569 __u8 inf_soft_mute;
570 __u8 pilot_pil;
571 __u8 io_verc;
572 __u8 in_det_out;
573} __packed;
574
Anantha Krishnanf950e322012-06-06 14:25:49 +0530575#define CLKSPURID_INDEX0 0
576#define CLKSPURID_INDEX1 5
577#define CLKSPURID_INDEX2 10
578#define CLKSPURID_INDEX3 15
579#define CLKSPURID_INDEX4 20
580#define CLKSPURID_INDEX5 25
581
582#define MAX_SPUR_FREQ_LIMIT 30
583#define CKK_SPUR 0x3B
584#define SPUR_DATA_SIZE 0x4
585#define SPUR_ENTRIES_PER_ID 0x5
586
587#define COMPUTE_SPUR(val) ((((val) - (76000)) / (50)))
588#define GET_FREQ(val, bit) ((bit == 1) ? ((val) >> 8) : ((val) & 0xFF))
589#define GET_SPUR_ENTRY_LEVEL(val) ((val) / (5))
590
591struct hci_fm_spur_data {
592 __u32 freq[MAX_SPUR_FREQ_LIMIT];
593 __s8 rmssi[MAX_SPUR_FREQ_LIMIT];
594 __u8 enable[MAX_SPUR_FREQ_LIMIT];
595} __packed;
596
597
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700598/* HCI dev events */
599#define RADIO_HCI_DEV_REG 1
600#define RADIO_HCI_DEV_WRITE 2
601
602#define hci_req_lock(d) mutex_lock(&d->req_lock)
603#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
604
Ankur Nandwani78a782b2011-07-07 21:11:21 -0700605/* FM RDS */
Ankur Nandwani42462512011-07-15 17:08:24 -0700606#define RDS_PTYPE 2
607#define RDS_PID_LOWER 1
608#define RDS_PID_HIGHER 0
Ankur Nandwani78a782b2011-07-07 21:11:21 -0700609#define RDS_OFFSET 5
610#define RDS_PS_LENGTH_OFFSET 7
611#define RDS_STRING 8
612#define RDS_PS_DATA_OFFSET 8
Srinivasa Rao Uppala58273f82011-08-10 19:07:45 -0700613#define RDS_CONFIG_OFFSET 3
Srinivasa Rao Uppala3c7a8eb2011-09-18 09:10:21 +0530614#define RDS_AF_JUMP_OFFSET 4
615#define PI_CODE_OFFSET 4
616#define AF_SIZE_OFFSET 6
617#define AF_LIST_OFFSET 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700618/*FM states*/
619
620enum radio_state_t {
621 FM_OFF,
622 FM_RECV,
623 FM_TRANS,
624 FM_RESET,
Ayaz Ahmadc1e6a952012-05-15 19:29:54 +0530625 FM_CALIB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700626};
627
Ankur Nandwanid928d542011-08-11 13:15:41 -0700628enum emphasis_type {
629 FM_RX_EMP75 = 0x0,
630 FM_RX_EMP50 = 0x1
631};
632
633enum channel_space_type {
634 FM_RX_SPACE_200KHZ = 0x0,
635 FM_RX_SPACE_100KHZ = 0x1,
636 FM_RX_SPACE_50KHZ = 0x2
637};
638
639enum high_low_injection {
640 AUTO_HI_LO_INJECTION = 0x0,
641 LOW_SIDE_INJECTION = 0x1,
642 HIGH_SIDE_INJECTION = 0x2
643};
644
645enum fm_rds_type {
646 FM_RX_RDBS_SYSTEM = 0x0,
647 FM_RX_RDS_SYSTEM = 0x1
648};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700649
650enum iris_region_t {
651 IRIS_REGION_US,
652 IRIS_REGION_EU,
653 IRIS_REGION_JAPAN,
654 IRIS_REGION_JAPAN_WIDE,
655 IRIS_REGION_OTHER
656};
657
Ayaz Ahmad89265112012-10-05 19:39:11 +0530658#define STD_BUF_SIZE (256)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700659
660enum iris_buf_t {
661 IRIS_BUF_SRCH_LIST,
662 IRIS_BUF_EVENTS,
663 IRIS_BUF_RT_RDS,
664 IRIS_BUF_PS_RDS,
665 IRIS_BUF_RAW_RDS,
666 IRIS_BUF_AF_LIST,
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700667 IRIS_BUF_PEEK,
668 IRIS_BUF_SSBI_PEEK,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530669 IRIS_BUF_RDS_CNTRS,
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530670 IRIS_BUF_RD_DEFAULT,
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530671 IRIS_BUF_CAL_DATA,
Ayaz Ahmad89265112012-10-05 19:39:11 +0530672 IRIS_BUF_RT_PLUS,
673 IRIS_BUF_ERT,
674 IRIS_BUF_MAX,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700675};
676
677enum iris_xfr_t {
678 IRIS_XFR_SYNC,
679 IRIS_XFR_ERROR,
680 IRIS_XFR_SRCH_LIST,
681 IRIS_XFR_RT_RDS,
682 IRIS_XFR_PS_RDS,
683 IRIS_XFR_AF_LIST,
684 IRIS_XFR_MAX
685};
686
687#undef FMDBG
688#ifdef FM_DEBUG
689#define FMDBG(fmt, args...) pr_info("iris_radio: " fmt, ##args)
690#else
691#define FMDBG(fmt, args...)
692#endif
693
694#undef FMDERR
695#define FMDERR(fmt, args...) pr_err("iris_radio: " fmt, ##args)
696
697/* Search options */
698enum search_t {
699 SEEK,
700 SCAN,
701 SCAN_FOR_STRONG,
702 SCAN_FOR_WEAK,
703 RDS_SEEK_PTY,
704 RDS_SCAN_PTY,
705 RDS_SEEK_PI,
706 RDS_AF_JUMP,
707};
708
Anantha Krishnanf950e322012-06-06 14:25:49 +0530709enum spur_entry_levels {
710 ENTRY_0,
711 ENTRY_1,
712 ENTRY_2,
713 ENTRY_3,
714 ENTRY_4,
715 ENTRY_5,
716};
Ankur Nandwanid928d542011-08-11 13:15:41 -0700717
718/* Band limits */
719#define REGION_US_EU_BAND_LOW 87500
Ayaz Ahmadb69202b2012-02-23 19:24:46 +0530720#define REGION_US_EU_BAND_HIGH 108000
Ankur Nandwanid928d542011-08-11 13:15:41 -0700721#define REGION_JAPAN_STANDARD_BAND_LOW 76000
722#define REGION_JAPAN_STANDARD_BAND_HIGH 90000
723#define REGION_JAPAN_WIDE_BAND_LOW 90000
724#define REGION_JAPAN_WIDE_BAND_HIGH 108000
725
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700726#define SRCH_MODE 0x07
727#define SRCH_DIR 0x08 /* 0-up 1-down */
728#define SCAN_DWELL 0x70
729#define SRCH_ON 0x80
730
731/* I/O Control */
732#define IOC_HRD_MUTE 0x03
733#define IOC_SFT_MUTE 0x01
734#define IOC_MON_STR 0x01
735#define IOC_SIG_BLND 0x01
736#define IOC_INTF_BLND 0x01
737#define IOC_ANTENNA 0x01
738
739/* RDS Control */
740#define RDS_ON 0x01
741#define RDS_BUF_SZ 100
742
Ankur Nandwanid928d542011-08-11 13:15:41 -0700743/* constants */
744#define RDS_BLOCKS_NUM (4)
745#define BYTES_PER_BLOCK (3)
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530746#define MAX_PS_LENGTH (108)
Ankur Nandwanid928d542011-08-11 13:15:41 -0700747#define MAX_RT_LENGTH (64)
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530748#define RDS_GRP_CNTR_LEN (36)
Srinivasa Rao Uppala69839842012-01-13 18:36:12 +0530749#define RX_RT_DATA_LENGTH (63)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700750/* Search direction */
751#define SRCH_DIR_UP (0)
752#define SRCH_DIR_DOWN (1)
753
Srinivasa Rao Uppala7bb22102011-07-14 11:27:30 -0700754/*Search RDS stations*/
755#define SEARCH_RDS_STNS_MODE_OFFSET 4
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700756
757/*Search Station list */
Srinivasa Rao Uppala4b92e4b2011-08-09 15:46:25 -0700758#define PARAMS_PER_STATION 0x08
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700759#define STN_NUM_OFFSET 0x01
760#define STN_FREQ_OFFSET 0x02
761#define KHZ_TO_MHZ 1000
762#define GET_MSB(x)((x >> 8) & 0xFF)
763#define GET_LSB(x)((x) & 0xFF)
764
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700765/* control options */
766#define CTRL_ON (1)
767#define CTRL_OFF (0)
768
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700769/*Diagnostic commands*/
770
771#define RIVA_PEEK_OPCODE 0x0D
772#define RIVA_POKE_OPCODE 0x0C
773
774#define PEEK_DATA_OFSET 0x1
775#define RIVA_PEEK_PARAM 0x6
776#define RIVA_PEEK_LEN_OFSET 0x6
777#define SSBI_PEEK_LEN 0x01
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530778/*Calibration data*/
779#define PROCS_CALIB_MODE 1
780#define PROCS_CALIB_SIZE 23
781#define DC_CALIB_MODE 2
782#define DC_CALIB_SIZE 48
783#define RSB_CALIB_MODE 3
784#define RSB_CALIB_SIZE 4
785#define CALIB_DATA_OFSET 2
786#define CALIB_MODE_OFSET 1
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530787#define MAX_CALIB_SIZE 75
Ayaz Ahmad37294ba2012-07-10 16:38:11 +0530788
789/* Channel validity */
790#define INVALID_CHANNEL (0)
791#define VALID_CHANNEL (1)
792
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530793struct hci_fm_set_cal_req_proc {
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530794 __u8 mode;
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530795 /*Max process calibration data size*/
796 __u8 data[PROCS_CALIB_SIZE];
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530797} __packed;
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530798
799struct hci_fm_set_cal_req_dc {
800 __u8 mode;
801 /*Max DC calibration data size*/
802 __u8 data[DC_CALIB_SIZE];
803} __packed;
804
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530805struct hci_cc_do_calibration_rsp {
806 __u8 status;
807 __u8 mode;
808 __u8 data[MAX_CALIB_SIZE];
809} __packed;
Srinivasa Rao Uppalaf856ae62011-10-17 18:43:26 +0530810
811/* Low Power mode*/
812#define SIG_LEVEL_INTR (1 << 0)
813#define RDS_SYNC_INTR (1 << 1)
814#define AUDIO_CTRL_INTR (1 << 2)
815#define AF_JUMP_ENABLE (1 << 4)
Anantha Krishnanf950e322012-06-06 14:25:49 +0530816
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700817int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
818 struct radio_hci_dev *hdev);
819int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
820 struct radio_hci_dev *hdev);
821int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
822int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700823
824#endif /* __RADIO_HCI_CORE_H */