kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Simplify USB id retrieval
rodzic
13dffa0915
commit
bb318cf8f3
|
@ -4845,25 +4845,24 @@ static Genesys_Device* attach_device_by_name(SANE_String_Const devname, bool may
|
|||
usb_dev.open(devname);
|
||||
DBG(DBG_info, "%s: device `%s' successfully opened\n", __func__, devname);
|
||||
|
||||
int vendor, product;
|
||||
usb_dev.get_vendor_product(vendor, product);
|
||||
auto vendor_id = usb_dev.get_vendor_id();
|
||||
auto product_id = usb_dev.get_product_id();
|
||||
usb_dev.close();
|
||||
|
||||
/* KV-SS080 is an auxiliary device which requires a master device to be here */
|
||||
if(vendor == 0x04da && product == 0x100f)
|
||||
{
|
||||
if (vendor_id == 0x04da && product_id == 0x100f) {
|
||||
present = false;
|
||||
sanei_usb_find_devices (vendor, 0x1006, check_present);
|
||||
sanei_usb_find_devices (vendor, 0x1007, check_present);
|
||||
sanei_usb_find_devices (vendor, 0x1010, check_present);
|
||||
sanei_usb_find_devices(vendor_id, 0x1006, check_present);
|
||||
sanei_usb_find_devices(vendor_id, 0x1007, check_present);
|
||||
sanei_usb_find_devices(vendor_id, 0x1010, check_present);
|
||||
if (present == false) {
|
||||
throw SaneException("master device not present");
|
||||
}
|
||||
}
|
||||
|
||||
Genesys_Device* dev = attach_usb_device(devname, vendor, product);
|
||||
Genesys_Device* dev = attach_usb_device(devname, vendor_id, product_id);
|
||||
|
||||
DBG(DBG_info, "%s: found %u flatbed scanner %u at %s\n", __func__, vendor, product,
|
||||
DBG(DBG_info, "%s: found %u flatbed scanner %u at %s\n", __func__, vendor_id, product_id,
|
||||
dev->file_name.c_str());
|
||||
|
||||
return dev;
|
||||
|
|
|
@ -96,12 +96,18 @@ void TestUsbDevice::close()
|
|||
name_ = "";
|
||||
}
|
||||
|
||||
void TestUsbDevice::get_vendor_product(int& vendor, int& product)
|
||||
std::uint16_t TestUsbDevice::get_vendor_id()
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
assert_is_open();
|
||||
vendor = vendor_;
|
||||
product = product_;
|
||||
return vendor_;
|
||||
}
|
||||
|
||||
std::uint16_t TestUsbDevice::get_product_id()
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
assert_is_open();
|
||||
return product_;
|
||||
}
|
||||
|
||||
std::uint16_t TestUsbDevice::get_bcd_device()
|
||||
|
|
|
@ -63,7 +63,8 @@ public:
|
|||
void reset() override;
|
||||
void close() override;
|
||||
|
||||
void get_vendor_product(int& vendor, int& product) override;
|
||||
std::uint16_t get_vendor_id() override;
|
||||
std::uint16_t get_product_id() override;
|
||||
std::uint16_t get_bcd_device() override;
|
||||
|
||||
void control_msg(int rtype, int reg, int value, int index, int length,
|
||||
|
|
|
@ -101,11 +101,24 @@ void UsbDevice::close()
|
|||
sanei_usb_close(device_num);
|
||||
}
|
||||
|
||||
void UsbDevice::get_vendor_product(int& vendor, int& product)
|
||||
std::uint16_t UsbDevice::get_vendor_id()
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
assert_is_open();
|
||||
int vendor = 0;
|
||||
int product = 0;
|
||||
TIE(sanei_usb_get_vendor_product(device_num_, &vendor, &product));
|
||||
return static_cast<std::uint16_t>(vendor);
|
||||
}
|
||||
|
||||
std::uint16_t UsbDevice::get_product_id()
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
assert_is_open();
|
||||
int vendor = 0;
|
||||
int product = 0;
|
||||
TIE(sanei_usb_get_vendor_product(device_num_, &vendor, &product));
|
||||
return static_cast<std::uint16_t>(product);
|
||||
}
|
||||
|
||||
std::uint16_t UsbDevice::get_bcd_device()
|
||||
|
|
|
@ -71,7 +71,8 @@ public:
|
|||
virtual void reset() = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
virtual void get_vendor_product(int& vendor, int& product) = 0;
|
||||
virtual std::uint16_t get_vendor_id() = 0;
|
||||
virtual std::uint16_t get_product_id() = 0;
|
||||
virtual std::uint16_t get_bcd_device() = 0;
|
||||
|
||||
virtual void control_msg(int rtype, int reg, int value, int index, int length,
|
||||
|
@ -97,7 +98,8 @@ public:
|
|||
void reset() override;
|
||||
void close() override;
|
||||
|
||||
void get_vendor_product(int& vendor, int& product) override;
|
||||
std::uint16_t get_vendor_id() override;
|
||||
std::uint16_t get_product_id() override;
|
||||
std::uint16_t get_bcd_device() override;
|
||||
|
||||
void control_msg(int rtype, int reg, int value, int index, int length,
|
||||
|
|
Ładowanie…
Reference in New Issue