[libcamera-devel,2/2] libcamera: raspberrypi: fetch correct value for sensor's modeSensitivity
diff mbox series

Message ID 20210628085630.2081-3-david.plowman@raspberrypi.com
State Superseded
Headers show
Series
  • Application support for per-mode sensitivities
Related show

Commit Message

David Plowman June 28, 2021, 8:56 a.m. UTC
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 CameraConfiguration.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 include/libcamera/ipa/raspberrypi.mojom            | 7 ++++++-
 src/ipa/raspberrypi/raspberrypi.cpp                | 7 +++++--
 src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++++---
 3 files changed, 17 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom
index 606d1de4..3a71c167 100644
--- a/include/libcamera/ipa/raspberrypi.mojom
+++ b/include/libcamera/ipa/raspberrypi.mojom
@@ -38,6 +38,10 @@  struct IPAConfig {
 	libcamera.FileDescriptor lsTableHandle;
 };
 
+struct IPAConfigResult {
+       float modeSensitivity;
+};
+
 struct StartConfig {
 	libcamera.ControlList controls;
 	int32 dropFrameCount;
@@ -57,6 +61,7 @@  interface IPARPiInterface {
 	 * \param[in] entityControls Controls provided by the pipeline entities
 	 * \param[in] ipaConfig Pipeline-handler-specific configuration data
 	 * \param[out] controls Controls to apply by the pipeline entity
+	 * \param[out] result Other results that the pipeline handler may require
 	 *
 	 * This method shall be called when the camera is configured to inform
 	 * the IPA of the camera's streams and the sensor settings.
@@ -71,7 +76,7 @@  interface IPARPiInterface {
 		  map<uint32, libcamera.IPAStream> streamConfig,
 		  map<uint32, libcamera.ControlInfoMap> entityControls,
 		  IPAConfig ipaConfig)
-		=> (int32 ret, libcamera.ControlList controls);
+		=> (int32 ret, libcamera.ControlList controls, IPAConfigResult result);
 
 	/**
 	 * \fn mapBuffers()
diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
index 9ce0db08..76376e06 100644
--- a/src/ipa/raspberrypi/raspberrypi.cpp
+++ b/src/ipa/raspberrypi/raspberrypi.cpp
@@ -96,7 +96,7 @@  public:
 		      const std::map<unsigned int, IPAStream> &streamConfig,
 		      const std::map<unsigned int, ControlInfoMap> &entityControls,
 		      const ipa::RPi::IPAConfig &data,
-		      ControlList *controls) override;
+		      ControlList *controls, ipa::RPi::IPAConfigResult *result) override;
 	void mapBuffers(const std::vector<IPABuffer> &buffers) override;
 	void unmapBuffers(const std::vector<unsigned int> &ids) override;
 	void signalStatReady(const uint32_t bufferId) override;
@@ -336,7 +336,7 @@  int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,
 		      [[maybe_unused]] const std::map<unsigned int, IPAStream> &streamConfig,
 		      const std::map<unsigned int, ControlInfoMap> &entityControls,
 		      const ipa::RPi::IPAConfig &ipaConfig,
-		      ControlList *controls)
+		      ControlList *controls, ipa::RPi::IPAConfigResult *result)
 {
 	if (entityControls.size() != 2) {
 		LOG(IPARPI, Error) << "No ISP or sensor controls found.";
@@ -388,6 +388,9 @@  int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,
 	/* Pass the camera mode to the CamHelper to setup algorithms. */
 	helper_->SetCameraMode(mode_);
 
+	/* The pipeline handler passes out the mode's sensitivity. */
+	result->modeSensitivity = mode_.sensitivity;
+
 	if (firstStart_) {
 		/* Supply initial values for frame durations. */
 		applyFrameDurations(defaultMinFrameDuration, defaultMaxFrameDuration);
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index a65b4568..7bace5b8 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -146,7 +146,7 @@  public:
 	void frameStarted(uint32_t sequence);
 
 	int loadIPA(ipa::RPi::SensorConfig *sensorConfig);
-	int configureIPA(const CameraConfiguration *config);
+	int configureIPA(CameraConfiguration *config);
 
 	void statsMetadataComplete(uint32_t bufferId, const ControlList &controls);
 	void runIsp(uint32_t bufferId);
@@ -1235,7 +1235,7 @@  int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig)
 	return ipa_->init(settings, sensorConfig);
 }
 
-int RPiCameraData::configureIPA(const CameraConfiguration *config)
+int RPiCameraData::configureIPA(CameraConfiguration *config)
 {
 	/* We know config must be an RPiCameraConfiguration. */
 	const RPiCameraConfiguration *rpiConfig =
@@ -1284,13 +1284,16 @@  int RPiCameraData::configureIPA(const CameraConfiguration *config)
 
 	/* Ready the IPA - it must know about the sensor resolution. */
 	ControlList controls;
+	ipa::RPi::IPAConfigResult result;
 	ret = ipa_->configure(sensorInfo_, streamConfig, entityControls, ipaConfig,
-			      &controls);
+			      &controls, &result);
 	if (ret < 0) {
 		LOG(RPI, Error) << "IPA configuration failed!";
 		return -EPIPE;
 	}
 
+	config->modeSensitivity = result.modeSensitivity;
+
 	if (!controls.empty())
 		unicam_[Unicam::Image].dev()->setControls(&controls);