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>
This commit is contained in:
Kieran Bingham 2025-04-02 16:39:16 +09:00 committed by Paul Elder
parent ee2b011b65
commit 0785f5f99a
2 changed files with 25 additions and 1 deletions

View file

@ -55,6 +55,8 @@ public:
Signal<> disconnected; Signal<> disconnected;
std::vector<MediaEntity *> locateEntities(unsigned int function);
protected: protected:
std::string logPrefix() const override; std::string logPrefix() const override;

View file

@ -829,4 +829,26 @@ int MediaDevice::setupLink(const MediaLink *link, unsigned int flags)
return 0; 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 */ } /* namespace libcamera */