From fab47108e1e26d84d2c4afd3876f158b3a4c4f3f Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Mon, 5 Jun 2023 10:14:06 +0100 Subject: 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 Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/ipa/rpi/common/ipa_base.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/ipa/rpi') 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(controller_.getAlgorithm("af")); + + if (af) { + float defaultPos = + ipaAfControls.at(&controls::LensPosition).def().get(); + 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); -- cgit v1.2.1