libcamera: camera_sensor: Discover VCMs through ancillary links

Add a function to check for and initialise any VCMs linked to the
CameraSensor's entity by ancillary links. This should initialise
the lens_ member with the linked entity. Call the new function
during CameraSensor::init().

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Daniel Scally
2022-03-03 23:49:51 +00:00
committed by Kieran Bingham
parent 2cde99032f
commit 9c003a5321
2 changed files with 41 additions and 0 deletions
+40
View File
@@ -172,6 +172,10 @@ int CameraSensor::init()
if (ret)
return ret;
ret = discoverAncillaryDevices();
if (ret)
return ret;
return applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);
}
@@ -443,6 +447,42 @@ int CameraSensor::initProperties()
return 0;
}
/**
* \brief Check for and initialise any ancillary devices
*
* Sensors sometimes have ancillary devices such as a Lens or Flash that could
* be linked to their MediaEntity by the kernel. Search for and handle any
* such device.
*
* \todo Handle MEDIA_ENT_F_FLASH too.
*/
int CameraSensor::discoverAncillaryDevices()
{
int ret;
for (MediaEntity *ancillary : entity_->ancillaryEntities()) {
switch (ancillary->function()) {
case MEDIA_ENT_F_LENS:
focusLens_ = std::make_unique<CameraLens>(ancillary);
ret = focusLens_->init();
if (ret) {
LOG(CameraSensor, Error)
<< "CameraLens initialisation failed";
return ret;
}
break;
default:
LOG(CameraSensor, Warning)
<< "Unsupported ancillary entity function "
<< ancillary->function();
break;
}
}
return 0;
}
/**
* \fn CameraSensor::model()
* \brief Retrieve the sensor model name