1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * USB Video Class definitions.
5 * Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be>
7 * This file holds USB constants and structures defined by the USB Device
8 * Class Definition for Video Devices. Unless otherwise stated, comments
9 * below reference relevant sections of the USB Video Class 1.1 specification
12 * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip
15 #ifndef __LINUX_USB_VIDEO_H
16 #define __LINUX_USB_VIDEO_H
18 #include <linux/types.h>
20 /* --------------------------------------------------------------------------
24 /* A.2. Video Interface Subclass Codes */
25 #define UVC_SC_UNDEFINED 0x00
26 #define UVC_SC_VIDEOCONTROL 0x01
27 #define UVC_SC_VIDEOSTREAMING 0x02
28 #define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03
30 /* A.3. Video Interface Protocol Codes */
31 #define UVC_PC_PROTOCOL_UNDEFINED 0x00
32 #define UVC_PC_PROTOCOL_15 0x01
34 /* A.5. Video Class-Specific VC Interface Descriptor Subtypes */
35 #define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
36 #define UVC_VC_HEADER 0x01
37 #define UVC_VC_INPUT_TERMINAL 0x02
38 #define UVC_VC_OUTPUT_TERMINAL 0x03
39 #define UVC_VC_SELECTOR_UNIT 0x04
40 #define UVC_VC_PROCESSING_UNIT 0x05
41 #define UVC_VC_EXTENSION_UNIT 0x06
43 /* A.6. Video Class-Specific VS Interface Descriptor Subtypes */
44 #define UVC_VS_UNDEFINED 0x00
45 #define UVC_VS_INPUT_HEADER 0x01
46 #define UVC_VS_OUTPUT_HEADER 0x02
47 #define UVC_VS_STILL_IMAGE_FRAME 0x03
48 #define UVC_VS_FORMAT_UNCOMPRESSED 0x04
49 #define UVC_VS_FRAME_UNCOMPRESSED 0x05
50 #define UVC_VS_FORMAT_MJPEG 0x06
51 #define UVC_VS_FRAME_MJPEG 0x07
52 #define UVC_VS_FORMAT_MPEG2TS 0x0a
53 #define UVC_VS_FORMAT_DV 0x0c
54 #define UVC_VS_COLORFORMAT 0x0d
55 #define UVC_VS_FORMAT_FRAME_BASED 0x10
56 #define UVC_VS_FRAME_FRAME_BASED 0x11
57 #define UVC_VS_FORMAT_STREAM_BASED 0x12
59 /* A.7. Video Class-Specific Endpoint Descriptor Subtypes */
60 #define UVC_EP_UNDEFINED 0x00
61 #define UVC_EP_GENERAL 0x01
62 #define UVC_EP_ENDPOINT 0x02
63 #define UVC_EP_INTERRUPT 0x03
65 /* A.8. Video Class-Specific Request Codes */
66 #define UVC_RC_UNDEFINED 0x00
67 #define UVC_SET_CUR 0x01
68 #define UVC_GET_CUR 0x81
69 #define UVC_GET_MIN 0x82
70 #define UVC_GET_MAX 0x83
71 #define UVC_GET_RES 0x84
72 #define UVC_GET_LEN 0x85
73 #define UVC_GET_INFO 0x86
74 #define UVC_GET_DEF 0x87
76 /* A.9.1. VideoControl Interface Control Selectors */
77 #define UVC_VC_CONTROL_UNDEFINED 0x00
78 #define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
79 #define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02
81 /* A.9.2. Terminal Control Selectors */
82 #define UVC_TE_CONTROL_UNDEFINED 0x00
84 /* A.9.3. Selector Unit Control Selectors */
85 #define UVC_SU_CONTROL_UNDEFINED 0x00
86 #define UVC_SU_INPUT_SELECT_CONTROL 0x01
88 /* A.9.4. Camera Terminal Control Selectors */
89 #define UVC_CT_CONTROL_UNDEFINED 0x00
90 #define UVC_CT_SCANNING_MODE_CONTROL 0x01
91 #define UVC_CT_AE_MODE_CONTROL 0x02
92 #define UVC_CT_AE_PRIORITY_CONTROL 0x03
93 #define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
94 #define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
95 #define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
96 #define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
97 #define UVC_CT_FOCUS_AUTO_CONTROL 0x08
98 #define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09
99 #define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a
100 #define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
101 #define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c
102 #define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d
103 #define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e
104 #define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
105 #define UVC_CT_ROLL_RELATIVE_CONTROL 0x10
106 #define UVC_CT_PRIVACY_CONTROL 0x11
108 /* A.9.5. Processing Unit Control Selectors */
109 #define UVC_PU_CONTROL_UNDEFINED 0x00
110 #define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
111 #define UVC_PU_BRIGHTNESS_CONTROL 0x02
112 #define UVC_PU_CONTRAST_CONTROL 0x03
113 #define UVC_PU_GAIN_CONTROL 0x04
114 #define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
115 #define UVC_PU_HUE_CONTROL 0x06
116 #define UVC_PU_SATURATION_CONTROL 0x07
117 #define UVC_PU_SHARPNESS_CONTROL 0x08
118 #define UVC_PU_GAMMA_CONTROL 0x09
119 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
120 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
121 #define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
122 #define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
123 #define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
124 #define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
125 #define UVC_PU_HUE_AUTO_CONTROL 0x10
126 #define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
127 #define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
129 /* A.9.7. VideoStreaming Interface Control Selectors */
130 #define UVC_VS_CONTROL_UNDEFINED 0x00
131 #define UVC_VS_PROBE_CONTROL 0x01
132 #define UVC_VS_COMMIT_CONTROL 0x02
133 #define UVC_VS_STILL_PROBE_CONTROL 0x03
134 #define UVC_VS_STILL_COMMIT_CONTROL 0x04
135 #define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
136 #define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
137 #define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
138 #define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
139 #define UVC_VS_SYNC_DELAY_CONTROL 0x09
141 /* B.1. USB Terminal Types */
142 #define UVC_TT_VENDOR_SPECIFIC 0x0100
143 #define UVC_TT_STREAMING 0x0101
145 /* B.2. Input Terminal Types */
146 #define UVC_ITT_VENDOR_SPECIFIC 0x0200
147 #define UVC_ITT_CAMERA 0x0201
148 #define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
150 /* B.3. Output Terminal Types */
151 #define UVC_OTT_VENDOR_SPECIFIC 0x0300
152 #define UVC_OTT_DISPLAY 0x0301
153 #define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
155 /* B.4. External Terminal Types */
156 #define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
157 #define UVC_COMPOSITE_CONNECTOR 0x0401
158 #define UVC_SVIDEO_CONNECTOR 0x0402
159 #define UVC_COMPONENT_CONNECTOR 0x0403
161 /* 2.4.2.2. Status Packet Type */
162 #define UVC_STATUS_TYPE_CONTROL 1
163 #define UVC_STATUS_TYPE_STREAMING 2
165 /* 2.4.3.3. Payload Header Information */
166 #define UVC_STREAM_EOH (1 << 7)
167 #define UVC_STREAM_ERR (1 << 6)
168 #define UVC_STREAM_STI (1 << 5)
169 #define UVC_STREAM_RES (1 << 4)
170 #define UVC_STREAM_SCR (1 << 3)
171 #define UVC_STREAM_PTS (1 << 2)
172 #define UVC_STREAM_EOF (1 << 1)
173 #define UVC_STREAM_FID (1 << 0)
175 /* 4.1.2. Control Capabilities */
176 #define UVC_CONTROL_CAP_GET (1 << 0)
177 #define UVC_CONTROL_CAP_SET (1 << 1)
178 #define UVC_CONTROL_CAP_DISABLED (1 << 2)
179 #define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)
180 #define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4)
182 /* ------------------------------------------------------------------------
186 /* All UVC descriptors have these 3 fields at the beginning */
187 struct uvc_descriptor_header
{
189 __u8 bDescriptorType
;
190 __u8 bDescriptorSubType
;
191 } __attribute__((packed
));
193 /* 3.7.2. Video Control Interface Header Descriptor */
194 struct uvc_header_descriptor
{
196 __u8 bDescriptorType
;
197 __u8 bDescriptorSubType
;
200 __u32 dwClockFrequency
;
202 __u8 baInterfaceNr
[];
203 } __attribute__((__packed__
));
205 #define UVC_DT_HEADER_SIZE(n) (12+(n))
207 #define UVC_HEADER_DESCRIPTOR(n) \
208 uvc_header_descriptor_##n
210 #define DECLARE_UVC_HEADER_DESCRIPTOR(n) \
211 struct UVC_HEADER_DESCRIPTOR(n) { \
213 __u8 bDescriptorType; \
214 __u8 bDescriptorSubType; \
216 __u16 wTotalLength; \
217 __u32 dwClockFrequency; \
218 __u8 bInCollection; \
219 __u8 baInterfaceNr[n]; \
220 } __attribute__ ((packed))
222 /* 3.7.2.1. Input Terminal Descriptor */
223 struct uvc_input_terminal_descriptor
{
225 __u8 bDescriptorType
;
226 __u8 bDescriptorSubType
;
231 } __attribute__((__packed__
));
233 #define UVC_DT_INPUT_TERMINAL_SIZE 8
235 /* 3.7.2.2. Output Terminal Descriptor */
236 struct uvc_output_terminal_descriptor
{
238 __u8 bDescriptorType
;
239 __u8 bDescriptorSubType
;
245 } __attribute__((__packed__
));
247 #define UVC_DT_OUTPUT_TERMINAL_SIZE 9
249 /* 3.7.2.3. Camera Terminal Descriptor */
250 struct uvc_camera_terminal_descriptor
{
252 __u8 bDescriptorType
;
253 __u8 bDescriptorSubType
;
258 __u16 wObjectiveFocalLengthMin
;
259 __u16 wObjectiveFocalLengthMax
;
260 __u16 wOcularFocalLength
;
263 } __attribute__((__packed__
));
265 #define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n))
267 /* 3.7.2.4. Selector Unit Descriptor */
268 struct uvc_selector_unit_descriptor
{
270 __u8 bDescriptorType
;
271 __u8 bDescriptorSubType
;
276 } __attribute__((__packed__
));
278 #define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n))
280 #define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
281 uvc_selector_unit_descriptor_##n
283 #define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
284 struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \
286 __u8 bDescriptorType; \
287 __u8 bDescriptorSubType; \
290 __u8 baSourceID[n]; \
292 } __attribute__ ((packed))
294 /* 3.7.2.5. Processing Unit Descriptor */
295 struct uvc_processing_unit_descriptor
{
297 __u8 bDescriptorType
;
298 __u8 bDescriptorSubType
;
301 __u16 wMaxMultiplier
;
305 } __attribute__((__packed__
));
307 #define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n))
309 /* 3.7.2.6. Extension Unit Descriptor */
310 struct uvc_extension_unit_descriptor
{
312 __u8 bDescriptorType
;
313 __u8 bDescriptorSubType
;
315 __u8 guidExtensionCode
[16];
322 } __attribute__((__packed__
));
324 #define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24+(p)+(n))
326 #define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
327 uvc_extension_unit_descriptor_##p_##n
329 #define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
330 struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \
332 __u8 bDescriptorType; \
333 __u8 bDescriptorSubType; \
335 __u8 guidExtensionCode[16]; \
338 __u8 baSourceID[p]; \
340 __u8 bmControls[n]; \
342 } __attribute__ ((packed))
344 /* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */
345 struct uvc_control_endpoint_descriptor
{
347 __u8 bDescriptorType
;
348 __u8 bDescriptorSubType
;
349 __u16 wMaxTransferSize
;
350 } __attribute__((__packed__
));
352 #define UVC_DT_CONTROL_ENDPOINT_SIZE 5
354 /* 3.9.2.1. Input Header Descriptor */
355 struct uvc_input_header_descriptor
{
357 __u8 bDescriptorType
;
358 __u8 bDescriptorSubType
;
361 __u8 bEndpointAddress
;
364 __u8 bStillCaptureMethod
;
365 __u8 bTriggerSupport
;
369 } __attribute__((__packed__
));
371 #define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p))
373 #define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
374 uvc_input_header_descriptor_##n_##p
376 #define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
377 struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \
379 __u8 bDescriptorType; \
380 __u8 bDescriptorSubType; \
382 __u16 wTotalLength; \
383 __u8 bEndpointAddress; \
385 __u8 bTerminalLink; \
386 __u8 bStillCaptureMethod; \
387 __u8 bTriggerSupport; \
388 __u8 bTriggerUsage; \
390 __u8 bmaControls[p][n]; \
391 } __attribute__ ((packed))
393 /* 3.9.2.2. Output Header Descriptor */
394 struct uvc_output_header_descriptor
{
396 __u8 bDescriptorType
;
397 __u8 bDescriptorSubType
;
400 __u8 bEndpointAddress
;
404 } __attribute__((__packed__
));
406 #define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p))
408 #define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
409 uvc_output_header_descriptor_##n_##p
411 #define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
412 struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \
414 __u8 bDescriptorType; \
415 __u8 bDescriptorSubType; \
417 __u16 wTotalLength; \
418 __u8 bEndpointAddress; \
419 __u8 bTerminalLink; \
421 __u8 bmaControls[p][n]; \
422 } __attribute__ ((packed))
424 /* 3.9.2.6. Color matching descriptor */
425 struct uvc_color_matching_descriptor
{
427 __u8 bDescriptorType
;
428 __u8 bDescriptorSubType
;
429 __u8 bColorPrimaries
;
430 __u8 bTransferCharacteristics
;
431 __u8 bMatrixCoefficients
;
432 } __attribute__((__packed__
));
434 #define UVC_DT_COLOR_MATCHING_SIZE 6
436 /* 4.3.1.1. Video Probe and Commit Controls */
437 struct uvc_streaming_control
{
441 __u32 dwFrameInterval
;
445 __u16 wCompWindowSize
;
447 __u32 dwMaxVideoFrameSize
;
448 __u32 dwMaxPayloadTransferSize
;
449 __u32 dwClockFrequency
;
451 __u8 bPreferedVersion
;
454 } __attribute__((__packed__
));
456 /* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */
457 struct uvc_format_uncompressed
{
459 __u8 bDescriptorType
;
460 __u8 bDescriptorSubType
;
462 __u8 bNumFrameDescriptors
;
465 __u8 bDefaultFrameIndex
;
468 __u8 bmInterfaceFlags
;
470 } __attribute__((__packed__
));
472 #define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
474 /* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */
475 struct uvc_frame_uncompressed
{
477 __u8 bDescriptorType
;
478 __u8 bDescriptorSubType
;
485 __u32 dwMaxVideoFrameBufferSize
;
486 __u32 dwDefaultFrameInterval
;
487 __u8 bFrameIntervalType
;
488 __u32 dwFrameInterval
[];
489 } __attribute__((__packed__
));
491 #define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n))
493 #define UVC_FRAME_UNCOMPRESSED(n) \
494 uvc_frame_uncompressed_##n
496 #define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \
497 struct UVC_FRAME_UNCOMPRESSED(n) { \
499 __u8 bDescriptorType; \
500 __u8 bDescriptorSubType; \
502 __u8 bmCapabilities; \
505 __u32 dwMinBitRate; \
506 __u32 dwMaxBitRate; \
507 __u32 dwMaxVideoFrameBufferSize; \
508 __u32 dwDefaultFrameInterval; \
509 __u8 bFrameIntervalType; \
510 __u32 dwFrameInterval[n]; \
511 } __attribute__ ((packed))
513 /* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */
514 struct uvc_format_mjpeg
{
516 __u8 bDescriptorType
;
517 __u8 bDescriptorSubType
;
519 __u8 bNumFrameDescriptors
;
521 __u8 bDefaultFrameIndex
;
524 __u8 bmInterfaceFlags
;
526 } __attribute__((__packed__
));
528 #define UVC_DT_FORMAT_MJPEG_SIZE 11
530 /* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */
531 struct uvc_frame_mjpeg
{
533 __u8 bDescriptorType
;
534 __u8 bDescriptorSubType
;
541 __u32 dwMaxVideoFrameBufferSize
;
542 __u32 dwDefaultFrameInterval
;
543 __u8 bFrameIntervalType
;
544 __u32 dwFrameInterval
[];
545 } __attribute__((__packed__
));
547 #define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n))
549 #define UVC_FRAME_MJPEG(n) \
552 #define DECLARE_UVC_FRAME_MJPEG(n) \
553 struct UVC_FRAME_MJPEG(n) { \
555 __u8 bDescriptorType; \
556 __u8 bDescriptorSubType; \
558 __u8 bmCapabilities; \
561 __u32 dwMinBitRate; \
562 __u32 dwMaxBitRate; \
563 __u32 dwMaxVideoFrameBufferSize; \
564 __u32 dwDefaultFrameInterval; \
565 __u8 bFrameIntervalType; \
566 __u32 dwFrameInterval[n]; \
567 } __attribute__ ((packed))
569 #endif /* __LINUX_USB_VIDEO_H */