pipeline: rpi: Fix for enumerating the media graphs
When there are multiple entities between the sensor and CFE device (e.g. a serialiser and deserialiser or multiple mux devices), the media graph enumeration would work incorrectly and report that the frontend entity was not found. This is because the found flag was stored locally in a boolean and got lost in the recursion. Fix this by explicitly tracking and returning the frontend found flag through the return value of enumerateVideoDevices(). This ensures the flag does not get lost through nested recursion. This flag can also be used to fail a camera registration if the frontend is not found. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Umang Jain <uajain@igalia.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
35ee8752b7
commit
5f94209b1d
2 changed files with 14 additions and 10 deletions
|
@ -806,7 +806,8 @@ int PipelineHandlerBase::registerCamera(std::unique_ptr<RPi::CameraData> &camera
|
|||
* chain. There may be a cascade of devices in this chain!
|
||||
*/
|
||||
MediaLink *link = sensorEntity->getPadByIndex(0)->links()[0];
|
||||
data->enumerateVideoDevices(link, frontendName);
|
||||
if (!data->enumerateVideoDevices(link, frontendName))
|
||||
return -EINVAL;
|
||||
|
||||
ipa::RPi::InitResult result;
|
||||
if (data->loadIPA(&result)) {
|
||||
|
@ -1018,16 +1019,20 @@ void CameraData::freeBuffers()
|
|||
* | Sensor2 | | Sensor3 |
|
||||
* +---------+ +---------+
|
||||
*/
|
||||
void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &frontend)
|
||||
bool CameraData::enumerateVideoDevices(MediaLink *link, const std::string &frontend)
|
||||
{
|
||||
const MediaPad *sinkPad = link->sink();
|
||||
const MediaEntity *entity = sinkPad->entity();
|
||||
bool frontendFound = false;
|
||||
|
||||
/* Once we reach the Frontend entity, we are done. */
|
||||
if (link->sink()->entity()->name() == frontend)
|
||||
return true;
|
||||
|
||||
/* We only deal with Video Mux and Bridge devices in cascade. */
|
||||
if (entity->function() != MEDIA_ENT_F_VID_MUX &&
|
||||
entity->function() != MEDIA_ENT_F_VID_IF_BRIDGE)
|
||||
return;
|
||||
return false;
|
||||
|
||||
/* Find the source pad for this Video Mux or Bridge device. */
|
||||
const MediaPad *sourcePad = nullptr;
|
||||
|
@ -1039,7 +1044,7 @@ void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &front
|
|||
* and this branch in the cascade.
|
||||
*/
|
||||
if (sourcePad)
|
||||
return;
|
||||
return false;
|
||||
|
||||
sourcePad = pad;
|
||||
}
|
||||
|
@ -1056,13 +1061,10 @@ void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &front
|
|||
* other Video Mux and Bridge devices.
|
||||
*/
|
||||
for (MediaLink *l : sourcePad->links()) {
|
||||
enumerateVideoDevices(l, frontend);
|
||||
/* Once we reach the Frontend entity, we are done. */
|
||||
if (l->sink()->entity()->name() == frontend) {
|
||||
frontendFound = true;
|
||||
frontendFound = enumerateVideoDevices(l, frontend);
|
||||
if (frontendFound)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* This identifies the end of our entity enumeration recursion. */
|
||||
if (link->source()->entity()->function() == MEDIA_ENT_F_CAM_SENSOR) {
|
||||
|
@ -1076,6 +1078,8 @@ void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &front
|
|||
bridgeDevices_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
return frontendFound;
|
||||
}
|
||||
|
||||
int CameraData::loadPipelineConfiguration()
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
void freeBuffers();
|
||||
virtual void platformFreeBuffers() = 0;
|
||||
|
||||
void enumerateVideoDevices(MediaLink *link, const std::string &frontend);
|
||||
bool enumerateVideoDevices(MediaLink *link, const std::string &frontend);
|
||||
|
||||
int loadPipelineConfiguration();
|
||||
int loadIPA(ipa::RPi::InitResult *result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue