From patchwork Mon Jun 13 14:28:48 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: 16214 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 268C4C3277 for ; Mon, 13 Jun 2022 14:29:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C94C46563F; Mon, 13 Jun 2022 16:29:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655130549; bh=8qgOFag72F04VxPWN61txryRmlxFyVU8SBwJO0kuhFY=; 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=DOEfRgKMykN8WmOW+H+DeHsRvAM2wjjYmn1bmSJ95Pyex1NN0mxrPR94CIMkFAm5O exLLvuhj/BMLC/DF5ltgr4p5HJQZPjxe1qYToYiDvLINq2vJstuUDPfU2Ef/yZu3QI lnN1qBnXrl+KeZWPssHT4dl6Phn+TlNOT+8M16YP8yI11YRRFuVL7WgekbixmQdMiA wVr3dIp1HnCceYWP6pU0/Yw+cxaaKfZssEiMJ47gvoUh0SQU5k+tJ4rTQ7CzR5ZtWS MHmLuu+yBSxdXfIgbs7kA1lRLZ/quBi+sA1M+rd644dSD+dg0d9N3TehxWL7pRGAIJ h00XHlqA8tT8g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 07C4E65631 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="ia2q/OSK"; 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 B0363440; Mon, 13 Jun 2022 16:29:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655130540; bh=8qgOFag72F04VxPWN61txryRmlxFyVU8SBwJO0kuhFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ia2q/OSKhvF+p5JkZCaeuxONOzUDaOtgHorPNN0b96q5Aedy/ryYN7q0pk6giskJ2 a5rx2iusiR/jBdNdP42r+MJY51E9IHvO3N3mbPlmXItfUURqZxBDathrXEdBfHvrbJ Nk8RlYw7AtIGQUMRVYDCsXYnqfq9wCZPE8TBMvds= To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Jun 2022 16:28:48 +0200 Message-Id: <20220613142853.98484-6-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 05/10] ipa: raspberrypi: Af: Add AfState 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" Now that controls are introduced, use the AfState to control the algorithm. Signed-off-by: Jean-Michel Hautbois --- src/ipa/raspberrypi/controller/af_status.h | 5 +++-- src/ipa/raspberrypi/controller/iob/af.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ipa/raspberrypi/controller/af_status.h b/src/ipa/raspberrypi/controller/af_status.h index f8cb1301..3428d032 100644 --- a/src/ipa/raspberrypi/controller/af_status.h +++ b/src/ipa/raspberrypi/controller/af_status.h @@ -7,15 +7,16 @@ */ #pragma once +#include +#include #include /* * The focus algorithm should post the following structure into the image's * "af.status" metadata. */ - struct AfStatus { uint32_t lensPosition; - uint32_t state; + libcamera::controls::AfStateEnum state; libcamera::Rectangle windows; }; diff --git a/src/ipa/raspberrypi/controller/iob/af.cpp b/src/ipa/raspberrypi/controller/iob/af.cpp index 12d41c81..b03e52c5 100644 --- a/src/ipa/raspberrypi/controller/iob/af.cpp +++ b/src/ipa/raspberrypi/controller/iob/af.cpp @@ -78,7 +78,7 @@ void Af::Initialise() { status_.lensPosition = 0.0; maxContrast_ = 0.0; - status_.state = 1; + status_.state = libcamera::controls::AfStateScanning; } void Af::Prepare(Metadata *image_metadata) @@ -109,7 +109,7 @@ void Af::afFineScan() if (afScan(kFineSearchStep)) { LOG(IoBAf, Debug) << "AF found the best focus position !"; - status_.state = 2; + status_.state = libcamera::controls::AfStateFocused; fineCompleted_ = true; } } @@ -162,7 +162,7 @@ void Af::afReset() LOG(IoBAf, Debug) << "Reset AF parameters"; status_.lensPosition = 0; focus_ = 0; - status_.state = 0; + status_.state = libcamera::controls::AfStateIdle; previousContrast_ = 0.0; coarseCompleted_ = false; fineCompleted_ = false; @@ -195,7 +195,7 @@ void Af::Process(StatisticsPtr &stats, [[maybe_unused]] Metadata *image_metadata currentContrast_ += stats->focus_stats[i].contrast_val[1][1] / stats->focus_stats[i].contrast_val_num[1][1]; - if (status_.state != 2) { + if (status_.state != libcamera::controls::AfStateFocused) { afCoarseScan(); afFineScan(); } else {