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