[libcamera-devel] [PATCH v6 1/9] libcamera: device_enumerator: Add method to lookup sysfs path
Niklas Söderlund
niklas.soderlund at ragnatech.se
Mon Aug 3 23:17:25 CEST 2020
Add an implementation to lookup a device nodes sysfs interface path
based on the assumption that device name under /dev matches the one
under /sysfs. Subclasses of the DeviceEnumerator may override this to
create more clever methods to lookup the path.
Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
include/libcamera/internal/device_enumerator.h | 2 ++
src/libcamera/device_enumerator.cpp | 14 ++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h
index a9850400229d2b53..11961f4f9304f6d7 100644
--- a/include/libcamera/internal/device_enumerator.h
+++ b/include/libcamera/internal/device_enumerator.h
@@ -45,6 +45,8 @@ public:
std::shared_ptr<MediaDevice> search(const DeviceMatch &dm);
+ virtual std::string lookupSysfsPath(const std::string &deviceNode);
+
Signal<> devicesAdded;
protected:
diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
index 647974b17341f44b..ef2451ac29159bf0 100644
--- a/src/libcamera/device_enumerator.cpp
+++ b/src/libcamera/device_enumerator.cpp
@@ -318,4 +318,18 @@ std::shared_ptr<MediaDevice> DeviceEnumerator::search(const DeviceMatch &dm)
return nullptr;
}
+/**
+ * \brief Lookup a nodes sysfs path
+ * \param[in] deviceNode device node to lookup
+ *
+ * Lookup \a deviceNode sysfs interface.
+ *
+ * \return Path in sysfs
+ */
+std::string DeviceEnumerator::lookupSysfsPath(const std::string &deviceNode)
+{
+ std::string dev = basename(deviceNode.c_str());
+ return "/sys/class/video4linux/" + dev;
+}
+
} /* namespace libcamera */
--
2.28.0
More information about the libcamera-devel
mailing list