* 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
|
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;
|
BParameterGroup* subgroup;
|
||||||
BContinuousParameter* p;
|
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
|
uint16 wValue = 0; // Control Selector
|
||||||
float minValue = 0.0;
|
float minValue = 0.0;
|
||||||
float maxValue = 100.0;
|
float maxValue = 100.0;
|
||||||
@@ -933,17 +827,17 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
|||||||
if (descriptor->controlSize >= 2) {
|
if (descriptor->controlSize >= 2) {
|
||||||
if (descriptor->controls[1] & 1) {
|
if (descriptor->controls[1] & 1) {
|
||||||
// debug_printf("\tBACKLIGHT COMPENSATION\n");
|
// debug_printf("\tBACKLIGHT COMPENSATION\n");
|
||||||
wValue = PU_BACKLIGHT_COMPENSATION_CONTROL;
|
int16 data;
|
||||||
wValue = wValue << 8;
|
wValue = 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, 2, data);
|
GET_MAX, wValue, fControlRequestIndex, sizeof(data), &data);
|
||||||
maxValue = (float)(*((uint16*)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, 2, data);
|
GET_MIN, wValue, fControlRequestIndex, sizeof(data), &data);
|
||||||
minValue = (float)(*((uint16*)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, 2, data);
|
GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data);
|
||||||
fBacklightCompensation = (float)(*((uint16*)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
|
||||||
fBinaryBacklightCompensation = true;
|
fBinaryBacklightCompensation = true;
|
||||||
@@ -954,7 +848,7 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
|||||||
fBinaryBacklightCompensation = false;
|
fBinaryBacklightCompensation = false;
|
||||||
p = subgroup->MakeContinuousParameter(index + 11,
|
p = subgroup->MakeContinuousParameter(index + 11,
|
||||||
B_MEDIA_RAW_VIDEO, "Backlight Compensation",
|
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) {
|
if (descriptor->controls[1] & 2) {
|
||||||
@@ -964,15 +858,15 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
|||||||
}
|
}
|
||||||
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;
|
wValue = PU_POWER_LINE_FREQUENCY_CONTROL << 8;
|
||||||
wValue = wValue << 8;
|
int8 data;
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN,
|
||||||
GET_CUR, wValue, fControlRequestIndex, 1, data);
|
GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data) == sizeof(data)) {
|
||||||
fPowerlineFrequency = (uint16)(*((uint8*)data));
|
fPowerlineFrequency = data;
|
||||||
|
}
|
||||||
subgroup = group->MakeGroup("Power Line Frequency");
|
subgroup = group->MakeGroup("Power Line Frequency");
|
||||||
p = subgroup->MakeContinuousParameter(index + 13,
|
p = subgroup->MakeContinuousParameter(index + 13,
|
||||||
B_MEDIA_RAW_VIDEO, "Frequency",
|
B_MEDIA_RAW_VIDEO, "Frequency", B_GAIN, "", 0, 60.0, 1.0 / 60.0);
|
||||||
B_GAIN, "", 0, 60.0, 1.0 / 60.0);
|
|
||||||
}
|
}
|
||||||
// TODO Determine whether controls apply to these
|
// TODO Determine whether controls apply to these
|
||||||
/*
|
/*
|
||||||
@@ -991,7 +885,94 @@ UVCCamDevice::AddParameters(BParameterGroup* group, int32& index)
|
|||||||
debug_printf("\tAnalog Video Lock Status\n");
|
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);
|
printf("UVCCAmDevice::GetParameterValue(%ld)\n", id - fFirstParameterID);
|
||||||
float* currValue;
|
float* currValue;
|
||||||
int* currValueInt;
|
int* currValueInt;
|
||||||
void* data;
|
int16 data;
|
||||||
uint16 wValue = 0;
|
uint16 wValue = 0;
|
||||||
switch (id - fFirstParameterID) {
|
switch (id - fFirstParameterID) {
|
||||||
case 0:
|
case 0:
|
||||||
// debug_printf("\tBrightness:\n");
|
// debug_printf("\tBrightness:\n");
|
||||||
// debug_printf("\tValue = %f\n",fBrightness);
|
// debug_printf("\tValue = %f\n",fBrightness);
|
||||||
*size = sizeof(float);
|
*size = sizeof(float);
|
||||||
currValue = ((float*)value);
|
currValue = (float*)value;
|
||||||
*currValue = fBrightness;
|
*currValue = fBrightness;
|
||||||
*last_change = fLastParameterChanges;
|
*last_change = fLastParameterChanges;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -1021,7 +1002,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
|||||||
// debug_printf("\tContrast:\n");
|
// debug_printf("\tContrast:\n");
|
||||||
// debug_printf("\tValue = %f\n",fContrast);
|
// debug_printf("\tValue = %f\n",fContrast);
|
||||||
*size = sizeof(float);
|
*size = sizeof(float);
|
||||||
currValue = ((float*)value);
|
currValue = (float*)value;
|
||||||
*currValue = fContrast;
|
*currValue = fContrast;
|
||||||
*last_change = fLastParameterChanges;
|
*last_change = fLastParameterChanges;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -1029,7 +1010,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
|||||||
// debug_printf("\tHue:\n");
|
// debug_printf("\tHue:\n");
|
||||||
// debug_printf("\tValue = %f\n",fHue);
|
// debug_printf("\tValue = %f\n",fHue);
|
||||||
*size = sizeof(float);
|
*size = sizeof(float);
|
||||||
currValue = ((float*)value);
|
currValue = (float*)value;
|
||||||
*currValue = fHue;
|
*currValue = fHue;
|
||||||
*last_change = fLastParameterChanges;
|
*last_change = fLastParameterChanges;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -1037,7 +1018,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
|||||||
// debug_printf("\tSaturation:\n");
|
// debug_printf("\tSaturation:\n");
|
||||||
// debug_printf("\tValue = %f\n",fSaturation);
|
// debug_printf("\tValue = %f\n",fSaturation);
|
||||||
*size = sizeof(float);
|
*size = sizeof(float);
|
||||||
currValue = ((float*)value);
|
currValue = (float*)value;
|
||||||
*currValue = fSaturation;
|
*currValue = fSaturation;
|
||||||
*last_change = fLastParameterChanges;
|
*last_change = fLastParameterChanges;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -1045,19 +1026,20 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
|||||||
// debug_printf("\tSharpness:\n");
|
// debug_printf("\tSharpness:\n");
|
||||||
// debug_printf("\tValue = %f\n",fSharpness);
|
// debug_printf("\tValue = %f\n",fSharpness);
|
||||||
*size = sizeof(float);
|
*size = sizeof(float);
|
||||||
currValue = ((float*)value);
|
currValue = (float*)value;
|
||||||
*currValue = fSharpness;
|
*currValue = fSharpness;
|
||||||
*last_change = fLastParameterChanges;
|
*last_change = fLastParameterChanges;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
case 7:
|
case 7:
|
||||||
// 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;
|
wValue = PU_WHITE_BALANCE_TEMPERATURE_CONTROL << 8;
|
||||||
wValue = wValue << 8;
|
if (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)
|
||||||
GET_CUR, wValue, fControlRequestIndex, 2, data);
|
== sizeof(data)) {
|
||||||
fWBTemp = (float)(*((uint16*)data));
|
fWBTemp = (float)data;
|
||||||
|
}
|
||||||
// debug_printf("\tValue = %f\n",fWBTemp);
|
// debug_printf("\tValue = %f\n",fWBTemp);
|
||||||
*currValue = fWBTemp;
|
*currValue = fWBTemp;
|
||||||
*last_change = fLastParameterChanges;
|
*last_change = fLastParameterChanges;
|
||||||
@@ -1075,13 +1057,13 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
|||||||
// debug_printf("\tBacklight Compensation:\n");
|
// debug_printf("\tBacklight Compensation:\n");
|
||||||
// debug_printf("\tValue = %f\n",fBacklightCompensation);
|
// debug_printf("\tValue = %f\n",fBacklightCompensation);
|
||||||
*size = sizeof(float);
|
*size = sizeof(float);
|
||||||
currValue = ((float*)value);
|
currValue = (float*)value;
|
||||||
*currValue = fBacklightCompensation;
|
*currValue = fBacklightCompensation;
|
||||||
*last_change = fLastParameterChanges;
|
*last_change = fLastParameterChanges;
|
||||||
} else {
|
} else {
|
||||||
// debug_printf("\tBacklight Compensation:\n");
|
// debug_printf("\tBacklight Compensation:\n");
|
||||||
// debug_printf("\tValue = %d\n",fBacklightCompensationBinary);
|
// debug_printf("\tValue = %d\n",fBacklightCompensationBinary);
|
||||||
currValueInt = ((int*)value);
|
currValueInt = (int*)value;
|
||||||
*currValueInt = fBacklightCompensationBinary;
|
*currValueInt = fBacklightCompensationBinary;
|
||||||
*last_change = fLastParameterChanges;
|
*last_change = fLastParameterChanges;
|
||||||
}
|
}
|
||||||
@@ -1090,7 +1072,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
|||||||
// debug_printf("\tGain:\n");
|
// debug_printf("\tGain:\n");
|
||||||
// debug_printf("\tValue = %f\n",fGain);
|
// debug_printf("\tValue = %f\n",fGain);
|
||||||
*size = sizeof(float);
|
*size = sizeof(float);
|
||||||
currValue = ((float*)value);
|
currValue = (float*)value;
|
||||||
*currValue = fGain;
|
*currValue = fGain;
|
||||||
*last_change = fLastParameterChanges;
|
*last_change = fLastParameterChanges;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -1098,7 +1080,7 @@ UVCCamDevice::GetParameterValue(int32 id, bigtime_t* last_change, void* value,
|
|||||||
// debug_printf("\tPowerline Frequency:\n");
|
// debug_printf("\tPowerline Frequency:\n");
|
||||||
// debug_printf("\tValue = %d\n",fPowerlineFrequency);
|
// debug_printf("\tValue = %d\n",fPowerlineFrequency);
|
||||||
*size = sizeof(float);
|
*size = sizeof(float);
|
||||||
currValue = ((float*)value);
|
currValue = (float*)value;
|
||||||
switch (fPowerlineFrequency) {
|
switch (fPowerlineFrequency) {
|
||||||
case 0:
|
case 0:
|
||||||
*currValue = 0.0;
|
*currValue = 0.0;
|
||||||
@@ -1123,149 +1105,87 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
|
|||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
printf("UVCCamDevice::SetParameterValue(%ld)\n", id - fFirstParameterID);
|
printf("UVCCamDevice::SetParameterValue(%ld)\n", id - fFirstParameterID);
|
||||||
uint16 wValue = 0; //Control Selector
|
|
||||||
uint16 setValue = 0;
|
|
||||||
switch (id - fFirstParameterID) {
|
switch (id - fFirstParameterID) {
|
||||||
case 0:
|
case 0:
|
||||||
// debug_printf("\tBrightness:\n");
|
// debug_printf("\tBrightness:\n");
|
||||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
|
||||||
if (!value || (size != sizeof(float)))
|
if (!value || (size != sizeof(float)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
wValue = PU_BRIGHTNESS_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fBrightness = *((float*)value);
|
fBrightness = *((float*)value);
|
||||||
fLastParameterChanges = when;
|
fLastParameterChanges = when;
|
||||||
setValue = (uint16)fBrightness;
|
return _SetParameterValue(PU_BRIGHTNESS_CONTROL, (int16)fBrightness);
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
|
||||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
|
||||||
return B_OK;
|
|
||||||
case 1:
|
case 1:
|
||||||
// debug_printf("\tContrast:\n");
|
// debug_printf("\tContrast:\n");
|
||||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
|
||||||
if (!value || (size != sizeof(float)))
|
if (!value || (size != sizeof(float)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
wValue = PU_CONTRAST_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fContrast = *((float*)value);
|
fContrast = *((float*)value);
|
||||||
fLastParameterChanges = when;
|
fLastParameterChanges = when;
|
||||||
setValue = (uint16)fContrast;
|
return _SetParameterValue(PU_CONTRAST_CONTROL, (int16)fContrast);
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
|
||||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
|
||||||
return B_OK;
|
|
||||||
case 2:
|
case 2:
|
||||||
// debug_printf("\tHue:\n");
|
// debug_printf("\tHue:\n");
|
||||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
|
||||||
if (!value || (size != sizeof(float)))
|
if (!value || (size != sizeof(float)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
wValue = PU_HUE_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fHue = *((float*)value);
|
fHue = *((float*)value);
|
||||||
fLastParameterChanges = when;
|
fLastParameterChanges = when;
|
||||||
setValue = (uint16)fHue;
|
return _SetParameterValue(PU_HUE_CONTROL, (int16)fHue);
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
|
||||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
|
||||||
return B_OK;
|
|
||||||
case 4:
|
case 4:
|
||||||
// debug_printf("\tSaturation:\n");
|
// debug_printf("\tSaturation:\n");
|
||||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
|
||||||
if (!value || (size != sizeof(float)))
|
if (!value || (size != sizeof(float)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
wValue = PU_SATURATION_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fSaturation = *((float*)value);
|
fSaturation = *((float*)value);
|
||||||
fLastParameterChanges = when;
|
fLastParameterChanges = when;
|
||||||
setValue = (uint16)fSaturation;
|
return _SetParameterValue(PU_SATURATION_CONTROL, (int16)fSaturation);
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
|
||||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
|
||||||
return B_OK;
|
|
||||||
case 5:
|
case 5:
|
||||||
// debug_printf("\tSharpness:\n");
|
// debug_printf("\tSharpness:\n");
|
||||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
|
||||||
if (!value || (size != sizeof(float)))
|
if (!value || (size != sizeof(float)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
wValue = PU_SHARPNESS_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fSharpness = *((float*)value);
|
fSharpness = *((float*)value);
|
||||||
fLastParameterChanges = when;
|
fLastParameterChanges = when;
|
||||||
setValue = (uint16)fSharpness;
|
return _SetParameterValue(PU_SHARPNESS_CONTROL, (int16)fSharpness);
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
|
||||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
|
||||||
return B_OK;
|
|
||||||
case 7:
|
case 7:
|
||||||
if (!fWBTempAuto) {
|
if (fWBTempAuto)
|
||||||
|
return B_OK;
|
||||||
// debug_printf("\tWB Temperature:\n");
|
// debug_printf("\tWB Temperature:\n");
|
||||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
|
||||||
if (!value || (size != sizeof(float)))
|
if (!value || (size != sizeof(float)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
wValue = PU_WHITE_BALANCE_TEMPERATURE_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fWBTemp = *((float*)value);
|
fWBTemp = *((float*)value);
|
||||||
fLastParameterChanges = when;
|
fLastParameterChanges = when;
|
||||||
setValue = (uint16)fWBTemp;
|
return _SetParameterValue(PU_WHITE_BALANCE_TEMPERATURE_CONTROL,
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
(int16)fWBTemp);
|
||||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
|
||||||
}
|
|
||||||
return B_OK;
|
|
||||||
case 8:
|
case 8:
|
||||||
// debug_printf("\tWB Temperature Auto:\n");
|
// debug_printf("\tWB Temperature Auto:\n");
|
||||||
if (!value || (size != sizeof(int)))
|
if (!value || (size != sizeof(int)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
// debug_printf("\tValue = %d\n",*((int*)value));
|
|
||||||
wValue = PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fWBTempAuto = *((int*)value);
|
fWBTempAuto = *((int*)value);
|
||||||
fLastParameterChanges = when;
|
fLastParameterChanges = when;
|
||||||
setValue = fWBTempAuto;
|
return _SetParameterValue(
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, (int8)fWBTempAuto);
|
||||||
SET_CUR, wValue, fControlRequestIndex, 1, &setValue);
|
|
||||||
return B_OK;
|
|
||||||
case 11:
|
case 11:
|
||||||
if (!fBinaryBacklightCompensation) {
|
if (!fBinaryBacklightCompensation) {
|
||||||
// debug_printf("\tBacklight Compensation:\n");
|
// debug_printf("\tBacklight Compensation:\n");
|
||||||
if (!value || (size != sizeof(float)))
|
if (!value || (size != sizeof(float)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
|
||||||
wValue = PU_BACKLIGHT_COMPENSATION_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fBacklightCompensation = *((float*)value);
|
fBacklightCompensation = *((float*)value);
|
||||||
fLastParameterChanges = when;
|
} else {
|
||||||
setValue = (uint16)fBacklightCompensation;
|
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
|
||||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
|
||||||
}else{
|
|
||||||
// debug_printf("\tBacklight Compensation:\n");
|
// debug_printf("\tBacklight Compensation:\n");
|
||||||
if (!value || (size != sizeof(int)))
|
if (!value || (size != sizeof(int)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
// debug_printf("\tValue = %d\n",*((int*)value));
|
|
||||||
wValue = PU_BACKLIGHT_COMPENSATION_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fBacklightCompensationBinary = *((int*)value);
|
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:
|
case 12:
|
||||||
// debug_printf("\tGain:\n");
|
// debug_printf("\tGain:\n");
|
||||||
// debug_printf("\tValue = %f\n",*((float*)value));
|
|
||||||
if (!value || (size != sizeof(float)))
|
if (!value || (size != sizeof(float)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
wValue = PU_GAIN_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
fGain = *((float*)value);
|
fGain = *((float*)value);
|
||||||
fLastParameterChanges = when;
|
fLastParameterChanges = when;
|
||||||
setValue = (uint16)fGain;
|
return _SetParameterValue(PU_GAIN_CONTROL, (int16)fGain);
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
|
||||||
SET_CUR, wValue, fControlRequestIndex, 2, &setValue);
|
|
||||||
return B_OK;
|
|
||||||
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));
|
||||||
if (!value || (size != sizeof(float)))
|
if (!value || (size != sizeof(float)))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
wValue = PU_POWER_LINE_FREQUENCY_CONTROL;
|
|
||||||
wValue = wValue << 8;
|
|
||||||
float inValue = *((float*)value);
|
float inValue = *((float*)value);
|
||||||
fPowerlineFrequency = 0;
|
fPowerlineFrequency = 0;
|
||||||
if (inValue > 45.0 && inValue < 55.0) {
|
if (inValue > 45.0 && inValue < 55.0) {
|
||||||
@@ -1275,16 +1195,32 @@ UVCCamDevice::SetParameterValue(int32 id, bigtime_t when, const void* value,
|
|||||||
fPowerlineFrequency = 2;
|
fPowerlineFrequency = 2;
|
||||||
}
|
}
|
||||||
fLastParameterChanges = when;
|
fLastParameterChanges = when;
|
||||||
setValue = (uint8)fPowerlineFrequency;
|
return _SetParameterValue(PU_POWER_LINE_FREQUENCY_CONTROL,
|
||||||
fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_OUT,
|
(int8)fPowerlineFrequency);
|
||||||
SET_CUR, wValue, fControlRequestIndex, 1, &setValue);
|
|
||||||
return B_OK;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return B_BAD_VALUE;
|
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
|
status_t
|
||||||
UVCCamDevice::FillFrameBuffer(BBuffer* buffer, bigtime_t* stamp)
|
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
|
extern "C" status_t
|
||||||
B_WEBCAM_MKINTFUNC(uvccam)
|
B_WEBCAM_MKINTFUNC(uvccam)
|
||||||
(WebCamMediaAddOn* webcam, CamDeviceAddon **addon)
|
(WebCamMediaAddOn* webcam, CamDeviceAddon **addon)
|
||||||
|
|||||||
@@ -49,11 +49,20 @@ private:
|
|||||||
unsigned char *src, int32 width,
|
unsigned char *src, int32 width,
|
||||||
int32 height);
|
int32 height);
|
||||||
|
|
||||||
|
void _AddProcessingParameter(BParameterGroup* group,
|
||||||
|
int32 index,
|
||||||
|
const usbvc_processing_unit_descriptor*
|
||||||
|
descriptor);
|
||||||
float _AddParameter(BParameterGroup* group,
|
float _AddParameter(BParameterGroup* group,
|
||||||
BParameterGroup** subgroup, int32 index,
|
BParameterGroup** subgroup, int32 index,
|
||||||
uint16 wValue, const char* name);
|
uint16 wValue, const char* name);
|
||||||
int _AddAutoParameter(BParameterGroup* subgroup,
|
uint8 _AddAutoParameter(BParameterGroup* subgroup,
|
||||||
int32 index, uint16 wValue);
|
int32 index, uint16 wValue);
|
||||||
|
status_t _SetParameterValue(uint16 wValue,
|
||||||
|
int16 setValue);
|
||||||
|
status_t _SetParameterValue(uint16 wValue,
|
||||||
|
int8 setValue);
|
||||||
|
|
||||||
|
|
||||||
usbvc_interface_header_descriptor *fHeaderDescriptor;
|
usbvc_interface_header_descriptor *fHeaderDescriptor;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user