blob: 518dfb183c3ca51177d77c14b58fcd7cb4bff4c6 [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"
Ayaz Ahmad905c01d2013-12-19 18:39:57 +053035const unsigned char MIN_TX_TONE_VAL = 0x00;
36const unsigned char MAX_TX_TONE_VAL = 0x07;
37const unsigned char MIN_HARD_MUTE_VAL = 0x00;
38const unsigned char MAX_HARD_MUTE_VAL = 0x03;
39const unsigned char MIN_SRCH_MODE = 0x00;
Satish Kodishalaedbad932014-01-09 16:58:32 +053040const unsigned char MAX_SRCH_MODE = 0x09;
Ayaz Ahmad905c01d2013-12-19 18:39:57 +053041const unsigned char MIN_SCAN_DWELL = 0x00;
42const unsigned char MAX_SCAN_DWELL = 0x0F;
43const unsigned char MIN_SIG_TH = 0x00;
44const unsigned char MAX_SIG_TH = 0x03;
45const unsigned char MIN_PTY = 0X00;
46const unsigned char MAX_PTY = 0x1F;
47const unsigned short MIN_PI = 0x0000;
48const unsigned short MAX_PI = 0xFFFF;
49const unsigned char MIN_SRCH_STATIONS_CNT = 0x00;
50const unsigned char MAX_SRCH_STATIONS_CNT = 0x14;
51const unsigned char MIN_CHAN_SPACING = 0x00;
52const unsigned char MAX_CHAN_SPACING = 0x02;
53const unsigned char MIN_EMPHASIS = 0x00;
54const unsigned char MAX_EMPHASIS = 0x01;
55const unsigned char MIN_RDS_STD = 0x00;
56const unsigned char MAX_RDS_STD = 0x02;
57const unsigned char MIN_ANTENNA_VAL = 0x00;
58const unsigned char MAX_ANTENNA_VAL = 0x01;
59const unsigned char MIN_TX_PS_REPEAT_CNT = 0x01;
60const unsigned char MAX_TX_PS_REPEAT_CNT = 0x0F;
61const unsigned char MIN_SOFT_MUTE = 0x00;
62const unsigned char MAX_SOFT_MUTE = 0x01;
63const unsigned char MIN_PEEK_ACCESS_LEN = 0x01;
64const unsigned char MAX_PEEK_ACCESS_LEN = 0xF9;
65const unsigned char MIN_RESET_CNTR = 0x00;
66const unsigned char MAX_RESET_CNTR = 0x01;
67const unsigned char MIN_HLSI = 0x00;
68const unsigned char MAX_HLSI = 0x02;
69const unsigned char MIN_NOTCH_FILTER = 0x00;
70const unsigned char MAX_NOTCH_FILTER = 0x02;
71const unsigned char MIN_INTF_DET_OUT_LW_TH = 0x00;
72const unsigned char MAX_INTF_DET_OUT_LW_TH = 0xFF;
73const unsigned char MIN_INTF_DET_OUT_HG_TH = 0x00;
74const unsigned char MAX_INTF_DET_OUT_HG_TH = 0xFF;
75const signed char MIN_SINR_TH = -128;
76const signed char MAX_SINR_TH = 127;
77const unsigned char MIN_SINR_SAMPLES = 0x01;
78const unsigned char MAX_SINR_SAMPLES = 0xFF;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079
80/* ---- HCI Packet structures ---- */
81#define RADIO_HCI_COMMAND_HDR_SIZE sizeof(struct radio_hci_command_hdr)
82#define RADIO_HCI_EVENT_HDR_SIZE sizeof(struct radio_hci_event_hdr)
83
84/* HCI data types */
85#define RADIO_HCI_COMMAND_PKT 0x11
86#define RADIO_HCI_EVENT_PKT 0x14
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -070087/*HCI reponce packets*/
88#define MAX_RIVA_PEEK_RSP_SIZE 251
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +053089/* default data access */
90#define DEFAULT_DATA_OFFSET 2
91#define DEFAULT_DATA_SIZE 249
Venkateshwarlu Domakonda71731d52012-04-04 12:30:51 +053092/* Power levels are 0-7, but SOC will expect values from 0-255
93 * So the each level step size will be 255/7 = 36 */
94#define FM_TX_PWR_LVL_STEP_SIZE 36
95#define FM_TX_PWR_LVL_0 0 /* Lowest power lvl that can be set for Tx */
96#define FM_TX_PWR_LVL_MAX 7 /* Max power lvl for Tx */
97#define FM_TX_PHY_CFG_MODE 0x3c
98#define FM_TX_PHY_CFG_LEN 0x10
99#define FM_TX_PWR_GAIN_OFFSET 14
Ayaz Ahmaddb04b0c2013-02-01 17:18:34 +0530100/**RDS CONFIG MODE**/
101#define FM_RDS_CNFG_MODE 0x0f
102#define FM_RDS_CNFG_LEN 0x10
103#define AF_RMSSI_TH_LSB_OFFSET 10
104#define AF_RMSSI_TH_MSB_OFFSET 11
105#define AF_RMSSI_SAMPLES_OFFSET 15
106/**RX CONFIG MODE**/
107#define FM_RX_CONFG_MODE 0x15
108#define FM_RX_CNFG_LEN 0x20
109#define GD_CH_RMSSI_TH_OFFSET 12
110#define MAX_GD_CH_RMSSI_TH 127
111#define SRCH_ALGO_TYPE_OFFSET 25
112#define SINRFIRSTSTAGE_OFFSET 26
113#define RMSSIFIRSTSTAGE_OFFSET 27
114#define CF0TH12_BYTE1_OFFSET 8
115#define CF0TH12_BYTE2_OFFSET 9
116#define CF0TH12_BYTE3_OFFSET 10
117#define CF0TH12_BYTE4_OFFSET 11
118#define MAX_SINR_FIRSTSTAGE 127
119#define MAX_RMSSI_FIRSTSTAGE 127
Venkateshwarlu Domakonda70e47162013-04-30 14:12:13 +0530120#define RDS_PS0_XFR_MODE 0x01
121#define RDS_PS0_LEN 6
122#define RX_REPEATE_BYTE_OFFSET 5
Ayaz Ahmaddb04b0c2013-02-01 17:18:34 +0530123
Venkateshwarlu Domakondae8a4187c2013-06-25 18:56:54 +0530124#define FM_AF_LIST_MAX_SIZE 200
125#define AF_LIST_MAX (FM_AF_LIST_MAX_SIZE / 4) /* Each AF frequency consist
126 of sizeof(int) bytes */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700127/* HCI timeouts */
128#define RADIO_HCI_TIMEOUT (10000) /* 10 seconds */
129
130#define TUNE_PARAM 16
131struct radio_hci_command_hdr {
132 __le16 opcode; /* OCF & OGF */
133 __u8 plen;
134} __packed;
135
136struct radio_hci_event_hdr {
137 __u8 evt;
138 __u8 plen;
139} __packed;
140
141struct radio_hci_dev {
142 char name[8];
143 unsigned long flags;
144 __u16 id;
145 __u8 bus;
146 __u8 dev_type;
147 __u8 dev_name[248];
148 __u8 dev_class[3];
149 __u8 features[8];
150 __u8 commands[64];
151
152 unsigned int data_block_len;
153 unsigned long cmd_last_tx;
154
155 struct sk_buff *sent_cmd;
156
157 __u32 req_status;
158 __u32 req_result;
159 atomic_t cmd_cnt;
160
161 struct tasklet_struct cmd_task;
162 struct tasklet_struct rx_task;
163 struct tasklet_struct tx_task;
164
165 struct sk_buff_head rx_q;
166 struct sk_buff_head raw_q;
167 struct sk_buff_head cmd_q;
168
169 struct mutex req_lock;
170 wait_queue_head_t req_wait_q;
171
172 int (*open)(struct radio_hci_dev *hdev);
173 int (*close)(struct radio_hci_dev *hdev);
174 int (*flush)(struct radio_hci_dev *hdev);
175 int (*send)(struct sk_buff *skb);
176 void (*destruct)(struct radio_hci_dev *hdev);
177 void (*notify)(struct radio_hci_dev *hdev, unsigned int evt);
178};
179
180int radio_hci_register_dev(struct radio_hci_dev *hdev);
181int radio_hci_unregister_dev(struct radio_hci_dev *hdev);
182int radio_hci_recv_frame(struct sk_buff *skb);
183int radio_hci_send_cmd(struct radio_hci_dev *hdev, __u16 opcode, __u32 plen,
184 void *param);
185void radio_hci_event_packet(struct radio_hci_dev *hdev, struct sk_buff *skb);
186
187/* Opcode OCF */
188/* HCI recv control commands opcode */
189#define HCI_OCF_FM_ENABLE_RECV_REQ 0x0001
190#define HCI_OCF_FM_DISABLE_RECV_REQ 0x0002
191#define HCI_OCF_FM_GET_RECV_CONF_REQ 0x0003
192#define HCI_OCF_FM_SET_RECV_CONF_REQ 0x0004
193#define HCI_OCF_FM_SET_MUTE_MODE_REQ 0x0005
194#define HCI_OCF_FM_SET_STEREO_MODE_REQ 0x0006
195#define HCI_OCF_FM_SET_ANTENNA 0x0007
196#define HCI_OCF_FM_SET_SIGNAL_THRESHOLD 0x0008
197#define HCI_OCF_FM_GET_SIGNAL_THRESHOLD 0x0009
198#define HCI_OCF_FM_GET_STATION_PARAM_REQ 0x000A
199#define HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ 0x000B
200#define HCI_OCF_FM_GET_RADIO_TEXT_REQ 0x000C
201#define HCI_OCF_FM_GET_AF_LIST_REQ 0x000D
202#define HCI_OCF_FM_SEARCH_STATIONS 0x000E
203#define HCI_OCF_FM_SEARCH_RDS_STATIONS 0x000F
204#define HCI_OCF_FM_SEARCH_STATIONS_LIST 0x0010
205#define HCI_OCF_FM_CANCEL_SEARCH 0x0011
206#define HCI_OCF_FM_RDS_GRP 0x0012
207#define HCI_OCF_FM_RDS_GRP_PROCESS 0x0013
208#define HCI_OCF_FM_EN_WAN_AVD_CTRL 0x0014
209#define HCI_OCF_FM_EN_NOTCH_CTRL 0x0015
Srinivasa Rao Uppalaf856ae62011-10-17 18:43:26 +0530210#define HCI_OCF_FM_SET_EVENT_MASK 0x0016
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530211#define HCI_OCF_FM_SET_CH_DET_THRESHOLD 0x0017
212#define HCI_OCF_FM_GET_CH_DET_THRESHOLD 0x0018
Ankur Nandwanid928d542011-08-11 13:15:41 -0700213/* HCI trans control commans opcode*/
214#define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001
215#define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002
216#define HCI_OCF_FM_GET_TRANS_CONF_REQ 0x0003
217#define HCI_OCF_FM_SET_TRANS_CONF_REQ 0x0004
218#define HCI_OCF_FM_RDS_RT_REQ 0x0008
219#define HCI_OCF_FM_RDS_PS_REQ 0x0009
220
221
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700222/* HCI common control commands opcode */
223#define HCI_OCF_FM_TUNE_STATION_REQ 0x0001
224#define HCI_OCF_FM_DEFAULT_DATA_READ 0x0002
225#define HCI_OCF_FM_DEFAULT_DATA_WRITE 0x0003
226#define HCI_OCF_FM_RESET 0x0004
227#define HCI_OCF_FM_GET_FEATURE_LIST 0x0005
228#define HCI_OCF_FM_DO_CALIBRATION 0x0006
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530229#define HCI_OCF_FM_SET_CALIBRATION 0x0007
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700230
231/*HCI Status parameters commands*/
232#define HCI_OCF_FM_READ_GRP_COUNTERS 0x0001
233
234/*HCI Diagnostic commands*/
235#define HCI_OCF_FM_PEEK_DATA 0x0002
236#define HCI_OCF_FM_POKE_DATA 0x0003
237#define HCI_OCF_FM_SSBI_PEEK_REG 0x0004
238#define HCI_OCF_FM_SSBI_POKE_REG 0x0005
239#define HCI_OCF_FM_STATION_DBG_PARAM 0x0007
Ankur Nandwanid928d542011-08-11 13:15:41 -0700240#define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700241
242/* Opcode OGF */
243#define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013
Ankur Nandwanid928d542011-08-11 13:15:41 -0700244#define HCI_OGF_FM_TRANS_CTRL_CMD_REQ 0x0014
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700245#define HCI_OGF_FM_COMMON_CTRL_CMD_REQ 0x0015
246#define HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ 0x0016
247#define HCI_OGF_FM_TEST_CMD_REQ 0x0017
248#define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F
249
250/* Command opcode pack/unpack */
251#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
252#define hci_opcode_ogf(op) (op >> 10)
253#define hci_opcode_ocf(op) (op & 0x03ff)
254#define hci_recv_ctrl_cmd_op_pack(ocf) \
255 (__u16) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf)
Ankur Nandwanid928d542011-08-11 13:15:41 -0700256#define hci_trans_ctrl_cmd_op_pack(ocf) \
257 (__u16) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700258#define hci_common_cmd_op_pack(ocf) \
259 (__u16) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf)
260#define hci_status_param_op_pack(ocf) \
261 (__u16) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf)
262#define hci_diagnostic_cmd_op_pack(ocf) \
263 (__u16) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf)
264
265
266/* HCI commands with no arguments*/
267#define HCI_FM_ENABLE_RECV_CMD 1
268#define HCI_FM_DISABLE_RECV_CMD 2
269#define HCI_FM_GET_RECV_CONF_CMD 3
270#define HCI_FM_GET_STATION_PARAM_CMD 4
271#define HCI_FM_GET_SIGNAL_TH_CMD 5
272#define HCI_FM_GET_PROGRAM_SERVICE_CMD 6
273#define HCI_FM_GET_RADIO_TEXT_CMD 7
274#define HCI_FM_GET_AF_LIST_CMD 8
275#define HCI_FM_CANCEL_SEARCH_CMD 9
276#define HCI_FM_RESET_CMD 10
277#define HCI_FM_GET_FEATURES_CMD 11
278#define HCI_FM_STATION_DBG_PARAM_CMD 12
Ankur Nandwanid928d542011-08-11 13:15:41 -0700279#define HCI_FM_ENABLE_TRANS_CMD 13
280#define HCI_FM_DISABLE_TRANS_CMD 14
Srinivasa Rao Uppalac5320c22011-11-28 14:28:51 +0530281#define HCI_FM_GET_TX_CONFIG 15
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530282#define HCI_FM_GET_DET_CH_TH_CMD 16
Ankur Nandwanid928d542011-08-11 13:15:41 -0700283
284/* Defines for FM TX*/
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530285#define TX_PS_DATA_LENGTH 108
Ankur Nandwanid928d542011-08-11 13:15:41 -0700286#define TX_RT_DATA_LENGTH 64
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530287#define PS_STRING_LEN 9
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700288
289/* ----- HCI Command request ----- */
290struct hci_fm_recv_conf_req {
291 __u8 emphasis;
292 __u8 ch_spacing;
293 __u8 rds_std;
294 __u8 hlsi;
295 __u32 band_low_limit;
296 __u32 band_high_limit;
297} __packed;
298
Ankur Nandwanid928d542011-08-11 13:15:41 -0700299/* ----- HCI Command request ----- */
300struct hci_fm_trans_conf_req_struct {
301 __u8 emphasis;
302 __u8 rds_std;
303 __u32 band_low_limit;
304 __u32 band_high_limit;
305} __packed;
306
307
308/* ----- HCI Command request ----- */
309struct hci_fm_tx_ps {
310 __u8 ps_control;
311 __u16 pi;
312 __u8 pty;
313 __u8 ps_repeatcount;
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530314 __u8 ps_num;
Ankur Nandwanid928d542011-08-11 13:15:41 -0700315 __u8 ps_data[TX_PS_DATA_LENGTH];
316} __packed;
317
318struct hci_fm_tx_rt {
319 __u8 rt_control;
320 __u16 pi;
321 __u8 pty;
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530322 __u8 rt_len;
Ankur Nandwanid928d542011-08-11 13:15:41 -0700323 __u8 rt_data[TX_RT_DATA_LENGTH];
324} __packed;
325
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700326struct hci_fm_mute_mode_req {
327 __u8 hard_mute;
328 __u8 soft_mute;
329} __packed;
330
331struct hci_fm_stereo_mode_req {
332 __u8 stereo_mode;
333 __u8 sig_blend;
334 __u8 intf_blend;
335 __u8 most_switch;
336} __packed;
337
338struct hci_fm_search_station_req {
339 __u8 srch_mode;
340 __u8 scan_time;
341 __u8 srch_dir;
342} __packed;
343
344struct hci_fm_search_rds_station_req {
345 struct hci_fm_search_station_req srch_station;
346 __u8 srch_pty;
347 __u16 srch_pi;
348} __packed;
349
350struct hci_fm_search_station_list_req {
351 __u8 srch_list_mode;
352 __u8 srch_list_dir;
353 __u32 srch_list_max;
354 __u8 srch_pty;
355} __packed;
356
357struct hci_fm_rds_grp_req {
358 __u32 rds_grp_enable_mask;
359 __u32 rds_buf_size;
360 __u8 en_rds_change_filter;
361} __packed;
362
363struct hci_fm_en_avd_ctrl_req {
364 __u8 no_freqs;
365 __u8 freq_index;
366 __u8 lo_shft;
367 __u16 freq_min;
368 __u16 freq_max;
369} __packed;
370
371struct hci_fm_def_data_rd_req {
372 __u8 mode;
373 __u8 length;
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530374 __u8 param_len;
375 __u8 param;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700376} __packed;
377
378struct hci_fm_def_data_wr_req {
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530379 __u8 mode;
380 __u8 length;
381 __u8 data[DEFAULT_DATA_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700382} __packed;
383
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700384struct hci_fm_riva_data {
385 __u8 subopcode;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700386 __u32 start_addr;
387 __u8 length;
388} __packed;
389
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700390struct hci_fm_riva_poke {
391 struct hci_fm_riva_data cmd_params;
392 __u8 data[MAX_RIVA_PEEK_RSP_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700393} __packed;
394
395struct hci_fm_ssbi_req {
396 __u16 start_addr;
397 __u8 data;
398} __packed;
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700399struct hci_fm_ssbi_peek {
400 __u16 start_address;
401} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700402
Srinivasa Rao Uppalad3184a42012-01-04 21:18:01 +0530403struct hci_fm_ch_det_threshold {
404 char sinr;
405 __u8 sinr_samples;
406 __u8 low_th;
407 __u8 high_th;
408
409} __packed;
410
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700411/*HCI events*/
412#define HCI_EV_TUNE_STATUS 0x01
413#define HCI_EV_RDS_LOCK_STATUS 0x02
414#define HCI_EV_STEREO_STATUS 0x03
415#define HCI_EV_SERVICE_AVAILABLE 0x04
416#define HCI_EV_SEARCH_PROGRESS 0x05
417#define HCI_EV_SEARCH_RDS_PROGRESS 0x06
418#define HCI_EV_SEARCH_LIST_PROGRESS 0x07
419#define HCI_EV_RDS_RX_DATA 0x08
420#define HCI_EV_PROGRAM_SERVICE 0x09
421#define HCI_EV_RADIO_TEXT 0x0A
422#define HCI_EV_FM_AF_LIST 0x0B
423#define HCI_EV_TX_RDS_GRP_AVBLE 0x0C
424#define HCI_EV_TX_RDS_GRP_COMPL 0x0D
425#define HCI_EV_TX_RDS_CONT_GRP_COMPL 0x0E
426#define HCI_EV_CMD_COMPLETE 0x0F
427#define HCI_EV_CMD_STATUS 0x10
428#define HCI_EV_TUNE_COMPLETE 0x11
429#define HCI_EV_SEARCH_COMPLETE 0x12
430#define HCI_EV_SEARCH_RDS_COMPLETE 0x13
431#define HCI_EV_SEARCH_LIST_COMPLETE 0x14
432
433#define HCI_REQ_DONE 0
434#define HCI_REQ_PEND 1
435#define HCI_REQ_CANCELED 2
436#define HCI_REQ_STATUS 3
437
Ayaz Ahmad89265112012-10-05 19:39:11 +0530438#define MAX_RAW_RDS_GRPS 21
439
440#define RDSGRP_DATA_OFFSET 0x1
441
442/*RT PLUS*/
443#define DUMMY_CLASS 0
444#define RT_PLUS_LEN_1_TAG 3
445#define RT_ERT_FLAG_BIT 5
446
447/*TAG1*/
448#define TAG1_MSB_OFFSET 3
449#define TAG1_MSB_MASK 7
450#define TAG1_LSB_OFFSET 5
451#define TAG1_POS_MSB_MASK 31
452#define TAG1_POS_MSB_OFFSET 1
453#define TAG1_POS_LSB_OFFSET 7
454#define TAG1_LEN_OFFSET 1
455#define TAG1_LEN_MASK 63
456
457/*TAG2*/
458#define TAG2_MSB_OFFSET 5
459#define TAG2_MSB_MASK 1
460#define TAG2_LSB_OFFSET 3
461#define TAG2_POS_MSB_MASK 7
462#define TAG2_POS_MSB_OFFSET 3
463#define TAG2_POS_LSB_OFFSET 5
464#define TAG2_LEN_MASK 31
465
466#define AGT_MASK 31
467/*Extract 5 left most bits of lsb of 2nd block*/
468#define AGT(x) (x & AGT_MASK)
469/*16 bits of 4th block*/
470#define AID(lsb, msb) ((msb << 8) | (lsb))
471/*Extract 5 right most bits of msb of 2nd block*/
472#define GTC(blk2msb) (blk2msb >> 3)
473
474#define GRP_3A 0x6
475#define RT_PLUS_AID 0x4bd7
476
477/*ERT*/
478#define ERT_AID 0x6552
479#define CARRIAGE_RETURN 0x000D
480#define MAX_ERT_SEGMENT 31
481#define ERT_FORMAT_DIR_BIT 1
482
483#define EXTRACT_BIT(data, bit_pos) ((data & (1 << bit_pos)) >> bit_pos)
484
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700485struct hci_ev_tune_status {
486 __u8 sub_event;
487 __le32 station_freq;
488 __u8 serv_avble;
489 __u8 rssi;
490 __u8 stereo_prg;
491 __u8 rds_sync_status;
492 __u8 mute_mode;
Srinivasa Rao Uppalaacdebcc2011-12-23 14:31:38 +0530493 char sinr;
494 __u8 intf_det_th;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700495} __packed;
496
Ayaz Ahmad89265112012-10-05 19:39:11 +0530497struct rds_blk_data {
498 __u8 rdsMsb;
499 __u8 rdsLsb;
500 __u8 blockStatus;
501} __packed;
502
503struct rds_grp_data {
504 struct rds_blk_data rdsBlk[4];
505} __packed;
506
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700507struct hci_ev_rds_rx_data {
508 __u8 num_rds_grps;
Ayaz Ahmad89265112012-10-05 19:39:11 +0530509 struct rds_grp_data rds_grp_data[MAX_RAW_RDS_GRPS];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700510} __packed;
511
512struct hci_ev_prg_service {
513 __le16 pi_prg_id;
514 __u8 pty_prg_type;
515 __u8 ta_prg_code_type;
516 __u8 ta_ann_code_flag;
517 __u8 ms_switch_code_flag;
518 __u8 dec_id_ctrl_code_flag;
519 __u8 ps_num;
520 __u8 prg_service_name[119];
521} __packed;
522
523struct hci_ev_radio_text {
524 __le16 pi_prg_id;
525 __u8 pty_prg_type;
526 __u8 ta_prg_code_type;
527 __u8 txt_ab_flag;
528 __u8 radio_txt[64];
529} __packed;
530
531struct hci_ev_af_list {
532 __le32 tune_freq;
533 __le16 pi_code;
534 __u8 af_size;
Venkateshwarlu Domakondae8a4187c2013-06-25 18:56:54 +0530535 __u8 af_list[FM_AF_LIST_MAX_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700536} __packed;
537
538struct hci_ev_cmd_complete {
539 __u8 num_hci_cmd_pkts;
540 __le16 cmd_opcode;
541} __packed;
542
543struct hci_ev_cmd_status {
544 __u8 status;
545 __u8 num_hci_cmd_pkts;
546 __le16 status_opcode;
547} __packed;
548
549struct hci_ev_srch_st {
550 __le32 station_freq;
551 __u8 rds_cap;
552 __u8 pty;
553 __le16 status_opcode;
554} __packed;
555
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700556struct hci_ev_rel_freq {
557 __u8 rel_freq_msb;
558 __u8 rel_freq_lsb;
559
560} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700561struct hci_ev_srch_list_compl {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700562 __u8 num_stations_found;
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700563 struct hci_ev_rel_freq rel_freq[20];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700564} __packed;
565
566/* ----- HCI Event Response ----- */
567struct hci_fm_conf_rsp {
568 __u8 status;
569 struct hci_fm_recv_conf_req recv_conf_rsp;
570} __packed;
571
Srinivasa Rao Uppalac5320c22011-11-28 14:28:51 +0530572struct hci_fm_get_trans_conf_rsp {
573 __u8 status;
574 struct hci_fm_trans_conf_req_struct trans_conf_rsp;
575} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700576struct hci_fm_sig_threshold_rsp {
577 __u8 status;
578 __u8 sig_threshold;
579} __packed;
580
581struct hci_fm_station_rsp {
582 struct hci_ev_tune_status station_rsp;
583} __packed;
584
585struct hci_fm_prgm_srv_rsp {
586 __u8 status;
587 struct hci_ev_prg_service prg_srv;
588} __packed;
589
590struct hci_fm_radio_txt_rsp {
591 __u8 status;
592 struct hci_ev_radio_text rd_txt;
593} __packed;
594
595struct hci_fm_af_list_rsp {
596 __u8 status;
597 struct hci_ev_af_list rd_txt;
598} __packed;
599
600struct hci_fm_data_rd_rsp {
601 __u8 status;
602 __u8 ret_data_len;
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530603 __u8 data[DEFAULT_DATA_SIZE];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700604} __packed;
605
606struct hci_fm_feature_list_rsp {
607 __u8 status;
608 __u8 feature_mask;
609} __packed;
610
611struct hci_fm_dbg_param_rsp {
612 __u8 status;
613 __u8 blend;
614 __u8 soft_mute;
615 __u8 inf_blend;
616 __u8 inf_soft_mute;
617 __u8 pilot_pil;
618 __u8 io_verc;
619 __u8 in_det_out;
620} __packed;
621
Anantha Krishnanf950e322012-06-06 14:25:49 +0530622#define CLKSPURID_INDEX0 0
623#define CLKSPURID_INDEX1 5
624#define CLKSPURID_INDEX2 10
625#define CLKSPURID_INDEX3 15
626#define CLKSPURID_INDEX4 20
627#define CLKSPURID_INDEX5 25
628
629#define MAX_SPUR_FREQ_LIMIT 30
630#define CKK_SPUR 0x3B
631#define SPUR_DATA_SIZE 0x4
632#define SPUR_ENTRIES_PER_ID 0x5
633
634#define COMPUTE_SPUR(val) ((((val) - (76000)) / (50)))
635#define GET_FREQ(val, bit) ((bit == 1) ? ((val) >> 8) : ((val) & 0xFF))
636#define GET_SPUR_ENTRY_LEVEL(val) ((val) / (5))
637
638struct hci_fm_spur_data {
639 __u32 freq[MAX_SPUR_FREQ_LIMIT];
640 __s8 rmssi[MAX_SPUR_FREQ_LIMIT];
641 __u8 enable[MAX_SPUR_FREQ_LIMIT];
642} __packed;
643
644
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700645/* HCI dev events */
646#define RADIO_HCI_DEV_REG 1
647#define RADIO_HCI_DEV_WRITE 2
648
649#define hci_req_lock(d) mutex_lock(&d->req_lock)
650#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
651
Ankur Nandwani78a782b2011-07-07 21:11:21 -0700652/* FM RDS */
Ankur Nandwani42462512011-07-15 17:08:24 -0700653#define RDS_PTYPE 2
654#define RDS_PID_LOWER 1
655#define RDS_PID_HIGHER 0
Ankur Nandwani78a782b2011-07-07 21:11:21 -0700656#define RDS_OFFSET 5
657#define RDS_PS_LENGTH_OFFSET 7
658#define RDS_STRING 8
659#define RDS_PS_DATA_OFFSET 8
Srinivasa Rao Uppala58273f82011-08-10 19:07:45 -0700660#define RDS_CONFIG_OFFSET 3
Srinivasa Rao Uppala3c7a8eb2011-09-18 09:10:21 +0530661#define RDS_AF_JUMP_OFFSET 4
662#define PI_CODE_OFFSET 4
663#define AF_SIZE_OFFSET 6
664#define AF_LIST_OFFSET 7
Ayaz Ahmade4a0c172013-06-27 17:32:30 +0530665#define RT_A_B_FLAG_OFFSET 4
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700666/*FM states*/
667
668enum radio_state_t {
669 FM_OFF,
670 FM_RECV,
671 FM_TRANS,
672 FM_RESET,
Venkateshwarlu Domakondab750fba2013-06-04 15:19:56 +0530673 FM_CALIB,
Ayaz Ahmad64b1e472013-06-04 15:19:56 +0530674 FM_TURNING_OFF,
675 FM_RECV_TURNING_ON,
676 FM_TRANS_TURNING_ON,
Ayaz Ahmad905c01d2013-12-19 18:39:57 +0530677 FM_MAX_NO_STATES,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700678};
679
Ankur Nandwanid928d542011-08-11 13:15:41 -0700680enum emphasis_type {
681 FM_RX_EMP75 = 0x0,
682 FM_RX_EMP50 = 0x1
683};
684
685enum channel_space_type {
686 FM_RX_SPACE_200KHZ = 0x0,
687 FM_RX_SPACE_100KHZ = 0x1,
688 FM_RX_SPACE_50KHZ = 0x2
689};
690
691enum high_low_injection {
692 AUTO_HI_LO_INJECTION = 0x0,
693 LOW_SIDE_INJECTION = 0x1,
694 HIGH_SIDE_INJECTION = 0x2
695};
696
697enum fm_rds_type {
698 FM_RX_RDBS_SYSTEM = 0x0,
699 FM_RX_RDS_SYSTEM = 0x1
700};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700701
702enum iris_region_t {
703 IRIS_REGION_US,
704 IRIS_REGION_EU,
705 IRIS_REGION_JAPAN,
706 IRIS_REGION_JAPAN_WIDE,
707 IRIS_REGION_OTHER
708};
709
Ayaz Ahmad89265112012-10-05 19:39:11 +0530710#define STD_BUF_SIZE (256)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700711
712enum iris_buf_t {
713 IRIS_BUF_SRCH_LIST,
714 IRIS_BUF_EVENTS,
715 IRIS_BUF_RT_RDS,
716 IRIS_BUF_PS_RDS,
717 IRIS_BUF_RAW_RDS,
718 IRIS_BUF_AF_LIST,
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700719 IRIS_BUF_PEEK,
720 IRIS_BUF_SSBI_PEEK,
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530721 IRIS_BUF_RDS_CNTRS,
Venkateshwarlu Domakonda787af692011-10-14 21:23:03 +0530722 IRIS_BUF_RD_DEFAULT,
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530723 IRIS_BUF_CAL_DATA,
Ayaz Ahmad89265112012-10-05 19:39:11 +0530724 IRIS_BUF_RT_PLUS,
725 IRIS_BUF_ERT,
726 IRIS_BUF_MAX,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700727};
728
729enum iris_xfr_t {
730 IRIS_XFR_SYNC,
731 IRIS_XFR_ERROR,
732 IRIS_XFR_SRCH_LIST,
733 IRIS_XFR_RT_RDS,
734 IRIS_XFR_PS_RDS,
735 IRIS_XFR_AF_LIST,
736 IRIS_XFR_MAX
737};
738
739#undef FMDBG
740#ifdef FM_DEBUG
741#define FMDBG(fmt, args...) pr_info("iris_radio: " fmt, ##args)
742#else
743#define FMDBG(fmt, args...)
744#endif
745
746#undef FMDERR
747#define FMDERR(fmt, args...) pr_err("iris_radio: " fmt, ##args)
748
749/* Search options */
750enum search_t {
751 SEEK,
752 SCAN,
753 SCAN_FOR_STRONG,
754 SCAN_FOR_WEAK,
755 RDS_SEEK_PTY,
756 RDS_SCAN_PTY,
757 RDS_SEEK_PI,
758 RDS_AF_JUMP,
759};
760
Anantha Krishnanf950e322012-06-06 14:25:49 +0530761enum spur_entry_levels {
762 ENTRY_0,
763 ENTRY_1,
764 ENTRY_2,
765 ENTRY_3,
766 ENTRY_4,
767 ENTRY_5,
768};
Ankur Nandwanid928d542011-08-11 13:15:41 -0700769
770/* Band limits */
771#define REGION_US_EU_BAND_LOW 87500
Ayaz Ahmadb69202b2012-02-23 19:24:46 +0530772#define REGION_US_EU_BAND_HIGH 108000
Ankur Nandwanid928d542011-08-11 13:15:41 -0700773#define REGION_JAPAN_STANDARD_BAND_LOW 76000
774#define REGION_JAPAN_STANDARD_BAND_HIGH 90000
775#define REGION_JAPAN_WIDE_BAND_LOW 90000
776#define REGION_JAPAN_WIDE_BAND_HIGH 108000
777
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700778#define SRCH_MODE 0x07
779#define SRCH_DIR 0x08 /* 0-up 1-down */
780#define SCAN_DWELL 0x70
781#define SRCH_ON 0x80
782
783/* I/O Control */
784#define IOC_HRD_MUTE 0x03
785#define IOC_SFT_MUTE 0x01
786#define IOC_MON_STR 0x01
787#define IOC_SIG_BLND 0x01
788#define IOC_INTF_BLND 0x01
789#define IOC_ANTENNA 0x01
790
791/* RDS Control */
792#define RDS_ON 0x01
793#define RDS_BUF_SZ 100
794
Ankur Nandwanid928d542011-08-11 13:15:41 -0700795/* constants */
796#define RDS_BLOCKS_NUM (4)
797#define BYTES_PER_BLOCK (3)
Ayaz Ahmad1c0db522012-08-27 17:52:51 +0530798#define MAX_PS_LENGTH (108)
Ankur Nandwanid928d542011-08-11 13:15:41 -0700799#define MAX_RT_LENGTH (64)
Srinivasa Rao Uppala0f4098f2011-09-06 16:46:28 +0530800#define RDS_GRP_CNTR_LEN (36)
Srinivasa Rao Uppala69839842012-01-13 18:36:12 +0530801#define RX_RT_DATA_LENGTH (63)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802/* Search direction */
803#define SRCH_DIR_UP (0)
804#define SRCH_DIR_DOWN (1)
805
Srinivasa Rao Uppala7bb22102011-07-14 11:27:30 -0700806/*Search RDS stations*/
807#define SEARCH_RDS_STNS_MODE_OFFSET 4
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700808
809/*Search Station list */
Srinivasa Rao Uppala4b92e4b2011-08-09 15:46:25 -0700810#define PARAMS_PER_STATION 0x08
Srinivasa Rao Uppala18fb80e2011-07-17 17:33:00 -0700811#define STN_NUM_OFFSET 0x01
812#define STN_FREQ_OFFSET 0x02
813#define KHZ_TO_MHZ 1000
814#define GET_MSB(x)((x >> 8) & 0xFF)
815#define GET_LSB(x)((x) & 0xFF)
816
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700817/* control options */
818#define CTRL_ON (1)
819#define CTRL_OFF (0)
820
Srinivasa Rao Uppalaabc8efa2011-08-02 14:31:30 -0700821/*Diagnostic commands*/
822
823#define RIVA_PEEK_OPCODE 0x0D
824#define RIVA_POKE_OPCODE 0x0C
825
826#define PEEK_DATA_OFSET 0x1
827#define RIVA_PEEK_PARAM 0x6
828#define RIVA_PEEK_LEN_OFSET 0x6
829#define SSBI_PEEK_LEN 0x01
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530830/*Calibration data*/
831#define PROCS_CALIB_MODE 1
832#define PROCS_CALIB_SIZE 23
833#define DC_CALIB_MODE 2
834#define DC_CALIB_SIZE 48
835#define RSB_CALIB_MODE 3
836#define RSB_CALIB_SIZE 4
837#define CALIB_DATA_OFSET 2
838#define CALIB_MODE_OFSET 1
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530839#define MAX_CALIB_SIZE 75
Ayaz Ahmad37294ba2012-07-10 16:38:11 +0530840
841/* Channel validity */
842#define INVALID_CHANNEL (0)
843#define VALID_CHANNEL (1)
844
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530845struct hci_fm_set_cal_req_proc {
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530846 __u8 mode;
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530847 /*Max process calibration data size*/
848 __u8 data[PROCS_CALIB_SIZE];
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530849} __packed;
Venkateshwarlu Domakonda3a0b75d2011-11-23 17:03:27 +0530850
851struct hci_fm_set_cal_req_dc {
852 __u8 mode;
853 /*Max DC calibration data size*/
854 __u8 data[DC_CALIB_SIZE];
855} __packed;
856
Srinivasa Rao Uppalacb48ee62011-10-25 09:57:06 +0530857struct hci_cc_do_calibration_rsp {
858 __u8 status;
859 __u8 mode;
860 __u8 data[MAX_CALIB_SIZE];
861} __packed;
Srinivasa Rao Uppalaf856ae62011-10-17 18:43:26 +0530862
863/* Low Power mode*/
864#define SIG_LEVEL_INTR (1 << 0)
865#define RDS_SYNC_INTR (1 << 1)
866#define AUDIO_CTRL_INTR (1 << 2)
867#define AF_JUMP_ENABLE (1 << 4)
Anantha Krishnanf950e322012-06-06 14:25:49 +0530868
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700869int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
870 struct radio_hci_dev *hdev);
871int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
872 struct radio_hci_dev *hdev);
873int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
874int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700875
Ayaz Ahmad905c01d2013-12-19 18:39:57 +0530876static inline int is_valid_tone(int tone)
877{
878 if ((tone >= MIN_TX_TONE_VAL) &&
879 (tone <= MAX_TX_TONE_VAL))
880 return 1;
881 else
882 return 0;
883}
884
885static inline int is_valid_hard_mute(int hard_mute)
886{
887 if ((hard_mute >= MIN_HARD_MUTE_VAL) &&
888 (hard_mute <= MAX_HARD_MUTE_VAL))
889 return 1;
890 else
891 return 0;
892}
893
894static inline int is_valid_srch_mode(int srch_mode)
895{
896 if ((srch_mode >= MIN_SRCH_MODE) &&
897 (srch_mode <= MAX_SRCH_MODE))
898 return 1;
899 else
900 return 0;
901}
902
903static inline int is_valid_scan_dwell_prd(int scan_dwell_prd)
904{
905 if ((scan_dwell_prd >= MIN_SCAN_DWELL) &&
906 (scan_dwell_prd <= MAX_SCAN_DWELL))
907 return 1;
908 else
909 return 0;
910}
911
912static inline int is_valid_sig_th(int sig_th)
913{
914 if ((sig_th >= MIN_SIG_TH) &&
915 (sig_th <= MAX_SIG_TH))
916 return 1;
917 else
918 return 0;
919}
920
921static inline int is_valid_pty(int pty)
922{
923 if ((pty >= MIN_PTY) &&
924 (pty <= MAX_PTY))
925 return 1;
926 else
927 return 0;
928}
929
930static inline int is_valid_pi(int pi)
931{
932 if ((pi >= MIN_PI) &&
933 (pi <= MAX_PI))
934 return 1;
935 else
936 return 0;
937}
938
939static inline int is_valid_srch_station_cnt(int cnt)
940{
941 if ((cnt >= MIN_SRCH_STATIONS_CNT) &&
942 (cnt <= MAX_SRCH_STATIONS_CNT))
943 return 1;
944 else
945 return 0;
946}
947
948static inline int is_valid_chan_spacing(int spacing)
949{
950 if ((spacing >= MIN_CHAN_SPACING) &&
951 (spacing <= MAX_CHAN_SPACING))
952 return 1;
953 else
954 return 0;
955}
956
957static inline int is_valid_emphasis(int emphasis)
958{
959 if ((emphasis >= MIN_EMPHASIS) &&
960 (emphasis <= MAX_EMPHASIS))
961 return 1;
962 else
963 return 0;
964}
965
966static inline int is_valid_rds_std(int rds_std)
967{
968 if ((rds_std >= MIN_RDS_STD) &&
969 (rds_std <= MAX_RDS_STD))
970 return 1;
971 else
972 return 0;
973}
974
975static inline int is_valid_antenna(int antenna_type)
976{
977 if ((antenna_type >= MIN_ANTENNA_VAL) &&
978 (antenna_type <= MAX_ANTENNA_VAL))
979 return 1;
980 else
981 return 0;
982}
983
984static inline int is_valid_ps_repeat_cnt(int cnt)
985{
986 if ((cnt >= MIN_TX_PS_REPEAT_CNT) &&
987 (cnt <= MAX_TX_PS_REPEAT_CNT))
988 return 1;
989 else
990 return 0;
991}
992
993static inline int is_valid_soft_mute(int soft_mute)
994{
995 if ((soft_mute >= MIN_SOFT_MUTE) &&
996 (soft_mute <= MAX_SOFT_MUTE))
997 return 1;
998 else
999 return 0;
1000}
1001
1002static inline int is_valid_peek_len(int len)
1003{
1004 if ((len >= MIN_PEEK_ACCESS_LEN) &&
1005 (len <= MAX_PEEK_ACCESS_LEN))
1006 return 1;
1007 else
1008 return 0;
1009}
1010
1011static inline int is_valid_reset_cntr(int cntr)
1012{
1013 if ((cntr >= MIN_RESET_CNTR) &&
1014 (cntr <= MAX_RESET_CNTR))
1015 return 1;
1016 else
1017 return 0;
1018}
1019
1020static inline int is_valid_hlsi(int hlsi)
1021{
1022 if ((hlsi >= MIN_HLSI) &&
1023 (hlsi <= MAX_HLSI))
1024 return 1;
1025 else
1026 return 0;
1027}
1028
1029static inline int is_valid_notch_filter(int filter)
1030{
1031 if ((filter >= MIN_NOTCH_FILTER) &&
1032 (filter <= MAX_NOTCH_FILTER))
1033 return 1;
1034 else
1035 return 0;
1036}
1037
1038static inline int is_valid_intf_det_low_th(int th)
1039{
1040 if ((th >= MIN_INTF_DET_OUT_LW_TH) &&
1041 (th <= MAX_INTF_DET_OUT_LW_TH))
1042 return 1;
1043 else
1044 return 0;
1045}
1046
1047static inline int is_valid_intf_det_hgh_th(int th)
1048{
1049 if ((th >= MIN_INTF_DET_OUT_HG_TH) &&
1050 (th <= MAX_INTF_DET_OUT_HG_TH))
1051 return 1;
1052 else
1053 return 0;
1054}
1055
1056static inline int is_valid_sinr_th(int th)
1057{
1058 if ((th >= MIN_SINR_TH) &&
1059 (th <= MAX_SINR_TH))
1060 return 1;
1061 else
1062 return 0;
1063}
1064
1065static inline int is_valid_sinr_samples(int samples_cnt)
1066{
1067 if ((samples_cnt >= MIN_SINR_SAMPLES) &&
1068 (samples_cnt <= MAX_SINR_SAMPLES))
1069 return 1;
1070 else
1071 return 0;
1072}
1073
1074static inline int is_valid_fm_state(int state)
1075{
1076 if ((state >= 0) && (state < FM_MAX_NO_STATES))
1077 return 1;
1078 else
1079 return 0;
1080}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001081#endif /* __RADIO_HCI_CORE_H */