Show a patch.

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

{
    "id": 18398,
    "url": "https://patchwork.libcamera.org/api/patches/18398/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18398/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20230314144834.85193-8-dse@thaumatec.com>",
    "date": "2023-03-14T14:48:31",
    "name": "[libcamera-devel,v4,07/10] ipa: rkisp1: af: Add \"Windows\" Metering mode",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "43097c9f4f22dca5c9dc7b9b7cb8766600b68144",
    "submitter": {
        "id": 126,
        "url": "https://patchwork.libcamera.org/api/people/126/?format=api",
        "name": "Daniel Semkowicz",
        "email": "dse@thaumatec.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18398/mbox/",
    "series": [
        {
            "id": 3805,
            "url": "https://patchwork.libcamera.org/api/series/3805/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3805",
            "date": "2023-03-14T14:48:24",
            "name": "ipa: rkisp1: Add autofocus algorithm",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/3805/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18398/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18398/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 6F185C329E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Mar 2023 14:50:06 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5324062728;\n\tTue, 14 Mar 2023 15:50:05 +0100 (CET)",
            "from mail-lj1-x230.google.com (mail-lj1-x230.google.com\n\t[IPv6:2a00:1450:4864:20::230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C03C46270A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Mar 2023 15:49:55 +0100 (CET)",
            "by mail-lj1-x230.google.com with SMTP id f16so16272877ljq.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Mar 2023 07:49:55 -0700 (PDT)",
            "from localhost.localdomain ([91.90.166.178])\n\tby smtp.gmail.com with ESMTPSA id\n\tq25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 14 Mar 2023 07:49:54 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1678805405;\n\tbh=RYSIynGlDgflsC6y+mnJZbE9L7co31kh2vCYt83mD0Y=;\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=R0ToUK81KijAmo6M1deIOieDoJ29ylB/Hn3OCNyzpvmPbQpaIf539gkdwPRVtrERS\n\t45edXmL0rglxy7dEEkPU4HFlEeg6PZ9EhTWC4l6MABZDVkERsYbHPRscEvLGhWMTJw\n\t7dmNoc+jbE5dI7bj9fa6tsTFVFe7Nes7fiCsVQiIqL0hF7MkcL31o1hC2pJ7AYTce+\n\tGOneBVS9YkjRDDrXO2VxbfRptp9fwkVfTOCB7LOornYAx68mj237zTUg6Bl6AF6iLw\n\tMvTr5w/QzpzF4EcBq2XyK28hduWq6NRQureMgYr9Cbmm8katoGig6sqZG+wJS94XUL\n\tc1ba5EO7uokgQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805394;\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=LIMALetFO7wAVuqtZcDoxVbIpR8Q7JtG3uCyJPy1QWQ=;\n\tb=QlMKpjtWamjxgnE/9Njmk/dFO2HT3by3QsRXqGEldxDXg31wTbByB4JTN9rPbp9kg7\n\tSnkg8wHMmKS/1/Lf3DdAN/jlFbPSupVj9RZAV9ZxgcFy2dG76kpcCyKFj+3i4tzZF8oF\n\t8YPIyrodd+li3EI/DWJ0ctR+P3mzmXQpCi4uHxfw7pdfcjldWkVjvnWgLEoa7awSkNso\n\t00IkWmBTckf+e4zKbq1CrbN0OJZ+oZS4/dsYwRUBijkrEgbBt+i1jcz3iYoCUOKaC9BU\n\tpM2epLGmSTufMEyrJtCddlexqkCHc8UvPvIXCETZMU0wVqpXPGbAgBcwK6jJxeZiH1Sm\n\tr0BQ=="
        ],
        "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=\"QlMKpjtW\"; \n\tdkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1678805394;\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=LIMALetFO7wAVuqtZcDoxVbIpR8Q7JtG3uCyJPy1QWQ=;\n\tb=AWwWU+vfH9Zb+r/T2W70PKi1Jma4wWEGGQVjv7BLkyTG1Hk3rsz9XSN674B8HO5Q5o\n\tcPXi1YMrnkImpaVLkmxjWlfVevu/64pgG5+FwNDouZYZL9dh3j2GyeQ0Q1jBbXYDFvpv\n\tHBghps81Zi47CCFfkTMvjCuxLkdF/egBa7HERrM4fu8saoPeetHLqHiXRPi0PVGky3Fb\n\tTBA8YQZPMEl59BRg/T+V23Qm5mWiH2XZd8jpSWBsFzmVIXdeNVWDnFnlw4KdBEapv/7X\n\txs0lgJNHCLOFC2vo3bAQkaDYmJH5WOTvP2RYSQ7GAxZkJVbrVcyIBI95zh42YiaZIGC9\n\tkMAg==",
        "X-Gm-Message-State": "AO0yUKUPycC9uweQEotuQyVBiTpZhFYeCtnSRpBGqw4ywkJo8HHmWebU\n\tcwRuSXiCoQ5aQu62l6GUzhSqCYQ2pDbJEmwDNCE=",
        "X-Google-Smtp-Source": "AK7set+YhA7EpitO3VtL65P7R58fNxZt0SuO9W39EysUlpoOU0Jv1LbglmxNagEt0PuYlSBwOnesRQ==",
        "X-Received": "by 2002:a2e:7006:0:b0:294:6a83:fb28 with SMTP id\n\tl6-20020a2e7006000000b002946a83fb28mr12243828ljc.41.1678805394701; \n\tTue, 14 Mar 2023 07:49:54 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 14 Mar 2023 15:48:31 +0100",
        "Message-Id": "<20230314144834.85193-8-dse@thaumatec.com>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20230314144834.85193-1-dse@thaumatec.com>",
        "References": "<20230314144834.85193-1-dse@thaumatec.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 07/10] ipa: rkisp1: af: Add \"Windows\"\n\tMetering mode",
        "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": "Add platform related code for configuring auto focus window on the\nrkisp1. Connect to the windowUpdateRequested() signal exposed by the\nAfHillClimbing and configure the window on each signal emission.\nThis enables support of AfMetering and AfWindows controls on the rkisp1\nplatform.\n\nCurrently, only one window is enabled, but ISP allows up to three\nof them.\n\nSigned-off-by: Daniel Semkowicz <dse@thaumatec.com>\n---\n src/ipa/rkisp1/algorithms/af.cpp | 63 +++++++++++++++++++++++++++++++-\n src/ipa/rkisp1/algorithms/af.h   | 11 ++++++\n 2 files changed, 73 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/af.cpp b/src/ipa/rkisp1/algorithms/af.cpp\nindex abf5d91f..794fa59e 100644\n--- a/src/ipa/rkisp1/algorithms/af.cpp\n+++ b/src/ipa/rkisp1/algorithms/af.cpp\n@@ -31,18 +31,48 @@ namespace libcamera::ipa::rkisp1::algorithms {\n  *   amount of time on each movement. This parameter should be set according\n  *   to the worst case  - the number of frames it takes to move lens between\n  *   limit positions.\n+ * - **isp-threshold:** Threshold used for minimizing the influence of noise.\n+ *   This affects the ISP sharpness calculation.\n+ * - **isp-var-shift:** The number of bits for the shift operation at the end\n+ *   of the calculation chain. This affects the ISP sharpness calculation.\n+ *\n+ * \\sa libcamera::ipa::common::algorithms::AfHillClimbing for additional tuning\n+ * parameters.\n  */\n \n LOG_DEFINE_CATEGORY(RkISP1Af)\n \n+namespace {\n+\n+constexpr rkisp1_cif_isp_window rectangleToIspWindow(const Rectangle &rectangle)\n+{\n+\treturn rkisp1_cif_isp_window{\n+\t\t.h_offs = static_cast<uint16_t>(rectangle.x),\n+\t\t.v_offs = static_cast<uint16_t>(rectangle.y),\n+\t\t.h_size = static_cast<uint16_t>(rectangle.width),\n+\t\t.v_size = static_cast<uint16_t>(rectangle.height)\n+\t};\n+}\n+\n+} /* namespace */\n+\n+Af::Af()\n+{\n+\taf.windowUpdateRequested.connect(this, &Af::updateCurrentWindow);\n+}\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+\tispThreshold_ = tuningData[\"isp-threshold\"].get<uint32_t>(128);\n+\tispVarShift_ = tuningData[\"isp-var-shift\"].get<uint32_t>(4);\n \n-\tLOG(RkISP1Af, Debug) << \"waitFramesLens_: \" << waitFramesLens_;\n+\tLOG(RkISP1Af, Debug) << \"waitFramesLens_: \" << waitFramesLens_\n+\t\t\t     << \", ispThreshold_: \" << ispThreshold_\n+\t\t\t     << \", ispVarShift_: \" << ispVarShift_;\n \n \treturn af.init(tuningData);\n }\n@@ -77,6 +107,32 @@ void Af::queueRequest([[maybe_unused]] IPAContext &context,\n \taf.queueRequest(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 rkisp1_params_cfg *params)\n+{\n+\tif (updateWindow_) {\n+\t\tparams->meas.afc_config.num_afm_win = 1;\n+\t\tparams->meas.afc_config.thres = ispThreshold_;\n+\t\tparams->meas.afc_config.var_shift = ispVarShift_;\n+\t\tparams->meas.afc_config.afm_win[0] =\n+\t\t\trectangleToIspWindow(*updateWindow_);\n+\n+\t\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AFC;\n+\t\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_AFC;\n+\t\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_AFC;\n+\n+\t\tupdateWindow_.reset();\n+\n+\t\t/* Wait one frame for the ISP to apply changes */\n+\t\taf.setFramesToSkip(1);\n+\t}\n+}\n+\n /**\n  * \\copydoc libcamera::ipa::Algorithm::process\n  */\n@@ -102,6 +158,11 @@ void Af::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \t}\n }\n \n+void Af::updateCurrentWindow(const Rectangle &window)\n+{\n+\tupdateWindow_ = window;\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\nindex 85de0a64..df2ca31a 100644\n--- a/src/ipa/rkisp1/algorithms/af.h\n+++ b/src/ipa/rkisp1/algorithms/af.h\n@@ -18,20 +18,31 @@ namespace libcamera::ipa::rkisp1::algorithms {\n class Af : public Algorithm\n {\n public:\n+\tAf();\n+\n \tint init(IPAContext &context, const YamlObject &tuningData) override;\n \tint configure(IPAContext &context,\n \t\t      const IPACameraSensorInfo &configInfo) override;\n \tvoid queueRequest(IPAContext &context, const uint32_t frame,\n \t\t\t  IPAFrameContext &frameContext,\n \t\t\t  const ControlList &controls) override;\n+\tvoid prepare(IPAContext &context, const uint32_t frame,\n+\t\t     IPAFrameContext &frameContext,\n+\t\t     rkisp1_params_cfg *params) override;\n \tvoid process(IPAContext &context, const uint32_t frame,\n \t\t     IPAFrameContext &frameContext,\n \t\t     const rkisp1_stat_buffer *stats,\n \t\t     ControlList &metadata) override;\n \n private:\n+\tvoid updateCurrentWindow(const Rectangle &window);\n+\n \tipa::common::algorithms::AfHillClimbing af;\n \n+\tstd::optional<Rectangle> updateWindow_;\n+\tuint32_t ispThreshold_;\n+\tuint32_t ispVarShift_;\n+\n \t/* Wait number of frames after changing lens position */\n \tuint32_t waitFramesLens_;\n };\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "07/10"
    ]
}