Patch Detail
Show a patch.
GET /api/patches/26203/?format=api
{ "id": 26203, "url": "https://patchwork.libcamera.org/api/patches/26203/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26203/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20260219-kbingham-quantizers-v8-6-2b6ff68ead26@ideasonboard.com>", "date": "2026-02-19T15:05:07", "name": "[v8,06/15] ipa: rkisp1: cproc: Convert to use Quantized types", "commit_ref": "9d1b2b3ba8fec72374818da107d9f047d2bde02c", "pull_url": null, "state": "accepted", "archived": false, "hash": "1561c061b0044336591341edd34b284585c66632", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26203/mbox/", "series": [ { "id": 5802, "url": "https://patchwork.libcamera.org/api/series/5802/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5802", "date": "2026-02-19T15:05:01", "name": "libipa: Introduce a Quantized type", "version": 8, "mbox": "https://patchwork.libcamera.org/series/5802/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26203/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26203/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 973F3C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Feb 2026 15:05:24 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E028462267;\n\tThu, 19 Feb 2026 16:05:17 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 23BCA62256\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Feb 2026 16:05:10 +0100 (CET)", "from ping.linuxembedded.co.uk\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EB7ED19A8;\n\tThu, 19 Feb 2026 16:04:16 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"u6a51fek\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1771513457;\n\tbh=CRMX1wVhgL2atyvM+zrnGPqIHbnsdykYtN2tLS62HGk=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=u6a51fekZF+7CxMceebuU3UtNjbHDH0Q6y4aRZ08YfQUI25zvKs4V7H9k7DUXqG/p\n\tV444attwYSSeKjhuxYfPpSsKhWHs5teCPo0iagi1NdE9yLl7LjFEyi+1VoIIyUFqqR\n\tJzILJ5FmObZbtXGXgFvRHa8zHcWT9QMqgxcOS0d8=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Date": "Thu, 19 Feb 2026 15:05:07 +0000", "Subject": "[PATCH v8 06/15] ipa: rkisp1: cproc: Convert to use Quantized types", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260219-kbingham-quantizers-v8-6-2b6ff68ead26@ideasonboard.com>", "References": "<20260219-kbingham-quantizers-v8-0-2b6ff68ead26@ideasonboard.com>", "In-Reply-To": "<20260219-kbingham-quantizers-v8-0-2b6ff68ead26@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>, \n\tIsaac Scott <isaac.scott@ideasonboard.com>, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>, \n\tPaul Elder <paul.elder@ideasonboard.com>", "X-Mailer": "b4 0.14.3", "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1771513507; l=4735;\n\ti=kieran.bingham@ideasonboard.com; s=20260207;\n\th=from:subject:message-id; \n\tbh=CRMX1wVhgL2atyvM+zrnGPqIHbnsdykYtN2tLS62HGk=;\n\tb=CQHZqNSNahlA7gKqSg2jsUVzMqsRcinKndS5uBuZDtH4dGy2IM+VaXn19/GtiEgM29/9i0Vay\n\tpAQEVKpEYCBCACvIKsNRCfWKlPAgv8i8ptFN8z5nU+XHz8EcvySMduT", "X-Developer-Key": "i=kieran.bingham@ideasonboard.com; a=ed25519;\n\tpk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY=", "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": "Convert the Brightness, Contrast and Saturation helper functions to a\nQuantizer type to support maintaining the data.\n\nWhile modifying the include blocks of the ipa_context.h, also fix the\ninclude style for libipa components.\n\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/cproc.cpp | 28 +++++++++-------------------\n src/ipa/rkisp1/ipa_context.h | 23 +++++++++++++++--------\n 2 files changed, 24 insertions(+), 27 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp\nindex d1fff6990d37..4374c08c2a4f 100644\n--- a/src/ipa/rkisp1/algorithms/cproc.cpp\n+++ b/src/ipa/rkisp1/algorithms/cproc.cpp\n@@ -39,16 +39,6 @@ constexpr float kDefaultBrightness = 0.0f;\n constexpr float kDefaultContrast = 1.0f;\n constexpr float kDefaultSaturation = 1.0f;\n \n-int convertBrightness(const float v)\n-{\n-\treturn std::clamp<int>(std::lround(v * 128), -128, 127);\n-}\n-\n-int convertContrastOrSaturation(const float v)\n-{\n-\treturn std::clamp<int>(std::lround(v * 128), 0, 255);\n-}\n-\n } /* namespace */\n \n /**\n@@ -74,9 +64,9 @@ int ColorProcessing::configure(IPAContext &context,\n {\n \tauto &cproc = context.activeState.cproc;\n \n-\tcproc.brightness = convertBrightness(kDefaultBrightness);\n-\tcproc.contrast = convertContrastOrSaturation(kDefaultContrast);\n-\tcproc.saturation = convertContrastOrSaturation(kDefaultSaturation);\n+\tcproc.brightness = BrightnessQ(kDefaultBrightness);\n+\tcproc.contrast = ContrastQ(kDefaultContrast);\n+\tcproc.saturation = SaturationQ(kDefaultSaturation);\n \n \treturn 0;\n }\n@@ -97,7 +87,7 @@ void ColorProcessing::queueRequest(IPAContext &context,\n \n \tconst auto &brightness = controls.get(controls::Brightness);\n \tif (brightness) {\n-\t\tint value = convertBrightness(*brightness);\n+\t\tBrightnessQ value = *brightness;\n \t\tif (cproc.brightness != value) {\n \t\t\tcproc.brightness = value;\n \t\t\tupdate = true;\n@@ -108,7 +98,7 @@ void ColorProcessing::queueRequest(IPAContext &context,\n \n \tconst auto &contrast = controls.get(controls::Contrast);\n \tif (contrast) {\n-\t\tint value = convertContrastOrSaturation(*contrast);\n+\t\tContrastQ value = *contrast;\n \t\tif (cproc.contrast != value) {\n \t\t\tcproc.contrast = value;\n \t\t\tupdate = true;\n@@ -119,7 +109,7 @@ void ColorProcessing::queueRequest(IPAContext &context,\n \n \tconst auto saturation = controls.get(controls::Saturation);\n \tif (saturation) {\n-\t\tint value = convertContrastOrSaturation(*saturation);\n+\t\tSaturationQ value = *saturation;\n \t\tif (cproc.saturation != value) {\n \t\t\tcproc.saturation = value;\n \t\t\tupdate = true;\n@@ -148,9 +138,9 @@ void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,\n \n \tauto config = params->block<BlockType::Cproc>();\n \tconfig.setEnabled(true);\n-\tconfig->brightness = frameContext.cproc.brightness;\n-\tconfig->contrast = frameContext.cproc.contrast;\n-\tconfig->sat = frameContext.cproc.saturation;\n+\tconfig->brightness = frameContext.cproc.brightness.quantized();\n+\tconfig->contrast = frameContext.cproc.contrast.quantized();\n+\tconfig->sat = frameContext.cproc.saturation.quantized();\n }\n \n REGISTER_IPA_ALGORITHM(ColorProcessing, \"ColorProcessing\")\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex fa748811be74..cca5e281c732 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -24,14 +24,20 @@\n #include \"libcamera/internal/matrix.h\"\n #include \"libcamera/internal/vector.h\"\n \n-#include <libipa/camera_sensor_helper.h>\n-#include <libipa/fc_queue.h>\n #include \"libipa/agc_mean_luminance.h\"\n+#include \"libipa/camera_sensor_helper.h\"\n+#include \"libipa/fc_queue.h\"\n+#include \"libipa/fixedpoint.h\"\n \n namespace libcamera {\n \n namespace ipa::rkisp1 {\n \n+/* Fixed point types used by CPROC */\n+using BrightnessQ = Q<1, 7>;\n+using ContrastQ = UQ<1, 7>;\n+using SaturationQ = UQ<1, 7>;\n+\n struct IPAHwSettings {\n \tunsigned int numAeCells;\n \tunsigned int numHistogramBins;\n@@ -111,9 +117,9 @@ struct IPAActiveState {\n \t} ccm;\n \n \tstruct {\n-\t\tint8_t brightness;\n-\t\tuint8_t contrast;\n-\t\tuint8_t saturation;\n+\t\tBrightnessQ brightness;\n+\t\tContrastQ contrast;\n+\t\tSaturationQ saturation;\n \t} cproc;\n \n \tstruct {\n@@ -173,9 +179,10 @@ struct IPAFrameContext : public FrameContext {\n \t} awb;\n \n \tstruct {\n-\t\tint8_t brightness;\n-\t\tuint8_t contrast;\n-\t\tuint8_t saturation;\n+\t\tBrightnessQ brightness;\n+\t\tContrastQ contrast;\n+\t\tSaturationQ saturation;\n+\n \t\tbool update;\n \t} cproc;\n \n", "prefixes": [ "v8", "06/15" ] }