Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dvb_usb.h
Go to the documentation of this file.
1 /*
2  * DVB USB framework
3  *
4  * Copyright (C) 2004-6 Patrick Boettcher <[email protected]>
5  * Copyright (C) 2012 Antti Palosaari <[email protected]>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef DVB_USB_H
23 #define DVB_USB_H
24 
25 #include <linux/usb/input.h>
26 #include <linux/firmware.h>
27 #include <media/rc-core.h>
28 
29 #include "dvb_frontend.h"
30 #include "dvb_demux.h"
31 #include "dvb_net.h"
32 #include "dmxdev.h"
33 #include "dvb-usb-ids.h"
34 
35 /*
36  * device file: /dev/dvb/adapter[0-1]/frontend[0-2]
37  *
38  * |-- device
39  * | |-- adapter0
40  * | | |-- frontend0
41  * | | |-- frontend1
42  * | | `-- frontend2
43  * | `-- adapter1
44  * | |-- frontend0
45  * | |-- frontend1
46  * | `-- frontend2
47  *
48  *
49  * Commonly used variable names:
50  * d = pointer to device (struct dvb_usb_device *)
51  * adap = pointer to adapter (struct dvb_usb_adapter *)
52  * fe = pointer to frontend (struct dvb_frontend *)
53  *
54  * Use macros defined in that file to resolve needed pointers.
55  */
56 
57 /* helper macros for every DVB USB driver use */
58 #define adap_to_d(adap) (container_of(adap, struct dvb_usb_device, \
59  adapter[adap->id]))
60 #define adap_to_priv(adap) (adap_to_d(adap)->priv)
61 #define fe_to_adap(fe) ((struct dvb_usb_adapter *) ((fe)->dvb->priv))
62 #define fe_to_d(fe) (adap_to_d(fe_to_adap(fe)))
63 #define fe_to_priv(fe) (fe_to_d(fe)->priv)
64 #define d_to_priv(d) (d->priv)
65 
66 #define dvb_usb_dbg_usb_control_msg(udev, r, t, v, i, b, l) { \
67  char *direction; \
68  if (t == (USB_TYPE_VENDOR | USB_DIR_OUT)) \
69  direction = ">>>"; \
70  else \
71  direction = "<<<"; \
72  dev_dbg(&udev->dev, "%s: %02x %02x %02x %02x %02x %02x %02x %02x " \
73  "%s %*ph\n", __func__, t, r, v & 0xff, v >> 8, \
74  i & 0xff, i >> 8, l & 0xff, l >> 8, direction, l, b); \
75 }
76 
77 #define DVB_USB_STREAM_BULK(endpoint_, count_, size_) { \
78  .type = USB_BULK, \
79  .count = count_, \
80  .endpoint = endpoint_, \
81  .u = { \
82  .bulk = { \
83  .buffersize = size_, \
84  } \
85  } \
86 }
87 
88 #define DVB_USB_STREAM_ISOC(endpoint_, count_, frames_, size_, interval_) { \
89  .type = USB_ISOC, \
90  .count = count_, \
91  .endpoint = endpoint_, \
92  .u = { \
93  .isoc = { \
94  .framesperurb = frames_, \
95  .framesize = size_,\
96  .interval = interval_, \
97  } \
98  } \
99 }
100 
101 #define DVB_USB_DEVICE(vend, prod, props_, name_, rc) \
102  .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
103  .idVendor = (vend), \
104  .idProduct = (prod), \
105  .driver_info = (kernel_ulong_t) &((const struct dvb_usb_driver_info) { \
106  .props = (props_), \
107  .name = (name_), \
108  .rc_map = (rc), \
109  })
110 
111 struct dvb_usb_device;
112 struct dvb_usb_adapter;
113 
122  const char *name;
123  const char *rc_map;
125 };
126 
137 struct dvb_usb_rc {
138  const char *map_name;
140  int (*change_protocol)(struct rc_dev *dev, u64 rc_type);
141  int (*query) (struct dvb_usb_device *d);
142  unsigned int interval;
144  bool bulk_mode;
145 };
146 
154 #define USB_BULK 1
155 #define USB_ISOC 2
159 
160  union {
161  struct {
162  unsigned int buffersize; /* per URB */
163  } bulk;
164  struct {
165  int framesperurb;
166  int framesize;
167  int interval;
168  } isoc;
169  } u;
170 };
171 
180 #define MAX_NO_OF_FE_PER_ADAP 3
182 #define DVB_USB_ADAP_HAS_PID_FILTER 0x01
183 #define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
184 #define DVB_USB_ADAP_NEED_PID_FILTERING 0x04
186 
190 
192 };
193 
228 #define MAX_NO_OF_ADAPTER_PER_DEVICE 2
230  const char *driver_name;
231  struct module *owner;
232  short *adapter_nr;
233 
235  unsigned int size_of_priv;
239 
240 #define WARM 0
241 #define COLD 1
242  int (*identify_state) (struct dvb_usb_device *, const char **);
243  const char *firmware;
244 #define RECONNECTS_USB 1
245  int (*download_firmware) (struct dvb_usb_device *,
246  const struct firmware *);
247 
248  struct i2c_algorithm *i2c_algo;
249 
250  unsigned int num_adapters;
253  int (*power_ctrl) (struct dvb_usb_device *, int);
255  int (*read_mac_address) (struct dvb_usb_adapter *, u8 []);
260  int (*init) (struct dvb_usb_device *);
261  void (*exit) (struct dvb_usb_device *);
262  int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *);
263 #define DVB_USB_FE_TS_TYPE_188 0
264 #define DVB_USB_FE_TS_TYPE_204 1
265 #define DVB_USB_FE_TS_TYPE_RAW 2
267  struct usb_data_stream_properties *);
268 };
269 
280 #define MAX_NO_URBS_FOR_DATA_STREAM 10
281 struct usb_data_stream {
282  struct usb_device *udev;
283  struct usb_data_stream_properties props;
284 
285 #define USB_STATE_INIT 0x00
286 #define USB_STATE_URB_BUF 0x01
288 
289  void (*complete) (struct usb_data_stream *, u8 *, size_t);
290 
292  int buf_num;
293  unsigned long buf_size;
296 
297  int urbs_initialized;
298  int urbs_submitted;
299 
300  void *user_priv;
301 };
302 
322 struct dvb_usb_adapter {
325  u8 id;
332 
333  /* dvb */
334  struct dvb_adapter dvb_adap;
335  struct dmxdev dmxdev;
336  struct dvb_demux demux;
337  struct dvb_net dvb_net;
339 
343 };
344 
363 struct dvb_usb_device {
365  const char *name;
366  const char *rc_map;
367 
368  struct usb_device *udev;
370  struct dvb_usb_rc rc;
373  int powered;
374 
375  /* locking */
376  struct mutex usb_mutex;
377 
378  /* i2c */
379  struct mutex i2c_mutex;
380  struct i2c_adapter i2c_adap;
381 
383 
384  /* remote control */
385  struct rc_dev *rc_dev;
386  char rc_phys[64];
388 
389  void *priv;
390 };
391 
392 extern int dvb_usbv2_probe(struct usb_interface *,
393  const struct usb_device_id *);
394 extern void dvb_usbv2_disconnect(struct usb_interface *);
395 extern int dvb_usbv2_suspend(struct usb_interface *, pm_message_t);
396 extern int dvb_usbv2_resume(struct usb_interface *);
397 extern int dvb_usbv2_reset_resume(struct usb_interface *);
398 
399 /* the generic read/write method for device control */
400 extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16);
401 extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16);
402 
403 #endif