diff options
Diffstat (limited to 'drivers/media/dvb/dvb-usb/dvb-usb.h')
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb.h | 266 |
1 files changed, 162 insertions, 104 deletions
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index 97f8ea962438..5546554d3876 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h | |||
@@ -1,9 +1,11 @@ | |||
1 | /* dvb-usb.h is part of the DVB USB library. | 1 | /* dvb-usb.h is part of the DVB USB library. |
2 | * | 2 | * |
3 | * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) | 3 | * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) |
4 | * see dvb-usb-init.c for copyright information. | 4 | * see dvb-usb-init.c for copyright information. |
5 | * | 5 | * |
6 | * the headerfile, all dvb-usb-drivers have to include. | 6 | * the headerfile, all dvb-usb-drivers have to include. |
7 | * | ||
8 | * TODO: clean-up the structures for unused fields and update the comments | ||
7 | */ | 9 | */ |
8 | #ifndef __DVB_USB_H__ | 10 | #ifndef __DVB_USB_H__ |
9 | #define __DVB_USB_H__ | 11 | #define __DVB_USB_H__ |
@@ -84,36 +86,83 @@ struct dvb_usb_rc_key { | |||
84 | }; | 86 | }; |
85 | 87 | ||
86 | struct dvb_usb_device; | 88 | struct dvb_usb_device; |
89 | struct dvb_usb_adapter; | ||
90 | struct usb_data_stream; | ||
87 | 91 | ||
88 | /** | 92 | /** |
89 | * struct dvb_usb_properties - properties of a dvb-usb-device | 93 | * Properties of USB streaming - TODO this structure does not belong here actually |
94 | * describes the kind of USB transfer used for MPEG2-TS-streaming. | ||
95 | * (BULK or ISOC) | ||
96 | */ | ||
97 | struct usb_data_stream_properties { | ||
98 | #define USB_BULK 1 | ||
99 | #define USB_ISOC 2 | ||
100 | int type; | ||
101 | int count; | ||
102 | int endpoint; | ||
103 | |||
104 | union { | ||
105 | struct { | ||
106 | int buffersize; /* per URB */ | ||
107 | } bulk; | ||
108 | struct { | ||
109 | int framesperurb; | ||
110 | int framesize; | ||
111 | int interval; | ||
112 | } isoc; | ||
113 | } u; | ||
114 | }; | ||
115 | |||
116 | /** | ||
117 | * struct dvb_usb_adapter_properties - properties of a dvb-usb-adapter. | ||
118 | * A DVB-USB-Adapter is basically a dvb_adapter which is present on a USB-device. | ||
90 | * @caps: capabilities of the DVB USB device. | 119 | * @caps: capabilities of the DVB USB device. |
91 | * @pid_filter_count: number of PID filter position in the optional hardware | 120 | * @pid_filter_count: number of PID filter position in the optional hardware |
92 | * PID-filter. | 121 | * PID-filter. |
93 | * | 122 | * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the |
123 | * device (not URB submitting/killing). | ||
124 | * @pid_filter_ctrl: called to en/disable the PID filter, if any. | ||
125 | * @pid_filter: called to set/unset a PID for filtering. | ||
126 | * @frontend_attach: called to attach the possible frontends (fill fe-field | ||
127 | * of struct dvb_usb_device). | ||
128 | * @tuner_attach: called to attach the correct tuner and to fill pll_addr, | ||
129 | * pll_desc and pll_init_buf of struct dvb_usb_device). | ||
130 | * @stream: configuration of the USB streaming | ||
131 | */ | ||
132 | struct dvb_usb_adapter_properties { | ||
133 | #define DVB_USB_ADAP_HAS_PID_FILTER 0x01 | ||
134 | #define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02 | ||
135 | #define DVB_USB_ADAP_NEED_PID_FILTERING 0x04 | ||
136 | int caps; | ||
137 | int pid_filter_count; | ||
138 | |||
139 | int (*streaming_ctrl) (struct dvb_usb_adapter *, int); | ||
140 | int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int); | ||
141 | int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int); | ||
142 | |||
143 | int (*frontend_attach) (struct dvb_usb_adapter *); | ||
144 | int (*tuner_attach) (struct dvb_usb_adapter *); | ||
145 | |||
146 | struct usb_data_stream_properties stream; | ||
147 | |||
148 | int size_of_priv; | ||
149 | }; | ||
150 | |||
151 | /** | ||
152 | * struct dvb_usb_device_properties - properties of a dvb-usb-device | ||
94 | * @usb_ctrl: which USB device-side controller is in use. Needed for firmware | 153 | * @usb_ctrl: which USB device-side controller is in use. Needed for firmware |
95 | * download. | 154 | * download. |
96 | * @firmware: name of the firmware file. | 155 | * @firmware: name of the firmware file. |
97 | * @download_firmware: called to download the firmware when the usb_ctrl is | 156 | * @download_firmware: called to download the firmware when the usb_ctrl is |
98 | * DEVICE_SPECIFIC. | 157 | * DEVICE_SPECIFIC. |
99 | * @no_reconnect: device doesn't do a reconnect after downloading the firmware, | 158 | * @no_reconnect: device doesn't do a reconnect after downloading the firmware, |
100 | so do the warm initialization right after it | 159 | * so do the warm initialization right after it |
101 | 160 | * | |
102 | * @size_of_priv: how many bytes shall be allocated for the private field | 161 | * @size_of_priv: how many bytes shall be allocated for the private field |
103 | * of struct dvb_usb_device. | 162 | * of struct dvb_usb_device. |
104 | * | 163 | * |
105 | * @power_ctrl: called to enable/disable power of the device. | 164 | * @power_ctrl: called to enable/disable power of the device. |
106 | * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the | ||
107 | * device (not URB submitting/killing). | ||
108 | * @pid_filter_ctrl: called to en/disable the PID filter, if any. | ||
109 | * @pid_filter: called to set/unset a PID for filtering. | ||
110 | * | ||
111 | * @read_mac_address: called to read the MAC address of the device. | 165 | * @read_mac_address: called to read the MAC address of the device. |
112 | * | ||
113 | * @frontend_attach: called to attach the possible frontends (fill fe-field | ||
114 | * of struct dvb_usb_device). | ||
115 | * @tuner_attach: called to attach the correct tuner and to fill pll_addr, | ||
116 | * pll_desc and pll_init_buf of struct dvb_usb_device). | ||
117 | * @identify_state: called to determine the state (cold or warm), when it | 166 | * @identify_state: called to determine the state (cold or warm), when it |
118 | * is not distinguishable by the USB IDs. | 167 | * is not distinguishable by the USB IDs. |
119 | * | 168 | * |
@@ -130,21 +179,15 @@ struct dvb_usb_device; | |||
130 | * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write- | 179 | * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write- |
131 | * helper functions. | 180 | * helper functions. |
132 | * | 181 | * |
133 | * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming. | ||
134 | * (BULK or ISOC) | ||
135 | * | ||
136 | * @num_device_descs: number of struct dvb_usb_device_description in @devices | 182 | * @num_device_descs: number of struct dvb_usb_device_description in @devices |
137 | * @devices: array of struct dvb_usb_device_description compatibles with these | 183 | * @devices: array of struct dvb_usb_device_description compatibles with these |
138 | * properties. | 184 | * properties. |
139 | */ | 185 | */ |
140 | struct dvb_usb_properties { | 186 | #define MAX_NO_OF_ADAPTER_PER_DEVICE 2 |
187 | struct dvb_usb_device_properties { | ||
141 | 188 | ||
142 | #define DVB_USB_HAS_PID_FILTER 0x01 | 189 | #define DVB_USB_IS_AN_I2C_ADAPTER 0x01 |
143 | #define DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF 0x02 | ||
144 | #define DVB_USB_NEED_PID_FILTERING 0x04 | ||
145 | #define DVB_USB_IS_AN_I2C_ADAPTER 0x08 | ||
146 | int caps; | 190 | int caps; |
147 | int pid_filter_count; | ||
148 | 191 | ||
149 | #define DEVICE_SPECIFIC 0 | 192 | #define DEVICE_SPECIFIC 0 |
150 | #define CYPRESS_AN2135 1 | 193 | #define CYPRESS_AN2135 1 |
@@ -157,16 +200,12 @@ struct dvb_usb_properties { | |||
157 | 200 | ||
158 | int size_of_priv; | 201 | int size_of_priv; |
159 | 202 | ||
160 | int (*power_ctrl) (struct dvb_usb_device *, int); | 203 | int num_adapters; |
161 | int (*streaming_ctrl) (struct dvb_usb_device *, int); | 204 | struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; |
162 | int (*pid_filter_ctrl) (struct dvb_usb_device *, int); | ||
163 | int (*pid_filter) (struct dvb_usb_device *, int, u16, int); | ||
164 | 205 | ||
206 | int (*power_ctrl) (struct dvb_usb_device *, int); | ||
165 | int (*read_mac_address) (struct dvb_usb_device *, u8 []); | 207 | int (*read_mac_address) (struct dvb_usb_device *, u8 []); |
166 | int (*frontend_attach) (struct dvb_usb_device *); | 208 | int (*identify_state) (struct usb_device *, struct dvb_usb_device_properties *, |
167 | int (*tuner_attach) (struct dvb_usb_device *); | ||
168 | |||
169 | int (*identify_state) (struct usb_device *, struct dvb_usb_properties *, | ||
170 | struct dvb_usb_device_description **, int *); | 209 | struct dvb_usb_device_description **, int *); |
171 | 210 | ||
172 | /* remote control properties */ | 211 | /* remote control properties */ |
@@ -182,40 +221,12 @@ struct dvb_usb_properties { | |||
182 | 221 | ||
183 | int generic_bulk_ctrl_endpoint; | 222 | int generic_bulk_ctrl_endpoint; |
184 | 223 | ||
185 | struct { | ||
186 | #define DVB_USB_BULK 1 | ||
187 | #define DVB_USB_ISOC 2 | ||
188 | int type; | ||
189 | int count; | ||
190 | int endpoint; | ||
191 | |||
192 | union { | ||
193 | struct { | ||
194 | int buffersize; /* per URB */ | ||
195 | } bulk; | ||
196 | struct { | ||
197 | int framesperurb; | ||
198 | int framesize; | ||
199 | int interval; | ||
200 | } isoc; | ||
201 | } u; | ||
202 | } urb; | ||
203 | |||
204 | int num_device_descs; | 224 | int num_device_descs; |
205 | struct dvb_usb_device_description devices[9]; | 225 | struct dvb_usb_device_description devices[9]; |
206 | }; | 226 | }; |
207 | 227 | ||
208 | |||
209 | /** | 228 | /** |
210 | * struct dvb_usb_device - object of a DVB USB device | 229 | * struct usb_data_stream - generic object of an USB stream |
211 | * @props: copy of the struct dvb_usb_properties this device belongs to. | ||
212 | * @desc: pointer to the device's struct dvb_usb_device_description. | ||
213 | * @state: initialization and runtime state of the device. | ||
214 | * | ||
215 | * @udev: pointer to the device's struct usb_device. | ||
216 | * @urb_list: array of dynamically allocated struct urb for the MPEG2-TS- | ||
217 | * streaming. | ||
218 | * | ||
219 | * @buf_num: number of buffer allocated. | 230 | * @buf_num: number of buffer allocated. |
220 | * @buf_size: size of each buffer in buf_list. | 231 | * @buf_size: size of each buffer in buf_list. |
221 | * @buf_list: array containing all allocate buffers for streaming. | 232 | * @buf_list: array containing all allocate buffers for streaming. |
@@ -224,19 +235,44 @@ struct dvb_usb_properties { | |||
224 | * @urbs_initialized: number of URBs initialized. | 235 | * @urbs_initialized: number of URBs initialized. |
225 | * @urbs_submitted: number of URBs submitted. | 236 | * @urbs_submitted: number of URBs submitted. |
226 | * | 237 | * |
238 | * TODO put this in the correct place. | ||
239 | */ | ||
240 | #define MAX_NO_URBS_FOR_DATA_STREAM 10 | ||
241 | struct usb_data_stream { | ||
242 | struct usb_device *udev; | ||
243 | struct usb_data_stream_properties props; | ||
244 | |||
245 | #define USB_STATE_INIT 0x00 | ||
246 | #define USB_STATE_URB_BUF 0x01 | ||
247 | int state; | ||
248 | |||
249 | void (*complete) (struct usb_data_stream *, u8 *, size_t); | ||
250 | |||
251 | struct urb *urb_list[MAX_NO_URBS_FOR_DATA_STREAM]; | ||
252 | |||
253 | int buf_num; | ||
254 | unsigned long buf_size; | ||
255 | u8 *buf_list[MAX_NO_URBS_FOR_DATA_STREAM]; | ||
256 | dma_addr_t dma_addr[MAX_NO_URBS_FOR_DATA_STREAM]; | ||
257 | |||
258 | int urbs_initialized; | ||
259 | int urbs_submitted; | ||
260 | |||
261 | void *user_priv; | ||
262 | }; | ||
263 | |||
264 | /** | ||
265 | * struct dvb_usb_adapter - a DVB adapter on a USB device | ||
266 | * @id: index of this adapter (starting with 0). | ||
267 | * | ||
227 | * @feedcount: number of reqested feeds (used for streaming-activation) | 268 | * @feedcount: number of reqested feeds (used for streaming-activation) |
228 | * @pid_filtering: is hardware pid_filtering used or not. | 269 | * @pid_filtering: is hardware pid_filtering used or not. |
229 | * | 270 | * |
230 | * @usb_mutex: semaphore of USB control messages (reading needs two messages) | ||
231 | * @i2c_mutex: semaphore for i2c-transfers | ||
232 | * | ||
233 | * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB | ||
234 | * @pll_addr: I2C address of the tuner for programming | 271 | * @pll_addr: I2C address of the tuner for programming |
235 | * @pll_init: array containing the initialization buffer | 272 | * @pll_init: array containing the initialization buffer |
236 | * @pll_desc: pointer to the appropriate struct dvb_pll_desc | 273 | * @pll_desc: pointer to the appropriate struct dvb_pll_desc |
237 | * | 274 | * |
238 | * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board | 275 | * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board |
239 | * | ||
240 | * @dvb_adap: device's dvb_adapter. | 276 | * @dvb_adap: device's dvb_adapter. |
241 | * @dmxdev: device's dmxdev. | 277 | * @dmxdev: device's dmxdev. |
242 | * @demux: device's software demuxer. | 278 | * @demux: device's software demuxer. |
@@ -246,6 +282,56 @@ struct dvb_usb_properties { | |||
246 | * device | 282 | * device |
247 | * @fe_sleep: rerouted frontend-sleep function. | 283 | * @fe_sleep: rerouted frontend-sleep function. |
248 | * @fe_init: rerouted frontend-init (wakeup) function. | 284 | * @fe_init: rerouted frontend-init (wakeup) function. |
285 | * @stream: the usb data stream. | ||
286 | */ | ||
287 | struct dvb_usb_adapter { | ||
288 | struct dvb_usb_device *dev; | ||
289 | struct dvb_usb_adapter_properties props; | ||
290 | |||
291 | #define DVB_USB_ADAP_STATE_INIT 0x000 | ||
292 | #define DVB_USB_ADAP_STATE_DVB 0x001 | ||
293 | int state; | ||
294 | |||
295 | int id; | ||
296 | |||
297 | int feedcount; | ||
298 | int pid_filtering; | ||
299 | |||
300 | /* tuner programming information */ | ||
301 | u8 pll_addr; | ||
302 | u8 pll_init[4]; | ||
303 | struct dvb_pll_desc *pll_desc; | ||
304 | int (*tuner_pass_ctrl) (struct dvb_frontend *, int, u8); | ||
305 | |||
306 | /* dvb */ | ||
307 | struct dvb_adapter dvb_adap; | ||
308 | struct dmxdev dmxdev; | ||
309 | struct dvb_demux demux; | ||
310 | struct dvb_net dvb_net; | ||
311 | struct dvb_frontend *fe; | ||
312 | int max_feed_count; | ||
313 | |||
314 | int (*fe_sleep) (struct dvb_frontend *); | ||
315 | int (*fe_init) (struct dvb_frontend *); | ||
316 | |||
317 | struct usb_data_stream stream; | ||
318 | |||
319 | void *priv; | ||
320 | }; | ||
321 | |||
322 | /** | ||
323 | * struct dvb_usb_device - object of a DVB USB device | ||
324 | * @props: copy of the struct dvb_usb_properties this device belongs to. | ||
325 | * @desc: pointer to the device's struct dvb_usb_device_description. | ||
326 | * @state: initialization and runtime state of the device. | ||
327 | * | ||
328 | * @udev: pointer to the device's struct usb_device. | ||
329 | * | ||
330 | * @usb_mutex: semaphore of USB control messages (reading needs two messages) | ||
331 | * @i2c_mutex: semaphore for i2c-transfers | ||
332 | * | ||
333 | * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB | ||
334 | * | ||
249 | * @rc_input_dev: input device for the remote control. | 335 | * @rc_input_dev: input device for the remote control. |
250 | * @rc_query_work: struct work_struct frequent rc queries | 336 | * @rc_query_work: struct work_struct frequent rc queries |
251 | * @last_event: last triggered event | 337 | * @last_event: last triggered event |
@@ -255,32 +341,18 @@ struct dvb_usb_properties { | |||
255 | * in size_of_priv of dvb_usb_properties). | 341 | * in size_of_priv of dvb_usb_properties). |
256 | */ | 342 | */ |
257 | struct dvb_usb_device { | 343 | struct dvb_usb_device { |
258 | struct dvb_usb_properties props; | 344 | struct dvb_usb_device_properties props; |
259 | struct dvb_usb_device_description *desc; | 345 | struct dvb_usb_device_description *desc; |
260 | 346 | ||
261 | #define DVB_USB_STATE_INIT 0x000 | ||
262 | #define DVB_USB_STATE_URB_LIST 0x001 | ||
263 | #define DVB_USB_STATE_URB_BUF 0x002 | ||
264 | #define DVB_USB_STATE_DVB 0x004 | ||
265 | #define DVB_USB_STATE_I2C 0x008 | ||
266 | #define DVB_USB_STATE_REMOTE 0x010 | ||
267 | #define DVB_USB_STATE_URB_SUBMIT 0x020 | ||
268 | int state; | ||
269 | |||
270 | /* usb */ | ||
271 | struct usb_device *udev; | 347 | struct usb_device *udev; |
272 | struct urb **urb_list; | ||
273 | |||
274 | int buf_num; | ||
275 | unsigned long buf_size; | ||
276 | u8 **buf_list; | ||
277 | dma_addr_t *dma_addr; | ||
278 | 348 | ||
279 | int urbs_initialized; | 349 | #define DVB_USB_STATE_INIT 0x000 |
280 | int urbs_submitted; | 350 | #define DVB_USB_STATE_I2C 0x001 |
351 | #define DVB_USB_STATE_DVB 0x002 | ||
352 | #define DVB_USB_STATE_REMOTE 0x004 | ||
353 | int state; | ||
281 | 354 | ||
282 | int feedcount; | 355 | int powered; |
283 | int pid_filtering; | ||
284 | 356 | ||
285 | /* locking */ | 357 | /* locking */ |
286 | struct mutex usb_mutex; | 358 | struct mutex usb_mutex; |
@@ -289,22 +361,8 @@ struct dvb_usb_device { | |||
289 | struct mutex i2c_mutex; | 361 | struct mutex i2c_mutex; |
290 | struct i2c_adapter i2c_adap; | 362 | struct i2c_adapter i2c_adap; |
291 | 363 | ||
292 | /* tuner programming information */ | 364 | int num_adapters_initialized; |
293 | u8 pll_addr; | 365 | struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; |
294 | u8 pll_init[4]; | ||
295 | struct dvb_pll_desc *pll_desc; | ||
296 | int (*tuner_pass_ctrl)(struct dvb_frontend *, int, u8); | ||
297 | |||
298 | /* dvb */ | ||
299 | struct dvb_adapter dvb_adap; | ||
300 | struct dmxdev dmxdev; | ||
301 | struct dvb_demux demux; | ||
302 | struct dvb_net dvb_net; | ||
303 | struct dvb_frontend* fe; | ||
304 | int max_feed_count; | ||
305 | |||
306 | int (*fe_sleep) (struct dvb_frontend *); | ||
307 | int (*fe_init) (struct dvb_frontend *); | ||
308 | 366 | ||
309 | /* remote control */ | 367 | /* remote control */ |
310 | struct input_dev *rc_input_dev; | 368 | struct input_dev *rc_input_dev; |
@@ -318,7 +376,7 @@ struct dvb_usb_device { | |||
318 | void *priv; | 376 | void *priv; |
319 | }; | 377 | }; |
320 | 378 | ||
321 | extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **); | 379 | extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_device_properties *, struct module *, struct dvb_usb_device **); |
322 | extern void dvb_usb_device_exit(struct usb_interface *); | 380 | extern void dvb_usb_device_exit(struct usb_interface *); |
323 | 381 | ||
324 | /* the generic read/write method for device control */ | 382 | /* the generic read/write method for device control */ |