Ticket #5940: USB_video.2.h

File USB_video.2.h, 21.7 KB (added by iambrj, 2 years ago)

merged enums and typedefs from both the USB_video.h

Line 
1/*
2 * Copyright 2016, Adrien Destugues, pulkomandy@pulkomandy.tk
3 * Distributed under terms of the MIT license.
4 */
5
6
7#ifndef USB_VIDEO_H
8#define USB_VIDEO_H
9
10
11// Based on specification for UVC version 1.5.
12
13
14#include <BeBuild.h> // for _PACKED definition
15#include <lendian_bitfield.h>
16#include <SupportDefs.h>
17
18
19#define USB_VIDEO_DEVICE_CLASS 0x0E
20
21enum { // Video Interface Subclasses
22 USB_VIDEO_INTERFACE_UNDEFINED_SUBCLASS = 0x00,
23 USB_VIDEO_INTERFACE_VIDEOCONTROL_SUBCLASS = 0x01,
24 USB_VIDEO_INTERFACE_VIDEOSTREAMING_SUBCLASS = 0x02,
25 USB_VIDEO_INTERFACE_COLLECTION_SUBCLASS = 0x03,
26};
27
28enum { // Video Interface Class Code
29 USB_VIDEO_INTERFACE_VIDEO_CLASS = 0x0e
30};
31
32enum { // Video Interface Protocol Codes
33 USB_VIDEO_PROTOCOL_UNDEFINED = 0x00,
34 USB_VIDEO_PROTOCOL_15 = 0x01,
35};
36
37
38enum { // Video Interface Class-Specific Descriptor Types
39 USB_VIDEO_CS_UNDEFINED = 0x20,
40 USB_VIDEO_CS_DEVICE = 0x21,
41 USB_VIDEO_CS_CONFIGURATION = 0x22,
42 USB_VIDEO_CS_STRING = 0x23,
43 USB_VIDEO_CS_INTERFACE = 0x24,
44 USB_VIDEO_CS_ENDPOINT = 0x25,
45};
46
47
48enum { // Video Class-Specific VideoControl Interface descriptor subtypes
49 USB_VIDEO_VC_DESCRIPTOR_UNDEFINED = 0x00,
50 USB_VIDEO_VC_HEADER = 0x01,
51 USB_VIDEO_VC_INPUT_TERMINAL = 0x02,
52 USB_VIDEO_VC_OUTPUT_TERMINAL = 0x03,
53 USB_VIDEO_VC_SELECTOR_UNIT = 0x04,
54 USB_VIDEO_VC_PROCESSING_UNIT = 0x05,
55 USB_VIDEO_VC_EXTENSION_UNIT = 0x06,
56 USB_VIDEO_VC_ENCODING_UNIT = 0x07,
57};
58
59
60enum { // Video Class-Specific VideoStreaming Interface descriptor subtypes
61 USB_VIDEO_VS_UNDEFINED = 0x00,
62 USB_VIDEO_VS_INPUT_HEADER = 0x01,
63 USB_VIDEO_VS_OUTPUT_HEADER = 0x02,
64 USB_VIDEO_VS_STILL_IMAGE_FRAME = 0x03,
65 USB_VIDEO_VS_FORMAT_UNCOMPRESSED = 0x04,
66 USB_VIDEO_VS_FRAME_UNCOMPRESSED = 0x05,
67 USB_VIDEO_VS_FORMAT_MJPEG = 0x06,
68 USB_VIDEO_VS_FRAME_MJPEG = 0x07,
69 USB_VIDEO_VS_FORMAT_MPEG2TS = 0x0a,
70 USB_VIDEO_VS_FORMAT_DV = 0x0c,
71 USB_VIDEO_VS_COLORFORMAT = 0x0d,
72 USB_VIDEO_VS_FORMAT_FRAME_BASED = 0x10,
73 USB_VIDEO_VS_FRAME_FRAME_BASED = 0x11,
74 USB_VIDEO_VS_FORMAT_STREAM_BASED = 0x12,
75 USB_VIDEO_VS_FORMAT_H264 = 0x13,
76 USB_VIDEO_VS_FRAME_H264 = 0x14,
77 USB_VIDEO_VS_FORMAT_H264_SIMULCAST = 0x15,
78 USB_VIDEO_VS_FORMAT_VP8 = 0x16,
79 USB_VIDEO_VS_FRAME_VP8 = 0x17,
80 USB_VIDEO_VS_FORMAT_VP8_SIMULCAST = 0x18,
81};
82
83
84enum { // Video Streaming Interface Control Selectors
85 USB_VIDEO_VS_CONTROL_UNDEFINED = 0x00,
86 USB_VIDEO_VS_PROBE_CONTROL = 0x01,
87 USB_VIDEO_VS_COMMIT_CONTROL = 0x02,
88 USB_VIDEO_VS_STILL_PROBE_CONTROL = 0x03,
89 USB_VIDEO_VS_STILL_COMMIT_CONTROL = 0x04,
90 USB_VIDEO_VS_STILL_IMAGE_TRIGGER_CONTROL = 0x05,
91 USB_VIDEO_VS_STREAM_ERROR_CODE_CONTROL = 0x06,
92 USB_VIDEO_VS_GENERATE_KEY_FRAME_CONTROL = 0x07,
93 USB_VIDEO_VS_UPDATE_FRAME_SEGMENT_CONTROL = 0x08,
94 USB_VIDEO_VS_SYNCH_DELAY_CONTROL = 0x09
95};
96
97enum {
98 // USB Terminal Types
99 USB_VIDEO_VENDOR_USB_IO = 0x100,
100 USB_VIDEO_STREAMING_USB_IO = 0x101,
101 // Input terminal types
102 USB_VIDEO_VENDOR_IN = 0x200,
103 USB_VIDEO_CAMERA_IN = 0x201,
104 USB_VIDEO_MEDIA_TRANSPORT_IN = 0x202,
105 // Output terminal types
106 USB_VIDEO_VENDOR_OUT = 0x300,
107 USB_VIDEO_DISPLAY_OUT = 0x301,
108 USB_VIDEO_MEDIA_TRANSPORT_OUT = 0x302,
109 // External terminal types
110 USB_VIDEO_VENDOR_EXT = 0x400,
111 USB_VIDEO_COMPOSITE_EXT = 0x401,
112 USB_VIDEO_SVIDEO_EXT = 0x402,
113 USB_VIDEO_COMPONENT_EXT = 0x403,
114};
115
116
117enum { // Video Class-Specific Endpoint Descriptor Subtypes
118 EP_SUBTYPE_UNDEFINED = 0x00,
119 EP_SUBTYPE_GENERAL = 0x01,
120 EP_SUBTYPE_ENDPOINT = 0x02,
121 EP_SUBTYPE_INTERRUPT = 0x03,
122};
123
124enum { // Terminal Control Selectors
125 USB_VIDEO_TE_CONTROL_UNDEFINED = 0x00
126};
127
128enum { // Selector Unit Control Selectors
129 USB_VIDEO_SU_CONTROL_UNDEFINED = 0x00,
130 USB_VIDEO_SU_INPUT_SELECT_CONTROL = 0x01
131};
132
133enum { // Video Class-Specific Request Codes
134 USB_VIDEO_RC_UNDEFINED = 0x00,
135 USB_VIDEO_SET_CUR = 0x01,
136 USB_VIDEO_GET_CUR = 0x81,
137 USB_VIDEO_GET_MIN = 0x82,
138 USB_VIDEO_GET_MAX = 0x83,
139 USB_VIDEO_GET_RES = 0x84,
140 USB_VIDEO_GET_LEN = 0x85,
141 USB_VIDEO_GET_INFO = 0x86,
142 USB_VIDEO_GET_DEF = 0x87
143};
144
145enum { // Camera Terminal Control Selectors
146 USB_VIDEO_CT_CONTROL_UNDEFINED = 0x00,
147 USB_VIDEO_CT_SCANNING_MODE_CONTROL = 0x01,
148 USB_VIDEO_CT_AE_MODE_CONTROL = 0x02,
149 USB_VIDEO_CT_AE_PRIORITY_CONTROL = 0x03,
150 USB_VIDEO_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL = 0x04,
151 USB_VIDEO_CT_EXPOSURE_TIME_RELATIVE_CONTROL = 0x05,
152 USB_VIDEO_CT_FOCUS_ABSOLUTE_CONTROL = 0x06,
153 USB_VIDEO_CT_FOCUS_RELATIVE_CONTROL = 0x07,
154 USB_VIDEO_CT_FOCUS_AUTO_CONTROL = 0x08,
155 USB_VIDEO_CT_IRIS_ABSOLUTE_CONTROL = 0x09,
156 USB_VIDEO_CT_IRIS_RELATIVE_CONTROL = 0x0A,
157 USB_VIDEO_CT_ZOOM_ABSOLUTE_CONTROL = 0x0B,
158 USB_VIDEO_CT_ZOOM_RELATIVE_CONTROL = 0x0C,
159 USB_VIDEO_CT_PANTILT_ABSOLUTE_CONTROL = 0x0D,
160 USB_VIDEO_CT_PANTILT_RELATIVE_CONTROL = 0x0E,
161 USB_VIDEO_CT_ROLL_ABSOLUTE_CONTROL = 0x0F,
162 USB_VIDEO_CT_ROLL_RELATIVE_CONTROL = 0x10,
163 USB_VIDEO_CT_PRIVACY_CONTROL = 0x11
164};
165
166enum { // Processing Unit Control Selectors
167 USB_VIDEO_PU_CONTROL_UNDEFINED = 0x00,
168 USB_VIDEO_PU_BACKLIGHT_COMPENSATION_CONTROL = 0x01,
169 USB_VIDEO_PU_BRIGHTNESS_CONTROL = 0x02,
170 USB_VIDEO_PU_CONTRAST_CONTROL = 0x03,
171 USB_VIDEO_PU_GAIN_CONTROL = 0x04,
172 USB_VIDEO_PU_POWER_LINE_FREQUENCY_CONTROL = 0x05,
173 USB_VIDEO_PU_HUE_CONTROL = 0x06,
174 USB_VIDEO_PU_SATURATION_CONTROL = 0x07,
175 USB_VIDEO_PU_SHARPNESS_CONTROL = 0x08,
176 USB_VIDEO_PU_GAMMA_CONTROL = 0x09,
177 USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL = 0x0A,
178 USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL = 0x0B,
179 USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_COMPONENT_CONTROL = 0x0C,
180 USB_VIDEO_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL = 0x0D,
181 USB_VIDEO_PU_DIGITAL_MULTIPLEXER_CONTROL = 0x0E,
182 USB_VIDEO_PU_DIGITAL_MULTIPLEXER_LIMIT_CONTROL = 0x0F,
183 USB_VIDEO_PU_HUE_AUTO_CONTROL = 0x10,
184 USB_VIDEO_PU_ANALOG_VIDEO_STANDARD_CONTROL = 0x11,
185 USB_VIDEO_PU_ANALOG_LOCK_STATUS_CONTROL = 0x12
186};
187
188
189enum { // Extension Unit Control Selectors
190 USB_VIDEO_XU_CONTROL_UNDEFINED = 0x00
191};
192
193/*!
194 Struct status_packet_format includes two common fields and other fields
195 that depend on the type of the originator field of the first status_type
196 struct. The orignator bitfield of the status_type struct can have the
197 following values: 0 = reserved, 1 = VideoControl interface,
198 2 = VideoStreaming interface. The second common status_packet_format field
199 orignator includes ID of the Terminal, Unit or Interface that reports the
200 interrupt.
201 If the orginator bitfield value is 1 (VideoControl interface) then third
202 field of the status_packet_format is event field that includes value 0x00
203 for control change. Other values (0x01 - 0xFF) are reserved.
204 The fourth field selector reports the Control Selector of the control that
205 have issued the interrupt.
206 The fifth field attribute specifies the type of control change: 0x00 is
207 Control value change, 0x01 is Control info change, 0x02 is Control failure
208 change and values 0x03 - 0xFF are reserved.
209 After that can be several value fields that can include values 0x00, 0x01
210 and 0x02.
211 If the originator bitfield value is 2 (VideoStreaming interface) then
212 third field of the status_packet_format is event field that can have
213 value 0x00 (Button Press) or values 0x01 - 0xFF (Stream errors).
214 If event value is 0x00 (Button Press) there is only one value field. It
215 can include values 0x00 (Button released) or 0x01 (Button pressed). If
216 event value was some Stream error value, then there can be several value
217 fields.
218*/
219typedef struct status_packet_format {
220 struct status_type {
221 LBITFIELD8_2 (
222 originator: 4,
223 reserved: 4
224 );
225 } _status_type;
226 uint8 originator;
227 union {
228 struct videocontrol_interface_as_orignator {
229 uint8 event;
230 uint8 selector;
231 uint8 attribute;
232 uint8* value;
233 } _videocontrol_interface_as_orignator;
234 struct videostreaming_interface_as_originator {
235 uint8 event;
236 uint8* value;
237 } _videostreaming_interface_as_originator;
238 } originators;
239} _PACKED usb_video_status_packet_format;
240
241typedef struct std_vc_interface_descriptor {
242 uint8 length; // 9 bytes
243 uint8 descriptor_type;
244 uint8 interface_number;
245 uint8 alternate_setting;
246 uint8 num_endpoints;
247 uint8 interface_class;
248 uint8 interface_sub_class;
249 // Not used. Must be set to USB_VIDEO_PC_PROTOCOL_UNDEFINED
250 uint8 interface_protocol;
251 uint8 interface;
252} _PACKED usb_video_standard_vc_interface_descriptor;
253
254typedef struct std_video_interface_collection_iad {
255 uint8 length; // 8 bytes
256 uint8 descriptor_type;
257 uint8 first_interface;
258 uint8 interface_count;
259 uint8 function_class;
260 uint8 function_sub_class;
261 // Not used. Must be set to USB_VIDEO_PC_PROTOCOL_UNDEFINED
262 uint8 function_protocol;
263 uint8 function;
264} _PACKED usb_video_standard_video_interface_collection_iad;
265
266typedef struct selector_unit_descriptor {
267 uint8 length; // 6 bytes + nr_in_pins
268 uint8 descriptor_type;
269 uint8 descriptor_sub_type;
270 uint8 unit_id;
271 uint8 nr_in_pins;
272 uint8* source_id;
273 uint8 selector;
274} _PACKED usb_video_selector_unit_descriptor;
275
276typedef struct payload_header_format {
277 uint8 header_length;
278 struct header_info {
279 LBITFIELD8_8 (
280 frame_id: 1,
281 end_of_frame: 1,
282 presentation_time: 1,
283 source_clock_reference: 1,
284 reserved: 1,
285 still_image: 1,
286 error: 1,
287 end_of_header: 1
288 );
289 } _header_info;
290} _PACKED usb_video_payload_header_format;
291
292
293struct payload_header_format_extended_fields {
294 uint32 presentation_time;
295 uint8 source_clock[6];
296} _PACKED usb_video_payload_header_format_extended_fields;
297
298typedef struct {
299 uint8 length;
300 uint8 descriptor_type; // USB_AUDIO_CS_INTERFACE
301 uint8 descriptor_subtype; // USB_AUDIO_AC_HEADER
302 uint16 bcd_release_no;
303 uint16 total_length;
304 uint32 clock_frequency;
305 uint8 in_collection;
306 uint8 interface_numbers[0];
307} _PACKED usb_videocontrol_header_descriptor;
308
309typedef struct extension_unit_descriptor {
310 uint8 length; // 24 bytes + nr_in_pins + control_size
311 uint8 descriptor_type;
312 uint8 descriptor_sub_type;
313 uint8 unit_id;
314 uint8 guid_extension_code[16];
315 uint8 num_controls;
316 uint8 nr_in_pins;
317 uint8* source_id;
318 uint8 control_size;
319 struct controls {
320 LBITFIELD8_8 (
321 vendor_specific0 : 1,
322 vendor_specific1 : 1,
323 vendor_specific2 : 1,
324 vendor_specific3 : 1,
325 vendor_specific4 : 1,
326 vendor_specific5 : 1,
327 vendor_specific6 : 1,
328 vendor_specific7 : 1
329 );
330 } * _controls;
331 uint8 extension;
332} _PACKED usb_video_extension_unit_descriptor;
333
334typedef struct std_vc_interrupt_endpoint_descriptor {
335 uint8 length; // 7 bytes
336 uint8 descriptor_type;
337 struct end_point_address {
338 LBITFIELD8_3 (
339 endpoint_number: 4, // Determined by the designer
340 reserved: 3, // Reserved. Set to zero.
341 direction: 1 // 0 = OUT, 1 = IN
342 );
343 } _end_point_address;
344 struct attributes {
345 LBITFIELD8_3 (
346 transfer_type: 2, // Must be set to 11 (Interrupt)
347 synchronization_type: 2, // Must be set to 00 (None)
348 reserved: 4 // Reserved. Must be set to zero
349 );
350 } _attributes;
351 uint16 max_packet_size;
352 uint8 interval;
353} _PACKED usb_video_vc_interrupt_endpoint_descriptor;
354
355typedef struct std_vs_interface_descriptor {
356 uint8 length; // 9 bytes
357 uint8 descriptor_type;
358 uint8 interface_number;
359 uint8 alternate_setting;
360 uint8 num_endpoints;
361 uint8 interface_class;
362 uint8 interface_sub_class;
363 // Not used. Must be set to USB_VIDEO_PC_PROTOCOL_UNDEFINED
364 uint8 interface_protocol;
365 uint8 interface;
366} _PACKED usb_video_standard_vs_interface_descriptor;
367typedef struct class_specific_vc_interrupt_endpoint_descriptor {
368 uint8 length; // 5 bytes
369 uint8 descriptor_type;
370 uint8 descriptor_sub_type;
371 uint16 max_transfer_size;
372} _PACKED usb_video_class_specific_vc_interrupt_endpoint_descriptor;
373
374// Input Terminal Descriptor
375// 1.5: Table 3-4, page 50
376typedef struct {
377 uint8 length;
378 uint8 descriptor_type; // USB_VIDEO_CS_INTERFACE
379 uint8 descriptor_subtype; // USB_VIDEO_VC_INPUT_TERMINAL
380 uint8 terminal_id;
381 uint16 terminal_type;
382 uint8 assoc_terminal;
383 uint8 terminal;
384
385 union {
386 struct {
387 uint16 focal_length_min;
388 uint16 focal_length_max;
389 uint16 focal_length;
390 uint8 control_size;
391 uint8 controls[3];
392 } _PACKED camera;
393 };
394} _PACKED usb_video_input_terminal_descriptor;
395
396typedef struct class_specific_vs_interface_input_header_descriptor {
397 uint8 length; // 13 bytes + (num_formats*control_size)
398 uint8 descriptor_type;
399 uint8 descriptor_sub_type;
400 uint8 num_formats;
401 uint16 total_length;
402 struct endpoint_address {
403 LBITFIELD8_3 (
404 endpoint_number: 4, // Determined by the designer
405 reserved: 3, // Set to zero.
406 direction: 1 // 0 = OUT, 1 = IN
407 );
408 } _endpoint_address;
409 struct info {
410 LBITFIELD8_2 (
411 dynamic_format_change_support: 1,
412 reserved: 7 // Set to zero.
413 );
414 } _info;
415 uint8 terminal_link;
416 uint8 still_capture_method;
417 uint8 trigger_support;
418 uint8 trigger_usage;
419 uint8 control_size;
420 struct ma_controls {
421 // For four first bits, a bit set to 1 indicates that the named field
422 // is supported by the Video Probe and Commit Control when
423 // its format_index is 1:
424 LBITFIELD8_7 (
425 key_frame_rate: 1,
426 p_frame_rate: 1,
427 comp_quality: 1,
428 comp_window_size: 1,
429 // For the next two bits, a bit set to 1 indicates that the named
430 // control is supported by the device when
431 // format_index is 1:
432 generate_key_frame: 1,
433 update_frame_segment: 1,
434 reserved: 2 // (control_size*8-1): Set to zero.
435 );
436 } * _ma_controls;
437} _PACKED usb_video_class_specific_vs_interface_input_header_descriptor;
438
439// Output terminal descriptor
440// 1.5: Table 3-5, page 51
441typedef struct {
442 uint8 length;
443 uint8 descriptor_type; // USB_VIDEO_CS_INTERFACE
444 uint8 descriptor_subtype; // USB_VIDEO_VC_OUTPUT_TERMINAL
445 uint8 terminal_id;
446 uint16 terminal_type;
447 uint8 assoc_terminal;
448 uint8 source_id;
449 uint8 terminal;
450} _PACKED usb_video_output_terminal_descriptor;
451
452typedef struct class_specific_vs_interface_output_header_descriptor {
453 uint8 length; // 9 + (num_formats*control_size)
454 uint8 descriptor_type;
455 uint8 descriptor_sub_type;
456 uint8 num_formats;
457 uint16 total_length;
458 struct endpoint_address {
459 LBITFIELD8_3 (
460 endpoint_number: 4, // Determined by the designer
461 reserved: 3, // Set to zero.
462 direction: 1 // 0 = OUT
463 );
464 } _endpoint_address;
465 uint8 terminal_link;
466 uint8 control_size;
467 struct ma_controls {
468 // For four first bits, a bit set to 1 indicates that the named field
469 // is supported by the Video Probe and Commit Control when its
470 // format_index is 1:
471 LBITFIELD8_5 (
472 key_frame_rate: 1,
473 p_frame_rate: 1,
474 comp_quality: 1,
475 comp_window_size: 1,
476 reserved: 4 // (control_size*8-1) Set to zero.
477 );
478 } * _ma_controls;
479} _PACKED usb_video_class_specific_vs_interface_output_header_descriptor;
480
481
482// Processing unit descriptor
483// 1.5: Table 3-8, page 54
484typedef struct {
485 uint8 length;
486 uint8 descriptor_type;
487 uint8 descriptor_subtype;
488 uint8 unit_id;
489 uint8 source_id;
490 uint16 max_multiplier;
491 uint8 control_size;
492 uint8 controls[3];
493 uint8 processing;
494 uint8 video_standards;
495#if B_HOST_IS_LENDIAN
496 struct controls {
497 struct control_a {
498 LBITFIELD16 (
499 brightness: 1,
500 contrast: 1,
501 hue: 1,
502 saturation: 1,
503 sharpness: 1,
504 gamma: 1,
505 white_balance_temperature: 1,
506 white_balance_component: 1,
507 backlight_compensation: 1,
508 gain: 1,
509 power_line_frequency: 1,
510 hue_auto: 1,
511 white_balance_temperature_auto: 1,
512 white_balance_component_auto: 1,
513 digital_multiplier: 1,
514 digital_multiplier_limit: 1
515 );
516 } _control_a;
517 struct control_b {
518 LBITFIELD3 (
519 analog_video_standard: 1,
520 analog_video_lock_status: 1,
521 reserved: 14 // Reserved. Se to zero.
522 );
523 } _control_b;
524 } _controls;
525#else
526 struct controls {
527 struct control_b {
528 LBITFIELD3 (
529 analog_video_standard: 1,
530 analog_video_lock_status: 1,
531 reserved: 14 // Reserved. Se to zero.
532 );
533 } _control_b;
534 struct control_a {
535 LBITFIELD16 (
536 brightness: 1,
537 contrast: 1,
538 hue: 1,
539 saturation: 1,
540 sharpness: 1,
541 gamma: 1,
542 white_balance_temperature: 1,
543 white_balance_component: 1,
544 backlight_compensation: 1,
545 gain: 1,
546 power_line_frequency: 1,
547 hue_auto: 1,
548 white_balance_temperature_auto: 1,
549 white_balance_component_auto: 1,
550 digital_multiplier: 1,
551 digital_multiplier_limit: 1
552 );
553 } _control_a;
554 } _controls;
555#endif
556 uint8 processing;
557 struct video_standards {
558 LBITFIELD8_8 (
559 none: 1,
560 ntsc_525_60: 1,
561 pal_625_50: 1,
562 secam_625_50: 1,
563 ntsc_625_50: 1,
564 pal_525_60: 1,
565 reserved6: 1, // Reserved. Set to zero.
566 reserved7: 1 // Reserved. Set to zero.
567 );
568 } _video_standards;
569} _PACKED usb_video_processing_unit_descriptor;
570
571typedef struct camera_terminal_descriptor {
572 uint8 length; // 15 + control_size bytes
573 uint8 descriptor_type;
574 uint8 descriptor_sub_type;
575 uint8 terminal_id;
576 uint16 terminal_type;
577 uint8 assoc_terminal;
578 uint8 terminal;
579 uint16 objective_focal_length_min;
580 uint16 objective_focal_length_max;
581 uint16 ocular_focal_length;
582 uint8 control_size;
583#if B_HOST_IS_LENDIAN
584 struct controls {
585 struct control_a {
586 LBITFIELD16 (
587 scanning_mode: 1,
588 auto_exposure_mode: 1,
589 auto_exposure_priority: 1,
590 exposure_time_absolute: 1,
591 exposure_time_relative: 1,
592 focus_absolute: 1,
593 focus_relative: 1,
594 iris_absolute: 1,
595 iris_relative: 1,
596 zoom_absolute: 1,
597 zoom_relative: 1,
598 pan_tilt_absolute: 1,
599 pan_tilt_relative: 1,
600 roll_absolute: 1,
601 roll_relative: 1,
602 reserved15: 1
603 );
604 } _control_a;
605 struct control_b {
606 LBITFIELD4 (
607 reserved16: 1,
608 focus_auto: 1,
609 privacy: 1,
610 // D19...(control_size*8-1): Reserved, set to zero.
611 reserved: 13
612 );
613 } _contorl_b;
614 } _controls;
615#else
616 struct controls {
617 struct control_b {
618 LBITFIELD4 (
619 reserved16: 1,
620 focus_auto: 1,
621 privacy: 1,
622 // D19...(control_size*8-1): Reserved, set to zero.
623 reserved: 13
624 );
625 } _contorl_b;
626 struct control_a {
627 LBITFIELD16 (
628 scanning_mode: 1,
629 auto_exposure_mode: 1,
630 auto_exposure_priority: 1,
631 exposure_time_absolute: 1,
632 exposure_time_relative: 1,
633 focus_absolute: 1,
634 focus_relative: 1,
635 iris_absolute: 1,
636 iris_relative: 1,
637 zoom_absolute: 1,
638 zoom_relative: 1,
639 pan_tilt_absolute: 1,
640 pan_tilt_relative: 1,
641 roll_absolute: 1,
642 roll_relative: 1,
643 reserved15: 1
644 );
645 } _control_a;
646 } _controls;
647#endif
648} _PACKED usb_video_camera_terminal_descriptor;
649
650struct usb_video_frame_descriptor {
651 uint8 length;
652 uint8 descriptor_type;
653 uint8 descriptor_subtype;
654 uint8 frame_index;
655 uint8 capabilities;
656 uint16 width;
657 uint16 height;
658 uint32 min_bit_rate;
659 uint32 max_bit_rate;
660 uint32 max_video_frame_buffer_size;
661 uint32 default_frame_interval;
662 uint8 frame_interval_type;
663 union {
664 struct {
665 uint32 min_frame_interval;
666 uint32 max_frame_tnterval;
667 uint32 frame_interval_step;
668 } continuous;
669 uint32 discrete_frame_intervals[0];
670 };
671} _PACKED;
672
673typedef struct video_probe_and_commit_controls {
674 uint8 length; // 34 bytes
675 struct hint {
676 LBITFIELD5 (
677 frame_interval: 1,
678 key_frame_rate: 1,
679 p_frame_rate: 1,
680 comp_quality: 1,
681 reserved: 12
682 );
683 } _hint;
684 uint8 format_index;
685 uint8 frame_index;
686 uint32 frame_interval;
687 uint16 key_frame_rate;
688 uint16 p_frame_rate;
689 uint16 comp_quality;
690 uint16 comp_window_size;
691 uint16 delay;
692 uint32 max_video_frame_size;
693 uint32 max_payload_transfer_size;
694 uint32 clock_frequency;
695 struct framing_info {
696 LBITFIELD8_3 (
697 is_frame_id_required: 1,
698 is_end_of_frame_present: 1,
699 reserved: 6
700 );
701 } _framing_info;
702 uint8 prefered_version;
703 uint8 min_version;
704 uint8 max_version;
705} _PACKED usb_video_video_probe_and_commit_controls;
706
707typedef struct video_still_probe_control_and_still_commit_control {
708 uint8 length; // 11 bytes
709 uint8 frame_index;
710 uint8 compression_index;
711 uint32 max_video_frame_size;
712 uint32 max_payload_transfer_size;
713} _PACKED usb_video_video_still_probe_control_and_still_commit_control;
714
715typedef struct still_image_frame_descriptor {
716 // 10 bytes + (4 * num_image_size_patterns) - 4 + num_compression_pattern
717 uint8 length;
718 uint8 descriptor_type;
719 uint8 descriptor_sub_type;
720 uint8 endpoint_address;
721 uint8 num_image_size_patterns;
722 struct pattern_size {
723 uint16 width;
724 uint16 height;
725 } * _pattern_size;
726 uint8 num_compression_pattern;
727 uint8* compression;
728} _PACKED usb_video_still_image_frame_descriptor;
729
730typedef struct std_vs_bulk_still_image_data_endpoint_descriptor {
731 uint8 length; // 7 bytes
732 struct endpoint_address {
733 LBITFIELD8_3 (
734 endpoint_number: 4, // Determined by the designer
735 reserved: 3,
736 direction: 1 // Set to 1 = IN endpoint)
737 );
738 } _endpoint_address;
739 struct attributes {
740 LBITFIELD8_2 (
741 transfer_type: 2, // Set to 10 = Bulk
742 reserved: 6
743 );
744 } _attributes;
745 uint16 max_packet_size;
746 uint8 interval;
747} _PACKED usb_video_standard_vs_bulk_still_image_data_endpoint_descriptor;
748
749typedef struct color_matching_descriptor {
750 uint8 length; // 6 bytes
751 uint8 descriptor_type;
752 uint8 descriptor_sub_type;
753 uint8 color_primaries;
754 uint8 transfer_characteristics;
755 uint8 matrix_coefficients;
756} _PACKED usb_video_color_matching_descriptor;
757
758typedef struct std_vs_isochronous_video_data_endpoint_descriptor {
759 uint8 length; // 7 bytes
760 uint8 descriptor_type;
761 struct endpoint_address {
762 LBITFIELD8_3 (
763 endpoint_number: 4, // Determined by the designer
764 reserved: 3, // Reset to zero.
765 direction: 1 // 0 = OUT endpoint, 1 = IN endpoint
766 );
767 } _endpoint_address;
768 struct attributes {
769 LBITFIELD8_3 (
770 transfer_type: 2, // 01 = isochronous
771 synchronization_type: 2, // 01 = asynchronous
772 reserved: 4
773 );
774 } _attributes;
775 uint16 max_packet_size;
776 uint8 interval;
777} _PACKED usb_video_std_vs_isochronous_video_data_endpoint_descriptor;
778
779typedef struct std_vs_bulk_video_data_endpoint_descriptor {
780 uint8 length; // 7 bytes
781 uint8 descriptor_type;
782 struct endpoint_address {
783 LBITFIELD8_3 (
784 endpoint_number: 4, // Determined by the designer
785 reserved: 3, // Reset to zero.
786 direction: 1 // 0 = OUT endpoint
787 );
788 } _endpoint_address;
789 struct attributes {
790 LBITFIELD8_2 (
791 transfer_type: 2, // Set to 10 = Bulk
792 reserved: 6
793 );
794 } _attributes;
795 uint16 max_packet_size;
796 uint8 interval;
797} _PACKED usb_video_standard_vs_bulk_video_data_endpoint_descriptor;
798
799#endif /* !USB_VIDEO_H */