{"id":26731,"url":"https://patchwork.libcamera.org/api/patches/26731/?format=json","web_url":"https://patchwork.libcamera.org/patch/26731/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20260512123619.120068-9-mzamazal@redhat.com>","date":"2026-05-12T12:36:12","name":"[RFC,v5,08/10] ipa: simple: Add LSC type","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"90e3afc1e00c0f874740a9a06384b7b84e6d985d","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26731/mbox/","series":[{"id":5936,"url":"https://patchwork.libcamera.org/api/series/5936/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5936","date":"2026-05-12T12:36:04","name":"LSC for SoftISP simple pipeline","version":5,"mbox":"https://patchwork.libcamera.org/series/5936/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26731/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26731/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 67645C32F7\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 May 2026 12:37:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 03DC563039;\n\tTue, 12 May 2026 14:37:02 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 331B76303B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 May 2026 14:36:58 +0200 (CEST)","from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-371-AZ9LaXMJMbmbThGroB-VgA-1;\n\tTue, 12 May 2026 08:36:55 -0400","from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.17])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id AA83A19560B4; Tue, 12 May 2026 12:36:54 +0000 (UTC)","from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.50.44])\n\tby mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 9E6D41955D84; Tue, 12 May 2026 12:36:52 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"HJjO03k9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1778589417;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=t7TccxbaxtRtPBd2f1gcTDUkMwjnJo0KY5oE/XGxSyA=;\n\tb=HJjO03k9sIAOU7Ua5CvkxMxk/9EE/A6qnrMorGWyUAUjkw4iLNgF6qPWCKkqotQx9irLR/\n\tLtNSIczw9IFOHGgSIjLzpmzHFxWGevhKnCW7xr9MqTwtqDcVPDXpWPKJW0uxV44IuCjWfv\n\tuYZTDMBCSdg+VQXEzJgkjs53W8Zpqk8=","X-MC-Unique":"AZ9LaXMJMbmbThGroB-VgA-1","X-Mimecast-MFC-AGG-ID":"AZ9LaXMJMbmbThGroB-VgA_1778589414","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>, Bryan O'Donoghue <bod.linux@nxsw.ie>,\n\tHans de Goede <johannes.goede@oss.qualcomm.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"[RFC PATCH v5 08/10] ipa: simple: Add LSC type","Date":"Tue, 12 May 2026 14:36:12 +0200","Message-ID":"<20260512123619.120068-9-mzamazal@redhat.com>","In-Reply-To":"<20260512123619.120068-1-mzamazal@redhat.com>","References":"<20260512123619.120068-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.17","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"HTHu721DmnzVgDEoR8RdDnAnaMQirZeIddydKU7GoVk_1778589414","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a `type' YAML item to the lens shading correction algorithm, in\norder to distinguish between different methods and their parameters.  It\nis the same as in rkisp1 IPA.  A corresponding class variable is added\nto Lsc.\n\nThe only supported type for the moment is `table', for the grid-based\nLSC already implemented.\n\nThe LSC type will be passed through the IPA interface in a followup\npatch.  For this reason, it's defined as an enum based on uint32_t\nrather than as an `enum class', so that it can be passed through the\nMojo interface as a simple integer without further arrangements.\n\nThe Lsc algorithm YAML definition has now a new required item\n\n  type: table\n\nto indicate the LSC method to be used.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n .../internal/software_isp/debayer_params.h    |  3 +++\n src/ipa/simple/algorithms/lsc.cpp             | 23 +++++++++++++------\n src/ipa/simple/algorithms/lsc.h               |  1 +\n src/libcamera/software_isp/debayer.cpp        | 10 ++++++++\n 4 files changed, 30 insertions(+), 7 deletions(-)","diff":"diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h\nindex 5b1c8b508..9e6c9ddb8 100644\n--- a/include/libcamera/internal/software_isp/debayer_params.h\n+++ b/include/libcamera/internal/software_isp/debayer_params.h\n@@ -34,6 +34,9 @@ struct DebayerParams {\n \t\tkLscValuesPerCell * sizeof(LscValueType);\n \tusing LscLookupTable =\n \t\tstd::array<LscValueType, kLscGridSize * kLscGridSize * kLscValuesPerCell>;\n+\tenum LscType : uint32_t {\n+\t\tLscTable,\n+\t};\n \tLscLookupTable lscLut{};\n };\n \ndiff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp\nindex 4b821005f..87023bc9b 100644\n--- a/src/ipa/simple/algorithms/lsc.cpp\n+++ b/src/ipa/simple/algorithms/lsc.cpp\n@@ -17,13 +17,22 @@ LOG_DEFINE_CATEGORY(IPASoftLsc)\n \n int Lsc::init(IPAContext &context, const ValueNode &tuningData)\n {\n-\tint retR = lscR_.readYaml(tuningData[\"sets\"], \"ct\", \"r\");\n-\tint retG = lscG_.readYaml(tuningData[\"sets\"], \"ct\", \"g\");\n-\tint retB = lscB_.readYaml(tuningData[\"sets\"], \"ct\", \"b\");\n-\n-\tif (retR < 0 || retG < 0 || retB < 0) {\n-\t\tLOG(IPASoftLsc, Error)\n-\t\t\t<< \"Failed to parse 'lsc' parameter from tuning file.\";\n+\tstd::string type = tuningData[\"type\"].get<std::string>(\"table\");\n+\n+\tif (type == \"table\") {\n+\t\tint retR = lscR_.readYaml(tuningData[\"sets\"], \"ct\", \"r\");\n+\t\tint retG = lscG_.readYaml(tuningData[\"sets\"], \"ct\", \"g\");\n+\t\tint retB = lscB_.readYaml(tuningData[\"sets\"], \"ct\", \"b\");\n+\n+\t\tif (retR < 0 || retG < 0 || retB < 0) {\n+\t\t\tLOG(IPASoftLsc, Error)\n+\t\t\t\t<< \"Failed to parse 'lsc' parameter from tuning file.\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\ttype_ = DebayerParams::LscTable;\n+\t} else {\n+\t\tLOG(IPASoftLsc, Error) << \"LSC: type \" << type << \" not supported\";\n \t\treturn -EINVAL;\n \t}\n \ndiff --git a/src/ipa/simple/algorithms/lsc.h b/src/ipa/simple/algorithms/lsc.h\nindex 16950c5af..d7d7c9559 100644\n--- a/src/ipa/simple/algorithms/lsc.h\n+++ b/src/ipa/simple/algorithms/lsc.h\n@@ -31,6 +31,7 @@ public:\n \n private:\n \tusing LscMatrix = Matrix<float, DebayerParams::kLscGridSize, DebayerParams::kLscGridSize>;\n+\tDebayerParams::LscType type_;\n \tInterpolator<LscMatrix> lscR_;\n \tInterpolator<LscMatrix> lscG_;\n \tInterpolator<LscMatrix> lscB_;\ndiff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp\nindex cc1dbb2d0..12c2ec9fd 100644\n--- a/src/libcamera/software_isp/debayer.cpp\n+++ b/src/libcamera/software_isp/debayer.cpp\n@@ -53,6 +53,16 @@ namespace libcamera {\n  * \\brief Number of pixel values per each of the lens shading grid areas\n  */\n \n+/**\n+ * \\enum DebayerParams::LscType\n+ * \\brief Type of lens shading correction to apply\n+ */\n+\n+/**\n+ * \\var DebayerParams::LscTable\n+ * \\brief Lens shading correction using a lookup table\n+ */\n+\n /**\n  * \\typedef DebayerParams::LscValueType\n  * \\brief Type of LSC grid values\n","prefixes":["RFC","v5","08/10"]}