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 | 99e44da | 2016-01-24 12:56:58 -0200 | [diff] [blame^] | 3 | * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.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> |
Mauro Carvalho Chehab | 6bda964 | 2010-11-17 13:28:38 -0300 | [diff] [blame] | 17 | #include <media/rc-core.h> |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 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 | |
| 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 | */ |
| 70 | struct 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 Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 78 | static inline u8 rc5_custom(struct rc_map_table *key) |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 79 | { |
Mauro Carvalho Chehab | 34abf21 | 2010-07-31 11:24:57 -0300 | [diff] [blame] | 80 | return (key->scancode >> 8) & 0xff; |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 81 | } |
| 82 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 83 | static inline u8 rc5_data(struct rc_map_table *key) |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 84 | { |
Mauro Carvalho Chehab | 34abf21 | 2010-07-31 11:24:57 -0300 | [diff] [blame] | 85 | return key->scancode & 0xff; |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 86 | } |
| 87 | |
Manoel Pinheiro | 147b68c | 2011-05-07 03:49:13 -0300 | [diff] [blame] | 88 | static inline u16 rc5_scan(struct rc_map_table *key) |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 89 | { |
Mauro Carvalho Chehab | 34abf21 | 2010-07-31 11:24:57 -0300 | [diff] [blame] | 90 | return key->scancode & 0xffff; |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 91 | } |
| 92 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 93 | struct dvb_usb_device; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 94 | struct dvb_usb_adapter; |
| 95 | struct usb_data_stream; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 96 | |
| 97 | /** |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 98 | * Properties of USB streaming - TODO this structure should be somewhere else |
| 99 | * describes the kind of USB transfer used for data-streaming. |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 100 | * (BULK or ISOC) |
| 101 | */ |
| 102 | struct 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 Dobriyan | be787ac | 2006-03-07 22:20:23 -0300 | [diff] [blame] | 124 | * @caps: capabilities of the DVB USB device. |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 125 | * @pid_filter_count: number of PID filter position in the optional hardware |
| 126 | * PID-filter. |
Antti Palosaari | 9bd9e3b | 2011-07-25 20:16:13 -0300 | [diff] [blame] | 127 | * @num_frontends: number of frontends of the DVB USB adapter. |
| 128 | * @frontend_ctrl: called to power on/off active frontend. |
Michael Krufky | 09129f0 | 2007-05-04 22:51:04 -0300 | [diff] [blame] | 129 | * @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] | 130 | * 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 | */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 139 | struct dvb_usb_adapter_fe_properties { |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 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 Boettcher | 0540c496 | 2006-09-19 12:51:43 -0300 | [diff] [blame] | 143 | #define DVB_USB_ADAP_RECEIVES_204_BYTE_TS 0x08 |
Michael Krufky | 379aa4d | 2011-09-08 04:47:20 -0300 | [diff] [blame] | 144 | #define DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD 0x10 |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 145 | int caps; |
| 146 | int pid_filter_count; |
| 147 | |
| 148 | int (*streaming_ctrl) (struct dvb_usb_adapter *, int); |
| 149 | int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int); |
| 150 | int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int); |
| 151 | |
| 152 | int (*frontend_attach) (struct dvb_usb_adapter *); |
| 153 | int (*tuner_attach) (struct dvb_usb_adapter *); |
| 154 | |
| 155 | struct usb_data_stream_properties stream; |
| 156 | |
| 157 | int size_of_priv; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 158 | }; |
Michael Krufky | 94d9831 | 2009-09-07 13:32:29 -0300 | [diff] [blame] | 159 | |
Michael Krufky | 5266088 | 2012-01-29 15:53:12 -0300 | [diff] [blame] | 160 | #define MAX_NO_OF_FE_PER_ADAP 3 |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 161 | struct dvb_usb_adapter_properties { |
| 162 | int size_of_priv; |
| 163 | |
| 164 | int (*frontend_ctrl) (struct dvb_frontend *, int); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 165 | |
| 166 | int num_frontends; |
| 167 | struct dvb_usb_adapter_fe_properties fe[MAX_NO_OF_FE_PER_ADAP]; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | /** |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 171 | * struct dvb_rc_legacy - old properties of remote controller |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 172 | * @rc_map_table: a hard-wired array of struct rc_map_table (NULL to disable |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 173 | * remote control handling). |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 174 | * @rc_map_size: number of items in @rc_map_table. |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 175 | * @rc_query: called to query an event event. |
| 176 | * @rc_interval: time in ms between two queries. |
| 177 | */ |
| 178 | struct dvb_rc_legacy { |
| 179 | /* remote control properties */ |
| 180 | #define REMOTE_NO_KEY_PRESSED 0x00 |
| 181 | #define REMOTE_KEY_PRESSED 0x01 |
| 182 | #define REMOTE_KEY_REPEAT 0x02 |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 183 | struct rc_map_table *rc_map_table; |
| 184 | int rc_map_size; |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 185 | int (*rc_query) (struct dvb_usb_device *, u32 *, int *); |
| 186 | int rc_interval; |
| 187 | }; |
| 188 | |
| 189 | /** |
Mauro Carvalho Chehab | 6520342 | 2010-07-31 19:07:55 -0300 | [diff] [blame] | 190 | * struct dvb_rc properties of remote controller, using rc-core |
| 191 | * @rc_codes: name of rc codes table |
Mauro Carvalho Chehab | 0ffd1ab | 2010-08-01 09:37:23 -0300 | [diff] [blame] | 192 | * @protocol: type of protocol(s) currently used by the driver |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 193 | * @allowed_protos: protocol(s) supported by the driver |
Patrick Boettcher | 739ff04 | 2010-10-31 16:24:19 -0300 | [diff] [blame] | 194 | * @driver_type: Used to point if a device supports raw mode |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 195 | * @change_protocol: callback to change protocol |
Mauro Carvalho Chehab | 6520342 | 2010-07-31 19:07:55 -0300 | [diff] [blame] | 196 | * @rc_query: called to query an event event. |
| 197 | * @rc_interval: time in ms between two queries. |
Mauro Carvalho Chehab | 6520342 | 2010-07-31 19:07:55 -0300 | [diff] [blame] | 198 | * @bulk_mode: device supports bulk mode for RC (disable polling mode) |
| 199 | */ |
| 200 | struct dvb_rc { |
| 201 | char *rc_codes; |
Mauro Carvalho Chehab | 0ffd1ab | 2010-08-01 09:37:23 -0300 | [diff] [blame] | 202 | u64 protocol; |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 203 | u64 allowed_protos; |
Patrick Boettcher | 739ff04 | 2010-10-31 16:24:19 -0300 | [diff] [blame] | 204 | enum rc_driver_type driver_type; |
David Härdeman | c003ab1 | 2012-10-11 19:11:54 -0300 | [diff] [blame] | 205 | int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); |
Mauro Carvalho Chehab | 6520342 | 2010-07-31 19:07:55 -0300 | [diff] [blame] | 206 | char *module_name; |
| 207 | int (*rc_query) (struct dvb_usb_device *d); |
| 208 | int rc_interval; |
Mauro Carvalho Chehab | 6520342 | 2010-07-31 19:07:55 -0300 | [diff] [blame] | 209 | bool bulk_mode; /* uses bulk mode */ |
| 210 | }; |
| 211 | |
| 212 | /** |
| 213 | * enum dvb_usb_mode - Specifies if it is using a legacy driver or a new one |
| 214 | * based on rc-core |
| 215 | * This is initialized/used only inside dvb-usb-remote.c. |
| 216 | * It shouldn't be set by the drivers. |
| 217 | */ |
| 218 | enum dvb_usb_mode { |
| 219 | DVB_RC_LEGACY, |
| 220 | DVB_RC_CORE, |
| 221 | }; |
| 222 | |
| 223 | /** |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 224 | * struct dvb_usb_device_properties - properties of a dvb-usb-device |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 225 | * @usb_ctrl: which USB device-side controller is in use. Needed for firmware |
| 226 | * download. |
| 227 | * @firmware: name of the firmware file. |
Patrick Boettcher | d3707ad | 2006-01-09 15:25:04 -0200 | [diff] [blame] | 228 | * @download_firmware: called to download the firmware when the usb_ctrl is |
| 229 | * DEVICE_SPECIFIC. |
| 230 | * @no_reconnect: device doesn't do a reconnect after downloading the firmware, |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 231 | * so do the warm initialization right after it |
| 232 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 233 | * @size_of_priv: how many bytes shall be allocated for the private field |
| 234 | * of struct dvb_usb_device. |
| 235 | * |
| 236 | * @power_ctrl: called to enable/disable power of the device. |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 237 | * @read_mac_address: called to read the MAC address of the device. |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 238 | * @identify_state: called to determine the state (cold or warm), when it |
| 239 | * is not distinguishable by the USB IDs. |
| 240 | * |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 241 | * @rc: remote controller properties |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 242 | * |
| 243 | * @i2c_algo: i2c_algorithm if the device has I2CoverUSB. |
| 244 | * |
| 245 | * @generic_bulk_ctrl_endpoint: most of the DVB USB devices have a generic |
| 246 | * endpoint which received control messages with bulk transfers. When this |
| 247 | * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write- |
| 248 | * helper functions. |
| 249 | * |
Michael Krufky | 4605664 | 2010-01-31 21:06:10 -0300 | [diff] [blame] | 250 | * @generic_bulk_ctrl_endpoint_response: some DVB USB devices use a separate |
| 251 | * endpoint for responses to control messages sent with bulk transfers via |
| 252 | * the generic_bulk_ctrl_endpoint. When this is non-zero, this will be used |
| 253 | * instead of the generic_bulk_ctrl_endpoint when reading usb responses in |
| 254 | * the dvb_usb_generic_rw helper function. |
| 255 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 256 | * @num_device_descs: number of struct dvb_usb_device_description in @devices |
| 257 | * @devices: array of struct dvb_usb_device_description compatibles with these |
| 258 | * properties. |
| 259 | */ |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 260 | #define MAX_NO_OF_ADAPTER_PER_DEVICE 2 |
| 261 | struct dvb_usb_device_properties { |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 262 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 263 | #define DVB_USB_IS_AN_I2C_ADAPTER 0x01 |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 264 | int caps; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 265 | |
Patrick Boettcher | d3707ad | 2006-01-09 15:25:04 -0200 | [diff] [blame] | 266 | #define DEVICE_SPECIFIC 0 |
| 267 | #define CYPRESS_AN2135 1 |
| 268 | #define CYPRESS_AN2235 2 |
| 269 | #define CYPRESS_FX2 3 |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 270 | int usb_ctrl; |
| 271 | int (*download_firmware) (struct usb_device *, const struct firmware *); |
Samuel Ortiz | 56aec8d8 | 2009-05-27 00:49:34 +0200 | [diff] [blame] | 272 | const char *firmware; |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 273 | int no_reconnect; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 274 | |
| 275 | int size_of_priv; |
| 276 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 277 | int num_adapters; |
| 278 | struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 279 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 280 | int (*power_ctrl) (struct dvb_usb_device *, int); |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 281 | int (*read_mac_address) (struct dvb_usb_device *, u8 []); |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 282 | int (*identify_state) (struct usb_device *, struct dvb_usb_device_properties *, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 283 | struct dvb_usb_device_description **, int *); |
| 284 | |
Mauro Carvalho Chehab | 6520342 | 2010-07-31 19:07:55 -0300 | [diff] [blame] | 285 | struct { |
| 286 | enum dvb_usb_mode mode; /* Drivers shouldn't touch on it */ |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 287 | struct dvb_rc_legacy legacy; |
Mauro Carvalho Chehab | 6520342 | 2010-07-31 19:07:55 -0300 | [diff] [blame] | 288 | struct dvb_rc core; |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 289 | } rc; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 290 | |
| 291 | struct i2c_algorithm *i2c_algo; |
| 292 | |
| 293 | int generic_bulk_ctrl_endpoint; |
Michael Krufky | 4605664 | 2010-01-31 21:06:10 -0300 | [diff] [blame] | 294 | int generic_bulk_ctrl_endpoint_response; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 295 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 296 | int num_device_descs; |
Armin Schenker | 513846e | 2009-04-20 11:57:49 -0300 | [diff] [blame] | 297 | struct dvb_usb_device_description devices[12]; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 298 | }; |
| 299 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 300 | /** |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 301 | * struct usb_data_stream - generic object of an USB stream |
Patrick Boettcher | 7f5fee5 | 2005-07-07 17:58:08 -0700 | [diff] [blame] | 302 | * @buf_num: number of buffer allocated. |
| 303 | * @buf_size: size of each buffer in buf_list. |
| 304 | * @buf_list: array containing all allocate buffers for streaming. |
| 305 | * @dma_addr: list of dma_addr_t for each buffer in buf_list. |
| 306 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 307 | * @urbs_initialized: number of URBs initialized. |
| 308 | * @urbs_submitted: number of URBs submitted. |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 309 | */ |
| 310 | #define MAX_NO_URBS_FOR_DATA_STREAM 10 |
| 311 | struct usb_data_stream { |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 312 | struct usb_device *udev; |
| 313 | struct usb_data_stream_properties props; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 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 | |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 321 | struct urb *urb_list[MAX_NO_URBS_FOR_DATA_STREAM]; |
| 322 | int buf_num; |
| 323 | unsigned long buf_size; |
| 324 | u8 *buf_list[MAX_NO_URBS_FOR_DATA_STREAM]; |
| 325 | dma_addr_t dma_addr[MAX_NO_URBS_FOR_DATA_STREAM]; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 326 | |
| 327 | int urbs_initialized; |
| 328 | int urbs_submitted; |
| 329 | |
| 330 | void *user_priv; |
| 331 | }; |
| 332 | |
| 333 | /** |
| 334 | * struct dvb_usb_adapter - a DVB adapter on a USB device |
| 335 | * @id: index of this adapter (starting with 0). |
| 336 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 337 | * @feedcount: number of reqested feeds (used for streaming-activation) |
| 338 | * @pid_filtering: is hardware pid_filtering used or not. |
Patrick Boettcher | 7f5fee5 | 2005-07-07 17:58:08 -0700 | [diff] [blame] | 339 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 340 | * @pll_addr: I2C address of the tuner for programming |
| 341 | * @pll_init: array containing the initialization buffer |
| 342 | * @pll_desc: pointer to the appropriate struct dvb_pll_desc |
Patrick Boettcher | 7f5fee5 | 2005-07-07 17:58:08 -0700 | [diff] [blame] | 343 | * @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] | 344 | * |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 345 | * @dvb_adap: device's dvb_adapter. |
| 346 | * @dmxdev: device's dmxdev. |
| 347 | * @demux: device's software demuxer. |
| 348 | * @dvb_net: device's dvb_net interfaces. |
| 349 | * @dvb_frontend: device's frontend. |
| 350 | * @max_feed_count: how many feeds can be handled simultaneously by this |
| 351 | * device |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 352 | * |
| 353 | * @fe_init: rerouted frontend-init (wakeup) function. |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 354 | * @fe_sleep: rerouted frontend-sleep function. |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 355 | * |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 356 | * @stream: the usb data stream. |
| 357 | */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 358 | struct dvb_usb_fe_adapter { |
| 359 | struct dvb_frontend *fe; |
| 360 | |
| 361 | int (*fe_init) (struct dvb_frontend *); |
| 362 | int (*fe_sleep) (struct dvb_frontend *); |
| 363 | |
| 364 | struct usb_data_stream stream; |
| 365 | |
| 366 | int pid_filtering; |
| 367 | int max_feed_count; |
| 368 | |
| 369 | void *priv; |
| 370 | }; |
| 371 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 372 | struct dvb_usb_adapter { |
| 373 | struct dvb_usb_device *dev; |
| 374 | struct dvb_usb_adapter_properties props; |
| 375 | |
| 376 | #define DVB_USB_ADAP_STATE_INIT 0x000 |
| 377 | #define DVB_USB_ADAP_STATE_DVB 0x001 |
| 378 | int state; |
| 379 | |
Patrick Boettcher | 136cafb | 2006-09-19 12:51:33 -0300 | [diff] [blame] | 380 | u8 id; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 381 | |
| 382 | int feedcount; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 383 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 384 | /* dvb */ |
| 385 | struct dvb_adapter dvb_adap; |
| 386 | struct dmxdev dmxdev; |
| 387 | struct dvb_demux demux; |
| 388 | struct dvb_net dvb_net; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 389 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 390 | struct dvb_usb_fe_adapter fe_adap[MAX_NO_OF_FE_PER_ADAP]; |
| 391 | int active_fe; |
| 392 | int num_frontends_initialized; |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 393 | |
| 394 | void *priv; |
| 395 | }; |
| 396 | |
| 397 | /** |
| 398 | * struct dvb_usb_device - object of a DVB USB device |
| 399 | * @props: copy of the struct dvb_usb_properties this device belongs to. |
| 400 | * @desc: pointer to the device's struct dvb_usb_device_description. |
| 401 | * @state: initialization and runtime state of the device. |
| 402 | * |
Patrick Boettcher | a37ddce | 2006-09-20 06:06:11 -0300 | [diff] [blame] | 403 | * @powered: indicated whether the device is power or not. |
| 404 | * Powered is in/decremented for each call to modify the state. |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 405 | * @udev: pointer to the device's struct usb_device. |
| 406 | * |
| 407 | * @usb_mutex: semaphore of USB control messages (reading needs two messages) |
| 408 | * @i2c_mutex: semaphore for i2c-transfers |
| 409 | * |
| 410 | * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB |
| 411 | * |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 412 | * @rc_dev: rc device for the remote control (rc-core mode) |
| 413 | * @input_dev: input device for the remote control (legacy mode) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 414 | * @rc_query_work: struct work_struct frequent rc queries |
| 415 | * @last_event: last triggered event |
| 416 | * @last_state: last state (no, pressed, repeat) |
| 417 | * @owner: owner of the dvb_adapter |
| 418 | * @priv: private data of the actual driver (allocate by dvb-usb, size defined |
| 419 | * in size_of_priv of dvb_usb_properties). |
| 420 | */ |
| 421 | struct dvb_usb_device { |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 422 | struct dvb_usb_device_properties props; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 423 | struct dvb_usb_device_description *desc; |
| 424 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 425 | struct usb_device *udev; |
| 426 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 427 | #define DVB_USB_STATE_INIT 0x000 |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 428 | #define DVB_USB_STATE_I2C 0x001 |
| 429 | #define DVB_USB_STATE_DVB 0x002 |
| 430 | #define DVB_USB_STATE_REMOTE 0x004 |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 431 | int state; |
| 432 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 433 | int powered; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 434 | |
| 435 | /* locking */ |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 436 | struct mutex usb_mutex; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 437 | |
| 438 | /* i2c */ |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 439 | struct mutex i2c_mutex; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 440 | struct i2c_adapter i2c_adap; |
| 441 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 442 | int num_adapters_initialized; |
| 443 | struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 444 | |
| 445 | /* remote control */ |
David Härdeman | d8b4b58 | 2010-10-29 16:08:23 -0300 | [diff] [blame] | 446 | struct rc_dev *rc_dev; |
| 447 | struct input_dev *input_dev; |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 448 | char rc_phys[64]; |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 449 | struct delayed_work rc_query_work; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 450 | u32 last_event; |
| 451 | int last_state; |
| 452 | |
| 453 | struct module *owner; |
| 454 | |
| 455 | void *priv; |
| 456 | }; |
| 457 | |
Janne Grunau | 78e92006 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 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); |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 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 | |
Patrick Boettcher | d3707ad | 2006-01-09 15:25:04 -0200 | [diff] [blame] | 471 | /* commonly used firmware download types and function */ |
| 472 | struct hexline { |
| 473 | u8 len; |
| 474 | u32 addr; |
| 475 | u8 type; |
| 476 | u8 data[255]; |
| 477 | u8 chk; |
| 478 | }; |
Patrick Boettcher | f537378 | 2006-01-09 18:21:38 -0200 | [diff] [blame] | 479 | 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] | 480 | extern int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos); |
| 481 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 482 | |
| 483 | #endif |