blob: aab92adc4e06112ea224e506d325cad24c32cf7c [file] [log] [blame]
Jeremy Gebben1c143462015-10-29 13:04:12 -06001/*
2 *
3 * Copyright (c) 2011-2016 The Linux Foundation. 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_IRIS_H
28#define __RADIO_IRIS_H
29
30#include <uapi/media/radio-iris.h>
31
32#include <linux/skbuff.h>
33#include <linux/interrupt.h>
34#include <linux/mutex.h>
35#include <linux/atomic.h>
36
himta ram8c7bd3d2018-03-21 15:26:14 +053037#define RDS_PS_SIMPLE_OFFSET 2
38extern struct mutex fm_smd_enable;
39
Jeremy Gebben1c143462015-10-29 13:04:12 -060040struct radio_hci_dev {
41 char name[8];
42 unsigned long flags;
43 __u16 id;
44 __u8 bus;
45 __u8 dev_type;
46 __u8 dev_name[248];
47 __u8 dev_class[3];
48 __u8 features[8];
49 __u8 commands[64];
50
51 unsigned int data_block_len;
52 unsigned long cmd_last_tx;
53
54 struct sk_buff *sent_cmd;
55
56 __u32 req_status;
57 __u32 req_result;
58 atomic_t cmd_cnt;
59
60 struct tasklet_struct cmd_task;
61 struct tasklet_struct rx_task;
62 struct tasklet_struct tx_task;
63
64 struct sk_buff_head rx_q;
65 struct sk_buff_head raw_q;
66 struct sk_buff_head cmd_q;
67
68 struct mutex req_lock;
69 wait_queue_head_t req_wait_q;
70
71 int (*open)(struct radio_hci_dev *hdev);
72 int (*close)(struct radio_hci_dev *hdev);
73 int (*flush)(struct radio_hci_dev *hdev);
74 int (*send)(struct sk_buff *skb);
75 void (*destruct)(struct radio_hci_dev *hdev);
76 void (*notify)(struct radio_hci_dev *hdev, unsigned int evt);
77 void (*close_smd)(void);
78};
79
80int radio_hci_register_dev(struct radio_hci_dev *hdev);
himta ram8c7bd3d2018-03-21 15:26:14 +053081int radio_hci_unregister_dev(void);
Jeremy Gebben1c143462015-10-29 13:04:12 -060082int radio_hci_recv_frame(struct sk_buff *skb);
83int radio_hci_send_cmd(struct radio_hci_dev *hdev, __u16 opcode, __u32 plen,
84 void *param);
85void radio_hci_event_packet(struct radio_hci_dev *hdev, struct sk_buff *skb);
86
87#define hci_req_lock(d) mutex_lock(&d->req_lock)
88#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
89
90#undef FMDBG
91#ifdef FM_DEBUG
92#define FMDBG(fmt, args...) pr_info("iris_radio: " fmt, ##args)
93#else
94#define FMDBG(fmt, args...)
95#endif
96
97#undef FMDERR
98#define FMDERR(fmt, args...) pr_err("iris_radio: " fmt, ##args)
99
100/* HCI timeouts */
101#define RADIO_HCI_TIMEOUT (10000) /* 10 seconds */
102
103int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
104 struct radio_hci_dev *hdev);
105int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
106 struct radio_hci_dev *hdev);
107int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
108int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev);
109
110static inline int is_valid_tone(int tone)
111{
112 if ((tone >= MIN_TX_TONE_VAL) &&
113 (tone <= MAX_TX_TONE_VAL))
114 return 1;
115 else
116 return 0;
117}
118
119static inline int is_valid_hard_mute(int hard_mute)
120{
121 if ((hard_mute >= MIN_HARD_MUTE_VAL) &&
122 (hard_mute <= MAX_HARD_MUTE_VAL))
123 return 1;
124 else
125 return 0;
126}
127
128static inline int is_valid_srch_mode(int srch_mode)
129{
130 if ((srch_mode >= MIN_SRCH_MODE) &&
131 (srch_mode <= MAX_SRCH_MODE))
132 return 1;
133 else
134 return 0;
135}
136
137static inline int is_valid_scan_dwell_prd(int scan_dwell_prd)
138{
139 if ((scan_dwell_prd >= MIN_SCAN_DWELL) &&
140 (scan_dwell_prd <= MAX_SCAN_DWELL))
141 return 1;
142 else
143 return 0;
144}
145
146static inline int is_valid_sig_th(int sig_th)
147{
148 if ((sig_th >= MIN_SIG_TH) &&
149 (sig_th <= MAX_SIG_TH))
150 return 1;
151 else
152 return 0;
153}
154
155static inline int is_valid_pty(int pty)
156{
157 if ((pty >= MIN_PTY) &&
158 (pty <= MAX_PTY))
159 return 1;
160 else
161 return 0;
162}
163
164static inline int is_valid_pi(int pi)
165{
166 if ((pi >= MIN_PI) &&
167 (pi <= MAX_PI))
168 return 1;
169 else
170 return 0;
171}
172
173static inline int is_valid_srch_station_cnt(int cnt)
174{
175 if ((cnt >= MIN_SRCH_STATIONS_CNT) &&
176 (cnt <= MAX_SRCH_STATIONS_CNT))
177 return 1;
178 else
179 return 0;
180}
181
182static inline int is_valid_chan_spacing(int spacing)
183{
184 if ((spacing >= MIN_CHAN_SPACING) &&
185 (spacing <= MAX_CHAN_SPACING))
186 return 1;
187 else
188 return 0;
189}
190
191static inline int is_valid_emphasis(int emphasis)
192{
193 if ((emphasis >= MIN_EMPHASIS) &&
194 (emphasis <= MAX_EMPHASIS))
195 return 1;
196 else
197 return 0;
198}
199
200static inline int is_valid_rds_std(int rds_std)
201{
202 if ((rds_std >= MIN_RDS_STD) &&
203 (rds_std <= MAX_RDS_STD))
204 return 1;
205 else
206 return 0;
207}
208
209static inline int is_valid_antenna(int antenna_type)
210{
211 if ((antenna_type >= MIN_ANTENNA_VAL) &&
212 (antenna_type <= MAX_ANTENNA_VAL))
213 return 1;
214 else
215 return 0;
216}
217
218static inline int is_valid_ps_repeat_cnt(int cnt)
219{
220 if ((cnt >= MIN_TX_PS_REPEAT_CNT) &&
221 (cnt <= MAX_TX_PS_REPEAT_CNT))
222 return 1;
223 else
224 return 0;
225}
226
227static inline int is_valid_soft_mute(int soft_mute)
228{
229 if ((soft_mute >= MIN_SOFT_MUTE) &&
230 (soft_mute <= MAX_SOFT_MUTE))
231 return 1;
232 else
233 return 0;
234}
235
236static inline int is_valid_peek_len(int len)
237{
238 if ((len >= MIN_PEEK_ACCESS_LEN) &&
239 (len <= MAX_PEEK_ACCESS_LEN))
240 return 1;
241 else
242 return 0;
243}
244
245static inline int is_valid_reset_cntr(int cntr)
246{
247 if ((cntr >= MIN_RESET_CNTR) &&
248 (cntr <= MAX_RESET_CNTR))
249 return 1;
250 else
251 return 0;
252}
253
254static inline int is_valid_hlsi(int hlsi)
255{
256 if ((hlsi >= MIN_HLSI) &&
257 (hlsi <= MAX_HLSI))
258 return 1;
259 else
260 return 0;
261}
262
263static inline int is_valid_notch_filter(int filter)
264{
265 if ((filter >= MIN_NOTCH_FILTER) &&
266 (filter <= MAX_NOTCH_FILTER))
267 return 1;
268 else
269 return 0;
270}
271
272static inline int is_valid_intf_det_low_th(int th)
273{
274 if ((th >= MIN_INTF_DET_OUT_LW_TH) &&
275 (th <= MAX_INTF_DET_OUT_LW_TH))
276 return 1;
277 else
278 return 0;
279}
280
281static inline int is_valid_intf_det_hgh_th(int th)
282{
283 if ((th >= MIN_INTF_DET_OUT_HG_TH) &&
284 (th <= MAX_INTF_DET_OUT_HG_TH))
285 return 1;
286 else
287 return 0;
288}
289
290static inline int is_valid_sinr_th(int th)
291{
292 if ((th >= MIN_SINR_TH) &&
293 (th <= MAX_SINR_TH))
294 return 1;
295 else
296 return 0;
297}
298
299static inline int is_valid_sinr_samples(int samples_cnt)
300{
301 if ((samples_cnt >= MIN_SINR_SAMPLES) &&
302 (samples_cnt <= MAX_SINR_SAMPLES))
303 return 1;
304 else
305 return 0;
306}
307
308static inline int is_valid_fm_state(int state)
309{
310 if ((state >= 0) && (state < FM_MAX_NO_STATES))
311 return 1;
312 else
313 return 0;
314}
315
316static inline int is_valid_blend_value(int val)
317{
318 if ((val >= MIN_BLEND_HI) && (val <= MAX_BLEND_HI))
319 return 1;
320 else
321 return 0;
322}
323
324#endif
325