• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * USB Video Class definitions.
4  *
5  * Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be>
6  *
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
10  * available at
11  *
12  * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip
13  */
14 
15 #ifndef __LINUX_USB_VIDEO_H
16 #define __LINUX_USB_VIDEO_H
17 
18 #include <linux/types.h>
19 
20 /* --------------------------------------------------------------------------
21  * UVC constants
22  */
23 
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
29 
30 /* A.3. Video Interface Protocol Codes */
31 #define UVC_PC_PROTOCOL_UNDEFINED 0x00
32 #define UVC_PC_PROTOCOL_15 0x01
33 
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
42 
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
58 
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
64 
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
75 
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
80 
81 /* A.9.2. Terminal Control Selectors */
82 #define UVC_TE_CONTROL_UNDEFINED 0x00
83 
84 /* A.9.3. Selector Unit Control Selectors */
85 #define UVC_SU_CONTROL_UNDEFINED 0x00
86 #define UVC_SU_INPUT_SELECT_CONTROL 0x01
87 
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
107 
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
128 
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
140 
141 /* B.1. USB Terminal Types */
142 #define UVC_TT_VENDOR_SPECIFIC 0x0100
143 #define UVC_TT_STREAMING 0x0101
144 
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
149 
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
154 
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
160 
161 /* 2.4.2.2. Status Packet Type */
162 #define UVC_STATUS_TYPE_CONTROL 1
163 #define UVC_STATUS_TYPE_STREAMING 2
164 
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)
174 
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)
181 
182 /* ------------------------------------------------------------------------
183  * UVC structures
184  */
185 
186 /* All UVC descriptors have these 3 fields at the beginning */
187 struct uvc_descriptor_header {
188     __u8 bLength;
189     __u8 bDescriptorType;
190     __u8 bDescriptorSubType;
191 } __attribute__((packed));
192 
193 /* 3.7.2. Video Control Interface Header Descriptor */
194 struct uvc_header_descriptor {
195     __u8 bLength;
196     __u8 bDescriptorType;
197     __u8 bDescriptorSubType;
198     __le16 bcdUVC;
199     __le16 wTotalLength;
200     __le32 dwClockFrequency;
201     __u8 bInCollection;
202     __u8 baInterfaceNr[];
203 } __attribute__((__packed__));
204 
205 #define UVC_DT_HEADER_SIZE(n) (12 + (n))
206 
207 #define UVC_HEADER_DESCRIPTOR(n) uvc_header_descriptor_##n
208 
209 #define DECLARE_UVC_HEADER_DESCRIPTOR(n)                                                                               \
210     struct UVC_HEADER_DESCRIPTOR(n) {                                                                                  \
211         __u8 bLength;                                                                                                  \
212         __u8 bDescriptorType;                                                                                          \
213         __u8 bDescriptorSubType;                                                                                       \
214         __le16 bcdUVC;                                                                                                 \
215         __le16 wTotalLength;                                                                                           \
216         __le32 dwClockFrequency;                                                                                       \
217         __u8 bInCollection;                                                                                            \
218         __u8 baInterfaceNr[n];                                                                                         \
219     } __attribute__((packed))
220 
221 /* 3.7.2.1. Input Terminal Descriptor */
222 struct uvc_input_terminal_descriptor {
223     __u8 bLength;
224     __u8 bDescriptorType;
225     __u8 bDescriptorSubType;
226     __u8 bTerminalID;
227     __le16 wTerminalType;
228     __u8 bAssocTerminal;
229     __u8 iTerminal;
230 } __attribute__((__packed__));
231 
232 #define UVC_DT_INPUT_TERMINAL_SIZE 8
233 
234 /* 3.7.2.2. Output Terminal Descriptor */
235 struct uvc_output_terminal_descriptor {
236     __u8 bLength;
237     __u8 bDescriptorType;
238     __u8 bDescriptorSubType;
239     __u8 bTerminalID;
240     __le16 wTerminalType;
241     __u8 bAssocTerminal;
242     __u8 bSourceID;
243     __u8 iTerminal;
244 } __attribute__((__packed__));
245 
246 #define UVC_DT_OUTPUT_TERMINAL_SIZE 9
247 
248 /* 3.7.2.3. Camera Terminal Descriptor */
249 struct uvc_camera_terminal_descriptor {
250     __u8 bLength;
251     __u8 bDescriptorType;
252     __u8 bDescriptorSubType;
253     __u8 bTerminalID;
254     __le16 wTerminalType;
255     __u8 bAssocTerminal;
256     __u8 iTerminal;
257     __le16 wObjectiveFocalLengthMin;
258     __le16 wObjectiveFocalLengthMax;
259     __le16 wOcularFocalLength;
260     __u8 bControlSize;
261     __u8 bmControls[3];
262 } __attribute__((__packed__));
263 
264 #define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15 + (n))
265 
266 /* 3.7.2.4. Selector Unit Descriptor */
267 struct uvc_selector_unit_descriptor {
268     __u8 bLength;
269     __u8 bDescriptorType;
270     __u8 bDescriptorSubType;
271     __u8 bUnitID;
272     __u8 bNrInPins;
273     __u8 baSourceID[0];
274     __u8 iSelector;
275 } __attribute__((__packed__));
276 
277 #define UVC_DT_SELECTOR_UNIT_SIZE(n) (6 + (n))
278 
279 #define UVC_SELECTOR_UNIT_DESCRIPTOR(n) uvc_selector_unit_descriptor_##n
280 
281 #define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n)                                                                        \
282     struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) {                                                                           \
283         __u8 bLength;                                                                                                  \
284         __u8 bDescriptorType;                                                                                          \
285         __u8 bDescriptorSubType;                                                                                       \
286         __u8 bUnitID;                                                                                                  \
287         __u8 bNrInPins;                                                                                                \
288         __u8 baSourceID[n];                                                                                            \
289         __u8 iSelector;                                                                                                \
290     } __attribute__((packed))
291 
292 /* 3.7.2.5. Processing Unit Descriptor */
293 struct uvc_processing_unit_descriptor {
294     __u8 bLength;
295     __u8 bDescriptorType;
296     __u8 bDescriptorSubType;
297     __u8 bUnitID;
298     __u8 bSourceID;
299     __le16 wMaxMultiplier;
300     __u8 bControlSize;
301     __u8 bmControls[2];
302     __u8 iProcessing;
303     __u8 bmVideoStandards;
304 } __attribute__((__packed__));
305 
306 #define UVC_DT_PROCESSING_UNIT_SIZE(n) (10 + (n))
307 
308 /* 3.7.2.6. Extension Unit Descriptor */
309 struct uvc_extension_unit_descriptor {
310     __u8 bLength;
311     __u8 bDescriptorType;
312     __u8 bDescriptorSubType;
313     __u8 bUnitID;
314     __u8 guidExtensionCode[16];
315     __u8 bNumControls;
316     __u8 bNrInPins;
317     __u8 baSourceID[0];
318     __u8 bControlSize;
319     __u8 bmControls[0];
320     __u8 iExtension;
321 } __attribute__((__packed__));
322 
323 #define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24 + (p) + (n))
324 
325 #define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) uvc_extension_unit_descriptor_##p_##n
326 
327 #define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n)                                                                    \
328     struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) {                                                                       \
329         __u8 bLength;                                                                                                  \
330         __u8 bDescriptorType;                                                                                          \
331         __u8 bDescriptorSubType;                                                                                       \
332         __u8 bUnitID;                                                                                                  \
333         __u8 guidExtensionCode[16];                                                                                    \
334         __u8 bNumControls;                                                                                             \
335         __u8 bNrInPins;                                                                                                \
336         __u8 baSourceID[p];                                                                                            \
337         __u8 bControlSize;                                                                                             \
338         __u8 bmControls[n];                                                                                            \
339         __u8 iExtension;                                                                                               \
340     } __attribute__((packed))
341 
342 /* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */
343 struct uvc_control_endpoint_descriptor {
344     __u8 bLength;
345     __u8 bDescriptorType;
346     __u8 bDescriptorSubType;
347     __le16 wMaxTransferSize;
348 } __attribute__((__packed__));
349 
350 #define UVC_DT_CONTROL_ENDPOINT_SIZE 5
351 
352 /* 3.9.2.1. Input Header Descriptor */
353 struct uvc_input_header_descriptor {
354     __u8 bLength;
355     __u8 bDescriptorType;
356     __u8 bDescriptorSubType;
357     __u8 bNumFormats;
358     __le16 wTotalLength;
359     __u8 bEndpointAddress;
360     __u8 bmInfo;
361     __u8 bTerminalLink;
362     __u8 bStillCaptureMethod;
363     __u8 bTriggerSupport;
364     __u8 bTriggerUsage;
365     __u8 bControlSize;
366     __u8 bmaControls[];
367 } __attribute__((__packed__));
368 
369 #define UVC_DT_INPUT_HEADER_SIZE(n, p) (13 + ((n) * (p)))
370 
371 #define UVC_INPUT_HEADER_DESCRIPTOR(n, p) uvc_input_header_descriptor_##n_##p
372 
373 #define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p)                                                                      \
374     struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) {                                                                         \
375         __u8 bLength;                                                                                                  \
376         __u8 bDescriptorType;                                                                                          \
377         __u8 bDescriptorSubType;                                                                                       \
378         __u8 bNumFormats;                                                                                              \
379         __le16 wTotalLength;                                                                                           \
380         __u8 bEndpointAddress;                                                                                         \
381         __u8 bmInfo;                                                                                                   \
382         __u8 bTerminalLink;                                                                                            \
383         __u8 bStillCaptureMethod;                                                                                      \
384         __u8 bTriggerSupport;                                                                                          \
385         __u8 bTriggerUsage;                                                                                            \
386         __u8 bControlSize;                                                                                             \
387         __u8 bmaControls[p][n];                                                                                        \
388     } __attribute__((packed))
389 
390 /* 3.9.2.2. Output Header Descriptor */
391 struct uvc_output_header_descriptor {
392     __u8 bLength;
393     __u8 bDescriptorType;
394     __u8 bDescriptorSubType;
395     __u8 bNumFormats;
396     __le16 wTotalLength;
397     __u8 bEndpointAddress;
398     __u8 bTerminalLink;
399     __u8 bControlSize;
400     __u8 bmaControls[];
401 } __attribute__((__packed__));
402 
403 #define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9 + ((n) * (p)))
404 
405 #define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) uvc_output_header_descriptor_##n_##p
406 
407 #define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p)                                                                     \
408     struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) {                                                                        \
409         __u8 bLength;                                                                                                  \
410         __u8 bDescriptorType;                                                                                          \
411         __u8 bDescriptorSubType;                                                                                       \
412         __u8 bNumFormats;                                                                                              \
413         __le16 wTotalLength;                                                                                           \
414         __u8 bEndpointAddress;                                                                                         \
415         __u8 bTerminalLink;                                                                                            \
416         __u8 bControlSize;                                                                                             \
417         __u8 bmaControls[p][n];                                                                                        \
418     } __attribute__((packed))
419 
420 /* 3.9.2.6. Color matching descriptor */
421 struct uvc_color_matching_descriptor {
422     __u8 bLength;
423     __u8 bDescriptorType;
424     __u8 bDescriptorSubType;
425     __u8 bColorPrimaries;
426     __u8 bTransferCharacteristics;
427     __u8 bMatrixCoefficients;
428 } __attribute__((__packed__));
429 
430 #define UVC_DT_COLOR_MATCHING_SIZE 6
431 
432 /* 4.3.1.1. Video Probe and Commit Controls */
433 struct uvc_streaming_control {
434     __u16 bmHint;
435     __u8 bFormatIndex;
436     __u8 bFrameIndex;
437     __u32 dwFrameInterval;
438     __u16 wKeyFrameRate;
439     __u16 wPFrameRate;
440     __u16 wCompQuality;
441     __u16 wCompWindowSize;
442     __u16 wDelay;
443     __u32 dwMaxVideoFrameSize;
444     __u32 dwMaxPayloadTransferSize;
445     __u32 dwClockFrequency;
446     __u8 bmFramingInfo;
447     __u8 bPreferedVersion;
448     __u8 bMinVersion;
449     __u8 bMaxVersion;
450 } __attribute__((__packed__));
451 
452 /* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */
453 struct uvc_format_uncompressed {
454     __u8 bLength;
455     __u8 bDescriptorType;
456     __u8 bDescriptorSubType;
457     __u8 bFormatIndex;
458     __u8 bNumFrameDescriptors;
459     __u8 guidFormat[16];
460     __u8 bBitsPerPixel;
461     __u8 bDefaultFrameIndex;
462     __u8 bAspectRatioX;
463     __u8 bAspectRatioY;
464     __u8 bmInterfaceFlags;
465     __u8 bCopyProtect;
466 } __attribute__((__packed__));
467 
468 #define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
469 
470 /* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */
471 struct uvc_frame_uncompressed {
472     __u8 bLength;
473     __u8 bDescriptorType;
474     __u8 bDescriptorSubType;
475     __u8 bFrameIndex;
476     __u8 bmCapabilities;
477     __le16 wWidth;
478     __le16 wHeight;
479     __le32 dwMinBitRate;
480     __le32 dwMaxBitRate;
481     __le32 dwMaxVideoFrameBufferSize;
482     __le32 dwDefaultFrameInterval;
483     __u8 bFrameIntervalType;
484     __le32 dwFrameInterval[];
485 } __attribute__((__packed__));
486 
487 #define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26 + 4 * (n))
488 
489 #define UVC_FRAME_UNCOMPRESSED(n) uvc_frame_uncompressed_##n
490 
491 #define DECLARE_UVC_FRAME_UNCOMPRESSED(n)                                                                              \
492     struct UVC_FRAME_UNCOMPRESSED(n) {                                                                                 \
493         __u8 bLength;                                                                                                  \
494         __u8 bDescriptorType;                                                                                          \
495         __u8 bDescriptorSubType;                                                                                       \
496         __u8 bFrameIndex;                                                                                              \
497         __u8 bmCapabilities;                                                                                           \
498         __le16 wWidth;                                                                                                 \
499         __le16 wHeight;                                                                                                \
500         __le32 dwMinBitRate;                                                                                           \
501         __le32 dwMaxBitRate;                                                                                           \
502         __le32 dwMaxVideoFrameBufferSize;                                                                              \
503         __le32 dwDefaultFrameInterval;                                                                                 \
504         __u8 bFrameIntervalType;                                                                                       \
505         __le32 dwFrameInterval[n];                                                                                     \
506     } __attribute__((packed))
507 
508 /* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */
509 struct uvc_format_mjpeg {
510     __u8 bLength;
511     __u8 bDescriptorType;
512     __u8 bDescriptorSubType;
513     __u8 bFormatIndex;
514     __u8 bNumFrameDescriptors;
515     __u8 bmFlags;
516     __u8 bDefaultFrameIndex;
517     __u8 bAspectRatioX;
518     __u8 bAspectRatioY;
519     __u8 bmInterfaceFlags;
520     __u8 bCopyProtect;
521 } __attribute__((__packed__));
522 
523 #define UVC_DT_FORMAT_MJPEG_SIZE 11
524 
525 /* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */
526 struct uvc_frame_mjpeg {
527     __u8 bLength;
528     __u8 bDescriptorType;
529     __u8 bDescriptorSubType;
530     __u8 bFrameIndex;
531     __u8 bmCapabilities;
532     __le16 wWidth;
533     __le16 wHeight;
534     __le32 dwMinBitRate;
535     __le32 dwMaxBitRate;
536     __le32 dwMaxVideoFrameBufferSize;
537     __le32 dwDefaultFrameInterval;
538     __u8 bFrameIntervalType;
539     __le32 dwFrameInterval[];
540 } __attribute__((__packed__));
541 
542 #define UVC_DT_FRAME_MJPEG_SIZE(n) (26 + 4 * (n))
543 
544 #define UVC_FRAME_MJPEG(n) uvc_frame_mjpeg_##n
545 
546 #define DECLARE_UVC_FRAME_MJPEG(n)                                                                                     \
547     struct UVC_FRAME_MJPEG(n) {                                                                                        \
548         __u8 bLength;                                                                                                  \
549         __u8 bDescriptorType;                                                                                          \
550         __u8 bDescriptorSubType;                                                                                       \
551         __u8 bFrameIndex;                                                                                              \
552         __u8 bmCapabilities;                                                                                           \
553         __le16 wWidth;                                                                                                 \
554         __le16 wHeight;                                                                                                \
555         __le32 dwMinBitRate;                                                                                           \
556         __le32 dwMaxBitRate;                                                                                           \
557         __le32 dwMaxVideoFrameBufferSize;                                                                              \
558         __le32 dwDefaultFrameInterval;                                                                                 \
559         __u8 bFrameIntervalType;                                                                                       \
560         __le32 dwFrameInterval[n];                                                                                     \
561     } __attribute__((packed))
562 
563 /* Frame Based Payload - 3.1.1. Frame Based Video Format Descriptor */
564 struct uvc_format_framebased {
565     __u8 bLength;
566     __u8 bDescriptorType;
567     __u8 bDescriptorSubType;
568     __u8 bFormatIndex;
569     __u8 bNumFrameDescriptors;
570     __u8 guidFormat[16];
571     __u8 bBitsPerPixel;
572     __u8 bDefaultFrameIndex;
573     __u8 bAspectRatioX;
574     __u8 bAspectRatioY;
575     __u8 bmInterfaceFlags;
576     __u8 bCopyProtect;
577     __u8 bVariableSize;
578 } __attribute__((__packed__));
579 
580 #define UVC_DT_FORMAT_FRAMEBASED_SIZE 28
581 
582 /* Frame Based Payload - 3.1.2. Frame Based Video Frame Descriptor */
583 struct uvc_frame_framebased {
584     __u8 bLength;
585     __u8 bDescriptorType;
586     __u8 bDescriptorSubType;
587     __u8 bFrameIndex;
588     __u8 bmCapabilities;
589     __u16 wWidth;
590     __u16 wHeight;
591     __u32 dwMinBitRate;
592     __u32 dwMaxBitRate;
593     __u32 dwDefaultFrameInterval;
594     __u8 bFrameIntervalType;
595     __u32 dwBytesPerLine;
596     __u32 dwFrameInterval[];
597 } __attribute__((__packed__));
598 
599 #define UVC_DT_FRAME_FRAMEBASED_SIZE(n) (26 + 4 * (n))
600 
601 #define UVC_FRAME_FRAMEBASED(n) uvc_frame_framebased_##n
602 
603 #define DECLARE_UVC_FRAME_FRAMEBASED(n)                                                                                \
604     struct UVC_FRAME_FRAMEBASED(n) {                                                                                   \
605         __u8 bLength;                                                                                                  \
606         __u8 bDescriptorType;                                                                                          \
607         __u8 bDescriptorSubType;                                                                                       \
608         __u8 bFrameIndex;                                                                                              \
609         __u8 bmCapabilities;                                                                                           \
610         __u16 wWidth;                                                                                                  \
611         __u16 wHeight;                                                                                                 \
612         __u32 dwMinBitRate;                                                                                            \
613         __u32 dwMaxBitRate;                                                                                            \
614         __u32 dwDefaultFrameInterval;                                                                                  \
615         __u8 bFrameIntervalType;                                                                                       \
616         __u32 dwBytesPerLine;                                                                                          \
617         __u32 dwFrameInterval[n];                                                                                      \
618     } __attribute__((packed))
619 
620 #endif /* __LINUX_USB_VIDEO_H */
621