libcamera: raspberrypi: Fetch correct value for SensorSensitivity

These changes retrieve the correct value for sensitivity of the mode
selected for the sensor. This value is known to the CamHelper which
passes it across to the pipeline handler so that it can be set
correctly in the camera properties.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
David Plowman 2022-04-21 16:11:17 +01:00 committed by Kieran Bingham
parent 998d23c0a2
commit 065a9e6c05
3 changed files with 19 additions and 7 deletions

View file

@ -38,6 +38,10 @@ struct IPAConfig {
libcamera.SharedFD lsTableHandle; libcamera.SharedFD lsTableHandle;
}; };
struct IPAConfigResult {
float modeSensitivity;
};
struct StartConfig { struct StartConfig {
libcamera.ControlList controls; libcamera.ControlList controls;
int32 dropFrameCount; int32 dropFrameCount;
@ -58,6 +62,7 @@ interface IPARPiInterface {
* \param[in] entityControls Controls provided by the pipeline entities * \param[in] entityControls Controls provided by the pipeline entities
* \param[in] ipaConfig Pipeline-handler-specific configuration data * \param[in] ipaConfig Pipeline-handler-specific configuration data
* \param[out] controls Controls to apply by the pipeline entity * \param[out] controls Controls to apply by the pipeline entity
* \param[out] result Other results that the pipeline handler may require
* *
* This function shall be called when the camera is configured to inform * This function shall be called when the camera is configured to inform
* the IPA of the camera's streams and the sensor settings. * the IPA of the camera's streams and the sensor settings.
@ -72,7 +77,7 @@ interface IPARPiInterface {
map<uint32, libcamera.IPAStream> streamConfig, map<uint32, libcamera.IPAStream> streamConfig,
map<uint32, libcamera.ControlInfoMap> entityControls, map<uint32, libcamera.ControlInfoMap> entityControls,
IPAConfig ipaConfig) IPAConfig ipaConfig)
=> (int32 ret, libcamera.ControlList controls); => (int32 ret, libcamera.ControlList controls, IPAConfigResult result);
/** /**
* \fn mapBuffers() * \fn mapBuffers()

View file

@ -99,7 +99,7 @@ public:
const std::map<unsigned int, IPAStream> &streamConfig, const std::map<unsigned int, IPAStream> &streamConfig,
const std::map<unsigned int, ControlInfoMap> &entityControls, const std::map<unsigned int, ControlInfoMap> &entityControls,
const IPAConfig &data, const IPAConfig &data,
ControlList *controls) override; ControlList *controls, IPAConfigResult *result) override;
void mapBuffers(const std::vector<IPABuffer> &buffers) override; void mapBuffers(const std::vector<IPABuffer> &buffers) override;
void unmapBuffers(const std::vector<unsigned int> &ids) override; void unmapBuffers(const std::vector<unsigned int> &ids) override;
void signalStatReady(const uint32_t bufferId) override; void signalStatReady(const uint32_t bufferId) override;
@ -344,7 +344,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,
[[maybe_unused]] const std::map<unsigned int, IPAStream> &streamConfig, [[maybe_unused]] const std::map<unsigned int, IPAStream> &streamConfig,
const std::map<unsigned int, ControlInfoMap> &entityControls, const std::map<unsigned int, ControlInfoMap> &entityControls,
const IPAConfig &ipaConfig, const IPAConfig &ipaConfig,
ControlList *controls) ControlList *controls, IPAConfigResult *result)
{ {
if (entityControls.size() != 2) { if (entityControls.size() != 2) {
LOG(IPARPI, Error) << "No ISP or sensor controls found."; LOG(IPARPI, Error) << "No ISP or sensor controls found.";
@ -404,6 +404,9 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,
*/ */
ControlList ctrls(sensorCtrls_); ControlList ctrls(sensorCtrls_);
/* The pipeline handler passes out the mode's sensitivity. */
result->modeSensitivity = mode_.sensitivity;
if (firstStart_) { if (firstStart_) {
/* Supply initial values for frame durations. */ /* Supply initial values for frame durations. */
applyFrameDurations(defaultMinFrameDuration, defaultMaxFrameDuration); applyFrameDurations(defaultMinFrameDuration, defaultMaxFrameDuration);

View file

@ -200,7 +200,7 @@ public:
void frameStarted(uint32_t sequence); void frameStarted(uint32_t sequence);
int loadIPA(ipa::RPi::SensorConfig *sensorConfig); int loadIPA(ipa::RPi::SensorConfig *sensorConfig);
int configureIPA(const CameraConfiguration *config); int configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result);
void enumerateVideoDevices(MediaLink *link); void enumerateVideoDevices(MediaLink *link);
@ -898,7 +898,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
data->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop); data->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop);
ret = data->configureIPA(config); ipa::RPi::IPAConfigResult result;
ret = data->configureIPA(config, &result);
if (ret) if (ret)
LOG(RPI, Error) << "Failed to configure the IPA: " << ret; LOG(RPI, Error) << "Failed to configure the IPA: " << ret;
@ -937,6 +938,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
*/ */
data->properties_.set(properties::ScalerCropMaximum, data->sensorInfo_.analogCrop); data->properties_.set(properties::ScalerCropMaximum, data->sensorInfo_.analogCrop);
/* Store the mode sensitivity for the application. */
data->properties_.set(properties::SensorSensitivity, result.modeSensitivity);
/* Setup the Video Mux/Bridge entities. */ /* Setup the Video Mux/Bridge entities. */
for (auto &[device, link] : data->bridgeDevices_) { for (auto &[device, link] : data->bridgeDevices_) {
/* /*
@ -1528,7 +1532,7 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig)
return ipa_->init(settings, sensorConfig); return ipa_->init(settings, sensorConfig);
} }
int RPiCameraData::configureIPA(const CameraConfiguration *config) int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result)
{ {
std::map<unsigned int, IPAStream> streamConfig; std::map<unsigned int, IPAStream> streamConfig;
std::map<unsigned int, ControlInfoMap> entityControls; std::map<unsigned int, ControlInfoMap> entityControls;
@ -1574,7 +1578,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)
/* Ready the IPA - it must know about the sensor resolution. */ /* Ready the IPA - it must know about the sensor resolution. */
ControlList controls; ControlList controls;
ret = ipa_->configure(sensorInfo_, streamConfig, entityControls, ipaConfig, ret = ipa_->configure(sensorInfo_, streamConfig, entityControls, ipaConfig,
&controls); &controls, result);
if (ret < 0) { if (ret < 0) {
LOG(RPI, Error) << "IPA configuration failed!"; LOG(RPI, Error) << "IPA configuration failed!";
return -EPIPE; return -EPIPE;