Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 1 | /* dvb-usb.h is part of the DVB USB library. |
| 2 | * |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 3 | * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 4 | * see dvb-usb-init.c for copyright information. |
| 5 | * |
| 6 | * the headerfile, all dvb-usb-drivers have to include. |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 7 | * |
| 8 | * TODO: clean-up the structures for unused fields and update the comments |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 9 | */ |
| 10 | #ifndef __DVB_USB_H__ |
| 11 | #define __DVB_USB_H__ |
| 12 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 13 | #include <linux/input.h> |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 14 | #include <linux/usb.h> |
Patrick Boettcher | d3707ad | 2006-01-09 15:25:04 -0200 | [diff] [blame] | 15 | #include <linux/firmware.h> |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 16 | #include <linux/mutex.h> |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 17 | |
| 18 | #include "dvb_frontend.h" |
| 19 | #include "dvb_demux.h" |
| 20 | #include "dvb_net.h" |
| 21 | #include "dmxdev.h" |
| 22 | |
| 23 | #include "dvb-pll.h" |
| 24 | |
| 25 | #include "dvb-usb-ids.h" |
| 26 | |
| 27 | /* debug */ |
| 28 | #ifdef CONFIG_DVB_USB_DEBUG |
| 29 | #define dprintk(var,level,args...) \ |
| 30 | do { if ((var & level)) { printk(args); } } while (0) |
| 31 | |
| 32 | #define debug_dump(b,l,func) {\ |
| 33 | int loop_; \ |
| 34 | for (loop_ = 0; loop_ < l; loop_++) func("%02x ", b[loop_]); \ |
| 35 | func("\n");\ |
| 36 | } |
| 37 | #define DVB_USB_DEBUG_STATUS |
| 38 | #else |
| 39 | #define dprintk(args...) |
| 40 | #define debug_dump(b,l,func) |
| 41 | |
| 42 | #define DVB_USB_DEBUG_STATUS " (debugging is not enabled)" |
| 43 | |
| 44 | #endif |
| 45 | |
| 46 | /* generic log methods - taken from usb.h */ |
| 47 | #ifndef DVB_USB_LOG_PREFIX |
| 48 | #define DVB_USB_LOG_PREFIX "dvb-usb (please define a log prefix)" |
| 49 | #endif |
| 50 | |
| 51 | #undef err |
| 52 | #define err(format, arg...) printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) |
| 53 | #undef info |
| 54 | #define info(format, arg...) printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) |
| 55 | #undef warn |
| 56 | #define warn(format, arg...) printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) |
| 57 | |
| 58 | /** |
| 59 | * struct dvb_usb_device_description - name and its according USB IDs |
| 60 | * @name: real name of the box, regardless which DVB USB device class is in use |
| 61 | * @cold_ids: array of struct usb_device_id which describe the device in |
| 62 | * pre-firmware state |
| 63 | * @warm_ids: array of struct usb_device_id which describe the device in |
| 64 | * post-firmware state |
| 65 | * |
| 66 | * Each DVB USB device class can have one or more actual devices, this struct |
| 67 | * assigns a name to it. |
| 68 | */ |
| 69 | struct dvb_usb_device_description { |
| 70 | const char *name; |
| 71 | |
| 72 | #define DVB_USB_ID_MAX_NUM 15 |
| 73 | struct usb_device_id *cold_ids[DVB_USB_ID_MAX_NUM]; |
| 74 | struct usb_device_id *warm_ids[DVB_USB_ID_MAX_NUM]; |
| 75 | }; |
| 76 | |
| 77 | /** |
| 78 | * struct dvb_usb_rc_key - a remote control key and its input-event |
| 79 | * @custom: the vendor/custom part of the key |
| 80 | * @data: the actual key part |
| 81 | * @event: the input event assigned to key identified by custom and data |
| 82 | */ |
| 83 | struct dvb_usb_rc_key { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 84 | u16 scan; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 85 | u32 event; |
| 86 | }; |
| 87 | |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 88 | static inline u8 rc5_custom(struct dvb_usb_rc_key *key) |
| 89 | { |
| 90 | return (key->scan >> 8) & 0xff; |
| 91 | } |
| 92 | |
| 93 | static inline u8 rc5_data(struct dvb_usb_rc_key *key) |
| 94 | { |
| 95 | return key->scan & 0xff; |
| 96 | } |
| 97 | |
| 98 | static inline u8 rc5_scan(struct dvb_usb_rc_key *key) |
| 99 | { |
| 100 | return key->scan & 0xffff; |
| 101 | } |
| 102 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 103 | struct dvb_usb_device; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 104 | struct dvb_usb_adapter; |
| 105 | struct usb_data_stream; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 106 | |
| 107 | /** |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 108 | * Properties of USB streaming - TODO this structure should be somewhere else |
| 109 | * describes the kind of USB transfer used for data-streaming. |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 110 | * (BULK or ISOC) |
| 111 | */ |
| 112 | struct usb_data_stream_properties { |
| 113 | #define USB_BULK 1 |
| 114 | #define USB_ISOC 2 |
| 115 | int type; |
| 116 | int count; |
| 117 | int endpoint; |
| 118 | |
| 119 | union { |
| 120 | struct { |
| 121 | int buffersize; /* per URB */ |
| 122 | } bulk; |
| 123 | struct { |
| 124 | int framesperurb; |
| 125 | int framesize; |
| 126 | int interval; |
| 127 | } isoc; |
| 128 | } u; |
| 129 | }; |
| 130 | |
| 131 | /** |
| 132 | * struct dvb_usb_adapter_properties - properties of a dvb-usb-adapter. |
| 133 | * A DVB-USB-Adapter is basically a dvb_adapter which is present on a USB-device. |
Alexey Dobriyan | be787ac | 2006-03-07 22:20:23 -0300 | [diff] [blame] | 134 | * @caps: capabilities of the DVB USB device. |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 135 | * @pid_filter_count: number of PID filter position in the optional hardware |
| 136 | * PID-filter. |
Michael Krufky | 09129f0 | 2007-05-04 22:51:04 -0300 | [diff] [blame] | 137 | * @streaming_ctrl: called to start and stop the MPEG2-TS streaming of the |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 138 | * device (not URB submitting/killing). |
| 139 | * @pid_filter_ctrl: called to en/disable the PID filter, if any. |
| 140 | * @pid_filter: called to set/unset a PID for filtering. |
| 141 | * @frontend_attach: called to attach the possible frontends (fill fe-field |
| 142 | * of struct dvb_usb_device). |
| 143 | * @tuner_attach: called to attach the correct tuner and to fill pll_addr, |
| 144 | * pll_desc and pll_init_buf of struct dvb_usb_device). |
| 145 | * @stream: configuration of the USB streaming |
| 146 | */ |
| 147 | struct dvb_usb_adapter_properties { |
| 148 | #define DVB_USB_ADAP_HAS_PID_FILTER 0x01 |
| 149 | #define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02 |
| 150 | #define DVB_USB_ADAP_NEED_PID_FILTERING 0x04 |
Patrick Boettcher | 0540c49 | 2006-09-19 12:51:43 -0300 | [diff] [blame] | 151 | #define DVB_USB_ADAP_RECEIVES_204_BYTE_TS 0x08 |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 152 | int caps; |
| 153 | int pid_filter_count; |
| 154 | |
| 155 | int (*streaming_ctrl) (struct dvb_usb_adapter *, int); |
| 156 | int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int); |
| 157 | int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int); |
| 158 | |
| 159 | int (*frontend_attach) (struct dvb_usb_adapter *); |
| 160 | int (*tuner_attach) (struct dvb_usb_adapter *); |
| 161 | |
| 162 | struct usb_data_stream_properties stream; |
| 163 | |
| 164 | int size_of_priv; |
Michael Krufky | 94d9831 | 2009-09-07 13:32:29 -0300 | [diff] [blame] | 165 | |
| 166 | int (*fe_ioctl_override) (struct dvb_frontend *, |
| 167 | unsigned int, void *, unsigned int); |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | /** |
| 171 | * struct dvb_usb_device_properties - properties of a dvb-usb-device |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 172 | * @usb_ctrl: which USB device-side controller is in use. Needed for firmware |
| 173 | * download. |
| 174 | * @firmware: name of the firmware file. |
Patrick Boettcher | d3707ad | 2006-01-09 15:25:04 -0200 | [diff] [blame] | 175 | * @download_firmware: called to download the firmware when the usb_ctrl is |
| 176 | * DEVICE_SPECIFIC. |
| 177 | * @no_reconnect: device doesn't do a reconnect after downloading the firmware, |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 178 | * so do the warm initialization right after it |
| 179 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 180 | * @size_of_priv: how many bytes shall be allocated for the private field |
| 181 | * of struct dvb_usb_device. |
| 182 | * |
| 183 | * @power_ctrl: called to enable/disable power of the device. |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 184 | * @read_mac_address: called to read the MAC address of the device. |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 185 | * @identify_state: called to determine the state (cold or warm), when it |
| 186 | * is not distinguishable by the USB IDs. |
| 187 | * |
| 188 | * @rc_key_map: a hard-wired array of struct dvb_usb_rc_key (NULL to disable |
| 189 | * remote control handling). |
| 190 | * @rc_key_map_size: number of items in @rc_key_map. |
| 191 | * @rc_query: called to query an event event. |
| 192 | * @rc_interval: time in ms between two queries. |
| 193 | * |
| 194 | * @i2c_algo: i2c_algorithm if the device has I2CoverUSB. |
| 195 | * |
| 196 | * @generic_bulk_ctrl_endpoint: most of the DVB USB devices have a generic |
| 197 | * endpoint which received control messages with bulk transfers. When this |
| 198 | * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write- |
| 199 | * helper functions. |
| 200 | * |
Michael Krufky | 4605664 | 2010-01-31 21:06:10 -0300 | [diff] [blame] | 201 | * @generic_bulk_ctrl_endpoint_response: some DVB USB devices use a separate |
| 202 | * endpoint for responses to control messages sent with bulk transfers via |
| 203 | * the generic_bulk_ctrl_endpoint. When this is non-zero, this will be used |
| 204 | * instead of the generic_bulk_ctrl_endpoint when reading usb responses in |
| 205 | * the dvb_usb_generic_rw helper function. |
| 206 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 207 | * @num_device_descs: number of struct dvb_usb_device_description in @devices |
| 208 | * @devices: array of struct dvb_usb_device_description compatibles with these |
| 209 | * properties. |
| 210 | */ |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 211 | #define MAX_NO_OF_ADAPTER_PER_DEVICE 2 |
| 212 | struct dvb_usb_device_properties { |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 213 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 214 | #define DVB_USB_IS_AN_I2C_ADAPTER 0x01 |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 215 | int caps; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 216 | |
Patrick Boettcher | d3707ad | 2006-01-09 15:25:04 -0200 | [diff] [blame] | 217 | #define DEVICE_SPECIFIC 0 |
| 218 | #define CYPRESS_AN2135 1 |
| 219 | #define CYPRESS_AN2235 2 |
| 220 | #define CYPRESS_FX2 3 |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 221 | int usb_ctrl; |
| 222 | int (*download_firmware) (struct usb_device *, const struct firmware *); |
Samuel Ortiz | 56aec8d8 | 2009-05-27 00:49:34 +0200 | [diff] [blame] | 223 | const char *firmware; |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 224 | int no_reconnect; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 225 | |
| 226 | int size_of_priv; |
| 227 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 228 | int num_adapters; |
| 229 | struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 230 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 231 | int (*power_ctrl) (struct dvb_usb_device *, int); |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 232 | int (*read_mac_address) (struct dvb_usb_device *, u8 []); |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 233 | int (*identify_state) (struct usb_device *, struct dvb_usb_device_properties *, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 234 | struct dvb_usb_device_description **, int *); |
| 235 | |
| 236 | /* remote control properties */ |
| 237 | #define REMOTE_NO_KEY_PRESSED 0x00 |
| 238 | #define REMOTE_KEY_PRESSED 0x01 |
| 239 | #define REMOTE_KEY_REPEAT 0x02 |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 240 | struct dvb_usb_rc_key *rc_key_map; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 241 | int rc_key_map_size; |
| 242 | int (*rc_query) (struct dvb_usb_device *, u32 *, int *); |
| 243 | int rc_interval; |
| 244 | |
| 245 | struct i2c_algorithm *i2c_algo; |
| 246 | |
| 247 | int generic_bulk_ctrl_endpoint; |
Michael Krufky | 4605664 | 2010-01-31 21:06:10 -0300 | [diff] [blame] | 248 | int generic_bulk_ctrl_endpoint_response; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 249 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 250 | int num_device_descs; |
Armin Schenker | 513846e | 2009-04-20 11:57:49 -0300 | [diff] [blame] | 251 | struct dvb_usb_device_description devices[12]; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 252 | }; |
| 253 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 254 | /** |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 255 | * struct usb_data_stream - generic object of an USB stream |
Patrick Boettcher | 7f5fee5 | 2005-07-07 17:58:08 -0700 | [diff] [blame] | 256 | * @buf_num: number of buffer allocated. |
| 257 | * @buf_size: size of each buffer in buf_list. |
| 258 | * @buf_list: array containing all allocate buffers for streaming. |
| 259 | * @dma_addr: list of dma_addr_t for each buffer in buf_list. |
| 260 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 261 | * @urbs_initialized: number of URBs initialized. |
| 262 | * @urbs_submitted: number of URBs submitted. |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 263 | */ |
| 264 | #define MAX_NO_URBS_FOR_DATA_STREAM 10 |
| 265 | struct usb_data_stream { |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 266 | struct usb_device *udev; |
| 267 | struct usb_data_stream_properties props; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 268 | |
| 269 | #define USB_STATE_INIT 0x00 |
| 270 | #define USB_STATE_URB_BUF 0x01 |
| 271 | int state; |
| 272 | |
| 273 | void (*complete) (struct usb_data_stream *, u8 *, size_t); |
| 274 | |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 275 | struct urb *urb_list[MAX_NO_URBS_FOR_DATA_STREAM]; |
| 276 | int buf_num; |
| 277 | unsigned long buf_size; |
| 278 | u8 *buf_list[MAX_NO_URBS_FOR_DATA_STREAM]; |
| 279 | dma_addr_t dma_addr[MAX_NO_URBS_FOR_DATA_STREAM]; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 280 | |
| 281 | int urbs_initialized; |
| 282 | int urbs_submitted; |
| 283 | |
| 284 | void *user_priv; |
| 285 | }; |
| 286 | |
| 287 | /** |
| 288 | * struct dvb_usb_adapter - a DVB adapter on a USB device |
| 289 | * @id: index of this adapter (starting with 0). |
| 290 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 291 | * @feedcount: number of reqested feeds (used for streaming-activation) |
| 292 | * @pid_filtering: is hardware pid_filtering used or not. |
Patrick Boettcher | 7f5fee5 | 2005-07-07 17:58:08 -0700 | [diff] [blame] | 293 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 294 | * @pll_addr: I2C address of the tuner for programming |
| 295 | * @pll_init: array containing the initialization buffer |
| 296 | * @pll_desc: pointer to the appropriate struct dvb_pll_desc |
Patrick Boettcher | 7f5fee5 | 2005-07-07 17:58:08 -0700 | [diff] [blame] | 297 | * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 298 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 299 | * @dvb_adap: device's dvb_adapter. |
| 300 | * @dmxdev: device's dmxdev. |
| 301 | * @demux: device's software demuxer. |
| 302 | * @dvb_net: device's dvb_net interfaces. |
| 303 | * @dvb_frontend: device's frontend. |
| 304 | * @max_feed_count: how many feeds can be handled simultaneously by this |
| 305 | * device |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 306 | * |
| 307 | * @fe_init: rerouted frontend-init (wakeup) function. |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 308 | * @fe_sleep: rerouted frontend-sleep function. |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 309 | * |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 310 | * @stream: the usb data stream. |
| 311 | */ |
| 312 | struct dvb_usb_adapter { |
| 313 | struct dvb_usb_device *dev; |
| 314 | struct dvb_usb_adapter_properties props; |
| 315 | |
| 316 | #define DVB_USB_ADAP_STATE_INIT 0x000 |
| 317 | #define DVB_USB_ADAP_STATE_DVB 0x001 |
| 318 | int state; |
| 319 | |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 320 | u8 id; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 321 | |
| 322 | int feedcount; |
| 323 | int pid_filtering; |
| 324 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 325 | /* dvb */ |
| 326 | struct dvb_adapter dvb_adap; |
| 327 | struct dmxdev dmxdev; |
| 328 | struct dvb_demux demux; |
| 329 | struct dvb_net dvb_net; |
| 330 | struct dvb_frontend *fe; |
| 331 | int max_feed_count; |
| 332 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 333 | int (*fe_init) (struct dvb_frontend *); |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 334 | int (*fe_sleep) (struct dvb_frontend *); |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 335 | |
| 336 | struct usb_data_stream stream; |
| 337 | |
| 338 | void *priv; |
| 339 | }; |
| 340 | |
| 341 | /** |
| 342 | * struct dvb_usb_device - object of a DVB USB device |
| 343 | * @props: copy of the struct dvb_usb_properties this device belongs to. |
| 344 | * @desc: pointer to the device's struct dvb_usb_device_description. |
| 345 | * @state: initialization and runtime state of the device. |
| 346 | * |
Patrick Boettcher | a37ddce | 2006-09-20 06:06:11 -0300 | [diff] [blame] | 347 | * @powered: indicated whether the device is power or not. |
| 348 | * Powered is in/decremented for each call to modify the state. |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 349 | * @udev: pointer to the device's struct usb_device. |
| 350 | * |
| 351 | * @usb_mutex: semaphore of USB control messages (reading needs two messages) |
| 352 | * @i2c_mutex: semaphore for i2c-transfers |
| 353 | * |
| 354 | * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB |
| 355 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 356 | * @rc_input_dev: input device for the remote control. |
| 357 | * @rc_query_work: struct work_struct frequent rc queries |
| 358 | * @last_event: last triggered event |
| 359 | * @last_state: last state (no, pressed, repeat) |
| 360 | * @owner: owner of the dvb_adapter |
| 361 | * @priv: private data of the actual driver (allocate by dvb-usb, size defined |
| 362 | * in size_of_priv of dvb_usb_properties). |
| 363 | */ |
| 364 | struct dvb_usb_device { |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 365 | struct dvb_usb_device_properties props; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 366 | struct dvb_usb_device_description *desc; |
| 367 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 368 | struct usb_device *udev; |
| 369 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 370 | #define DVB_USB_STATE_INIT 0x000 |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 371 | #define DVB_USB_STATE_I2C 0x001 |
| 372 | #define DVB_USB_STATE_DVB 0x002 |
| 373 | #define DVB_USB_STATE_REMOTE 0x004 |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 374 | int state; |
| 375 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 376 | int powered; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 377 | |
| 378 | /* locking */ |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 379 | struct mutex usb_mutex; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 380 | |
| 381 | /* i2c */ |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 382 | struct mutex i2c_mutex; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 383 | struct i2c_adapter i2c_adap; |
| 384 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 385 | int num_adapters_initialized; |
| 386 | struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 387 | |
| 388 | /* remote control */ |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 389 | struct input_dev *rc_input_dev; |
| 390 | char rc_phys[64]; |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 391 | struct delayed_work rc_query_work; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 392 | u32 last_event; |
| 393 | int last_state; |
| 394 | |
| 395 | struct module *owner; |
| 396 | |
| 397 | void *priv; |
| 398 | }; |
| 399 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 400 | extern int dvb_usb_device_init(struct usb_interface *, |
| 401 | struct dvb_usb_device_properties *, |
| 402 | struct module *, struct dvb_usb_device **, |
| 403 | short *adapter_nums); |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 404 | extern void dvb_usb_device_exit(struct usb_interface *); |
| 405 | |
| 406 | /* the generic read/write method for device control */ |
| 407 | extern int dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,int); |
| 408 | extern int dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16); |
| 409 | |
| 410 | /* commonly used remote control parsing */ |
| 411 | extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *); |
| 412 | |
Patrick Boettcher | d3707ad | 2006-01-09 15:25:04 -0200 | [diff] [blame] | 413 | /* commonly used firmware download types and function */ |
| 414 | struct hexline { |
| 415 | u8 len; |
| 416 | u32 addr; |
| 417 | u8 type; |
| 418 | u8 data[255]; |
| 419 | u8 chk; |
| 420 | }; |
Patrick Boettcher | f537378 | 2006-01-09 18:21:38 -0200 | [diff] [blame] | 421 | extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type); |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 422 | extern int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos); |
| 423 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 424 | |
| 425 | #endif |