summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2025-04-02 16:39:16 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2025-04-29 01:20:50 +0900
commit0785f5f99acb6d41149394b28a1e9c79d39a4484 (patch)
tree60d627a586f3d99f39884d8a9a00b8014a45aa2c /src
parentee2b011b65c69fa2126c0b118a52871d87776b0c (diff)
libcamera: media_device: Add helper to return matching entities
Provide a helper on the MediaDevice to return a list of all available entities which match a given function in the graph. As a drive by, also fix a whitespace error in the documentation of MediaDevice::setupLink. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/media_device.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index 75abd91d..353f34a8 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -794,7 +794,7 @@ void MediaDevice::fixupEntityFlags(struct media_v2_entity *entity)
* low-level link setup as it performs no checks on the validity of the \a
* flags, and assumes that the supplied \a flags are valid for the link (e.g.
* immutable links cannot be disabled).
-*
+ *
* \sa MediaLink::setEnabled(bool enable)
*
* \return 0 on success or a negative error code otherwise
@@ -829,4 +829,26 @@ int MediaDevice::setupLink(const MediaLink *link, unsigned int flags)
return 0;
}
+/**
+ * \brief Identify all entities of a common function in the MediaDevice
+ * \param[in] function The entity function to search for
+ *
+ * Search all entities within the graph of the MediaDevice and return
+ * a vector of those which match the given function.
+ *
+ * \return A vector of matching entities
+ */
+std::vector<MediaEntity *> MediaDevice::locateEntities(unsigned int function)
+{
+ std::vector<MediaEntity *> found;
+
+ /* Gather all the entities matching the function they expose. */
+ for (MediaEntity *entity : entities()) {
+ if (entity->function() == function)
+ found.push_back(entity);
+ }
+
+ return found;
+}
+
} /* namespace libcamera */