Show a patch.

GET /api/1.1/patches/18144/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 18144,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18144/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18144/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20230119084112.20564-6-dse@thaumatec.com>",
    "date": "2023-01-19T08:41:09",
    "name": "[libcamera-devel,v3,5/8] ipa: rkisp1: Add AF algorithm basing on common AfHillClimbing class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "d55402ea6a253449abfa24365104f1e84f71cb2d",
    "submitter": {
        "id": 126,
        "url": "https://patchwork.libcamera.org/api/1.1/people/126/?format=api",
        "name": "Daniel Semkowicz",
        "email": "dse@thaumatec.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18144/mbox/",
    "series": [
        {
            "id": 3714,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3714/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3714",
            "date": "2023-01-19T08:41:04",
            "name": "ipa: rkisp1: Add autofocus algorithm",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/3714/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18144/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18144/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 C8DD0C3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Jan 2023 08:42:15 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 333C0625FE;\n\tThu, 19 Jan 2023 09:42:15 +0100 (CET)",
            "from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D2DC4625EA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Jan 2023 09:42:11 +0100 (CET)",
            "by mail-wm1-x32a.google.com with SMTP id\n\tm5-20020a05600c4f4500b003db03b2559eso679426wmq.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Jan 2023 00:42:11 -0800 (PST)",
            "from localhost.localdomain (ip092042140082.rev.nessus.at.\n\t[92.42.140.82]) by smtp.gmail.com with ESMTPSA id\n\tj10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 19 Jan 2023 00:42:11 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1674117735;\n\tbh=gscmoJ/hmm/k0IzEqmPI5QVJOjA+vf+JMdzx/ZsIgbo=;\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=Iv0FHxHyMOvXNwKQiwEkE50tE5fkVmJ3cCPze2wt+m62OYDuRqr6fNfXGRTBtCbk2\n\ta+spnWjsGwVC3Ut+GXqnVNp9TBke1RD7vWoz1m3Jna4BPt7QEawGKX2BN8SOj9XM9x\n\t4636YrHA+EQdfRt0sCnvOnvVG7b3uJltG9/8O9LSu6YOSdJl65FCnER2Rpd/l7PN6S\n\tB5ei2dOLGg1i3iFsFvPG/OImVuWRePzxo2cr68ucA+1N9kRvnjHniqg1b/1WGOOOMo\n\tF0TcWStx73G/1MQba6bzQGRlUNQCl9lGgJNzf+9Fm3liVW1LJwV4AGmDn0Qwqzj9mx\n\td8et4B5dGFF7A==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=thaumatec-com.20210112.gappssmtp.com; s=20210112;\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=kprmtRGy07+WJsHQiGi/OEpWYVBfWR8o/DjLzEG6T0c=;\n\tb=ryhjO1PV1mUiTqRiFrQuMEUV5l3eOgd0aK1Upw6EC9MCFEi9WdJppZr/c7rqZy+W/8\n\tC7vE8WKwD+fBbCcG0kVyBunXXqwpJ+udZa9eiTHHk3ePESb5g/myaBlHoZmuzc+BQcVU\n\tbu56ENSQsNPQ0tsb4UsVwdxjUnyw9ItKYJQfPEgNQHEjN55Jh8fyw8TC9Rg4HE5iNpVA\n\tTp476tWVCrSMankxF75ulIsuOssp9fTNRPUQ4cAZk/iDgU12AZi2S7rnVrezemhG3vbK\n\t3z8STqEMxR81Ap4z37eA5QrrapwxwRDMm/pLNyVM2iqtQyqzmoBHpUUqVJrZMsn/me7w\n\ttgAg=="
        ],
        "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=\"ryhjO1PV\"; \n\tdkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=kprmtRGy07+WJsHQiGi/OEpWYVBfWR8o/DjLzEG6T0c=;\n\tb=FlRiFsaj/chSTcuZTNiJ434cUenijaRQmK/MVx4VQX9o9gPLqPfuEK84vHGzyTWl0M\n\tF0aJoqHm1e7prJxTJzUsZ2ac5L9DuAYQdP17/hgUNx34htTv1dNHMwwUEHeGS8LZBuVo\n\tnQ3iUIShDZnsAv7DVQhwl9cB/V3Zhn71wQXi21mS5fJ6n3zicbIqAH5dz6WDdaNgXBNC\n\tAhlgxV81FXJG3VCEpBVjNXEhlIPCSiXZwNo+DFKH5QJPNpeSTjmiWcl2W1zaZlPO1d7e\n\tA8Vn2mCeYXyJE3yxbCn4J0LclBTwksQlZWSuQQ2frPFwWMVCuv61zRRWGs2jIR8XyYwt\n\t1zIw==",
        "X-Gm-Message-State": "AFqh2kp3vcbvy+H4O+0lhdrHZDv4j2WREwCAvH4+6pa/a6Tlhoce1Vd4\n\twmn8XfP+sOhKqaVpXuCqTknf+8k04pvSL07wt1Q=",
        "X-Google-Smtp-Source": "AMrXdXuiHsxfnR/BDIKAbQakqOzseeiNHabpbpwFENhtVX1w5SPPlXYX/kcqYlFot+MW6Vd8zehnDw==",
        "X-Received": "by 2002:a05:600c:1c83:b0:3da:fbd8:59a0 with SMTP id\n\tk3-20020a05600c1c8300b003dafbd859a0mr9484212wms.11.1674117731561; \n\tThu, 19 Jan 2023 00:42:11 -0800 (PST)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 19 Jan 2023 09:41:09 +0100",
        "Message-Id": "<20230119084112.20564-6-dse@thaumatec.com>",
        "X-Mailer": "git-send-email 2.39.0",
        "In-Reply-To": "<20230119084112.20564-1-dse@thaumatec.com>",
        "References": "<20230119084112.20564-1-dse@thaumatec.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 5/8] ipa: rkisp1: Add AF algorithm\n\tbasing on 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      | 101 ++++++++++++++++++++++++++\n src/ipa/rkisp1/algorithms/af.h        |  42 +++++++++++\n src/ipa/rkisp1/algorithms/meson.build |   1 +\n 3 files changed, 144 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..c2a321cd\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/af.cpp\n@@ -0,0 +1,101 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Theobroma Systems\n+ *\n+ * af.cpp - RkISP1 AF hill climbing based 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::init\n+ */\n+int Af::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)\n+{\n+\twaitFramesLens_ = tuningData[\"wait-frames-lens\"].get<uint32_t>(1);\n+\n+\tLOG(RkISP1Af, Debug) << \"waitFramesLens_: \" << waitFramesLens_;\n+\n+\treturn initBase(tuningData);\n+}\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::queueRequest\n+ */\n+void Af::queueRequest([[maybe_unused]] IPAContext &context,\n+\t\t      const uint32_t frame,\n+\t\t      [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t      const ControlList &controls)\n+{\n+\tqueueRequestBase(frame, controls);\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void Af::prepare([[maybe_unused]] IPAContext &context,\n+\t\t [[maybe_unused]] const uint32_t frame,\n+\t\t [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t [[maybe_unused]] rkisp1_params_cfg *params)\n+{\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::process\n+ */\n+void Af::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n+\t\t [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t const rkisp1_stat_buffer *stats,\n+\t\t [[maybe_unused]] ControlList &metadata)\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.activeState.af.lensPosition\n+\t\t\t     << \", Sharpness: \" << sharpness\n+\t\t\t     << \", Luminance: \" << luminance;\n+\n+\tuint32_t lensPosition = processAutofocus(sharpness);\n+\n+\tif (lensPosition != context.activeState.af.lensPosition) {\n+\t\tcontext.activeState.af.lensPosition = lensPosition;\n+\t\tcontext.activeState.af.applyLensCtrls = true;\n+\t\tsetFramesToSkip(waitFramesLens_);\n+\t}\n+}\n+\n+void Af::setMeteringMode([[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..882be952\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/af.h\n@@ -0,0 +1,42 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Theobroma Systems\n+ *\n+ * af.h - RkISP1 AF hill climbing based control algorithm\n+ */\n+\n+#pragma once\n+\n+#include <linux/rkisp1-config.h>\n+\n+#include \"libipa/algorithms/af_hill_climbing.h\"\n+\n+#include \"algorithm.h\"\n+\n+namespace libcamera::ipa::rkisp1::algorithms {\n+\n+class Af : public ipa::common::algorithms::AfHillClimbing, public Algorithm\n+{\n+public:\n+\tAf() = default;\n+\t~Af() = default;\n+\n+\tint init(IPAContext &context, const YamlObject &tuningData) override;\n+\tint configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;\n+\tvoid queueRequest(IPAContext &context, const uint32_t frame,\n+\t\t\t  IPAFrameContext &frameContext, const ControlList &controls) override;\n+\tvoid prepare(IPAContext &context, const uint32_t frame,\n+\t\t     IPAFrameContext &frameContext, rkisp1_params_cfg *params) override;\n+\tvoid process(IPAContext &context, const uint32_t frame,\n+\t\t     IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats,\n+\t\t     ControlList &metadata) override;\n+\n+private:\n+\tvoid setMeteringMode(controls::AfMeteringEnum metering) final;\n+\tvoid setWindows(Span<const Rectangle> windows) final;\n+\n+\t/* Wait number of frames after changing lens position */\n+\tuint32_t waitFramesLens_;\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 93a48329..ab7e44f3 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",
        "v3",
        "5/8"
    ]
}