From patchwork Tue May 12 12:36:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 26731 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 67645C32F7 for ; Tue, 12 May 2026 12:37:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 03DC563039; Tue, 12 May 2026 14:37:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="HJjO03k9"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 331B76303B for ; Tue, 12 May 2026 14:36:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778589417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t7TccxbaxtRtPBd2f1gcTDUkMwjnJo0KY5oE/XGxSyA=; b=HJjO03k9sIAOU7Ua5CvkxMxk/9EE/A6qnrMorGWyUAUjkw4iLNgF6qPWCKkqotQx9irLR/ LtNSIczw9IFOHGgSIjLzpmzHFxWGevhKnCW7xr9MqTwtqDcVPDXpWPKJW0uxV44IuCjWfv uYZTDMBCSdg+VQXEzJgkjs53W8Zpqk8= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-371-AZ9LaXMJMbmbThGroB-VgA-1; Tue, 12 May 2026 08:36:55 -0400 X-MC-Unique: AZ9LaXMJMbmbThGroB-VgA-1 X-Mimecast-MFC-AGG-ID: AZ9LaXMJMbmbThGroB-VgA_1778589414 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AA83A19560B4; Tue, 12 May 2026 12:36:54 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.50.44]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9E6D41955D84; Tue, 12 May 2026 12:36:52 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Bryan O'Donoghue , Hans de Goede , Laurent Pinchart 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-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a `type' YAML item to the lens shading correction algorithm, in order to distinguish between different methods and their parameters. It is the same as in rkisp1 IPA. A corresponding class variable is added to Lsc. The only supported type for the moment is `table', for the grid-based LSC already implemented. The LSC type will be passed through the IPA interface in a followup patch. For this reason, it's defined as an enum based on uint32_t rather than as an `enum class', so that it can be passed through the Mojo interface as a simple integer without further arrangements. The Lsc algorithm YAML definition has now a new required item type: table to indicate the LSC method to be used. Signed-off-by: Milan Zamazal --- .../internal/software_isp/debayer_params.h | 3 +++ src/ipa/simple/algorithms/lsc.cpp | 23 +++++++++++++------ src/ipa/simple/algorithms/lsc.h | 1 + src/libcamera/software_isp/debayer.cpp | 10 ++++++++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 5b1c8b508..9e6c9ddb8 100644 --- a/include/libcamera/internal/software_isp/debayer_params.h +++ b/include/libcamera/internal/software_isp/debayer_params.h @@ -34,6 +34,9 @@ struct DebayerParams { kLscValuesPerCell * sizeof(LscValueType); using LscLookupTable = std::array; + enum LscType : uint32_t { + LscTable, + }; LscLookupTable lscLut{}; }; diff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp index 4b821005f..87023bc9b 100644 --- a/src/ipa/simple/algorithms/lsc.cpp +++ b/src/ipa/simple/algorithms/lsc.cpp @@ -17,13 +17,22 @@ LOG_DEFINE_CATEGORY(IPASoftLsc) int Lsc::init(IPAContext &context, const ValueNode &tuningData) { - int retR = lscR_.readYaml(tuningData["sets"], "ct", "r"); - int retG = lscG_.readYaml(tuningData["sets"], "ct", "g"); - int retB = lscB_.readYaml(tuningData["sets"], "ct", "b"); - - if (retR < 0 || retG < 0 || retB < 0) { - LOG(IPASoftLsc, Error) - << "Failed to parse 'lsc' parameter from tuning file."; + std::string type = tuningData["type"].get("table"); + + if (type == "table") { + int retR = lscR_.readYaml(tuningData["sets"], "ct", "r"); + int retG = lscG_.readYaml(tuningData["sets"], "ct", "g"); + int retB = lscB_.readYaml(tuningData["sets"], "ct", "b"); + + if (retR < 0 || retG < 0 || retB < 0) { + LOG(IPASoftLsc, Error) + << "Failed to parse 'lsc' parameter from tuning file."; + return -EINVAL; + } + + type_ = DebayerParams::LscTable; + } else { + LOG(IPASoftLsc, Error) << "LSC: type " << type << " not supported"; return -EINVAL; } diff --git a/src/ipa/simple/algorithms/lsc.h b/src/ipa/simple/algorithms/lsc.h index 16950c5af..d7d7c9559 100644 --- a/src/ipa/simple/algorithms/lsc.h +++ b/src/ipa/simple/algorithms/lsc.h @@ -31,6 +31,7 @@ public: private: using LscMatrix = Matrix; + DebayerParams::LscType type_; Interpolator lscR_; Interpolator lscG_; Interpolator lscB_; diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index cc1dbb2d0..12c2ec9fd 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -53,6 +53,16 @@ namespace libcamera { * \brief Number of pixel values per each of the lens shading grid areas */ +/** + * \enum DebayerParams::LscType + * \brief Type of lens shading correction to apply + */ + +/** + * \var DebayerParams::LscTable + * \brief Lens shading correction using a lookup table + */ + /** * \typedef DebayerParams::LscValueType * \brief Type of LSC grid values