From e78832cf91a81539f6188cf38739c3547b74684b Mon Sep 17 00:00:00 2001 From: Daniel Semkowicz Date: Thu, 19 Jan 2023 09:41:06 +0100 Subject: rkisp1: Control camera lens position from IPA Allow control of lens position from the IPA, by setting corresponding af fields in the IPAFrameContext structure. Controls are then passed to the pipeline handler, which sets the lens position in CameraLens. Signed-off-by: Daniel Semkowicz --- src/ipa/rkisp1/ipa_context.h | 5 +++++ src/ipa/rkisp1/rkisp1.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) (limited to 'src/ipa/rkisp1') diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index b9b20653..1fac6af9 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -53,6 +53,11 @@ struct IPASessionConfiguration { }; struct IPAActiveState { + struct { + uint32_t lensPosition; + bool applyLensCtrls; + } af; + struct { struct { uint32_t exposure; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 9e861fc0..297161b2 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -270,6 +270,10 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW; }); + /* Lens position is unknown at the startup, so initilize the variable + * that holds the current position to something out of the range. */ + context_.activeState.af.lensPosition = std::numeric_limits::max(); + for (auto const &a : algorithms()) { Algorithm *algo = static_cast(a.get()); @@ -452,6 +456,14 @@ void IPARkISP1::setControls(unsigned int frame) ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain)); setSensorControls.emit(frame, ctrls); + + if (lensControls_ && context_.activeState.af.applyLensCtrls) { + context_.activeState.af.applyLensCtrls = false; + ControlList lensCtrls(*lensControls_); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, + static_cast(context_.activeState.af.lensPosition)); + setLensControls.emit(lensCtrls); + } } } /* namespace ipa::rkisp1 */ -- cgit v1.2.1