From 3ed4e6881740688b418826303447f815cdd83999 Mon Sep 17 00:00:00 2001 From: Daniel Semkowicz via libcamera-devel Date: Wed, 13 Jul 2022 10:43:12 +0200 Subject: ipa: rkisp1: Pass requests setting AF controls to the AF algorithm Pass the controls set by top level API to the AF algorithm if it was enabled. Signed-off-by: Daniel Semkowicz --- src/ipa/rkisp1/rkisp1.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 01bb54fb..53b53f12 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -28,6 +28,7 @@ #include "libcamera/internal/mapped_framebuffer.h" #include "libcamera/internal/yaml_parser.h" +#include "algorithms/af.h" #include "algorithms/agc.h" #include "algorithms/algorithm.h" #include "algorithms/awb.h" @@ -295,9 +296,56 @@ void IPARkISP1::unmapBuffers(const std::vector &ids) } void IPARkISP1::queueRequest([[maybe_unused]] const uint32_t frame, - [[maybe_unused]] const ControlList &controls) + const ControlList &controls) { - /* \todo Start processing for 'frame' based on 'controls'. */ + using namespace algorithms; + + for (auto const &ctrl : controls) { + unsigned int ctrlEnum = ctrl.first; + const ControlValue &ctrlValue = ctrl.second; + + LOG(IPARkISP1, Debug) << "Request ctrl: " + << controls::controls.at(ctrlEnum)->name() + << " = " << ctrlValue.toString(); + + switch (ctrlEnum) { + case controls::AF_MODE: { + Af *af = getAlgorithm(); + if (!af) { + LOG(IPARkISP1, Warning) << "Could not set AF_MODE - no AF algorithm"; + break; + } + + af->setMode(static_cast(ctrlValue.get())); + break; + } + case controls::AF_TRIGGER: { + Af *af = getAlgorithm(); + if (!af) { + LOG(IPARkISP1, Warning) << "Could not set AF_TRIGGER - no AF algorithm"; + break; + } + + af->setTrigger(static_cast(ctrlValue.get())); + break; + } + case controls::AF_PAUSE: { + Af *af = getAlgorithm(); + if (!af) { + LOG(IPARkISP1, Warning) << "Could not set AF_TRIGGER - no AF algorithm"; + break; + } + + af->setPause(static_cast(ctrlValue.get())); + break; + } + default: + LOG(IPARkISP1, Warning) + << "Ctrl " << controls::controls.at(ctrlEnum)->name() + << " is not handled."; + break; + } + } } void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) -- cgit v1.2.1