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 /* dvb-usb.h is part of the DVB USB library.
2  *
3  * Copyright (C) 2004-6 Patrick Boettcher ([email protected])
4  * see dvb-usb-init.c for copyright information.
5  *
6  * the headerfile, all dvb-usb-drivers have to include.
7  *
8  * TODO: clean-up the structures for unused fields and update the comments
9  */
10 #ifndef __DVB_USB_H__
11 #define __DVB_USB_H__
12 
13 #include <linux/input.h>
14 #include <linux/usb.h>
15 #include <linux/firmware.h>
16 #include <linux/mutex.h>
17 #include <media/rc-core.h>
18 
19 #include "dvb_frontend.h"
20 #include "dvb_demux.h"
21 #include "dvb_net.h"
22 #include "dmxdev.h"
23 
24 #include "dvb-pll.h"
25 
26 #include "dvb-usb-ids.h"
27 
28 /* debug */
29 #ifdef CONFIG_DVB_USB_DEBUG
30 #define dprintk(var,level,args...) \
31  do { if ((var & level)) { printk(args); } } while (0)
32 
33 #define debug_dump(b,l,func) {\
34  int loop_; \
35  for (loop_ = 0; loop_ < l; loop_++) func("%02x ", b[loop_]); \
36  func("\n");\
37 }
38 #define DVB_USB_DEBUG_STATUS
39 #else
40 #define dprintk(args...)
41 #define debug_dump(b,l,func)
42 
43 #define DVB_USB_DEBUG_STATUS " (debugging is not enabled)"
44 
45 #endif
46 
47 /* generic log methods - taken from usb.h */
48 #ifndef DVB_USB_LOG_PREFIX
49  #define DVB_USB_LOG_PREFIX "dvb-usb (please define a log prefix)"
50 #endif
51 
52 #undef err
53 #define err(format, arg...) printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
54 #undef info
55 #define info(format, arg...) printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
56 #undef warn
57 #define warn(format, arg...) printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
58 
71  const char *name;
72 
73 #define DVB_USB_ID_MAX_NUM 15
76 };
77 
78 static inline u8 rc5_custom(struct rc_map_table *key)
79 {
80  return (key->scancode >> 8) & 0xff;
81 }
82 
83 static inline u8 rc5_data(struct rc_map_table *key)
84 {
85  return key->scancode & 0xff;
86 }
87 
88 static inline u16 rc5_scan(struct rc_map_table *key)
89 {
90  return key->scancode & 0xffff;
91 }
92 
93 struct dvb_usb_device;
94 struct dvb_usb_adapter;
95 struct usb_data_stream;
96 
103 #define USB_BULK 1
104 #define USB_ISOC 2
105  int type;
106  int count;
107  int endpoint;
108 
109  union {
110  struct {
111  int buffersize; /* per URB */
112  } bulk;
113  struct {
116  int interval;
117  } isoc;
118  } u;
119 };
120 
140 #define DVB_USB_ADAP_HAS_PID_FILTER 0x01
141 #define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
142 #define DVB_USB_ADAP_NEED_PID_FILTERING 0x04
143 #define DVB_USB_ADAP_RECEIVES_204_BYTE_TS 0x08
144 #define DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD 0x10
145  int caps;
147 
151 
154 
156 
158 };
159 
160 #define MAX_NO_OF_FE_PER_ADAP 3
163 
165 
168 };
169 
179 /* remote control properties */
180 #define REMOTE_NO_KEY_PRESSED 0x00
181 #define REMOTE_KEY_PRESSED 0x01
182 #define REMOTE_KEY_REPEAT 0x02
185  int (*rc_query) (struct dvb_usb_device *, u32 *, int *);
187 };
188 
200 struct dvb_rc {
201  char *rc_codes;
205  int (*change_protocol)(struct rc_dev *dev, u64 rc_type);
206  char *module_name;
207  int (*rc_query) (struct dvb_usb_device *d);
209  bool bulk_mode; /* uses bulk mode */
210 };
211 
221 };
222 
260 #define MAX_NO_OF_ADAPTER_PER_DEVICE 2
262 
263 #define DVB_USB_IS_AN_I2C_ADAPTER 0x01
264  int caps;
265 
266 #define DEVICE_SPECIFIC 0
267 #define CYPRESS_AN2135 1
268 #define CYPRESS_AN2235 2
269 #define CYPRESS_FX2 3
270  int usb_ctrl;
271  int (*download_firmware) (struct usb_device *, const struct firmware *);
272  const char *firmware;
274 
276 
279 
282  int (*identify_state) (struct usb_device *, struct dvb_usb_device_properties *,
283  struct dvb_usb_device_description **, int *);
284 
285  struct {
286  enum dvb_usb_mode mode; /* Drivers shouldn't touch on it */
288  struct dvb_rc core;
289  } rc;
290 
292 
295 
298 };
299 
310 #define MAX_NO_URBS_FOR_DATA_STREAM 10
312  struct usb_device *udev;
314 
315 #define USB_STATE_INIT 0x00
316 #define USB_STATE_URB_BUF 0x01
317  int state;
318 
319  void (*complete) (struct usb_data_stream *, u8 *, size_t);
320 
322  int buf_num;
323  unsigned long buf_size;
326 
329 
330  void *user_priv;
331 };
332 
359  struct dvb_frontend *fe;
360 
361  int (*fe_init) (struct dvb_frontend *);
362  int (*fe_sleep) (struct dvb_frontend *);
363 
365 
368 
369  void *priv;
370 };
371 
375 
376 #define DVB_USB_ADAP_STATE_INIT 0x000
377 #define DVB_USB_ADAP_STATE_DVB 0x001
378  int state;
379 
381 
383 
384  /* dvb */
386  struct dmxdev dmxdev;
387  struct dvb_demux demux;
388  struct dvb_net dvb_net;
389 
393 
394  void *priv;
395 };
396 
424 
425  struct usb_device *udev;
426 
427 #define DVB_USB_STATE_INIT 0x000
428 #define DVB_USB_STATE_I2C 0x001
429 #define DVB_USB_STATE_DVB 0x002
430 #define DVB_USB_STATE_REMOTE 0x004
431  int state;
432 
433  int powered;
434 
435  /* locking */
436  struct mutex usb_mutex;
437 
438  /* i2c */
439  struct mutex i2c_mutex;
441 
444 
445  /* remote control */
446  struct rc_dev *rc_dev;
448  char rc_phys[64];
452 
453  struct module *owner;
454 
455  void *priv;
456 };
457 
458 extern int dvb_usb_device_init(struct usb_interface *,
459  struct dvb_usb_device_properties *,
460  struct module *, struct dvb_usb_device **,
461  short *adapter_nums);
462 extern void dvb_usb_device_exit(struct usb_interface *);
463 
464 /* the generic read/write method for device control */
465 extern int dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,int);
466 extern int dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16);
467 
468 /* commonly used remote control parsing */
469 extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *);
470 
471 /* commonly used firmware download types and function */
472 struct hexline {
476  u8 data[255];
478 };
479 extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type);
480 extern int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos);
481 
482 
483 #endif