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 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_TEMPERATURE_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 nr_in_pins; 281 uint8* source_id; 282 uint8 selector; 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 nr_in_pins; 329 uint8 source_id[0]; 330 #if 0 331 // Remaining part of the structure can't be encoded because source_id has 332 // a variable size 333 uint8 control_size; 334 struct controls { 335 B_LBITFIELD8_8 ( 336 vendor_specific0 : 1, 337 vendor_specific1 : 1, 338 vendor_specific2 : 1, 339 vendor_specific3 : 1, 340 vendor_specific4 : 1, 341 vendor_specific5 : 1, 342 vendor_specific6 : 1, 343 vendor_specific7 : 1 344 ); 345 } * _controls; 346 uint8 extension; 347 #endif 348 } _PACKED usb_video_extension_unit_descriptor; 349 350 351 typedef struct { 352 uint8 length; // 7 bytes 353 uint8 descriptor_type; 354 struct end_point_address { 355 B_LBITFIELD8_3 ( 356 endpoint_number: 4, // Determined by the designer 357 reserved: 3, // Reserved. Set to zero. 358 direction: 1 // 0 = OUT, 1 = IN 359 ); 360 } _end_point_address; 361 struct attributes { 362 B_LBITFIELD8_3 ( 363 transfer_type: 2, // Must be set to 11 (Interrupt) 364 synchronization_type: 2, // Must be set to 00 (None) 365 reserved: 4 // Reserved. Must be set to zero 366 ); 367 } _attributes; 368 uint16 max_packet_size; 369 uint8 interval; 370 } _PACKED usb_video_vc_interrupt_endpoint_descriptor; 371 372 373 typedef struct { 374 uint8 length; // 9 bytes 375 uint8 descriptor_type; 376 uint8 interface_number; 377 uint8 alternate_setting; 378 uint8 num_endpoints; 379 uint8 interface_class; 380 uint8 interface_sub_class; 381 uint8 interface_protocol; 382 // Not used. Must be set to USB_VIDEO_PC_PROTOCOL_UNDEFINED 383 uint8 interface; 384 } _PACKED usb_video_standard_vs_interface_descriptor; 385 386 387 typedef struct { 388 uint8 length; // 5 bytes 389 uint8 descriptor_type; 390 uint8 descriptor_sub_type; 391 uint16 max_transfer_size; 392 } _PACKED usb_video_class_specific_vc_interrupt_endpoint_descriptor; 393 394 395 // Input Terminal Descriptor 396 // 1.5: Table 3-4, page 50 397 typedef struct { 398 uint8 length; 399 uint8 descriptor_type; // USB_VIDEO_CS_INTERFACE 400 uint8 descriptor_subtype; // USB_VIDEO_VC_INPUT_TERMINAL 401 uint8 terminal_id; 402 uint16 terminal_type; 403 uint8 assoc_terminal; 404 uint8 terminal; 405 406 union { 407 struct { 408 uint16 focal_length_min; 409 uint16 focal_length_max; 410 uint16 focal_length; 411 uint8 control_size; 412 uint8 controls[3]; 413 } _PACKED camera; 414 }; 415 } _PACKED usb_video_input_terminal_descriptor; 416 417 418 typedef struct { 419 uint8 length; // 13 bytes + (num_formats*control_size) 420 uint8 descriptor_type; 421 uint8 descriptor_sub_type; 422 uint8 num_formats; 423 uint16 total_length; 424 struct endpoint_address { 425 B_LBITFIELD8_3 ( 426 endpoint_number: 4, // Determined by the designer 427 reserved: 3, // Set to zero. 428 direction: 1 // 0 = OUT, 1 = IN 429 ); 430 } _endpoint_address; 431 struct info { 432 B_LBITFIELD8_2 ( 433 dynamic_format_change_support: 1, 434 reserved: 7 // Set to zero. 435 ); 436 } _info; 437 uint8 terminal_link; 438 uint8 still_capture_method; 439 uint8 trigger_support; 440 uint8 trigger_usage; 441 uint8 control_size; 442 struct ma_controls { 443 // For four first bits, a bit set to 1 indicates that the named field 444 // is supported by the Video Probe and Commit Control when 445 // its format_index is 1: 446 B_LBITFIELD8_7 ( 447 key_frame_rate: 1, 448 p_frame_rate: 1, 449 comp_quality: 1, 450 comp_window_size: 1, 451 // For the next two bits, a bit set to 1 indicates that the named 452 // control is supported by the device when 453 // format_index is 1: 454 generate_key_frame: 1, 455 update_frame_segment: 1, 456 reserved: 2 // (control_size*8-1): Set to zero. 457 ); 458 } * _ma_controls; 459 } _PACKED usb_video_class_specific_vs_interface_input_header_descriptor; 460 461 462 463 // Output terminal descriptor 464 // 1.5: Table 3-5, page 51 465 typedef struct { 466 uint8 length; 467 uint8 descriptor_type; // USB_VIDEO_CS_INTERFACE 468 uint8 descriptor_subtype; // USB_VIDEO_VC_OUTPUT_TERMINAL 469 uint8 terminal_id; 470 uint16 terminal_type; 471 uint8 assoc_terminal; 472 uint8 source_id; 473 uint8 terminal; 474 } _PACKED usb_video_output_terminal_descriptor; 475 476 477 typedef struct { 478 uint8 length; // 9 + (num_formats*control_size) 479 uint8 descriptor_type; 480 uint8 descriptor_sub_type; 481 uint8 num_formats; 482 uint16 total_length; 483 struct endpoint_address { 484 B_LBITFIELD8_3 ( 485 endpoint_number: 4, // Determined by the designer 486 reserved: 3, // Set to zero. 487 direction: 1 // 0 = OUT 488 ); 489 } _endpoint_address; 490 uint8 terminal_link; 491 uint8 control_size; 492 struct ma_controls { 493 // For four first bits, a bit set to 1 indicates that the named field 494 // is supported by the Video Probe and Commit Control when its 495 // format_index is 1: 496 B_LBITFIELD8_5 ( 497 key_frame_rate: 1, 498 p_frame_rate: 1, 499 comp_quality: 1, 500 comp_window_size: 1, 501 reserved: 4 // (control_size*8-1) Set to zero. 502 ); 503 } * _ma_controls; 504 } _PACKED usb_video_class_specific_vs_interface_output_header_descriptor; 505 506 507 // Processing unit descriptor 508 // 1.5: Table 3-8, page 54 509 typedef struct { 510 uint8 length; 511 uint8 descriptor_type; 512 uint8 descriptor_subtype; 513 uint8 unit_id; 514 uint8 source_id; 515 uint16 max_multiplier; 516 uint8 control_size; 517 union { 518 #if B_HOST_IS_LENDIAN 519 struct { 520 struct control_a { 521 B_LBITFIELD16_16 ( 522 brightness: 1, 523 contrast: 1, 524 hue: 1, 525 saturation: 1, 526 sharpness: 1, 527 gamma: 1, 528 white_balance_temperature: 1, 529 white_balance_component: 1, 530 backlight_compensation: 1, 531 gain: 1, 532 power_line_frequency: 1, 533 hue_auto: 1, 534 white_balance_temperature_auto: 1, 535 white_balance_component_auto: 1, 536 digital_multiplier: 1, 537 digital_multiplier_limit: 1 538 ); 539 } _control_a; 540 struct control_b { 541 B_LBITFIELD16_3 ( 542 analog_video_standard: 1, 543 analog_video_lock_status: 1, 544 reserved: 14 // Reserved. Se to zero. 545 ); 546 } _control_b; 547 } _controls; 548 #else 549 struct { 550 struct control_b { 551 B_LBITFIELD16_3 ( 552 analog_video_standard: 1, 553 analog_video_lock_status: 1, 554 reserved: 14 // Reserved. Se to zero. 555 ); 556 } _control_b; 557 struct control_a { 558 B_LBITFIELD16_16 ( 559 brightness: 1, 560 contrast: 1, 561 hue: 1, 562 saturation: 1, 563 sharpness: 1, 564 gamma: 1, 565 white_balance_temperature: 1, 566 white_balance_component: 1, 567 backlight_compensation: 1, 568 gain: 1, 569 power_line_frequency: 1, 570 hue_auto: 1, 571 white_balance_temperature_auto: 1, 572 white_balance_component_auto: 1, 573 digital_multiplier: 1, 574 digital_multiplier_limit: 1 575 ); 576 } _control_a; 577 } _controls; 578 #endif 579 uint8_t controls[4]; 580 }; 581 uint8 processing; 582 union { 583 struct { 584 B_LBITFIELD8_8 ( 585 none: 1, 586 ntsc_525_60: 1, 587 pal_625_50: 1, 588 secam_625_50: 1, 589 ntsc_625_50: 1, 590 pal_525_60: 1, 591 reserved6: 1, // Reserved. Set to zero. 592 reserved7: 1 // Reserved. Set to zero. 593 ); 594 } _video_standards; 595 uint8_t video_standards; 596 }; 597 } _PACKED usb_video_processing_unit_descriptor; 598 599 600 typedef struct { 601 uint8 length; // 15 + control_size bytes 602 uint8 descriptor_type; 603 uint8 descriptor_sub_type; 604 uint8 terminal_id; 605 uint16 terminal_type; 606 uint8 assoc_terminal; 607 uint8 terminal; 608 uint16 objective_focal_length_min; 609 uint16 objective_focal_length_max; 610 uint16 ocular_focal_length; 611 uint8 control_size; 612 #if B_HOST_IS_LENDIAN 613 struct controls { 614 struct control_a { 615 B_LBITFIELD16_16 ( 616 scanning_mode: 1, 617 auto_exposure_mode: 1, 618 auto_exposure_priority: 1, 619 exposure_time_absolute: 1, 620 exposure_time_relative: 1, 621 focus_absolute: 1, 622 focus_relative: 1, 623 iris_absolute: 1, 624 iris_relative: 1, 625 zoom_absolute: 1, 626 zoom_relative: 1, 627 pan_tilt_absolute: 1, 628 pan_tilt_relative: 1, 629 roll_absolute: 1, 630 roll_relative: 1, 631 reserved15: 1 632 ); 633 } _control_a; 634 struct control_b { 635 B_LBITFIELD16_4 ( 636 reserved16: 1, 637 focus_auto: 1, 638 privacy: 1, 639 // D19...(control_size*8-1): Reserved, set to zero. 640 reserved: 13 641 ); 642 } _contorl_b; 643 } _controls; 644 #else 645 struct controls { 646 struct control_b { 647 B_LBITFIELD16_4 ( 648 reserved16: 1, 649 focus_auto: 1, 650 privacy: 1, 651 // D19...(control_size*8-1): Reserved, set to zero. 652 reserved: 13 653 ); 654 } _contorl_b; 655 struct control_a { 656 B_LBITFIELD16_16 ( 657 scanning_mode: 1, 658 auto_exposure_mode: 1, 659 auto_exposure_priority: 1, 660 exposure_time_absolute: 1, 661 exposure_time_relative: 1, 662 focus_absolute: 1, 663 focus_relative: 1, 664 iris_absolute: 1, 665 iris_relative: 1, 666 zoom_absolute: 1, 667 zoom_relative: 1, 668 pan_tilt_absolute: 1, 669 pan_tilt_relative: 1, 670 roll_absolute: 1, 671 roll_relative: 1, 672 reserved15: 1 673 ); 674 } _control_a; 675 } _controls; 676 #endif 677 } _PACKED usb_video_camera_terminal_descriptor; 678 679 680 typedef struct { 681 uint8 length; 682 uint8 descriptor_type; 683 uint8 descriptor_subtype; 684 uint8 frame_index; 685 uint8 capabilities; 686 uint16 width; 687 uint16 height; 688 uint32 min_bit_rate; 689 uint32 max_bit_rate; 690 uint32 max_video_frame_buffer_size; 691 uint32 default_frame_interval; 692 uint8 frame_interval_type; 693 union { 694 struct { 695 uint32 min_frame_interval; 696 uint32 max_frame_tnterval; 697 uint32 frame_interval_step; 698 } continuous; 699 uint32 discrete_frame_intervals[0]; 700 }; 701 } _PACKED usb_video_frame_descriptor; 702 703 704 typedef struct { 705 uint8 length; // 34 bytes 706 struct hint { 707 B_LBITFIELD16_5 ( 708 frame_interval: 1, 709 key_frame_rate: 1, 710 p_frame_rate: 1, 711 comp_quality: 1, 712 reserved: 12 713 ); 714 } _hint; 715 uint8 format_index; 716 uint8 frame_index; 717 uint32 frame_interval; 718 uint16 key_frame_rate; 719 uint16 p_frame_rate; 720 uint16 comp_quality; 721 uint16 comp_window_size; 722 uint16 delay; 723 uint32 max_video_frame_size; 724 uint32 max_payload_transfer_size; 725 uint32 clock_frequency; 726 struct framing_info { 727 B_LBITFIELD8_3 ( 728 is_frame_id_required: 1, 729 is_end_of_frame_present: 1, 730 reserved: 6 731 ); 732 } _framing_info; 733 uint8 prefered_version; 734 uint8 min_version; 735 uint8 max_version; 736 } _PACKED usb_video_video_probe_and_commit_controls; 737 738 739 typedef struct { 740 uint8 length; // 11 bytes 741 uint8 frame_index; 742 uint8 compression_index; 743 uint32 max_video_frame_size; 744 uint32 max_payload_transfer_size; 745 } _PACKED usb_video_video_still_probe_control_and_still_commit_control; 746 747 748 typedef struct { 749 // 10 bytes + (4 * num_image_size_patterns) - 4 + num_compression_pattern 750 uint8 length; 751 uint8 descriptor_type; 752 uint8 descriptor_sub_type; 753 uint8 endpoint_address; 754 uint8 num_image_size_patterns; 755 struct pattern_size { 756 uint16 width; 757 uint16 height; 758 } * _pattern_size; 759 uint8 num_compression_pattern; 760 uint8* compression; 761 } _PACKED usb_video_still_image_frame_descriptor; 762 763 764 typedef struct { 765 uint8 length; // 7 bytes 766 struct endpoint_address { 767 B_LBITFIELD8_3 ( 768 endpoint_number: 4, // Determined by the designer 769 reserved: 3, 770 direction: 1 // Set to 1 = IN endpoint) 771 ); 772 } _endpoint_address; 773 struct attributes { 774 B_LBITFIELD8_2 ( 775 transfer_type: 2, // Set to 10 = Bulk 776 reserved: 6 777 ); 778 } _attributes; 779 uint16 max_packet_size; 780 uint8 interval; 781 } _PACKED usb_video_standard_vs_bulk_still_image_data_endpoint_descriptor; 782 783 784 typedef struct { 785 uint8 length; // 6 bytes 786 uint8 descriptor_type; 787 uint8 descriptor_sub_type; 788 uint8 color_primaries; 789 uint8 transfer_characteristics; 790 uint8 matrix_coefficients; 791 } _PACKED usb_video_color_matching_descriptor; 792 793 794 typedef struct { 795 uint8 length; // 7 bytes 796 uint8 descriptor_type; 797 struct endpoint_address { 798 B_LBITFIELD8_3 ( 799 endpoint_number: 4, // Determined by the designer 800 reserved: 3, // Reset to zero. 801 direction: 1 // 0 = OUT endpoint, 1 = IN endpoint 802 ); 803 } _endpoint_address; 804 struct attributes { 805 B_LBITFIELD8_3 ( 806 transfer_type: 2, // 01 = isochronous 807 synchronization_type: 2, // 01 = asynchronous 808 reserved: 4 809 ); 810 } _attributes; 811 uint16 max_packet_size; 812 uint8 interval; 813 } _PACKED usb_video_std_vs_isochronous_video_data_endpoint_descriptor; 814 815 816 typedef struct { 817 uint8 length; // 7 bytes 818 uint8 descriptor_type; 819 struct endpoint_address { 820 B_LBITFIELD8_3 ( 821 endpoint_number: 4, // Determined by the designer 822 reserved: 3, // Reset to zero. 823 direction: 1 // 0 = OUT endpoint 824 ); 825 } _endpoint_address; 826 struct attributes { 827 B_LBITFIELD8_2 ( 828 transfer_type: 2, // Set to 10 = Bulk 829 reserved: 6 830 ); 831 } _attributes; 832 uint16 max_packet_size; 833 uint8 interval; 834 } _PACKED usb_video_standard_vs_bulk_video_data_endpoint_descriptor; 835 836 837 #endif /* !USB_VIDEO_H */ 838