Patch Detail
Show a patch.
GET /api/1.1/patches/18146/?format=api
{ "id": 18146, "url": "https://patchwork.libcamera.org/api/1.1/patches/18146/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18146/", "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-8-dse@thaumatec.com>", "date": "2023-01-19T08:41:11", "name": "[libcamera-devel,v3,7/8] ipa: rkisp1: Add \"Windows\" Metering mode to auto focus algorithm", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "52f08e30d0af891dcd7a219582c727aa57e67bd9", "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/18146/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/18146/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18146/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 150DAC3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Jan 2023 08:42:25 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CC530625EB;\n\tThu, 19 Jan 2023 09:42:24 +0100 (CET)", "from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9939F625F6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Jan 2023 09:42:13 +0100 (CET)", "by mail-wm1-x32c.google.com with SMTP id\n\tc4-20020a1c3504000000b003d9e2f72093so3044568wma.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Jan 2023 00:42:13 -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.12\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 19 Jan 2023 00:42:12 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1674117744;\n\tbh=/sWMrM0yDvzVCpeO45m6mMKX2012/YfF5BROtCocLs8=;\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=q+qP9boHawxIJW6aJJDT4Rpd24h6HbKn/w2R2eXN/0QRwRNj8S8W0FgPzZ5RJGlKf\n\tqBtIraDBBk/UrqUo+aDGVWgD4kJXKbLrK480zSP+xIiL3Wxi3WrNfXsaFgtVM120dn\n\tk9w71SNef2BAMg/vt263O+pTfOGiutUCI4bYxU55H3QZ99dYaTQ2NANI5Sd4ecDEWv\n\t4q9zAB9SAGsydTRhBGFr5GgfeFyJB55A+DW5H406u+QHs1YTUTaP3Yczuqk76eqaj8\n\tWIMRFh35tzhzUogxt1sOnfJBmOx0JV/0jM0sgxEwNtrD5Mo1Hc542R98hMmCqB7Z39\n\tt6LkH82pvm5Eg==", "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=ZdYpCqlVgBVjIXhtQANwxiepcG4LDSc5L3JxbSsR2KI=;\n\tb=dRdmPQa/2FfkiDhcclksM8LF+gn1x1tG7Fk9lwvzWmEDGiX0cAV3QMgO90SN9g25Dh\n\tbn10FV2R9aO72fFlISTdF/8FaV3njHioORxWF7O4H9JKJxhEzB6Qfhg/ksB5vNYPnQfN\n\ty5Xa7PN3SbmWIQWdNvjQJdkTewS1Ins3+U9Zf/2nm8S1+0J4gA2JdCzAuwoD9sX8wYsO\n\tkubQo/PkzP8Q353ICf43YCGbbVN7G4VWZ66JEoCpoX8oyoT+UxfdQ6OP8+mAUMycs+kj\n\tbbxy/Cc1hY5OpP2pnP7G40HAJPabfDq9umcfwfP80LksLJO0umreXjsBygJSL6f84Pe7\n\tkMyQ==" ], "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=\"dRdmPQa/\"; \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=ZdYpCqlVgBVjIXhtQANwxiepcG4LDSc5L3JxbSsR2KI=;\n\tb=K5gTNUpo3pZ1r8t514kJzZccsULFF39T4EZoBCsxgLevfxXUtL7U2Pv8JMEhYWk3c1\n\tuKQc4HGMqTw92hIDiG9w+pAmUi2/FAXPWqoxTv0wGb8V6G24Lk1wgkjQMk1FTVnZCrG3\n\tXXRVpqwZIxZZWh4SuXWuScG/qoNerko2e78Et2/vPRceDJ47EbWyB+GaM4ySQkbN4cfe\n\tDXuiU7k4DZjWnKFSs3YfkTZkQUPUpkYCZ0+DMxrfkz2nf5m0lAqsOWbUr1P9sRDn8CrH\n\txnDLKHTaeDz5M42lc6UUBnNLaoZDth6TMTqHjE0KDunHKr8d066/q+E2DuY7flTEfzJG\n\tFvzQ==", "X-Gm-Message-State": "AFqh2kpgWQbXbhgdXM1xIEg5yNSxLcE7t3DV0iAHrGSoCumXbIf07tqT\n\tC5HRfWbM9yrTCq2NKyAKw68Aar/62thm3S+RIJ4=", "X-Google-Smtp-Source": "AMrXdXvd+oyp7qnUJ5BSw0OuEe7OaPrIKGJokgLkgwY/HnieD5B/pWyLQgeqIneK68tQRa3pig64Fw==", "X-Received": "by 2002:a05:600c:3495:b0:3db:a3a:4594 with SMTP id\n\ta21-20020a05600c349500b003db0a3a4594mr8239090wmq.28.1674117733262; \n\tThu, 19 Jan 2023 00:42:13 -0800 (PST)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 19 Jan 2023 09:41:11 +0100", "Message-Id": "<20230119084112.20564-8-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 7/8] ipa: rkisp1: Add \"Windows\"\n\tMetering mode to auto focus algorithm", "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": "Allow manually setting auto focus window. Currently only one window is\nenabled, but ISP allows up to three of them.\n\nSigned-off-by: Daniel Semkowicz <dse@thaumatec.com>\n---\n src/ipa/rkisp1/algorithms/af.cpp | 93 +++++++++++++++++++++++++++++---\n src/ipa/rkisp1/algorithms/af.h | 9 ++++\n src/ipa/rkisp1/rkisp1.cpp | 2 +\n 3 files changed, 98 insertions(+), 6 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/af.cpp b/src/ipa/rkisp1/algorithms/af.cpp\nindex c2a321cd..65768fc4 100644\n--- a/src/ipa/rkisp1/algorithms/af.cpp\n+++ b/src/ipa/rkisp1/algorithms/af.cpp\n@@ -20,14 +20,32 @@ namespace libcamera::ipa::rkisp1::algorithms {\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 /**\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 initBase(tuningData);\n }\n@@ -36,8 +54,15 @@ int Af::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)\n * \\copydoc libcamera::ipa::Algorithm::configure\n */\n int Af::configure([[maybe_unused]] IPAContext &context,\n-\t\t [[maybe_unused]] const IPACameraSensorInfo &configInfo)\n+\t\t const IPACameraSensorInfo &configInfo)\n {\n+\t/* Default AF window of 3/4 size of the screen placed at the center */\n+\tdefaultWindow_ = Rectangle(configInfo.outputSize.width / 8,\n+\t\t\t\t configInfo.outputSize.height / 8,\n+\t\t\t\t 3 * configInfo.outputSize.width / 4,\n+\t\t\t\t 3 * configInfo.outputSize.height / 4);\n+\tupdateCurrentWindow(defaultWindow_);\n+\n \treturn 0;\n }\n \n@@ -50,6 +75,21 @@ void Af::queueRequest([[maybe_unused]] IPAContext &context,\n \t\t const ControlList &controls)\n {\n \tqueueRequestBase(frame, controls);\n+\n+\tfor (auto const &[id, value] : controls) {\n+\t\tswitch (id) {\n+\t\tcase controls::AF_METERING: {\n+\t\t\tsetMeteringMode(static_cast<controls::AfMeteringEnum>(value.get<int32_t>()));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase controls::AF_WINDOWS: {\n+\t\t\tsetWindows(value.get<Span<const Rectangle>>());\n+\t\t\tbreak;\n+\t\t}\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\t}\n }\n \n /**\n@@ -58,8 +98,23 @@ void Af::queueRequest([[maybe_unused]] IPAContext &context,\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+\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] = rectangleToIspWindow(*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\tsetFramesToSkip(1);\n+\t}\n }\n \n /**\n@@ -88,12 +143,38 @@ void Af::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \n void Af::setMeteringMode([[maybe_unused]] controls::AfMeteringEnum metering)\n {\n-\tLOG(RkISP1Af, Error) << __FUNCTION__ << \" not implemented!\";\n+\tif (metering == meteringMode_)\n+\t\treturn;\n+\n+\tif (metering == controls::AfMeteringWindows) {\n+\t\tupdateCurrentWindow(userWindow_);\n+\t} else {\n+\t\tupdateCurrentWindow(defaultWindow_);\n+\t}\n+\n+\tmeteringMode_ = metering;\n+}\n+\n+void Af::setWindows(Span<const Rectangle> windows)\n+{\n+\tif (windows.size() != 1) {\n+\t\tLOG(RkISP1Af, Error) << \"Only one AF window is supported\";\n+\t\treturn;\n+\t}\n+\n+\t/* \\todo Check if window size is valid for ISP */\n+\n+\tLOG(RkISP1Af, Debug) << \"setWindows: \" << userWindow_;\n+\n+\tuserWindow_ = windows[0];\n+\n+\tif (meteringMode_ == controls::AfMeteringWindows)\n+\t\tupdateCurrentWindow(userWindow_);\n }\n \n-void Af::setWindows([[maybe_unused]] Span<const Rectangle> windows)\n+void Af::updateCurrentWindow(const Rectangle &window)\n {\n-\tLOG(RkISP1Af, Error) << __FUNCTION__ << \" not implemented!\";\n+\tupdateWindow_ = window;\n }\n \n REGISTER_IPA_ALGORITHM(Af, \"Af\")\ndiff --git a/src/ipa/rkisp1/algorithms/af.h b/src/ipa/rkisp1/algorithms/af.h\nindex 882be952..72cc7932 100644\n--- a/src/ipa/rkisp1/algorithms/af.h\n+++ b/src/ipa/rkisp1/algorithms/af.h\n@@ -35,6 +35,15 @@ private:\n \tvoid setMeteringMode(controls::AfMeteringEnum metering) final;\n \tvoid setWindows(Span<const Rectangle> windows) final;\n \n+\tvoid updateCurrentWindow(const Rectangle &window);\n+\n+\tcontrols::AfMeteringEnum meteringMode_ = controls::AfMeteringAuto;\n+\tRectangle defaultWindow_;\n+\tRectangle userWindow_;\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 };\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex bc2508a2..c300c3b0 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -101,9 +101,11 @@ namespace {\n /* List of controls handled by the RkISP1 IPA */\n const ControlInfoMap::Map rkisp1Controls{\n \t{ &controls::AeEnable, ControlInfo(false, true) },\n+\t{ &controls::AfMetering, ControlInfo(controls::AfMeteringValues) },\n \t{ &controls::AfMode, ControlInfo(controls::AfModeValues) },\n \t{ &controls::AfPause, ControlInfo(controls::AfPauseValues) },\n \t{ &controls::AfTrigger, ControlInfo(controls::AfTriggerValues) },\n+\t{ &controls::AfWindows, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) },\n \t{ &controls::AwbEnable, ControlInfo(false, true) },\n \t{ &controls::ColourGains, ControlInfo(0.0f, 3.996f, 1.0f) },\n \t{ &controls::Brightness, ControlInfo(-1.0f, 0.993f, 0.0f) },\n", "prefixes": [ "libcamera-devel", "v3", "7/8" ] }