summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2023-06-05 10:14:06 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-06-06 18:22:20 +0300
commitfab47108e1e26d84d2c4afd3876f158b3a4c4f3f (patch)
tree90e8f1b8d15aaa34e4812268f5c200f3c2abd972 /src
parentd66ff77759dc5aca41f4c575d7c962e97547406f (diff)
ipa: rpi: Set lens position to hyperfocal on startup
On the first ipa->configure() call, set the lens position (if a lens is present) to the default position. Typically this would be the hyperfocal position based on the tuning data. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/ipa/rpi/common/ipa_base.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp
index 866f6924..f40f2e71 100644
--- a/src/ipa/rpi/common/ipa_base.cpp
+++ b/src/ipa/rpi/common/ipa_base.cpp
@@ -208,6 +208,26 @@ int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa
agcStatus.shutterTime = defaultExposureTime;
agcStatus.analogueGain = defaultAnalogueGain;
applyAGC(&agcStatus, ctrls);
+
+ /*
+ * Set the lens to the default (typically hyperfocal) position
+ * on first start.
+ */
+ if (lensPresent_) {
+ RPiController::AfAlgorithm *af =
+ dynamic_cast<RPiController::AfAlgorithm *>(controller_.getAlgorithm("af"));
+
+ if (af) {
+ float defaultPos =
+ ipaAfControls.at(&controls::LensPosition).def().get<float>();
+ ControlList lensCtrl(lensCtrls_);
+ int32_t hwpos;
+
+ af->setLensPosition(defaultPos, &hwpos);
+ lensCtrl.set(V4L2_CID_FOCUS_ABSOLUTE, hwpos);
+ result->lensControls = std::move(lensCtrl);
+ }
+ }
}
result->sensorControls = std::move(ctrls);