summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-20 22:49:23 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-23 13:30:24 +0200
commit3f97be923c11df4324f20a94591dc5562a05c7ba (patch)
tree8e7874bbf545130c2e876d0e1333b7a934c15a01
parentd6f5621e1501d236e0e1762e5cd055eb3c8af25d (diff)
libcamera: device_enumerator_udev: Don't add media device twice
Commit 68daa9302f90 ("libcamera: device_enumerator: Don't stop if one device fails") introduced a bug in device enumeration. Previously, a media device would only be added when all its dependencies were present, as indicated by populateMediaDevice() returning 0. The commit changed the logic to propagate the populateMediaDevice() return code up, but mistakenly added the media device to the enumerator even when dependencies were missing. This causes media devices enumerated with missing dependencies to be added twice, once when enumerating the media device itself, and a second time when all the dependencies are found. Fix it by deferring addition of the media device when dependencies are missing, and add debug messages to track this process. Fixes: 68daa9302f90 ("libcamera: device_enumerator: Don't stop if one device fails") Reported-by: Andrey Konovalov <andrey.konovalov@linaro.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--src/libcamera/device_enumerator_udev.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp
index 87638c59..e5535054 100644
--- a/src/libcamera/device_enumerator_udev.cpp
+++ b/src/libcamera/device_enumerator_udev.cpp
@@ -90,6 +90,13 @@ int DeviceEnumeratorUdev::addUdevDevice(struct udev_device *dev)
return ret;
}
+ if (ret) {
+ LOG(DeviceEnumerator, Debug)
+ << "Defer media device " << media->deviceNode()
+ << " due to " << ret << " missing dependencies";
+ return 0;
+ }
+
addDevice(media);
return 0;
}
@@ -313,6 +320,9 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)
deps->deps_.erase(devnum);
if (deps->deps_.empty()) {
+ LOG(DeviceEnumerator, Debug)
+ << "All dependencies for media device "
+ << deps->media_->deviceNode() << " found";
addDevice(deps->media_);
pending_.remove(*deps);
}