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 SC_UNDEFINED 0x00
76 #define SC_VIDEOCONTROL 0x01
77 #define SC_VIDEOSTREAMING 0x02
78 #define SC_VIDEO_INTERFACE_COLLECTION 0x03
80 #define PC_PROTOCOL_UNDEFINED 0x00
82 #define CS_UNDEFINED 0x20
83 #define CS_DEVICE 0x21
84 #define CS_CONFIGURATION 0x22
85 #define CS_STRING 0x23
86 #define CS_INTERFACE 0x24
87 #define CS_ENDPOINT 0x25
89 /* VideoControl class specific interface descriptor */
90 #define VC_DESCRIPTOR_UNDEFINED 0x00
91 #define VC_HEADER 0x01
92 #define VC_INPUT_TERMINAL 0x02
93 #define VC_OUTPUT_TERMINAL 0x03
94 #define VC_SELECTOR_UNIT 0x04
95 #define VC_PROCESSING_UNIT 0x05
96 #define VC_EXTENSION_UNIT 0x06
98 /* VideoStreaming class specific interface descriptor */
99 #define VS_UNDEFINED 0x00
100 #define VS_INPUT_HEADER 0x01
101 #define VS_OUTPUT_HEADER 0x02
102 #define VS_STILL_IMAGE_FRAME 0x03
103 #define VS_FORMAT_UNCOMPRESSED 0x04
104 #define VS_FRAME_UNCOMPRESSED 0x05
105 #define VS_FORMAT_MJPEG 0x06
106 #define VS_FRAME_MJPEG 0x07
107 #define VS_FORMAT_MPEG2TS 0x0a
108 #define VS_FORMAT_DV 0x0c
109 #define VS_COLORFORMAT 0x0d
110 #define VS_FORMAT_FRAME_BASED 0x10
111 #define VS_FRAME_FRAME_BASED 0x11
112 #define VS_FORMAT_STREAM_BASED 0x12
115 #define EP_UNDEFINED 0x00
116 #define EP_GENERAL 0x01
117 #define EP_ENDPOINT 0x02
118 #define EP_INTERRUPT 0x03
121 #define RC_UNDEFINED 0x00
128 #define GET_INFO 0x86
131 /* VideoControl interface controls */
132 #define VC_CONTROL_UNDEFINED 0x00
133 #define VC_VIDEO_POWER_MODE_CONTROL 0x01
134 #define VC_REQUEST_ERROR_CODE_CONTROL 0x02
136 /* Terminal controls */
137 #define TE_CONTROL_UNDEFINED 0x00
139 /* Selector Unit controls */
140 #define SU_CONTROL_UNDEFINED 0x00
141 #define SU_INPUT_SELECT_CONTROL 0x01
143 /* Camera Terminal controls */
144 #define CT_CONTROL_UNDEFINED 0x00
145 #define CT_SCANNING_MODE_CONTROL 0x01
146 #define CT_AE_MODE_CONTROL 0x02
147 #define CT_AE_PRIORITY_CONTROL 0x03
148 #define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
149 #define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
150 #define CT_FOCUS_ABSOLUTE_CONTROL 0x06
151 #define CT_FOCUS_RELATIVE_CONTROL 0x07
152 #define CT_FOCUS_AUTO_CONTROL 0x08
153 #define CT_IRIS_ABSOLUTE_CONTROL 0x09
154 #define CT_IRIS_RELATIVE_CONTROL 0x0a
155 #define CT_ZOOM_ABSOLUTE_CONTROL 0x0b
156 #define CT_ZOOM_RELATIVE_CONTROL 0x0c
157 #define CT_PANTILT_ABSOLUTE_CONTROL 0x0d
158 #define CT_PANTILT_RELATIVE_CONTROL 0x0e
159 #define CT_ROLL_ABSOLUTE_CONTROL 0x0f
160 #define CT_ROLL_RELATIVE_CONTROL 0x10
161 #define CT_PRIVACY_CONTROL 0x11
163 /* Processing Unit controls */
164 #define PU_CONTROL_UNDEFINED 0x00
165 #define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
166 #define PU_BRIGHTNESS_CONTROL 0x02
167 #define PU_CONTRAST_CONTROL 0x03
168 #define PU_GAIN_CONTROL 0x04
169 #define PU_POWER_LINE_FREQUENCY_CONTROL 0x05
170 #define PU_HUE_CONTROL 0x06
171 #define PU_SATURATION_CONTROL 0x07
172 #define PU_SHARPNESS_CONTROL 0x08
173 #define PU_GAMMA_CONTROL 0x09
174 #define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
175 #define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
176 #define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
177 #define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
178 #define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
179 #define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
180 #define PU_HUE_AUTO_CONTROL 0x10
181 #define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
182 #define PU_ANALOG_LOCK_STATUS_CONTROL 0x12
184 #define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01
185 #define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02
186 #define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03
188 /* VideoStreaming interface controls */
189 #define VS_CONTROL_UNDEFINED 0x00
190 #define VS_PROBE_CONTROL 0x01
191 #define VS_COMMIT_CONTROL 0x02
192 #define VS_STILL_PROBE_CONTROL 0x03
193 #define VS_STILL_COMMIT_CONTROL 0x04
194 #define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
195 #define VS_STREAM_ERROR_CODE_CONTROL 0x06
196 #define VS_GENERATE_KEY_FRAME_CONTROL 0x07
197 #define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
198 #define VS_SYNC_DELAY_CONTROL 0x09
200 #define TT_VENDOR_SPECIFIC 0x0100
201 #define TT_STREAMING 0x0101
203 /* Input Terminal types */
204 #define ITT_VENDOR_SPECIFIC 0x0200
205 #define ITT_CAMERA 0x0201
206 #define ITT_MEDIA_TRANSPORT_INPUT 0x0202
208 /* Output Terminal types */
209 #define OTT_VENDOR_SPECIFIC 0x0300
210 #define OTT_DISPLAY 0x0301
211 #define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
213 /* External Terminal types */
214 #define EXTERNAL_VENDOR_SPECIFIC 0x0400
215 #define COMPOSITE_CONNECTOR 0x0401
216 #define SVIDEO_CONNECTOR 0x0402
217 #define COMPONENT_CONNECTOR 0x0403
219 #define UVC_TERM_INPUT 0x0000
220 #define UVC_TERM_OUTPUT 0x8000
222 #define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff)
223 #define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0)
224 #define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0)
225 #define UVC_ENTITY_IS_ITERM(entity) \
226 (((entity)->type & 0x8000) == UVC_TERM_INPUT)
227 #define UVC_ENTITY_IS_OTERM(entity) \
228 (((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
230 #define UVC_STATUS_TYPE_CONTROL 1
231 #define UVC_STATUS_TYPE_STREAMING 2
233 /* ------------------------------------------------------------------------
236 #define UVC_GUID_UVC_CAMERA \
237 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
239 #define UVC_GUID_UVC_OUTPUT \
240 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}
242 #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \
243 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
244 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
245 #define UVC_GUID_UVC_PROCESSING \
246 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}
248 #define UVC_GUID_UVC_SELECTOR \
249 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
250 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}
252 #define UVC_GUID_LOGITECH_DEV_INFO \
253 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
254 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1e}
255 #define UVC_GUID_LOGITECH_USER_HW \
256 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
257 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1f}
258 #define UVC_GUID_LOGITECH_VIDEO \
259 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
260 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x50}
261 #define UVC_GUID_LOGITECH_MOTOR \
262 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
263 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x56}
265 #define UVC_GUID_FORMAT_MJPEG \
266 { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \
267 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
268 #define UVC_GUID_FORMAT_YUY2 \
269 { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
270 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
271 #define UVC_GUID_FORMAT_NV12 \
272 { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
273 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
274 #define UVC_GUID_FORMAT_YV12 \
275 { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
276 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
277 #define UVC_GUID_FORMAT_I420 \
278 { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
279 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
280 #define UVC_GUID_FORMAT_UYVY \
281 { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \
282 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
283 #define UVC_GUID_FORMAT_Y800 \
284 { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \
285 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
286 #define UVC_GUID_FORMAT_BY8 \
287 { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \
288 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
291 /* ------------------------------------------------------------------------
292 * Driver specific constants.
295 #define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 0)
297 /* Number of isochronous URBs. */
299 /* Maximum number of packets per isochronous URB. */
300 #define UVC_MAX_ISO_PACKETS 40
301 /* Maximum frame size in bytes, for sanity checking. */
302 #define UVC_MAX_FRAME_SIZE (16*1024*1024)
303 /* Maximum number of video buffers. */
304 #define UVC_MAX_VIDEO_BUFFERS 32
305 /* Maximum status buffer size in bytes of interrupt URB. */
306 #define UVC_MAX_STATUS_SIZE 16
308 #define UVC_CTRL_CONTROL_TIMEOUT 300
309 #define UVC_CTRL_STREAMING_TIMEOUT 1000
312 #define UVC_QUIRK_STATUS_INTERVAL 0x00000001
313 #define UVC_QUIRK_PROBE_MINMAX 0x00000002
314 #define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004
315 #define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008
316 #define UVC_QUIRK_STREAM_NO_FID 0x00000010
317 #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020
318 #define UVC_QUIRK_PRUNE_CONTROLS 0x00000040
321 #define UVC_FMT_FLAG_COMPRESSED 0x00000001
322 #define UVC_FMT_FLAG_STREAM 0x00000002
324 /* ------------------------------------------------------------------------
330 /* TODO: Put the most frequently accessed fields at the beginning of
331 * structures to maximize cache efficiency.
333 struct uvc_streaming_control {
337 __u32 dwFrameInterval;
341 __u16 wCompWindowSize;
343 __u32 dwMaxVideoFrameSize;
344 __u32 dwMaxPayloadTransferSize;
345 __u32 dwClockFrequency;
347 __u8 bPreferedVersion;
352 struct uvc_menu_info {
357 struct uvc_control_info {
358 struct list_head list;
359 struct list_head mappings;
369 struct uvc_control_mapping {
370 struct list_head list;
372 struct uvc_control_info *ctrl;
381 enum v4l2_ctrl_type v4l2_type;
384 struct uvc_menu_info *menu_info;
387 __s32 (*get) (struct uvc_control_mapping *mapping, __u8 query,
389 void (*set) (struct uvc_control_mapping *mapping, __s32 value,
394 struct uvc_entity *entity;
395 struct uvc_control_info *info;
397 __u8 index; /* Used to match the uvc_control entry with a
406 struct uvc_format_desc {
412 /* The term 'entity' refers to both UVC units and UVC terminals.
414 * The type field is either the terminal type (wTerminalType in the terminal
415 * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor).
416 * As the bDescriptorSubtype field is one byte long, the type value will
417 * always have a null MSB for units. All terminal types defined by the UVC
418 * specification have a non-null MSB, so it is safe to use the MSB to
419 * differentiate between units and terminals as long as the descriptor parsing
420 * code makes sure terminal types have a non-null MSB.
422 * For terminals, the type's most significant bit stores the terminal
423 * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should
424 * always be accessed with the UVC_ENTITY_* macros and never directly.
428 struct list_head list; /* Entity as part of a UVC device. */
429 struct list_head chain; /* Entity as part of a video device
437 __u16 wObjectiveFocalLengthMin;
438 __u16 wObjectiveFocalLengthMax;
439 __u16 wOcularFocalLength;
447 __u8 bTransportModeSize;
448 __u8 *bmTransportModes;
457 __u16 wMaxMultiplier;
460 __u8 bmVideoStandards;
469 __u8 guidExtensionCode[16];
475 __u8 *bmControlsType;
479 unsigned int ncontrols;
480 struct uvc_control *controls;
490 __u32 dwMaxVideoFrameBufferSize;
491 __u8 bFrameIntervalType;
492 __u32 dwDefaultFrameInterval;
493 __u32 *dwFrameInterval;
506 unsigned int nframes;
507 struct uvc_frame *frame;
510 struct uvc_streaming_header {
512 __u8 bEndpointAddress;
516 /* The following fields are used by input headers only. */
518 __u8 bStillCaptureMethod;
519 __u8 bTriggerSupport;
523 struct uvc_streaming {
524 struct list_head list;
526 struct usb_interface *intf;
530 struct uvc_streaming_header header;
531 enum v4l2_buf_type type;
533 unsigned int nformats;
534 struct uvc_format *format;
536 struct uvc_streaming_control ctrl;
537 struct uvc_format *cur_format;
538 struct uvc_frame *cur_frame;
543 enum uvc_buffer_state {
544 UVC_BUF_STATE_IDLE = 0,
545 UVC_BUF_STATE_QUEUED = 1,
546 UVC_BUF_STATE_ACTIVE = 2,
547 UVC_BUF_STATE_DONE = 3,
548 UVC_BUF_STATE_ERROR = 4,
552 unsigned long vma_use_count;
553 struct list_head stream;
555 /* Touched by interrupt handler. */
556 struct v4l2_buffer buf;
557 struct list_head queue;
558 wait_queue_head_t wait;
559 enum uvc_buffer_state state;
562 #define UVC_QUEUE_STREAMING (1 << 0)
563 #define UVC_QUEUE_DISCONNECTED (1 << 1)
564 #define UVC_QUEUE_DROP_INCOMPLETE (1 << 2)
566 struct uvc_video_queue {
567 enum v4l2_buf_type type;
574 unsigned int buf_size;
575 unsigned int buf_used;
576 struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS];
577 struct mutex mutex; /* protects buffers and mainqueue */
578 spinlock_t irqlock; /* protects irqqueue */
580 struct list_head mainqueue;
581 struct list_head irqqueue;
584 struct uvc_video_device {
585 struct uvc_device *dev;
586 struct video_device *vdev;
588 unsigned int frozen : 1;
590 struct list_head iterms; /* Input terminals */
591 struct uvc_entity *oterm; /* Output terminal */
592 struct uvc_entity *sterm; /* USB streaming terminal */
593 struct uvc_entity *processing;
594 struct uvc_entity *selector;
595 struct list_head extensions;
596 struct mutex ctrl_mutex;
598 struct uvc_video_queue queue;
600 /* Video streaming object, must always be non-NULL. */
601 struct uvc_streaming *streaming;
603 void (*decode) (struct urb *urb, struct uvc_video_device *video,
604 struct uvc_buffer *buf);
606 /* Context data used by the bulk completion handler. */
609 unsigned int header_size;
612 __u32 max_payload_size;
615 struct urb *urb[UVC_URBS];
616 char *urb_buffer[UVC_URBS];
617 dma_addr_t urb_dma[UVC_URBS];
618 unsigned int urb_size;
623 enum uvc_device_state {
624 UVC_DEV_DISCONNECTED = 1,
628 struct usb_device *udev;
629 struct usb_interface *intf;
630 unsigned long warnings;
635 enum uvc_device_state state;
637 struct list_head list;
639 /* Video control interface */
641 __u32 clock_frequency;
643 struct list_head entities;
645 struct uvc_video_device video;
647 /* Status Interrupt Endpoint */
648 struct usb_host_endpoint *int_ep;
651 struct input_dev *input;
653 /* Video Streaming interfaces */
654 struct list_head streaming;
657 enum uvc_handle_state {
658 UVC_HANDLE_PASSIVE = 0,
659 UVC_HANDLE_ACTIVE = 1,
663 struct uvc_video_device *device;
664 enum uvc_handle_state state;
668 struct usb_driver driver;
670 struct mutex open_mutex; /* protects from open/disconnect race */
672 struct list_head devices; /* struct uvc_device list */
673 struct list_head controls; /* struct uvc_control_info list */
674 struct mutex ctrl_mutex; /* protects controls and devices
678 /* ------------------------------------------------------------------------
679 * Debugging, printing and logging
682 #define UVC_TRACE_PROBE (1 << 0)
683 #define UVC_TRACE_DESCR (1 << 1)
684 #define UVC_TRACE_CONTROL (1 << 2)
685 #define UVC_TRACE_FORMAT (1 << 3)
686 #define UVC_TRACE_CAPTURE (1 << 4)
687 #define UVC_TRACE_CALLS (1 << 5)
688 #define UVC_TRACE_IOCTL (1 << 6)
689 #define UVC_TRACE_FRAME (1 << 7)
690 #define UVC_TRACE_SUSPEND (1 << 8)
691 #define UVC_TRACE_STATUS (1 << 9)
693 #define UVC_WARN_MINMAX 0
694 #define UVC_WARN_PROBE_DEF 1
696 extern unsigned int uvc_no_drop_param;
697 extern unsigned int uvc_trace_param;
699 #define uvc_trace(flag, msg...) \
701 if (uvc_trace_param & flag) \
702 printk(KERN_DEBUG "uvcvideo: " msg); \
705 #define uvc_warn_once(dev, warn, msg...) \
707 if (!test_and_set_bit(warn, &dev->warnings)) \
708 printk(KERN_INFO "uvcvideo: " msg); \
711 #define uvc_printk(level, msg...) \
712 printk(level "uvcvideo: " msg)
714 #define UVC_GUID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \
715 "%02x%02x%02x%02x%02x%02x"
716 #define UVC_GUID_ARGS(guid) \
717 (guid)[3], (guid)[2], (guid)[1], (guid)[0], \
718 (guid)[5], (guid)[4], \
719 (guid)[7], (guid)[6], \
720 (guid)[8], (guid)[9], \
721 (guid)[10], (guid)[11], (guid)[12], \
722 (guid)[13], (guid)[14], (guid)[15]
724 /* --------------------------------------------------------------------------
725 * Internal functions.
729 extern struct uvc_driver uvc_driver;
730 extern void uvc_delete(struct kref *kref);
732 /* Video buffers queue management. */
733 extern void uvc_queue_init(struct uvc_video_queue *queue,
734 enum v4l2_buf_type type);
735 extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
736 unsigned int nbuffers, unsigned int buflength);
737 extern int uvc_free_buffers(struct uvc_video_queue *queue);
738 extern int uvc_query_buffer(struct uvc_video_queue *queue,
739 struct v4l2_buffer *v4l2_buf);
740 extern int uvc_queue_buffer(struct uvc_video_queue *queue,
741 struct v4l2_buffer *v4l2_buf);
742 extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
743 struct v4l2_buffer *v4l2_buf, int nonblocking);
744 extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable);
745 extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);
746 extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
747 struct uvc_buffer *buf);
748 extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
749 struct file *file, poll_table *wait);
750 static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
752 return queue->flags & UVC_QUEUE_STREAMING;
756 extern struct file_operations uvc_fops;
759 extern int uvc_video_init(struct uvc_video_device *video);
760 extern int uvc_video_suspend(struct uvc_video_device *video);
761 extern int uvc_video_resume(struct uvc_video_device *video);
762 extern int uvc_video_enable(struct uvc_video_device *video, int enable);
763 extern int uvc_probe_video(struct uvc_video_device *video,
764 struct uvc_streaming_control *probe);
765 extern int uvc_commit_video(struct uvc_video_device *video,
766 struct uvc_streaming_control *ctrl);
767 extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
768 __u8 intfnum, __u8 cs, void *data, __u16 size);
771 extern int uvc_status_init(struct uvc_device *dev);
772 extern void uvc_status_cleanup(struct uvc_device *dev);
773 extern int uvc_status_suspend(struct uvc_device *dev);
774 extern int uvc_status_resume(struct uvc_device *dev);
777 extern struct uvc_control *uvc_find_control(struct uvc_video_device *video,
778 __u32 v4l2_id, struct uvc_control_mapping **mapping);
779 extern int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
780 struct v4l2_queryctrl *v4l2_ctrl);
782 extern int uvc_ctrl_add_info(struct uvc_control_info *info);
783 extern int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping);
784 extern int uvc_ctrl_init_device(struct uvc_device *dev);
785 extern void uvc_ctrl_cleanup_device(struct uvc_device *dev);
786 extern int uvc_ctrl_resume_device(struct uvc_device *dev);
787 extern void uvc_ctrl_init(void);
789 extern int uvc_ctrl_begin(struct uvc_video_device *video);
790 extern int __uvc_ctrl_commit(struct uvc_video_device *video, int rollback);
791 static inline int uvc_ctrl_commit(struct uvc_video_device *video)
793 return __uvc_ctrl_commit(video, 0);
795 static inline int uvc_ctrl_rollback(struct uvc_video_device *video)
797 return __uvc_ctrl_commit(video, 1);
800 extern int uvc_ctrl_get(struct uvc_video_device *video,
801 struct v4l2_ext_control *xctrl);
802 extern int uvc_ctrl_set(struct uvc_video_device *video,
803 struct v4l2_ext_control *xctrl);
805 extern int uvc_xu_ctrl_query(struct uvc_video_device *video,
806 struct uvc_xu_control *ctrl, int set);
808 /* Utility functions */
809 extern void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator,
810 unsigned int n_terms, unsigned int threshold);
811 extern uint32_t uvc_fraction_to_interval(uint32_t numerator,
812 uint32_t denominator);
813 extern struct usb_host_endpoint *uvc_find_endpoint(
814 struct usb_host_interface *alts, __u8 epaddr);
817 void uvc_video_decode_isight(struct urb *urb, struct uvc_video_device *video,
818 struct uvc_buffer *buf);
820 #endif /* __KERNEL__ */