@@ -31,6 +31,7 @@ public:
virtual int enumerate() = 0;
std::shared_ptr<MediaDevice> search(const MediaDeviceMatch &dm);
+ std::shared_ptr<USBDevice> search(const USBDeviceMatch &dm);
Signal<> devicesAdded;
@@ -271,4 +271,18 @@ std::shared_ptr<MediaDevice> DeviceEnumerator::search(const MediaDeviceMatch &dm
return nullptr;
}
+std::shared_ptr<USBDevice> DeviceEnumerator::search(const USBDeviceMatch &dm)
+{
+ for (std::shared_ptr<USBDevice> &usb : usbDevices_) {
+ if (dm.match(usb.get())) {
+ LOG(DeviceEnumerator, Debug)
+ << "Successful match for USB device "
+ << usb->vid() << "-" << usb->pid();
+ return usb;
+ }
+ }
+
+ return nullptr;
+}
+
} /* namespace libcamera */
Add support for searching a USBDevice by providing a USBDeviceMatch to the device enumerator. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> --- include/libcamera/internal/device_enumerator.h | 1 + src/libcamera/device_enumerator.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+)