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