[libcamera-devel] [PATCH 1/2] libcamera: media_device: expose media graph model name

Niklas Söderlund niklas.soderlund at ragnatech.se
Mon Jan 21 16:30:04 CET 2019


Pipeline handlers such as the upcoming ucvideo handler needs the model
name to properly name the Camera object it creates. Store the model name
when querying the media device info and handle it in a similar fashion
as the driver name which is already retrieved.

Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
 src/libcamera/include/media_device.h | 2 ++
 src/libcamera/media_device.cpp       | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
index a8dec0d3347bd5fc..d96b8ec718427011 100644
--- a/src/libcamera/include/media_device.h
+++ b/src/libcamera/include/media_device.h
@@ -36,6 +36,7 @@ public:
 
 	const std::string driver() const { return driver_; }
 	const std::string devnode() const { return devnode_; }
+	const std::string model() const { return model_; }
 
 	const std::vector<MediaEntity *> &entities() const { return entities_; }
 	MediaEntity *getEntityByName(const std::string &name) const;
@@ -50,6 +51,7 @@ public:
 private:
 	std::string driver_;
 	std::string devnode_;
+	std::string model_;
 	int fd_;
 	bool valid_;
 	bool acquired_;
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index a346296bc38e8f3d..b315e4f383b3bbb1 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -162,6 +162,7 @@ int MediaDevice::open()
 	}
 
 	driver_ = info.driver;
+	model_ = info.model;
 
 	return 0;
 }
@@ -285,6 +286,12 @@ int MediaDevice::populate()
  * \return The MediaDevice devnode path
  */
 
+/**
+ * \fn MediaDevice::model()
+ * \brief Retrieve the media device model name
+ * \return The MediaDevice model name
+ */
+
 /**
  * \fn MediaDevice::entities()
  * \brief Retrieve the list of entities in the media graph
-- 
2.20.1



More information about the libcamera-devel mailing list