uvc_webcam: use shared USB_video.h

The driver had its own header file with definitions from the USB video
specification. Use the system ones already in place for use in listusb.

Also recognize devices which advertise themselves as "miscellaneous" in
the device descriptor, this is the recommended way in the specification
as the usb_video interface may be only part of a device, with other
interfaces and endpoints used for audio or for HID for example.

Change-Id: I7e2e45328dcc1e81c407937e8dd3d77209c5c52a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8581
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
PulkoMandy 2024-11-18 14:05:21 +01:00 committed by waddlesplash
parent 603521ecdc
commit d05ff048a2
7 changed files with 247 additions and 518 deletions

View File

@ -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. * Distributed under terms of the MIT license.
*/ */
@ -171,18 +171,18 @@ enum { // Camera Terminal Control Selectors
enum { // Processing Unit Control Selectors enum { // Processing Unit Control Selectors
USB_VIDEO_PU_CONTROL_UNDEFINED = 0x00, 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_BRIGHTNESS_CONTROL = 0x02,
USB_VIDEO_PU_CONTRAST_CONTROL = 0x03, USB_VIDEO_PU_CONTRAST_CONTROL = 0x03,
USB_VIDEO_PU_GAIN_CONTROL = 0x04, USB_VIDEO_PU_GAIN_CONTROL = 0x04,
USB_VIDEO_PU_POWER_LINE_FREQUENCY_CONTROL = 0x05, USB_VIDEO_PU_POWER_LINE_FREQUENCY_CONTROL = 0x05,
USB_VIDEO_PU_HUE_CONTROL = 0x06, 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_SHARPNESS_CONTROL = 0x08,
USB_VIDEO_PU_GAMMA_CONTROL = 0x09, USB_VIDEO_PU_GAMMA_CONTROL = 0x09,
USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL = 0x0A, USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL = 0x0A,
USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL = 0x0B, 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_WHITE_BALANCE_COMPONENT_AUTO_CONTROL = 0x0D,
USB_VIDEO_PU_DIGITAL_MULTIPLEXER_CONTROL = 0x0E, USB_VIDEO_PU_DIGITAL_MULTIPLEXER_CONTROL = 0x0E,
USB_VIDEO_PU_DIGITAL_MULTIPLEXER_LIMIT_CONTROL = 0x0F, USB_VIDEO_PU_DIGITAL_MULTIPLEXER_LIMIT_CONTROL = 0x0F,
@ -277,9 +277,9 @@ typedef struct {
uint8 descriptor_type; uint8 descriptor_type;
uint8 descriptor_sub_type; uint8 descriptor_sub_type;
uint8 unit_id; uint8 unit_id;
uint8 nr_in_pins; uint8 num_input_pins;
uint8* source_id; uint8 source_id[0];
uint8 selector; uint8 Selector() const { return source_id[num_input_pins]; }
} _PACKED usb_video_selector_unit_descriptor; } _PACKED usb_video_selector_unit_descriptor;
@ -325,26 +325,13 @@ typedef struct {
uint8 unit_id; uint8 unit_id;
uint8 guid_extension_code[16]; uint8 guid_extension_code[16];
uint8 num_controls; uint8 num_controls;
uint8 nr_in_pins; uint8 num_input_pins;
uint8 source_id[0]; uint8 source_id[0];
#if 0
// Remaining part of the structure can't be encoded because source_id has uint8 ControlSize() const { return source_id[num_input_pins]; }
// a variable size const uint8* Controls() const { return &source_id[num_input_pins + 1]; }
uint8 control_size; uint8 Extension() const
struct controls { { return source_id[num_input_pins + ControlSize() + 1]; }
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
} _PACKED usb_video_extension_unit_descriptor; } _PACKED usb_video_extension_unit_descriptor;
@ -405,14 +392,14 @@ typedef struct {
union { union {
struct { struct {
uint16 focal_length_min; uint16 objective_focal_length_min;
uint16 focal_length_max; uint16 objective_focal_length_max;
uint16 focal_length; uint16 ocular_focal_length;
uint8 control_size; uint8 control_size;
uint8 controls[3]; uint8 controls[3];
} _PACKED camera; } _PACKED camera;
}; };
} _PACKED usb_video_input_terminal_descriptor; } _PACKED usb_video_camera_input_terminal_descriptor;
typedef struct { typedef struct {
@ -455,7 +442,7 @@ typedef struct {
update_frame_segment: 1, update_frame_segment: 1,
reserved: 2 // (control_size*8-1): Set to zero. reserved: 2 // (control_size*8-1): Set to zero.
); );
} * _ma_controls; } _ma_controls[0];
} _PACKED usb_video_class_specific_vs_interface_input_header_descriptor; } _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 descriptor_subtype; // USB_VIDEO_VC_OUTPUT_TERMINAL
uint8 terminal_id; uint8 terminal_id;
uint16 terminal_type; uint16 terminal_type;
uint8 assoc_terminal; uint8 associated_terminal;
uint8 source_id; uint8 source_id;
uint8 terminal; uint8 terminal;
} _PACKED usb_video_output_terminal_descriptor; } _PACKED usb_video_output_terminal_descriptor;
@ -500,7 +487,7 @@ typedef struct {
comp_window_size: 1, comp_window_size: 1,
reserved: 4 // (control_size*8-1) Set to zero. reserved: 4 // (control_size*8-1) Set to zero.
); );
} * _ma_controls; } _ma_controls[0];
} _PACKED usb_video_class_specific_vs_interface_output_header_descriptor; } _PACKED usb_video_class_specific_vs_interface_output_header_descriptor;
@ -541,7 +528,7 @@ typedef struct {
B_LBITFIELD16_3 ( B_LBITFIELD16_3 (
analog_video_standard: 1, analog_video_standard: 1,
analog_video_lock_status: 1, analog_video_lock_status: 1,
reserved: 14 // Reserved. Se to zero. reserved: 14 // Reserved. Set to zero.
); );
} _control_b; } _control_b;
} _controls; } _controls;
@ -551,7 +538,7 @@ typedef struct {
B_LBITFIELD16_3 ( B_LBITFIELD16_3 (
analog_video_standard: 1, analog_video_standard: 1,
analog_video_lock_status: 1, analog_video_lock_status: 1,
reserved: 14 // Reserved. Se to zero. reserved: 14 // Reserved. Set to zero.
); );
} _control_b; } _control_b;
struct control_a { struct control_a {
@ -578,8 +565,9 @@ typedef struct {
#endif #endif
uint8_t controls[4]; uint8_t controls[4];
}; };
uint8 processing;
union { uint8 Processing() const { return controls[control_size]; }
typedef union {
struct { struct {
B_LBITFIELD8_8 ( B_LBITFIELD8_8 (
none: 1, none: 1,
@ -593,7 +581,8 @@ typedef struct {
); );
} _video_standards; } _video_standards;
uint8_t 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; } _PACKED usb_video_processing_unit_descriptor;
@ -693,7 +682,7 @@ typedef struct {
union { union {
struct { struct {
uint32 min_frame_interval; uint32 min_frame_interval;
uint32 max_frame_tnterval; uint32 max_frame_interval;
uint32 frame_interval_step; uint32 frame_interval_step;
} continuous; } continuous;
uint32 discrete_frame_intervals[0]; uint32 discrete_frame_intervals[0];
@ -702,7 +691,6 @@ typedef struct {
typedef struct { typedef struct {
uint8 length; // 34 bytes
struct hint { struct hint {
B_LBITFIELD16_5 ( B_LBITFIELD16_5 (
frame_interval: 1, frame_interval: 1,
@ -733,7 +721,7 @@ typedef struct {
uint8 prefered_version; uint8 prefered_version;
uint8 min_version; uint8 min_version;
uint8 max_version; uint8 max_version;
} _PACKED usb_video_video_probe_and_commit_controls; } _PACKED usb_video_probe_and_commit_controls;
typedef struct { typedef struct {
@ -755,9 +743,12 @@ typedef struct {
struct pattern_size { struct pattern_size {
uint16 width; uint16 width;
uint16 height; uint16 height;
} * _pattern_size; } _pattern_size[0];
uint8 num_compression_pattern; uint8 NumCompressionPatterns() const { return *(CompressionPatterns() - 1); }
uint8* compression; 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; } _PACKED usb_video_still_image_frame_descriptor;

View File

@ -142,8 +142,9 @@ status_t
CamRoster::LoadExternalAddons() CamRoster::LoadExternalAddons()
{ {
PRINT((CH "()" CT)); PRINT((CH "()" CT));
// FIXME // TODO implement external add-ons
return B_ERROR; return B_ERROR;
#if 0
int32 index; int32 index;
int32 sclass; int32 sclass;
status_t err; status_t err;
@ -162,6 +163,7 @@ CamRoster::LoadExternalAddons()
err)); err));
} }
return B_OK; return B_OK;
#endif
} }

View File

@ -1,5 +1,7 @@
SubDir HAIKU_TOP src add-ons media media-add-ons usb_webcam ; SubDir HAIKU_TOP src add-ons media media-add-ons usb_webcam ;
UsePrivateHeaders drivers ;
usbKitLibraryName = libdevice.so ; usbKitLibraryName = libdevice.so ;
# source directories # source directories

View File

@ -7,156 +7,16 @@
#define _USB_VIDEO_H #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_CONTROL_UNDEFINED 0x0
#define VC_VIDEO_POWER_MODE_CONTROL 0x1 #define VC_VIDEO_POWER_MODE_CONTROL 0x1
#define VC_REQUEST_ERROR_CODE_CONTROL 0x2 #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 { typedef struct usbvc_class_descriptor {
uint8 length; uint8 length;
uint8 descriptorType; uint8 descriptorType;
uint8 descriptorSubtype; uint8 descriptorSubtype;
} _PACKED usbvc_class_descriptor; } _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]; typedef uint8 usbvc_guid[16];
struct usbvc_format_descriptor { struct usbvc_format_descriptor {
@ -186,58 +46,6 @@ struct usbvc_format_descriptor {
}; };
} _PACKED; } _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 { struct usbvc_interface_header_descriptor {
uint8 length; uint8 length;
uint8 descriptorType; uint8 descriptorType;
@ -259,90 +67,5 @@ struct usbvc_input_terminal_descriptor {
uint8 terminal; uint8 terminal;
} _PACKED; } _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 */ #endif /* _USB_VIDEO_H */

View File

@ -17,7 +17,8 @@
usb_webcam_support_descriptor kSupportedDevices[] = { usb_webcam_support_descriptor kSupportedDevices[] = {
// ofcourse we support a generic UVC device... // 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: // ...whilst the following IDs were 'stolen' from a recent Linux driver:
{{ 0, 0, 0, 0x045e, 0x00f8, }, "Microsoft", "Lifecam NX-6000", "??" }, {{ 0, 0, 0, 0x045e, 0x00f8, }, "Microsoft", "Lifecam NX-6000", "??" },
{{ 0, 0, 0, 0x045e, 0x0723, }, "Microsoft", "Lifecam VX-7000", "??" }, {{ 0, 0, 0, 0x045e, 0x0723, }, "Microsoft", "Lifecam VX-7000", "??" },
@ -91,8 +92,8 @@ UVCCamDevice::UVCCamDevice(CamDeviceAddon& _addon, BUSBDevice* _device)
if (interface == NULL) if (interface == NULL)
continue; continue;
if (interface->Class() == CC_VIDEO && interface->Subclass() if (interface->Class() == USB_VIDEO_DEVICE_CLASS && interface->Subclass()
== SC_VIDEOCONTROL) { == USB_VIDEO_INTERFACE_VIDEOCONTROL_SUBCLASS) {
printf("UVCCamDevice: (%" B_PRIu32 ",%" B_PRIu32 "): Found Video Control " printf("UVCCamDevice: (%" B_PRIu32 ",%" B_PRIu32 "): Found Video Control "
"interface.\n", i, j); "interface.\n", i, j);
@ -114,8 +115,8 @@ UVCCamDevice::UVCCamDevice(CamDeviceAddon& _addon, BUSBDevice* _device)
} }
} }
fInitStatus = B_OK; fInitStatus = B_OK;
} else if (interface->Class() == CC_VIDEO && interface->Subclass() } else if (interface->Class() == USB_VIDEO_DEVICE_CLASS && interface->Subclass()
== SC_VIDEOSTREAMING) { == USB_VIDEO_INTERFACE_VIDEOSTREAMING_SUBCLASS) {
printf("UVCCamDevice: (%" B_PRIu32 ",%" B_PRIu32 "): Found Video Streaming " printf("UVCCamDevice: (%" B_PRIu32 ",%" B_PRIu32 "): Found Video Streaming "
"interface.\n", i, j); "interface.\n", i, j);
@ -154,34 +155,38 @@ UVCCamDevice::_ParseVideoStreaming(const usbvc_class_descriptor* _descriptor,
size_t len) size_t len)
{ {
switch (_descriptor->descriptorSubtype) { switch (_descriptor->descriptorSubtype) {
case VS_INPUT_HEADER: case USB_VIDEO_VS_INPUT_HEADER:
{ {
const usbvc_input_header_descriptor* descriptor const usb_video_class_specific_vs_interface_input_header_descriptor* descriptor
= (const usbvc_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\n", descriptor->numFormats, printf("VS_INPUT_HEADER:\t#fmts=%d,ept=0x%x (%s)\n", descriptor->num_formats,
descriptor->endpointAddress); descriptor->_endpoint_address.endpoint_number,
if (descriptor->info & 1) descriptor->_endpoint_address.direction ? "IN" : "OUT");
if (descriptor->_info.dynamic_format_change_support)
printf("\tDynamic Format Change supported\n"); printf("\tDynamic Format Change supported\n");
printf("\toutput terminal id=%d\n", descriptor->terminalLink); printf("\toutput terminal id=%d\n", descriptor->terminal_link);
printf("\tstill capture method=%d\n", descriptor->stillCaptureMethod); printf("\tstill capture method=%d\n", descriptor->still_capture_method);
if (descriptor->triggerSupport) { if (descriptor->trigger_support) {
printf("\ttrigger button fixed to still capture=%s\n", printf("\ttrigger button fixed to still capture=%s\n",
descriptor->triggerUsage ? "no" : "yes"); descriptor->trigger_usage ? "no" : "yes");
} }
const uint8* controls = descriptor->controls; const struct usb_video_class_specific_vs_interface_input_header_descriptor::ma_controls*
for (uint8 i = 0; i < descriptor->numFormats; i++, controls = descriptor->_ma_controls;
controls += descriptor->controlSize) { 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, printf("\tfmt%d: %s %s %s %s - %s %s\n", i,
(*controls & 1) ? "wKeyFrameRate" : "", (controls->key_frame_rate) ? "wKeyFrameRate" : "",
(*controls & 2) ? "wPFrameRate" : "", (controls->p_frame_rate) ? "wPFrameRate" : "",
(*controls & 4) ? "wCompQuality" : "", (controls->comp_quality) ? "wCompQuality" : "",
(*controls & 8) ? "wCompWindowSize" : "", (controls->comp_window_size) ? "wCompWindowSize" : "",
(*controls & 16) ? "<Generate Key Frame>" : "", (controls->generate_key_frame) ? "<Generate Key Frame>" : "",
(*controls & 32) ? "<Update Frame Segment>" : ""); (controls->update_frame_segment) ? "<Update Frame Segment>" : "");
} }
break; break;
} }
case VS_FORMAT_UNCOMPRESSED: case USB_VIDEO_VS_FORMAT_UNCOMPRESSED:
{ {
const usbvc_format_descriptor* descriptor const usbvc_format_descriptor* descriptor
= (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"); printf("\tRestrict duplication\n");
break; break;
} }
case VS_FRAME_MJPEG: case USB_VIDEO_VS_FRAME_MJPEG:
case VS_FRAME_UNCOMPRESSED: case USB_VIDEO_VS_FRAME_UNCOMPRESSED:
{ {
const usbvc_frame_descriptor* descriptor const usb_video_frame_descriptor* descriptor
= (const usbvc_frame_descriptor*)_descriptor; = (const usb_video_frame_descriptor*)_descriptor;
if (_descriptor->descriptorSubtype == VS_FRAME_UNCOMPRESSED) { if (_descriptor->descriptorSubtype == USB_VIDEO_VS_FRAME_UNCOMPRESSED) {
printf("VS_FRAME_UNCOMPRESSED:"); printf("VS_FRAME_UNCOMPRESSED:");
fUncompressedFrames.AddItem( fUncompressedFrames.AddItem(
new usbvc_frame_descriptor(*descriptor)); new usb_video_frame_descriptor(*descriptor));
} else { } else {
printf("VS_FRAME_MJPEG:"); printf("VS_FRAME_MJPEG:");
fMJPEGFrames.AddItem(new usbvc_frame_descriptor(*descriptor)); fMJPEGFrames.AddItem(new usb_video_frame_descriptor(*descriptor));
} }
printf("\tbFrameIdx=%d,stillsupported=%s," printf("\tbFrameIdx=%d,stillsupported=%s,"
"fixedframerate=%s\n", descriptor->frameIndex, "fixedframerate=%s\n", descriptor->frame_index,
(descriptor->capabilities & 1) ? "yes" : "no", (descriptor->capabilities & 1) ? "yes" : "no",
(descriptor->capabilities & 2) ? "yes" : "no"); (descriptor->capabilities & 2) ? "yes" : "no");
printf("\twidth=%u,height=%u,min/max bitrate=%" B_PRIu32 "/%" B_PRIu32 ", maxbuf=%" B_PRIu32 "\n", printf("\twidth=%u,height=%u,min/max bitrate=%" B_PRIu32 "/%" B_PRIu32 ", maxbuf=%" B_PRIu32 "\n",
descriptor->width, descriptor->height, descriptor->width, descriptor->height,
descriptor->minBitRate, descriptor->maxBitRate, descriptor->min_bit_rate, descriptor->max_bit_rate,
descriptor->maxVideoFrameBufferSize); descriptor->max_video_frame_buffer_size);
printf("\tdefault frame interval: %" B_PRIu32 ", #intervals(0=cont): %d\n", printf("\tdefault frame interval: %" B_PRIu32 ", #intervals(0=cont): %d\n",
descriptor->defaultFrameInterval, descriptor->frameIntervalType); descriptor->default_frame_interval, descriptor->frame_interval_type);
if (descriptor->frameIntervalType == 0) { if (descriptor->frame_interval_type == 0) {
printf("min/max frame interval=%" B_PRIu32 "/%" B_PRIu32 ", step=%" B_PRIu32 "\n", printf("min/max frame interval=%" B_PRIu32 "/%" B_PRIu32 ", step=%" B_PRIu32 "\n",
descriptor->continuous.minFrameInterval, descriptor->continuous.min_frame_interval,
descriptor->continuous.maxFrameInterval, descriptor->continuous.max_frame_interval,
descriptor->continuous.frameIntervalStep); descriptor->continuous.frame_interval_step);
} else for (uint8 i = 0; i < descriptor->frameIntervalType; i++) { } else for (uint8 i = 0; i < descriptor->frame_interval_type; i++) {
printf("\tdiscrete frame interval: %" B_PRIu32 "\n", printf("\tdiscrete frame interval: %" B_PRIu32 "\n",
descriptor->discreteFrameIntervals[i]); descriptor->discrete_frame_intervals[i]);
} }
break; break;
} }
case VS_COLORFORMAT: case USB_VIDEO_VS_COLORFORMAT:
{ {
const usbvc_color_matching_descriptor* descriptor const usb_video_color_matching_descriptor* descriptor
= (const usbvc_color_matching_descriptor*)_descriptor; = (const usb_video_color_matching_descriptor*)_descriptor;
printf("VS_COLORFORMAT:\n\tbColorPrimaries: "); printf("VS_COLORFORMAT:\n\tbColorPrimaries: ");
switch (descriptor->colorPrimaries) { switch (descriptor->color_primaries) {
case 0: printf("Unspecified\n"); break; case 0: printf("Unspecified\n"); break;
case 1: printf("BT.709,sRGB\n"); break; case 1: printf("BT.709,sRGB\n"); break;
case 2: printf("BT.470-2(M)\n"); break; case 2: printf("BT.470-2(M)\n"); break;
case 3: printf("BT.470-2(B,G)\n"); break; case 3: printf("BT.470-2(B,G)\n"); break;
case 4: printf("SMPTE 170M\n"); break; case 4: printf("SMPTE 170M\n"); break;
case 5: printf("SMPTE 240M\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: "); printf("\tbTransferCharacteristics: ");
switch (descriptor->transferCharacteristics) { switch (descriptor->transfer_characteristics) {
case 0: printf("Unspecified\n"); break; case 0: printf("Unspecified\n"); break;
case 1: printf("BT.709\n"); break; case 1: printf("BT.709\n"); break;
case 2: printf("BT.470-2(M)\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 6: printf("Linear (V=Lc)\n"); break;
case 7: printf("sRGB\n"); break; case 7: printf("sRGB\n"); break;
default: printf("Invalid (%d)\n", default: printf("Invalid (%d)\n",
descriptor->transferCharacteristics); descriptor->transfer_characteristics);
} }
printf("\tbMatrixCoefficients: "); printf("\tbMatrixCoefficients: ");
switch (descriptor->matrixCoefficients) { switch (descriptor->matrix_coefficients) {
case 0: printf("Unspecified\n"); break; case 0: printf("Unspecified\n"); break;
case 1: printf("BT.709\n"); break; case 1: printf("BT.709\n"); break;
case 2: printf("FCC\n"); break; case 2: printf("FCC\n"); break;
case 3: printf("BT.470-2(B,G)\n"); break; case 3: printf("BT.470-2(B,G)\n"); break;
case 4: printf("SMPTE 170M (BT.601)\n"); break; case 4: printf("SMPTE 170M (BT.601)\n"); break;
case 5: printf("SMPTE 240M\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; break;
} }
case VS_OUTPUT_HEADER: case USB_VIDEO_VS_OUTPUT_HEADER:
{ {
const usbvc_output_header_descriptor* descriptor const usb_video_class_specific_vs_interface_output_header_descriptor* descriptor
= (const usbvc_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\n", printf("VS_OUTPUT_HEADER:\t#fmts=%d,ept=0x%x (%s)\n",
descriptor->numFormats, descriptor->endpointAddress); descriptor->num_formats, descriptor->_endpoint_address.endpoint_number,
printf("\toutput terminal id=%d\n", descriptor->terminalLink); descriptor->_endpoint_address.direction ? "IN" : "OUT");
const uint8* controls = descriptor->controls; printf("\toutput terminal id=%d\n", descriptor->terminal_link);
for (uint8 i = 0; i < descriptor->numFormats; i++, const struct usb_video_class_specific_vs_interface_output_header_descriptor::ma_controls*
controls += descriptor->controlSize) { 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, printf("\tfmt%d: %s %s %s %s\n", i,
(*controls & 1) ? "wKeyFrameRate" : "", (controls->key_frame_rate) ? "wKeyFrameRate" : "",
(*controls & 2) ? "wPFrameRate" : "", (controls->p_frame_rate) ? "wPFrameRate" : "",
(*controls & 4) ? "wCompQuality" : "", (controls->comp_quality) ? "wCompQuality" : "",
(*controls & 8) ? "wCompWindowSize" : ""); (controls->comp_window_size) ? "wCompWindowSize" : "");
} }
break; break;
} }
case VS_STILL_IMAGE_FRAME: case USB_VIDEO_VS_STILL_IMAGE_FRAME:
{ {
const usbvc_still_image_frame_descriptor* descriptor const usb_video_still_image_frame_descriptor* descriptor
= (const usbvc_still_image_frame_descriptor*)_descriptor; = (const usb_video_still_image_frame_descriptor*)_descriptor;
printf("VS_STILL_IMAGE_FRAME:\t#imageSizes=%d,compressions=%d," 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->NumCompressionPatterns(),
descriptor->endpointAddress); descriptor->endpoint_address);
for (uint8 i = 0; i < descriptor->numImageSizePatterns; i++) { for (uint8 i = 0; i < descriptor->num_image_size_patterns; i++) {
printf("imageSize%d: %dx%d\n", i, printf("imageSize%d: %dx%d\n", i,
descriptor->imageSizePatterns[i].width, descriptor->_pattern_size[i].width,
descriptor->imageSizePatterns[i].height); descriptor->_pattern_size[i].height);
} }
for (uint8 i = 0; i < descriptor->NumCompressionPatterns(); i++) { for (uint8 i = 0; i < descriptor->NumCompressionPatterns(); i++) {
printf("compression%d: %d\n", i, printf("compression%d: %d\n", i,
@ -322,7 +331,7 @@ UVCCamDevice::_ParseVideoStreaming(const usbvc_class_descriptor* _descriptor,
} }
break; break;
} }
case VS_FORMAT_MJPEG: case USB_VIDEO_VS_FORMAT_MJPEG:
{ {
const usbvc_format_descriptor* descriptor const usbvc_format_descriptor* descriptor
= (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"); printf("\tRestrict duplication\n");
break; break;
} }
case VS_FORMAT_MPEG2TS: case USB_VIDEO_VS_FORMAT_MPEG2TS:
printf("VS_FORMAT_MPEG2TS:\t\n"); printf("VS_FORMAT_MPEG2TS:\t\n");
break; break;
case VS_FORMAT_DV: case USB_VIDEO_VS_FORMAT_DV:
printf("VS_FORMAT_DV:\t\n"); printf("VS_FORMAT_DV:\t\n");
break; break;
case VS_FORMAT_FRAME_BASED: case USB_VIDEO_VS_FORMAT_FRAME_BASED:
printf("VS_FORMAT_FRAME_BASED:\t\n"); printf("VS_FORMAT_FRAME_BASED:\t\n");
break; break;
case VS_FRAME_FRAME_BASED: case USB_VIDEO_VS_FRAME_FRAME_BASED:
printf("VS_FRAME_FRAME_BASED:\t\n"); printf("VS_FRAME_FRAME_BASED:\t\n");
break; break;
case VS_FORMAT_STREAM_BASED: case USB_VIDEO_VS_FORMAT_STREAM_BASED:
printf("VS_FORMAT_STREAM_BASED:\t\n"); printf("VS_FORMAT_STREAM_BASED:\t\n");
break; break;
default: default:
@ -379,7 +388,7 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor,
size_t len) size_t len)
{ {
switch (_descriptor->descriptorSubtype) { switch (_descriptor->descriptorSubtype) {
case VC_HEADER: case USB_VIDEO_VC_HEADER:
{ {
if (fHeaderDescriptor != NULL) { if (fHeaderDescriptor != NULL) {
printf("ERROR: multiple VC_HEADER! Skipping...\n"); printf("ERROR: multiple VC_HEADER! Skipping...\n");
@ -397,7 +406,7 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor,
} }
break; break;
} }
case VC_INPUT_TERMINAL: case USB_VIDEO_VC_INPUT_TERMINAL:
{ {
const usbvc_input_terminal_descriptor* descriptor const usbvc_input_terminal_descriptor* descriptor
= (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", printf("\tDesc: %s\n",
fDevice->DecodeStringDescriptor(descriptor->terminal)); fDevice->DecodeStringDescriptor(descriptor->terminal));
if (descriptor->terminalType == 0x201) { if (descriptor->terminalType == 0x201) {
const usbvc_camera_terminal_descriptor* desc const usb_video_camera_terminal_descriptor* desc
= (const usbvc_camera_terminal_descriptor*)descriptor; = (const usb_video_camera_terminal_descriptor*)descriptor;
printf("\tObjectiveFocalLength Min/Max %d/%d\n", printf("\tObjectiveFocalLength Min/Max %d/%d\n",
desc->objectiveFocalLengthMin, desc->objective_focal_length_min,
desc->objectiveFocalLengthMax); desc->objective_focal_length_max);
printf("\tOcularFocalLength %d\n", desc->ocularFocalLength); printf("\tOcularFocalLength %d\n", desc->ocular_focal_length);
printf("\tControlSize %d\n", desc->controlSize); printf("\tControlSize %d\n", desc->control_size);
} }
break; break;
} }
case VC_OUTPUT_TERMINAL: case USB_VIDEO_VC_OUTPUT_TERMINAL:
{ {
const usbvc_output_terminal_descriptor* descriptor const usb_video_output_terminal_descriptor* descriptor
= (const usbvc_output_terminal_descriptor*)_descriptor; = (const usb_video_output_terminal_descriptor*)_descriptor;
printf("VC_OUTPUT_TERMINAL:\tid=%d,type=%04x,associated terminal=" printf("VC_OUTPUT_TERMINAL:\tid=%d,type=%04x,associated terminal="
"%d, src id=%d\n", descriptor->terminalID, "%d, src id=%d\n", descriptor->terminal_id,
descriptor->terminalType, descriptor->associatedTerminal, descriptor->terminal_type, descriptor->associated_terminal,
descriptor->sourceID); descriptor->source_id);
printf("\tDesc: %s\n", printf("\tDesc: %s\n",
fDevice->DecodeStringDescriptor(descriptor->terminal)); fDevice->DecodeStringDescriptor(descriptor->terminal));
break; break;
} }
case VC_SELECTOR_UNIT: case USB_VIDEO_VC_SELECTOR_UNIT:
{ {
const usbvc_selector_unit_descriptor* descriptor const usb_video_selector_unit_descriptor* descriptor
= (const usbvc_selector_unit_descriptor*)_descriptor; = (const usb_video_selector_unit_descriptor*)_descriptor;
printf("VC_SELECTOR_UNIT:\tid=%d,#pins=%d\n", printf("VC_SELECTOR_UNIT:\tid=%d,#pins=%d\n",
descriptor->unitID, descriptor->numInputPins); descriptor->unit_id, descriptor->num_input_pins);
printf("\t"); printf("\t");
for (uint8 i = 0; i < descriptor->numInputPins; i++) for (uint8 i = 0; i < descriptor->num_input_pins; i++)
printf("%d ", descriptor->sourceID[i]); printf("%d ", descriptor->source_id[i]);
printf("\n"); printf("\n");
printf("\tDesc: %s\n", printf("\tDesc: %s\n",
fDevice->DecodeStringDescriptor(descriptor->Selector())); fDevice->DecodeStringDescriptor(descriptor->Selector()));
break; break;
} }
case VC_PROCESSING_UNIT: case USB_VIDEO_VC_PROCESSING_UNIT:
{ {
const usbvc_processing_unit_descriptor* descriptor const usb_video_processing_unit_descriptor* descriptor
= (const usbvc_processing_unit_descriptor*)_descriptor; = (const usb_video_processing_unit_descriptor*)_descriptor;
fControlRequestIndex = fControlIndex + (descriptor->unitID << 8); fControlRequestIndex = fControlIndex + (descriptor->unit_id << 8);
printf("VC_PROCESSING_UNIT:\t unit id=%d,src id=%d, digmul=%d\n", printf("VC_PROCESSING_UNIT:\t unit id=%d,src id=%d, digmul=%d\n",
descriptor->unitID, descriptor->sourceID, descriptor->unit_id, descriptor->source_id,
descriptor->maxMultiplier); descriptor->max_multiplier);
printf("\tbControlSize=%d\n", descriptor->controlSize); printf("\tbControlSize=%d\n", descriptor->control_size);
if (descriptor->controlSize >= 1) { if (descriptor->control_size >= 1) {
if (descriptor->controls[0] & 1) if (descriptor->controls[0] & 1)
printf("\tBrightness\n"); printf("\tBrightness\n");
if (descriptor->controls[0] & 2) if (descriptor->controls[0] & 2)
@ -470,7 +479,7 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor,
if (descriptor->controls[0] & 128) if (descriptor->controls[0] & 128)
printf("\tWhite Balance Component\n"); printf("\tWhite Balance Component\n");
} }
if (descriptor->controlSize >= 2) { if (descriptor->control_size >= 2) {
if (descriptor->controls[1] & 1) if (descriptor->controls[1] & 1)
printf("\tBacklight Compensation\n"); printf("\tBacklight Compensation\n");
if (descriptor->controls[1] & 2) if (descriptor->controls[1] & 2)
@ -488,7 +497,7 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor,
if (descriptor->controls[1] & 128) if (descriptor->controls[1] & 128)
printf("\tDigital Multiplier Limit\n"); printf("\tDigital Multiplier Limit\n");
} }
if (descriptor->controlSize >= 3) { if (descriptor->control_size >= 3) {
if (descriptor->controls[2] & 1) if (descriptor->controls[2] & 1)
printf("\tAnalog Video Standard\n"); printf("\tAnalog Video Standard\n");
if (descriptor->controls[2] & 2) if (descriptor->controls[2] & 2)
@ -496,29 +505,29 @@ UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor,
} }
printf("\tDesc: %s\n", printf("\tDesc: %s\n",
fDevice->DecodeStringDescriptor(descriptor->Processing())); fDevice->DecodeStringDescriptor(descriptor->Processing()));
if (descriptor->VideoStandards() & 2) if (descriptor->VideoStandards()._video_standards.ntsc_525_60)
printf("\tNTSC 525/60\n"); printf("\tNTSC 525/60\n");
if (descriptor->VideoStandards() & 4) if (descriptor->VideoStandards()._video_standards.pal_625_50)
printf("\tPAL 625/50\n"); printf("\tPAL 625/50\n");
if (descriptor->VideoStandards() & 8) if (descriptor->VideoStandards()._video_standards.secam_625_50)
printf("\tSECAM 625/50\n"); printf("\tSECAM 625/50\n");
if (descriptor->VideoStandards() & 16) if (descriptor->VideoStandards()._video_standards.ntsc_625_50)
printf("\tNTSC 625/50\n"); printf("\tNTSC 625/50\n");
if (descriptor->VideoStandards() & 32) if (descriptor->VideoStandards()._video_standards.pal_525_60)
printf("\tPAL 525/60\n"); printf("\tPAL 525/60\n");
break; break;
} }
case VC_EXTENSION_UNIT: case USB_VIDEO_VC_EXTENSION_UNIT:
{ {
const usbvc_extension_unit_descriptor* descriptor const usb_video_extension_unit_descriptor* descriptor
= (const usbvc_extension_unit_descriptor*)_descriptor; = (const usb_video_extension_unit_descriptor*)_descriptor;
printf("VC_EXTENSION_UNIT:\tid=%d, guid=", descriptor->unitID); printf("VC_EXTENSION_UNIT:\tid=%d, guid=", descriptor->unit_id);
print_guid(descriptor->guidExtensionCode); print_guid(descriptor->guid_extension_code);
printf("\n\t#ctrls=%d, #pins=%d\n", descriptor->numControls, printf("\n\t#ctrls=%d, #pins=%d\n", descriptor->num_controls,
descriptor->numInputPins); descriptor->num_input_pins);
printf("\t"); printf("\t");
for (uint8 i = 0; i < descriptor->numInputPins; i++) for (uint8 i = 0; i < descriptor->num_input_pins; i++)
printf("%d ", descriptor->sourceID[i]); printf("%d ", descriptor->source_id[i]);
printf("\n"); printf("\n");
printf("\tDesc: %s\n", printf("\tDesc: %s\n",
fDevice->DecodeStringDescriptor(descriptor->Extension())); fDevice->DecodeStringDescriptor(descriptor->Extension()));
@ -564,8 +573,8 @@ UVCCamDevice::SuggestVideoFrame(uint32& width, uint32& height)
width = 320; width = 320;
height = 240; height = 240;
if (!AcceptVideoFrame(width, height)) { if (!AcceptVideoFrame(width, height)) {
const usbvc_frame_descriptor* descriptor const usb_video_frame_descriptor* descriptor
= (const usbvc_frame_descriptor*)fUncompressedFrames.FirstItem(); = (const usb_video_frame_descriptor*)fUncompressedFrames.FirstItem();
width = (*descriptor).width; width = (*descriptor).width;
height = (*descriptor).height; height = (*descriptor).height;
} }
@ -594,8 +603,8 @@ UVCCamDevice::AcceptVideoFrame(uint32& width, uint32& height)
} }
for (int i = 0; i<fUncompressedFrames.CountItems(); i++) { for (int i = 0; i<fUncompressedFrames.CountItems(); i++) {
const usbvc_frame_descriptor* descriptor const usb_video_frame_descriptor* descriptor
= (const usbvc_frame_descriptor*)fUncompressedFrames.ItemAt(i); = (const usb_video_frame_descriptor*)fUncompressedFrames.ItemAt(i);
if ((*descriptor).width == width && (*descriptor).height == height) { if ((*descriptor).width == width && (*descriptor).height == height) {
fUncompressedFrameIndex = i; fUncompressedFrameIndex = i;
SetVideoFrame(BRect(0, 0, width - 1, height - 1)); SetVideoFrame(BRect(0, 0, width - 1, height - 1));
@ -624,16 +633,16 @@ UVCCamDevice::_ProbeCommitFormat()
printf("Error code = Ox%x\n", error); printf("Error code = Ox%x\n", error);
*/ */
usbvc_probecommit request; usb_video_probe_and_commit_controls request;
memset(&request, 0, sizeof(request)); memset(&request, 0, sizeof(request));
request.hint = 1; request._hint.frame_interval = 1;
request.SetFrameInterval(333333); request.frame_interval = 333333;
request.formatIndex = fUncompressedFormatIndex; request.format_index = fUncompressedFormatIndex;
request.frameIndex = fUncompressedFrameIndex; request.frame_index = fUncompressedFrameIndex;
size_t length = fHeaderDescriptor->version > 0x100 ? 34 : 26; size_t length = fHeaderDescriptor->version > 0x100 ? 34 : 26;
size_t actualLength = fDevice->ControlTransfer( size_t actualLength = fDevice->ControlTransfer(
USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT, SET_CUR, USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT, USB_VIDEO_RC_SET_CUR,
VS_PROBE_CONTROL << 8, fStreamingIndex, length, &request); USB_VIDEO_VS_PROBE_CONTROL << 8, fStreamingIndex, length, &request);
if (actualLength != length) { if (actualLength != length) {
fprintf(stderr, "UVCCamDevice::_ProbeFormat() SET_CUR ProbeControl1" fprintf(stderr, "UVCCamDevice::_ProbeFormat() SET_CUR ProbeControl1"
" failed %ld\n", actualLength); " 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)); memset(&response, 0, sizeof(response));
actualLength = fDevice->ControlTransfer( actualLength = fDevice->ControlTransfer(
USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, GET_CUR, USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, USB_VIDEO_RC_GET_CUR,
VS_PROBE_CONTROL << 8, fStreamingIndex, length, &response); USB_VIDEO_VS_PROBE_CONTROL << 8, fStreamingIndex, length, &response);
/* /*
actualLength = fDevice->ControlTransfer( actualLength = fDevice->ControlTransfer(
@ -674,8 +683,8 @@ UVCCamDevice::_ProbeCommitFormat()
*/ */
actualLength = fDevice->ControlTransfer( actualLength = fDevice->ControlTransfer(
USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT, SET_CUR, USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT, USB_VIDEO_RC_SET_CUR,
VS_COMMIT_CONTROL << 8, fStreamingIndex, length, &request); USB_VIDEO_VS_COMMIT_CONTROL << 8, fStreamingIndex, length, &request);
if (actualLength != length) { if (actualLength != length) {
fprintf(stderr, "UVCCamDevice::_ProbeFormat() SetCur CommitControl" fprintf(stderr, "UVCCamDevice::_ProbeFormat() SetCur CommitControl"
" failed\n"); " failed\n");
@ -683,8 +692,8 @@ UVCCamDevice::_ProbeCommitFormat()
} }
fMaxVideoFrameSize = response.maxVideoFrameSize; fMaxVideoFrameSize = response.max_video_frame_size;
fMaxPayloadTransferSize = response.maxPayloadTransferSize; fMaxPayloadTransferSize = response.max_payload_transfer_size;
printf("usbvc_probecommit setup done maxVideoFrameSize:%" B_PRIu32 "" printf("usbvc_probecommit setup done maxVideoFrameSize:%" B_PRIu32 ""
" maxPayloadTransferSize:%" B_PRIu32 "\n", fMaxVideoFrameSize, " maxPayloadTransferSize:%" B_PRIu32 "\n", fMaxVideoFrameSize,
fMaxPayloadTransferSize); fMaxPayloadTransferSize);
@ -765,85 +774,85 @@ UVCCamDevice::_SelectIdleAlternate()
void void
UVCCamDevice::_AddProcessingParameter(BParameterGroup* group, UVCCamDevice::_AddProcessingParameter(BParameterGroup* group,
int32 index, const usbvc_processing_unit_descriptor* descriptor) int32 index, const usb_video_processing_unit_descriptor* descriptor)
{ {
BParameterGroup* subgroup; BParameterGroup* subgroup;
uint16 wValue = 0; // Control Selector uint16 wValue = 0; // Control Selector
float minValue = 0.0; float minValue = 0.0;
float maxValue = 100.0; float maxValue = 100.0;
if (descriptor->controlSize >= 1) { if (descriptor->control_size >= 1) {
if (descriptor->controls[0] & 1) { if (descriptor->controls[0] & 1) {
// debug_printf("\tBRIGHTNESS\n"); // debug_printf("\tBRIGHTNESS\n");
fBrightness = _AddParameter(group, &subgroup, index, fBrightness = _AddParameter(group, &subgroup, index,
PU_BRIGHTNESS_CONTROL, "Brightness"); USB_VIDEO_PU_BRIGHTNESS_CONTROL, "Brightness");
} }
if (descriptor->controls[0] & 2) { if (descriptor->controls[0] & 2) {
// debug_printf("\tCONSTRAST\n"); // debug_printf("\tCONSTRAST\n");
fContrast = _AddParameter(group, &subgroup, index + 1, fContrast = _AddParameter(group, &subgroup, index + 1,
PU_CONTRAST_CONTROL, "Contrast"); USB_VIDEO_PU_CONTRAST_CONTROL, "Contrast");
} }
if (descriptor->controls[0] & 4) { if (descriptor->controls[0] & 4) {
// debug_printf("\tHUE\n"); // debug_printf("\tHUE\n");
fHue = _AddParameter(group, &subgroup, index + 2, fHue = _AddParameter(group, &subgroup, index + 2,
PU_HUE_CONTROL, "Hue"); USB_VIDEO_PU_HUE_CONTROL, "Hue");
if (descriptor->controlSize >= 2) { if (descriptor->control_size >= 2) {
if (descriptor->controls[1] & 8) { if (descriptor->controls[1] & 8) {
fHueAuto = _AddAutoParameter(subgroup, index + 3, fHueAuto = _AddAutoParameter(subgroup, index + 3,
PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL); USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL);
} }
} }
} }
if (descriptor->controls[0] & 8) { if (descriptor->controls[0] & 8) {
// debug_printf("\tSATURATION\n"); // debug_printf("\tSATURATION\n");
fSaturation = _AddParameter(group, &subgroup, index + 4, fSaturation = _AddParameter(group, &subgroup, index + 4,
PU_SATURATION_CONTROL, "Saturation"); USB_VIDEO_PU_SATURATION_CONTROL, "Saturation");
} }
if (descriptor->controls[0] & 16) { if (descriptor->controls[0] & 16) {
// debug_printf("\tSHARPNESS\n"); // debug_printf("\tSHARPNESS\n");
fSharpness = _AddParameter(group, &subgroup, index + 5, fSharpness = _AddParameter(group, &subgroup, index + 5,
PU_SHARPNESS_CONTROL, "Sharpness"); USB_VIDEO_PU_SHARPNESS_CONTROL, "Sharpness");
} }
if (descriptor->controls[0] & 32) { if (descriptor->controls[0] & 32) {
// debug_printf("\tGamma\n"); // debug_printf("\tGamma\n");
fGamma = _AddParameter(group, &subgroup, index + 6, fGamma = _AddParameter(group, &subgroup, index + 6,
PU_GAMMA_CONTROL, "Gamma"); USB_VIDEO_PU_GAMMA_CONTROL, "Gamma");
} }
if (descriptor->controls[0] & 64) { if (descriptor->controls[0] & 64) {
// debug_printf("\tWHITE BALANCE TEMPERATURE\n"); // debug_printf("\tWHITE BALANCE TEMPERATURE\n");
fWBTemp = _AddParameter(group, &subgroup, index + 7, fWBTemp = _AddParameter(group, &subgroup, index + 7,
PU_WHITE_BALANCE_TEMPERATURE_CONTROL, "WB Temperature"); USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL, "WB Temperature");
if (descriptor->controlSize >= 2) { if (descriptor->control_size >= 2) {
if (descriptor->controls[1] & 16) { if (descriptor->controls[1] & 16) {
fWBTempAuto = _AddAutoParameter(subgroup, index + 8, fWBTempAuto = _AddAutoParameter(subgroup, index + 8,
PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL); USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL);
} }
} }
} }
if (descriptor->controls[0] & 128) { if (descriptor->controls[0] & 128) {
// debug_printf("\tWhite Balance Component\n"); // debug_printf("\tWhite Balance Component\n");
fWBComponent = _AddParameter(group, &subgroup, index + 9, fWBComponent = _AddParameter(group, &subgroup, index + 9,
PU_WHITE_BALANCE_COMPONENT_CONTROL, "WB Component"); USB_VIDEO_PU_WHITE_BALANCE_COMPONENT_CONTROL, "WB Component");
if (descriptor->controlSize >= 2) { if (descriptor->control_size >= 2) {
if (descriptor->controls[1] & 32) { if (descriptor->controls[1] & 32) {
fWBTempAuto = _AddAutoParameter(subgroup, index + 10, 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) { if (descriptor->controls[1] & 1) {
// debug_printf("\tBACKLIGHT COMPENSATION\n"); // debug_printf("\tBACKLIGHT COMPENSATION\n");
int16 data; 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, 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; maxValue = (float)data;
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, 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; minValue = (float)data;
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, 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; fBacklightCompensation = (float)data;
subgroup = group->MakeGroup("Backlight Compensation"); subgroup = group->MakeGroup("Backlight Compensation");
if (maxValue - minValue == 1) { // Binary Switch if (maxValue - minValue == 1) { // Binary Switch
@ -860,15 +869,16 @@ UVCCamDevice::_AddProcessingParameter(BParameterGroup* group,
} }
if (descriptor->controls[1] & 2) { if (descriptor->controls[1] & 2) {
// debug_printf("\tGAIN\n"); // 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"); "Gain");
} }
if (descriptor->controls[1] & 4) { if (descriptor->controls[1] & 4) {
// debug_printf("\tPOWER LINE FREQUENCY\n"); // debug_printf("\tPOWER LINE FREQUENCY\n");
wValue = PU_POWER_LINE_FREQUENCY_CONTROL << 8; wValue = USB_VIDEO_PU_POWER_LINE_FREQUENCY_CONTROL << 8;
int8 data; int8 data;
if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, 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; fPowerlineFrequency = data;
} }
subgroup = group->MakeGroup("Power Line Frequency"); subgroup = group->MakeGroup("Power Line Frequency");
@ -909,17 +919,17 @@ UVCCamDevice::_AddParameter(BParameterGroup* group,
wValue <<= 8; wValue <<= 8;
if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, 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)) { == sizeof(data)) {
maxValue = (float)data; maxValue = (float)data;
} }
if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, 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)) { == sizeof(data)) {
minValue = (float)data; minValue = (float)data;
} }
if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, 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)) { == sizeof(data)) {
currValue = (float)data; currValue = (float)data;
} }
@ -940,7 +950,7 @@ UVCCamDevice::_AddAutoParameter(BParameterGroup* subgroup, int32 index,
wValue <<= 8; wValue <<= 8;
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, 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", subgroup->MakeDiscreteParameter(index, B_MEDIA_RAW_VIDEO, "Auto",
B_ENABLE); B_ENABLE);
@ -971,8 +981,8 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
interface = config->InterfaceAt(j); interface = config->InterfaceAt(j);
if (interface == NULL) if (interface == NULL)
continue; continue;
if (interface->Class() != CC_VIDEO || interface->Subclass() if (interface->Class() != USB_VIDEO_DEVICE_CLASS || interface->Subclass()
!= SC_VIDEOCONTROL) != USB_VIDEO_INTERFACE_VIDEOCONTROL_SUBCLASS)
continue; continue;
for (uint32 k = 0; interface->OtherDescriptorAt(k, generic, for (uint32 k = 0; interface->OtherDescriptorAt(k, generic,
sizeof(buffer)) == B_OK; k++) { sizeof(buffer)) == B_OK; k++) {
@ -981,9 +991,9 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
continue; continue;
if (((const usbvc_class_descriptor*)generic)->descriptorSubtype if (((const usbvc_class_descriptor*)generic)->descriptorSubtype
== VC_PROCESSING_UNIT) { == USB_VIDEO_VC_PROCESSING_UNIT) {
_AddProcessingParameter(group, index, _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"); // debug_printf("\tWB Temperature:\n");
*size = sizeof(float); *size = sizeof(float);
currValue = (float*)value; 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, 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)) { == sizeof(data)) {
fWBTemp = (float)data; fWBTemp = (float)data;
} }
@ -1123,35 +1133,35 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
return B_BAD_VALUE; return B_BAD_VALUE;
fBrightness = *((float*)value); fBrightness = *((float*)value);
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue(PU_BRIGHTNESS_CONTROL, (int16)fBrightness); return _SetParameterValue(USB_VIDEO_PU_BRIGHTNESS_CONTROL, (int16)fBrightness);
case 1: case 1:
// debug_printf("\tContrast:\n"); // debug_printf("\tContrast:\n");
if (!value || (size != sizeof(float))) if (!value || (size != sizeof(float)))
return B_BAD_VALUE; return B_BAD_VALUE;
fContrast = *((float*)value); fContrast = *((float*)value);
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue(PU_CONTRAST_CONTROL, (int16)fContrast); return _SetParameterValue(USB_VIDEO_PU_CONTRAST_CONTROL, (int16)fContrast);
case 2: case 2:
// debug_printf("\tHue:\n"); // debug_printf("\tHue:\n");
if (!value || (size != sizeof(float))) if (!value || (size != sizeof(float)))
return B_BAD_VALUE; return B_BAD_VALUE;
fHue = *((float*)value); fHue = *((float*)value);
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue(PU_HUE_CONTROL, (int16)fHue); return _SetParameterValue(USB_VIDEO_PU_HUE_CONTROL, (int16)fHue);
case 4: case 4:
// debug_printf("\tSaturation:\n"); // debug_printf("\tSaturation:\n");
if (!value || (size != sizeof(float))) if (!value || (size != sizeof(float)))
return B_BAD_VALUE; return B_BAD_VALUE;
fSaturation = *((float*)value); fSaturation = *((float*)value);
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue(PU_SATURATION_CONTROL, (int16)fSaturation); return _SetParameterValue(USB_VIDEO_PU_SATURATION_CONTROL, (int16)fSaturation);
case 5: case 5:
// debug_printf("\tSharpness:\n"); // debug_printf("\tSharpness:\n");
if (!value || (size != sizeof(float))) if (!value || (size != sizeof(float)))
return B_BAD_VALUE; return B_BAD_VALUE;
fSharpness = *((float*)value); fSharpness = *((float*)value);
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue(PU_SHARPNESS_CONTROL, (int16)fSharpness); return _SetParameterValue(USB_VIDEO_PU_SHARPNESS_CONTROL, (int16)fSharpness);
case 7: case 7:
if (fWBTempAuto) if (fWBTempAuto)
return B_OK; return B_OK;
@ -1160,7 +1170,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
return B_BAD_VALUE; return B_BAD_VALUE;
fWBTemp = *((float*)value); fWBTemp = *((float*)value);
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue(PU_WHITE_BALANCE_TEMPERATURE_CONTROL, return _SetParameterValue(USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL,
(int16)fWBTemp); (int16)fWBTemp);
case 8: case 8:
// debug_printf("\tWB Temperature Auto:\n"); // debug_printf("\tWB Temperature Auto:\n");
@ -1169,7 +1179,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
fWBTempAuto = *((int*)value); fWBTempAuto = *((int*)value);
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue( return _SetParameterValue(
PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, (int8)fWBTempAuto); USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, (int8)fWBTempAuto);
case 11: case 11:
if (!fBinaryBacklightCompensation) { if (!fBinaryBacklightCompensation) {
// debug_printf("\tBacklight Compensation:\n"); // debug_printf("\tBacklight Compensation:\n");
@ -1183,7 +1193,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
fBacklightCompensationBinary = *((int*)value); fBacklightCompensationBinary = *((int*)value);
} }
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue(PU_BACKLIGHT_COMPENSATION_CONTROL, return _SetParameterValue(USB_VIDEO_PU_BACKLIGHT_COMPENSATION_CONTROL,
(int16)fBacklightCompensationBinary); (int16)fBacklightCompensationBinary);
case 12: case 12:
// debug_printf("\tGain:\n"); // debug_printf("\tGain:\n");
@ -1191,7 +1201,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
return B_BAD_VALUE; return B_BAD_VALUE;
fGain = *((float*)value); fGain = *((float*)value);
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue(PU_GAIN_CONTROL, (int16)fGain); return _SetParameterValue(USB_VIDEO_PU_GAIN_CONTROL, (int16)fGain);
case 13: case 13:
// debug_printf("\tPowerline Frequency:\n"); // debug_printf("\tPowerline Frequency:\n");
// debug_printf("\tValue = %f\n",*((float*)value)); // debug_printf("\tValue = %f\n",*((float*)value));
@ -1206,7 +1216,7 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
fPowerlineFrequency = 2; fPowerlineFrequency = 2;
} }
fLastParameterChanges = when; fLastParameterChanges = when;
return _SetParameterValue(PU_POWER_LINE_FREQUENCY_CONTROL, return _SetParameterValue(USB_VIDEO_PU_POWER_LINE_FREQUENCY_CONTROL,
(int8)fPowerlineFrequency); (int8)fPowerlineFrequency);
} }
@ -1218,7 +1228,7 @@ status_t
UVCCamDevice::_SetParameterValue(uint16 wValue, int16 setValue) UVCCamDevice::_SetParameterValue(uint16 wValue, int16 setValue)
{ {
return (fDevice->ControlTransfer(USB_REQTYPE_CLASS 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); sizeof(setValue), &setValue)) == sizeof(setValue);
} }
@ -1227,7 +1237,7 @@ status_t
UVCCamDevice::_SetParameterValue(uint16 wValue, int8 setValue) UVCCamDevice::_SetParameterValue(uint16 wValue, int8 setValue)
{ {
return (fDevice->ControlTransfer(USB_REQTYPE_CLASS 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); sizeof(setValue), &setValue)) == sizeof(setValue);
} }

View File

@ -10,6 +10,7 @@
#include "CamDevice.h" #include "CamDevice.h"
#include "USB_video.h" #include "USB_video.h"
#include <usb/USB_video.h>
class UVCCamDevice : public CamDevice { class UVCCamDevice : public CamDevice {
@ -51,7 +52,7 @@ private:
void _AddProcessingParameter(BParameterGroup* group, void _AddProcessingParameter(BParameterGroup* group,
int32 index, int32 index,
const usbvc_processing_unit_descriptor* const usb_video_processing_unit_descriptor*
descriptor); descriptor);
float _AddParameter(BParameterGroup* group, float _AddParameter(BParameterGroup* group,
BParameterGroup** subgroup, int32 index, BParameterGroup** subgroup, int32 index,

View File

@ -84,7 +84,7 @@ DumpVideoCSInterfaceDescriptorOutputTerminal(
descriptor->terminal_type, descriptor->terminal_type,
TerminalTypeName(descriptor->terminal_type)); TerminalTypeName(descriptor->terminal_type));
printf(" Associated Terminal %u\n", printf(" Associated Terminal %u\n",
descriptor->assoc_terminal); descriptor->associated_terminal);
printf(" Source ID ......... %u\n", printf(" Source ID ......... %u\n",
descriptor->source_id); descriptor->source_id);
printf(" Terminal .......... %u\n", printf(" Terminal .......... %u\n",
@ -94,7 +94,7 @@ DumpVideoCSInterfaceDescriptorOutputTerminal(
void void
DumpVideoCSInterfaceDescriptorInputTerminal( DumpVideoCSInterfaceDescriptorInputTerminal(
const usb_video_input_terminal_descriptor* descriptor) const usb_video_camera_input_terminal_descriptor* descriptor)
{ {
printf(" Type .............. 0x%02x\n", printf(" Type .............. 0x%02x\n",
descriptor->descriptor_type); descriptor->descriptor_type);
@ -111,11 +111,11 @@ DumpVideoCSInterfaceDescriptorInputTerminal(
if (descriptor->terminal_type == USB_VIDEO_CAMERA_IN) if (descriptor->terminal_type == USB_VIDEO_CAMERA_IN)
{ {
printf(" Min. Focal length . %u\n", printf(" Min. Focal length . %u\n",
descriptor->camera.focal_length_min); descriptor->camera.objective_focal_length_min);
printf(" Max. Focal length . %u\n", printf(" Max. Focal length . %u\n",
descriptor->camera.focal_length_min); descriptor->camera.objective_focal_length_min);
printf(" Focal length ...... %u\n", printf(" Focal length ...... %u\n",
descriptor->camera.focal_length); descriptor->camera.ocular_focal_length);
printf(" Controls .......... %02x%02x%02x\n", printf(" Controls .......... %02x%02x%02x\n",
descriptor->camera.controls[0], descriptor->camera.controls[0],
descriptor->camera.controls[1], descriptor->camera.controls[1],
@ -199,9 +199,9 @@ DumpVideoCSInterfaceDescriptorProcessingUnit(
} }
printf("\n"); printf("\n");
printf(" Processing ........ %u\n", printf(" Processing ........ %u\n",
descriptor->processing); descriptor->Processing());
printf(" Video Standards ... 0x%02x\n", printf(" Video Standards ... 0x%02x\n",
descriptor->video_standards); descriptor->VideoStandards().video_standards);
} }
@ -255,7 +255,7 @@ DumpVideoControlCSInterfaceDescriptor(const usb_generic_descriptor* descriptor)
break; break;
case USB_VIDEO_VC_INPUT_TERMINAL: case USB_VIDEO_VC_INPUT_TERMINAL:
DumpVideoCSInterfaceDescriptorInputTerminal( DumpVideoCSInterfaceDescriptorInputTerminal(
(usb_video_input_terminal_descriptor*)descriptor); (usb_video_camera_input_terminal_descriptor*)descriptor);
break; break;
case USB_VIDEO_VC_OUTPUT_TERMINAL: case USB_VIDEO_VC_OUTPUT_TERMINAL:
DumpVideoCSInterfaceDescriptorOutputTerminal( DumpVideoCSInterfaceDescriptorOutputTerminal(