* extracted some private methods to have a more readable code
* fixed negative parameter values handling * clean up and method shuffle git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42703 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -755,118 +755,12 @@ UVCCamDevice::_SelectIdleAlternate()
|
||||
}
|
||||
|
||||
|
||||
UVCCamDeviceAddon::UVCCamDeviceAddon(WebCamMediaAddOn* webcam)
|
||||
: CamDeviceAddon(webcam)
|
||||
{
|
||||
printf("UVCCamDeviceAddon::UVCCamDeviceAddon(WebCamMediaAddOn* webcam)\n");
|
||||
SetSupportedDevices(kSupportedDevices);
|
||||
}
|
||||
|
||||
|
||||
UVCCamDeviceAddon::~UVCCamDeviceAddon()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
UVCCamDeviceAddon::BrandName()
|
||||
{
|
||||
printf("UVCCamDeviceAddon::BrandName()\n");
|
||||
return "USB Video Class";
|
||||
}
|
||||
|
||||
|
||||
UVCCamDevice *
|
||||
UVCCamDeviceAddon::Instantiate(CamRoster& roster, BUSBDevice* from)
|
||||
{
|
||||
printf("UVCCamDeviceAddon::Instantiate()\n");
|
||||
return new UVCCamDevice(*this, from);
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
UVCCamDevice::_AddParameter(BParameterGroup* group,
|
||||
BParameterGroup** subgroup, int32 index, uint16 wValue, const char* name)
|
||||
{
|
||||
float minValue = 0.0;
|
||||
float maxValue = 100.0;
|
||||
float currValue = 0.0;
|
||||
|
||||
BContinuousParameter* p;
|
||||
uint16 data;
|
||||
|
||||
wValue = wValue << 8;
|
||||
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_MAX, wValue, fControlRequestIndex, 2, &data);
|
||||
maxValue = (float)(*((uint16*)data));
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_MIN, wValue, fControlRequestIndex, 2, &data);
|
||||
minValue = (float)(*((uint16*)data));
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_CUR, wValue, fControlRequestIndex, 2, &data);
|
||||
currValue = (float)data;
|
||||
|
||||
*subgroup = group->MakeGroup(name);
|
||||
p = (*subgroup)->MakeContinuousParameter(index,
|
||||
B_MEDIA_RAW_VIDEO, name,
|
||||
B_GAIN, "", minValue, maxValue, 1.0 / (maxValue - minValue));
|
||||
|
||||
return currValue;
|
||||
}
|
||||
|
||||
|
||||
int UVCCamDevice::_AddAutoParameter(BParameterGroup* subgroup, int32 index,
|
||||
uint16 wValue)
|
||||
{
|
||||
uint8 data;
|
||||
wValue <<= 8;
|
||||
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_CUR, wValue, fControlRequestIndex, 1, &data);
|
||||
subgroup->MakeDiscreteParameter(index, B_MEDIA_RAW_VIDEO, "Auto",
|
||||
B_ENABLE);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
||||
UVCCamDevice::_AddProcessingParameter(BParameterGroup* group,
|
||||
int32 index, const usbvc_processing_unit_descriptor* descriptor)
|
||||
{
|
||||
printf("UVCCamDevice::AddParameters()\n");
|
||||
fFirstParameterID = index;
|
||||
// debug_printf("fIndex = %d\n",fIndex);
|
||||
BParameterGroup* subgroup;
|
||||
BContinuousParameter* p;
|
||||
CamDevice::AddParameters(group, index);
|
||||
|
||||
const BUSBConfiguration* config;
|
||||
const BUSBInterface* interface;
|
||||
usb_descriptor* generic;
|
||||
uint8 buffer[1024];
|
||||
|
||||
void* data = (void*)(new uint16);
|
||||
|
||||
generic = (usb_descriptor*)buffer;
|
||||
|
||||
for (uint32 i = 0; i < fDevice->CountConfigurations(); i++) {
|
||||
config = fDevice->ConfigurationAt(i);
|
||||
fDevice->SetConfiguration(config);
|
||||
for (uint32 j = 0; j < config->CountInterfaces(); j++) {
|
||||
interface = config->InterfaceAt(j);
|
||||
if (interface->Class() == CC_VIDEO && interface->Subclass()
|
||||
== SC_VIDEOCONTROL) {
|
||||
for (uint32 k = 0; interface->OtherDescriptorAt(k, generic,
|
||||
sizeof(buffer)) == B_OK; k++) {
|
||||
if (generic->generic.descriptor_type != (USB_REQTYPE_CLASS
|
||||
| USB_DESCRIPTOR_INTERFACE))
|
||||
continue;
|
||||
|
||||
if (((const usbvc_class_descriptor*)generic)->descriptorSubtype
|
||||
== VC_PROCESSING_UNIT) {
|
||||
const usbvc_processing_unit_descriptor* descriptor
|
||||
= (const usbvc_processing_unit_descriptor*)generic;
|
||||
uint16 wValue = 0; // Control Selector
|
||||
float minValue = 0.0;
|
||||
float maxValue = 100.0;
|
||||
@@ -933,17 +827,17 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
||||
if (descriptor->controlSize >= 2) {
|
||||
if (descriptor->controls[1] & 1) {
|
||||
// debug_printf("\tBACKLIGHT COMPENSATION\n");
|
||||
wValue = PU_BACKLIGHT_COMPENSATION_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
int16 data;
|
||||
wValue = PU_BACKLIGHT_COMPENSATION_CONTROL << 8;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_MAX, wValue, fControlRequestIndex, 2, data);
|
||||
maxValue = (float)(*((uint16*)data));
|
||||
GET_MAX, wValue, fControlRequestIndex, sizeof(data), &data);
|
||||
maxValue = (float)data;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_MIN, wValue, fControlRequestIndex, 2, data);
|
||||
minValue = (float)(*((uint16*)data));
|
||||
GET_MIN, wValue, fControlRequestIndex, sizeof(data), &data);
|
||||
minValue = (float)data;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_CUR, wValue, fControlRequestIndex, 2, data);
|
||||
fBacklightCompensation = (float)(*((uint16*)data));
|
||||
GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data);
|
||||
fBacklightCompensation = (float)data;
|
||||
subgroup = group->MakeGroup("Backlight Compensation");
|
||||
if (maxValue - minValue == 1) { // Binary Switch
|
||||
fBinaryBacklightCompensation = true;
|
||||
@@ -954,7 +848,7 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
||||
fBinaryBacklightCompensation = false;
|
||||
p = subgroup->MakeContinuousParameter(index + 11,
|
||||
B_MEDIA_RAW_VIDEO, "Backlight Compensation",
|
||||
B_GAIN, "", minValue, maxValue, 1.0/(maxValue - minValue));
|
||||
B_GAIN, "", minValue, maxValue, 1.0 / (maxValue - minValue));
|
||||
}
|
||||
}
|
||||
if (descriptor->controls[1] & 2) {
|
||||
@@ -964,15 +858,15 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
||||
}
|
||||
if (descriptor->controls[1] & 4) {
|
||||
// debug_printf("\tPOWER LINE FREQUENCY\n");
|
||||
wValue = PU_POWER_LINE_FREQUENCY_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_CUR, wValue, fControlRequestIndex, 1, data);
|
||||
fPowerlineFrequency = (uint16)(*((uint8*)data));
|
||||
wValue = 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)) {
|
||||
fPowerlineFrequency = data;
|
||||
}
|
||||
subgroup = group->MakeGroup("Power Line Frequency");
|
||||
p = subgroup->MakeContinuousParameter(index + 13,
|
||||
B_MEDIA_RAW_VIDEO, "Frequency",
|
||||
B_GAIN, "", 0, 60.0, 1.0 / 60.0);
|
||||
B_MEDIA_RAW_VIDEO, "Frequency", B_GAIN, "", 0, 60.0, 1.0 / 60.0);
|
||||
}
|
||||
// TODO Determine whether controls apply to these
|
||||
/*
|
||||
@@ -991,7 +885,94 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
||||
debug_printf("\tAnalog Video Lock Status\n");
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
float
|
||||
UVCCamDevice::_AddParameter(BParameterGroup* group,
|
||||
BParameterGroup** subgroup, int32 index, uint16 wValue, const char* name)
|
||||
{
|
||||
float minValue = 0.0;
|
||||
float maxValue = 100.0;
|
||||
float currValue = 0.0;
|
||||
int16 data;
|
||||
|
||||
wValue <<= 8;
|
||||
|
||||
if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
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)
|
||||
== sizeof(data)) {
|
||||
minValue = (float)data;
|
||||
}
|
||||
if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data)
|
||||
== sizeof(data)) {
|
||||
currValue = (float)data;
|
||||
}
|
||||
|
||||
*subgroup = group->MakeGroup(name);
|
||||
BContinuousParameter* p = (*subgroup)->MakeContinuousParameter(index,
|
||||
B_MEDIA_RAW_VIDEO, name, B_GAIN, "", minValue, maxValue,
|
||||
1.0 / (maxValue - minValue));
|
||||
return currValue;
|
||||
}
|
||||
|
||||
|
||||
uint8
|
||||
UVCCamDevice::_AddAutoParameter(BParameterGroup* subgroup, int32 index,
|
||||
uint16 wValue)
|
||||
{
|
||||
uint8 data;
|
||||
wValue <<= 8;
|
||||
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_CUR, wValue, fControlRequestIndex, 1, &data);
|
||||
subgroup->MakeDiscreteParameter(index, B_MEDIA_RAW_VIDEO, "Auto",
|
||||
B_ENABLE);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
||||
{
|
||||
printf("UVCCamDevice::AddParameters()\n");
|
||||
fFirstParameterID = index;
|
||||
// debug_printf("fIndex = %d\n",fIndex);
|
||||
CamDevice::AddParameters(group, index);
|
||||
|
||||
const BUSBConfiguration* config;
|
||||
const BUSBInterface* interface;
|
||||
uint8 buffer[1024];
|
||||
|
||||
usb_descriptor* generic = (usb_descriptor*)buffer;
|
||||
|
||||
for (uint32 i = 0; i < fDevice->CountConfigurations(); i++) {
|
||||
config = fDevice->ConfigurationAt(i);
|
||||
fDevice->SetConfiguration(config);
|
||||
for (uint32 j = 0; j < config->CountInterfaces(); j++) {
|
||||
interface = config->InterfaceAt(j);
|
||||
if (interface->Class() != CC_VIDEO || interface->Subclass()
|
||||
!= SC_VIDEOCONTROL)
|
||||
continue;
|
||||
for (uint32 k = 0; interface->OtherDescriptorAt(k, generic,
|
||||
sizeof(buffer)) == B_OK; k++) {
|
||||
if (generic->generic.descriptor_type != (USB_REQTYPE_CLASS
|
||||
| USB_DESCRIPTOR_INTERFACE))
|
||||
continue;
|
||||
|
||||
if (((const usbvc_class_descriptor*)generic)->descriptorSubtype
|
||||
== VC_PROCESSING_UNIT) {
|
||||
_AddProcessingParameter(group, index,
|
||||
(const usbvc_processing_unit_descriptor*)generic);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1006,14 +987,14 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
||||
printf("UVCCAmDevice::GetParameterValue(%ld)\n", id - fFirstParameterID);
|
||||
float* currValue;
|
||||
int* currValueInt;
|
||||
void* data;
|
||||
int16 data;
|
||||
uint16 wValue = 0;
|
||||
switch (id - fFirstParameterID) {
|
||||
case 0:
|
||||
// debug_printf("\tBrightness:\n");
|
||||
// debug_printf("\tValue = %f\n",fBrightness);
|
||||
*size = sizeof(float);
|
||||
currValue = ((float*)value);
|
||||
currValue = (float*)value;
|
||||
*currValue = fBrightness;
|
||||
*last_change = fLastParameterChanges;
|
||||
return B_OK;
|
||||
@@ -1021,7 +1002,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
||||
// debug_printf("\tContrast:\n");
|
||||
// debug_printf("\tValue = %f\n",fContrast);
|
||||
*size = sizeof(float);
|
||||
currValue = ((float*)value);
|
||||
currValue = (float*)value;
|
||||
*currValue = fContrast;
|
||||
*last_change = fLastParameterChanges;
|
||||
return B_OK;
|
||||
@@ -1029,7 +1010,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
||||
// debug_printf("\tHue:\n");
|
||||
// debug_printf("\tValue = %f\n",fHue);
|
||||
*size = sizeof(float);
|
||||
currValue = ((float*)value);
|
||||
currValue = (float*)value;
|
||||
*currValue = fHue;
|
||||
*last_change = fLastParameterChanges;
|
||||
return B_OK;
|
||||
@@ -1037,7 +1018,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
||||
// debug_printf("\tSaturation:\n");
|
||||
// debug_printf("\tValue = %f\n",fSaturation);
|
||||
*size = sizeof(float);
|
||||
currValue = ((float*)value);
|
||||
currValue = (float*)value;
|
||||
*currValue = fSaturation;
|
||||
*last_change = fLastParameterChanges;
|
||||
return B_OK;
|
||||
@@ -1045,19 +1026,20 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
||||
// debug_printf("\tSharpness:\n");
|
||||
// debug_printf("\tValue = %f\n",fSharpness);
|
||||
*size = sizeof(float);
|
||||
currValue = ((float*)value);
|
||||
currValue = (float*)value;
|
||||
*currValue = fSharpness;
|
||||
*last_change = fLastParameterChanges;
|
||||
return B_OK;
|
||||
case 7:
|
||||
// debug_printf("\tWB Temperature:\n");
|
||||
*size = sizeof(float);
|
||||
currValue = ((float*)value);
|
||||
wValue = PU_WHITE_BALANCE_TEMPERATURE_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_CUR, wValue, fControlRequestIndex, 2, data);
|
||||
fWBTemp = (float)(*((uint16*)data));
|
||||
currValue = (float*)value;
|
||||
wValue = PU_WHITE_BALANCE_TEMPERATURE_CONTROL << 8;
|
||||
if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||
GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data)
|
||||
== sizeof(data)) {
|
||||
fWBTemp = (float)data;
|
||||
}
|
||||
// debug_printf("\tValue = %f\n",fWBTemp);
|
||||
*currValue = fWBTemp;
|
||||
*last_change = fLastParameterChanges;
|
||||
@@ -1075,13 +1057,13 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
||||
// debug_printf("\tBacklight Compensation:\n");
|
||||
// debug_printf("\tValue = %f\n",fBacklightCompensation);
|
||||
*size = sizeof(float);
|
||||
currValue = ((float*)value);
|
||||
currValue = (float*)value;
|
||||
*currValue = fBacklightCompensation;
|
||||
*last_change = fLastParameterChanges;
|
||||
} else {
|
||||
// debug_printf("\tBacklight Compensation:\n");
|
||||
// debug_printf("\tValue = %d\n",fBacklightCompensationBinary);
|
||||
currValueInt = ((int*)value);
|
||||
currValueInt = (int*)value;
|
||||
*currValueInt = fBacklightCompensationBinary;
|
||||
*last_change = fLastParameterChanges;
|
||||
}
|
||||
@@ -1090,7 +1072,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
||||
// debug_printf("\tGain:\n");
|
||||
// debug_printf("\tValue = %f\n",fGain);
|
||||
*size = sizeof(float);
|
||||
currValue = ((float*)value);
|
||||
currValue = (float*)value;
|
||||
*currValue = fGain;
|
||||
*last_change = fLastParameterChanges;
|
||||
return B_OK;
|
||||
@@ -1098,7 +1080,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
||||
// debug_printf("\tPowerline Frequency:\n");
|
||||
// debug_printf("\tValue = %d\n",fPowerlineFrequency);
|
||||
*size = sizeof(float);
|
||||
currValue = ((float*)value);
|
||||
currValue = (float*)value;
|
||||
switch (fPowerlineFrequency) {
|
||||
case 0:
|
||||
*currValue = 0.0;
|
||||
@@ -1123,149 +1105,87 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
|
||||
size_t size)
|
||||
{
|
||||
printf("UVCCamDevice::SetParameterValue(%ld)\n", id - fFirstParameterID);
|
||||
uint16 wValue = 0; //Control Selector
|
||||
uint16 setValue = 0;
|
||||
switch (id - fFirstParameterID) {
|
||||
case 0:
|
||||
// debug_printf("\tBrightness:\n");
|
||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
||||
if (!value || (size != sizeof(float)))
|
||||
return B_BAD_VALUE;
|
||||
wValue = PU_BRIGHTNESS_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fBrightness = *((float*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = (uint16)fBrightness;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
||||
return B_OK;
|
||||
return _SetParameterValue(PU_BRIGHTNESS_CONTROL, (int16)fBrightness);
|
||||
case 1:
|
||||
// debug_printf("\tContrast:\n");
|
||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
||||
if (!value || (size != sizeof(float)))
|
||||
return B_BAD_VALUE;
|
||||
wValue = PU_CONTRAST_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fContrast = *((float*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = (uint16)fContrast;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
||||
return B_OK;
|
||||
return _SetParameterValue(PU_CONTRAST_CONTROL, (int16)fContrast);
|
||||
case 2:
|
||||
// debug_printf("\tHue:\n");
|
||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
||||
if (!value || (size != sizeof(float)))
|
||||
return B_BAD_VALUE;
|
||||
wValue = PU_HUE_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fHue = *((float*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = (uint16)fHue;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
||||
return B_OK;
|
||||
return _SetParameterValue(PU_HUE_CONTROL, (int16)fHue);
|
||||
case 4:
|
||||
// debug_printf("\tSaturation:\n");
|
||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
||||
if (!value || (size != sizeof(float)))
|
||||
return B_BAD_VALUE;
|
||||
wValue = PU_SATURATION_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fSaturation = *((float*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = (uint16)fSaturation;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
||||
return B_OK;
|
||||
return _SetParameterValue(PU_SATURATION_CONTROL, (int16)fSaturation);
|
||||
case 5:
|
||||
// debug_printf("\tSharpness:\n");
|
||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
||||
if (!value || (size != sizeof(float)))
|
||||
return B_BAD_VALUE;
|
||||
wValue = PU_SHARPNESS_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fSharpness = *((float*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = (uint16)fSharpness;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
||||
return B_OK;
|
||||
return _SetParameterValue(PU_SHARPNESS_CONTROL, (int16)fSharpness);
|
||||
case 7:
|
||||
if (!fWBTempAuto) {
|
||||
if (fWBTempAuto)
|
||||
return B_OK;
|
||||
// debug_printf("\tWB Temperature:\n");
|
||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
||||
if (!value || (size != sizeof(float)))
|
||||
return B_BAD_VALUE;
|
||||
wValue = PU_WHITE_BALANCE_TEMPERATURE_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fWBTemp = *((float*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = (uint16)fWBTemp;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
||||
}
|
||||
return B_OK;
|
||||
return _SetParameterValue(PU_WHITE_BALANCE_TEMPERATURE_CONTROL,
|
||||
(int16)fWBTemp);
|
||||
case 8:
|
||||
// debug_printf("\tWB Temperature Auto:\n");
|
||||
if (!value || (size != sizeof(int)))
|
||||
return B_BAD_VALUE;
|
||||
// debug_printf("\tValue = %d\n",*((int*)value));
|
||||
wValue = PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fWBTempAuto = *((int*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = fWBTempAuto;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 1, &setValue);
|
||||
return B_OK;
|
||||
return _SetParameterValue(
|
||||
PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, (int8)fWBTempAuto);
|
||||
case 11:
|
||||
if (!fBinaryBacklightCompensation) {
|
||||
// debug_printf("\tBacklight Compensation:\n");
|
||||
if (!value || (size != sizeof(float)))
|
||||
return B_BAD_VALUE;
|
||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
||||
wValue = PU_BACKLIGHT_COMPENSATION_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fBacklightCompensation = *((float*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = (uint16)fBacklightCompensation;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
||||
}else{
|
||||
} else {
|
||||
// debug_printf("\tBacklight Compensation:\n");
|
||||
if (!value || (size != sizeof(int)))
|
||||
return B_BAD_VALUE;
|
||||
// debug_printf("\tValue = %d\n",*((int*)value));
|
||||
wValue = PU_BACKLIGHT_COMPENSATION_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fBacklightCompensationBinary = *((int*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = fBacklightCompensationBinary;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
||||
}
|
||||
return B_OK;
|
||||
fLastParameterChanges = when;
|
||||
return _SetParameterValue(PU_BACKLIGHT_COMPENSATION_CONTROL,
|
||||
(int16)fBacklightCompensationBinary);
|
||||
case 12:
|
||||
// debug_printf("\tGain:\n");
|
||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
||||
if (!value || (size != sizeof(float)))
|
||||
return B_BAD_VALUE;
|
||||
wValue = PU_GAIN_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
fGain = *((float*)value);
|
||||
fLastParameterChanges = when;
|
||||
setValue = (uint16)fGain;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
||||
return B_OK;
|
||||
return _SetParameterValue(PU_GAIN_CONTROL, (int16)fGain);
|
||||
case 13:
|
||||
// debug_printf("\tPowerline Frequency:\n");
|
||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
||||
if (!value || (size != sizeof(float)))
|
||||
return B_BAD_VALUE;
|
||||
wValue = PU_POWER_LINE_FREQUENCY_CONTROL;
|
||||
wValue = wValue << 8;
|
||||
float inValue = *((float*)value);
|
||||
fPowerlineFrequency = 0;
|
||||
if (inValue > 45.0 && inValue < 55.0) {
|
||||
@@ -1275,16 +1195,32 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
|
||||
fPowerlineFrequency = 2;
|
||||
}
|
||||
fLastParameterChanges = when;
|
||||
setValue = (uint8)fPowerlineFrequency;
|
||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
||||
SET_CUR, wValue, fControlRequestIndex, 1, &setValue);
|
||||
return B_OK;
|
||||
return _SetParameterValue(PU_POWER_LINE_FREQUENCY_CONTROL,
|
||||
(int8)fPowerlineFrequency);
|
||||
|
||||
}
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
UVCCamDevice::_SetParameterValue(uint16 wValue, int16 setValue)
|
||||
{
|
||||
return (fDevice->ControlTransfer(USB_REQTYPE_CLASS
|
||||
| USB_REQTYPE_INTERFACE_OUT, SET_CUR, wValue << 8, fControlRequestIndex,
|
||||
sizeof(setValue), &setValue)) == sizeof(setValue);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
UVCCamDevice::_SetParameterValue(uint16 wValue, int8 setValue)
|
||||
{
|
||||
return (fDevice->ControlTransfer(USB_REQTYPE_CLASS
|
||||
| USB_REQTYPE_INTERFACE_OUT, SET_CUR, wValue << 8, fControlRequestIndex,
|
||||
sizeof(setValue), &setValue)) == sizeof(setValue);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
UVCCamDevice::FillFrameBuffer(BBuffer* buffer, bigtime_t* stamp)
|
||||
{
|
||||
@@ -1392,6 +1328,37 @@ UVCCamDevice::_DecodeColor(unsigned char* dst, unsigned char* src,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
UVCCamDeviceAddon::UVCCamDeviceAddon(WebCamMediaAddOn* webcam)
|
||||
: CamDeviceAddon(webcam)
|
||||
{
|
||||
printf("UVCCamDeviceAddon::UVCCamDeviceAddon(WebCamMediaAddOn* webcam)\n");
|
||||
SetSupportedDevices(kSupportedDevices);
|
||||
}
|
||||
|
||||
|
||||
UVCCamDeviceAddon::~UVCCamDeviceAddon()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
UVCCamDeviceAddon::BrandName()
|
||||
{
|
||||
printf("UVCCamDeviceAddon::BrandName()\n");
|
||||
return "USB Video Class";
|
||||
}
|
||||
|
||||
|
||||
UVCCamDevice *
|
||||
UVCCamDeviceAddon::Instantiate(CamRoster& roster, BUSBDevice* from)
|
||||
{
|
||||
printf("UVCCamDeviceAddon::Instantiate()\n");
|
||||
return new UVCCamDevice(*this, from);
|
||||
}
|
||||
|
||||
|
||||
extern "C" status_t
|
||||
B_WEBCAM_MKINTFUNC(uvccam)
|
||||
(WebCamMediaAddOn* webcam, CamDeviceAddon **addon)
|
||||
|
||||
@@ -49,11 +49,20 @@ private:
|
||||
unsigned char *src, int32 width,
|
||||
int32 height);
|
||||
|
||||
void _AddProcessingParameter(BParameterGroup* group,
|
||||
int32 index,
|
||||
const usbvc_processing_unit_descriptor*
|
||||
descriptor);
|
||||
float _AddParameter(BParameterGroup* group,
|
||||
BParameterGroup** subgroup, int32 index,
|
||||
uint16 wValue, const char* name);
|
||||
int _AddAutoParameter(BParameterGroup* subgroup,
|
||||
uint8 _AddAutoParameter(BParameterGroup* subgroup,
|
||||
int32 index, uint16 wValue);
|
||||
status_t _SetParameterValue(uint16 wValue,
|
||||
int16 setValue);
|
||||
status_t _SetParameterValue(uint16 wValue,
|
||||
int8 setValue);
|
||||
|
||||
|
||||
usbvc_interface_header_descriptor *fHeaderDescriptor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user