[libcamera-devel,v4,1/9] libcamera: Add members to MediaEntity to support ancillary entities
diff mbox series

Message ID 20220131223330.61563-2-djrscally@gmail.com
State Superseded
Headers show
Series
  • Enumerate CameraLens by following sensor's ancillary links
Related show

Commit Message

Daniel Scally Jan. 31, 2022, 10:33 p.m. UTC
With kernel support for ancillary links, we can describe the
relationship between two devices represented individually as instances
of MediaEntity. As the only property of that relationship is its
existence, describe those relationships in libcamera simply as a
vector of MediaEntity pointers to the ancillary devices.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
---
Changes in v4:

	- Reordered addAncillaryEntity() in the .cpp to match the .h

Changes in v3:

	- Fixed some style issues
	- Made addAncillaryEntity() private

 include/libcamera/internal/media_object.h |  4 ++++
 src/libcamera/media_object.cpp            | 15 +++++++++++++++
 2 files changed, 19 insertions(+)

Patch
diff mbox series

diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
index 90c63598..b1572968 100644
--- a/include/libcamera/internal/media_object.h
+++ b/include/libcamera/internal/media_object.h
@@ -104,6 +104,7 @@  public:
 	unsigned int deviceMinor() const { return minor_; }
 
 	const std::vector<MediaPad *> &pads() const { return pads_; }
+	const std::vector<MediaEntity *> ancillaryEntities() const { return ancillaryEntities_; }
 
 	const MediaPad *getPadByIndex(unsigned int index) const;
 	const MediaPad *getPadById(unsigned int id) const;
@@ -120,6 +121,8 @@  private:
 
 	void addPad(MediaPad *pad);
 
+	void addAncillaryEntity(MediaEntity *ancillaryEntity);
+
 	std::string name_;
 	unsigned int function_;
 	unsigned int flags_;
@@ -129,6 +132,7 @@  private:
 	unsigned int minor_;
 
 	std::vector<MediaPad *> pads_;
+	std::vector<MediaEntity *> ancillaryEntities_;
 };
 
 } /* namespace libcamera */
diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp
index f425d044..c78f4758 100644
--- a/src/libcamera/media_object.cpp
+++ b/src/libcamera/media_object.cpp
@@ -423,4 +423,19 @@  void MediaEntity::addPad(MediaPad *pad)
 	pads_.push_back(pad);
 }
 
+/**
+ * \brief Add a MediaEntity to the list of ancillary entities
+ * \param[in] ancillaryEntity The instance of MediaEntity to add
+ */
+void MediaEntity::addAncillaryEntity(MediaEntity *ancillaryEntity)
+{
+	ancillaryEntities_.push_back(ancillaryEntity);
+}
+
+/**
+ * \fn MediaEntity::ancillaryEntities()
+ * \brief Retrieve all ancillary entities of the entity
+ * \return The list of the entity's ancillary entities
+ */
+
 } /* namespace libcamera */