From patchwork Mon Jun 13 14:28:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 16216 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 31D5BC3279 for ; Mon, 13 Jun 2022 14:29:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D70D86564F; Mon, 13 Jun 2022 16:29:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655130549; bh=3d3YCVuSR1T5JIzEhU3hNZBepDk383+F08oRIFv/9+g=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=2FNkTBfI4EEgf5Mp2zfMMbh4Qa7Y4PFe9MLAa8jol7RK1XWPrdlPnL1FgdY2S5Swe Dcyt78n+Xzm5EBp237gSISN7X63NnyxTWLjrryd0W6176CM0LS/6Xm/3c+o+ovwaUJ lLRyX12FOM8Vz2mbRxtq+YW4gnebs/UExD6zTgWtbY04LP/hEuvd6hyw/i9V34EqKq VLBCK55Zqyt5vtmgQBfkk73KSgKxcR0BR/SWH8LiTVkbgvT7lBQGFP/764FPrkr5bw 13Qxyowg2qCSWTKlqJVlCbH2Fxt/w5j0uqMkVPTrd2WnyJ16lfmLh88ZQXZn9tFbw7 hjIFVVey8FnbA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B2A9365636 for ; Mon, 13 Jun 2022 16:29:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="t4m203rm"; dkim-atps=neutral Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:a1c7:c28c:7720:9b30]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 60FCC87B; Mon, 13 Jun 2022 16:29:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655130541; bh=3d3YCVuSR1T5JIzEhU3hNZBepDk383+F08oRIFv/9+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t4m203rmCcGT7h8puhZ6aoRQmAFbEt/GOqwi7Y9bGseanGFqjAvojgjlpYTwUGRRy abOI4ADKn9WQENst+L4CriDrdva3/rYVFlWz8at2d/gExaRxMdvsDKHjVcl8qPt6Af X1os7yrCl5bI/RgeeK5tuJUrM9bvIDXp50Q5LBn8= To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Jun 2022 16:28:51 +0200 Message-Id: <20220613142853.98484-9-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220613142853.98484-1-jeanmichel.hautbois@ideasonboard.com> References: <20220613142853.98484-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 08/10] ipa: raspberrypi: Introduce AfTrigger control X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jean-Michel Hautbois via libcamera-devel From: Jean-Michel Hautbois Reply-To: Jean-Michel Hautbois Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When the algorithm is in auto mode, it will start a new scan, and either end in the AfStateFocused ot AfStateFailed state. The user may decide to trigger a new scan, passing the AfTrigger control down to the pipeline handler. Implement a simple trigger operation in the IPA and call it from the pipeline handler when the control is passed. Signed-off-by: Jean-Michel Hautbois --- include/libcamera/ipa/raspberrypi.h | 1 + src/ipa/raspberrypi/controller/af_algorithm.hpp | 2 +- src/ipa/raspberrypi/controller/iob/af.cpp | 12 ++++++++++-- src/ipa/raspberrypi/controller/iob/af.h | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 14 ++++++++++++++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index a7a15904..17c7de72 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -50,6 +50,7 @@ static const ControlInfoMap Controls({ { &controls::AfState, ControlInfo(controls::AfStateValues) }, { &controls::AfPause, ControlInfo(controls::AfPauseValues) }, { &controls::AfPauseState, ControlInfo(controls::AfPauseStateValues) }, + { &controls::AfTrigger, ControlInfo(controls::AfTriggerValues) }, }, controls::controls); } /* namespace RPi */ diff --git a/src/ipa/raspberrypi/controller/af_algorithm.hpp b/src/ipa/raspberrypi/controller/af_algorithm.hpp index ac34e3b6..925b2d03 100644 --- a/src/ipa/raspberrypi/controller/af_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/af_algorithm.hpp @@ -19,7 +19,7 @@ public: // An af algorithm must provide the following: virtual void SetMode(const uint32_t &mode) = 0; // start a cycle (in auto mode) - virtual void Trigger() = 0; + virtual void Trigger(const uint32_t &trigger) = 0; // cancel a cycle (in auto mode) virtual void Cancel() = 0; // pause the continuous mode diff --git a/src/ipa/raspberrypi/controller/iob/af.cpp b/src/ipa/raspberrypi/controller/iob/af.cpp index 2efc12f5..1d9bc2bc 100644 --- a/src/ipa/raspberrypi/controller/iob/af.cpp +++ b/src/ipa/raspberrypi/controller/iob/af.cpp @@ -59,8 +59,16 @@ void Af::SetMode(const uint32_t &mode) } } -void Af::Trigger() -{ +void Af::Trigger(const uint32_t &trigger) +{ + LOG(IoBAf, Debug) << "Trigger called in mode " << mode_ + << " with " << trigger; + if (mode_ == libcamera::controls::AfModeAuto) { + if (trigger == libcamera::controls::AfTriggerStart) + afReset(); + else + status_.state = libcamera::controls::AfStateIdle; + } } void Af::Pause(const uint32_t &pause) diff --git a/src/ipa/raspberrypi/controller/iob/af.h b/src/ipa/raspberrypi/controller/iob/af.h index c4ab3574..12d7bbbd 100644 --- a/src/ipa/raspberrypi/controller/iob/af.h +++ b/src/ipa/raspberrypi/controller/iob/af.h @@ -24,7 +24,7 @@ public: void Prepare(Metadata *image_metadata) override; void Process(StatisticsPtr &stats, Metadata *image_metadata) override; void SetMode(const uint32_t &mode) override; - void Trigger() override; + void Trigger(const uint32_t &trigger) override; void Cancel() override; void Pause(const uint32_t &pause) override; void SetWindows(const libcamera::Rectangle &afWindows) override; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 8c6f213f..673a2e79 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -986,6 +986,20 @@ void IPARPi::queueRequest(const ControlList &controls) break; } + case controls::AF_TRIGGER: { + RPiController::AfAlgorithm *af = dynamic_cast( + controller_.GetAlgorithm("iob.af")); + if (!af) { + LOG(IPARPI, Warning) + << "Could not set AF_MODE - no AF algorithm"; + break; + } + + af->Trigger(ctrl.second.get()); + + break; + } + default: LOG(IPARPI, Warning) << "Ctrl " << controls::controls.at(ctrl.first)->name()