summaryrefslogtreecommitdiff
path: root/include/media/radio-iris.h
blob: 22888b0f2ca6df3aa8401f96afe9f00340b3cbfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/*
 *
 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
 *
 * This file is based on include/net/bluetooth/hci_core.h
 *
 * Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
 * CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 * ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
 * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
 * SOFTWARE IS DISCLAIMED.
 */

#ifndef __RADIO_IRIS_H
#define __RADIO_IRIS_H

#include <uapi/media/radio-iris.h>

#include <linux/skbuff.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/atomic.h>

struct radio_hci_dev {
	char		name[8];
	unsigned long	flags;
	__u16		id;
	__u8		bus;
	__u8		dev_type;
	__u8		dev_name[248];
	__u8		dev_class[3];
	__u8		features[8];
	__u8		commands[64];

	unsigned int	data_block_len;
	unsigned long	cmd_last_tx;

	struct sk_buff		*sent_cmd;

	__u32			req_status;
	__u32			req_result;
	atomic_t	cmd_cnt;

	struct tasklet_struct	cmd_task;
	struct tasklet_struct	rx_task;
	struct tasklet_struct	tx_task;

	struct sk_buff_head	rx_q;
	struct sk_buff_head	raw_q;
	struct sk_buff_head	cmd_q;

	struct mutex		req_lock;
	wait_queue_head_t	req_wait_q;

	int (*open)(struct radio_hci_dev *hdev);
	int (*close)(struct radio_hci_dev *hdev);
	int (*flush)(struct radio_hci_dev *hdev);
	int (*send)(struct sk_buff *skb);
	void (*destruct)(struct radio_hci_dev *hdev);
	void (*notify)(struct radio_hci_dev *hdev, unsigned int evt);
	void (*close_smd)(void);
};

int radio_hci_register_dev(struct radio_hci_dev *hdev);
int radio_hci_unregister_dev(struct radio_hci_dev *hdev);
int radio_hci_recv_frame(struct sk_buff *skb);
int radio_hci_send_cmd(struct radio_hci_dev *hdev, __u16 opcode, __u32 plen,
	void *param);
void radio_hci_event_packet(struct radio_hci_dev *hdev, struct sk_buff *skb);

#define hci_req_lock(d)		mutex_lock(&d->req_lock)
#define hci_req_unlock(d)	mutex_unlock(&d->req_lock)

#undef FMDBG
#ifdef FM_DEBUG
#define FMDBG(fmt, args...) pr_info("iris_radio: " fmt, ##args)
#else
#define FMDBG(fmt, args...)
#endif

#undef FMDERR
#define FMDERR(fmt, args...) pr_err("iris_radio: " fmt, ##args)

/* HCI timeouts */
#define RADIO_HCI_TIMEOUT	(10000)	/* 10 seconds */

int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
	struct radio_hci_dev *hdev);
int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
	struct radio_hci_dev *hdev);
int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);

static inline int is_valid_tone(int tone)
{
	if ((tone >= MIN_TX_TONE_VAL) &&
		(tone <= MAX_TX_TONE_VAL))
		return 1;
	else
		return 0;
}

static inline int is_valid_hard_mute(int hard_mute)
{
	if ((hard_mute >= MIN_HARD_MUTE_VAL) &&
		(hard_mute <= MAX_HARD_MUTE_VAL))
		return 1;
	else
		return 0;
}

static inline int is_valid_srch_mode(int srch_mode)
{
	if ((srch_mode >= MIN_SRCH_MODE) &&
		(srch_mode <= MAX_SRCH_MODE))
		return 1;
	else
		return 0;
}

static inline int is_valid_scan_dwell_prd(int scan_dwell_prd)
{
	if ((scan_dwell_prd >= MIN_SCAN_DWELL) &&
		(scan_dwell_prd <= MAX_SCAN_DWELL))
		return 1;
	else
		return 0;
}

static inline int is_valid_sig_th(int sig_th)
{
	if ((sig_th >= MIN_SIG_TH) &&
		(sig_th <= MAX_SIG_TH))
		return 1;
	else
		return 0;
}

static inline int is_valid_pty(int pty)
{
	if ((pty >= MIN_PTY) &&
		(pty <= MAX_PTY))
		return 1;
	else
		return 0;
}

static inline int is_valid_pi(int pi)
{
	if ((pi >= MIN_PI) &&
		(pi <= MAX_PI))
		return 1;
	else
		return 0;
}

static inline int is_valid_srch_station_cnt(int cnt)
{
	if ((cnt >= MIN_SRCH_STATIONS_CNT) &&
		(cnt <= MAX_SRCH_STATIONS_CNT))
		return 1;
	else
		return 0;
}

static inline int is_valid_chan_spacing(int spacing)
{
	if ((spacing >= MIN_CHAN_SPACING) &&
		(spacing <= MAX_CHAN_SPACING))
		return 1;
	else
		return 0;
}

static inline int is_valid_emphasis(int emphasis)
{
	if ((emphasis >= MIN_EMPHASIS) &&
		(emphasis <= MAX_EMPHASIS))
		return 1;
	else
		return 0;
}

static inline int is_valid_rds_std(int rds_std)
{
	if ((rds_std >= MIN_RDS_STD) &&
		(rds_std <= MAX_RDS_STD))
		return 1;
	else
		return 0;
}

static inline int is_valid_antenna(int antenna_type)
{
	if ((antenna_type >= MIN_ANTENNA_VAL) &&
		(antenna_type <= MAX_ANTENNA_VAL))
		return 1;
	else
		return 0;
}

static inline int is_valid_ps_repeat_cnt(int cnt)
{
	if ((cnt >= MIN_TX_PS_REPEAT_CNT) &&
		(cnt <= MAX_TX_PS_REPEAT_CNT))
		return 1;
	else
		return 0;
}

static inline int is_valid_soft_mute(int soft_mute)
{
	if ((soft_mute >= MIN_SOFT_MUTE) &&
		(soft_mute <= MAX_SOFT_MUTE))
		return 1;
	else
		return 0;
}

static inline int is_valid_peek_len(int len)
{
	if ((len >= MIN_PEEK_ACCESS_LEN) &&
		(len <= MAX_PEEK_ACCESS_LEN))
		return 1;
	else
		return 0;
}

static inline int is_valid_reset_cntr(int cntr)
{
	if ((cntr >= MIN_RESET_CNTR) &&
		(cntr <= MAX_RESET_CNTR))
		return 1;
	else
		return 0;
}

static inline int is_valid_hlsi(int hlsi)
{
	if ((hlsi >= MIN_HLSI) &&
		(hlsi <= MAX_HLSI))
		return 1;
	else
		return 0;
}

static inline int is_valid_notch_filter(int filter)
{
	if ((filter >= MIN_NOTCH_FILTER) &&
		(filter <= MAX_NOTCH_FILTER))
		return 1;
	else
		return 0;
}

static inline int is_valid_intf_det_low_th(int th)
{
	if ((th >= MIN_INTF_DET_OUT_LW_TH) &&
		(th <= MAX_INTF_DET_OUT_LW_TH))
		return 1;
	else
		return 0;
}

static inline int is_valid_intf_det_hgh_th(int th)
{
	if ((th >= MIN_INTF_DET_OUT_HG_TH) &&
		(th <= MAX_INTF_DET_OUT_HG_TH))
		return 1;
	else
		return 0;
}

static inline int is_valid_sinr_th(int th)
{
	if ((th >= MIN_SINR_TH) &&
		(th <= MAX_SINR_TH))
		return 1;
	else
		return 0;
}

static inline int is_valid_sinr_samples(int samples_cnt)
{
	if ((samples_cnt >= MIN_SINR_SAMPLES) &&
		(samples_cnt <= MAX_SINR_SAMPLES))
		return 1;
	else
		return 0;
}

static inline int is_valid_fm_state(int state)
{
	if ((state >= 0) && (state < FM_MAX_NO_STATES))
		return 1;
	else
		return 0;
}

static inline int is_valid_blend_value(int val)
{
	if ((val >= MIN_BLEND_HI) && (val <= MAX_BLEND_HI))
		return 1;
	else
		return 0;
}

#endif