diff --git a/headers/os/drivers/usb/USB_video.h b/headers/os/drivers/usb/USB_video.h index f9798eaf61..52bc50c3ee 100644 --- a/headers/os/drivers/usb/USB_video.h +++ b/headers/os/drivers/usb/USB_video.h @@ -1,5 +1,5 @@ /* - * Copyright 2016, Adrien Destugues, pulkomandy@pulkomandy.tk + * Copyright 2016-2024, Adrien Destugues, pulkomandy@pulkomandy.tk * Distributed under terms of the MIT license. */ @@ -171,18 +171,18 @@ enum { // Camera Terminal Control Selectors enum { // Processing Unit Control Selectors USB_VIDEO_PU_CONTROL_UNDEFINED = 0x00, - USB_VIDEO_PU_BACKLIGHT_COMPENSATION_CONTROL = 0x01, + USB_VIDEO_PU_BACKLIGHT_COMPENSATION_CONTROL = 0x01, USB_VIDEO_PU_BRIGHTNESS_CONTROL = 0x02, USB_VIDEO_PU_CONTRAST_CONTROL = 0x03, USB_VIDEO_PU_GAIN_CONTROL = 0x04, USB_VIDEO_PU_POWER_LINE_FREQUENCY_CONTROL = 0x05, USB_VIDEO_PU_HUE_CONTROL = 0x06, - USB_VIDEO_PU_SATURATION_CONTROL = 0x07, + USB_VIDEO_PU_SATURATION_CONTROL = 0x07, USB_VIDEO_PU_SHARPNESS_CONTROL = 0x08, USB_VIDEO_PU_GAMMA_CONTROL = 0x09, USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL = 0x0A, USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL = 0x0B, - USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_COMPONENT_CONTROL = 0x0C, + USB_VIDEO_PU_WHITE_BALANCE_COMPONENT_CONTROL = 0x0C, USB_VIDEO_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL = 0x0D, USB_VIDEO_PU_DIGITAL_MULTIPLEXER_CONTROL = 0x0E, USB_VIDEO_PU_DIGITAL_MULTIPLEXER_LIMIT_CONTROL = 0x0F, @@ -277,9 +277,9 @@ typedef struct { uint8 descriptor_type; uint8 descriptor_sub_type; uint8 unit_id; - uint8 nr_in_pins; - uint8* source_id; - uint8 selector; + uint8 num_input_pins; + uint8 source_id[0]; + uint8 Selector() const { return source_id[num_input_pins]; } } _PACKED usb_video_selector_unit_descriptor; @@ -325,26 +325,13 @@ typedef struct { uint8 unit_id; uint8 guid_extension_code[16]; uint8 num_controls; - uint8 nr_in_pins; + uint8 num_input_pins; uint8 source_id[0]; -#if 0 - // Remaining part of the structure can't be encoded because source_id has - // a variable size - uint8 control_size; - struct controls { - B_LBITFIELD8_8 ( - vendor_specific0 : 1, - vendor_specific1 : 1, - vendor_specific2 : 1, - vendor_specific3 : 1, - vendor_specific4 : 1, - vendor_specific5 : 1, - vendor_specific6 : 1, - vendor_specific7 : 1 - ); - } * _controls; - uint8 extension; -#endif + + uint8 ControlSize() const { return source_id[num_input_pins]; } + const uint8* Controls() const { return &source_id[num_input_pins + 1]; } + uint8 Extension() const + { return source_id[num_input_pins + ControlSize() + 1]; } } _PACKED usb_video_extension_unit_descriptor; @@ -405,14 +392,14 @@ typedef struct { union { struct { - uint16 focal_length_min; - uint16 focal_length_max; - uint16 focal_length; + uint16 objective_focal_length_min; + uint16 objective_focal_length_max; + uint16 ocular_focal_length; uint8 control_size; uint8 controls[3]; } _PACKED camera; }; -} _PACKED usb_video_input_terminal_descriptor; +} _PACKED usb_video_camera_input_terminal_descriptor; typedef struct { @@ -455,7 +442,7 @@ typedef struct { update_frame_segment: 1, reserved: 2 // (control_size*8-1): Set to zero. ); - } * _ma_controls; + } _ma_controls[0]; } _PACKED usb_video_class_specific_vs_interface_input_header_descriptor; @@ -468,7 +455,7 @@ typedef struct { uint8 descriptor_subtype; // USB_VIDEO_VC_OUTPUT_TERMINAL uint8 terminal_id; uint16 terminal_type; - uint8 assoc_terminal; + uint8 associated_terminal; uint8 source_id; uint8 terminal; } _PACKED usb_video_output_terminal_descriptor; @@ -500,7 +487,7 @@ typedef struct { comp_window_size: 1, reserved: 4 // (control_size*8-1) Set to zero. ); - } * _ma_controls; + } _ma_controls[0]; } _PACKED usb_video_class_specific_vs_interface_output_header_descriptor; @@ -541,7 +528,7 @@ typedef struct { B_LBITFIELD16_3 ( analog_video_standard: 1, analog_video_lock_status: 1, - reserved: 14 // Reserved. Se to zero. + reserved: 14 // Reserved. Set to zero. ); } _control_b; } _controls; @@ -551,7 +538,7 @@ typedef struct { B_LBITFIELD16_3 ( analog_video_standard: 1, analog_video_lock_status: 1, - reserved: 14 // Reserved. Se to zero. + reserved: 14 // Reserved. Set to zero. ); } _control_b; struct control_a { @@ -578,8 +565,9 @@ typedef struct { #endif uint8_t controls[4]; }; - uint8 processing; - union { + + uint8 Processing() const { return controls[control_size]; } + typedef union { struct { B_LBITFIELD8_8 ( none: 1, @@ -593,7 +581,8 @@ typedef struct { ); } _video_standards; uint8_t video_standards; - }; + } video_standards; + video_standards VideoStandards() const { return *(video_standards*)&controls[control_size+1]; } } _PACKED usb_video_processing_unit_descriptor; @@ -693,7 +682,7 @@ typedef struct { union { struct { uint32 min_frame_interval; - uint32 max_frame_tnterval; + uint32 max_frame_interval; uint32 frame_interval_step; } continuous; uint32 discrete_frame_intervals[0]; @@ -702,7 +691,6 @@ typedef struct { typedef struct { - uint8 length; // 34 bytes struct hint { B_LBITFIELD16_5 ( frame_interval: 1, @@ -733,7 +721,7 @@ typedef struct { uint8 prefered_version; uint8 min_version; uint8 max_version; -} _PACKED usb_video_video_probe_and_commit_controls; +} _PACKED usb_video_probe_and_commit_controls; typedef struct { @@ -755,9 +743,12 @@ typedef struct { struct pattern_size { uint16 width; uint16 height; - } * _pattern_size; - uint8 num_compression_pattern; - uint8* compression; + } _pattern_size[0]; + uint8 NumCompressionPatterns() const { return *(CompressionPatterns() - 1); } + const uint8* CompressionPatterns() const { + return ((const uint8*)_pattern_size + sizeof(pattern_size) + * num_image_size_patterns + sizeof(uint8)); + } } _PACKED usb_video_still_image_frame_descriptor; diff --git a/src/add-ons/media/media-add-ons/usb_webcam/CamRoster.cpp b/src/add-ons/media/media-add-ons/usb_webcam/CamRoster.cpp index ec7bda74e0..5ea8a170df 100644 --- a/src/add-ons/media/media-add-ons/usb_webcam/CamRoster.cpp +++ b/src/add-ons/media/media-add-ons/usb_webcam/CamRoster.cpp @@ -142,8 +142,9 @@ status_t CamRoster::LoadExternalAddons() { PRINT((CH "()" CT)); - // FIXME + // TODO implement external add-ons return B_ERROR; +#if 0 int32 index; int32 sclass; status_t err; @@ -162,6 +163,7 @@ CamRoster::LoadExternalAddons() err)); } return B_OK; +#endif } diff --git a/src/add-ons/media/media-add-ons/usb_webcam/Jamfile b/src/add-ons/media/media-add-ons/usb_webcam/Jamfile index 629daf1e7f..4be0934ed6 100644 --- a/src/add-ons/media/media-add-ons/usb_webcam/Jamfile +++ b/src/add-ons/media/media-add-ons/usb_webcam/Jamfile @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src add-ons media media-add-ons usb_webcam ; +UsePrivateHeaders drivers ; + usbKitLibraryName = libdevice.so ; # source directories diff --git a/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/USB_video.h b/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/USB_video.h index 0b9cf546d6..d8c7431d4b 100644 --- a/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/USB_video.h +++ b/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/USB_video.h @@ -7,156 +7,16 @@ #define _USB_VIDEO_H -/* Class/Subclass/Protocol */ -#define CC_VIDEO 0xE -#define SC_UNDEFINED 0x0 -#define SC_VIDEOCONTROL 0x1 -#define SC_VIDEOSTREAMING 0x2 -#define SC_VIDEO_INTERFACE_COLLECTION 0x3 -#define PC_PROTOCOL_UNDEFINED 0x0 - -#define CS_UNDEFINED 0x20 -#define CS_DEVICE 0x21 -#define CS_CONFIGURATION 0x22 -#define CS_STRING 0x23 -#define CS_INTERFACE 0x24 -#define CS_ENDPOINT 0x25 - -/* Video Control Class Descriptors */ -#define VC_DESCRIPTOR_UNDEFINED 0x0 -#define VC_HEADER 0x1 -#define VC_INPUT_TERMINAL 0x2 -#define VC_OUTPUT_TERMINAL 0x3 -#define VC_SELECTOR_UNIT 0x4 -#define VC_PROCESSING_UNIT 0x5 -#define VC_EXTENSION_UNIT 0x6 - -/* Video Streaming Class Descriptors */ -#define VS_UNDEFINED 0x00 -#define VS_INPUT_HEADER 0x01 -#define VS_OUTPUT_HEADER 0x02 -#define VS_STILL_IMAGE_FRAME 0x03 -#define VS_FORMAT_UNCOMPRESSED 0x04 -#define VS_FRAME_UNCOMPRESSED 0x05 -#define VS_FORMAT_MJPEG 0x06 -#define VS_FRAME_MJPEG 0x07 -#define VS_FORMAT_MPEG2TS 0x0a -#define VS_FORMAT_DV 0x0c -#define VS_COLORFORMAT 0x0d -#define VS_FORMAT_FRAME_BASED 0x10 -#define VS_FRAME_FRAME_BASED 0x11 -#define VS_FORMAT_STREAM_BASED 0x12 - -#define EP_UNDEFINED 0x0 -#define EP_GENERAL 0x1 -#define EP_ENDPOINT 0x2 -#define EP_INTERRUPT 0x3 - -#define RC_UNDEFINED 0x00 -#define SET_CUR 0x01 -#define GET_CUR 0x81 -#define GET_MIN 0x82 -#define GET_MAX 0x83 -#define GET_RES 0x84 -#define GET_LEN 0x85 -#define GET_INFO 0x86 -#define GET_DEF 0x87 - #define VC_CONTROL_UNDEFINED 0x0 #define VC_VIDEO_POWER_MODE_CONTROL 0x1 #define VC_REQUEST_ERROR_CODE_CONTROL 0x2 -#define TE_CONTROL_UNDEFINED 0x0 - -#define SU_CONTROL_UNDEFINED 0x0 -#define SU_INPUT_SELECT_CONTROL 0x1 - -#define CT_CONTROL_UNDEFINED 0x0 -#define CT_SCANNING_MODE_CONTROL 0x1 -#define CT_AE_MODE_CONTROL 0x2 -#define CT_AE_PRIORITY_CONTROL 0x3 -#define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x4 -#define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x5 -#define CT_FOCUS_ABSOLUTE_CONTROL 0x6 -#define CT_FOCUS_RELATIVE_CONTROL 0x7 -#define CT_FOCUS_AUTO_CONTROL 0x8 -#define CT_IRIS_ABSOLUTE_CONTROL 0x9 -#define CT_IRIS_RELATIVE_CONTROL 0xa -#define CT_ZOOM_ABSOLUTE_CONTROL 0xb -#define CT_ZOOM_RELATIVE_CONTROL 0xc -#define CT_PANTILT_ABSOLUTE_CONTROL 0xd -#define CT_PANTILT_RELATIVE_CONTROL 0xe -#define CT_ROLL_ABSOLUTE_CONTROL 0xf -#define CT_ROLL_RELATIVE_CONTROL 0x10 -#define CT_PRIVACY_CONTROL 0x11 - -#define PU_CONTROL_UNDEFINED 0x0 -#define PU_BACKLIGHT_COMPENSATION_CONTROL 0x1 -#define PU_BRIGHTNESS_CONTROL 0x2 -#define PU_CONTRAST_CONTROL 0x3 -#define PU_GAIN_CONTROL 0x4 -#define PU_POWER_LINE_FREQUENCY_CONTROL 0x5 -#define PU_HUE_CONTROL 0x6 -#define PU_SATURATION_CONTROL 0x7 -#define PU_SHARPNESS_CONTROL 0x8 -#define PU_GAMMA_CONTROL 0x9 -#define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0xa -#define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0xb -#define PU_WHITE_BALANCE_COMPONENT_CONTROL 0xc -#define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0xd -#define PU_DIGITAL_MULTIPLIER_CONTROL 0xe -#define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0xf -#define PU_HUE_AUTO_CONTROL 0x10 -#define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 -#define PU_ANALOG_LOCK_STATUS_CONTROL 0x12 - -#define XU_CONTROL_UNDEFINED 0x0 - -#define VS_CONTROL_UNDEFINED 0x0 -#define VS_PROBE_CONTROL 0x1 -#define VS_COMMIT_CONTROL 0x2 -#define VS_STILL_PROBE_CONTROL 0x3 -#define VS_STILL_COMMIT_CONTROL 0x4 -#define VS_STILL_IMAGE_TRIGGER_CONTROL 0x5 -#define VS_STREAM_ERROR_CODE_CONTROL 0x6 -#define VS_GENERATE_KEY_FRAME_CONTROL 0x7 -#define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x8 -#define VS_SYNCH_DELAY_CONTROL 0x9 - typedef struct usbvc_class_descriptor { uint8 length; uint8 descriptorType; - uint8 descriptorSubtype; + uint8 descriptorSubtype; } _PACKED usbvc_class_descriptor; -struct usbvc_input_header_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 numFormats; - uint16 totalLength; - uint8 endpointAddress; - uint8 info; - uint8 terminalLink; - uint8 stillCaptureMethod; - uint8 triggerSupport; - uint8 triggerUsage; - uint8 controlSize; - uint8 controls[0]; -} _PACKED; - -struct usbvc_output_header_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 numFormats; - uint16 totalLength; - uint8 endpointAddress; - uint8 terminalLink; - uint8 controlSize; - uint8 controls[0]; -} _PACKED; - typedef uint8 usbvc_guid[16]; struct usbvc_format_descriptor { @@ -186,58 +46,6 @@ struct usbvc_format_descriptor { }; } _PACKED; -struct usbvc_frame_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 frameIndex; - uint8 capabilities; - uint16 width; - uint16 height; - uint32 minBitRate; - uint32 maxBitRate; - uint32 maxVideoFrameBufferSize; - uint32 defaultFrameInterval; - uint8 frameIntervalType; - union { - struct { - uint32 minFrameInterval; - uint32 maxFrameInterval; - uint32 frameIntervalStep; - } continuous; - uint32 discreteFrameIntervals[0]; - }; -} _PACKED; - -typedef struct { - uint16 width; - uint16 height; -} _PACKED usbvc_image_size_pattern; - -struct usbvc_still_image_frame_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 endpointAddress; - uint8 numImageSizePatterns; - usbvc_image_size_pattern imageSizePatterns[0]; - uint8 NumCompressionPatterns() const { return *(CompressionPatterns() - 1); } - const uint8* CompressionPatterns() const { - return ((const uint8*)imageSizePatterns + sizeof(usbvc_image_size_pattern) - * numImageSizePatterns + sizeof(uint8)); - } -} _PACKED; - -struct usbvc_color_matching_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 colorPrimaries; - uint8 transferCharacteristics; - uint8 matrixCoefficients; -} _PACKED; - - struct usbvc_interface_header_descriptor { uint8 length; uint8 descriptorType; @@ -259,90 +67,5 @@ struct usbvc_input_terminal_descriptor { uint8 terminal; } _PACKED; -struct usbvc_output_terminal_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 terminalID; - uint16 terminalType; - uint8 associatedTerminal; - uint8 sourceID; - uint8 terminal; -} _PACKED; - -struct usbvc_camera_terminal_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 terminalID; - uint16 terminalType; - uint8 associatedTerminal; - uint8 terminal; - uint16 objectiveFocalLengthMin; - uint16 objectiveFocalLengthMax; - uint16 ocularFocalLength; - uint8 controlSize; - uint8 controls[0]; -} _PACKED; - -struct usbvc_selector_unit_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 unitID; - uint8 numInputPins; - uint8 sourceID[0]; - uint8 Selector() const { return sourceID[numInputPins]; } -} _PACKED; - -struct usbvc_processing_unit_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 unitID; - uint8 sourceID; - uint16 maxMultiplier; - uint8 controlSize; - uint8 controls[0]; - uint8 Processing() const { return controls[controlSize]; } - uint8 VideoStandards() const { return controls[controlSize+1]; } -} _PACKED; - -struct usbvc_extension_unit_descriptor { - uint8 length; - uint8 descriptorType; - uint8 descriptorSubtype; - uint8 unitID; - usbvc_guid guidExtensionCode; - uint8 numControls; - uint8 numInputPins; - uint8 sourceID[0]; - uint8 ControlSize() const { return sourceID[numInputPins]; } - const uint8* Controls() const { return &sourceID[numInputPins+1]; } - uint8 Extension() const - { return sourceID[numInputPins + ControlSize() + 1]; } -} _PACKED; - -struct usbvc_probecommit { - uint16 hint; - uint8 formatIndex; - uint8 frameIndex; - uint32 frameInterval; - uint16 keyFrameRate; - uint16 pFrameRate; - uint16 compQuality; - uint16 compWindowSize; - uint16 delay; - uint32 maxVideoFrameSize; - uint32 maxPayloadTransferSize; - uint32 clockFrequency; - uint8 framingInfo; - uint8 preferredVersion; - uint8 minVersion; - uint8 maxVersion; - void SetFrameInterval(uint32 interval) - { frameInterval = interval; } -} _PACKED; - #endif /* _USB_VIDEO_H */ diff --git a/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.cpp b/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.cpp index 4c0cfbdd73..13987ee472 100644 --- a/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.cpp +++ b/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.cpp @@ -17,7 +17,8 @@ usb_webcam_support_descriptor kSupportedDevices[] = { // ofcourse we support a generic UVC device... - {{ CC_VIDEO, SC_VIDEOCONTROL, 0, 0, 0 }, "Generic UVC", "Video Class", "??" }, + {{ USB_VIDEO_DEVICE_CLASS, USB_VIDEO_INTERFACE_VIDEOCONTROL_SUBCLASS, 0, 0, 0 }, "Generic UVC", "Video Class", "??" }, + {{ 0xEF, 0x02, 0, 0, 0 }, "Miscellaneous device", "Interface association", "??" }, // ...whilst the following IDs were 'stolen' from a recent Linux driver: {{ 0, 0, 0, 0x045e, 0x00f8, }, "Microsoft", "Lifecam NX-6000", "??" }, {{ 0, 0, 0, 0x045e, 0x0723, }, "Microsoft", "Lifecam VX-7000", "??" }, @@ -91,8 +92,8 @@ UVCCamDevice::UVCCamDevice(CamDeviceAddon& _addon, BUSBDevice* _device) if (interface == NULL) continue; - if (interface->Class() == CC_VIDEO && interface->Subclass() - == SC_VIDEOCONTROL) { + if (interface->Class() == USB_VIDEO_DEVICE_CLASS && interface->Subclass() + == USB_VIDEO_INTERFACE_VIDEOCONTROL_SUBCLASS) { printf("UVCCamDevice: (%" B_PRIu32 ",%" B_PRIu32 "): Found Video Control " "interface.\n", i, j); @@ -114,8 +115,8 @@ UVCCamDevice::UVCCamDevice(CamDeviceAddon& _addon, BUSBDevice* _device) } } fInitStatus = B_OK; - } else if (interface->Class() == CC_VIDEO && interface->Subclass() - == SC_VIDEOSTREAMING) { + } else if (interface->Class() == USB_VIDEO_DEVICE_CLASS && interface->Subclass() + == USB_VIDEO_INTERFACE_VIDEOSTREAMING_SUBCLASS) { printf("UVCCamDevice: (%" B_PRIu32 ",%" B_PRIu32 "): Found Video Streaming " "interface.\n", i, j); @@ -154,34 +155,38 @@ UVCCamDevice::_ParseVideoStreaming(const usbvc_class_descriptor* _descriptor, size_t len) { switch (_descriptor->descriptorSubtype) { - case VS_INPUT_HEADER: + case USB_VIDEO_VS_INPUT_HEADER: { - const usbvc_input_header_descriptor* descriptor - = (const usbvc_input_header_descriptor*)_descriptor; - printf("VS_INPUT_HEADER:\t#fmts=%d,ept=0x%x\n", descriptor->numFormats, - descriptor->endpointAddress); - if (descriptor->info & 1) + const usb_video_class_specific_vs_interface_input_header_descriptor* descriptor + = (const usb_video_class_specific_vs_interface_input_header_descriptor*)_descriptor; + printf("VS_INPUT_HEADER:\t#fmts=%d,ept=0x%x (%s)\n", descriptor->num_formats, + descriptor->_endpoint_address.endpoint_number, + descriptor->_endpoint_address.direction ? "IN" : "OUT"); + if (descriptor->_info.dynamic_format_change_support) printf("\tDynamic Format Change supported\n"); - printf("\toutput terminal id=%d\n", descriptor->terminalLink); - printf("\tstill capture method=%d\n", descriptor->stillCaptureMethod); - if (descriptor->triggerSupport) { + printf("\toutput terminal id=%d\n", descriptor->terminal_link); + printf("\tstill capture method=%d\n", descriptor->still_capture_method); + if (descriptor->trigger_support) { printf("\ttrigger button fixed to still capture=%s\n", - descriptor->triggerUsage ? "no" : "yes"); + descriptor->trigger_usage ? "no" : "yes"); } - const uint8* controls = descriptor->controls; - for (uint8 i = 0; i < descriptor->numFormats; i++, - controls += descriptor->controlSize) { + const struct usb_video_class_specific_vs_interface_input_header_descriptor::ma_controls* + controls = descriptor->_ma_controls; + for (uint8 i = 0; i < descriptor->num_formats; i++, + controls = + (const struct usb_video_class_specific_vs_interface_input_header_descriptor + ::ma_controls*)((const char*)controls + descriptor->control_size)) { printf("\tfmt%d: %s %s %s %s - %s %s\n", i, - (*controls & 1) ? "wKeyFrameRate" : "", - (*controls & 2) ? "wPFrameRate" : "", - (*controls & 4) ? "wCompQuality" : "", - (*controls & 8) ? "wCompWindowSize" : "", - (*controls & 16) ? "" : "", - (*controls & 32) ? "" : ""); + (controls->key_frame_rate) ? "wKeyFrameRate" : "", + (controls->p_frame_rate) ? "wPFrameRate" : "", + (controls->comp_quality) ? "wCompQuality" : "", + (controls->comp_window_size) ? "wCompWindowSize" : "", + (controls->generate_key_frame) ? "" : "", + (controls->update_frame_segment) ? "" : ""); } break; } - case VS_FORMAT_UNCOMPRESSED: + case USB_VIDEO_VS_FORMAT_UNCOMPRESSED: { const usbvc_format_descriptor* descriptor = (const usbvc_format_descriptor*)_descriptor; @@ -212,56 +217,56 @@ UVCCamDevice::_ParseVideoStreaming(const usbvc_class_descriptor* _descriptor, printf("\tRestrict duplication\n"); break; } - case VS_FRAME_MJPEG: - case VS_FRAME_UNCOMPRESSED: + case USB_VIDEO_VS_FRAME_MJPEG: + case USB_VIDEO_VS_FRAME_UNCOMPRESSED: { - const usbvc_frame_descriptor* descriptor - = (const usbvc_frame_descriptor*)_descriptor; - if (_descriptor->descriptorSubtype == VS_FRAME_UNCOMPRESSED) { + const usb_video_frame_descriptor* descriptor + = (const usb_video_frame_descriptor*)_descriptor; + if (_descriptor->descriptorSubtype == USB_VIDEO_VS_FRAME_UNCOMPRESSED) { printf("VS_FRAME_UNCOMPRESSED:"); fUncompressedFrames.AddItem( - new usbvc_frame_descriptor(*descriptor)); + new usb_video_frame_descriptor(*descriptor)); } else { printf("VS_FRAME_MJPEG:"); - fMJPEGFrames.AddItem(new usbvc_frame_descriptor(*descriptor)); + fMJPEGFrames.AddItem(new usb_video_frame_descriptor(*descriptor)); } printf("\tbFrameIdx=%d,stillsupported=%s," - "fixedframerate=%s\n", descriptor->frameIndex, + "fixedframerate=%s\n", descriptor->frame_index, (descriptor->capabilities & 1) ? "yes" : "no", (descriptor->capabilities & 2) ? "yes" : "no"); printf("\twidth=%u,height=%u,min/max bitrate=%" B_PRIu32 "/%" B_PRIu32 ", maxbuf=%" B_PRIu32 "\n", descriptor->width, descriptor->height, - descriptor->minBitRate, descriptor->maxBitRate, - descriptor->maxVideoFrameBufferSize); + descriptor->min_bit_rate, descriptor->max_bit_rate, + descriptor->max_video_frame_buffer_size); printf("\tdefault frame interval: %" B_PRIu32 ", #intervals(0=cont): %d\n", - descriptor->defaultFrameInterval, descriptor->frameIntervalType); - if (descriptor->frameIntervalType == 0) { + descriptor->default_frame_interval, descriptor->frame_interval_type); + if (descriptor->frame_interval_type == 0) { printf("min/max frame interval=%" B_PRIu32 "/%" B_PRIu32 ", step=%" B_PRIu32 "\n", - descriptor->continuous.minFrameInterval, - descriptor->continuous.maxFrameInterval, - descriptor->continuous.frameIntervalStep); - } else for (uint8 i = 0; i < descriptor->frameIntervalType; i++) { + descriptor->continuous.min_frame_interval, + descriptor->continuous.max_frame_interval, + descriptor->continuous.frame_interval_step); + } else for (uint8 i = 0; i < descriptor->frame_interval_type; i++) { printf("\tdiscrete frame interval: %" B_PRIu32 "\n", - descriptor->discreteFrameIntervals[i]); + descriptor->discrete_frame_intervals[i]); } break; } - case VS_COLORFORMAT: + case USB_VIDEO_VS_COLORFORMAT: { - const usbvc_color_matching_descriptor* descriptor - = (const usbvc_color_matching_descriptor*)_descriptor; + const usb_video_color_matching_descriptor* descriptor + = (const usb_video_color_matching_descriptor*)_descriptor; printf("VS_COLORFORMAT:\n\tbColorPrimaries: "); - switch (descriptor->colorPrimaries) { + switch (descriptor->color_primaries) { case 0: printf("Unspecified\n"); break; case 1: printf("BT.709,sRGB\n"); break; case 2: printf("BT.470-2(M)\n"); break; case 3: printf("BT.470-2(B,G)\n"); break; case 4: printf("SMPTE 170M\n"); break; case 5: printf("SMPTE 240M\n"); break; - default: printf("Invalid (%d)\n", descriptor->colorPrimaries); + default: printf("Invalid (%d)\n", descriptor->color_primaries); } printf("\tbTransferCharacteristics: "); - switch (descriptor->transferCharacteristics) { + switch (descriptor->transfer_characteristics) { case 0: printf("Unspecified\n"); break; case 1: printf("BT.709\n"); break; case 2: printf("BT.470-2(M)\n"); break; @@ -271,50 +276,54 @@ UVCCamDevice::_ParseVideoStreaming(const usbvc_class_descriptor* _descriptor, case 6: printf("Linear (V=Lc)\n"); break; case 7: printf("sRGB\n"); break; default: printf("Invalid (%d)\n", - descriptor->transferCharacteristics); + descriptor->transfer_characteristics); } printf("\tbMatrixCoefficients: "); - switch (descriptor->matrixCoefficients) { + switch (descriptor->matrix_coefficients) { case 0: printf("Unspecified\n"); break; case 1: printf("BT.709\n"); break; case 2: printf("FCC\n"); break; case 3: printf("BT.470-2(B,G)\n"); break; case 4: printf("SMPTE 170M (BT.601)\n"); break; case 5: printf("SMPTE 240M\n"); break; - default: printf("Invalid (%d)\n", descriptor->matrixCoefficients); + default: printf("Invalid (%d)\n", descriptor->matrix_coefficients); } break; } - case VS_OUTPUT_HEADER: + case USB_VIDEO_VS_OUTPUT_HEADER: { - const usbvc_output_header_descriptor* descriptor - = (const usbvc_output_header_descriptor*)_descriptor; - printf("VS_OUTPUT_HEADER:\t#fmts=%d,ept=0x%x\n", - descriptor->numFormats, descriptor->endpointAddress); - printf("\toutput terminal id=%d\n", descriptor->terminalLink); - const uint8* controls = descriptor->controls; - for (uint8 i = 0; i < descriptor->numFormats; i++, - controls += descriptor->controlSize) { + const usb_video_class_specific_vs_interface_output_header_descriptor* descriptor + = (const usb_video_class_specific_vs_interface_output_header_descriptor*)_descriptor; + printf("VS_OUTPUT_HEADER:\t#fmts=%d,ept=0x%x (%s)\n", + descriptor->num_formats, descriptor->_endpoint_address.endpoint_number, + descriptor->_endpoint_address.direction ? "IN" : "OUT"); + printf("\toutput terminal id=%d\n", descriptor->terminal_link); + const struct usb_video_class_specific_vs_interface_output_header_descriptor::ma_controls* + controls = descriptor->_ma_controls; + for (uint8 i = 0; i < descriptor->num_formats; i++, + controls + = (const struct usb_video_class_specific_vs_interface_output_header_descriptor + ::ma_controls*)((const char*)controls + descriptor->control_size)) { printf("\tfmt%d: %s %s %s %s\n", i, - (*controls & 1) ? "wKeyFrameRate" : "", - (*controls & 2) ? "wPFrameRate" : "", - (*controls & 4) ? "wCompQuality" : "", - (*controls & 8) ? "wCompWindowSize" : ""); + (controls->key_frame_rate) ? "wKeyFrameRate" : "", + (controls->p_frame_rate) ? "wPFrameRate" : "", + (controls->comp_quality) ? "wCompQuality" : "", + (controls->comp_window_size) ? "wCompWindowSize" : ""); } break; } - case VS_STILL_IMAGE_FRAME: + case USB_VIDEO_VS_STILL_IMAGE_FRAME: { - const usbvc_still_image_frame_descriptor* descriptor - = (const usbvc_still_image_frame_descriptor*)_descriptor; + const usb_video_still_image_frame_descriptor* descriptor + = (const usb_video_still_image_frame_descriptor*)_descriptor; printf("VS_STILL_IMAGE_FRAME:\t#imageSizes=%d,compressions=%d," - "ept=0x%x\n", descriptor->numImageSizePatterns, + "ept=0x%x\n", descriptor->num_image_size_patterns, descriptor->NumCompressionPatterns(), - descriptor->endpointAddress); - for (uint8 i = 0; i < descriptor->numImageSizePatterns; i++) { + descriptor->endpoint_address); + for (uint8 i = 0; i < descriptor->num_image_size_patterns; i++) { printf("imageSize%d: %dx%d\n", i, - descriptor->imageSizePatterns[i].width, - descriptor->imageSizePatterns[i].height); + descriptor->_pattern_size[i].width, + descriptor->_pattern_size[i].height); } for (uint8 i = 0; i < descriptor->NumCompressionPatterns(); i++) { printf("compression%d: %d\n", i, @@ -322,7 +331,7 @@ UVCCamDevice::_ParseVideoStreaming(const usbvc_class_descriptor* _descriptor, } break; } - case VS_FORMAT_MJPEG: + case USB_VIDEO_VS_FORMAT_MJPEG: { const usbvc_format_descriptor* descriptor = (const usbvc_format_descriptor*)_descriptor; @@ -352,19 +361,19 @@ UVCCamDevice::_ParseVideoStreaming(const usbvc_class_descriptor* _descriptor, printf("\tRestrict duplication\n"); break; } - case VS_FORMAT_MPEG2TS: + case USB_VIDEO_VS_FORMAT_MPEG2TS: printf("VS_FORMAT_MPEG2TS:\t\n"); break; - case VS_FORMAT_DV: + case USB_VIDEO_VS_FORMAT_DV: printf("VS_FORMAT_DV:\t\n"); break; - case VS_FORMAT_FRAME_BASED: + case USB_VIDEO_VS_FORMAT_FRAME_BASED: printf("VS_FORMAT_FRAME_BASED:\t\n"); break; - case VS_FRAME_FRAME_BASED: + case USB_VIDEO_VS_FRAME_FRAME_BASED: printf("VS_FRAME_FRAME_BASED:\t\n"); break; - case VS_FORMAT_STREAM_BASED: + case USB_VIDEO_VS_FORMAT_STREAM_BASED: printf("VS_FORMAT_STREAM_BASED:\t\n"); break; default: @@ -379,7 +388,7 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor, size_t len) { switch (_descriptor->descriptorSubtype) { - case VC_HEADER: + case USB_VIDEO_VC_HEADER: { if (fHeaderDescriptor != NULL) { printf("ERROR: multiple VC_HEADER! Skipping...\n"); @@ -397,7 +406,7 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor, } break; } - case VC_INPUT_TERMINAL: + case USB_VIDEO_VC_INPUT_TERMINAL: { const usbvc_input_terminal_descriptor* descriptor = (const usbvc_input_terminal_descriptor*)_descriptor; @@ -407,52 +416,52 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor, printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->terminal)); if (descriptor->terminalType == 0x201) { - const usbvc_camera_terminal_descriptor* desc - = (const usbvc_camera_terminal_descriptor*)descriptor; + const usb_video_camera_terminal_descriptor* desc + = (const usb_video_camera_terminal_descriptor*)descriptor; printf("\tObjectiveFocalLength Min/Max %d/%d\n", - desc->objectiveFocalLengthMin, - desc->objectiveFocalLengthMax); - printf("\tOcularFocalLength %d\n", desc->ocularFocalLength); - printf("\tControlSize %d\n", desc->controlSize); + desc->objective_focal_length_min, + desc->objective_focal_length_max); + printf("\tOcularFocalLength %d\n", desc->ocular_focal_length); + printf("\tControlSize %d\n", desc->control_size); } break; } - case VC_OUTPUT_TERMINAL: + case USB_VIDEO_VC_OUTPUT_TERMINAL: { - const usbvc_output_terminal_descriptor* descriptor - = (const usbvc_output_terminal_descriptor*)_descriptor; + const usb_video_output_terminal_descriptor* descriptor + = (const usb_video_output_terminal_descriptor*)_descriptor; printf("VC_OUTPUT_TERMINAL:\tid=%d,type=%04x,associated terminal=" - "%d, src id=%d\n", descriptor->terminalID, - descriptor->terminalType, descriptor->associatedTerminal, - descriptor->sourceID); + "%d, src id=%d\n", descriptor->terminal_id, + descriptor->terminal_type, descriptor->associated_terminal, + descriptor->source_id); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->terminal)); break; } - case VC_SELECTOR_UNIT: + case USB_VIDEO_VC_SELECTOR_UNIT: { - const usbvc_selector_unit_descriptor* descriptor - = (const usbvc_selector_unit_descriptor*)_descriptor; + const usb_video_selector_unit_descriptor* descriptor + = (const usb_video_selector_unit_descriptor*)_descriptor; printf("VC_SELECTOR_UNIT:\tid=%d,#pins=%d\n", - descriptor->unitID, descriptor->numInputPins); + descriptor->unit_id, descriptor->num_input_pins); printf("\t"); - for (uint8 i = 0; i < descriptor->numInputPins; i++) - printf("%d ", descriptor->sourceID[i]); + for (uint8 i = 0; i < descriptor->num_input_pins; i++) + printf("%d ", descriptor->source_id[i]); printf("\n"); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->Selector())); break; } - case VC_PROCESSING_UNIT: + case USB_VIDEO_VC_PROCESSING_UNIT: { - const usbvc_processing_unit_descriptor* descriptor - = (const usbvc_processing_unit_descriptor*)_descriptor; - fControlRequestIndex = fControlIndex + (descriptor->unitID << 8); + const usb_video_processing_unit_descriptor* descriptor + = (const usb_video_processing_unit_descriptor*)_descriptor; + fControlRequestIndex = fControlIndex + (descriptor->unit_id << 8); printf("VC_PROCESSING_UNIT:\t unit id=%d,src id=%d, digmul=%d\n", - descriptor->unitID, descriptor->sourceID, - descriptor->maxMultiplier); - printf("\tbControlSize=%d\n", descriptor->controlSize); - if (descriptor->controlSize >= 1) { + descriptor->unit_id, descriptor->source_id, + descriptor->max_multiplier); + printf("\tbControlSize=%d\n", descriptor->control_size); + if (descriptor->control_size >= 1) { if (descriptor->controls[0] & 1) printf("\tBrightness\n"); if (descriptor->controls[0] & 2) @@ -470,7 +479,7 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor, if (descriptor->controls[0] & 128) printf("\tWhite Balance Component\n"); } - if (descriptor->controlSize >= 2) { + if (descriptor->control_size >= 2) { if (descriptor->controls[1] & 1) printf("\tBacklight Compensation\n"); if (descriptor->controls[1] & 2) @@ -488,7 +497,7 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor, if (descriptor->controls[1] & 128) printf("\tDigital Multiplier Limit\n"); } - if (descriptor->controlSize >= 3) { + if (descriptor->control_size >= 3) { if (descriptor->controls[2] & 1) printf("\tAnalog Video Standard\n"); if (descriptor->controls[2] & 2) @@ -496,29 +505,29 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor, } printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->Processing())); - if (descriptor->VideoStandards() & 2) + if (descriptor->VideoStandards()._video_standards.ntsc_525_60) printf("\tNTSC 525/60\n"); - if (descriptor->VideoStandards() & 4) + if (descriptor->VideoStandards()._video_standards.pal_625_50) printf("\tPAL 625/50\n"); - if (descriptor->VideoStandards() & 8) + if (descriptor->VideoStandards()._video_standards.secam_625_50) printf("\tSECAM 625/50\n"); - if (descriptor->VideoStandards() & 16) + if (descriptor->VideoStandards()._video_standards.ntsc_625_50) printf("\tNTSC 625/50\n"); - if (descriptor->VideoStandards() & 32) + if (descriptor->VideoStandards()._video_standards.pal_525_60) printf("\tPAL 525/60\n"); break; } - case VC_EXTENSION_UNIT: + case USB_VIDEO_VC_EXTENSION_UNIT: { - const usbvc_extension_unit_descriptor* descriptor - = (const usbvc_extension_unit_descriptor*)_descriptor; - printf("VC_EXTENSION_UNIT:\tid=%d, guid=", descriptor->unitID); - print_guid(descriptor->guidExtensionCode); - printf("\n\t#ctrls=%d, #pins=%d\n", descriptor->numControls, - descriptor->numInputPins); + const usb_video_extension_unit_descriptor* descriptor + = (const usb_video_extension_unit_descriptor*)_descriptor; + printf("VC_EXTENSION_UNIT:\tid=%d, guid=", descriptor->unit_id); + print_guid(descriptor->guid_extension_code); + printf("\n\t#ctrls=%d, #pins=%d\n", descriptor->num_controls, + descriptor->num_input_pins); printf("\t"); - for (uint8 i = 0; i < descriptor->numInputPins; i++) - printf("%d ", descriptor->sourceID[i]); + for (uint8 i = 0; i < descriptor->num_input_pins; i++) + printf("%d ", descriptor->source_id[i]); printf("\n"); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->Extension())); @@ -564,8 +573,8 @@ UVCCamDevice::SuggestVideoFrame(uint32& width, uint32& height) width = 320; height = 240; if (!AcceptVideoFrame(width, height)) { - const usbvc_frame_descriptor* descriptor - = (const usbvc_frame_descriptor*)fUncompressedFrames.FirstItem(); + const usb_video_frame_descriptor* descriptor + = (const usb_video_frame_descriptor*)fUncompressedFrames.FirstItem(); width = (*descriptor).width; height = (*descriptor).height; } @@ -594,8 +603,8 @@ UVCCamDevice::AcceptVideoFrame(uint32& width, uint32& height) } for (int i = 0; iversion > 0x100 ? 34 : 26; size_t actualLength = fDevice->ControlTransfer( - USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT, SET_CUR, - VS_PROBE_CONTROL << 8, fStreamingIndex, length, &request); + USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT, USB_VIDEO_RC_SET_CUR, + USB_VIDEO_VS_PROBE_CONTROL << 8, fStreamingIndex, length, &request); if (actualLength != length) { fprintf(stderr, "UVCCamDevice::_ProbeFormat() SET_CUR ProbeControl1" " failed %ld\n", actualLength); @@ -656,11 +665,11 @@ UVCCamDevice::_ProbeCommitFormat() */ - usbvc_probecommit response; + usb_video_probe_and_commit_controls response; memset(&response, 0, sizeof(response)); actualLength = fDevice->ControlTransfer( - USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, GET_CUR, - VS_PROBE_CONTROL << 8, fStreamingIndex, length, &response); + USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, USB_VIDEO_RC_GET_CUR, + USB_VIDEO_VS_PROBE_CONTROL << 8, fStreamingIndex, length, &response); /* actualLength = fDevice->ControlTransfer( @@ -674,8 +683,8 @@ UVCCamDevice::_ProbeCommitFormat() */ actualLength = fDevice->ControlTransfer( - USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT, SET_CUR, - VS_COMMIT_CONTROL << 8, fStreamingIndex, length, &request); + USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT, USB_VIDEO_RC_SET_CUR, + USB_VIDEO_VS_COMMIT_CONTROL << 8, fStreamingIndex, length, &request); if (actualLength != length) { fprintf(stderr, "UVCCamDevice::_ProbeFormat() SetCur CommitControl" " failed\n"); @@ -683,8 +692,8 @@ UVCCamDevice::_ProbeCommitFormat() } - fMaxVideoFrameSize = response.maxVideoFrameSize; - fMaxPayloadTransferSize = response.maxPayloadTransferSize; + fMaxVideoFrameSize = response.max_video_frame_size; + fMaxPayloadTransferSize = response.max_payload_transfer_size; printf("usbvc_probecommit setup done maxVideoFrameSize:%" B_PRIu32 "" " maxPayloadTransferSize:%" B_PRIu32 "\n", fMaxVideoFrameSize, fMaxPayloadTransferSize); @@ -765,85 +774,85 @@ UVCCamDevice::_SelectIdleAlternate() void UVCCamDevice::_AddProcessingParameter(BParameterGroup* group, - int32 index, const usbvc_processing_unit_descriptor* descriptor) + int32 index, const usb_video_processing_unit_descriptor* descriptor) { BParameterGroup* subgroup; uint16 wValue = 0; // Control Selector float minValue = 0.0; float maxValue = 100.0; - if (descriptor->controlSize >= 1) { + if (descriptor->control_size >= 1) { if (descriptor->controls[0] & 1) { // debug_printf("\tBRIGHTNESS\n"); fBrightness = _AddParameter(group, &subgroup, index, - PU_BRIGHTNESS_CONTROL, "Brightness"); + USB_VIDEO_PU_BRIGHTNESS_CONTROL, "Brightness"); } if (descriptor->controls[0] & 2) { // debug_printf("\tCONSTRAST\n"); fContrast = _AddParameter(group, &subgroup, index + 1, - PU_CONTRAST_CONTROL, "Contrast"); + USB_VIDEO_PU_CONTRAST_CONTROL, "Contrast"); } if (descriptor->controls[0] & 4) { // debug_printf("\tHUE\n"); fHue = _AddParameter(group, &subgroup, index + 2, - PU_HUE_CONTROL, "Hue"); - if (descriptor->controlSize >= 2) { + USB_VIDEO_PU_HUE_CONTROL, "Hue"); + if (descriptor->control_size >= 2) { if (descriptor->controls[1] & 8) { fHueAuto = _AddAutoParameter(subgroup, index + 3, - PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL); + USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL); } } } if (descriptor->controls[0] & 8) { // debug_printf("\tSATURATION\n"); fSaturation = _AddParameter(group, &subgroup, index + 4, - PU_SATURATION_CONTROL, "Saturation"); + USB_VIDEO_PU_SATURATION_CONTROL, "Saturation"); } if (descriptor->controls[0] & 16) { // debug_printf("\tSHARPNESS\n"); fSharpness = _AddParameter(group, &subgroup, index + 5, - PU_SHARPNESS_CONTROL, "Sharpness"); + USB_VIDEO_PU_SHARPNESS_CONTROL, "Sharpness"); } if (descriptor->controls[0] & 32) { // debug_printf("\tGamma\n"); fGamma = _AddParameter(group, &subgroup, index + 6, - PU_GAMMA_CONTROL, "Gamma"); + USB_VIDEO_PU_GAMMA_CONTROL, "Gamma"); } if (descriptor->controls[0] & 64) { // debug_printf("\tWHITE BALANCE TEMPERATURE\n"); fWBTemp = _AddParameter(group, &subgroup, index + 7, - PU_WHITE_BALANCE_TEMPERATURE_CONTROL, "WB Temperature"); - if (descriptor->controlSize >= 2) { + USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL, "WB Temperature"); + if (descriptor->control_size >= 2) { if (descriptor->controls[1] & 16) { fWBTempAuto = _AddAutoParameter(subgroup, index + 8, - PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL); + USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL); } } } if (descriptor->controls[0] & 128) { // debug_printf("\tWhite Balance Component\n"); fWBComponent = _AddParameter(group, &subgroup, index + 9, - PU_WHITE_BALANCE_COMPONENT_CONTROL, "WB Component"); - if (descriptor->controlSize >= 2) { + USB_VIDEO_PU_WHITE_BALANCE_COMPONENT_CONTROL, "WB Component"); + if (descriptor->control_size >= 2) { if (descriptor->controls[1] & 32) { fWBTempAuto = _AddAutoParameter(subgroup, index + 10, - PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL); + USB_VIDEO_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL); } } } } - if (descriptor->controlSize >= 2) { + if (descriptor->control_size >= 2) { if (descriptor->controls[1] & 1) { // debug_printf("\tBACKLIGHT COMPENSATION\n"); int16 data; - wValue = PU_BACKLIGHT_COMPENSATION_CONTROL << 8; + wValue = USB_VIDEO_PU_BACKLIGHT_COMPENSATION_CONTROL << 8; fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, - GET_MAX, wValue, fControlRequestIndex, sizeof(data), &data); + USB_VIDEO_RC_GET_MAX, wValue, fControlRequestIndex, sizeof(data), &data); maxValue = (float)data; fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, - GET_MIN, wValue, fControlRequestIndex, sizeof(data), &data); + USB_VIDEO_RC_GET_MIN, wValue, fControlRequestIndex, sizeof(data), &data); minValue = (float)data; fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, - GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data); + USB_VIDEO_RC_GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data); fBacklightCompensation = (float)data; subgroup = group->MakeGroup("Backlight Compensation"); if (maxValue - minValue == 1) { // Binary Switch @@ -860,15 +869,16 @@ UVCCamDevice::_AddProcessingParameter(BParameterGroup* group, } if (descriptor->controls[1] & 2) { // debug_printf("\tGAIN\n"); - fGain = _AddParameter(group, &subgroup, index + 12, PU_GAIN_CONTROL, + fGain = _AddParameter(group, &subgroup, index + 12, USB_VIDEO_PU_GAIN_CONTROL, "Gain"); } if (descriptor->controls[1] & 4) { // debug_printf("\tPOWER LINE FREQUENCY\n"); - wValue = PU_POWER_LINE_FREQUENCY_CONTROL << 8; + wValue = USB_VIDEO_PU_POWER_LINE_FREQUENCY_CONTROL << 8; int8 data; if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, - GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data) == sizeof(data)) { + USB_VIDEO_RC_GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data) + == sizeof(data)) { fPowerlineFrequency = data; } subgroup = group->MakeGroup("Power Line Frequency"); @@ -909,17 +919,17 @@ UVCCamDevice::_AddParameter(BParameterGroup* group, wValue <<= 8; if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, - GET_MAX, wValue, fControlRequestIndex, sizeof(data), &data) + USB_VIDEO_RC_GET_MAX, wValue, fControlRequestIndex, sizeof(data), &data) == sizeof(data)) { maxValue = (float)data; } if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, - GET_MIN, wValue, fControlRequestIndex, sizeof(data), &data) + USB_VIDEO_RC_GET_MIN, wValue, fControlRequestIndex, sizeof(data), &data) == sizeof(data)) { minValue = (float)data; } if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, - GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data) + USB_VIDEO_RC_GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data) == sizeof(data)) { currValue = (float)data; } @@ -940,7 +950,7 @@ UVCCamDevice::_AddAutoParameter(BParameterGroup* subgroup, int32 index, wValue <<= 8; fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, - GET_CUR, wValue, fControlRequestIndex, 1, &data); + USB_VIDEO_RC_GET_CUR, wValue, fControlRequestIndex, 1, &data); subgroup->MakeDiscreteParameter(index, B_MEDIA_RAW_VIDEO, "Auto", B_ENABLE); @@ -971,8 +981,8 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index) interface = config->InterfaceAt(j); if (interface == NULL) continue; - if (interface->Class() != CC_VIDEO || interface->Subclass() - != SC_VIDEOCONTROL) + if (interface->Class() != USB_VIDEO_DEVICE_CLASS || interface->Subclass() + != USB_VIDEO_INTERFACE_VIDEOCONTROL_SUBCLASS) continue; for (uint32 k = 0; interface->OtherDescriptorAt(k, generic, sizeof(buffer)) == B_OK; k++) { @@ -981,9 +991,9 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index) continue; if (((const usbvc_class_descriptor*)generic)->descriptorSubtype - == VC_PROCESSING_UNIT) { + == USB_VIDEO_VC_PROCESSING_UNIT) { _AddProcessingParameter(group, index, - (const usbvc_processing_unit_descriptor*)generic); + (const usb_video_processing_unit_descriptor*)generic); } } } @@ -1045,9 +1055,9 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value, // debug_printf("\tWB Temperature:\n"); *size = sizeof(float); currValue = (float*)value; - wValue = PU_WHITE_BALANCE_TEMPERATURE_CONTROL << 8; + wValue = USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL << 8; if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, - GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data) + USB_VIDEO_RC_GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data) == sizeof(data)) { fWBTemp = (float)data; } @@ -1123,35 +1133,35 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value, return B_BAD_VALUE; fBrightness = *((float*)value); fLastParameterChanges = when; - return _SetParameterValue(PU_BRIGHTNESS_CONTROL, (int16)fBrightness); + return _SetParameterValue(USB_VIDEO_PU_BRIGHTNESS_CONTROL, (int16)fBrightness); case 1: // debug_printf("\tContrast:\n"); if (!value || (size != sizeof(float))) return B_BAD_VALUE; fContrast = *((float*)value); fLastParameterChanges = when; - return _SetParameterValue(PU_CONTRAST_CONTROL, (int16)fContrast); + return _SetParameterValue(USB_VIDEO_PU_CONTRAST_CONTROL, (int16)fContrast); case 2: // debug_printf("\tHue:\n"); if (!value || (size != sizeof(float))) return B_BAD_VALUE; fHue = *((float*)value); fLastParameterChanges = when; - return _SetParameterValue(PU_HUE_CONTROL, (int16)fHue); + return _SetParameterValue(USB_VIDEO_PU_HUE_CONTROL, (int16)fHue); case 4: // debug_printf("\tSaturation:\n"); if (!value || (size != sizeof(float))) return B_BAD_VALUE; fSaturation = *((float*)value); fLastParameterChanges = when; - return _SetParameterValue(PU_SATURATION_CONTROL, (int16)fSaturation); + return _SetParameterValue(USB_VIDEO_PU_SATURATION_CONTROL, (int16)fSaturation); case 5: // debug_printf("\tSharpness:\n"); if (!value || (size != sizeof(float))) return B_BAD_VALUE; fSharpness = *((float*)value); fLastParameterChanges = when; - return _SetParameterValue(PU_SHARPNESS_CONTROL, (int16)fSharpness); + return _SetParameterValue(USB_VIDEO_PU_SHARPNESS_CONTROL, (int16)fSharpness); case 7: if (fWBTempAuto) return B_OK; @@ -1160,7 +1170,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value, return B_BAD_VALUE; fWBTemp = *((float*)value); fLastParameterChanges = when; - return _SetParameterValue(PU_WHITE_BALANCE_TEMPERATURE_CONTROL, + return _SetParameterValue(USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL, (int16)fWBTemp); case 8: // debug_printf("\tWB Temperature Auto:\n"); @@ -1169,7 +1179,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value, fWBTempAuto = *((int*)value); fLastParameterChanges = when; return _SetParameterValue( - PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, (int8)fWBTempAuto); + USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, (int8)fWBTempAuto); case 11: if (!fBinaryBacklightCompensation) { // debug_printf("\tBacklight Compensation:\n"); @@ -1183,7 +1193,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value, fBacklightCompensationBinary = *((int*)value); } fLastParameterChanges = when; - return _SetParameterValue(PU_BACKLIGHT_COMPENSATION_CONTROL, + return _SetParameterValue(USB_VIDEO_PU_BACKLIGHT_COMPENSATION_CONTROL, (int16)fBacklightCompensationBinary); case 12: // debug_printf("\tGain:\n"); @@ -1191,7 +1201,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value, return B_BAD_VALUE; fGain = *((float*)value); fLastParameterChanges = when; - return _SetParameterValue(PU_GAIN_CONTROL, (int16)fGain); + return _SetParameterValue(USB_VIDEO_PU_GAIN_CONTROL, (int16)fGain); case 13: // debug_printf("\tPowerline Frequency:\n"); // debug_printf("\tValue = %f\n",*((float*)value)); @@ -1206,7 +1216,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value, fPowerlineFrequency = 2; } fLastParameterChanges = when; - return _SetParameterValue(PU_POWER_LINE_FREQUENCY_CONTROL, + return _SetParameterValue(USB_VIDEO_PU_POWER_LINE_FREQUENCY_CONTROL, (int8)fPowerlineFrequency); } @@ -1218,7 +1228,7 @@ status_t UVCCamDevice::_SetParameterValue(uint16 wValue, int16 setValue) { return (fDevice->ControlTransfer(USB_REQTYPE_CLASS - | USB_REQTYPE_INTERFACE_OUT, SET_CUR, wValue << 8, fControlRequestIndex, + | USB_REQTYPE_INTERFACE_OUT, USB_VIDEO_RC_SET_CUR, wValue << 8, fControlRequestIndex, sizeof(setValue), &setValue)) == sizeof(setValue); } @@ -1227,7 +1237,7 @@ status_t UVCCamDevice::_SetParameterValue(uint16 wValue, int8 setValue) { return (fDevice->ControlTransfer(USB_REQTYPE_CLASS - | USB_REQTYPE_INTERFACE_OUT, SET_CUR, wValue << 8, fControlRequestIndex, + | USB_REQTYPE_INTERFACE_OUT, USB_VIDEO_RC_SET_CUR, wValue << 8, fControlRequestIndex, sizeof(setValue), &setValue)) == sizeof(setValue); } diff --git a/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.h b/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.h index b40ef1fad5..9b60f38bfb 100644 --- a/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.h +++ b/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.h @@ -10,6 +10,7 @@ #include "CamDevice.h" #include "USB_video.h" +#include class UVCCamDevice : public CamDevice { @@ -51,7 +52,7 @@ private: void _AddProcessingParameter(BParameterGroup* group, int32 index, - const usbvc_processing_unit_descriptor* + const usb_video_processing_unit_descriptor* descriptor); float _AddParameter(BParameterGroup* group, BParameterGroup** subgroup, int32 index, diff --git a/src/bin/listusb/usb_video.cpp b/src/bin/listusb/usb_video.cpp index dc9d657b52..94fcf6b734 100644 --- a/src/bin/listusb/usb_video.cpp +++ b/src/bin/listusb/usb_video.cpp @@ -84,7 +84,7 @@ DumpVideoCSInterfaceDescriptorOutputTerminal( descriptor->terminal_type, TerminalTypeName(descriptor->terminal_type)); printf(" Associated Terminal %u\n", - descriptor->assoc_terminal); + descriptor->associated_terminal); printf(" Source ID ......... %u\n", descriptor->source_id); printf(" Terminal .......... %u\n", @@ -94,7 +94,7 @@ DumpVideoCSInterfaceDescriptorOutputTerminal( void DumpVideoCSInterfaceDescriptorInputTerminal( - const usb_video_input_terminal_descriptor* descriptor) + const usb_video_camera_input_terminal_descriptor* descriptor) { printf(" Type .............. 0x%02x\n", descriptor->descriptor_type); @@ -111,11 +111,11 @@ DumpVideoCSInterfaceDescriptorInputTerminal( if (descriptor->terminal_type == USB_VIDEO_CAMERA_IN) { printf(" Min. Focal length . %u\n", - descriptor->camera.focal_length_min); + descriptor->camera.objective_focal_length_min); printf(" Max. Focal length . %u\n", - descriptor->camera.focal_length_min); + descriptor->camera.objective_focal_length_min); printf(" Focal length ...... %u\n", - descriptor->camera.focal_length); + descriptor->camera.ocular_focal_length); printf(" Controls .......... %02x%02x%02x\n", descriptor->camera.controls[0], descriptor->camera.controls[1], @@ -199,9 +199,9 @@ DumpVideoCSInterfaceDescriptorProcessingUnit( } printf("\n"); printf(" Processing ........ %u\n", - descriptor->processing); + descriptor->Processing()); printf(" Video Standards ... 0x%02x\n", - descriptor->video_standards); + descriptor->VideoStandards().video_standards); } @@ -255,7 +255,7 @@ DumpVideoControlCSInterfaceDescriptor(const usb_generic_descriptor* descriptor) break; case USB_VIDEO_VC_INPUT_TERMINAL: DumpVideoCSInterfaceDescriptorInputTerminal( - (usb_video_input_terminal_descriptor*)descriptor); + (usb_video_camera_input_terminal_descriptor*)descriptor); break; case USB_VIDEO_VC_OUTPUT_TERMINAL: DumpVideoCSInterfaceDescriptorOutputTerminal(