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