1
2
3
4
5
6
7
8
9 #ifndef DVB_USB_H
10 #define DVB_USB_H
11
12 #include <linux/usb/input.h>
13 #include <linux/firmware.h>
14 #include <media/rc-core.h>
15 #include <media/media-device.h>
16
17 #include <media/dvb_frontend.h>
18 #include <media/dvb_demux.h>
19 #include <media/dvb_net.h>
20 #include <media/dmxdev.h>
21 #include <media/dvb-usb-ids.h>
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 #define adap_to_d(adap) (container_of(adap, struct dvb_usb_device, \
47 adapter[adap->id]))
48 #define adap_to_priv(adap) (adap_to_d(adap)->priv)
49 #define fe_to_adap(fe) ((struct dvb_usb_adapter *) ((fe)->dvb->priv))
50 #define fe_to_d(fe) (adap_to_d(fe_to_adap(fe)))
51 #define fe_to_priv(fe) (fe_to_d(fe)->priv)
52 #define d_to_priv(d) (d->priv)
53
54 #define dvb_usb_dbg_usb_control_msg(udev, r, t, v, i, b, l) { \
55 char *direction; \
56 if (t == (USB_TYPE_VENDOR | USB_DIR_OUT)) \
57 direction = ">>>"; \
58 else \
59 direction = "<<<"; \
60 dev_dbg(&udev->dev, "%s: %02x %02x %02x %02x %02x %02x %02x %02x " \
61 "%s %*ph\n", __func__, t, r, v & 0xff, v >> 8, \
62 i & 0xff, i >> 8, l & 0xff, l >> 8, direction, l, b); \
63 }
64
65 #define DVB_USB_STREAM_BULK(endpoint_, count_, size_) { \
66 .type = USB_BULK, \
67 .count = count_, \
68 .endpoint = endpoint_, \
69 .u = { \
70 .bulk = { \
71 .buffersize = size_, \
72 } \
73 } \
74 }
75
76 #define DVB_USB_STREAM_ISOC(endpoint_, count_, frames_, size_, interval_) { \
77 .type = USB_ISOC, \
78 .count = count_, \
79 .endpoint = endpoint_, \
80 .u = { \
81 .isoc = { \
82 .framesperurb = frames_, \
83 .framesize = size_,\
84 .interval = interval_, \
85 } \
86 } \
87 }
88
89 #define DVB_USB_DEVICE(vend, prod, props_, name_, rc) \
90 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
91 .idVendor = (vend), \
92 .idProduct = (prod), \
93 .driver_info = (kernel_ulong_t) &((const struct dvb_usb_driver_info) { \
94 .props = (props_), \
95 .name = (name_), \
96 .rc_map = (rc), \
97 })
98
99 struct dvb_usb_device;
100 struct dvb_usb_adapter;
101
102
103
104
105
106
107
108
109 struct dvb_usb_driver_info {
110 const char *name;
111 const char *rc_map;
112 const struct dvb_usb_device_properties *props;
113 };
114
115
116
117
118
119
120
121
122
123
124
125 struct dvb_usb_rc {
126 const char *map_name;
127 u64 allowed_protos;
128 int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto);
129 int (*query) (struct dvb_usb_device *d);
130 unsigned int interval;
131 enum rc_driver_type driver_type;
132 bool bulk_mode;
133 };
134
135
136
137
138
139
140
141 struct usb_data_stream_properties {
142 #define USB_BULK 1
143 #define USB_ISOC 2
144 u8 type;
145 u8 count;
146 u8 endpoint;
147
148 union {
149 struct {
150 unsigned int buffersize;
151 } bulk;
152 struct {
153 int framesperurb;
154 int framesize;
155 int interval;
156 } isoc;
157 } u;
158 };
159
160
161
162
163
164
165
166
167
168 #define MAX_NO_OF_FE_PER_ADAP 3
169 struct dvb_usb_adapter_properties {
170 #define DVB_USB_ADAP_HAS_PID_FILTER 0x01
171 #define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
172 #define DVB_USB_ADAP_NEED_PID_FILTERING 0x04
173 u8 caps;
174
175 u8 pid_filter_count;
176 int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
177 int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int);
178
179 struct usb_data_stream_properties stream;
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 #define MAX_NO_OF_ADAPTER_PER_DEVICE 2
220 struct dvb_usb_device_properties {
221 const char *driver_name;
222 struct module *owner;
223 short *adapter_nr;
224
225 u8 bInterfaceNumber;
226 unsigned int size_of_priv;
227 u8 generic_bulk_ctrl_endpoint;
228 u8 generic_bulk_ctrl_endpoint_response;
229 unsigned int generic_bulk_ctrl_delay;
230
231 int (*probe)(struct dvb_usb_device *);
232 void (*disconnect)(struct dvb_usb_device *);
233 #define WARM 0
234 #define COLD 1
235 int (*identify_state) (struct dvb_usb_device *, const char **);
236 const char *firmware;
237 #define RECONNECTS_USB 1
238 int (*download_firmware) (struct dvb_usb_device *,
239 const struct firmware *);
240
241 struct i2c_algorithm *i2c_algo;
242
243 unsigned int num_adapters;
244 int (*get_adapter_count) (struct dvb_usb_device *);
245 struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
246 int (*power_ctrl) (struct dvb_usb_device *, int);
247 int (*read_config) (struct dvb_usb_device *d);
248 int (*read_mac_address) (struct dvb_usb_adapter *, u8 []);
249 int (*frontend_attach) (struct dvb_usb_adapter *);
250 int (*frontend_detach)(struct dvb_usb_adapter *);
251 int (*tuner_attach) (struct dvb_usb_adapter *);
252 int (*tuner_detach)(struct dvb_usb_adapter *);
253 int (*frontend_ctrl) (struct dvb_frontend *, int);
254 int (*streaming_ctrl) (struct dvb_frontend *, int);
255 int (*init) (struct dvb_usb_device *);
256 void (*exit) (struct dvb_usb_device *);
257 int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *);
258 #define DVB_USB_FE_TS_TYPE_188 0
259 #define DVB_USB_FE_TS_TYPE_204 1
260 #define DVB_USB_FE_TS_TYPE_RAW 2
261 int (*get_stream_config) (struct dvb_frontend *, u8 *,
262 struct usb_data_stream_properties *);
263 };
264
265
266
267
268
269
270
271
272
273
274
275 #define MAX_NO_URBS_FOR_DATA_STREAM 10
276 struct usb_data_stream {
277 struct usb_device *udev;
278 struct usb_data_stream_properties props;
279
280 #define USB_STATE_INIT 0x00
281 #define USB_STATE_URB_BUF 0x01
282 u8 state;
283
284 void (*complete) (struct usb_data_stream *, u8 *, size_t);
285
286 struct urb *urb_list[MAX_NO_URBS_FOR_DATA_STREAM];
287 int buf_num;
288 unsigned long buf_size;
289 u8 *buf_list[MAX_NO_URBS_FOR_DATA_STREAM];
290 dma_addr_t dma_addr[MAX_NO_URBS_FOR_DATA_STREAM];
291
292 int urbs_initialized;
293 int urbs_submitted;
294
295 void *user_priv;
296 };
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317 struct dvb_usb_adapter {
318 const struct dvb_usb_adapter_properties *props;
319 struct usb_data_stream stream;
320 u8 id;
321 u8 ts_type;
322 bool suspend_resume_active;
323 bool pid_filtering;
324 u8 feed_count;
325 u8 max_feed_count;
326 s8 active_fe;
327 #define ADAP_INIT 0
328 #define ADAP_SLEEP 1
329 #define ADAP_STREAMING 2
330 unsigned long state_bits;
331
332
333 struct dvb_adapter dvb_adap;
334 struct dmxdev dmxdev;
335 struct dvb_demux demux;
336 struct dvb_net dvb_net;
337
338 struct dvb_frontend *fe[MAX_NO_OF_FE_PER_ADAP];
339 int (*fe_init[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
340 int (*fe_sleep[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
341 };
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361 struct dvb_usb_device {
362 const struct dvb_usb_device_properties *props;
363 const char *name;
364 const char *rc_map;
365 bool rc_polling_active;
366 struct usb_interface *intf;
367 struct usb_device *udev;
368 struct dvb_usb_rc rc;
369 int powered;
370
371
372 struct mutex usb_mutex;
373
374
375 struct mutex i2c_mutex;
376 struct i2c_adapter i2c_adap;
377
378 struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
379
380
381 struct rc_dev *rc_dev;
382 char rc_phys[64];
383 struct delayed_work rc_query_work;
384
385 void *priv;
386 };
387
388 extern int dvb_usbv2_probe(struct usb_interface *,
389 const struct usb_device_id *);
390 extern void dvb_usbv2_disconnect(struct usb_interface *);
391 extern int dvb_usbv2_suspend(struct usb_interface *, pm_message_t);
392 extern int dvb_usbv2_resume(struct usb_interface *);
393 extern int dvb_usbv2_reset_resume(struct usb_interface *);
394
395
396 extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16);
397 extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16);
398
399 extern int dvb_usbv2_generic_rw_locked(struct dvb_usb_device *,
400 u8 *, u16, u8 *, u16);
401 extern int dvb_usbv2_generic_write_locked(struct dvb_usb_device *, u8 *, u16);
402
403 #endif