From patchwork Fri Feb 13 16:57:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 26142 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 9B65FBD78E for ; Fri, 13 Feb 2026 16:58:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4EE1B621DC; Fri, 13 Feb 2026 17:58:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VI8W1fSq"; 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 5615262010 for ; Fri, 13 Feb 2026 17:58:04 +0100 (CET) Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D9444348; Fri, 13 Feb 2026 17:57:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1771001835; bh=XTDk1b9gzdajspcw2h77FDBR3S943inQN0g0g8+9VOk=; h=From:Subject:Date:To:Cc:From; b=VI8W1fSqnReGK10+ngkZ/ofxZH/F84loA2xw0jXIeNrbwRnRWwhLl+z8xXeQcDIDo rhbHkxJEhm8d8DQKDGl9OLyBHrFxIywU8zFmoeuN+VSE6sQzqq/SmFE55El7WytTxV v6nMubK78ngeTei4fk9DSIpIbiCo2FHSbwXGCEJs= From: Kieran Bingham Subject: [PATCH v7 00/15] libipa: Introduce a Quantized type Date: Fri, 13 Feb 2026 16:57:39 +0000 Message-Id: <20260213-kbingham-quantizers-v7-0-1626b9aaabf1@ideasonboard.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAANYj2kC/x3MQQqAIBBA0avIrBNMsKirRAvNsYbISiui8O5Jy 7f4/4WIgTBCy14IeFGk1WfUBYNh0n5ETjYbpJCVkKXgsyE/Tnrh+6n9QQ+GyBtrldDOVUY5yOU W0NH9X7s+pQ/SHEJ2ZQAAAA== X-Change-ID: 20260210-kbingham-quantizers-9dd50aff6b5f To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , =?utf-8?q?Barnab?= =?utf-8?b?w6FzIFDFkWN6ZQ==?= , Isaac Scott , Laurent Pinchart , "van Veen, Stephan" X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771001883; l=6061; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=XTDk1b9gzdajspcw2h77FDBR3S943inQN0g0g8+9VOk=; b=4gEfXAJYfzs8ecgkHNzNinOKrvIHNoMfUe/NsjKPsuWSUWUVS51+hpPhR1dwYgAP2ivPsBfFy 73/Jxx7OLeFBSbhzBFCmciHp9BT/B6AVNg0HGCunOtidLHGwhsQ3zOE X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= 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" This series superceeds [0] "rkisp1: cproc - Metadata and Hue developments" by introducing a new base type for libipa to be able to maintain values which are quantized for hardware. These data values often need to be converted, perhaps to a fixed-point format for configuration of hardware, but also then back to a floating point for returning as metadata. The underlying storage of a quantized fixed point is now always unsigned and we ensure that signed extensions can not occur when storing in larger registers. In particular this series builds to solve the review comment that blocked the original series at [1] The Quantized type provides a storage mechanism to make both of these storage representations visible to code that wishes to utilise the specific values. The series then re-introduces the proposed updates to cproc using the new Q types by supplying Fixed Point types and a scaled fixed point type for the Hue control. Finally, the remaining users of the fixedToFloatingPoint and floatingToFixedPoint are converted and the old helpers and tests are removed. This in cases such as the Mali-C55 AWB Gains means that we now report accurate gains as used by the hardware in the metadata. This then allows us to clean up a workaround which was managing the usage of unsigned integers to represent signed floats. Tests and documentation are provided throughout. [0] https://patchwork.libcamera.org/project/libcamera/list/?series=5245 [1] https://patchwork.libcamera.org/patch/23645/#34626 Running the tests directly shows the following output (all passing) Q1.7(-1 .. 0.992188) Min: [0x80:-1] -- Max: [0x7f:0.992188] Step:0.0078125 Checking -2 == [0x80:-1] Checking -1 == [0x80:-1] Checking -0.992 == [0x81:-0.992188] Checking -0.006 == [0xff:-0.0078125] Checking 0 == [0x00:0] Checking 0.008 == [0x01:0.0078125] Checking 0.992 == [0x7f:0.992188] Checking 2 == [0x7f:0.992188] UQ1.7(0 .. 1.99219) Min: [0x00:0] -- Max: [0xff:1.99219] Step:0.0078125 Checking -1 == [0x00:0] Checking 0 == [0x00:0] Checking 1 == [0x80:1] Checking 1.992 == [0xff:1.99219] Checking 2 == [0xff:1.99219] Q4.7(-8 .. 7.99219) Min: [0x0400:-8] -- Max: [0x03ff:7.99219] Step:0.0078125 Checking -8 == [0x0400:-8] Checking -0.008 == [0x07ff:-0.0078125] Checking 0 == [0x0000:0] Checking 0.008 == [0x0001:0.0078125] Checking 7.992 == [0x03ff:7.99219] Checking 0.2 == [0x001a:0.203125] Checking -0.2 == [0x07e6:-0.203125] Checking -0.8 == [0x079a:-0.796875] Checking -0.4 == [0x07cd:-0.398438] Checking -1.4 == [0x074d:-1.39844] UQ4.8(0 .. 15.9961) Min: [0x0000:0] -- Max: [0x0fff:15.9961] Step:0.00390625 Checking 0 == [0x0000:0] Checking 16 == [0x0fff:15.9961] Q5.4(-16 .. 15.9375) Min: [0x0100:-16] -- Max: [0x00ff:15.9375] Step:0.0625 Checking -16 == [0x0100:-16] Checking 15.94 == [0x00ff:15.9375] UQ5.8(0 .. 31.9961) Min: [0x0000:0] -- Max: [0x1fff:31.9961] Step:0.00390625 Checking 0 == [0x0000:0] Checking 32 == [0x1fff:31.9961] Q12.4(-2048 .. 2047.94) Min: [0x8000:-2048] -- Max: [0x7fff:2047.94] Step:0.0625 Checking 0 == [0x0000:0] Checking 7.5 == [0x0078:7.5] UQ12.4(0 .. 4095.94) Min: [0x0000:0] -- Max: [0xffff:4095.94] Step:0.0625 Checking 0 == [0x0000:0] Checking 7.5 == [0x0078:7.5] Q4.20(-8 .. 8) Min: [0x00800000:-8] -- Max: [0x007fffff:8] Step:9.53674e-07 Checking -9 == [0x00800000:-8] Checking -8 == [0x00800000:-8] Checking 8 == [0x007fffff:8] Checking 9 == [0x007fffff:8] UQ4.20(0 .. 16) Min: [0x00000000:0] -- Max: [0x00ffffff:16] Step:9.53674e-07 Checking -1 == [0x00000000:0] Checking 0 == [0x00000000:0] Checking 16 == [0x00ffffff:16] Checking 20 == [0x00ffffff:16] Testing sign extension of quantized values when cast to larger registers Checking [0x20:-2] == 0x20 Checking [0x80:-8] == 0x80 Checking [0x80:-8] == 0x0080 Checking [0x8000:-128] == 0x8000 Checking [0x8000:-128] == 0x00008000 Signed-off-by: Kieran Bingham --- Kieran Bingham (14): ipa: libipa: Provide a Quantized data type support test: libipa: Add tests for Quantized types ipa: libipa: fixedpoint: Fix unsigned usage ipa: libipa: Provide fixed point quantized traits test: libipa: Provide FixedPoint Quantized tests ipa: rkisp1: cproc: Convert to use Quantized types ipa: rkisp1: cproc: Report metadata ipa: rkisp1: cproc: Provide a Hue control ipa: rkisp1: ccm: Use Q<4, 7> format directly ipa: mali-c55: Reduce AWB calculations to float precision ipa: mali-c55: Convert AWB to UQ<4, 8> usage ipa: mali-c55: agc: Quantise the ISP Digital Gain test: libipa: Remove legacy fixed point conversion test ipa: libipa: fixedpoint: Move float conversion inline van Veen, Stephan (1): libcamera: controls: Define a new core Hue control src/ipa/libipa/fixedpoint.cpp | 108 +++++++++++++--- src/ipa/libipa/fixedpoint.h | 120 +++++++++++------ src/ipa/libipa/meson.build | 2 + src/ipa/libipa/quantized.cpp | 135 +++++++++++++++++++ src/ipa/libipa/quantized.h | 75 +++++++++++ src/ipa/mali-c55/algorithms/agc.cpp | 18 +-- src/ipa/mali-c55/algorithms/awb.cpp | 44 +++---- src/ipa/mali-c55/ipa_context.h | 16 ++- src/ipa/rkisp1/algorithms/ccm.cpp | 3 +- src/ipa/rkisp1/algorithms/cproc.cpp | 68 +++++++--- src/ipa/rkisp1/algorithms/cproc.h | 4 + src/ipa/rkisp1/ipa_context.h | 26 ++-- src/libcamera/control_ids_core.yaml | 15 +++ test/ipa/libipa/fixedpoint.cpp | 252 ++++++++++++++++++++++++++++-------- test/ipa/libipa/meson.build | 1 + test/ipa/libipa/quantized.cpp | 148 +++++++++++++++++++++ 16 files changed, 859 insertions(+), 176 deletions(-) --- base-commit: 1dcf9957a47fb54fce4fbae9daec0b587e52562e change-id: 20260210-kbingham-quantizers-9dd50aff6b5f Best regards,