Antti Palosaari | 12042b0 | 2012-06-20 23:09:41 -0300 | [diff] [blame] | 1 | /* |
| 2 | * DVB USB framework |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 3 | * |
Antti Palosaari | 12042b0 | 2012-06-20 23:09:41 -0300 | [diff] [blame] | 4 | * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@desy.de> |
| 5 | * Copyright (C) 2012 Antti Palosaari <crope@iki.fi> |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 6 | * |
Antti Palosaari | 12042b0 | 2012-06-20 23:09:41 -0300 | [diff] [blame] | 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 20 | */ |
Antti Palosaari | 12042b0 | 2012-06-20 23:09:41 -0300 | [diff] [blame] | 21 | |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 22 | #ifndef DVB_USB_H |
| 23 | #define DVB_USB_H |
| 24 | |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 25 | #include <linux/usb/input.h> |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 26 | #include <linux/firmware.h> |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 27 | #include <media/rc-core.h> |
| 28 | |
| 29 | #include "dvb_frontend.h" |
| 30 | #include "dvb_demux.h" |
| 31 | #include "dvb_net.h" |
| 32 | #include "dmxdev.h" |
Mauro Carvalho Chehab | ccc0e34 | 2012-08-05 19:50:15 -0300 | [diff] [blame] | 33 | #include "dvb-usb-ids.h" |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 34 | |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 35 | /* |
| 36 | * device file: /dev/dvb/adapter[0-1]/frontend[0-2] |
| 37 | * |
| 38 | * |-- device |
| 39 | * | |-- adapter0 |
| 40 | * | | |-- frontend0 |
| 41 | * | | |-- frontend1 |
| 42 | * | | `-- frontend2 |
| 43 | * | `-- adapter1 |
| 44 | * | |-- frontend0 |
| 45 | * | |-- frontend1 |
| 46 | * | `-- frontend2 |
| 47 | * |
| 48 | * |
| 49 | * Commonly used variable names: |
| 50 | * d = pointer to device (struct dvb_usb_device *) |
| 51 | * adap = pointer to adapter (struct dvb_usb_adapter *) |
| 52 | * fe = pointer to frontend (struct dvb_frontend *) |
| 53 | * |
| 54 | * Use macros defined in that file to resolve needed pointers. |
| 55 | */ |
| 56 | |
Antti Palosaari | f89f9ff | 2012-06-16 17:58:53 -0300 | [diff] [blame] | 57 | /* helper macros for every DVB USB driver use */ |
Antti Palosaari | ec0dd2f | 2012-06-18 20:09:07 -0300 | [diff] [blame] | 58 | #define adap_to_d(adap) (container_of(adap, struct dvb_usb_device, \ |
| 59 | adapter[adap->id])) |
Antti Palosaari | f89f9ff | 2012-06-16 17:58:53 -0300 | [diff] [blame] | 60 | #define adap_to_priv(adap) (adap_to_d(adap)->priv) |
| 61 | #define fe_to_adap(fe) ((struct dvb_usb_adapter *) ((fe)->dvb->priv)) |
| 62 | #define fe_to_d(fe) (adap_to_d(fe_to_adap(fe))) |
| 63 | #define fe_to_priv(fe) (fe_to_d(fe)->priv) |
| 64 | #define d_to_priv(d) (d->priv) |
| 65 | |
Antti Palosaari | 4ab7928 | 2012-08-22 19:41:59 -0300 | [diff] [blame] | 66 | #define dvb_usb_dbg_usb_control_msg(udev, r, t, v, i, b, l) { \ |
| 67 | char *direction; \ |
| 68 | if (t == (USB_TYPE_VENDOR | USB_DIR_OUT)) \ |
| 69 | direction = ">>>"; \ |
| 70 | else \ |
| 71 | direction = "<<<"; \ |
| 72 | dev_dbg(&udev->dev, "%s: %02x %02x %02x %02x %02x %02x %02x %02x " \ |
| 73 | "%s %*ph\n", __func__, t, r, v & 0xff, v >> 8, \ |
| 74 | i & 0xff, i >> 8, l & 0xff, l >> 8, direction, l, b); \ |
| 75 | } |
| 76 | |
Antti Palosaari | 12077a3 | 2012-06-16 13:56:37 -0300 | [diff] [blame] | 77 | #define DVB_USB_STREAM_BULK(endpoint_, count_, size_) { \ |
| 78 | .type = USB_BULK, \ |
| 79 | .count = count_, \ |
| 80 | .endpoint = endpoint_, \ |
| 81 | .u = { \ |
| 82 | .bulk = { \ |
| 83 | .buffersize = size_, \ |
| 84 | } \ |
| 85 | } \ |
| 86 | } |
| 87 | |
| 88 | #define DVB_USB_STREAM_ISOC(endpoint_, count_, frames_, size_, interval_) { \ |
| 89 | .type = USB_ISOC, \ |
| 90 | .count = count_, \ |
| 91 | .endpoint = endpoint_, \ |
| 92 | .u = { \ |
| 93 | .isoc = { \ |
| 94 | .framesperurb = frames_, \ |
| 95 | .framesize = size_,\ |
| 96 | .interval = interval_, \ |
| 97 | } \ |
| 98 | } \ |
| 99 | } |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 100 | |
Antti Palosaari | 0359b5f | 2012-06-04 20:12:55 -0300 | [diff] [blame] | 101 | #define DVB_USB_DEVICE(vend, prod, props_, name_, rc) \ |
| 102 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ |
| 103 | .idVendor = (vend), \ |
| 104 | .idProduct = (prod), \ |
Antti Palosaari | acaec14 | 2012-06-12 01:34:22 -0300 | [diff] [blame] | 105 | .driver_info = (kernel_ulong_t) &((const struct dvb_usb_driver_info) { \ |
Antti Palosaari | 0359b5f | 2012-06-04 20:12:55 -0300 | [diff] [blame] | 106 | .props = (props_), \ |
| 107 | .name = (name_), \ |
| 108 | .rc_map = (rc), \ |
| 109 | }) |
| 110 | |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 111 | struct dvb_usb_device; |
| 112 | struct dvb_usb_adapter; |
| 113 | |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 114 | /** |
| 115 | * structure for carrying all needed data from the device driver to the general |
| 116 | * dvb usb routines |
| 117 | * @name: device name |
| 118 | * @rc_map: name of rc codes table |
| 119 | * @props: structure containing all device properties |
| 120 | */ |
Antti Palosaari | 12077a3 | 2012-06-16 13:56:37 -0300 | [diff] [blame] | 121 | struct dvb_usb_driver_info { |
| 122 | const char *name; |
| 123 | const char *rc_map; |
| 124 | const struct dvb_usb_device_properties *props; |
| 125 | }; |
| 126 | |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 127 | /** |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 128 | * structure for remote controller configuration |
| 129 | * @map_name: name of rc codes table |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 130 | * @allowed_protos: protocol(s) supported by the driver |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 131 | * @change_protocol: callback to change protocol |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 132 | * @query: called to query an event from the device |
| 133 | * @interval: time in ms between two queries |
| 134 | * @driver_type: used to point if a device supports raw mode |
| 135 | * @bulk_mode: device supports bulk mode for rc (disable polling mode) |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 136 | */ |
| 137 | struct dvb_usb_rc { |
Antti Palosaari | de73bee | 2012-07-05 19:57:07 -0300 | [diff] [blame] | 138 | const char *map_name; |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 139 | u64 allowed_protos; |
David Härdeman | c003ab1 | 2012-10-11 19:11:54 -0300 | [diff] [blame] | 140 | int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 141 | int (*query) (struct dvb_usb_device *d); |
| 142 | unsigned int interval; |
Rodrigo Tartajo | 1e41413 | 2013-04-20 20:02:12 -0300 | [diff] [blame] | 143 | enum rc_driver_type driver_type; |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 144 | bool bulk_mode; |
| 145 | }; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 146 | |
| 147 | /** |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 148 | * usb streaming configration for adapter |
| 149 | * @type: urb type |
| 150 | * @count: count of used urbs |
| 151 | * @endpoint: stream usb endpoint number |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 152 | */ |
| 153 | struct usb_data_stream_properties { |
| 154 | #define USB_BULK 1 |
| 155 | #define USB_ISOC 2 |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 156 | u8 type; |
| 157 | u8 count; |
| 158 | u8 endpoint; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 159 | |
| 160 | union { |
| 161 | struct { |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 162 | unsigned int buffersize; /* per URB */ |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 163 | } bulk; |
| 164 | struct { |
| 165 | int framesperurb; |
| 166 | int framesize; |
| 167 | int interval; |
| 168 | } isoc; |
| 169 | } u; |
| 170 | }; |
| 171 | |
| 172 | /** |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 173 | * properties of dvb usb device adapter |
| 174 | * @caps: adapter capabilities |
| 175 | * @pid_filter_count: pid count of adapter pid-filter |
| 176 | * @pid_filter_ctrl: called to enable/disable pid-filter |
| 177 | * @pid_filter: called to set/unset pid for filtering |
| 178 | * @stream: adapter usb stream configuration |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 179 | */ |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 180 | #define MAX_NO_OF_FE_PER_ADAP 3 |
| 181 | struct dvb_usb_adapter_properties { |
Antti Palosaari | e46c5b6 | 2012-05-29 18:05:40 -0300 | [diff] [blame] | 182 | #define DVB_USB_ADAP_HAS_PID_FILTER 0x01 |
| 183 | #define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02 |
| 184 | #define DVB_USB_ADAP_NEED_PID_FILTERING 0x04 |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 185 | u8 caps; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 186 | |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 187 | u8 pid_filter_count; |
Antti Palosaari | e46c5b6 | 2012-05-29 18:05:40 -0300 | [diff] [blame] | 188 | int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int); |
| 189 | int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int); |
| 190 | |
Antti Palosaari | 3024985 | 2012-05-29 16:12:17 -0300 | [diff] [blame] | 191 | struct usb_data_stream_properties stream; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 192 | }; |
| 193 | |
| 194 | /** |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 195 | * struct dvb_usb_device_properties - properties of a dvb-usb-device |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 196 | * @driver_name: name of the owning driver module |
Antti Palosaari | 654e62d | 2012-05-23 15:03:56 -0300 | [diff] [blame] | 197 | * @owner: owner of the dvb_adapter |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 198 | * @adapter_nr: values from the DVB_DEFINE_MOD_OPT_ADAPTER_NR() macro |
| 199 | * @bInterfaceNumber: usb interface number driver binds |
| 200 | * @size_of_priv: bytes allocated for the driver private data |
| 201 | * @generic_bulk_ctrl_endpoint: bulk control endpoint number for sent |
| 202 | * @generic_bulk_ctrl_endpoint_response: bulk control endpoint number for |
| 203 | * receive |
| 204 | * @generic_bulk_ctrl_delay: delay between bulk control sent and receive message |
| 205 | * @identify_state: called to determine the firmware state (cold or warm) and |
| 206 | * return possible firmware file name to be loaded |
| 207 | * @firmware: name of the firmware file to be loaded |
| 208 | * @download_firmware: called to download the firmware |
| 209 | * @i2c_algo: i2c_algorithm if the device has i2c-adapter |
| 210 | * @num_adapters: dvb usb device adapter count |
| 211 | * @get_adapter_count: called to resolve adapter count |
| 212 | * @adapter: array of all adapter properties of device |
| 213 | * @power_ctrl: called to enable/disable power of the device |
| 214 | * @read_config: called to resolve device configuration |
| 215 | * @read_mac_address: called to resolve adapter mac-address |
| 216 | * @frontend_attach: called to attach the possible frontends |
Antti Palosaari | ca42129 | 2014-09-04 17:04:44 -0300 | [diff] [blame] | 217 | * @frontend_detach: called to detach the possible frontends |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 218 | * @tuner_attach: called to attach the possible tuners |
| 219 | * @frontend_ctrl: called to power on/off active frontend |
| 220 | * @streaming_ctrl: called to start/stop the usb streaming of adapter |
Antti Palosaari | dc78693 | 2012-05-23 10:44:15 -0300 | [diff] [blame] | 221 | * @init: called after adapters are created in order to finalize device |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 222 | * configuration |
| 223 | * @exit: called when driver is unloaded |
| 224 | * @get_rc_config: called to resolve used remote controller configuration |
| 225 | * @get_stream_config: called to resolve input and output stream configuration |
| 226 | * of the adapter just before streaming is started. input stream is transport |
| 227 | * stream from the demodulator and output stream is usb stream to host. |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 228 | */ |
| 229 | #define MAX_NO_OF_ADAPTER_PER_DEVICE 2 |
| 230 | struct dvb_usb_device_properties { |
Antti Palosaari | 0575289 | 2012-05-26 11:43:24 -0300 | [diff] [blame] | 231 | const char *driver_name; |
Antti Palosaari | 654e62d | 2012-05-23 15:03:56 -0300 | [diff] [blame] | 232 | struct module *owner; |
Antti Palosaari | 55b1f70 | 2012-05-23 16:23:44 -0300 | [diff] [blame] | 233 | short *adapter_nr; |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 234 | |
Antti Palosaari | 3676403 | 2012-06-07 17:34:41 -0300 | [diff] [blame] | 235 | u8 bInterfaceNumber; |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 236 | unsigned int size_of_priv; |
| 237 | u8 generic_bulk_ctrl_endpoint; |
| 238 | u8 generic_bulk_ctrl_endpoint_response; |
Antti Palosaari | 1162c7b | 2012-06-20 20:27:42 -0300 | [diff] [blame] | 239 | unsigned int generic_bulk_ctrl_delay; |
Antti Palosaari | 005bc3f | 2012-05-25 12:28:43 -0300 | [diff] [blame] | 240 | |
Antti Palosaari | a0921af | 2012-06-18 23:42:53 -0300 | [diff] [blame] | 241 | #define WARM 0 |
| 242 | #define COLD 1 |
| 243 | int (*identify_state) (struct dvb_usb_device *, const char **); |
Antti Palosaari | 005bc3f | 2012-05-25 12:28:43 -0300 | [diff] [blame] | 244 | const char *firmware; |
Antti Palosaari | a0921af | 2012-06-18 23:42:53 -0300 | [diff] [blame] | 245 | #define RECONNECTS_USB 1 |
Antti Palosaari | 4e60d95 | 2012-05-24 14:44:21 -0300 | [diff] [blame] | 246 | int (*download_firmware) (struct dvb_usb_device *, |
| 247 | const struct firmware *); |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 248 | |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 249 | struct i2c_algorithm *i2c_algo; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 250 | |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 251 | unsigned int num_adapters; |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 252 | int (*get_adapter_count) (struct dvb_usb_device *); |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 253 | struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 254 | int (*power_ctrl) (struct dvb_usb_device *, int); |
Antti Palosaari | 43402bb | 2012-05-24 22:18:37 -0300 | [diff] [blame] | 255 | int (*read_config) (struct dvb_usb_device *d); |
Antti Palosaari | ddee569 | 2012-06-15 21:17:04 -0300 | [diff] [blame] | 256 | int (*read_mac_address) (struct dvb_usb_adapter *, u8 []); |
Antti Palosaari | 2d2b37c7 | 2012-06-12 01:05:20 -0300 | [diff] [blame] | 257 | int (*frontend_attach) (struct dvb_usb_adapter *); |
Antti Palosaari | ca42129 | 2014-09-04 17:04:44 -0300 | [diff] [blame] | 258 | int (*frontend_detach)(struct dvb_usb_adapter *); |
Antti Palosaari | 2d2b37c7 | 2012-06-12 01:05:20 -0300 | [diff] [blame] | 259 | int (*tuner_attach) (struct dvb_usb_adapter *); |
Antti Palosaari | 1066d77 | 2014-09-04 18:31:40 -0300 | [diff] [blame] | 260 | int (*tuner_detach)(struct dvb_usb_adapter *); |
Antti Palosaari | 2d2b37c7 | 2012-06-12 01:05:20 -0300 | [diff] [blame] | 261 | int (*frontend_ctrl) (struct dvb_frontend *, int); |
Antti Palosaari | a13a6e1 | 2012-06-26 00:04:33 -0300 | [diff] [blame] | 262 | int (*streaming_ctrl) (struct dvb_frontend *, int); |
Antti Palosaari | dc78693 | 2012-05-23 10:44:15 -0300 | [diff] [blame] | 263 | int (*init) (struct dvb_usb_device *); |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 264 | void (*exit) (struct dvb_usb_device *); |
Antti Palosaari | 0575289 | 2012-05-26 11:43:24 -0300 | [diff] [blame] | 265 | int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *); |
Antti Palosaari | b905a2a | 2012-06-18 22:54:16 -0300 | [diff] [blame] | 266 | #define DVB_USB_FE_TS_TYPE_188 0 |
| 267 | #define DVB_USB_FE_TS_TYPE_204 1 |
| 268 | #define DVB_USB_FE_TS_TYPE_RAW 2 |
| 269 | int (*get_stream_config) (struct dvb_frontend *, u8 *, |
Antti Palosaari | 39831f0 | 2012-05-28 21:28:01 -0300 | [diff] [blame] | 270 | struct usb_data_stream_properties *); |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | /** |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 274 | * generic object of an usb stream |
| 275 | * @buf_num: number of buffer allocated |
| 276 | * @buf_size: size of each buffer in buf_list |
| 277 | * @buf_list: array containing all allocate buffers for streaming |
| 278 | * @dma_addr: list of dma_addr_t for each buffer in buf_list |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 279 | * |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 280 | * @urbs_initialized: number of URBs initialized |
| 281 | * @urbs_submitted: number of URBs submitted |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 282 | */ |
| 283 | #define MAX_NO_URBS_FOR_DATA_STREAM 10 |
| 284 | struct usb_data_stream { |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 285 | struct usb_device *udev; |
| 286 | struct usb_data_stream_properties props; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 287 | |
| 288 | #define USB_STATE_INIT 0x00 |
| 289 | #define USB_STATE_URB_BUF 0x01 |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 290 | u8 state; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 291 | |
| 292 | void (*complete) (struct usb_data_stream *, u8 *, size_t); |
| 293 | |
| 294 | struct urb *urb_list[MAX_NO_URBS_FOR_DATA_STREAM]; |
| 295 | int buf_num; |
| 296 | unsigned long buf_size; |
| 297 | u8 *buf_list[MAX_NO_URBS_FOR_DATA_STREAM]; |
| 298 | dma_addr_t dma_addr[MAX_NO_URBS_FOR_DATA_STREAM]; |
| 299 | |
| 300 | int urbs_initialized; |
| 301 | int urbs_submitted; |
| 302 | |
| 303 | void *user_priv; |
| 304 | }; |
| 305 | |
| 306 | /** |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 307 | * dvb adapter object on dvb usb device |
| 308 | * @props: pointer to adapter properties |
| 309 | * @stream: adapter the usb data stream |
| 310 | * @id: index of this adapter (starting with 0) |
| 311 | * @ts_type: transport stream, input stream, type |
Antti Palosaari | 06bae12 | 2012-08-14 22:21:06 -0300 | [diff] [blame] | 312 | * @suspend_resume_active: set when there is ongoing suspend / resume |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 313 | * @pid_filtering: is hardware pid_filtering used or not |
| 314 | * @feed_count: current feed count |
| 315 | * @max_feed_count: maimum feed count device can handle |
| 316 | * @dvb_adap: adapter dvb_adapter |
| 317 | * @dmxdev: adapter dmxdev |
| 318 | * @demux: adapter software demuxer |
| 319 | * @dvb_net: adapter dvb_net interfaces |
| 320 | * @sync_mutex: mutex used to sync control and streaming of the adapter |
| 321 | * @fe: adapter frontends |
| 322 | * @fe_init: rerouted frontend-init function |
| 323 | * @fe_sleep: rerouted frontend-sleep function |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 324 | */ |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 325 | struct dvb_usb_adapter { |
Antti Palosaari | f093c38 | 2012-06-12 16:25:01 -0300 | [diff] [blame] | 326 | const struct dvb_usb_adapter_properties *props; |
Antti Palosaari | e46c5b6 | 2012-05-29 18:05:40 -0300 | [diff] [blame] | 327 | struct usb_data_stream stream; |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 328 | u8 id; |
Antti Palosaari | b905a2a | 2012-06-18 22:54:16 -0300 | [diff] [blame] | 329 | u8 ts_type; |
Antti Palosaari | 06bae12 | 2012-08-14 22:21:06 -0300 | [diff] [blame] | 330 | bool suspend_resume_active; |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 331 | bool pid_filtering; |
| 332 | u8 feed_count; |
| 333 | u8 max_feed_count; |
| 334 | s8 active_fe; |
Antti Palosaari | bdecbe4 | 2013-03-09 00:16:32 -0300 | [diff] [blame] | 335 | #define ADAP_INIT 0 |
| 336 | #define ADAP_SLEEP 1 |
| 337 | #define ADAP_STREAMING 2 |
| 338 | unsigned long state_bits; |
Antti Palosaari | 191f79a | 2012-06-17 00:27:00 -0300 | [diff] [blame] | 339 | |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 340 | /* dvb */ |
| 341 | struct dvb_adapter dvb_adap; |
| 342 | struct dmxdev dmxdev; |
| 343 | struct dvb_demux demux; |
| 344 | struct dvb_net dvb_net; |
| 345 | |
Antti Palosaari | 20bb9cc | 2012-05-29 22:20:24 -0300 | [diff] [blame] | 346 | struct dvb_frontend *fe[MAX_NO_OF_FE_PER_ADAP]; |
| 347 | int (*fe_init[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *); |
| 348 | int (*fe_sleep[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *); |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 349 | }; |
| 350 | |
| 351 | /** |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 352 | * dvb usb device object |
| 353 | * @props: device properties |
| 354 | * @name: device name |
| 355 | * @rc_map: name of rc codes table |
Antti Palosaari | ac1c86c | 2012-12-09 21:23:30 -0300 | [diff] [blame] | 356 | * @rc_polling_active: set when RC polling is active |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 357 | * @udev: pointer to the device's struct usb_device |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 358 | * @rc: remote controller configuration |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 359 | * @powered: indicated whether the device is power or not |
| 360 | * @usb_mutex: mutex for usb control messages |
| 361 | * @i2c_mutex: mutex for i2c-transfers |
| 362 | * @i2c_adap: device's i2c-adapter |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 363 | * @rc_dev: rc device for the remote control |
Antti Palosaari | f93c802 | 2012-06-20 22:22:14 -0300 | [diff] [blame] | 364 | * @rc_query_work: work for polling remote |
| 365 | * @priv: private data of the actual driver (allocate by dvb usb, size defined |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 366 | * in size_of_priv of dvb_usb_properties). |
| 367 | */ |
| 368 | struct dvb_usb_device { |
Antti Palosaari | f093c38 | 2012-06-12 16:25:01 -0300 | [diff] [blame] | 369 | const struct dvb_usb_device_properties *props; |
Antti Palosaari | 7dfd124 | 2012-05-24 20:00:28 -0300 | [diff] [blame] | 370 | const char *name; |
Antti Palosaari | 6492167 | 2012-05-25 10:19:03 -0300 | [diff] [blame] | 371 | const char *rc_map; |
Antti Palosaari | ac1c86c | 2012-12-09 21:23:30 -0300 | [diff] [blame] | 372 | bool rc_polling_active; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 373 | struct usb_device *udev; |
Antti Palosaari | 831511b | 2012-06-20 00:32:53 -0300 | [diff] [blame] | 374 | struct dvb_usb_rc rc; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 375 | int powered; |
| 376 | |
| 377 | /* locking */ |
| 378 | struct mutex usb_mutex; |
| 379 | |
| 380 | /* i2c */ |
| 381 | struct mutex i2c_mutex; |
| 382 | struct i2c_adapter i2c_adap; |
| 383 | |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 384 | struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; |
| 385 | |
| 386 | /* remote control */ |
| 387 | struct rc_dev *rc_dev; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 388 | char rc_phys[64]; |
| 389 | struct delayed_work rc_query_work; |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 390 | |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 391 | void *priv; |
| 392 | }; |
| 393 | |
Antti Palosaari | 6b8c8c4 | 2012-06-07 16:23:40 -0300 | [diff] [blame] | 394 | extern int dvb_usbv2_probe(struct usb_interface *, |
Antti Palosaari | 55b1f70 | 2012-05-23 16:23:44 -0300 | [diff] [blame] | 395 | const struct usb_device_id *); |
Antti Palosaari | 6b8c8c4 | 2012-06-07 16:23:40 -0300 | [diff] [blame] | 396 | extern void dvb_usbv2_disconnect(struct usb_interface *); |
Antti Palosaari | ef81e9e | 2012-06-11 17:47:04 -0300 | [diff] [blame] | 397 | extern int dvb_usbv2_suspend(struct usb_interface *, pm_message_t); |
| 398 | extern int dvb_usbv2_resume(struct usb_interface *); |
Antti Palosaari | 15d0883 | 2012-08-14 22:21:07 -0300 | [diff] [blame] | 399 | extern int dvb_usbv2_reset_resume(struct usb_interface *); |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 400 | |
| 401 | /* the generic read/write method for device control */ |
Antti Palosaari | 1162c7b | 2012-06-20 20:27:42 -0300 | [diff] [blame] | 402 | extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16); |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 403 | extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16); |
Antti Palosaari | acb0549 | 2013-02-26 13:01:48 -0300 | [diff] [blame] | 404 | /* caller must hold lock when locked versions are called */ |
| 405 | extern int dvb_usbv2_generic_rw_locked(struct dvb_usb_device *, |
| 406 | u8 *, u16, u8 *, u16); |
| 407 | extern int dvb_usbv2_generic_write_locked(struct dvb_usb_device *, u8 *, u16); |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 408 | |
Antti Palosaari | c79b339 | 2012-05-23 10:06:09 -0300 | [diff] [blame] | 409 | #endif |