1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef __LINUX_USB_VIDEO_H
15#define __LINUX_USB_VIDEO_H
16
17#include <linux/types.h>
18
19
20
21
22
23
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
28
29
30#define UVC_PC_PROTOCOL_UNDEFINED 0x00
31#define UVC_PC_PROTOCOL_15 0x01
32
33
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
41
42
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
57
58
59#define UVC_EP_UNDEFINED 0x00
60#define UVC_EP_GENERAL 0x01
61#define UVC_EP_ENDPOINT 0x02
62#define UVC_EP_INTERRUPT 0x03
63
64
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
74
75
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
79
80
81#define UVC_TE_CONTROL_UNDEFINED 0x00
82
83
84#define UVC_SU_CONTROL_UNDEFINED 0x00
85#define UVC_SU_INPUT_SELECT_CONTROL 0x01
86
87
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
106
107
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
127
128
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
139
140
141#define UVC_TT_VENDOR_SPECIFIC 0x0100
142#define UVC_TT_STREAMING 0x0101
143
144
145#define UVC_ITT_VENDOR_SPECIFIC 0x0200
146#define UVC_ITT_CAMERA 0x0201
147#define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
148
149
150#define UVC_OTT_VENDOR_SPECIFIC 0x0300
151#define UVC_OTT_DISPLAY 0x0301
152#define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
153
154
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
159
160
161#define UVC_STATUS_TYPE_CONTROL 1
162#define UVC_STATUS_TYPE_STREAMING 2
163
164
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)
173
174
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)
180
181
182
183
184
185
186struct uvc_descriptor_header {
187 __u8 bLength;
188 __u8 bDescriptorType;
189 __u8 bDescriptorSubType;
190} __attribute__((packed));
191
192
193struct uvc_header_descriptor {
194 __u8 bLength;
195 __u8 bDescriptorType;
196 __u8 bDescriptorSubType;
197 __u16 bcdUVC;
198 __u16 wTotalLength;
199 __u32 dwClockFrequency;
200 __u8 bInCollection;
201 __u8 baInterfaceNr[];
202} __attribute__((__packed__));
203
204#define UVC_DT_HEADER_SIZE(n) (12+(n))
205
206#define UVC_HEADER_DESCRIPTOR(n) \
207 uvc_header_descriptor_##n
208
209#define DECLARE_UVC_HEADER_DESCRIPTOR(n) \
210struct UVC_HEADER_DESCRIPTOR(n) { \
211 __u8 bLength; \
212 __u8 bDescriptorType; \
213 __u8 bDescriptorSubType; \
214 __u16 bcdUVC; \
215 __u16 wTotalLength; \
216 __u32 dwClockFrequency; \
217 __u8 bInCollection; \
218 __u8 baInterfaceNr[n]; \
219} __attribute__ ((packed))
220
221
222struct uvc_input_terminal_descriptor {
223 __u8 bLength;
224 __u8 bDescriptorType;
225 __u8 bDescriptorSubType;
226 __u8 bTerminalID;
227 __u16 wTerminalType;
228 __u8 bAssocTerminal;
229 __u8 iTerminal;
230} __attribute__((__packed__));
231
232#define UVC_DT_INPUT_TERMINAL_SIZE 8
233
234
235struct uvc_output_terminal_descriptor {
236 __u8 bLength;
237 __u8 bDescriptorType;
238 __u8 bDescriptorSubType;
239 __u8 bTerminalID;
240 __u16 wTerminalType;
241 __u8 bAssocTerminal;
242 __u8 bSourceID;
243 __u8 iTerminal;
244} __attribute__((__packed__));
245
246#define UVC_DT_OUTPUT_TERMINAL_SIZE 9
247
248
249struct uvc_camera_terminal_descriptor {
250 __u8 bLength;
251 __u8 bDescriptorType;
252 __u8 bDescriptorSubType;
253 __u8 bTerminalID;
254 __u16 wTerminalType;
255 __u8 bAssocTerminal;
256 __u8 iTerminal;
257 __u16 wObjectiveFocalLengthMin;
258 __u16 wObjectiveFocalLengthMax;
259 __u16 wOcularFocalLength;
260 __u8 bControlSize;
261 __u8 bmControls[3];
262} __attribute__((__packed__));
263
264#define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n))
265
266
267struct 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) \
280 uvc_selector_unit_descriptor_##n
281
282#define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
283struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \
284 __u8 bLength; \
285 __u8 bDescriptorType; \
286 __u8 bDescriptorSubType; \
287 __u8 bUnitID; \
288 __u8 bNrInPins; \
289 __u8 baSourceID[n]; \
290 __u8 iSelector; \
291} __attribute__ ((packed))
292
293
294struct uvc_processing_unit_descriptor {
295 __u8 bLength;
296 __u8 bDescriptorType;
297 __u8 bDescriptorSubType;
298 __u8 bUnitID;
299 __u8 bSourceID;
300 __u16 wMaxMultiplier;
301 __u8 bControlSize;
302 __u8 bmControls[2];
303 __u8 iProcessing;
304} __attribute__((__packed__));
305
306#define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n))
307
308
309struct 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) \
326 uvc_extension_unit_descriptor_##p_##n
327
328#define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
329struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \
330 __u8 bLength; \
331 __u8 bDescriptorType; \
332 __u8 bDescriptorSubType; \
333 __u8 bUnitID; \
334 __u8 guidExtensionCode[16]; \
335 __u8 bNumControls; \
336 __u8 bNrInPins; \
337 __u8 baSourceID[p]; \
338 __u8 bControlSize; \
339 __u8 bmControls[n]; \
340 __u8 iExtension; \
341} __attribute__ ((packed))
342
343
344struct uvc_control_endpoint_descriptor {
345 __u8 bLength;
346 __u8 bDescriptorType;
347 __u8 bDescriptorSubType;
348 __u16 wMaxTransferSize;
349} __attribute__((__packed__));
350
351#define UVC_DT_CONTROL_ENDPOINT_SIZE 5
352
353
354struct uvc_input_header_descriptor {
355 __u8 bLength;
356 __u8 bDescriptorType;
357 __u8 bDescriptorSubType;
358 __u8 bNumFormats;
359 __u16 wTotalLength;
360 __u8 bEndpointAddress;
361 __u8 bmInfo;
362 __u8 bTerminalLink;
363 __u8 bStillCaptureMethod;
364 __u8 bTriggerSupport;
365 __u8 bTriggerUsage;
366 __u8 bControlSize;
367 __u8 bmaControls[];
368} __attribute__((__packed__));
369
370#define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p))
371
372#define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
373 uvc_input_header_descriptor_##n_##p
374
375#define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
376struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \
377 __u8 bLength; \
378 __u8 bDescriptorType; \
379 __u8 bDescriptorSubType; \
380 __u8 bNumFormats; \
381 __u16 wTotalLength; \
382 __u8 bEndpointAddress; \
383 __u8 bmInfo; \
384 __u8 bTerminalLink; \
385 __u8 bStillCaptureMethod; \
386 __u8 bTriggerSupport; \
387 __u8 bTriggerUsage; \
388 __u8 bControlSize; \
389 __u8 bmaControls[p][n]; \
390} __attribute__ ((packed))
391
392
393struct uvc_output_header_descriptor {
394 __u8 bLength;
395 __u8 bDescriptorType;
396 __u8 bDescriptorSubType;
397 __u8 bNumFormats;
398 __u16 wTotalLength;
399 __u8 bEndpointAddress;
400 __u8 bTerminalLink;
401 __u8 bControlSize;
402 __u8 bmaControls[];
403} __attribute__((__packed__));
404
405#define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p))
406
407#define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
408 uvc_output_header_descriptor_##n_##p
409
410#define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
411struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \
412 __u8 bLength; \
413 __u8 bDescriptorType; \
414 __u8 bDescriptorSubType; \
415 __u8 bNumFormats; \
416 __u16 wTotalLength; \
417 __u8 bEndpointAddress; \
418 __u8 bTerminalLink; \
419 __u8 bControlSize; \
420 __u8 bmaControls[p][n]; \
421} __attribute__ ((packed))
422
423
424struct uvc_color_matching_descriptor {
425 __u8 bLength;
426 __u8 bDescriptorType;
427 __u8 bDescriptorSubType;
428 __u8 bColorPrimaries;
429 __u8 bTransferCharacteristics;
430 __u8 bMatrixCoefficients;
431} __attribute__((__packed__));
432
433#define UVC_DT_COLOR_MATCHING_SIZE 6
434
435
436struct uvc_streaming_control {
437 __u16 bmHint;
438 __u8 bFormatIndex;
439 __u8 bFrameIndex;
440 __u32 dwFrameInterval;
441 __u16 wKeyFrameRate;
442 __u16 wPFrameRate;
443 __u16 wCompQuality;
444 __u16 wCompWindowSize;
445 __u16 wDelay;
446 __u32 dwMaxVideoFrameSize;
447 __u32 dwMaxPayloadTransferSize;
448 __u32 dwClockFrequency;
449 __u8 bmFramingInfo;
450 __u8 bPreferedVersion;
451 __u8 bMinVersion;
452 __u8 bMaxVersion;
453} __attribute__((__packed__));
454
455
456struct uvc_format_uncompressed {
457 __u8 bLength;
458 __u8 bDescriptorType;
459 __u8 bDescriptorSubType;
460 __u8 bFormatIndex;
461 __u8 bNumFrameDescriptors;
462 __u8 guidFormat[16];
463 __u8 bBitsPerPixel;
464 __u8 bDefaultFrameIndex;
465 __u8 bAspectRatioX;
466 __u8 bAspectRatioY;
467 __u8 bmInterfaceFlags;
468 __u8 bCopyProtect;
469} __attribute__((__packed__));
470
471#define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
472
473
474struct uvc_frame_uncompressed {
475 __u8 bLength;
476 __u8 bDescriptorType;
477 __u8 bDescriptorSubType;
478 __u8 bFrameIndex;
479 __u8 bmCapabilities;
480 __u16 wWidth;
481 __u16 wHeight;
482 __u32 dwMinBitRate;
483 __u32 dwMaxBitRate;
484 __u32 dwMaxVideoFrameBufferSize;
485 __u32 dwDefaultFrameInterval;
486 __u8 bFrameIntervalType;
487 __u32 dwFrameInterval[];
488} __attribute__((__packed__));
489
490#define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n))
491
492#define UVC_FRAME_UNCOMPRESSED(n) \
493 uvc_frame_uncompressed_##n
494
495#define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \
496struct UVC_FRAME_UNCOMPRESSED(n) { \
497 __u8 bLength; \
498 __u8 bDescriptorType; \
499 __u8 bDescriptorSubType; \
500 __u8 bFrameIndex; \
501 __u8 bmCapabilities; \
502 __u16 wWidth; \
503 __u16 wHeight; \
504 __u32 dwMinBitRate; \
505 __u32 dwMaxBitRate; \
506 __u32 dwMaxVideoFrameBufferSize; \
507 __u32 dwDefaultFrameInterval; \
508 __u8 bFrameIntervalType; \
509 __u32 dwFrameInterval[n]; \
510} __attribute__ ((packed))
511
512
513struct uvc_format_mjpeg {
514 __u8 bLength;
515 __u8 bDescriptorType;
516 __u8 bDescriptorSubType;
517 __u8 bFormatIndex;
518 __u8 bNumFrameDescriptors;
519 __u8 bmFlags;
520 __u8 bDefaultFrameIndex;
521 __u8 bAspectRatioX;
522 __u8 bAspectRatioY;
523 __u8 bmInterfaceFlags;
524 __u8 bCopyProtect;
525} __attribute__((__packed__));
526
527#define UVC_DT_FORMAT_MJPEG_SIZE 11
528
529
530struct uvc_frame_mjpeg {
531 __u8 bLength;
532 __u8 bDescriptorType;
533 __u8 bDescriptorSubType;
534 __u8 bFrameIndex;
535 __u8 bmCapabilities;
536 __u16 wWidth;
537 __u16 wHeight;
538 __u32 dwMinBitRate;
539 __u32 dwMaxBitRate;
540 __u32 dwMaxVideoFrameBufferSize;
541 __u32 dwDefaultFrameInterval;
542 __u8 bFrameIntervalType;
543 __u32 dwFrameInterval[];
544} __attribute__((__packed__));
545
546#define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n))
547
548#define UVC_FRAME_MJPEG(n) \
549 uvc_frame_mjpeg_##n
550
551#define DECLARE_UVC_FRAME_MJPEG(n) \
552struct UVC_FRAME_MJPEG(n) { \
553 __u8 bLength; \
554 __u8 bDescriptorType; \
555 __u8 bDescriptorSubType; \
556 __u8 bFrameIndex; \
557 __u8 bmCapabilities; \
558 __u16 wWidth; \
559 __u16 wHeight; \
560 __u32 dwMinBitRate; \
561 __u32 dwMaxBitRate; \
562 __u32 dwMaxVideoFrameBufferSize; \
563 __u32 dwDefaultFrameInterval; \
564 __u8 bFrameIntervalType; \
565 __u32 dwFrameInterval[n]; \
566} __attribute__ ((packed))
567
568#endif
569
570