{"id":16485,"url":"https://patchwork.libcamera.org/api/1.1/patches/16485/?format=json","web_url":"https://patchwork.libcamera.org/patch/16485/","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":"<20220630143543.39599-4-dse@thaumatec.com>","date":"2022-06-30T14:35:38","name":"[libcamera-devel,3/8] ipa: rkisp1: Add AF algorithm basing on common AfHillClimbing class","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1f24b29b60fd51056158430e0a7b7812eb8d969a","submitter":{"id":126,"url":"https://patchwork.libcamera.org/api/1.1/people/126/?format=json","name":"Daniel Semkowicz","email":"dse@thaumatec.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16485/mbox/","series":[{"id":3239,"url":"https://patchwork.libcamera.org/api/1.1/series/3239/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3239","date":"2022-06-30T14:35:35","name":"ipa: rkisp1: Add autofocus algorithm","version":1,"mbox":"https://patchwork.libcamera.org/series/3239/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16485/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16485/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 CD4DEBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jun 2022 14:35:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 458CC65654;\n\tThu, 30 Jun 2022 16:35:57 +0200 (CEST)","from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 343A565652\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jun 2022 16:35:56 +0200 (CEST)","by mail-wm1-x335.google.com with SMTP id n185so11466745wmn.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jun 2022 07:35:56 -0700 (PDT)","from localhost.localdomain (ip092042140082.rev.nessus.at.\n\t[92.42.140.82]) by smtp.gmail.com with ESMTPSA id\n\tr5-20020a05600c320500b0039db500714fsm6405945wmp.6.2022.06.30.07.35.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 30 Jun 2022 07:35:55 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656599757;\n\tbh=D6mWfExN4PL82RnT4O1sKrGXxjVAv1vqtWJnSUSNSUk=;\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=rbVuy3OSj9X2lvTCSU/DmuArQryWE268MQLNHJmKcpSmtZ+gXa6ml+1F4LNlrlIMA\n\tFjNn/Usd4DLXkpgTBB+tFS92q62LZ1EatVK/7Lm9wAO6cKLSBMIOM6tDtXRrBqoMXl\n\txpkVOlTiIzf988vwaoQD86kQWfRXDdu8DC97Huj/qPAwe7vYxNvhVMLTfbsI/aJk0P\n\tK2ujQQIltST2dY80QANlb1E7MN0ciyZ/uER3vV11f/+ID+xeWBuWThu1W6J1pvlfoc\n\tquTcBJ1kGZS2RTkbDmA4jTkANMDQBdSApA/qPAbdBr4N9Sxksr4CTGQ0UJBGLGbtKt\n\t6i7dRf1v+s/CQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=thaumatec-com.20210112.gappssmtp.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=cluHbp3ZozxQ7erXZ6WbYUVfdEdHHTItUQcZGF8SkjE=;\n\tb=zRstArdb4ZGRNC8LnMSsbTCyWLgSSOi1s22LuC/C+FlydU3ZEnTZXw0PirbSbJTNp3\n\tlgRDoIKbTUFQKsvmq+Azj4n8NIvMyc8Mu5n0wOAcVZiniV4smjFcJU0m/VrHH3sz1tFk\n\tYZNfmJm/Ap54p6eaj/YxN7VpML5KdVCvjsVxEZmvQ/F4KKim/t7N53w6SWyXxihezj+j\n\tq9AInIN3ht2hek7F+VCJIOAe474NEeGVhc7RSg/XVy59SNz2uS0LzBFrtYMFbxPhytOG\n\tlFgaDwg0+tgiI9etrc8ZI3NqrPMiZ1rwMhVICfSh5hcH6lioTEEgOJXq1QhsmB+3m+fM\n\tQN3g=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=thaumatec-com.20210112.gappssmtp.com\n\theader.i=@thaumatec-com.20210112.gappssmtp.com header.b=\"zRstArdb\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=cluHbp3ZozxQ7erXZ6WbYUVfdEdHHTItUQcZGF8SkjE=;\n\tb=pLW8RCHd+L7OlK0wnNVNTIPx5HyzMEem6B9B7c4O7rGoRI/MRxdoh2/GCwi6AKauRL\n\tcdU3r5FVI5tUgQ0oQtzOIzCSvmML1YYzimMNgLwHq7vYgBJWrCovmkUGiSaSdj3oF3tN\n\t4IZnnQd4T5HVT5mutxdPEmtgJRveLVugyGDXwYFblcxhg/t9Y8ZFZu3U8aiirjHGiOGL\n\tCJqxDN4nZFrCV04Ghe8aAEUyvZ2R0dYQl131RZ+TdHRmx6Y3+vWXapMkFdD8/xFOfIOF\n\thcu58IRTkw3ftFDvCe2EDQZHJRWC94MoH/p/6YoyFmL4oLl3ZO9slt8Mv7IzSDx1n9IY\n\tqKpg==","X-Gm-Message-State":"AJIora+WTqBwliBY55CgI4OTD98mCpaJkyV4HSuX1eEgnftUTU78XKx2\n\t/GJ0CsnrKzrc9Bpb8wd9jNCtM/JgLo69Lw==","X-Google-Smtp-Source":"AGRyM1vNhcSQ4cLesuGgv3qkfE3jY1AKVsWNIcxW+BBa7sx88QElYkvOiAzS9DiPMgbPJJK3sw+ieQ==","X-Received":"by 2002:a1c:f60f:0:b0:3a0:3e0c:1de1 with SMTP id\n\tw15-20020a1cf60f000000b003a03e0c1de1mr12642265wmc.56.1656599755952; \n\tThu, 30 Jun 2022 07:35:55 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 30 Jun 2022 16:35:38 +0200","Message-Id":"<20220630143543.39599-4-dse@thaumatec.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220630143543.39599-1-dse@thaumatec.com>","References":"<20220630143543.39599-1-dse@thaumatec.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 3/8] ipa: rkisp1: Add AF algorithm basing\n\ton common AfHillClimbing class","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":"Daniel Semkowicz via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Daniel Semkowicz <dse@thaumatec.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Rockchip ISP AF block allows calculation of sharpness and luminance\nin up to three user defined windows. If no windows are set, there are\nsome default settings applied for the first window and exposed through\nthe driver. For each frame, use the sharpness value calculated for this\ndefault window and feed the hill climbing algorithm with them. Then set\nthe lens position to value calculated by the algorithm.\n\nSigned-off-by: Daniel Semkowicz <dse@thaumatec.com>\n---\n src/ipa/rkisp1/algorithms/af.cpp      | 70 +++++++++++++++++++++++++++\n src/ipa/rkisp1/algorithms/af.h        | 32 ++++++++++++\n src/ipa/rkisp1/algorithms/meson.build |  1 +\n 3 files changed, 103 insertions(+)\n create mode 100644 src/ipa/rkisp1/algorithms/af.cpp\n create mode 100644 src/ipa/rkisp1/algorithms/af.h","diff":"diff --git a/src/ipa/rkisp1/algorithms/af.cpp b/src/ipa/rkisp1/algorithms/af.cpp\nnew file mode 100644\nindex 00000000..8da970e3\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/af.cpp\n@@ -0,0 +1,70 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Theobroma Systems\n+ *\n+ * af.cpp - AF control algorithm\n+ */\n+\n+#include \"af.h\"\n+\n+/**\n+ * \\file af.h\n+ */\n+\n+namespace libcamera::ipa::rkisp1::algorithms {\n+\n+/**\n+ * \\class Af\n+ * \\brief AF control algorithm\n+ */\n+\n+LOG_DEFINE_CATEGORY(RkISP1Af)\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::configure\n+ */\n+int Af::configure([[maybe_unused]] IPAContext &context,\n+\t\t  [[maybe_unused]] const IPACameraSensorInfo &configInfo)\n+{\n+\treturn 0;\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void Af::prepare([[maybe_unused]] IPAContext &context, [[maybe_unused]] rkisp1_params_cfg *params)\n+{\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::process\n+ */\n+void Af::process(IPAContext &context,\n+\t\t [[maybe_unused]] IPAFrameContext *frameCtx,\n+\t\t const rkisp1_stat_buffer *stats)\n+{\n+\tuint32_t sharpness = stats->params.af.window[0].sum;\n+\tuint32_t luminance = stats->params.af.window[0].lum;\n+\n+\tLOG(RkISP1Af, Debug) << \"lensPosition: \" << context.frameContext.af.focus\n+\t\t\t     << \", Sharpness: \" << sharpness\n+\t\t\t     << \", Luminance: \" << luminance;\n+\n+\tuint32_t lensPosition = processAutofocus(sharpness);\n+\n+\tcontext.frameContext.af.focus = lensPosition;\n+}\n+\n+void Af::setMetering([[maybe_unused]] controls::AfMeteringEnum metering)\n+{\n+\tLOG(RkISP1Af, Error) << __FUNCTION__ << \" not implemented!\";\n+}\n+\n+void Af::setWindows([[maybe_unused]] Span<const Rectangle> windows)\n+{\n+\tLOG(RkISP1Af, Error) << __FUNCTION__ << \" not implemented!\";\n+}\n+\n+REGISTER_IPA_ALGORITHM(Af, \"Af\")\n+\n+} /* namespace libcamera::ipa::rkisp1::algorithms */\ndiff --git a/src/ipa/rkisp1/algorithms/af.h b/src/ipa/rkisp1/algorithms/af.h\nnew file mode 100644\nindex 00000000..c470c9b2\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/af.h\n@@ -0,0 +1,32 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Theobroma Systems\n+ *\n+ * af.h - AF control algorithm\n+ */\n+\n+#pragma once\n+\n+#include <linux/rkisp1-config.h>\n+\n+#include \"libipa/algorithms/af_hill_climbing.h\"\n+#include \"module.h\"\n+\n+namespace libcamera::ipa::rkisp1::algorithms {\n+\n+class Af : public ipa::common::algorithms::AfHillClimbing<Module>\n+{\n+public:\n+\tAf() = default;\n+\t~Af() = default;\n+\n+\tint configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;\n+\tvoid prepare(IPAContext &context, rkisp1_params_cfg *params) override;\n+\tvoid process(IPAContext &context, IPAFrameContext *frameCtx,\n+\t\t     const rkisp1_stat_buffer *stats) override;\n+\n+\tvoid setMetering(controls::AfMeteringEnum metering) override;\n+\tvoid setWindows(Span<const Rectangle> windows) override;\n+};\n+\n+} /* namespace libcamera::ipa::rkisp1::algorithms */\ndiff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build\nindex 7ec53d89..81addcc9 100644\n--- a/src/ipa/rkisp1/algorithms/meson.build\n+++ b/src/ipa/rkisp1/algorithms/meson.build\n@@ -1,6 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n rkisp1_ipa_algorithms = files([\n+    'af.cpp',\n     'agc.cpp',\n     'awb.cpp',\n     'blc.cpp',\n","prefixes":["libcamera-devel","3/8"]}