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
32 /* A.5. Video Class-Specific VC Interface Descriptor Subtypes */
33 #define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
34 #define UVC_VC_HEADER 0x01
35 #define UVC_VC_INPUT_TERMINAL 0x02
36 #define UVC_VC_OUTPUT_TERMINAL 0x03
37 #define UVC_VC_SELECTOR_UNIT 0x04
38 #define UVC_VC_PROCESSING_UNIT 0x05
39 #define UVC_VC_EXTENSION_UNIT 0x06
41 /* A.6. Video Class-Specific VS Interface Descriptor Subtypes */
42 #define UVC_VS_UNDEFINED 0x00
43 #define UVC_VS_INPUT_HEADER 0x01
44 #define UVC_VS_OUTPUT_HEADER 0x02
45 #define UVC_VS_STILL_IMAGE_FRAME 0x03
46 #define UVC_VS_FORMAT_UNCOMPRESSED 0x04
47 #define UVC_VS_FRAME_UNCOMPRESSED 0x05
48 #define UVC_VS_FORMAT_MJPEG 0x06
49 #define UVC_VS_FRAME_MJPEG 0x07
50 #define UVC_VS_FORMAT_MPEG2TS 0x0a
51 #define UVC_VS_FORMAT_DV 0x0c
52 #define UVC_VS_COLORFORMAT 0x0d
53 #define UVC_VS_FORMAT_FRAME_BASED 0x10
54 #define UVC_VS_FRAME_FRAME_BASED 0x11
55 #define UVC_VS_FORMAT_STREAM_BASED 0x12
57 /* A.7. Video Class-Specific Endpoint Descriptor Subtypes */
58 #define UVC_EP_UNDEFINED 0x00
59 #define UVC_EP_GENERAL 0x01
60 #define UVC_EP_ENDPOINT 0x02
61 #define UVC_EP_INTERRUPT 0x03
63 /* A.8. Video Class-Specific Request Codes */
64 #define UVC_RC_UNDEFINED 0x00
65 #define UVC_SET_CUR 0x01
66 #define UVC_GET_CUR 0x81
67 #define UVC_GET_MIN 0x82
68 #define UVC_GET_MAX 0x83
69 #define UVC_GET_RES 0x84
70 #define UVC_GET_LEN 0x85
71 #define UVC_GET_INFO 0x86
72 #define UVC_GET_DEF 0x87
74 /* A.9.1. VideoControl Interface Control Selectors */
75 #define UVC_VC_CONTROL_UNDEFINED 0x00
76 #define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
77 #define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02
79 /* A.9.2. Terminal Control Selectors */
80 #define UVC_TE_CONTROL_UNDEFINED 0x00
82 /* A.9.3. Selector Unit Control Selectors */
83 #define UVC_SU_CONTROL_UNDEFINED 0x00
84 #define UVC_SU_INPUT_SELECT_CONTROL 0x01
86 /* A.9.4. Camera Terminal Control Selectors */
87 #define UVC_CT_CONTROL_UNDEFINED 0x00
88 #define UVC_CT_SCANNING_MODE_CONTROL 0x01
89 #define UVC_CT_AE_MODE_CONTROL 0x02
90 #define UVC_CT_AE_PRIORITY_CONTROL 0x03
91 #define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
92 #define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
93 #define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
94 #define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
95 #define UVC_CT_FOCUS_AUTO_CONTROL 0x08
96 #define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09
97 #define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a
98 #define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
99 #define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c
100 #define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d
101 #define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e
102 #define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
103 #define UVC_CT_ROLL_RELATIVE_CONTROL 0x10
104 #define UVC_CT_PRIVACY_CONTROL 0x11
106 /* A.9.5. Processing Unit Control Selectors */
107 #define UVC_PU_CONTROL_UNDEFINED 0x00
108 #define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
109 #define UVC_PU_BRIGHTNESS_CONTROL 0x02
110 #define UVC_PU_CONTRAST_CONTROL 0x03
111 #define UVC_PU_GAIN_CONTROL 0x04
112 #define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
113 #define UVC_PU_HUE_CONTROL 0x06
114 #define UVC_PU_SATURATION_CONTROL 0x07
115 #define UVC_PU_SHARPNESS_CONTROL 0x08
116 #define UVC_PU_GAMMA_CONTROL 0x09
117 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
118 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
119 #define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
120 #define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
121 #define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
122 #define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
123 #define UVC_PU_HUE_AUTO_CONTROL 0x10
124 #define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
125 #define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
127 /* A.9.7. VideoStreaming Interface Control Selectors */
128 #define UVC_VS_CONTROL_UNDEFINED 0x00
129 #define UVC_VS_PROBE_CONTROL 0x01
130 #define UVC_VS_COMMIT_CONTROL 0x02
131 #define UVC_VS_STILL_PROBE_CONTROL 0x03
132 #define UVC_VS_STILL_COMMIT_CONTROL 0x04
133 #define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
134 #define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
135 #define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
136 #define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
137 #define UVC_VS_SYNC_DELAY_CONTROL 0x09
139 /* B.1. USB Terminal Types */
140 #define UVC_TT_VENDOR_SPECIFIC 0x0100
141 #define UVC_TT_STREAMING 0x0101
143 /* B.2. Input Terminal Types */
144 #define UVC_ITT_VENDOR_SPECIFIC 0x0200
145 #define UVC_ITT_CAMERA 0x0201
146 #define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
148 /* B.3. Output Terminal Types */
149 #define UVC_OTT_VENDOR_SPECIFIC 0x0300
150 #define UVC_OTT_DISPLAY 0x0301
151 #define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
153 /* B.4. External Terminal Types */
154 #define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
155 #define UVC_COMPOSITE_CONNECTOR 0x0401
156 #define UVC_SVIDEO_CONNECTOR 0x0402
157 #define UVC_COMPONENT_CONNECTOR 0x0403
159 /* 2.4.2.2. Status Packet Type */
160 #define UVC_STATUS_TYPE_CONTROL 1
161 #define UVC_STATUS_TYPE_STREAMING 2
163 /* 2.4.3.3. Payload Header Information */
164 #define UVC_STREAM_EOH (1 << 7)
165 #define UVC_STREAM_ERR (1 << 6)
166 #define UVC_STREAM_STI (1 << 5)
167 #define UVC_STREAM_RES (1 << 4)
168 #define UVC_STREAM_SCR (1 << 3)
169 #define UVC_STREAM_PTS (1 << 2)
170 #define UVC_STREAM_EOF (1 << 1)
171 #define UVC_STREAM_FID (1 << 0)
173 /* 4.1.2. Control Capabilities */
174 #define UVC_CONTROL_CAP_GET (1 << 0)
175 #define UVC_CONTROL_CAP_SET (1 << 1)
176 #define UVC_CONTROL_CAP_DISABLED (1 << 2)
177 #define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)
178 #define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4)
180 /* ------------------------------------------------------------------------
184 /* All UVC descriptors have these 3 fields at the beginning */
185 struct uvc_descriptor_header {
187 __u8 bDescriptorType;
188 __u8 bDescriptorSubType;
189 } __attribute__((packed));
191 /* 3.7.2. Video Control Interface Header Descriptor */
192 struct uvc_header_descriptor {
194 __u8 bDescriptorType;
195 __u8 bDescriptorSubType;
198 __u32 dwClockFrequency;
200 __u8 baInterfaceNr[];
201 } __attribute__((__packed__));
203 #define UVC_DT_HEADER_SIZE(n) (12+(n))
205 #define UVC_HEADER_DESCRIPTOR(n) \
206 uvc_header_descriptor_##n
208 #define DECLARE_UVC_HEADER_DESCRIPTOR(n) \
209 struct UVC_HEADER_DESCRIPTOR(n) { \
211 __u8 bDescriptorType; \
212 __u8 bDescriptorSubType; \
214 __u16 wTotalLength; \
215 __u32 dwClockFrequency; \
216 __u8 bInCollection; \
217 __u8 baInterfaceNr[n]; \
218 } __attribute__ ((packed))
220 /* 3.7.2.1. Input Terminal Descriptor */
221 struct uvc_input_terminal_descriptor {
223 __u8 bDescriptorType;
224 __u8 bDescriptorSubType;
229 } __attribute__((__packed__));
231 #define UVC_DT_INPUT_TERMINAL_SIZE 8
233 /* 3.7.2.2. Output Terminal Descriptor */
234 struct uvc_output_terminal_descriptor {
236 __u8 bDescriptorType;
237 __u8 bDescriptorSubType;
243 } __attribute__((__packed__));
245 #define UVC_DT_OUTPUT_TERMINAL_SIZE 9
247 /* 3.7.2.3. Camera Terminal Descriptor */
248 struct uvc_camera_terminal_descriptor {
250 __u8 bDescriptorType;
251 __u8 bDescriptorSubType;
256 __u16 wObjectiveFocalLengthMin;
257 __u16 wObjectiveFocalLengthMax;
258 __u16 wOcularFocalLength;
261 } __attribute__((__packed__));
263 #define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n))
265 /* 3.7.2.4. Selector Unit Descriptor */
266 struct uvc_selector_unit_descriptor {
268 __u8 bDescriptorType;
269 __u8 bDescriptorSubType;
274 } __attribute__((__packed__));
276 #define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n))
278 #define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
279 uvc_selector_unit_descriptor_##n
281 #define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
282 struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \
284 __u8 bDescriptorType; \
285 __u8 bDescriptorSubType; \
288 __u8 baSourceID[n]; \
290 } __attribute__ ((packed))
292 /* 3.7.2.5. Processing Unit Descriptor */
293 struct uvc_processing_unit_descriptor {
295 __u8 bDescriptorType;
296 __u8 bDescriptorSubType;
299 __u16 wMaxMultiplier;
303 } __attribute__((__packed__));
305 #define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n))
307 /* 3.7.2.6. Extension Unit Descriptor */
308 struct uvc_extension_unit_descriptor {
310 __u8 bDescriptorType;
311 __u8 bDescriptorSubType;
313 __u8 guidExtensionCode[16];
320 } __attribute__((__packed__));
322 #define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24+(p)+(n))
324 #define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
325 uvc_extension_unit_descriptor_##p_##n
327 #define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
328 struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \
330 __u8 bDescriptorType; \
331 __u8 bDescriptorSubType; \
333 __u8 guidExtensionCode[16]; \
336 __u8 baSourceID[p]; \
338 __u8 bmControls[n]; \
340 } __attribute__ ((packed))
342 /* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */
343 struct uvc_control_endpoint_descriptor {
345 __u8 bDescriptorType;
346 __u8 bDescriptorSubType;
347 __u16 wMaxTransferSize;
348 } __attribute__((__packed__));
350 #define UVC_DT_CONTROL_ENDPOINT_SIZE 5
352 /* 3.9.2.1. Input Header Descriptor */
353 struct uvc_input_header_descriptor {
355 __u8 bDescriptorType;
356 __u8 bDescriptorSubType;
359 __u8 bEndpointAddress;
362 __u8 bStillCaptureMethod;
363 __u8 bTriggerSupport;
367 } __attribute__((__packed__));
369 #define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p))
371 #define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
372 uvc_input_header_descriptor_##n_##p
374 #define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
375 struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \
377 __u8 bDescriptorType; \
378 __u8 bDescriptorSubType; \
380 __u16 wTotalLength; \
381 __u8 bEndpointAddress; \
383 __u8 bTerminalLink; \
384 __u8 bStillCaptureMethod; \
385 __u8 bTriggerSupport; \
386 __u8 bTriggerUsage; \
388 __u8 bmaControls[p][n]; \
389 } __attribute__ ((packed))
391 /* 3.9.2.2. Output Header Descriptor */
392 struct uvc_output_header_descriptor {
394 __u8 bDescriptorType;
395 __u8 bDescriptorSubType;
398 __u8 bEndpointAddress;
402 } __attribute__((__packed__));
404 #define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p))
406 #define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
407 uvc_output_header_descriptor_##n_##p
409 #define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
410 struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \
412 __u8 bDescriptorType; \
413 __u8 bDescriptorSubType; \
415 __u16 wTotalLength; \
416 __u8 bEndpointAddress; \
417 __u8 bTerminalLink; \
419 __u8 bmaControls[p][n]; \
420 } __attribute__ ((packed))
422 /* 3.9.2.6. Color matching descriptor */
423 struct uvc_color_matching_descriptor {
425 __u8 bDescriptorType;
426 __u8 bDescriptorSubType;
427 __u8 bColorPrimaries;
428 __u8 bTransferCharacteristics;
429 __u8 bMatrixCoefficients;
430 } __attribute__((__packed__));
432 #define UVC_DT_COLOR_MATCHING_SIZE 6
434 /* 4.3.1.1. Video Probe and Commit Controls */
435 struct uvc_streaming_control {
439 __u32 dwFrameInterval;
443 __u16 wCompWindowSize;
445 __u32 dwMaxVideoFrameSize;
446 __u32 dwMaxPayloadTransferSize;
447 __u32 dwClockFrequency;
449 __u8 bPreferedVersion;
452 } __attribute__((__packed__));
454 /* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */
455 struct uvc_format_uncompressed {
457 __u8 bDescriptorType;
458 __u8 bDescriptorSubType;
460 __u8 bNumFrameDescriptors;
463 __u8 bDefaultFrameIndex;
466 __u8 bmInterfaceFlags;
468 } __attribute__((__packed__));
470 #define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
472 /* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */
473 struct uvc_frame_uncompressed {
475 __u8 bDescriptorType;
476 __u8 bDescriptorSubType;
483 __u32 dwMaxVideoFrameBufferSize;
484 __u32 dwDefaultFrameInterval;
485 __u8 bFrameIntervalType;
486 __u32 dwFrameInterval[];
487 } __attribute__((__packed__));
489 #define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n))
491 #define UVC_FRAME_UNCOMPRESSED(n) \
492 uvc_frame_uncompressed_##n
494 #define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \
495 struct UVC_FRAME_UNCOMPRESSED(n) { \
497 __u8 bDescriptorType; \
498 __u8 bDescriptorSubType; \
500 __u8 bmCapabilities; \
503 __u32 dwMinBitRate; \
504 __u32 dwMaxBitRate; \
505 __u32 dwMaxVideoFrameBufferSize; \
506 __u32 dwDefaultFrameInterval; \
507 __u8 bFrameIntervalType; \
508 __u32 dwFrameInterval[n]; \
509 } __attribute__ ((packed))
511 /* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */
512 struct uvc_format_mjpeg {
514 __u8 bDescriptorType;
515 __u8 bDescriptorSubType;
517 __u8 bNumFrameDescriptors;
519 __u8 bDefaultFrameIndex;
522 __u8 bmInterfaceFlags;
524 } __attribute__((__packed__));
526 #define UVC_DT_FORMAT_MJPEG_SIZE 11
528 /* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */
529 struct uvc_frame_mjpeg {
531 __u8 bDescriptorType;
532 __u8 bDescriptorSubType;
539 __u32 dwMaxVideoFrameBufferSize;
540 __u32 dwDefaultFrameInterval;
541 __u8 bFrameIntervalType;
542 __u32 dwFrameInterval[];
543 } __attribute__((__packed__));
545 #define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n))
547 #define UVC_FRAME_MJPEG(n) \
550 #define DECLARE_UVC_FRAME_MJPEG(n) \
551 struct UVC_FRAME_MJPEG(n) { \
553 __u8 bDescriptorType; \
554 __u8 bDescriptorSubType; \
556 __u8 bmCapabilities; \
559 __u32 dwMinBitRate; \
560 __u32 dwMaxBitRate; \
561 __u32 dwMaxVideoFrameBufferSize; \
562 __u32 dwDefaultFrameInterval; \
563 __u8 bFrameIntervalType; \
564 __u32 dwFrameInterval[n]; \
565 } __attribute__ ((packed))
567 #endif /* __LINUX_USB_VIDEO_H */