[libcamera-devel,v2,12/14] ipa: raspberrypi: Add lens position to DeviceStatus
diff mbox series

Message ID 20230123154934.27803-13-naush@raspberrypi.com
State Accepted
Commit 9b0db2aa4349817a2064e8593790ce45bedba613
Headers show
Series
  • Raspberry Pi: Camera Module 3 support
Related show

Commit Message

Naushir Patuck Jan. 23, 2023, 3:49 p.m. UTC
Add the current frame's lens position (in dioptres) to the DeviceStatus
structure. This value is obtained from the AfAlgorithm::getLensPosition()
member function. Return this lens position back to the pipeline handler to
store in the metadata field of the request.

As a drive-by, fixup some inaccurate comments in the DeviceStatus structure.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Nick Hollinghurst nick.hollinghurst@raspberrypi.com
---
 src/ipa/raspberrypi/controller/device_status.h | 4 ++--
 src/ipa/raspberrypi/raspberrypi.cpp            | 7 +++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h
index 4384c2149589..c45db7499f94 100644
--- a/src/ipa/raspberrypi/controller/device_status.h
+++ b/src/ipa/raspberrypi/controller/device_status.h
@@ -32,9 +32,9 @@  struct DeviceStatus {
 	/* line length for the current frame */
 	libcamera::utils::Duration lineLength;
 	double analogueGain;
-	/* 1.0/distance-in-metres, or 0 if unknown */
+	/* 1.0/distance-in-metres */
 	std::optional<double> lensPosition;
-	/* 1/f so that brightness quadruples when this doubles, or 0 if unknown */
+	/* 1/f so that brightness quadruples when this doubles */
 	std::optional<double> aperture;
 	/* proportional to brightness with 0 = no flash, 1 = maximum flash */
 	std::optional<double> flashIntensity;
diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
index fbace14b1afe..5f7397e2ab21 100644
--- a/src/ipa/raspberrypi/raspberrypi.cpp
+++ b/src/ipa/raspberrypi/raspberrypi.cpp
@@ -586,6 +586,8 @@  void IPARPi::reportMetadata(unsigned int ipaContext)
 				       helper_->exposure(deviceStatus->frameLength, deviceStatus->lineLength).get<std::micro>());
 		if (deviceStatus->sensorTemperature)
 			libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensorTemperature);
+		if (deviceStatus->lensPosition)
+			libcameraMetadata_.set(controls::LensPosition, *deviceStatus->lensPosition);
 	}
 
 	AgcStatus *agcStatus = rpiMetadata.getLocked<AgcStatus>("agc.status");
@@ -1352,6 +1354,11 @@  void IPARPi::fillDeviceStatus(const ControlList &sensorControls, unsigned int ip
 	deviceStatus.analogueGain = helper_->gain(gainCode);
 	deviceStatus.frameLength = mode_.height + vblank;
 
+	RPiController::AfAlgorithm *af = dynamic_cast<RPiController::AfAlgorithm *>(
+			controller_.getAlgorithm("af"));
+	if (af)
+		deviceStatus.lensPosition = af->getLensPosition();
+
 	LOG(IPARPI, Debug) << "Metadata - " << deviceStatus;
 
 	rpiMetadata_[ipaContext].set("device.status", deviceStatus);