{"id":16214,"url":"https://patchwork.libcamera.org/api/1.1/patches/16214/?format=json","web_url":"https://patchwork.libcamera.org/patch/16214/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220613142853.98484-6-jeanmichel.hautbois@ideasonboard.com>","date":"2022-06-13T14:28:48","name":"[libcamera-devel,05/10] ipa: raspberrypi: Af: Add AfState","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2dcce10b590b5c3821c6032a02aef939e6d059b5","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/1.1/people/75/?format=json","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16214/mbox/","series":[{"id":3174,"url":"https://patchwork.libcamera.org/api/1.1/series/3174/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3174","date":"2022-06-13T14:28:43","name":"ipa: raspberrypi: Introduce an autofocus algorithm","version":1,"mbox":"https://patchwork.libcamera.org/series/3174/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16214/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16214/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 268C4C3277\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jun 2022 14:29:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C94C46563F;\n\tMon, 13 Jun 2022 16:29:08 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 07C4E65631\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jun 2022 16:29:01 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:a1c7:c28c:7720:9b30])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B0363440;\n\tMon, 13 Jun 2022 16:29:00 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655130549;\n\tbh=8qgOFag72F04VxPWN61txryRmlxFyVU8SBwJO0kuhFY=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=DOEfRgKMykN8WmOW+H+DeHsRvAM2wjjYmn1bmSJ95Pyex1NN0mxrPR94CIMkFAm5O\n\texLLvuhj/BMLC/DF5ltgr4p5HJQZPjxe1qYToYiDvLINq2vJstuUDPfU2Ef/yZu3QI\n\tlnN1qBnXrl+KeZWPssHT4dl6Phn+TlNOT+8M16YP8yI11YRRFuVL7WgekbixmQdMiA\n\twVr3dIp1HnCceYWP6pU0/Yw+cxaaKfZssEiMJ47gvoUh0SQU5k+tJ4rTQ7CzR5ZtWS\n\tMHmLuu+yBSxdXfIgbs7kA1lRLZ/quBi+sA1M+rd644dSD+dg0d9N3TehxWL7pRGAIJ\n\th00XHlqA8tT8g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655130540;\n\tbh=8qgOFag72F04VxPWN61txryRmlxFyVU8SBwJO0kuhFY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ia2q/OSKhvF+p5JkZCaeuxONOzUDaOtgHorPNN0b96q5Aedy/ryYN7q0pk6giskJ2\n\ta5rx2iusiR/jBdNdP42r+MJY51E9IHvO3N3mbPlmXItfUURqZxBDathrXEdBfHvrbJ\n\tNk8RlYw7AtIGQUMRVYDCsXYnqfq9wCZPE8TBMvds="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ia2q/OSK\"; dkim-atps=neutral","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","Content-Transfer-Encoding":"8bit","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":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Jean-Michel Hautbois via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Now that controls are introduced, use the AfState to control the\nalgorithm.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/raspberrypi/controller/af_status.h | 5 +++--\n src/ipa/raspberrypi/controller/iob/af.cpp  | 8 ++++----\n 2 files changed, 7 insertions(+), 6 deletions(-)","diff":"diff --git a/src/ipa/raspberrypi/controller/af_status.h b/src/ipa/raspberrypi/controller/af_status.h\nindex f8cb1301..3428d032 100644\n--- a/src/ipa/raspberrypi/controller/af_status.h\n+++ b/src/ipa/raspberrypi/controller/af_status.h\n@@ -7,15 +7,16 @@\n  */\n #pragma once\n \n+#include <libcamera/control_ids.h>\n+#include <libcamera/controls.h>\n #include <libcamera/geometry.h>\n \n /*\n  * The focus algorithm should post the following structure into the image's\n  * \"af.status\" metadata.\n  */\n-\n struct AfStatus {\n \tuint32_t lensPosition;\n-\tuint32_t state;\n+\tlibcamera::controls::AfStateEnum state;\n \tlibcamera::Rectangle windows;\n };\ndiff --git a/src/ipa/raspberrypi/controller/iob/af.cpp b/src/ipa/raspberrypi/controller/iob/af.cpp\nindex 12d41c81..b03e52c5 100644\n--- a/src/ipa/raspberrypi/controller/iob/af.cpp\n+++ b/src/ipa/raspberrypi/controller/iob/af.cpp\n@@ -78,7 +78,7 @@ void Af::Initialise()\n {\n \tstatus_.lensPosition = 0.0;\n \tmaxContrast_ = 0.0;\n-\tstatus_.state = 1;\n+\tstatus_.state = libcamera::controls::AfStateScanning;\n }\n \n void Af::Prepare(Metadata *image_metadata)\n@@ -109,7 +109,7 @@ void Af::afFineScan()\n \n \tif (afScan(kFineSearchStep)) {\n \t\tLOG(IoBAf, Debug) << \"AF found the best focus position !\";\n-\t\tstatus_.state = 2;\n+\t\tstatus_.state = libcamera::controls::AfStateFocused;\n \t\tfineCompleted_ = true;\n \t}\n }\n@@ -162,7 +162,7 @@ void Af::afReset()\n \tLOG(IoBAf, Debug) << \"Reset AF parameters\";\n \tstatus_.lensPosition = 0;\n \tfocus_ = 0;\n-\tstatus_.state = 0;\n+\tstatus_.state = libcamera::controls::AfStateIdle;\n \tpreviousContrast_ = 0.0;\n \tcoarseCompleted_ = false;\n \tfineCompleted_ = false;\n@@ -195,7 +195,7 @@ void Af::Process(StatisticsPtr &stats, [[maybe_unused]] Metadata *image_metadata\n \t\tcurrentContrast_ += stats->focus_stats[i].contrast_val[1][1]\n \t\t\t\t  / stats->focus_stats[i].contrast_val_num[1][1];\n \n-\tif (status_.state != 2) {\n+\tif (status_.state != libcamera::controls::AfStateFocused) {\n \t\tafCoarseScan();\n \t\tafFineScan();\n \t} else {\n","prefixes":["libcamera-devel","05/10"]}