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 #define UVC_LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01
178 #define UVC_LXU_MOTOR_PANTILT_RESET_CONTROL 0x02
179 #define UVC_LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03
181 /* VideoStreaming interface controls */
182 #define UVC_VS_CONTROL_UNDEFINED 0x00
183 #define UVC_VS_PROBE_CONTROL 0x01
184 #define UVC_VS_COMMIT_CONTROL 0x02
185 #define UVC_VS_STILL_PROBE_CONTROL 0x03
186 #define UVC_VS_STILL_COMMIT_CONTROL 0x04
187 #define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
188 #define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
189 #define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
190 #define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
191 #define UVC_VS_SYNC_DELAY_CONTROL 0x09
193 #define UVC_TT_VENDOR_SPECIFIC 0x0100
194 #define UVC_TT_STREAMING 0x0101
196 /* Input Terminal types */
197 #define UVC_ITT_VENDOR_SPECIFIC 0x0200
198 #define UVC_ITT_CAMERA 0x0201
199 #define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
201 /* Output Terminal types */
202 #define UVC_OTT_VENDOR_SPECIFIC 0x0300
203 #define UVC_OTT_DISPLAY 0x0301
204 #define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
206 /* External Terminal types */
207 #define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
208 #define UVC_COMPOSITE_CONNECTOR 0x0401
209 #define UVC_SVIDEO_CONNECTOR 0x0402
210 #define UVC_COMPONENT_CONNECTOR 0x0403
212 #define UVC_TERM_INPUT 0x0000
213 #define UVC_TERM_OUTPUT 0x8000
215 #define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff)
216 #define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0)
217 #define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0)
218 #define UVC_ENTITY_IS_ITERM(entity) \
219 (((entity)->type & 0x8000) == UVC_TERM_INPUT)
220 #define UVC_ENTITY_IS_OTERM(entity) \
221 (((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
223 #define UVC_STATUS_TYPE_CONTROL 1
224 #define UVC_STATUS_TYPE_STREAMING 2
226 /* ------------------------------------------------------------------------
229 #define UVC_GUID_UVC_CAMERA \
230 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
232 #define UVC_GUID_UVC_OUTPUT \
233 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}
235 #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \
236 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
238 #define UVC_GUID_UVC_PROCESSING \
239 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}
241 #define UVC_GUID_UVC_SELECTOR \
242 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}
245 #define UVC_GUID_LOGITECH_DEV_INFO \
246 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
247 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1e}
248 #define UVC_GUID_LOGITECH_USER_HW \
249 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
250 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1f}
251 #define UVC_GUID_LOGITECH_VIDEO \
252 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
253 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x50}
254 #define UVC_GUID_LOGITECH_MOTOR \
255 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
256 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x56}
258 #define UVC_GUID_FORMAT_MJPEG \
259 { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \
260 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
261 #define UVC_GUID_FORMAT_YUY2 \
262 { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
263 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
264 #define UVC_GUID_FORMAT_NV12 \
265 { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
266 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
267 #define UVC_GUID_FORMAT_YV12 \
268 { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
269 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
270 #define UVC_GUID_FORMAT_I420 \
271 { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
272 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
273 #define UVC_GUID_FORMAT_UYVY \
274 { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \
275 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
276 #define UVC_GUID_FORMAT_Y800 \
277 { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \
278 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
279 #define UVC_GUID_FORMAT_BY8 \
280 { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \
281 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
284 /* ------------------------------------------------------------------------
285 * Driver specific constants.
288 #define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 0)
290 /* Number of isochronous URBs. */
292 /* Maximum number of packets per URB. */
293 #define UVC_MAX_PACKETS 32
294 /* Maximum number of video buffers. */
295 #define UVC_MAX_VIDEO_BUFFERS 32
296 /* Maximum status buffer size in bytes of interrupt URB. */
297 #define UVC_MAX_STATUS_SIZE 16
299 #define UVC_CTRL_CONTROL_TIMEOUT 300
300 #define UVC_CTRL_STREAMING_TIMEOUT 1000
303 #define UVC_QUIRK_STATUS_INTERVAL 0x00000001
304 #define UVC_QUIRK_PROBE_MINMAX 0x00000002
305 #define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004
306 #define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008
307 #define UVC_QUIRK_STREAM_NO_FID 0x00000010
308 #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020
309 #define UVC_QUIRK_FIX_BANDWIDTH 0x00000080
312 #define UVC_FMT_FLAG_COMPRESSED 0x00000001
313 #define UVC_FMT_FLAG_STREAM 0x00000002
315 /* ------------------------------------------------------------------------
321 /* TODO: Put the most frequently accessed fields at the beginning of
322 * structures to maximize cache efficiency.
324 struct uvc_streaming_control
{
328 __u32 dwFrameInterval
;
332 __u16 wCompWindowSize
;
334 __u32 dwMaxVideoFrameSize
;
335 __u32 dwMaxPayloadTransferSize
;
336 __u32 dwClockFrequency
;
338 __u8 bPreferedVersion
;
343 struct uvc_menu_info
{
348 struct uvc_control_info
{
349 struct list_head list
;
350 struct list_head mappings
;
360 struct uvc_control_mapping
{
361 struct list_head list
;
363 struct uvc_control_info
*ctrl
;
372 enum v4l2_ctrl_type v4l2_type
;
375 struct uvc_menu_info
*menu_info
;
378 __s32 (*get
) (struct uvc_control_mapping
*mapping
, __u8 query
,
380 void (*set
) (struct uvc_control_mapping
*mapping
, __s32 value
,
385 struct uvc_entity
*entity
;
386 struct uvc_control_info
*info
;
388 __u8 index
; /* Used to match the uvc_control entry with a
397 struct uvc_format_desc
{
403 /* The term 'entity' refers to both UVC units and UVC terminals.
405 * The type field is either the terminal type (wTerminalType in the terminal
406 * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor).
407 * As the bDescriptorSubtype field is one byte long, the type value will
408 * always have a null MSB for units. All terminal types defined by the UVC
409 * specification have a non-null MSB, so it is safe to use the MSB to
410 * differentiate between units and terminals as long as the descriptor parsing
411 * code makes sure terminal types have a non-null MSB.
413 * For terminals, the type's most significant bit stores the terminal
414 * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should
415 * always be accessed with the UVC_ENTITY_* macros and never directly.
419 struct list_head list
; /* Entity as part of a UVC device. */
420 struct list_head chain
; /* Entity as part of a video device
428 __u16 wObjectiveFocalLengthMin
;
429 __u16 wObjectiveFocalLengthMax
;
430 __u16 wOcularFocalLength
;
438 __u8 bTransportModeSize
;
439 __u8
*bmTransportModes
;
448 __u16 wMaxMultiplier
;
451 __u8 bmVideoStandards
;
460 __u8 guidExtensionCode
[16];
466 __u8
*bmControlsType
;
470 unsigned int ncontrols
;
471 struct uvc_control
*controls
;
481 __u32 dwMaxVideoFrameBufferSize
;
482 __u8 bFrameIntervalType
;
483 __u32 dwDefaultFrameInterval
;
484 __u32
*dwFrameInterval
;
497 unsigned int nframes
;
498 struct uvc_frame
*frame
;
501 struct uvc_streaming_header
{
503 __u8 bEndpointAddress
;
507 /* The following fields are used by input headers only. */
509 __u8 bStillCaptureMethod
;
510 __u8 bTriggerSupport
;
514 struct uvc_streaming
{
515 struct list_head list
;
517 struct usb_interface
*intf
;
521 struct uvc_streaming_header header
;
522 enum v4l2_buf_type type
;
524 unsigned int nformats
;
525 struct uvc_format
*format
;
527 struct uvc_streaming_control ctrl
;
528 struct uvc_format
*cur_format
;
529 struct uvc_frame
*cur_frame
;
534 enum uvc_buffer_state
{
535 UVC_BUF_STATE_IDLE
= 0,
536 UVC_BUF_STATE_QUEUED
= 1,
537 UVC_BUF_STATE_ACTIVE
= 2,
538 UVC_BUF_STATE_DONE
= 3,
539 UVC_BUF_STATE_ERROR
= 4,
543 unsigned long vma_use_count
;
544 struct list_head stream
;
546 /* Touched by interrupt handler. */
547 struct v4l2_buffer buf
;
548 struct list_head queue
;
549 wait_queue_head_t wait
;
550 enum uvc_buffer_state state
;
553 #define UVC_QUEUE_STREAMING (1 << 0)
554 #define UVC_QUEUE_DISCONNECTED (1 << 1)
555 #define UVC_QUEUE_DROP_INCOMPLETE (1 << 2)
557 struct uvc_video_queue
{
558 enum v4l2_buf_type type
;
565 unsigned int buf_size
;
566 unsigned int buf_used
;
567 struct uvc_buffer buffer
[UVC_MAX_VIDEO_BUFFERS
];
568 struct mutex mutex
; /* protects buffers and mainqueue */
569 spinlock_t irqlock
; /* protects irqqueue */
571 struct list_head mainqueue
;
572 struct list_head irqqueue
;
575 struct uvc_video_device
{
576 struct uvc_device
*dev
;
577 struct video_device
*vdev
;
579 unsigned int frozen
: 1;
581 struct list_head iterms
; /* Input terminals */
582 struct uvc_entity
*oterm
; /* Output terminal */
583 struct uvc_entity
*sterm
; /* USB streaming terminal */
584 struct uvc_entity
*processing
;
585 struct uvc_entity
*selector
;
586 struct list_head extensions
;
587 struct mutex ctrl_mutex
;
589 struct uvc_video_queue queue
;
591 /* Video streaming object, must always be non-NULL. */
592 struct uvc_streaming
*streaming
;
594 void (*decode
) (struct urb
*urb
, struct uvc_video_device
*video
,
595 struct uvc_buffer
*buf
);
597 /* Context data used by the bulk completion handler. */
600 unsigned int header_size
;
603 __u32 max_payload_size
;
606 struct urb
*urb
[UVC_URBS
];
607 char *urb_buffer
[UVC_URBS
];
608 dma_addr_t urb_dma
[UVC_URBS
];
609 unsigned int urb_size
;
614 enum uvc_device_state
{
615 UVC_DEV_DISCONNECTED
= 1,
619 struct usb_device
*udev
;
620 struct usb_interface
*intf
;
621 unsigned long warnings
;
626 enum uvc_device_state state
;
628 struct list_head list
;
631 /* Video control interface */
633 __u32 clock_frequency
;
635 struct list_head entities
;
637 struct uvc_video_device video
;
639 /* Status Interrupt Endpoint */
640 struct usb_host_endpoint
*int_ep
;
643 struct input_dev
*input
;
646 /* Video Streaming interfaces */
647 struct list_head streaming
;
650 enum uvc_handle_state
{
651 UVC_HANDLE_PASSIVE
= 0,
652 UVC_HANDLE_ACTIVE
= 1,
656 struct uvc_video_device
*device
;
657 enum uvc_handle_state state
;
661 struct usb_driver driver
;
663 struct mutex open_mutex
; /* protects from open/disconnect race */
665 struct list_head devices
; /* struct uvc_device list */
666 struct list_head controls
; /* struct uvc_control_info list */
667 struct mutex ctrl_mutex
; /* protects controls and devices
671 /* ------------------------------------------------------------------------
672 * Debugging, printing and logging
675 #define UVC_TRACE_PROBE (1 << 0)
676 #define UVC_TRACE_DESCR (1 << 1)
677 #define UVC_TRACE_CONTROL (1 << 2)
678 #define UVC_TRACE_FORMAT (1 << 3)
679 #define UVC_TRACE_CAPTURE (1 << 4)
680 #define UVC_TRACE_CALLS (1 << 5)
681 #define UVC_TRACE_IOCTL (1 << 6)
682 #define UVC_TRACE_FRAME (1 << 7)
683 #define UVC_TRACE_SUSPEND (1 << 8)
684 #define UVC_TRACE_STATUS (1 << 9)
686 #define UVC_WARN_MINMAX 0
687 #define UVC_WARN_PROBE_DEF 1
689 extern unsigned int uvc_no_drop_param
;
690 extern unsigned int uvc_trace_param
;
692 #define uvc_trace(flag, msg...) \
694 if (uvc_trace_param & flag) \
695 printk(KERN_DEBUG "uvcvideo: " msg); \
698 #define uvc_warn_once(dev, warn, msg...) \
700 if (!test_and_set_bit(warn, &dev->warnings)) \
701 printk(KERN_INFO "uvcvideo: " msg); \
704 #define uvc_printk(level, msg...) \
705 printk(level "uvcvideo: " msg)
707 #define UVC_GUID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \
708 "%02x%02x%02x%02x%02x%02x"
709 #define UVC_GUID_ARGS(guid) \
710 (guid)[3], (guid)[2], (guid)[1], (guid)[0], \
711 (guid)[5], (guid)[4], \
712 (guid)[7], (guid)[6], \
713 (guid)[8], (guid)[9], \
714 (guid)[10], (guid)[11], (guid)[12], \
715 (guid)[13], (guid)[14], (guid)[15]
717 /* --------------------------------------------------------------------------
718 * Internal functions.
722 extern struct uvc_driver uvc_driver
;
723 extern void uvc_delete(struct kref
*kref
);
725 /* Video buffers queue management. */
726 extern void uvc_queue_init(struct uvc_video_queue
*queue
,
727 enum v4l2_buf_type type
);
728 extern int uvc_alloc_buffers(struct uvc_video_queue
*queue
,
729 unsigned int nbuffers
, unsigned int buflength
);
730 extern int uvc_free_buffers(struct uvc_video_queue
*queue
);
731 extern int uvc_query_buffer(struct uvc_video_queue
*queue
,
732 struct v4l2_buffer
*v4l2_buf
);
733 extern int uvc_queue_buffer(struct uvc_video_queue
*queue
,
734 struct v4l2_buffer
*v4l2_buf
);
735 extern int uvc_dequeue_buffer(struct uvc_video_queue
*queue
,
736 struct v4l2_buffer
*v4l2_buf
, int nonblocking
);
737 extern int uvc_queue_enable(struct uvc_video_queue
*queue
, int enable
);
738 extern void uvc_queue_cancel(struct uvc_video_queue
*queue
, int disconnect
);
739 extern struct uvc_buffer
*uvc_queue_next_buffer(struct uvc_video_queue
*queue
,
740 struct uvc_buffer
*buf
);
741 extern unsigned int uvc_queue_poll(struct uvc_video_queue
*queue
,
742 struct file
*file
, poll_table
*wait
);
743 extern int uvc_queue_allocated(struct uvc_video_queue
*queue
);
744 static inline int uvc_queue_streaming(struct uvc_video_queue
*queue
)
746 return queue
->flags
& UVC_QUEUE_STREAMING
;
750 extern const struct v4l2_file_operations uvc_fops
;
753 extern int uvc_video_init(struct uvc_video_device
*video
);
754 extern int uvc_video_suspend(struct uvc_video_device
*video
);
755 extern int uvc_video_resume(struct uvc_video_device
*video
);
756 extern int uvc_video_enable(struct uvc_video_device
*video
, int enable
);
757 extern int uvc_probe_video(struct uvc_video_device
*video
,
758 struct uvc_streaming_control
*probe
);
759 extern int uvc_commit_video(struct uvc_video_device
*video
,
760 struct uvc_streaming_control
*ctrl
);
761 extern int uvc_query_ctrl(struct uvc_device
*dev
, __u8 query
, __u8 unit
,
762 __u8 intfnum
, __u8 cs
, void *data
, __u16 size
);
765 extern int uvc_status_init(struct uvc_device
*dev
);
766 extern void uvc_status_cleanup(struct uvc_device
*dev
);
767 extern int uvc_status_start(struct uvc_device
*dev
);
768 extern void uvc_status_stop(struct uvc_device
*dev
);
769 extern int uvc_status_suspend(struct uvc_device
*dev
);
770 extern int uvc_status_resume(struct uvc_device
*dev
);
773 extern struct uvc_control
*uvc_find_control(struct uvc_video_device
*video
,
774 __u32 v4l2_id
, struct uvc_control_mapping
**mapping
);
775 extern int uvc_query_v4l2_ctrl(struct uvc_video_device
*video
,
776 struct v4l2_queryctrl
*v4l2_ctrl
);
778 extern int uvc_ctrl_add_info(struct uvc_control_info
*info
);
779 extern int uvc_ctrl_add_mapping(struct uvc_control_mapping
*mapping
);
780 extern int uvc_ctrl_init_device(struct uvc_device
*dev
);
781 extern void uvc_ctrl_cleanup_device(struct uvc_device
*dev
);
782 extern int uvc_ctrl_resume_device(struct uvc_device
*dev
);
783 extern void uvc_ctrl_init(void);
785 extern int uvc_ctrl_begin(struct uvc_video_device
*video
);
786 extern int __uvc_ctrl_commit(struct uvc_video_device
*video
, int rollback
);
787 static inline int uvc_ctrl_commit(struct uvc_video_device
*video
)
789 return __uvc_ctrl_commit(video
, 0);
791 static inline int uvc_ctrl_rollback(struct uvc_video_device
*video
)
793 return __uvc_ctrl_commit(video
, 1);
796 extern int uvc_ctrl_get(struct uvc_video_device
*video
,
797 struct v4l2_ext_control
*xctrl
);
798 extern int uvc_ctrl_set(struct uvc_video_device
*video
,
799 struct v4l2_ext_control
*xctrl
);
801 extern int uvc_xu_ctrl_query(struct uvc_video_device
*video
,
802 struct uvc_xu_control
*ctrl
, int set
);
804 /* Utility functions */
805 extern void uvc_simplify_fraction(uint32_t *numerator
, uint32_t *denominator
,
806 unsigned int n_terms
, unsigned int threshold
);
807 extern uint32_t uvc_fraction_to_interval(uint32_t numerator
,
808 uint32_t denominator
);
809 extern struct usb_host_endpoint
*uvc_find_endpoint(
810 struct usb_host_interface
*alts
, __u8 epaddr
);
813 void uvc_video_decode_isight(struct urb
*urb
, struct uvc_video_device
*video
,
814 struct uvc_buffer
*buf
);
816 #endif /* __KERNEL__ */