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