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