1 /* dvb-usb.h is part of the DVB USB library.
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
4 * see dvb-usb-init.c for copyright information.
6 * the headerfile, all dvb-usb-drivers have to include.
11 #include <linux/config.h>
12 #include <linux/input.h>
13 #include <linux/module.h>
14 #include <linux/usb.h>
16 #include "dvb_frontend.h"
17 #include "dvb_demux.h"
23 #include "dvb-usb-ids.h"
26 #ifdef CONFIG_DVB_USB_DEBUG
27 #define dprintk(var,level,args...) \
28 do { if ((var & level)) { printk(args); } } while (0)
30 #define debug_dump(b,l,func) {\
32 for (loop_ = 0; loop_ < l; loop_++) func("%02x ", b[loop_]); \
35 #define DVB_USB_DEBUG_STATUS
37 #define dprintk(args...)
38 #define debug_dump(b,l,func)
40 #define DVB_USB_DEBUG_STATUS " (debugging is not enabled)"
44 /* generic log methods - taken from usb.h */
45 #ifndef DVB_USB_LOG_PREFIX
46 #define DVB_USB_LOG_PREFIX "dvb-usb (please define a log prefix)"
50 #define err(format, arg...) printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
52 #define info(format, arg...) printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
54 #define warn(format, arg...) printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
57 * struct dvb_usb_device_description - name and its according USB IDs
58 * @name: real name of the box, regardless which DVB USB device class is in use
59 * @cold_ids: array of struct usb_device_id which describe the device in
61 * @warm_ids: array of struct usb_device_id which describe the device in
64 * Each DVB USB device class can have one or more actual devices, this struct
65 * assigns a name to it.
67 struct dvb_usb_device_description {
70 #define DVB_USB_ID_MAX_NUM 15
71 struct usb_device_id *cold_ids[DVB_USB_ID_MAX_NUM];
72 struct usb_device_id *warm_ids[DVB_USB_ID_MAX_NUM];
76 * struct dvb_usb_rc_key - a remote control key and its input-event
77 * @custom: the vendor/custom part of the key
78 * @data: the actual key part
79 * @event: the input event assigned to key identified by custom and data
81 struct dvb_usb_rc_key {
86 struct dvb_usb_device;
89 * struct dvb_usb_properties - properties of a dvb-usb-device
90 * @caps: capabilites of the DVB USB device.
91 * @pid_filter_count: number of PID filter position in the optional hardware
94 * @usb_ctrl: which USB device-side controller is in use. Needed for firmware
96 * @firmware: name of the firmware file.
98 * @size_of_priv: how many bytes shall be allocated for the private field
99 * of struct dvb_usb_device.
101 * @power_ctrl: called to enable/disable power of the device.
102 * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the
103 * device (not URB submitting/killing).
104 * @pid_filter_ctrl: called to en/disable the PID filter, if any.
105 * @pid_filter: called to set/unset a PID for filtering.
107 * @read_mac_address: called to read the MAC address of the device.
109 * @frontend_attach: called to attach the possible frontends (fill fe-field
110 * of struct dvb_usb_device).
111 * @tuner_attach: called to attach the correct tuner and to fill pll_addr,
112 * pll_desc and pll_init_buf of struct dvb_usb_device).
113 * @identify_state: called to determine the state (cold or warm), when it
114 * is not distinguishable by the USB IDs.
116 * @rc_key_map: a hard-wired array of struct dvb_usb_rc_key (NULL to disable
117 * remote control handling).
118 * @rc_key_map_size: number of items in @rc_key_map.
119 * @rc_query: called to query an event event.
120 * @rc_interval: time in ms between two queries.
122 * @i2c_algo: i2c_algorithm if the device has I2CoverUSB.
124 * @generic_bulk_ctrl_endpoint: most of the DVB USB devices have a generic
125 * endpoint which received control messages with bulk transfers. When this
126 * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write-
129 * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming.
132 * @num_device_descs: number of struct dvb_usb_device_description in @devices
133 * @devices: array of struct dvb_usb_device_description compatibles with these
136 struct dvb_usb_properties {
138 #define DVB_USB_HAS_PID_FILTER 0x01
139 #define DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF 0x02
140 #define DVB_USB_NEED_PID_FILTERING 0x04
141 #define DVB_USB_IS_AN_I2C_ADAPTER 0x08
143 int pid_filter_count;
145 #define CYPRESS_AN2135 0
146 #define CYPRESS_AN2235 1
147 #define CYPRESS_FX2 2
149 const char *firmware;
153 int (*power_ctrl) (struct dvb_usb_device *, int);
154 int (*streaming_ctrl) (struct dvb_usb_device *, int);
155 int (*pid_filter_ctrl) (struct dvb_usb_device *, int);
156 int (*pid_filter) (struct dvb_usb_device *, int, u16, int);
158 int (*read_mac_address) (struct dvb_usb_device *, u8 []);
159 int (*frontend_attach) (struct dvb_usb_device *);
160 int (*tuner_attach) (struct dvb_usb_device *);
162 int (*identify_state) (struct usb_device *, struct dvb_usb_properties *,
163 struct dvb_usb_device_description **, int *);
165 /* remote control properties */
166 #define REMOTE_NO_KEY_PRESSED 0x00
167 #define REMOTE_KEY_PRESSED 0x01
168 #define REMOTE_KEY_REPEAT 0x02
169 struct dvb_usb_rc_key *rc_key_map;
171 int (*rc_query) (struct dvb_usb_device *, u32 *, int *);
174 struct i2c_algorithm *i2c_algo;
176 int generic_bulk_ctrl_endpoint;
179 #define DVB_USB_BULK 1
180 #define DVB_USB_ISOC 2
187 int buffersize; /* per URB */
197 int num_device_descs;
198 struct dvb_usb_device_description devices[9];
203 * struct dvb_usb_device - object of a DVB USB device
204 * @props: copy of the struct dvb_usb_properties this device belongs to.
205 * @desc: pointer to the device's struct dvb_usb_device_description.
206 * @state: initialization and runtime state of the device.
208 * @udev: pointer to the device's struct usb_device.
209 * @urb_list: array of dynamically allocated struct urb for the MPEG2-TS-
212 * @buf_num: number of buffer allocated.
213 * @buf_size: size of each buffer in buf_list.
214 * @buf_list: array containing all allocate buffers for streaming.
215 * @dma_addr: list of dma_addr_t for each buffer in buf_list.
217 * @urbs_initialized: number of URBs initialized.
218 * @urbs_submitted: number of URBs submitted.
220 * @feedcount: number of reqested feeds (used for streaming-activation)
221 * @pid_filtering: is hardware pid_filtering used or not.
223 * @usb_sem: semaphore of USB control messages (reading needs two messages)
224 * @i2c_sem: semaphore for i2c-transfers
226 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
227 * @pll_addr: I2C address of the tuner for programming
228 * @pll_init: array containing the initialization buffer
229 * @pll_desc: pointer to the appropriate struct dvb_pll_desc
231 * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board
233 * @dvb_adap: device's dvb_adapter.
234 * @dmxdev: device's dmxdev.
235 * @demux: device's software demuxer.
236 * @dvb_net: device's dvb_net interfaces.
237 * @dvb_frontend: device's frontend.
238 * @max_feed_count: how many feeds can be handled simultaneously by this
240 * @fe_sleep: rerouted frontend-sleep function.
241 * @fe_init: rerouted frontend-init (wakeup) function.
242 * @rc_input_dev: input device for the remote control.
243 * @rc_query_work: struct work_struct frequent rc queries
244 * @last_event: last triggered event
245 * @last_state: last state (no, pressed, repeat)
246 * @owner: owner of the dvb_adapter
247 * @priv: private data of the actual driver (allocate by dvb-usb, size defined
248 * in size_of_priv of dvb_usb_properties).
250 struct dvb_usb_device {
251 struct dvb_usb_properties props;
252 struct dvb_usb_device_description *desc;
254 #define DVB_USB_STATE_INIT 0x000
255 #define DVB_USB_STATE_URB_LIST 0x001
256 #define DVB_USB_STATE_URB_BUF 0x002
257 #define DVB_USB_STATE_DVB 0x004
258 #define DVB_USB_STATE_I2C 0x008
259 #define DVB_USB_STATE_REMOTE 0x010
260 #define DVB_USB_STATE_URB_SUBMIT 0x020
264 struct usb_device *udev;
265 struct urb **urb_list;
268 unsigned long buf_size;
270 dma_addr_t *dma_addr;
272 int urbs_initialized;
279 struct semaphore usb_sem;
282 struct semaphore i2c_sem;
283 struct i2c_adapter i2c_adap;
285 /* tuner programming information */
288 struct dvb_pll_desc *pll_desc;
289 int (*tuner_pass_ctrl)(struct dvb_frontend *, int, u8);
292 struct dvb_adapter dvb_adap;
293 struct dmxdev dmxdev;
294 struct dvb_demux demux;
295 struct dvb_net dvb_net;
296 struct dvb_frontend* fe;
299 int (*fe_sleep) (struct dvb_frontend *);
300 int (*fe_init) (struct dvb_frontend *);
303 struct input_dev *rc_input_dev;
305 struct work_struct rc_query_work;
309 struct module *owner;
314 extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **);
315 extern void dvb_usb_device_exit(struct usb_interface *);
317 /* the generic read/write method for device control */
318 extern int dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,int);
319 extern int dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16);
321 /* commonly used remote control parsing */
322 extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *);
324 /* commonly used pll init and set functions */
325 extern int dvb_usb_pll_init_i2c(struct dvb_frontend *);
326 extern int dvb_usb_pll_set(struct dvb_frontend *, struct dvb_frontend_parameters *, u8[]);
327 extern int dvb_usb_pll_set_i2c(struct dvb_frontend *, struct dvb_frontend_parameters *);