From patchwork Mon Jul 20 14:59:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 27392 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 CCD90C328C for ; Mon, 20 Jul 2026 14:59:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0947467E4F; Mon, 20 Jul 2026 16:59:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eqIpD3Lp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B1DDF66177 for ; Mon, 20 Jul 2026 16:59:40 +0200 (CEST) Received: from [192.168.1.106] (mob-5-90-63-152.net.vodafone.it [5.90.63.152]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 995D4270; Mon, 20 Jul 2026 16:58:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1784559522; bh=H7/in1JCGamD909OeONr1G+ol7xLUzHSQXV3mR/9C00=; h=From:Subject:Date:To:Cc:From; b=eqIpD3Lp1NQNS1cEmTBwmHixSgD2k7Pi7V93mTfBKzlQ8lxSSmxhM0rXFwalAZCGa y/lw4Wb7iXromfl5iicXbcLmQaDByV+aF5jlrjoDEtLrWTWTtkXyHLRONPb1U60ppW 1IEf8uHWpr/XVli3qjzGTsWNI+AXXGgvV/RimuPg= From: Jacopo Mondi Subject: [PATCH v6 00/31] ipa: libipa: Introduce libipa algorithms Date: Mon, 20 Jul 2026 16:59:18 +0200 Message-Id: <20260720-libipa-algorithms-v6-0-ececb73f97cb@ideasonboard.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAMY3XmoC/4XOO27DMAyA4asEmqtCpl5mp96j6CDZVEwgiQIpM FoEvnvlLM1gt+NPgB95F5UKUxVvh7soNHPlfGnhXg5imMLlSJLH1gIUOOU6K08c+RpkOB1z4dt 0rtKicy4OQQVIou1dCyX+epgfn60nrrdcvh8n5m6d/qXNnVSS0OCA2hsAeueRQs2XmEMZX4d8F is6wxMEeguCBiX0RuvUAZk9SP9CXrktSDcIXe+tj0r3Me5A5hnqtyCzfqQIMSltAc0OZP+FbIO Utzg2B5OFDWhZlh/xBbsw3QEAAA== X-Change-ID: 20260615-libipa-algorithms-59666bca0a2f To: libcamera-devel@lists.libcamera.org, Stefan Klug , Milan Zamazal Cc: Jacopo Mondi , Kieran Bingham , Daniel Scally , Robert Mader , Laurent Pinchart X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7383; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=H7/in1JCGamD909OeONr1G+ol7xLUzHSQXV3mR/9C00=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqXjfQ7rcaX7j/6aQRBmPtpJbL7gBPILTvSAYW5 09vvqL1HIyJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCal430AAKCRByNAaPFqFW POtQD/0eOObMbAF0mem8YmvPGzBkyJNGOdWO+2xahn7VUYRgPtKrZTNoEPvT3SNK36V1Qwccxuw JiLNE9QtUKPTPJgrwauoZzPcsZh5t73bJpl2Mzona8oeE7I0gl2QeBEnl2DQCkMOHH1Qqtjo//a Jf4KIXvD1hQ64cVrUAJXRITa1j2fb2Z066uQNhrynQqDFpR7smV4HkFkijGFp4yOSp3qQqgcYwq W7VLZSbfnZMgBqyQR6jhme5muRlaVkinoP7gRKq6FoG2q3jk7kGXFchqW68xca6cggJ46OP8DKH qnHBFyz1PxbNUGnytYzurbd7Z1rccubV/Ng8z2vYTP1zIKutCS1Uv6GznEYF98WUBGDGfSDuHwU Fo6ZqSgxmmQBvgQUKoZGkANxar6uNJIXL3MwTCwBM+8FNVTUwQNMlVGXRilULPsJZn8OFRVNKPf K8t4SNT3UM5hlNapi0t4L5HSkuhuMNgxHbLeWBHHeE7vOVa9KqmzHxm23tZFy8rNnhIPxMQk5aE UocA2ZfPQas/pU82GpYSCf0EricxdWjktonrGKi4CAv20zOl8sKbD1FuFjoSUyalkjUcRm6ntyX GnYtldTnSmMbz3vMnGaPfNAbyFnGsohbhNcWvZGyCmSxlM5/56mE3XtaACXJ38Q5EIbrnzv09UG 1PAZVsAJNnLdDLQ== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" The series is identical to v5 up to patch 27. The only minor difference is that I back-tracked on making functions class members but in the RkISP1 IPA I kept them as static helpers. Patches 28 and 29 are new. They remove the templating of the LscAlgorithm class hierarchy and instead implement quantization in the LscAlgorithm class. So we now expand polynomials and parse tables as floats, store them in a map and in LscAlgorithm we re-iterate over it to either quantized them in the polynomial case, or simply cast floats to the register bit width if table. Timing the duration of the whole RkISP1 configure operation, it now takes 3 msec compared to 600 usec. RkISP1Lsc lsc.cpp:171 Configure took = 3081[µs] RkISP1Lsc lsc.cpp:172 Configure took = 583[µs] Also, now each IPA has to define their own Interpolator::interpolate() overload (see rkisp1 IPA as an example of this). As the interface of LscAlgorithm has changed, patches on the list that port the LSC algorithm of other platforms based on v5 will have to be rebased. Signed-off-by: Jacopo Mondi --- Changes in v6: - Address comments received on v5, mostly on documentation - Remove templating of LscPolynomial and perform quantization in LscAlgorithm Changes in v5: - Add "ipa: libipa: lsc_polynomial: Fix polynomial parsing error" to fix and exiting potential issue with Polynomial parsing - Fix Simple, which I broke in v4, thanks Milan Changes in v4: - s/awb/AWB in comments everywhere, same for CCM and LSC - Awb: changelog per patch - Make AwbStats pure virtual and move stats parsing logic to the IPA modules - Reduce comments/renames to reduce patch size and comments - Collect tags Changes in v3: - Address comments on Awb from Stefan: - Introduce AwbImplementation::Result - Move AwbStats implementation to IPAs - Drop AwbStats::rg()/bg() and re-implement AwbGray accordingly - Fix Saturation bug in Simple Ccm algorithm - Fix Simple Ccm gain limits using Q<2, 8> - Update Mali CCM and Gamma to latest uAPI patch version - Fix Mali CCM gain masking as reported by Dan - Break down libIPA Lsc implementation as requested by Stefan Changes in v2: - Introduce awb::Context to simplify ActiveState and FrameContext definition - Add mali uAPI header for CCM and Gamma - Do not rename Mali functions for hardware configuration in awb and lsc - Spelling and documentation --- Jacopo Mondi (28): ipa: libipa: awb: Reimplement AwbAlgorithm ipa: mali-c55: awb: Port to use libipa AwbAlgorithm ipa: libipa: Add CcmAlgorithm to libipa ipa: rkisp1: ccm: Port to use CcmAlgorithm include: linux: mali-c55: Update to support CCM and Gamma ipa: mali-c55: Implement Ccm algorithm ipa: rkisp1: lsc: Re-architecture Lsc support ipa: libipa: Introduce lsc_base.h ipa: libipa: lsc_polynomial: Fix polynomial parsing error ipa: libipa: lsc_polynomial: Rename LscPolynomial ipa: libipa: lsc_polynomial: Do not inline functions ipa: libipa: lsc: Move Interpolator to lsc_base ipa: rkisp1: lsc: Remove rogue empty line ipa: libipa: lsc_polynomial: Move LscPolynomial from RkISP1 ipa: libipa: lsc_table: Move LscTable from RkISP1 ipa: libipa: lsc_base: Add sampleForCrop documentation ipa: libipa: lsc: Introduce LscAlgorithm ipa: libipa: lsc: Move sizesListToPositions() back to rkisp1 ipa: rkisp1: lsc: Port to use LscAlgorithm ipa: libipa: lsc: Make Components a map<> ipa: libipa: lsc: Document Components parsing ipa: libipa: lsc_polynomial: Remove sensorSize_ ipa: libipa: lsc: Document LscDescriptor::sensorSize usage ipa: libipa: lsc: Quantize lsc gains in IPA ipa: libipa: lsc: Quantize gains in LscAlgorithm ipa: libipa: lsc: Re-sort LscAlgorithmBase documentation ipa: mali-c55: Add sensorInfo to IPAContext ipa: mali-c55: Port to use LscAlgorithm Kieran Bingham (2): ipa: simple: awb: Port to use libipa AwbAlgorithm ipa: simple: Port to use libipa CcmAlgorithm Laurent Pinchart (1): ipa: libipa: lsc_polynomial: Don't inline ValueNode accessor .../internal/software_isp/debayer_params.h | 4 +- include/linux/media/arm/mali-c55-config.h | 86 ++++- src/ipa/libipa/awb.cpp | 418 +++++++++++++++++--- src/ipa/libipa/awb.h | 100 ++++- src/ipa/libipa/awb_bayes.cpp | 52 +-- src/ipa/libipa/awb_bayes.h | 12 +- src/ipa/libipa/awb_grey.cpp | 16 +- src/ipa/libipa/awb_grey.h | 6 +- src/ipa/libipa/ccm.cpp | 245 ++++++++++++ src/ipa/libipa/ccm.h | 77 ++++ src/ipa/libipa/lsc.cpp | 372 ++++++++++++++++++ src/ipa/libipa/lsc.h | 137 +++++++ src/ipa/libipa/lsc_base.cpp | 136 +++++++ src/ipa/libipa/lsc_base.h | 56 +++ src/ipa/libipa/lsc_polynomial.cpp | 208 +++++++++- src/ipa/libipa/lsc_polynomial.h | 100 ++--- src/ipa/libipa/lsc_table.cpp | 107 +++++ src/ipa/libipa/lsc_table.h | 55 +++ src/ipa/libipa/meson.build | 8 + src/ipa/mali-c55/algorithms/awb.cpp | 223 ++++++----- src/ipa/mali-c55/algorithms/awb.h | 28 +- src/ipa/mali-c55/algorithms/ccm.cpp | 173 +++++++++ src/ipa/mali-c55/algorithms/ccm.h | 66 ++++ src/ipa/mali-c55/algorithms/lsc.cpp | 156 +++++--- src/ipa/mali-c55/algorithms/lsc.h | 32 +- src/ipa/mali-c55/algorithms/meson.build | 1 + src/ipa/mali-c55/ipa_context.cpp | 3 + src/ipa/mali-c55/ipa_context.h | 20 +- src/ipa/mali-c55/mali-c55.cpp | 2 + src/ipa/mali-c55/params.h | 2 + src/ipa/rkisp1/algorithms/awb.cpp | 191 ++------- src/ipa/rkisp1/algorithms/awb.h | 18 +- src/ipa/rkisp1/algorithms/ccm.cpp | 97 +---- src/ipa/rkisp1/algorithms/ccm.h | 17 +- src/ipa/rkisp1/algorithms/lsc.cpp | 429 +++------------------ src/ipa/rkisp1/algorithms/lsc.h | 74 ++-- src/ipa/rkisp1/ipa_context.h | 49 +-- src/ipa/simple/algorithms/awb.cpp | 140 +++++-- src/ipa/simple/algorithms/awb.h | 28 ++ src/ipa/simple/algorithms/blc.cpp | 2 +- src/ipa/simple/algorithms/ccm.cpp | 74 ++-- src/ipa/simple/algorithms/ccm.h | 22 +- src/ipa/simple/ipa_context.h | 15 +- src/libcamera/software_isp/debayer_cpu.cpp | 12 +- 44 files changed, 2934 insertions(+), 1135 deletions(-) --- base-commit: 709ad59a8d90af3570be1c8d02dee0ec9e011954 change-id: 20260615-libipa-algorithms-59666bca0a2f Best regards,