]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/media/video/uvc/uvcvideo.h
V4L/DVB (13506): uvcvideo: Factorize common field in uvc_entity structure
[net-next-2.6.git] / drivers / media / video / uvc / uvcvideo.h
CommitLineData
c0efd232
LP
1#ifndef _USB_VIDEO_H_
2#define _USB_VIDEO_H_
3
4#include <linux/kernel.h>
5#include <linux/videodev2.h>
6
c0efd232
LP
7/*
8 * Dynamic controls
9 */
10
11/* Data types for UVC control data */
12#define UVC_CTRL_DATA_TYPE_RAW 0
13#define UVC_CTRL_DATA_TYPE_SIGNED 1
14#define UVC_CTRL_DATA_TYPE_UNSIGNED 2
15#define UVC_CTRL_DATA_TYPE_BOOLEAN 3
16#define UVC_CTRL_DATA_TYPE_ENUM 4
17#define UVC_CTRL_DATA_TYPE_BITMASK 5
18
19/* Control flags */
20#define UVC_CONTROL_SET_CUR (1 << 0)
21#define UVC_CONTROL_GET_CUR (1 << 1)
22#define UVC_CONTROL_GET_MIN (1 << 2)
23#define UVC_CONTROL_GET_MAX (1 << 3)
24#define UVC_CONTROL_GET_RES (1 << 4)
25#define UVC_CONTROL_GET_DEF (1 << 5)
26/* Control should be saved at suspend and restored at resume. */
27#define UVC_CONTROL_RESTORE (1 << 6)
28/* Control can be updated by the camera. */
29#define UVC_CONTROL_AUTO_UPDATE (1 << 7)
30
31#define UVC_CONTROL_GET_RANGE (UVC_CONTROL_GET_CUR | UVC_CONTROL_GET_MIN | \
32 UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES | \
33 UVC_CONTROL_GET_DEF)
34
35struct uvc_xu_control_info {
36 __u8 entity[16];
37 __u8 index;
38 __u8 selector;
39 __u16 size;
40 __u32 flags;
41};
42
43struct uvc_xu_control_mapping {
44 __u32 id;
45 __u8 name[32];
46 __u8 entity[16];
47 __u8 selector;
48
49 __u8 size;
50 __u8 offset;
51 enum v4l2_ctrl_type v4l2_type;
52 __u32 data_type;
53};
54
55struct uvc_xu_control {
56 __u8 unit;
57 __u8 selector;
58 __u16 size;
59 __u8 __user *data;
60};
61
62#define UVCIOC_CTRL_ADD _IOW('U', 1, struct uvc_xu_control_info)
63#define UVCIOC_CTRL_MAP _IOWR('U', 2, struct uvc_xu_control_mapping)
64#define UVCIOC_CTRL_GET _IOWR('U', 3, struct uvc_xu_control)
65#define UVCIOC_CTRL_SET _IOW('U', 4, struct uvc_xu_control)
66
67#ifdef __KERNEL__
68
69#include <linux/poll.h>
de05f634 70#include <linux/usb/video.h>
c0efd232
LP
71
72/* --------------------------------------------------------------------------
73 * UVC constants
74 */
75
c0efd232
LP
76#define UVC_TERM_INPUT 0x0000
77#define UVC_TERM_OUTPUT 0x8000
6241d8ca 78#define UVC_TERM_DIRECTION(term) ((term)->type & 0x8000)
c0efd232
LP
79
80#define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff)
81#define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0)
82#define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0)
83#define UVC_ENTITY_IS_ITERM(entity) \
8e113595
LP
84 (UVC_ENTITY_IS_TERM(entity) && \
85 ((entity)->type & 0x8000) == UVC_TERM_INPUT)
c0efd232 86#define UVC_ENTITY_IS_OTERM(entity) \
8e113595
LP
87 (UVC_ENTITY_IS_TERM(entity) && \
88 ((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
c0efd232 89
c0efd232
LP
90
91/* ------------------------------------------------------------------------
92 * GUIDs
93 */
94#define UVC_GUID_UVC_CAMERA \
95 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
96 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
97#define UVC_GUID_UVC_OUTPUT \
98 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}
100#define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \
101 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
102 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
103#define UVC_GUID_UVC_PROCESSING \
104 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}
106#define UVC_GUID_UVC_SELECTOR \
107 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}
109
c0efd232
LP
110#define UVC_GUID_FORMAT_MJPEG \
111 { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \
112 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
113#define UVC_GUID_FORMAT_YUY2 \
114 { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
115 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
116#define UVC_GUID_FORMAT_NV12 \
117 { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
118 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
119#define UVC_GUID_FORMAT_YV12 \
120 { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
121 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
122#define UVC_GUID_FORMAT_I420 \
123 { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
124 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
125#define UVC_GUID_FORMAT_UYVY \
126 { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \
127 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
128#define UVC_GUID_FORMAT_Y800 \
129 { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \
130 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
131#define UVC_GUID_FORMAT_BY8 \
132 { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \
133 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
134
135
136/* ------------------------------------------------------------------------
137 * Driver specific constants.
138 */
139
140#define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 0)
141
142/* Number of isochronous URBs. */
143#define UVC_URBS 5
efdc8a95
LP
144/* Maximum number of packets per URB. */
145#define UVC_MAX_PACKETS 32
c0efd232
LP
146/* Maximum number of video buffers. */
147#define UVC_MAX_VIDEO_BUFFERS 32
a31a4055
ML
148/* Maximum status buffer size in bytes of interrupt URB. */
149#define UVC_MAX_STATUS_SIZE 16
c0efd232
LP
150
151#define UVC_CTRL_CONTROL_TIMEOUT 300
b232a012 152#define UVC_CTRL_STREAMING_TIMEOUT 3000
c0efd232
LP
153
154/* Devices quirks */
155#define UVC_QUIRK_STATUS_INTERVAL 0x00000001
156#define UVC_QUIRK_PROBE_MINMAX 0x00000002
157#define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004
158#define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008
159#define UVC_QUIRK_STREAM_NO_FID 0x00000010
160#define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020
50144aee 161#define UVC_QUIRK_FIX_BANDWIDTH 0x00000080
bab6f66c 162#define UVC_QUIRK_PROBE_DEF 0x00000100
c0efd232
LP
163
164/* Format flags */
165#define UVC_FMT_FLAG_COMPRESSED 0x00000001
166#define UVC_FMT_FLAG_STREAM 0x00000002
167
168/* ------------------------------------------------------------------------
169 * Structures.
170 */
171
172struct uvc_device;
173
174/* TODO: Put the most frequently accessed fields at the beginning of
175 * structures to maximize cache efficiency.
176 */
177struct uvc_streaming_control {
178 __u16 bmHint;
179 __u8 bFormatIndex;
180 __u8 bFrameIndex;
181 __u32 dwFrameInterval;
182 __u16 wKeyFrameRate;
183 __u16 wPFrameRate;
184 __u16 wCompQuality;
185 __u16 wCompWindowSize;
186 __u16 wDelay;
187 __u32 dwMaxVideoFrameSize;
188 __u32 dwMaxPayloadTransferSize;
189 __u32 dwClockFrequency;
190 __u8 bmFramingInfo;
191 __u8 bPreferedVersion;
192 __u8 bMinVersion;
193 __u8 bMaxVersion;
194};
195
196struct uvc_menu_info {
197 __u32 value;
198 __u8 name[32];
199};
200
201struct uvc_control_info {
202 struct list_head list;
203 struct list_head mappings;
204
205 __u8 entity[16];
206 __u8 index;
207 __u8 selector;
208
209 __u16 size;
210 __u32 flags;
211};
212
213struct uvc_control_mapping {
214 struct list_head list;
215
216 struct uvc_control_info *ctrl;
217
218 __u32 id;
219 __u8 name[32];
220 __u8 entity[16];
221 __u8 selector;
222
223 __u8 size;
224 __u8 offset;
225 enum v4l2_ctrl_type v4l2_type;
226 __u32 data_type;
227
228 struct uvc_menu_info *menu_info;
229 __u32 menu_count;
9768352a
LP
230
231 __s32 (*get) (struct uvc_control_mapping *mapping, __u8 query,
232 const __u8 *data);
233 void (*set) (struct uvc_control_mapping *mapping, __s32 value,
234 __u8 *data);
c0efd232
LP
235};
236
237struct uvc_control {
238 struct uvc_entity *entity;
239 struct uvc_control_info *info;
240
241 __u8 index; /* Used to match the uvc_control entry with a
242 uvc_control_info. */
243 __u8 dirty : 1,
244 loaded : 1,
245 modified : 1;
246
247 __u8 *data;
248};
249
250struct uvc_format_desc {
251 char *name;
252 __u8 guid[16];
253 __u32 fcc;
254};
255
256/* The term 'entity' refers to both UVC units and UVC terminals.
257 *
258 * The type field is either the terminal type (wTerminalType in the terminal
259 * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor).
260 * As the bDescriptorSubtype field is one byte long, the type value will
261 * always have a null MSB for units. All terminal types defined by the UVC
262 * specification have a non-null MSB, so it is safe to use the MSB to
263 * differentiate between units and terminals as long as the descriptor parsing
264 * code makes sure terminal types have a non-null MSB.
265 *
266 * For terminals, the type's most significant bit stores the terminal
267 * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should
268 * always be accessed with the UVC_ENTITY_* macros and never directly.
269 */
270
271struct uvc_entity {
272 struct list_head list; /* Entity as part of a UVC device. */
273 struct list_head chain; /* Entity as part of a video device
274 * chain. */
275 __u8 id;
276 __u16 type;
277 char name[64];
278
279 union {
280 struct {
281 __u16 wObjectiveFocalLengthMin;
282 __u16 wObjectiveFocalLengthMax;
283 __u16 wOcularFocalLength;
284 __u8 bControlSize;
285 __u8 *bmControls;
286 } camera;
287
288 struct {
289 __u8 bControlSize;
290 __u8 *bmControls;
291 __u8 bTransportModeSize;
292 __u8 *bmTransportModes;
293 } media;
294
295 struct {
c0efd232
LP
296 } output;
297
298 struct {
c0efd232
LP
299 __u16 wMaxMultiplier;
300 __u8 bControlSize;
301 __u8 *bmControls;
302 __u8 bmVideoStandards;
303 } processing;
304
305 struct {
c0efd232
LP
306 } selector;
307
308 struct {
309 __u8 guidExtensionCode[16];
310 __u8 bNumControls;
c0efd232
LP
311 __u8 bControlSize;
312 __u8 *bmControls;
313 __u8 *bmControlsType;
314 } extension;
315 };
316
8ca5a639
LP
317 __u8 bNrInPins;
318 __u8 *baSourceID;
319
c0efd232
LP
320 unsigned int ncontrols;
321 struct uvc_control *controls;
322};
323
324struct uvc_frame {
325 __u8 bFrameIndex;
326 __u8 bmCapabilities;
327 __u16 wWidth;
328 __u16 wHeight;
329 __u32 dwMinBitRate;
330 __u32 dwMaxBitRate;
331 __u32 dwMaxVideoFrameBufferSize;
332 __u8 bFrameIntervalType;
333 __u32 dwDefaultFrameInterval;
334 __u32 *dwFrameInterval;
335};
336
337struct uvc_format {
338 __u8 type;
339 __u8 index;
340 __u8 bpp;
341 __u8 colorspace;
342 __u32 fcc;
343 __u32 flags;
344
345 char name[32];
346
347 unsigned int nframes;
348 struct uvc_frame *frame;
349};
350
351struct uvc_streaming_header {
352 __u8 bNumFormats;
353 __u8 bEndpointAddress;
354 __u8 bTerminalLink;
355 __u8 bControlSize;
356 __u8 *bmaControls;
357 /* The following fields are used by input headers only. */
358 __u8 bmInfo;
359 __u8 bStillCaptureMethod;
360 __u8 bTriggerSupport;
361 __u8 bTriggerUsage;
362};
363
c0efd232 364enum uvc_buffer_state {
2c2d264b
LP
365 UVC_BUF_STATE_IDLE = 0,
366 UVC_BUF_STATE_QUEUED = 1,
367 UVC_BUF_STATE_ACTIVE = 2,
368 UVC_BUF_STATE_DONE = 3,
369 UVC_BUF_STATE_ERROR = 4,
c0efd232
LP
370};
371
372struct uvc_buffer {
373 unsigned long vma_use_count;
374 struct list_head stream;
375
376 /* Touched by interrupt handler. */
377 struct v4l2_buffer buf;
378 struct list_head queue;
379 wait_queue_head_t wait;
380 enum uvc_buffer_state state;
381};
382
383#define UVC_QUEUE_STREAMING (1 << 0)
384#define UVC_QUEUE_DISCONNECTED (1 << 1)
385#define UVC_QUEUE_DROP_INCOMPLETE (1 << 2)
386
387struct uvc_video_queue {
ff924203
LP
388 enum v4l2_buf_type type;
389
c0efd232
LP
390 void *mem;
391 unsigned int flags;
392 __u32 sequence;
393
394 unsigned int count;
395 unsigned int buf_size;
ff924203 396 unsigned int buf_used;
c0efd232
LP
397 struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS];
398 struct mutex mutex; /* protects buffers and mainqueue */
399 spinlock_t irqlock; /* protects irqqueue */
400
401 struct list_head mainqueue;
402 struct list_head irqqueue;
403};
404
8e113595
LP
405struct uvc_video_chain {
406 struct uvc_device *dev;
407 struct list_head list;
408
6241d8ca 409 struct list_head entities; /* All entities */
8e113595
LP
410 struct uvc_entity *processing; /* Processing unit */
411 struct uvc_entity *selector; /* Selector unit */
8e113595
LP
412
413 struct mutex ctrl_mutex;
414};
415
35f02a68
LP
416struct uvc_streaming {
417 struct list_head list;
c0efd232
LP
418 struct uvc_device *dev;
419 struct video_device *vdev;
8e113595 420 struct uvc_video_chain *chain;
c0efd232 421 atomic_t active;
c0efd232 422
35f02a68
LP
423 struct usb_interface *intf;
424 int intfnum;
425 __u16 maxpsize;
c0efd232 426
35f02a68
LP
427 struct uvc_streaming_header header;
428 enum v4l2_buf_type type;
429
430 unsigned int nformats;
431 struct uvc_format *format;
c0efd232 432
35f02a68
LP
433 struct uvc_streaming_control ctrl;
434 struct uvc_format *cur_format;
435 struct uvc_frame *cur_frame;
436
437 struct mutex mutex;
c0efd232 438
35f02a68
LP
439 unsigned int frozen : 1;
440 struct uvc_video_queue queue;
441 void (*decode) (struct urb *urb, struct uvc_streaming *video,
c0efd232
LP
442 struct uvc_buffer *buf);
443
444 /* Context data used by the bulk completion handler. */
445 struct {
446 __u8 header[256];
447 unsigned int header_size;
448 int skip_payload;
449 __u32 payload_size;
450 __u32 max_payload_size;
451 } bulk;
452
453 struct urb *urb[UVC_URBS];
454 char *urb_buffer[UVC_URBS];
e01117c8
LP
455 dma_addr_t urb_dma[UVC_URBS];
456 unsigned int urb_size;
c0efd232
LP
457
458 __u8 last_fid;
459};
460
461enum uvc_device_state {
462 UVC_DEV_DISCONNECTED = 1,
463};
464
465struct uvc_device {
466 struct usb_device *udev;
467 struct usb_interface *intf;
44f0079e 468 unsigned long warnings;
c0efd232
LP
469 __u32 quirks;
470 int intfnum;
471 char name[32];
472
473 enum uvc_device_state state;
c0efd232 474 struct list_head list;
04a37e0f 475 atomic_t users;
c0efd232
LP
476
477 /* Video control interface */
478 __u16 uvc_version;
479 __u32 clock_frequency;
480
481 struct list_head entities;
8e113595 482 struct list_head chains;
c0efd232 483
35f02a68
LP
484 /* Video Streaming interfaces */
485 struct list_head streams;
716fdee1 486 atomic_t nstreams;
35f02a68 487
c0efd232
LP
488 /* Status Interrupt Endpoint */
489 struct usb_host_endpoint *int_ep;
490 struct urb *int_urb;
a31a4055 491 __u8 *status;
c0efd232 492 struct input_dev *input;
f1801523 493 char input_phys[64];
c0efd232
LP
494};
495
496enum uvc_handle_state {
497 UVC_HANDLE_PASSIVE = 0,
498 UVC_HANDLE_ACTIVE = 1,
499};
500
501struct uvc_fh {
8e113595 502 struct uvc_video_chain *chain;
35f02a68 503 struct uvc_streaming *stream;
c0efd232
LP
504 enum uvc_handle_state state;
505};
506
507struct uvc_driver {
508 struct usb_driver driver;
509
c0efd232
LP
510 struct list_head devices; /* struct uvc_device list */
511 struct list_head controls; /* struct uvc_control_info list */
512 struct mutex ctrl_mutex; /* protects controls and devices
513 lists */
514};
515
516/* ------------------------------------------------------------------------
517 * Debugging, printing and logging
518 */
519
520#define UVC_TRACE_PROBE (1 << 0)
521#define UVC_TRACE_DESCR (1 << 1)
522#define UVC_TRACE_CONTROL (1 << 2)
523#define UVC_TRACE_FORMAT (1 << 3)
524#define UVC_TRACE_CAPTURE (1 << 4)
525#define UVC_TRACE_CALLS (1 << 5)
526#define UVC_TRACE_IOCTL (1 << 6)
527#define UVC_TRACE_FRAME (1 << 7)
528#define UVC_TRACE_SUSPEND (1 << 8)
529#define UVC_TRACE_STATUS (1 << 9)
663a4192 530#define UVC_TRACE_VIDEO (1 << 10)
c0efd232 531
44f0079e
LP
532#define UVC_WARN_MINMAX 0
533#define UVC_WARN_PROBE_DEF 1
534
0fbd8ee6 535extern unsigned int uvc_no_drop_param;
c0efd232 536extern unsigned int uvc_trace_param;
b232a012 537extern unsigned int uvc_timeout_param;
c0efd232
LP
538
539#define uvc_trace(flag, msg...) \
540 do { \
541 if (uvc_trace_param & flag) \
542 printk(KERN_DEBUG "uvcvideo: " msg); \
543 } while (0)
544
44f0079e
LP
545#define uvc_warn_once(dev, warn, msg...) \
546 do { \
547 if (!test_and_set_bit(warn, &dev->warnings)) \
548 printk(KERN_INFO "uvcvideo: " msg); \
549 } while (0)
550
c0efd232
LP
551#define uvc_printk(level, msg...) \
552 printk(level "uvcvideo: " msg)
553
554#define UVC_GUID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \
555 "%02x%02x%02x%02x%02x%02x"
556#define UVC_GUID_ARGS(guid) \
557 (guid)[3], (guid)[2], (guid)[1], (guid)[0], \
558 (guid)[5], (guid)[4], \
559 (guid)[7], (guid)[6], \
560 (guid)[8], (guid)[9], \
561 (guid)[10], (guid)[11], (guid)[12], \
562 (guid)[13], (guid)[14], (guid)[15]
563
564/* --------------------------------------------------------------------------
565 * Internal functions.
566 */
567
568/* Core driver */
569extern struct uvc_driver uvc_driver;
c0efd232
LP
570
571/* Video buffers queue management. */
ff924203
LP
572extern void uvc_queue_init(struct uvc_video_queue *queue,
573 enum v4l2_buf_type type);
c0efd232
LP
574extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
575 unsigned int nbuffers, unsigned int buflength);
576extern int uvc_free_buffers(struct uvc_video_queue *queue);
577extern int uvc_query_buffer(struct uvc_video_queue *queue,
578 struct v4l2_buffer *v4l2_buf);
579extern int uvc_queue_buffer(struct uvc_video_queue *queue,
580 struct v4l2_buffer *v4l2_buf);
581extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
582 struct v4l2_buffer *v4l2_buf, int nonblocking);
583extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable);
584extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);
585extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
586 struct uvc_buffer *buf);
587extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
588 struct file *file, poll_table *wait);
23ff6043 589extern int uvc_queue_allocated(struct uvc_video_queue *queue);
c0efd232
LP
590static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
591{
592 return queue->flags & UVC_QUEUE_STREAMING;
593}
594
595/* V4L2 interface */
bec43661 596extern const struct v4l2_file_operations uvc_fops;
c0efd232
LP
597
598/* Video */
35f02a68
LP
599extern int uvc_video_init(struct uvc_streaming *stream);
600extern int uvc_video_suspend(struct uvc_streaming *stream);
601extern int uvc_video_resume(struct uvc_streaming *stream);
602extern int uvc_video_enable(struct uvc_streaming *stream, int enable);
603extern int uvc_probe_video(struct uvc_streaming *stream,
c0efd232 604 struct uvc_streaming_control *probe);
35f02a68 605extern int uvc_commit_video(struct uvc_streaming *stream,
44f0079e 606 struct uvc_streaming_control *ctrl);
c0efd232
LP
607extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
608 __u8 intfnum, __u8 cs, void *data, __u16 size);
c0efd232
LP
609
610/* Status */
611extern int uvc_status_init(struct uvc_device *dev);
612extern void uvc_status_cleanup(struct uvc_device *dev);
04a37e0f
LP
613extern int uvc_status_start(struct uvc_device *dev);
614extern void uvc_status_stop(struct uvc_device *dev);
c0efd232
LP
615extern int uvc_status_suspend(struct uvc_device *dev);
616extern int uvc_status_resume(struct uvc_device *dev);
617
618/* Controls */
8e113595 619extern struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,
c0efd232 620 __u32 v4l2_id, struct uvc_control_mapping **mapping);
8e113595 621extern int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
c0efd232
LP
622 struct v4l2_queryctrl *v4l2_ctrl);
623
624extern int uvc_ctrl_add_info(struct uvc_control_info *info);
625extern int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping);
626extern int uvc_ctrl_init_device(struct uvc_device *dev);
627extern void uvc_ctrl_cleanup_device(struct uvc_device *dev);
628extern int uvc_ctrl_resume_device(struct uvc_device *dev);
629extern void uvc_ctrl_init(void);
630
8e113595
LP
631extern int uvc_ctrl_begin(struct uvc_video_chain *chain);
632extern int __uvc_ctrl_commit(struct uvc_video_chain *chain, int rollback);
633static inline int uvc_ctrl_commit(struct uvc_video_chain *chain)
c0efd232 634{
8e113595 635 return __uvc_ctrl_commit(chain, 0);
c0efd232 636}
8e113595 637static inline int uvc_ctrl_rollback(struct uvc_video_chain *chain)
c0efd232 638{
8e113595 639 return __uvc_ctrl_commit(chain, 1);
c0efd232
LP
640}
641
8e113595 642extern int uvc_ctrl_get(struct uvc_video_chain *chain,
c0efd232 643 struct v4l2_ext_control *xctrl);
8e113595 644extern int uvc_ctrl_set(struct uvc_video_chain *chain,
c0efd232
LP
645 struct v4l2_ext_control *xctrl);
646
8e113595 647extern int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
c0efd232
LP
648 struct uvc_xu_control *ctrl, int set);
649
650/* Utility functions */
651extern void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator,
652 unsigned int n_terms, unsigned int threshold);
653extern uint32_t uvc_fraction_to_interval(uint32_t numerator,
654 uint32_t denominator);
655extern struct usb_host_endpoint *uvc_find_endpoint(
656 struct usb_host_interface *alts, __u8 epaddr);
657
658/* Quirks support */
35f02a68 659void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
c0efd232
LP
660 struct uvc_buffer *buf);
661
662#endif /* __KERNEL__ */
663
664#endif
f87086e3 665