4 #include <linux/kernel.h>
5 #include <linux/videodev2.h>
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
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)
31 #define UVC_CONTROL_GET_RANGE (UVC_CONTROL_GET_CUR | UVC_CONTROL_GET_MIN | \
32 UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES | \
35 struct uvc_xu_control_info {
43 struct uvc_xu_control_mapping {
51 enum v4l2_ctrl_type v4l2_type;
55 struct uvc_xu_control {
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)
69 #include <linux/poll.h>
71 /* --------------------------------------------------------------------------
75 #define UVC_SC_UNDEFINED 0x00
76 #define UVC_SC_VIDEOCONTROL 0x01
77 #define UVC_SC_VIDEOSTREAMING 0x02
78 #define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03
80 #define UVC_PC_PROTOCOL_UNDEFINED 0x00
82 /* VideoControl class specific interface descriptor */
83 #define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
84 #define UVC_VC_HEADER 0x01
85 #define UVC_VC_INPUT_TERMINAL 0x02
86 #define UVC_VC_OUTPUT_TERMINAL 0x03
87 #define UVC_VC_SELECTOR_UNIT 0x04
88 #define UVC_VC_PROCESSING_UNIT 0x05
89 #define UVC_VC_EXTENSION_UNIT 0x06
91 /* VideoStreaming class specific interface descriptor */
92 #define UVC_VS_UNDEFINED 0x00
93 #define UVC_VS_INPUT_HEADER 0x01
94 #define UVC_VS_OUTPUT_HEADER 0x02
95 #define UVC_VS_STILL_IMAGE_FRAME 0x03
96 #define UVC_VS_FORMAT_UNCOMPRESSED 0x04
97 #define UVC_VS_FRAME_UNCOMPRESSED 0x05
98 #define UVC_VS_FORMAT_MJPEG 0x06
99 #define UVC_VS_FRAME_MJPEG 0x07
100 #define UVC_VS_FORMAT_MPEG2TS 0x0a
101 #define UVC_VS_FORMAT_DV 0x0c
102 #define UVC_VS_COLORFORMAT 0x0d
103 #define UVC_VS_FORMAT_FRAME_BASED 0x10
104 #define UVC_VS_FRAME_FRAME_BASED 0x11
105 #define UVC_VS_FORMAT_STREAM_BASED 0x12
108 #define UVC_EP_UNDEFINED 0x00
109 #define UVC_EP_GENERAL 0x01
110 #define UVC_EP_ENDPOINT 0x02
111 #define UVC_EP_INTERRUPT 0x03
114 #define UVC_RC_UNDEFINED 0x00
115 #define UVC_SET_CUR 0x01
116 #define UVC_GET_CUR 0x81
117 #define UVC_GET_MIN 0x82
118 #define UVC_GET_MAX 0x83
119 #define UVC_GET_RES 0x84
120 #define UVC_GET_LEN 0x85
121 #define UVC_GET_INFO 0x86
122 #define UVC_GET_DEF 0x87
124 /* VideoControl interface controls */
125 #define UVC_VC_CONTROL_UNDEFINED 0x00
126 #define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
127 #define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02
129 /* Terminal controls */
130 #define UVC_TE_CONTROL_UNDEFINED 0x00
132 /* Selector Unit controls */
133 #define UVC_SU_CONTROL_UNDEFINED 0x00
134 #define UVC_SU_INPUT_SELECT_CONTROL 0x01
136 /* Camera Terminal controls */
137 #define UVC_CT_CONTROL_UNDEFINED 0x00
138 #define UVC_CT_SCANNING_MODE_CONTROL 0x01
139 #define UVC_CT_AE_MODE_CONTROL 0x02
140 #define UVC_CT_AE_PRIORITY_CONTROL 0x03
141 #define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
142 #define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
143 #define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
144 #define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
145 #define UVC_CT_FOCUS_AUTO_CONTROL 0x08
146 #define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09
147 #define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a
148 #define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
149 #define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c
150 #define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d
151 #define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e
152 #define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
153 #define UVC_CT_ROLL_RELATIVE_CONTROL 0x10
154 #define UVC_CT_PRIVACY_CONTROL 0x11
156 /* Processing Unit controls */
157 #define UVC_PU_CONTROL_UNDEFINED 0x00
158 #define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
159 #define UVC_PU_BRIGHTNESS_CONTROL 0x02
160 #define UVC_PU_CONTRAST_CONTROL 0x03
161 #define UVC_PU_GAIN_CONTROL 0x04
162 #define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
163 #define UVC_PU_HUE_CONTROL 0x06
164 #define UVC_PU_SATURATION_CONTROL 0x07
165 #define UVC_PU_SHARPNESS_CONTROL 0x08
166 #define UVC_PU_GAMMA_CONTROL 0x09
167 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
168 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
169 #define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
170 #define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
171 #define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
172 #define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
173 #define UVC_PU_HUE_AUTO_CONTROL 0x10
174 #define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
175 #define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
177 /* VideoStreaming interface controls */
178 #define UVC_VS_CONTROL_UNDEFINED 0x00
179 #define UVC_VS_PROBE_CONTROL 0x01
180 #define UVC_VS_COMMIT_CONTROL 0x02
181 #define UVC_VS_STILL_PROBE_CONTROL 0x03
182 #define UVC_VS_STILL_COMMIT_CONTROL 0x04
183 #define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
184 #define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
185 #define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
186 #define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
187 #define UVC_VS_SYNC_DELAY_CONTROL 0x09
189 #define UVC_TT_VENDOR_SPECIFIC 0x0100
190 #define UVC_TT_STREAMING 0x0101
192 /* Input Terminal types */
193 #define UVC_ITT_VENDOR_SPECIFIC 0x0200
194 #define UVC_ITT_CAMERA 0x0201
195 #define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
197 /* Output Terminal types */
198 #define UVC_OTT_VENDOR_SPECIFIC 0x0300
199 #define UVC_OTT_DISPLAY 0x0301
200 #define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
202 /* External Terminal types */
203 #define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
204 #define UVC_COMPOSITE_CONNECTOR 0x0401
205 #define UVC_SVIDEO_CONNECTOR 0x0402
206 #define UVC_COMPONENT_CONNECTOR 0x0403
208 #define UVC_TERM_INPUT 0x0000
209 #define UVC_TERM_OUTPUT 0x8000
211 #define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff)
212 #define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0)
213 #define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0)
214 #define UVC_ENTITY_IS_ITERM(entity) \
215 (((entity)->type & 0x8000) == UVC_TERM_INPUT)
216 #define UVC_ENTITY_IS_OTERM(entity) \
217 (((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
219 #define UVC_STATUS_TYPE_CONTROL 1
220 #define UVC_STATUS_TYPE_STREAMING 2
222 /* ------------------------------------------------------------------------
225 #define UVC_GUID_UVC_CAMERA \
226 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
227 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
228 #define UVC_GUID_UVC_OUTPUT \
229 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
230 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}
231 #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \
232 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
234 #define UVC_GUID_UVC_PROCESSING \
235 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}
237 #define UVC_GUID_UVC_SELECTOR \
238 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}
241 #define UVC_GUID_FORMAT_MJPEG \
242 { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \
243 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
244 #define UVC_GUID_FORMAT_YUY2 \
245 { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
246 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
247 #define UVC_GUID_FORMAT_NV12 \
248 { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
249 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
250 #define UVC_GUID_FORMAT_YV12 \
251 { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
252 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
253 #define UVC_GUID_FORMAT_I420 \
254 { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
255 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
256 #define UVC_GUID_FORMAT_UYVY \
257 { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \
258 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
259 #define UVC_GUID_FORMAT_Y800 \
260 { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \
261 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
262 #define UVC_GUID_FORMAT_BY8 \
263 { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \
264 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
267 /* ------------------------------------------------------------------------
268 * Driver specific constants.
271 #define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 0)
273 /* Number of isochronous URBs. */
275 /* Maximum number of packets per URB. */
276 #define UVC_MAX_PACKETS 32
277 /* Maximum number of video buffers. */
278 #define UVC_MAX_VIDEO_BUFFERS 32
279 /* Maximum status buffer size in bytes of interrupt URB. */
280 #define UVC_MAX_STATUS_SIZE 16
282 #define UVC_CTRL_CONTROL_TIMEOUT 300
283 #define UVC_CTRL_STREAMING_TIMEOUT 1000
286 #define UVC_QUIRK_STATUS_INTERVAL 0x00000001
287 #define UVC_QUIRK_PROBE_MINMAX 0x00000002
288 #define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004
289 #define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008
290 #define UVC_QUIRK_STREAM_NO_FID 0x00000010
291 #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020
292 #define UVC_QUIRK_FIX_BANDWIDTH 0x00000080
295 #define UVC_FMT_FLAG_COMPRESSED 0x00000001
296 #define UVC_FMT_FLAG_STREAM 0x00000002
298 /* ------------------------------------------------------------------------
304 /* TODO: Put the most frequently accessed fields at the beginning of
305 * structures to maximize cache efficiency.
307 struct uvc_streaming_control {
311 __u32 dwFrameInterval;
315 __u16 wCompWindowSize;
317 __u32 dwMaxVideoFrameSize;
318 __u32 dwMaxPayloadTransferSize;
319 __u32 dwClockFrequency;
321 __u8 bPreferedVersion;
326 struct uvc_menu_info {
331 struct uvc_control_info {
332 struct list_head list;
333 struct list_head mappings;
343 struct uvc_control_mapping {
344 struct list_head list;
346 struct uvc_control_info *ctrl;
355 enum v4l2_ctrl_type v4l2_type;
358 struct uvc_menu_info *menu_info;
361 __s32 (*get) (struct uvc_control_mapping *mapping, __u8 query,
363 void (*set) (struct uvc_control_mapping *mapping, __s32 value,
368 struct uvc_entity *entity;
369 struct uvc_control_info *info;
371 __u8 index; /* Used to match the uvc_control entry with a
380 struct uvc_format_desc {
386 /* The term 'entity' refers to both UVC units and UVC terminals.
388 * The type field is either the terminal type (wTerminalType in the terminal
389 * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor).
390 * As the bDescriptorSubtype field is one byte long, the type value will
391 * always have a null MSB for units. All terminal types defined by the UVC
392 * specification have a non-null MSB, so it is safe to use the MSB to
393 * differentiate between units and terminals as long as the descriptor parsing
394 * code makes sure terminal types have a non-null MSB.
396 * For terminals, the type's most significant bit stores the terminal
397 * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should
398 * always be accessed with the UVC_ENTITY_* macros and never directly.
402 struct list_head list; /* Entity as part of a UVC device. */
403 struct list_head chain; /* Entity as part of a video device
411 __u16 wObjectiveFocalLengthMin;
412 __u16 wObjectiveFocalLengthMax;
413 __u16 wOcularFocalLength;
421 __u8 bTransportModeSize;
422 __u8 *bmTransportModes;
431 __u16 wMaxMultiplier;
434 __u8 bmVideoStandards;
443 __u8 guidExtensionCode[16];
449 __u8 *bmControlsType;
453 unsigned int ncontrols;
454 struct uvc_control *controls;
464 __u32 dwMaxVideoFrameBufferSize;
465 __u8 bFrameIntervalType;
466 __u32 dwDefaultFrameInterval;
467 __u32 *dwFrameInterval;
480 unsigned int nframes;
481 struct uvc_frame *frame;
484 struct uvc_streaming_header {
486 __u8 bEndpointAddress;
490 /* The following fields are used by input headers only. */
492 __u8 bStillCaptureMethod;
493 __u8 bTriggerSupport;
497 struct uvc_streaming {
498 struct list_head list;
500 struct usb_interface *intf;
504 struct uvc_streaming_header header;
505 enum v4l2_buf_type type;
507 unsigned int nformats;
508 struct uvc_format *format;
510 struct uvc_streaming_control ctrl;
511 struct uvc_format *cur_format;
512 struct uvc_frame *cur_frame;
517 enum uvc_buffer_state {
518 UVC_BUF_STATE_IDLE = 0,
519 UVC_BUF_STATE_QUEUED = 1,
520 UVC_BUF_STATE_ACTIVE = 2,
521 UVC_BUF_STATE_DONE = 3,
522 UVC_BUF_STATE_ERROR = 4,
526 unsigned long vma_use_count;
527 struct list_head stream;
529 /* Touched by interrupt handler. */
530 struct v4l2_buffer buf;
531 struct list_head queue;
532 wait_queue_head_t wait;
533 enum uvc_buffer_state state;
536 #define UVC_QUEUE_STREAMING (1 << 0)
537 #define UVC_QUEUE_DISCONNECTED (1 << 1)
538 #define UVC_QUEUE_DROP_INCOMPLETE (1 << 2)
540 struct uvc_video_queue {
541 enum v4l2_buf_type type;
548 unsigned int buf_size;
549 unsigned int buf_used;
550 struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS];
551 struct mutex mutex; /* protects buffers and mainqueue */
552 spinlock_t irqlock; /* protects irqqueue */
554 struct list_head mainqueue;
555 struct list_head irqqueue;
558 struct uvc_video_device {
559 struct uvc_device *dev;
560 struct video_device *vdev;
562 unsigned int frozen : 1;
564 struct list_head iterms; /* Input terminals */
565 struct uvc_entity *oterm; /* Output terminal */
566 struct uvc_entity *sterm; /* USB streaming terminal */
567 struct uvc_entity *processing;
568 struct uvc_entity *selector;
569 struct list_head extensions;
570 struct mutex ctrl_mutex;
572 struct uvc_video_queue queue;
574 /* Video streaming object, must always be non-NULL. */
575 struct uvc_streaming *streaming;
577 void (*decode) (struct urb *urb, struct uvc_video_device *video,
578 struct uvc_buffer *buf);
580 /* Context data used by the bulk completion handler. */
583 unsigned int header_size;
586 __u32 max_payload_size;
589 struct urb *urb[UVC_URBS];
590 char *urb_buffer[UVC_URBS];
591 dma_addr_t urb_dma[UVC_URBS];
592 unsigned int urb_size;
597 enum uvc_device_state {
598 UVC_DEV_DISCONNECTED = 1,
602 struct usb_device *udev;
603 struct usb_interface *intf;
604 unsigned long warnings;
609 enum uvc_device_state state;
611 struct list_head list;
614 /* Video control interface */
616 __u32 clock_frequency;
618 struct list_head entities;
620 struct uvc_video_device video;
622 /* Status Interrupt Endpoint */
623 struct usb_host_endpoint *int_ep;
626 struct input_dev *input;
629 /* Video Streaming interfaces */
630 struct list_head streaming;
633 enum uvc_handle_state {
634 UVC_HANDLE_PASSIVE = 0,
635 UVC_HANDLE_ACTIVE = 1,
639 struct uvc_video_device *device;
640 enum uvc_handle_state state;
644 struct usb_driver driver;
646 struct mutex open_mutex; /* protects from open/disconnect race */
648 struct list_head devices; /* struct uvc_device list */
649 struct list_head controls; /* struct uvc_control_info list */
650 struct mutex ctrl_mutex; /* protects controls and devices
654 /* ------------------------------------------------------------------------
655 * Debugging, printing and logging
658 #define UVC_TRACE_PROBE (1 << 0)
659 #define UVC_TRACE_DESCR (1 << 1)
660 #define UVC_TRACE_CONTROL (1 << 2)
661 #define UVC_TRACE_FORMAT (1 << 3)
662 #define UVC_TRACE_CAPTURE (1 << 4)
663 #define UVC_TRACE_CALLS (1 << 5)
664 #define UVC_TRACE_IOCTL (1 << 6)
665 #define UVC_TRACE_FRAME (1 << 7)
666 #define UVC_TRACE_SUSPEND (1 << 8)
667 #define UVC_TRACE_STATUS (1 << 9)
669 #define UVC_WARN_MINMAX 0
670 #define UVC_WARN_PROBE_DEF 1
672 extern unsigned int uvc_no_drop_param;
673 extern unsigned int uvc_trace_param;
675 #define uvc_trace(flag, msg...) \
677 if (uvc_trace_param & flag) \
678 printk(KERN_DEBUG "uvcvideo: " msg); \
681 #define uvc_warn_once(dev, warn, msg...) \
683 if (!test_and_set_bit(warn, &dev->warnings)) \
684 printk(KERN_INFO "uvcvideo: " msg); \
687 #define uvc_printk(level, msg...) \
688 printk(level "uvcvideo: " msg)
690 #define UVC_GUID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \
691 "%02x%02x%02x%02x%02x%02x"
692 #define UVC_GUID_ARGS(guid) \
693 (guid)[3], (guid)[2], (guid)[1], (guid)[0], \
694 (guid)[5], (guid)[4], \
695 (guid)[7], (guid)[6], \
696 (guid)[8], (guid)[9], \
697 (guid)[10], (guid)[11], (guid)[12], \
698 (guid)[13], (guid)[14], (guid)[15]
700 /* --------------------------------------------------------------------------
701 * Internal functions.
705 extern struct uvc_driver uvc_driver;
706 extern void uvc_delete(struct kref *kref);
708 /* Video buffers queue management. */
709 extern void uvc_queue_init(struct uvc_video_queue *queue,
710 enum v4l2_buf_type type);
711 extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
712 unsigned int nbuffers, unsigned int buflength);
713 extern int uvc_free_buffers(struct uvc_video_queue *queue);
714 extern int uvc_query_buffer(struct uvc_video_queue *queue,
715 struct v4l2_buffer *v4l2_buf);
716 extern int uvc_queue_buffer(struct uvc_video_queue *queue,
717 struct v4l2_buffer *v4l2_buf);
718 extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
719 struct v4l2_buffer *v4l2_buf, int nonblocking);
720 extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable);
721 extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);
722 extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
723 struct uvc_buffer *buf);
724 extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
725 struct file *file, poll_table *wait);
726 extern int uvc_queue_allocated(struct uvc_video_queue *queue);
727 static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
729 return queue->flags & UVC_QUEUE_STREAMING;
733 extern const struct v4l2_file_operations uvc_fops;
736 extern int uvc_video_init(struct uvc_video_device *video);
737 extern int uvc_video_suspend(struct uvc_video_device *video);
738 extern int uvc_video_resume(struct uvc_video_device *video);
739 extern int uvc_video_enable(struct uvc_video_device *video, int enable);
740 extern int uvc_probe_video(struct uvc_video_device *video,
741 struct uvc_streaming_control *probe);
742 extern int uvc_commit_video(struct uvc_video_device *video,
743 struct uvc_streaming_control *ctrl);
744 extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
745 __u8 intfnum, __u8 cs, void *data, __u16 size);
748 extern int uvc_status_init(struct uvc_device *dev);
749 extern void uvc_status_cleanup(struct uvc_device *dev);
750 extern int uvc_status_start(struct uvc_device *dev);
751 extern void uvc_status_stop(struct uvc_device *dev);
752 extern int uvc_status_suspend(struct uvc_device *dev);
753 extern int uvc_status_resume(struct uvc_device *dev);
756 extern struct uvc_control *uvc_find_control(struct uvc_video_device *video,
757 __u32 v4l2_id, struct uvc_control_mapping **mapping);
758 extern int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
759 struct v4l2_queryctrl *v4l2_ctrl);
761 extern int uvc_ctrl_add_info(struct uvc_control_info *info);
762 extern int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping);
763 extern int uvc_ctrl_init_device(struct uvc_device *dev);
764 extern void uvc_ctrl_cleanup_device(struct uvc_device *dev);
765 extern int uvc_ctrl_resume_device(struct uvc_device *dev);
766 extern void uvc_ctrl_init(void);
768 extern int uvc_ctrl_begin(struct uvc_video_device *video);
769 extern int __uvc_ctrl_commit(struct uvc_video_device *video, int rollback);
770 static inline int uvc_ctrl_commit(struct uvc_video_device *video)
772 return __uvc_ctrl_commit(video, 0);
774 static inline int uvc_ctrl_rollback(struct uvc_video_device *video)
776 return __uvc_ctrl_commit(video, 1);
779 extern int uvc_ctrl_get(struct uvc_video_device *video,
780 struct v4l2_ext_control *xctrl);
781 extern int uvc_ctrl_set(struct uvc_video_device *video,
782 struct v4l2_ext_control *xctrl);
784 extern int uvc_xu_ctrl_query(struct uvc_video_device *video,
785 struct uvc_xu_control *ctrl, int set);
787 /* Utility functions */
788 extern void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator,
789 unsigned int n_terms, unsigned int threshold);
790 extern uint32_t uvc_fraction_to_interval(uint32_t numerator,
791 uint32_t denominator);
792 extern struct usb_host_endpoint *uvc_find_endpoint(
793 struct usb_host_interface *alts, __u8 epaddr);
796 void uvc_video_decode_isight(struct urb *urb, struct uvc_video_device *video,
797 struct uvc_buffer *buf);
799 #endif /* __KERNEL__ */