2 * USB Video Class definitions.
4 * Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be>
6 * This file holds USB constants and structures defined by the USB Device
7 * Class Definition for Video Devices. Unless otherwise stated, comments
8 * below reference relevant sections of the USB Video Class 1.1 specification
11 * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip
14 #ifndef __LINUX_USB_VIDEO_H
15 #define __LINUX_USB_VIDEO_H
17 #include <linux/types.h>
19 /* --------------------------------------------------------------------------
23 /* A.2. Video Interface Subclass Codes */
24 #define UVC_SC_UNDEFINED 0x00
25 #define UVC_SC_VIDEOCONTROL 0x01
26 #define UVC_SC_VIDEOSTREAMING 0x02
27 #define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03
29 /* A.3. Video Interface Protocol Codes */
30 #define UVC_PC_PROTOCOL_UNDEFINED 0x00
31 #define UVC_PC_PROTOCOL_15 0x01
33 /* A.5. Video Class-Specific VC Interface Descriptor Subtypes */
34 #define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
35 #define UVC_VC_HEADER 0x01
36 #define UVC_VC_INPUT_TERMINAL 0x02
37 #define UVC_VC_OUTPUT_TERMINAL 0x03
38 #define UVC_VC_SELECTOR_UNIT 0x04
39 #define UVC_VC_PROCESSING_UNIT 0x05
40 #define UVC_VC_EXTENSION_UNIT 0x06
42 /* A.6. Video Class-Specific VS Interface Descriptor Subtypes */
43 #define UVC_VS_UNDEFINED 0x00
44 #define UVC_VS_INPUT_HEADER 0x01
45 #define UVC_VS_OUTPUT_HEADER 0x02
46 #define UVC_VS_STILL_IMAGE_FRAME 0x03
47 #define UVC_VS_FORMAT_UNCOMPRESSED 0x04
48 #define UVC_VS_FRAME_UNCOMPRESSED 0x05
49 #define UVC_VS_FORMAT_MJPEG 0x06
50 #define UVC_VS_FRAME_MJPEG 0x07
51 #define UVC_VS_FORMAT_MPEG2TS 0x0a
52 #define UVC_VS_FORMAT_DV 0x0c
53 #define UVC_VS_COLORFORMAT 0x0d
54 #define UVC_VS_FORMAT_FRAME_BASED 0x10
55 #define UVC_VS_FRAME_FRAME_BASED 0x11
56 #define UVC_VS_FORMAT_STREAM_BASED 0x12
58 /* A.7. Video Class-Specific Endpoint Descriptor Subtypes */
59 #define UVC_EP_UNDEFINED 0x00
60 #define UVC_EP_GENERAL 0x01
61 #define UVC_EP_ENDPOINT 0x02
62 #define UVC_EP_INTERRUPT 0x03
64 /* A.8. Video Class-Specific Request Codes */
65 #define UVC_RC_UNDEFINED 0x00
66 #define UVC_SET_CUR 0x01
67 #define UVC_GET_CUR 0x81
68 #define UVC_GET_MIN 0x82
69 #define UVC_GET_MAX 0x83
70 #define UVC_GET_RES 0x84
71 #define UVC_GET_LEN 0x85
72 #define UVC_GET_INFO 0x86
73 #define UVC_GET_DEF 0x87
75 /* A.9.1. VideoControl Interface Control Selectors */
76 #define UVC_VC_CONTROL_UNDEFINED 0x00
77 #define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
78 #define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02
80 /* A.9.2. Terminal Control Selectors */
81 #define UVC_TE_CONTROL_UNDEFINED 0x00
83 /* A.9.3. Selector Unit Control Selectors */
84 #define UVC_SU_CONTROL_UNDEFINED 0x00
85 #define UVC_SU_INPUT_SELECT_CONTROL 0x01
87 /* A.9.4. Camera Terminal Control Selectors */
88 #define UVC_CT_CONTROL_UNDEFINED 0x00
89 #define UVC_CT_SCANNING_MODE_CONTROL 0x01
90 #define UVC_CT_AE_MODE_CONTROL 0x02
91 #define UVC_CT_AE_PRIORITY_CONTROL 0x03
92 #define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
93 #define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
94 #define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
95 #define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
96 #define UVC_CT_FOCUS_AUTO_CONTROL 0x08
97 #define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09
98 #define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a
99 #define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
100 #define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c
101 #define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d
102 #define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e
103 #define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
104 #define UVC_CT_ROLL_RELATIVE_CONTROL 0x10
105 #define UVC_CT_PRIVACY_CONTROL 0x11
107 /* A.9.5. Processing Unit Control Selectors */
108 #define UVC_PU_CONTROL_UNDEFINED 0x00
109 #define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
110 #define UVC_PU_BRIGHTNESS_CONTROL 0x02
111 #define UVC_PU_CONTRAST_CONTROL 0x03
112 #define UVC_PU_GAIN_CONTROL 0x04
113 #define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
114 #define UVC_PU_HUE_CONTROL 0x06
115 #define UVC_PU_SATURATION_CONTROL 0x07
116 #define UVC_PU_SHARPNESS_CONTROL 0x08
117 #define UVC_PU_GAMMA_CONTROL 0x09
118 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
119 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
120 #define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
121 #define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
122 #define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
123 #define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
124 #define UVC_PU_HUE_AUTO_CONTROL 0x10
125 #define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
126 #define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
128 /* A.9.7. VideoStreaming Interface Control Selectors */
129 #define UVC_VS_CONTROL_UNDEFINED 0x00
130 #define UVC_VS_PROBE_CONTROL 0x01
131 #define UVC_VS_COMMIT_CONTROL 0x02
132 #define UVC_VS_STILL_PROBE_CONTROL 0x03
133 #define UVC_VS_STILL_COMMIT_CONTROL 0x04
134 #define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
135 #define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
136 #define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
137 #define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
138 #define UVC_VS_SYNC_DELAY_CONTROL 0x09
140 /* B.1. USB Terminal Types */
141 #define UVC_TT_VENDOR_SPECIFIC 0x0100
142 #define UVC_TT_STREAMING 0x0101
144 /* B.2. Input Terminal Types */
145 #define UVC_ITT_VENDOR_SPECIFIC 0x0200
146 #define UVC_ITT_CAMERA 0x0201
147 #define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
149 /* B.3. Output Terminal Types */
150 #define UVC_OTT_VENDOR_SPECIFIC 0x0300
151 #define UVC_OTT_DISPLAY 0x0301
152 #define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
154 /* B.4. External Terminal Types */
155 #define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
156 #define UVC_COMPOSITE_CONNECTOR 0x0401
157 #define UVC_SVIDEO_CONNECTOR 0x0402
158 #define UVC_COMPONENT_CONNECTOR 0x0403
160 /* 2.4.2.2. Status Packet Type */
161 #define UVC_STATUS_TYPE_CONTROL 1
162 #define UVC_STATUS_TYPE_STREAMING 2
164 /* 2.4.3.3. Payload Header Information */
165 #define UVC_STREAM_EOH (1 << 7)
166 #define UVC_STREAM_ERR (1 << 6)
167 #define UVC_STREAM_STI (1 << 5)
168 #define UVC_STREAM_RES (1 << 4)
169 #define UVC_STREAM_SCR (1 << 3)
170 #define UVC_STREAM_PTS (1 << 2)
171 #define UVC_STREAM_EOF (1 << 1)
172 #define UVC_STREAM_FID (1 << 0)
174 /* 4.1.2. Control Capabilities */
175 #define UVC_CONTROL_CAP_GET (1 << 0)
176 #define UVC_CONTROL_CAP_SET (1 << 1)
177 #define UVC_CONTROL_CAP_DISABLED (1 << 2)
178 #define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)
179 #define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4)
181 /* ------------------------------------------------------------------------
185 /* All UVC descriptors have these 3 fields at the beginning */
186 struct uvc_descriptor_header
{
188 __u8 bDescriptorType
;
189 __u8 bDescriptorSubType
;
190 } __attribute__((packed
));
192 /* 3.7.2. Video Control Interface Header Descriptor */
193 struct uvc_header_descriptor
{
195 __u8 bDescriptorType
;
196 __u8 bDescriptorSubType
;
199 __u32 dwClockFrequency
;
201 __u8 baInterfaceNr
[];
202 } __attribute__((__packed__
));
204 #define UVC_DT_HEADER_SIZE(n) (12+(n))
206 #define UVC_HEADER_DESCRIPTOR(n) \
207 uvc_header_descriptor_##n
209 #define DECLARE_UVC_HEADER_DESCRIPTOR(n) \
210 struct UVC_HEADER_DESCRIPTOR(n) { \
212 __u8 bDescriptorType; \
213 __u8 bDescriptorSubType; \
215 __u16 wTotalLength; \
216 __u32 dwClockFrequency; \
217 __u8 bInCollection; \
218 __u8 baInterfaceNr[n]; \
219 } __attribute__ ((packed))
221 /* 3.7.2.1. Input Terminal Descriptor */
222 struct uvc_input_terminal_descriptor
{
224 __u8 bDescriptorType
;
225 __u8 bDescriptorSubType
;
230 } __attribute__((__packed__
));
232 #define UVC_DT_INPUT_TERMINAL_SIZE 8
234 /* 3.7.2.2. Output Terminal Descriptor */
235 struct uvc_output_terminal_descriptor
{
237 __u8 bDescriptorType
;
238 __u8 bDescriptorSubType
;
244 } __attribute__((__packed__
));
246 #define UVC_DT_OUTPUT_TERMINAL_SIZE 9
248 /* 3.7.2.3. Camera Terminal Descriptor */
249 struct uvc_camera_terminal_descriptor
{
251 __u8 bDescriptorType
;
252 __u8 bDescriptorSubType
;
257 __u16 wObjectiveFocalLengthMin
;
258 __u16 wObjectiveFocalLengthMax
;
259 __u16 wOcularFocalLength
;
262 } __attribute__((__packed__
));
264 #define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n))
266 /* 3.7.2.4. Selector Unit Descriptor */
267 struct uvc_selector_unit_descriptor
{
269 __u8 bDescriptorType
;
270 __u8 bDescriptorSubType
;
275 } __attribute__((__packed__
));
277 #define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n))
279 #define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
280 uvc_selector_unit_descriptor_##n
282 #define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
283 struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \
285 __u8 bDescriptorType; \
286 __u8 bDescriptorSubType; \
289 __u8 baSourceID[n]; \
291 } __attribute__ ((packed))
293 /* 3.7.2.5. Processing Unit Descriptor */
294 struct uvc_processing_unit_descriptor
{
296 __u8 bDescriptorType
;
297 __u8 bDescriptorSubType
;
300 __u16 wMaxMultiplier
;
304 } __attribute__((__packed__
));
306 #define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n))
308 /* 3.7.2.6. Extension Unit Descriptor */
309 struct uvc_extension_unit_descriptor
{
311 __u8 bDescriptorType
;
312 __u8 bDescriptorSubType
;
314 __u8 guidExtensionCode
[16];
321 } __attribute__((__packed__
));
323 #define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24+(p)+(n))
325 #define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
326 uvc_extension_unit_descriptor_##p_##n
328 #define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
329 struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \
331 __u8 bDescriptorType; \
332 __u8 bDescriptorSubType; \
334 __u8 guidExtensionCode[16]; \
337 __u8 baSourceID[p]; \
339 __u8 bmControls[n]; \
341 } __attribute__ ((packed))
343 /* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */
344 struct uvc_control_endpoint_descriptor
{
346 __u8 bDescriptorType
;
347 __u8 bDescriptorSubType
;
348 __u16 wMaxTransferSize
;
349 } __attribute__((__packed__
));
351 #define UVC_DT_CONTROL_ENDPOINT_SIZE 5
353 /* 3.9.2.1. Input Header Descriptor */
354 struct uvc_input_header_descriptor
{
356 __u8 bDescriptorType
;
357 __u8 bDescriptorSubType
;
360 __u8 bEndpointAddress
;
363 __u8 bStillCaptureMethod
;
364 __u8 bTriggerSupport
;
368 } __attribute__((__packed__
));
370 #define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p))
372 #define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
373 uvc_input_header_descriptor_##n_##p
375 #define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
376 struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \
378 __u8 bDescriptorType; \
379 __u8 bDescriptorSubType; \
381 __u16 wTotalLength; \
382 __u8 bEndpointAddress; \
384 __u8 bTerminalLink; \
385 __u8 bStillCaptureMethod; \
386 __u8 bTriggerSupport; \
387 __u8 bTriggerUsage; \
389 __u8 bmaControls[p][n]; \
390 } __attribute__ ((packed))
392 /* 3.9.2.2. Output Header Descriptor */
393 struct uvc_output_header_descriptor
{
395 __u8 bDescriptorType
;
396 __u8 bDescriptorSubType
;
399 __u8 bEndpointAddress
;
403 } __attribute__((__packed__
));
405 #define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p))
407 #define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
408 uvc_output_header_descriptor_##n_##p
410 #define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
411 struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \
413 __u8 bDescriptorType; \
414 __u8 bDescriptorSubType; \
416 __u16 wTotalLength; \
417 __u8 bEndpointAddress; \
418 __u8 bTerminalLink; \
420 __u8 bmaControls[p][n]; \
421 } __attribute__ ((packed))
423 /* 3.9.2.6. Color matching descriptor */
424 struct uvc_color_matching_descriptor
{
426 __u8 bDescriptorType
;
427 __u8 bDescriptorSubType
;
428 __u8 bColorPrimaries
;
429 __u8 bTransferCharacteristics
;
430 __u8 bMatrixCoefficients
;
431 } __attribute__((__packed__
));
433 #define UVC_DT_COLOR_MATCHING_SIZE 6
435 /* 4.3.1.1. Video Probe and Commit Controls */
436 struct uvc_streaming_control
{
440 __u32 dwFrameInterval
;
444 __u16 wCompWindowSize
;
446 __u32 dwMaxVideoFrameSize
;
447 __u32 dwMaxPayloadTransferSize
;
448 __u32 dwClockFrequency
;
450 __u8 bPreferedVersion
;
453 } __attribute__((__packed__
));
455 /* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */
456 struct uvc_format_uncompressed
{
458 __u8 bDescriptorType
;
459 __u8 bDescriptorSubType
;
461 __u8 bNumFrameDescriptors
;
464 __u8 bDefaultFrameIndex
;
467 __u8 bmInterfaceFlags
;
469 } __attribute__((__packed__
));
471 #define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
473 /* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */
474 struct uvc_frame_uncompressed
{
476 __u8 bDescriptorType
;
477 __u8 bDescriptorSubType
;
484 __u32 dwMaxVideoFrameBufferSize
;
485 __u32 dwDefaultFrameInterval
;
486 __u8 bFrameIntervalType
;
487 __u32 dwFrameInterval
[];
488 } __attribute__((__packed__
));
490 #define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n))
492 #define UVC_FRAME_UNCOMPRESSED(n) \
493 uvc_frame_uncompressed_##n
495 #define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \
496 struct UVC_FRAME_UNCOMPRESSED(n) { \
498 __u8 bDescriptorType; \
499 __u8 bDescriptorSubType; \
501 __u8 bmCapabilities; \
504 __u32 dwMinBitRate; \
505 __u32 dwMaxBitRate; \
506 __u32 dwMaxVideoFrameBufferSize; \
507 __u32 dwDefaultFrameInterval; \
508 __u8 bFrameIntervalType; \
509 __u32 dwFrameInterval[n]; \
510 } __attribute__ ((packed))
512 /* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */
513 struct uvc_format_mjpeg
{
515 __u8 bDescriptorType
;
516 __u8 bDescriptorSubType
;
518 __u8 bNumFrameDescriptors
;
520 __u8 bDefaultFrameIndex
;
523 __u8 bmInterfaceFlags
;
525 } __attribute__((__packed__
));
527 #define UVC_DT_FORMAT_MJPEG_SIZE 11
529 /* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */
530 struct uvc_frame_mjpeg
{
532 __u8 bDescriptorType
;
533 __u8 bDescriptorSubType
;
540 __u32 dwMaxVideoFrameBufferSize
;
541 __u32 dwDefaultFrameInterval
;
542 __u8 bFrameIntervalType
;
543 __u32 dwFrameInterval
[];
544 } __attribute__((__packed__
));
546 #define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n))
548 #define UVC_FRAME_MJPEG(n) \
551 #define DECLARE_UVC_FRAME_MJPEG(n) \
552 struct UVC_FRAME_MJPEG(n) { \
554 __u8 bDescriptorType; \
555 __u8 bDescriptorSubType; \
557 __u8 bmCapabilities; \
560 __u32 dwMinBitRate; \
561 __u32 dwMaxBitRate; \
562 __u32 dwMaxVideoFrameBufferSize; \
563 __u32 dwDefaultFrameInterval; \
564 __u8 bFrameIntervalType; \
565 __u32 dwFrameInterval[n]; \
566 } __attribute__ ((packed))
568 #endif /* __LINUX_USB_VIDEO_H */