{"id":18446,"url":"https://patchwork.libcamera.org/api/1.1/patches/18446/?format=json","web_url":"https://patchwork.libcamera.org/patch/18446/","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":"<20230324142908.64224-4-dse@thaumatec.com>","date":"2023-03-24T14:29:01","name":"[libcamera-devel,v5,03/10] ipa: Add base class defining AF algorithm interface","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"910ccf6071ab724aaaed4877f221ade863511600","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/18446/mbox/","series":[{"id":3813,"url":"https://patchwork.libcamera.org/api/1.1/series/3813/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3813","date":"2023-03-24T14:28:58","name":"ipa: rkisp1: Add autofocus algorithm","version":5,"mbox":"https://patchwork.libcamera.org/series/3813/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18446/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18446/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 11E83C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Mar 2023 14:29:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E882B62710;\n\tFri, 24 Mar 2023 15:29:30 +0100 (CET)","from mail-lj1-x235.google.com (mail-lj1-x235.google.com\n\t[IPv6:2a00:1450:4864:20::235])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F0E061ECF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Mar 2023 15:29:26 +0100 (CET)","by mail-lj1-x235.google.com with SMTP id a11so1912949lji.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Mar 2023 07:29:26 -0700 (PDT)","from localhost.localdomain ([91.90.166.178])\n\tby smtp.gmail.com with ESMTPSA id\n\tj21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.25\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 24 Mar 2023 07:29:25 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679668171;\n\tbh=VvBr+2AA6dPAeiFBn7TRelJf2b2z8dbF/ClemE/ynww=;\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:Cc:\n\tFrom;\n\tb=ajYGHm/W4MiMHrLc6EQtOtFf1qqpQBsQxeln+KL9sfVzsn6Y+XdqtLgnrtGLUb3w3\n\tuOxt/as7YPULvszN2ynYesutZspjN/YVyy2R5Fi7WA1/Vis+9koqmGpWnGO2tNKF28\n\tAX0GmcLvpcYiIsO3rqSo4DOEvP4T2RPoXrkcmIbzvpb23oIYU8QeD0hnyA0+NmHgHw\n\tbjdVz1+/rzqBGEeRWbMP06i6+hr9uhfRZmkypJaJ1yA1jBk67JvrYr5kqXKp0Y1ulj\n\tqQdHz72Ai8VHcr5d/hL57kudMvYUp5OUPWzc+k9HAyxH7jINDtBELdpePl/OeTjA3m\n\tIW5cnhlAjRWvQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668166;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=p3ktg7MZDXz8/FGb1gjNfXnLADZbV4jL8TI3FRHHtyk=;\n\tb=0wLdG1u1gTAQYhkQyOwaltTyFMF9MFpAJsDWLYIwHaxYGKTwaXLiLSOEsdq7MhEroD\n\t4UJTUt6ybmqWJJsDkdXRzyKJ7+Kza2dYkgMkw7nnOa/54MMqkSWbk3r9ewrfle3s22er\n\tdIjAEqkauajShbb8cDQVnaDIbSLTwDHCBZ67O8ETzfL98tJgwmsopScwLWErcPRtIkNQ\n\t39GGiparp7bMYA5bJVX+JGY7JJ9KGCxS3DjKUsTLTFaSjuFXnMUnHmQhgYQmt4ygzE5M\n\ts13at2d7twU1NBmHaBHEJf10F5dvUEVvp9+tKKRaije9WR4gIWTsy89vGChKh7yhRdDN\n\tF49Q=="],"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=\"0wLdG1u1\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1679668166;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=p3ktg7MZDXz8/FGb1gjNfXnLADZbV4jL8TI3FRHHtyk=;\n\tb=E67cTqy9zeVAthTjcoyH9pmXtNlsoPPpQTxzwzoDs2XJeEqm63iPDdabEiP4KAJefw\n\tDu3/2cqoXNlzB5O2LdVyvj2HfTofepHYEMfcvMBbuF3NpIOe3qepo1jJThEUoahn6pWa\n\tkHwoGXsSvqHBAH6JGvAIrpdLaAGzj2L/2wXNVN2x9HcQqa4FAThDNSNeR4fK0yQZq98W\n\tp2JKjwCtriRP0W8kdNTPPblkH7o5STj0JkAuL8ECbRUQPtGng8kwbla6E8QKS+Xxxiuh\n\tf2pzNXI9qx8ce3CsDmhz3bIOCHgS1EcfsrDXj6P2FKJq0R5iCALqi7c7FUYKtO+hy//S\n\tcPiA==","X-Gm-Message-State":"AAQBX9cDQ+vpVMktc+yw0MdGk0C4dOyrEdz8/SYd0encFRSyoSMBCpip\n\tY0879a7wRl17BZ09TC8TRE/Lc1xn2vUvsl5TadY=","X-Google-Smtp-Source":"AKy350YHxv2Uc5CxDB65tD42VSneyoi48539GgdeEoo1yKbdJlZqQrgnCTU1D7xDGNsmWvvsovjF2Q==","X-Received":"by 2002:a2e:988c:0:b0:298:9fb6:77a with SMTP id\n\tb12-20020a2e988c000000b002989fb6077amr940020ljj.32.1679668165802; \n\tFri, 24 Mar 2023 07:29:25 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 24 Mar 2023 15:29:01 +0100","Message-Id":"<20230324142908.64224-4-dse@thaumatec.com>","X-Mailer":"git-send-email 2.39.2","In-Reply-To":"<20230324142908.64224-1-dse@thaumatec.com>","References":"<20230324142908.64224-1-dse@thaumatec.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 03/10] ipa: Add base class defining AF\n\talgorithm interface","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>","Cc":"jacopo.mondi@ideasonboard.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Define common interface with pure virtual methods that should be\nimplemented by the Auto Focus algorithm implementations.\nInterface methods match the AF controls that can be set in the frame\nrequest. Common implementation of controls parsing is provided,\nso the AF algorithms deriving from this interface should be able\nto reuse it.\n\nSigned-off-by: Daniel Semkowicz <dse@thaumatec.com>\n---\n src/ipa/libipa/algorithms/af.cpp      | 159 ++++++++++++++++++++++++++\n src/ipa/libipa/algorithms/af.h        |  45 ++++++++\n src/ipa/libipa/algorithms/meson.build |   9 ++\n src/ipa/libipa/meson.build            |   6 +\n 4 files changed, 219 insertions(+)\n create mode 100644 src/ipa/libipa/algorithms/af.cpp\n create mode 100644 src/ipa/libipa/algorithms/af.h\n create mode 100644 src/ipa/libipa/algorithms/meson.build","diff":"diff --git a/src/ipa/libipa/algorithms/af.cpp b/src/ipa/libipa/algorithms/af.cpp\nnew file mode 100644\nindex 00000000..0808aa3f\n--- /dev/null\n+++ b/src/ipa/libipa/algorithms/af.cpp\n@@ -0,0 +1,159 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Theobroma Systems\n+ *\n+ * af.cpp - Autofocus control algorithm interface\n+ */\n+\n+#include \"af.h\"\n+\n+/**\n+ * \\file af.h\n+ * \\brief AF algorithm common interface\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa::algorithms {\n+\n+/**\n+ * \\class Af\n+ * \\brief Common interface for auto-focus algorithms\n+ *\n+ * The Af class defines a standard interface for IPA auto focus algorithms.\n+ */\n+\n+/**\n+ * \\brief Provide control values to the algorithm\n+ * \\param[in] controls The list of user controls\n+ *\n+ * This method should be called in the libcamera::ipa::Algorithm::queueRequest()\n+ * method of the platform layer.\n+ */\n+void Af::queueRequest(const ControlList &controls)\n+{\n+\tusing namespace controls;\n+\n+\tfor (auto const &[id, value] : controls) {\n+\t\tswitch (id) {\n+\t\tcase AF_MODE: {\n+\t\t\tsetMode(static_cast<AfModeEnum>(value.get<int32_t>()));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase AF_RANGE: {\n+\t\t\tsetRange(static_cast<AfRangeEnum>(value.get<int32_t>()));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase AF_SPEED: {\n+\t\t\tsetSpeed(static_cast<AfSpeedEnum>(value.get<int32_t>()));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase AF_METERING: {\n+\t\t\tsetMeteringMode(static_cast<AfMeteringEnum>(value.get<int32_t>()));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase AF_WINDOWS: {\n+\t\t\tsetWindows(value.get<Span<const Rectangle>>());\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase AF_TRIGGER: {\n+\t\t\tsetTrigger(static_cast<AfTriggerEnum>(value.get<int32_t>()));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase AF_PAUSE: {\n+\t\t\tsetPause(static_cast<AfPauseEnum>(value.get<int32_t>()));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase LENS_POSITION: {\n+\t\t\tsetLensPosition(value.get<float>());\n+\t\t\tbreak;\n+\t\t}\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+\n+/**\n+ * \\fn Af::setMode()\n+ * \\brief Set auto focus mode\n+ * \\param[in] mode AF mode\n+ *\n+ * \\sa libcamera::controls::AfMode\n+ */\n+\n+/**\n+ * \\fn Af::setRange()\n+ * \\brief Set the range of focus distances that is scanned\n+ * \\param[in] range AF range\n+ *\n+ * \\sa libcamera::controls::AfRange\n+ */\n+\n+/**\n+ * \\fn Af::setSpeed()\n+ * \\brief Set how fast algorithm should move the lens\n+ * \\param[in] speed Lens move speed\n+ *\n+* \\sa libcamera::controls::AfSpeed\n+ */\n+\n+/**\n+ * \\fn Af::setMeteringMode()\n+ * \\brief Set AF metering mode\n+ * \\param[in] metering AF metering mode\n+ *\n+ * \\sa libcamera::controls::AfMetering\n+ */\n+\n+/**\n+ * \\fn Af::setWindows()\n+ * \\brief Set AF windows\n+ * \\param[in] windows AF windows\n+ *\n+ * \\sa libcamera::controls::AfWindows\n+ */\n+\n+/**\n+ * \\fn Af::setTrigger()\n+ * \\brief Starts or cancels the autofocus scan\n+ * \\param[in] trigger Trigger mode\n+ *\n+ * \\sa libcamera::controls::AfTrigger\n+ */\n+\n+/**\n+ * \\fn Af::setPause()\n+ * \\brief Pause the autofocus while in AfModeContinuous mode\n+ * \\param[in] pause Pause mode\n+ *\n+ * \\sa libcamera::controls::AfPause\n+ */\n+\n+/**\n+ * \\fn Af::setLensPosition()\n+ * \\brief Set the lens position while in AfModeManual\n+ * \\param[in] lensPosition Lens position\n+ *\n+ * \\sa libcamera::controls::LensPosition\n+ */\n+\n+/**\n+ * \\fn Af::state()\n+ * \\brief Get the current state of the AF algorithm\n+ * \\return AF state\n+ *\n+ * \\sa libcamera::controls::AfState\n+ */\n+\n+/**\n+ * \\fn Af::pauseState()\n+ * \\brief Get the current pause state of the AF algorithm\n+ * \\return AF pause state\n+ *\n+ * \\sa libcamera::controls::AfPauseState\n+ */\n+\n+} /* namespace ipa::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/libipa/algorithms/af.h b/src/ipa/libipa/algorithms/af.h\nnew file mode 100644\nindex 00000000..4fd16ac2\n--- /dev/null\n+++ b/src/ipa/libipa/algorithms/af.h\n@@ -0,0 +1,45 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Theobroma Systems\n+ *\n+ * af.h - Autofocus control algorithm interface\n+ */\n+#pragma once\n+\n+#include <libcamera/control_ids.h>\n+\n+namespace libcamera {\n+\n+namespace ipa::algorithms {\n+\n+class Af\n+{\n+public:\n+\tvirtual ~Af() = default;\n+\n+\tvoid queueRequest(const ControlList &controls);\n+\n+\tvirtual void setMode(controls::AfModeEnum mode) = 0;\n+\n+\tvirtual void setRange(controls::AfRangeEnum range) = 0;\n+\n+\tvirtual void setSpeed(controls::AfSpeedEnum speed) = 0;\n+\n+\tvirtual void setMeteringMode(controls::AfMeteringEnum metering) = 0;\n+\n+\tvirtual void setWindows(Span<const Rectangle> windows) = 0;\n+\n+\tvirtual void setTrigger(controls::AfTriggerEnum trigger) = 0;\n+\n+\tvirtual void setPause(controls::AfPauseEnum pause) = 0;\n+\n+\tvirtual void setLensPosition(float lensPosition) = 0;\n+\n+\tvirtual controls::AfStateEnum state() = 0;\n+\n+\tvirtual controls::AfPauseStateEnum pauseState() = 0;\n+};\n+\n+} /* namespace ipa::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/libipa/algorithms/meson.build b/src/ipa/libipa/algorithms/meson.build\nnew file mode 100644\nindex 00000000..3df4798f\n--- /dev/null\n+++ b/src/ipa/libipa/algorithms/meson.build\n@@ -0,0 +1,9 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+libipa_algorithms_headers = files([\n+    'af.h',\n+])\n+\n+libipa_algorithms_sources = files([\n+    'af.cpp',\n+])\ndiff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build\nindex 016b8e0e..134c2dba 100644\n--- a/src/ipa/libipa/meson.build\n+++ b/src/ipa/libipa/meson.build\n@@ -1,5 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n+subdir('algorithms')\n+\n libipa_headers = files([\n     'algorithm.h',\n     'camera_sensor_helper.h',\n@@ -8,6 +10,8 @@ libipa_headers = files([\n     'module.h',\n ])\n \n+libipa_headers += libipa_algorithms_headers\n+\n libipa_sources = files([\n     'algorithm.cpp',\n     'camera_sensor_helper.cpp',\n@@ -16,6 +20,8 @@ libipa_sources = files([\n     'module.cpp',\n ])\n \n+libipa_sources += libipa_algorithms_sources\n+\n libipa_includes = include_directories('..')\n \n libipa = static_library('ipa', [libipa_sources, libipa_headers],\n","prefixes":["libcamera-devel","v5","03/10"]}