[libcamera-devel] [PATCH 2/3] libcamera: v4l2_subdevice: Add subdevice name

Jacopo Mondi jacopo at jmondi.org
Tue Feb 19 17:56:19 CET 2019


Add a deviceName_ field that contains the human readable name of the
subdevice, which is created using the name of the associated media
entity.

Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
 src/libcamera/include/v4l2_subdevice.h | 2 ++
 src/libcamera/v4l2_subdevice.cpp       | 9 ++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h
index c7045776555c..40becd0ca99b 100644
--- a/src/libcamera/include/v4l2_subdevice.h
+++ b/src/libcamera/include/v4l2_subdevice.h
@@ -42,6 +42,7 @@ public:
 	void close();
 
 	std::string deviceNode() const { return deviceNode_; }
+	std::string deviceName() const { return deviceName_; }
 
 	int setCrop(unsigned int pad, Rectangle *rect);
 	int setCompose(unsigned int pad, Rectangle *rect);
@@ -55,6 +56,7 @@ private:
 			 Rectangle *rect);
 
 	std::string deviceNode_;
+	std::string deviceName_;
 	int fd_;
 };
 
diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index 5665154a2762..4411ffa51460 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -134,7 +134,7 @@ LOG_DEFINE_CATEGORY(V4L2Subdev)
  * path
  */
 V4L2Subdevice::V4L2Subdevice(const MediaEntity *entity)
-	: deviceNode_(entity->deviceNode()), fd_(-1)
+	: deviceNode_(entity->deviceNode()), deviceName_(entity->name()), fd_(-1)
 {
 }
 
@@ -193,6 +193,13 @@ void V4L2Subdevice::close()
  * \return The subdevice's device node system path
  */
 
+/**
+ * \fn V4L2Subdevice::deviceName()
+ * \brief Retrieve the name of the media entity associated with the subdevice
+ *
+ * \return The name of the media entity the subdevice is associated to
+ */
+
 /**
  * \brief Set a crop rectangle on one of the V4L2 subdevice pads
  * \param[in] pad The 0-indexed pad number the rectangle is to be applied to
-- 
2.20.1



More information about the libcamera-devel mailing list