@@ -55,6 +55,8 @@ public:
Signal<> disconnected;
+ std::vector<MediaEntity *> locateEntities(unsigned int function);
+
protected:
std::string logPrefix() const override;
@@ -793,7 +793,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
@@ -828,4 +828,27 @@ 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 as defined by the
+ * MEDIA_ENT_F_* macros of the Media Controller API.
+ *
+ * \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 */