* Make usb device detection in usb_webcam identical to the way the usb bus_manager handles it.
* Fix some minor printf()-style warnings in the debug build of usb_webcam. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29279 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -491,7 +491,7 @@ CamDevice::DataPumpThread()
|
|||||||
len = fBulkIn->BulkTransfer(fBuffer, fBufferLen);
|
len = fBulkIn->BulkTransfer(fBuffer, fBufferLen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PRINT((CH ": got %d bytes" CT, len));
|
PRINT((CH ": got %ld bytes" CT, len));
|
||||||
#ifdef DEBUG_WRITE_DUMP
|
#ifdef DEBUG_WRITE_DUMP
|
||||||
write(fDumpFD, fBuffer, len);
|
write(fDumpFD, fBuffer, len);
|
||||||
#endif
|
#endif
|
||||||
@@ -618,23 +618,48 @@ CamDeviceAddon::Sniff(BUSBDevice *device)
|
|||||||
return ENODEV;
|
return ENODEV;
|
||||||
if (!device)
|
if (!device)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
for (uint32 i = 0; fSupportedDevices[i].vendor; i++)
|
|
||||||
|
bool supported = false;
|
||||||
|
for (uint32 i = 0; !supported && fSupportedDevices[i].vendor; i++)
|
||||||
{
|
{
|
||||||
/* PRINT((CH "{%u,%u,%u,0x%x,0x%x} <> {%u,%u,%u,0x%x,0x%x}" CT,
|
if ((fSupportedDevices[i].desc.vendor != 0
|
||||||
device.Class(), device.Subclass(), device.Protocol(), device.VendorID(), device.ProductID(),
|
&& device->VendorID() != fSupportedDevices[i].desc.vendor)
|
||||||
fSupportedDevices[i].desc.dev_class, fSupportedDevices[i].desc.dev_subclass, fSupportedDevices[i].desc.dev_protocol, fSupportedDevices[i].desc.vendor, fSupportedDevices[i].desc.product));*/
|
|| (fSupportedDevices[i].desc.product != 0
|
||||||
/* if (device.Class() != fSupportedDevices[i].desc.dev_class)
|
&& device->ProductID() != fSupportedDevices[i].desc.product))
|
||||||
continue;
|
continue;
|
||||||
if (device.Subclass() != fSupportedDevices[i].desc.dev_subclass)
|
|
||||||
continue;
|
if ((fSupportedDevices[i].desc.dev_class == 0
|
||||||
if (device.Protocol() != fSupportedDevices[i].desc.dev_protocol)
|
|| device->Class() == fSupportedDevices[i].desc.dev_class)
|
||||||
continue;*/
|
&& (fSupportedDevices[i].desc.dev_subclass == 0
|
||||||
if (device->VendorID() != fSupportedDevices[i].desc.vendor)
|
|| device->Subclass() == fSupportedDevices[i].desc.dev_subclass)
|
||||||
continue;
|
&& (fSupportedDevices[i].desc.dev_protocol == 0
|
||||||
if (device->ProductID() != fSupportedDevices[i].desc.product)
|
|| device->Protocol() == fSupportedDevices[i].desc.dev_protocol)) {
|
||||||
continue;
|
supported = true;
|
||||||
return i;
|
}
|
||||||
|
|
||||||
|
// we have to check all interfaces for matching class/subclass/protocol
|
||||||
|
for (uint32 j = 0; !supported && j < device->CountConfigurations(); j++) {
|
||||||
|
const BUSBConfiguration* cfg = device->ConfigurationAt(j);
|
||||||
|
for (uint32 k = 0; !supported && k < cfg->CountInterfaces(); k++) {
|
||||||
|
const BUSBInterface* intf = cfg->InterfaceAt(k);
|
||||||
|
for (uint32 l = 0; !supported && l < intf->CountAlternates(); l++) {
|
||||||
|
const BUSBInterface* alt = intf->AlternateAt(l);
|
||||||
|
if ((fSupportedDevices[i].desc.dev_class == 0
|
||||||
|
|| alt->Class() == fSupportedDevices[i].desc.dev_class)
|
||||||
|
&& (fSupportedDevices[i].desc.dev_subclass == 0
|
||||||
|
|| alt->Subclass() == fSupportedDevices[i].desc.dev_subclass)
|
||||||
|
&& (fSupportedDevices[i].desc.dev_protocol == 0
|
||||||
|
|| alt->Protocol() == fSupportedDevices[i].desc.dev_protocol)) {
|
||||||
|
supported = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supported)
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ CamRoster::CountCameras()
|
|||||||
{
|
{
|
||||||
int32 count;
|
int32 count;
|
||||||
fLocker.Lock();
|
fLocker.Lock();
|
||||||
PRINT((CH "(): %d cameras" CT, fCameras.CountItems()));
|
PRINT((CH "(): %ld cameras" CT, fCameras.CountItems()));
|
||||||
count = fCameras.CountItems();
|
count = fCameras.CountItems();
|
||||||
fLocker.Unlock();
|
fLocker.Unlock();
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
Reference in New Issue
Block a user