blob: a3e77b2e22617be0d5da80334496c6ae48cd0459 [file] [log] [blame]
Johannes Stezenbach776338e2005-06-23 22:02:35 -07001/* dvb-usb.h is part of the DVB USB library.
2 *
Patrick Boettcher4d43e132006-09-30 06:53:48 -03003 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
Johannes Stezenbach776338e2005-06-23 22:02:35 -07004 * see dvb-usb-init.c for copyright information.
5 *
6 * the headerfile, all dvb-usb-drivers have to include.
Patrick Boettcher4d43e132006-09-30 06:53:48 -03007 *
8 * TODO: clean-up the structures for unused fields and update the comments
Johannes Stezenbach776338e2005-06-23 22:02:35 -07009 */
10#ifndef __DVB_USB_H__
11#define __DVB_USB_H__
12
Johannes Stezenbach776338e2005-06-23 22:02:35 -070013#include <linux/input.h>
Johannes Stezenbach776338e2005-06-23 22:02:35 -070014#include <linux/usb.h>
Patrick Boettcherd3707ad2006-01-09 15:25:04 -020015#include <linux/firmware.h>
Ingo Molnar3593cab2006-02-07 06:49:14 -020016#include <linux/mutex.h>
Mauro Carvalho Chehab6bda9642010-11-17 13:28:38 -030017#include <media/rc-core.h>
Johannes Stezenbach776338e2005-06-23 22:02:35 -070018
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
59/**
60 * struct dvb_usb_device_description - name and its according USB IDs
61 * @name: real name of the box, regardless which DVB USB device class is in use
62 * @cold_ids: array of struct usb_device_id which describe the device in
63 * pre-firmware state
64 * @warm_ids: array of struct usb_device_id which describe the device in
65 * post-firmware state
66 *
67 * Each DVB USB device class can have one or more actual devices, this struct
68 * assigns a name to it.
69 */
70struct dvb_usb_device_description {
71 const char *name;
72
73#define DVB_USB_ID_MAX_NUM 15
74 struct usb_device_id *cold_ids[DVB_USB_ID_MAX_NUM];
75 struct usb_device_id *warm_ids[DVB_USB_ID_MAX_NUM];
76};
77
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -030078static inline u8 rc5_custom(struct rc_map_table *key)
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -030079{
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -030080 return (key->scancode >> 8) & 0xff;
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -030081}
82
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -030083static inline u8 rc5_data(struct rc_map_table *key)
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -030084{
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -030085 return key->scancode & 0xff;
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -030086}
87
Manoel Pinheiro147b68c2011-05-07 03:49:13 -030088static inline u16 rc5_scan(struct rc_map_table *key)
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -030089{
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -030090 return key->scancode & 0xffff;
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -030091}
92
Johannes Stezenbach776338e2005-06-23 22:02:35 -070093struct dvb_usb_device;
Patrick Boettcher4d43e132006-09-30 06:53:48 -030094struct dvb_usb_adapter;
95struct usb_data_stream;
Johannes Stezenbach776338e2005-06-23 22:02:35 -070096
97/**
Patrick Boettcher136cafb2006-09-19 12:51:33 -030098 * Properties of USB streaming - TODO this structure should be somewhere else
99 * describes the kind of USB transfer used for data-streaming.
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300100 * (BULK or ISOC)
101 */
102struct usb_data_stream_properties {
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 {
114 int framesperurb;
115 int framesize;
116 int interval;
117 } isoc;
118 } u;
119};
120
121/**
122 * struct dvb_usb_adapter_properties - properties of a dvb-usb-adapter.
123 * A DVB-USB-Adapter is basically a dvb_adapter which is present on a USB-device.
Alexey Dobriyanbe787ac2006-03-07 22:20:23 -0300124 * @caps: capabilities of the DVB USB device.
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700125 * @pid_filter_count: number of PID filter position in the optional hardware
126 * PID-filter.
Antti Palosaari9bd9e3b2011-07-25 20:16:13 -0300127 * @num_frontends: number of frontends of the DVB USB adapter.
128 * @frontend_ctrl: called to power on/off active frontend.
Michael Krufky09129f02007-05-04 22:51:04 -0300129 * @streaming_ctrl: called to start and stop the MPEG2-TS streaming of the
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300130 * device (not URB submitting/killing).
131 * @pid_filter_ctrl: called to en/disable the PID filter, if any.
132 * @pid_filter: called to set/unset a PID for filtering.
133 * @frontend_attach: called to attach the possible frontends (fill fe-field
134 * of struct dvb_usb_device).
135 * @tuner_attach: called to attach the correct tuner and to fill pll_addr,
136 * pll_desc and pll_init_buf of struct dvb_usb_device).
137 * @stream: configuration of the USB streaming
138 */
139struct dvb_usb_adapter_properties {
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
Patrick Boettcher0540c492006-09-19 12:51:43 -0300143#define DVB_USB_ADAP_RECEIVES_204_BYTE_TS 0x08
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300144 int caps;
145 int pid_filter_count;
Antti Palosaari9bd9e3b2011-07-25 20:16:13 -0300146 int num_frontends;
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300147
Antti Palosaari9bd9e3b2011-07-25 20:16:13 -0300148 int (*frontend_ctrl) (struct dvb_frontend *, int);
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300149 int (*streaming_ctrl) (struct dvb_usb_adapter *, int);
150 int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
151 int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int);
152
153 int (*frontend_attach) (struct dvb_usb_adapter *);
154 int (*tuner_attach) (struct dvb_usb_adapter *);
155
156 struct usb_data_stream_properties stream;
157
158 int size_of_priv;
Michael Krufky94d98312009-09-07 13:32:29 -0300159
160 int (*fe_ioctl_override) (struct dvb_frontend *,
161 unsigned int, void *, unsigned int);
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300162};
163
164/**
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -0300165 * struct dvb_rc_legacy - old properties of remote controller
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300166 * @rc_map_table: a hard-wired array of struct rc_map_table (NULL to disable
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -0300167 * remote control handling).
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300168 * @rc_map_size: number of items in @rc_map_table.
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -0300169 * @rc_query: called to query an event event.
170 * @rc_interval: time in ms between two queries.
171 */
172struct dvb_rc_legacy {
173/* remote control properties */
174#define REMOTE_NO_KEY_PRESSED 0x00
175#define REMOTE_KEY_PRESSED 0x01
176#define REMOTE_KEY_REPEAT 0x02
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300177 struct rc_map_table *rc_map_table;
178 int rc_map_size;
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -0300179 int (*rc_query) (struct dvb_usb_device *, u32 *, int *);
180 int rc_interval;
181};
182
183/**
Mauro Carvalho Chehab65203422010-07-31 19:07:55 -0300184 * struct dvb_rc properties of remote controller, using rc-core
185 * @rc_codes: name of rc codes table
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -0300186 * @protocol: type of protocol(s) currently used by the driver
David Härdemand8b4b582010-10-29 16:08:23 -0300187 * @allowed_protos: protocol(s) supported by the driver
Patrick Boettcher739ff042010-10-31 16:24:19 -0300188 * @driver_type: Used to point if a device supports raw mode
David Härdemand8b4b582010-10-29 16:08:23 -0300189 * @change_protocol: callback to change protocol
Mauro Carvalho Chehab65203422010-07-31 19:07:55 -0300190 * @rc_query: called to query an event event.
191 * @rc_interval: time in ms between two queries.
Mauro Carvalho Chehab65203422010-07-31 19:07:55 -0300192 * @bulk_mode: device supports bulk mode for RC (disable polling mode)
193 */
194struct dvb_rc {
195 char *rc_codes;
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -0300196 u64 protocol;
David Härdemand8b4b582010-10-29 16:08:23 -0300197 u64 allowed_protos;
Patrick Boettcher739ff042010-10-31 16:24:19 -0300198 enum rc_driver_type driver_type;
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -0300199 int (*change_protocol)(struct rc_dev *dev, u64 rc_type);
Mauro Carvalho Chehab65203422010-07-31 19:07:55 -0300200 char *module_name;
201 int (*rc_query) (struct dvb_usb_device *d);
202 int rc_interval;
Mauro Carvalho Chehab65203422010-07-31 19:07:55 -0300203 bool bulk_mode; /* uses bulk mode */
204};
205
206/**
207 * enum dvb_usb_mode - Specifies if it is using a legacy driver or a new one
208 * based on rc-core
209 * This is initialized/used only inside dvb-usb-remote.c.
210 * It shouldn't be set by the drivers.
211 */
212enum dvb_usb_mode {
213 DVB_RC_LEGACY,
214 DVB_RC_CORE,
215};
216
217/**
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300218 * struct dvb_usb_device_properties - properties of a dvb-usb-device
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700219 * @usb_ctrl: which USB device-side controller is in use. Needed for firmware
220 * download.
221 * @firmware: name of the firmware file.
Patrick Boettcherd3707ad2006-01-09 15:25:04 -0200222 * @download_firmware: called to download the firmware when the usb_ctrl is
223 * DEVICE_SPECIFIC.
224 * @no_reconnect: device doesn't do a reconnect after downloading the firmware,
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300225 * so do the warm initialization right after it
226 *
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700227 * @size_of_priv: how many bytes shall be allocated for the private field
228 * of struct dvb_usb_device.
229 *
230 * @power_ctrl: called to enable/disable power of the device.
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700231 * @read_mac_address: called to read the MAC address of the device.
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700232 * @identify_state: called to determine the state (cold or warm), when it
233 * is not distinguishable by the USB IDs.
234 *
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -0300235 * @rc: remote controller properties
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700236 *
237 * @i2c_algo: i2c_algorithm if the device has I2CoverUSB.
238 *
239 * @generic_bulk_ctrl_endpoint: most of the DVB USB devices have a generic
240 * endpoint which received control messages with bulk transfers. When this
241 * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write-
242 * helper functions.
243 *
Michael Krufky46056642010-01-31 21:06:10 -0300244 * @generic_bulk_ctrl_endpoint_response: some DVB USB devices use a separate
245 * endpoint for responses to control messages sent with bulk transfers via
246 * the generic_bulk_ctrl_endpoint. When this is non-zero, this will be used
247 * instead of the generic_bulk_ctrl_endpoint when reading usb responses in
248 * the dvb_usb_generic_rw helper function.
249 *
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700250 * @num_device_descs: number of struct dvb_usb_device_description in @devices
251 * @devices: array of struct dvb_usb_device_description compatibles with these
252 * properties.
253 */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300254#define MAX_NO_OF_ADAPTER_PER_DEVICE 2
255struct dvb_usb_device_properties {
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700256
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300257#define DVB_USB_IS_AN_I2C_ADAPTER 0x01
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700258 int caps;
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700259
Patrick Boettcherd3707ad2006-01-09 15:25:04 -0200260#define DEVICE_SPECIFIC 0
261#define CYPRESS_AN2135 1
262#define CYPRESS_AN2235 2
263#define CYPRESS_FX2 3
Patrick Boettcher136cafb2006-09-19 12:51:33 -0300264 int usb_ctrl;
265 int (*download_firmware) (struct usb_device *, const struct firmware *);
Samuel Ortiz56aec8d82009-05-27 00:49:34 +0200266 const char *firmware;
Patrick Boettcher136cafb2006-09-19 12:51:33 -0300267 int no_reconnect;
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700268
269 int size_of_priv;
270
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300271 int num_adapters;
272 struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700273
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300274 int (*power_ctrl) (struct dvb_usb_device *, int);
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700275 int (*read_mac_address) (struct dvb_usb_device *, u8 []);
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300276 int (*identify_state) (struct usb_device *, struct dvb_usb_device_properties *,
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700277 struct dvb_usb_device_description **, int *);
278
Mauro Carvalho Chehab65203422010-07-31 19:07:55 -0300279 struct {
280 enum dvb_usb_mode mode; /* Drivers shouldn't touch on it */
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -0300281 struct dvb_rc_legacy legacy;
Mauro Carvalho Chehab65203422010-07-31 19:07:55 -0300282 struct dvb_rc core;
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -0300283 } rc;
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700284
285 struct i2c_algorithm *i2c_algo;
286
287 int generic_bulk_ctrl_endpoint;
Michael Krufky46056642010-01-31 21:06:10 -0300288 int generic_bulk_ctrl_endpoint_response;
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700289
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700290 int num_device_descs;
Armin Schenker513846e2009-04-20 11:57:49 -0300291 struct dvb_usb_device_description devices[12];
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700292};
293
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700294/**
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300295 * struct usb_data_stream - generic object of an USB stream
Patrick Boettcher7f5fee52005-07-07 17:58:08 -0700296 * @buf_num: number of buffer allocated.
297 * @buf_size: size of each buffer in buf_list.
298 * @buf_list: array containing all allocate buffers for streaming.
299 * @dma_addr: list of dma_addr_t for each buffer in buf_list.
300 *
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700301 * @urbs_initialized: number of URBs initialized.
302 * @urbs_submitted: number of URBs submitted.
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300303 */
304#define MAX_NO_URBS_FOR_DATA_STREAM 10
305struct usb_data_stream {
Patrick Boettcher136cafb2006-09-19 12:51:33 -0300306 struct usb_device *udev;
307 struct usb_data_stream_properties props;
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300308
309#define USB_STATE_INIT 0x00
310#define USB_STATE_URB_BUF 0x01
311 int state;
312
313 void (*complete) (struct usb_data_stream *, u8 *, size_t);
314
Patrick Boettcher136cafb2006-09-19 12:51:33 -0300315 struct urb *urb_list[MAX_NO_URBS_FOR_DATA_STREAM];
316 int buf_num;
317 unsigned long buf_size;
318 u8 *buf_list[MAX_NO_URBS_FOR_DATA_STREAM];
319 dma_addr_t dma_addr[MAX_NO_URBS_FOR_DATA_STREAM];
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300320
321 int urbs_initialized;
322 int urbs_submitted;
323
324 void *user_priv;
325};
326
327/**
328 * struct dvb_usb_adapter - a DVB adapter on a USB device
329 * @id: index of this adapter (starting with 0).
330 *
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700331 * @feedcount: number of reqested feeds (used for streaming-activation)
332 * @pid_filtering: is hardware pid_filtering used or not.
Patrick Boettcher7f5fee52005-07-07 17:58:08 -0700333 *
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700334 * @pll_addr: I2C address of the tuner for programming
335 * @pll_init: array containing the initialization buffer
336 * @pll_desc: pointer to the appropriate struct dvb_pll_desc
Patrick Boettcher7f5fee52005-07-07 17:58:08 -0700337 * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board
Patrick Boettcher136cafb2006-09-19 12:51:33 -0300338 *
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700339 * @dvb_adap: device's dvb_adapter.
340 * @dmxdev: device's dmxdev.
341 * @demux: device's software demuxer.
342 * @dvb_net: device's dvb_net interfaces.
343 * @dvb_frontend: device's frontend.
344 * @max_feed_count: how many feeds can be handled simultaneously by this
345 * device
Patrick Boettcher136cafb2006-09-19 12:51:33 -0300346 *
347 * @fe_init: rerouted frontend-init (wakeup) function.
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700348 * @fe_sleep: rerouted frontend-sleep function.
Patrick Boettcher136cafb2006-09-19 12:51:33 -0300349 *
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300350 * @stream: the usb data stream.
351 */
Antti Palosaari9bd9e3b2011-07-25 20:16:13 -0300352#define MAX_NO_OF_FE_PER_ADAP 2
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300353struct dvb_usb_adapter {
354 struct dvb_usb_device *dev;
355 struct dvb_usb_adapter_properties props;
356
357#define DVB_USB_ADAP_STATE_INIT 0x000
358#define DVB_USB_ADAP_STATE_DVB 0x001
359 int state;
360
Patrick Boettcher136cafb2006-09-19 12:51:33 -0300361 u8 id;
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300362
363 int feedcount;
364 int pid_filtering;
365
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300366 /* dvb */
367 struct dvb_adapter dvb_adap;
368 struct dmxdev dmxdev;
369 struct dvb_demux demux;
370 struct dvb_net dvb_net;
Antti Palosaari9bd9e3b2011-07-25 20:16:13 -0300371 struct dvb_frontend *fe[MAX_NO_OF_FE_PER_ADAP];
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300372 int max_feed_count;
373
Antti Palosaari9bd9e3b2011-07-25 20:16:13 -0300374 int (*fe_init[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
375 int (*fe_sleep[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300376
377 struct usb_data_stream stream;
378
379 void *priv;
380};
381
382/**
383 * struct dvb_usb_device - object of a DVB USB device
384 * @props: copy of the struct dvb_usb_properties this device belongs to.
385 * @desc: pointer to the device's struct dvb_usb_device_description.
386 * @state: initialization and runtime state of the device.
387 *
Patrick Boettchera37ddce2006-09-20 06:06:11 -0300388 * @powered: indicated whether the device is power or not.
389 * Powered is in/decremented for each call to modify the state.
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300390 * @udev: pointer to the device's struct usb_device.
391 *
392 * @usb_mutex: semaphore of USB control messages (reading needs two messages)
393 * @i2c_mutex: semaphore for i2c-transfers
394 *
395 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
396 *
David Härdemand8b4b582010-10-29 16:08:23 -0300397 * @rc_dev: rc device for the remote control (rc-core mode)
398 * @input_dev: input device for the remote control (legacy mode)
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700399 * @rc_query_work: struct work_struct frequent rc queries
400 * @last_event: last triggered event
401 * @last_state: last state (no, pressed, repeat)
402 * @owner: owner of the dvb_adapter
403 * @priv: private data of the actual driver (allocate by dvb-usb, size defined
404 * in size_of_priv of dvb_usb_properties).
405 */
406struct dvb_usb_device {
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300407 struct dvb_usb_device_properties props;
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700408 struct dvb_usb_device_description *desc;
409
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300410 struct usb_device *udev;
411
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700412#define DVB_USB_STATE_INIT 0x000
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300413#define DVB_USB_STATE_I2C 0x001
414#define DVB_USB_STATE_DVB 0x002
415#define DVB_USB_STATE_REMOTE 0x004
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700416 int state;
417
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300418 int powered;
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700419
420 /* locking */
Ingo Molnar3593cab2006-02-07 06:49:14 -0200421 struct mutex usb_mutex;
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700422
423 /* i2c */
Ingo Molnar3593cab2006-02-07 06:49:14 -0200424 struct mutex i2c_mutex;
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700425 struct i2c_adapter i2c_adap;
426
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300427 int num_adapters_initialized;
428 struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700429
430 /* remote control */
David Härdemand8b4b582010-10-29 16:08:23 -0300431 struct rc_dev *rc_dev;
432 struct input_dev *input_dev;
Dmitry Torokhovb7df3912005-09-15 02:01:53 -0500433 char rc_phys[64];
David Howellsc4028952006-11-22 14:57:56 +0000434 struct delayed_work rc_query_work;
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700435 u32 last_event;
436 int last_state;
437
438 struct module *owner;
439
440 void *priv;
441};
442
Janne Grunau78e92002008-04-09 19:13:13 -0300443extern int dvb_usb_device_init(struct usb_interface *,
444 struct dvb_usb_device_properties *,
445 struct module *, struct dvb_usb_device **,
446 short *adapter_nums);
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700447extern void dvb_usb_device_exit(struct usb_interface *);
448
449/* the generic read/write method for device control */
450extern int dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,int);
451extern int dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16);
452
453/* commonly used remote control parsing */
454extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *);
455
Patrick Boettcherd3707ad2006-01-09 15:25:04 -0200456/* commonly used firmware download types and function */
457struct hexline {
458 u8 len;
459 u32 addr;
460 u8 type;
461 u8 data[255];
462 u8 chk;
463};
Patrick Boettcherf5373782006-01-09 18:21:38 -0200464extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type);
Patrick Boettcher136cafb2006-09-19 12:51:33 -0300465extern int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos);
466
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700467
468#endif