Patch Detail
Show a patch.
GET /api/1.1/patches/24410/?format=api
{ "id": 24410, "url": "https://patchwork.libcamera.org/api/1.1/patches/24410/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24410/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20250919094041.183031-2-stefan.klug@ideasonboard.com>", "date": "2025-09-19T09:40:16", "name": "[v5,01/19] ipa: rkisp1: Add basic compression algorithm", "commit_ref": "b57ad23eb58d8c4570903303e0c195bdddcaf932", "pull_url": null, "state": "accepted", "archived": false, "hash": "b2516d4125d5c765deb84c4fd0df773a0f95e311", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24410/mbox/", "series": [ { "id": 5450, "url": "https://patchwork.libcamera.org/api/1.1/series/5450/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5450", "date": "2025-09-19T09:40:15", "name": "Implement WDR algorithm", "version": 5, "mbox": "https://patchwork.libcamera.org/series/5450/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24410/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24410/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 DD462C328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 19 Sep 2025 09:41:00 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 499036B599;\n\tFri, 19 Sep 2025 11:41:00 +0200 (CEST)", "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 1CDA669369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Sep 2025 11:40:57 +0200 (CEST)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:4d54:eab8:98ca:163b])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 85AD27E4;\n\tFri, 19 Sep 2025 11:39:36 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QAutSTn7\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1758274776;\n\tbh=oQcdMvtUb+EZcHrp/lYfdkzvy04kyfc66qUfF29BOKU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=QAutSTn7ZAAssbzeditdOANRGG7o5Ecnf2ySofywU1PbFUOdJh67yZBNTgzoSXmYN\n\tFHk4qUbp8ZwKxnqz+OIx071swrGMZ8gBAd6g1ltzug+2ycSJWglAATk4S83bWc3dLm\n\t3qlAZA5NLGXL0c+v+QG7SGqXfMFg5EUrkrspUGWM=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[PATCH v5 01/19] ipa: rkisp1: Add basic compression algorithm", "Date": "Fri, 19 Sep 2025 11:40:16 +0200", "Message-ID": "<20250919094041.183031-2-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.48.1", "In-Reply-To": "<20250919094041.183031-1-stefan.klug@ideasonboard.com>", "References": "<20250919094041.183031-1-stefan.klug@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "The i.MX8 M Plus has a compression curve inside the compand block. This\ncurve is necessary to process HDR stitched data and is useful for other\naspects like applying a digital gain to the incoming sensor data.\n\nAdd a basic algorithm for the compression curve. This algorithm has a\nhardcoded input width of 20bit and output width of 12bit which matches\nthe imx8mp pipeline. Only a static gain is supported in this version.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\n\nChanges in v5:\n- Removed unnecessary include\n- Added check for compress.supported in prepare()\n- Collected tag\n\nChanges in v4:\n- Moved activeState.compress.supported to\n configuration.compress.supported\n- Added documentation\n- Fixed typo in documentation\n- Replaced constant with RKISP1_CIF_ISP_COMPAND_NUM_POINTS\n\nChanges in v3:\n- Removed unused member\n- Fixed comment referencing copy-paste source\n- Ensure activeState.compress.supported stays false if unsupported\n---\n src/ipa/rkisp1/algorithms/compress.cpp | 103 +++++++++++++++++++++++++\n src/ipa/rkisp1/algorithms/compress.h | 30 +++++++\n src/ipa/rkisp1/algorithms/meson.build | 1 +\n src/ipa/rkisp1/ipa_context.cpp | 19 +++++\n src/ipa/rkisp1/ipa_context.h | 9 +++\n 5 files changed, 162 insertions(+)\n create mode 100644 src/ipa/rkisp1/algorithms/compress.cpp\n create mode 100644 src/ipa/rkisp1/algorithms/compress.h", "diff": "diff --git a/src/ipa/rkisp1/algorithms/compress.cpp b/src/ipa/rkisp1/algorithms/compress.cpp\nnew file mode 100644\nindex 000000000000..6445cd14bae3\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/compress.cpp\n@@ -0,0 +1,103 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2025, Ideas On Board\n+ *\n+ * RkISP1 Compression curve\n+ */\n+#include \"compress.h\"\n+\n+#include <linux/videodev2.h>\n+\n+#include <libcamera/base/log.h>\n+#include <libcamera/base/utils.h>\n+\n+#include \"linux/rkisp1-config.h\"\n+\n+/**\n+ * \\file compress.h\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa::rkisp1::algorithms {\n+\n+/**\n+ * \\class Compress\n+ * \\brief RkISP1 Compress curve\n+ *\n+ * This algorithm implements support for the compression curve in the compand\n+ * block available in the i.MX8 M Plus\n+ *\n+ * In its current version it only supports a static gain. This is useful for\n+ * the agc algorithm to compensate for exposure/gain quantization effects.\n+ *\n+ * This algorithm doesn't have any configuration options. It needs to be\n+ * configured per frame by other algorithms.\n+ *\n+ * Other algorithms can check configuration.compress.supported to see if\n+ * compression is available. If it is available they can configure it per frame\n+ * using frameContext.compress.enable and frameContext.compress.gain.\n+ */\n+\n+LOG_DEFINE_CATEGORY(RkISP1Compress)\n+\n+constexpr static int kRkISP1CompressInBits = 20;\n+constexpr static int kRkISP1CompressOutBits = 12;\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::configure\n+ */\n+int Compress::configure(IPAContext &context,\n+\t\t\t[[maybe_unused]] const IPACameraSensorInfo &configInfo)\n+{\n+\tif (context.configuration.paramFormat != V4L2_META_FMT_RK_ISP1_EXT_PARAMS ||\n+\t !context.hw->compand) {\n+\t\tLOG(RkISP1Compress, Warning)\n+\t\t\t<< \"Compression is not supported by the hardware or kernel.\";\n+\t\treturn 0;\n+\t}\n+\n+\tcontext.configuration.compress.supported = true;\n+\treturn 0;\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void Compress::prepare([[maybe_unused]] IPAContext &context,\n+\t\t [[maybe_unused]] const uint32_t frame,\n+\t\t IPAFrameContext &frameContext,\n+\t\t RkISP1Params *params)\n+{\n+\tif (!context.configuration.compress.supported)\n+\t\treturn;\n+\n+\tauto comp = params->block<BlockType::CompandCompress>();\n+\tcomp.setEnabled(frameContext.compress.enable);\n+\n+\tif (!frameContext.compress.enable)\n+\t\treturn;\n+\n+\tint xmax = (1 << kRkISP1CompressInBits);\n+\tint ymax = (1 << kRkISP1CompressOutBits);\n+\tint inLogStep = std::log2(xmax / RKISP1_CIF_ISP_COMPAND_NUM_POINTS);\n+\n+\tfor (unsigned int i = 0; i < RKISP1_CIF_ISP_COMPAND_NUM_POINTS; i++) {\n+\t\tdouble x = (i + 1) * (1.0 / RKISP1_CIF_ISP_COMPAND_NUM_POINTS);\n+\t\tdouble y = x * frameContext.compress.gain;\n+\n+\t\tcomp->px[i] = inLogStep;\n+\t\tcomp->x[i] = std::min<int>(x * xmax, xmax - 1);\n+\t\tcomp->y[i] = std::min<int>(y * ymax, ymax - 1);\n+\t}\n+\n+\tLOG(RkISP1Compress, Debug) << \"Compression: \" << kRkISP1CompressInBits\n+\t\t\t\t << \" bits to \" << kRkISP1CompressOutBits\n+\t\t\t\t << \" bits gain: \" << frameContext.compress.gain;\n+}\n+\n+REGISTER_IPA_ALGORITHM(Compress, \"Compress\")\n+\n+} /* namespace ipa::rkisp1::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/compress.h b/src/ipa/rkisp1/algorithms/compress.h\nnew file mode 100644\nindex 000000000000..87797b8ebcc5\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/compress.h\n@@ -0,0 +1,30 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2025, Ideas On Board\n+ *\n+ * RkISP1 Compression curve\n+ */\n+\n+#pragma once\n+\n+#include \"algorithm.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::rkisp1::algorithms {\n+\n+class Compress : public Algorithm\n+{\n+public:\n+\tCompress() = default;\n+\t~Compress() = default;\n+\n+\tint configure(IPAContext &context,\n+\t\t const IPACameraSensorInfo &configInfo) override;\n+\tvoid prepare(IPAContext &context, const uint32_t frame,\n+\t\t IPAFrameContext &frameContext,\n+\t\t RkISP1Params *params) override;\n+};\n+\n+} /* namespace ipa::rkisp1::algorithms */\n+} /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build\nindex c66b0b70b82f..2e42a80cf99d 100644\n--- a/src/ipa/rkisp1/algorithms/meson.build\n+++ b/src/ipa/rkisp1/algorithms/meson.build\n@@ -5,6 +5,7 @@ rkisp1_ipa_algorithms = files([\n 'awb.cpp',\n 'blc.cpp',\n 'ccm.cpp',\n+ 'compress.cpp',\n 'cproc.cpp',\n 'dpcc.cpp',\n 'dpf.cpp',\ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex 6509610573c0..15cb0afe9fe8 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -66,6 +66,14 @@ namespace libcamera::ipa::rkisp1 {\n * operates in manual or automatic mode.\n */\n \n+/**\n+ * \\var IPASessionConfiguration::compress\n+ * \\brief Compress parameters configuration of the IPA\n+ *\n+ * \\var IPASessionConfiguration::agc.supported\n+ * \\brief true if compression is supported and the algorithm is loaded\n+ */\n+\n /**\n * \\var IPASessionConfiguration::lsc\n * \\brief Lens Shading Correction configuration of the IPA\n@@ -377,6 +385,17 @@ namespace libcamera::ipa::rkisp1 {\n * \\brief Colour Correction Matrix\n */\n \n+/**\n+ * \\var IPAFrameContext::compress\n+ * \\brief Compress parameters for this frame\n+ *\n+ * \\struct IPAFrameContext::compress.enable\n+ * \\brief True if compression is enabled\n+ *\n+ * \\var IPAFrameContext::compress.gain\n+ * \\brief The gain applied with the compression curve\n+ */\n+\n /**\n * \\var IPAFrameContext::cproc\n * \\brief Color Processing parameters for this frame\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex 7ccc7b501aff..a723c79b04d9 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -49,6 +49,10 @@ struct IPASessionConfiguration {\n \t\tbool enabled;\n \t} awb;\n \n+\tstruct {\n+\t\tbool supported;\n+\t} compress;\n+\n \tstruct {\n \t\tbool enabled;\n \t} lsc;\n@@ -158,6 +162,11 @@ struct IPAFrameContext : public FrameContext {\n \t\tbool update;\n \t} cproc;\n \n+\tstruct {\n+\t\tbool enable;\n+\t\tdouble gain;\n+\t} compress;\n+\n \tstruct {\n \t\tbool denoise;\n \t\tbool update;\n", "prefixes": [ "v5", "01/19" ] }