Patch Detail
Show a patch.
GET /api/patches/24549/?format=api
{ "id": 24549, "url": "https://patchwork.libcamera.org/api/patches/24549/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24549/", "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": "<20251002133523.293413-2-naush@raspberrypi.com>", "date": "2025-10-02T13:26:04", "name": "[v1,1/4] ipa: rpi: pisp: Add decompand support using PiSP hardware block", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "f9ab938c25cb65a0efd827195280fe97669add23", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24549/mbox/", "series": [ { "id": 5474, "url": "https://patchwork.libcamera.org/api/series/5474/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5474", "date": "2025-10-02T13:26:03", "name": "Raspberry Pi: Decompanding support", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5474/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24549/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24549/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 6438CC328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 2 Oct 2025 13:35:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B6B1E6B5F3;\n\tThu, 2 Oct 2025 15:35:33 +0200 (CEST)", "from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1559D6B5A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 2 Oct 2025 15:35:31 +0200 (CEST)", "by mail-wm1-x32d.google.com with SMTP id\n\t5b1f17b1804b1-46e509368caso1392925e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 02 Oct 2025 06:35:31 -0700 (PDT)", "from NAUSH-P-DELL.pitowers.org ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-46e6918bdebsm40396015e9.9.2025.10.02.06.35.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 02 Oct 2025 06:35:29 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"RRoSG21L\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1759412130; x=1760016930;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=IVoMSQ9NqKSYjvVxbeL+oHW0AnGWWAyEI8GVF0//jK4=;\n\tb=RRoSG21LX0whvvVzC1mDANWqmxen6YnFVx2cIL2dkZYV9o/h5/YvAz4Xu9ko9rvKVW\n\trVtjxcd4gkl4TqKx2nIM/MNrXqrXjitwvOEf4cs8QKom142vXF2SApF78JC35Nj/fEYz\n\tN2L8VZNXT+11Qk6SC80C+3O5XK9o5DZru6pc9b4wV9RNjyA67dw+5O7IKpBTWvrOorsW\n\tPUGCycZGujEWMQSlIUz/gujYokCLy/f4nHXZp4f92FTqB6X1aqkgui/re9rHSxAqbG+8\n\tryMkdwhSkkioJXGQs53/AniTpXRyFe4Q8QOMUeR/NIdmyJUYEHUEhRLCyLoGGIJHisr4\n\txCxg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1759412130; x=1760016930;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=IVoMSQ9NqKSYjvVxbeL+oHW0AnGWWAyEI8GVF0//jK4=;\n\tb=i4J+mHfn+ftxgWk5F0IR8B++pbVJQmQZsQwoHkzDrJ4Ofnsg/gSUrzcGhxvti/2xq8\n\t2po/+yLfTGKJSBbE+48ElFXlBwJveE+1DLwvXV0njWSJGaRW9wBIsjwrKy9yI68K28S4\n\tkyAokL+auQrDusOrMaCgidsKBkbVr3aP5s4Simr+AMBv9CUy+MdhZwJW5pFO9hIIZ633\n\t6QpXquYKgVNxzF64tJ4bJ5FqKnCbp9/FVpSaA/zFzrUnmdtSDDfCeJiXoDqWQUhuMOUP\n\tvwVe+myWBjpVNYq4PQuOqSgy0NXAc7SL4HbcvFcRSYRJee1+pnYK+RsY8MMYJ4Xkr1yP\n\tQlHA==", "X-Gm-Message-State": "AOJu0YzvSEfFu/LvUKLxqSrWeOgyn3IrgFeAxiZgqpk7e2Ucj/dCNJso\n\t3VzUvKJG+kzzq1TyFUoOtI6wP4JycswRP/O8nMzdISR4ygk7GOMPuI554bObRNQJZ30osXVJgmh\n\tg1HiD", "X-Gm-Gg": "ASbGnctQKuTqMDweSpPH8zr6yrSG6FDL9WUjGOxJC4PR49uq6HZovBaA4VVrOetRFVI\n\tu2VmbjxrhYY0vY9MvBw/dakpcFMrLd4AXE02m6jXuy0M+mh2LLYTXVHwaYL9zhwAbubF+swiuKm\n\tYLxHU+Nf32NReyFRbxHLLmJECiZGTnxHu1toSpyJgT0CYpB7japgkW0sfhkNLF+fAg4vt8Jfb/8\n\tCqSS3/zRtAADS5FJIuZoDKJSOE3m7nyCCErrNERLom0avbxFJXAZ5WNDYTd+U1VYAHF0qvIio4T\n\tnhWmEpJElaTXo28C/quUaAjOi8nyghv+WmI5UZ6szTl5FOHaZWvuKcOVk3CjNHLJ/n1DhnixPGb\n\tsftbp2yb/rWbPbyEDALJJmmoMa6p5r45JO7+LtKL4R5q8ygqUwPWYZ6v9JcIQMzoe/g==", "X-Google-Smtp-Source": "AGHT+IEirLTYWf1LNe1EuyRVEnD7RJ/VXbyO11sbdUCcv7VOTLLa7bfZDk1dQsoah1YWoWMHQOxd1g==", "X-Received": "by 2002:a05:600c:1d19:b0:46e:3c73:2f9d with SMTP id\n\t5b1f17b1804b1-46e612c9809mr32447265e9.6.1759412130276; \n\tThu, 02 Oct 2025 06:35:30 -0700 (PDT)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "David Plowman <david.plowman@raspberrypi.com>,\n\tNick Hollinghurst <nick.hollinghurst@raspberrypi.com>,\n\tSena Asotani <aso.fam429@gmail.com>,\n\tNaushir Patuck <naush@raspberrypi.com>", "Subject": "[PATCH v1 1/4] ipa: rpi: pisp: Add decompand support using PiSP\n\thardware block", "Date": "Thu, 2 Oct 2025 14:26:04 +0100", "Message-ID": "<20251002133523.293413-2-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20251002133523.293413-1-naush@raspberrypi.com>", "References": "<20251002133523.293413-1-naush@raspberrypi.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": "From: Sena Asotani <aso.fam429@gmail.com>\n\nThis patch integrates a new decompand algorithm that utilizes the PiSP\nFE hardware block available on Raspberry Pi 5. The implementation\nenables conversion of companded sensor data into linear format prior to\nISP processing.\n\nChanges include:\n- Implementation of decompand logic for controller and pipe interfaces\n- Enabling decompand block by \"rpi.decompand\" in tuning.json\n\nSigned-off-by: Sena Asotani <aso.fam429@gmail.com>\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/controller/decompand_status.h | 8 ++++\n src/ipa/rpi/controller/meson.build | 1 +\n src/ipa/rpi/controller/rpi/decompand.cpp | 58 +++++++++++++++++++++++\n src/ipa/rpi/controller/rpi/decompand.h | 31 ++++++++++++\n src/ipa/rpi/pisp/pisp.cpp | 40 ++++++++++++++++\n 5 files changed, 138 insertions(+)\n create mode 100644 src/ipa/rpi/controller/decompand_status.h\n create mode 100644 src/ipa/rpi/controller/rpi/decompand.cpp\n create mode 100644 src/ipa/rpi/controller/rpi/decompand.h", "diff": "diff --git a/src/ipa/rpi/controller/decompand_status.h b/src/ipa/rpi/controller/decompand_status.h\nnew file mode 100644\nindex 000000000000..2d9888dca4f3\n--- /dev/null\n+++ b/src/ipa/rpi/controller/decompand_status.h\n@@ -0,0 +1,8 @@\n+#pragma once\n+\n+#include \"libipa/pwl.h\"\n+\n+struct DecompandStatus {\n+\tuint32_t bitdepth;\n+\tlibcamera::ipa::Pwl decompandCurve;\n+};\ndiff --git a/src/ipa/rpi/controller/meson.build b/src/ipa/rpi/controller/meson.build\nindex 74b74888bbff..c13c48539d10 100644\n--- a/src/ipa/rpi/controller/meson.build\n+++ b/src/ipa/rpi/controller/meson.build\n@@ -14,6 +14,7 @@ rpi_ipa_controller_sources = files([\n 'rpi/cac.cpp',\n 'rpi/ccm.cpp',\n 'rpi/contrast.cpp',\n+ 'rpi/decompand.cpp',\n 'rpi/denoise.cpp',\n 'rpi/dpc.cpp',\n 'rpi/geq.cpp',\ndiff --git a/src/ipa/rpi/controller/rpi/decompand.cpp b/src/ipa/rpi/controller/rpi/decompand.cpp\nnew file mode 100644\nindex 000000000000..911b04bc0da0\n--- /dev/null\n+++ b/src/ipa/rpi/controller/rpi/decompand.cpp\n@@ -0,0 +1,58 @@\n+#include \"decompand.h\"\n+\n+#include <libcamera/base/log.h>\n+\n+#include \"../decompand_status.h\"\n+#include \"../histogram.h\"\n+\n+using namespace RPiController;\n+using namespace libcamera;\n+\n+LOG_DEFINE_CATEGORY(RPiDecompand)\n+\n+#define NAME \"rpi.decompand\"\n+\n+Decompand::Decompand(Controller *controller)\n+\t: Algorithm(controller)\n+{\n+}\n+\n+char const *Decompand::name() const\n+{\n+\treturn NAME;\n+}\n+\n+int Decompand::read(const libcamera::YamlObject ¶ms)\n+{\n+\tconfig_.bitdepth = params[\"bitdepth\"].get<uint32_t>(0);\n+\tconfig_.decompandCurve = params[\"decompand_curve\"].get<ipa::Pwl>(ipa::Pwl{});\n+\treturn config_.decompandCurve.empty() ? -EINVAL : 0;\n+}\n+\n+void Decompand::initialise()\n+{\n+}\n+\n+void Decompand::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n+\t\t\t [[maybe_unused]] Metadata *metadata)\n+{\n+\tmode_ = cameraMode;\n+}\n+\n+void Decompand::prepare(Metadata *imageMetadata)\n+{\n+\tDecompandStatus decompandStatus;\n+\n+\tif (config_.bitdepth == 0 || mode_.bitdepth == config_.bitdepth) {\n+\t\tdecompandStatus.decompandCurve = config_.decompandCurve;\n+\t\timageMetadata->set(\"decompand.status\", decompandStatus);\n+\t}\n+}\n+\n+/* Register algorithm with the system. */\n+static Algorithm *create(Controller *controller)\n+{\n+\treturn (Algorithm *)new Decompand(controller);\n+}\n+\n+static RegisterAlgorithm reg(NAME, &create);\ndiff --git a/src/ipa/rpi/controller/rpi/decompand.h b/src/ipa/rpi/controller/rpi/decompand.h\nnew file mode 100644\nindex 000000000000..5ef35946efa5\n--- /dev/null\n+++ b/src/ipa/rpi/controller/rpi/decompand.h\n@@ -0,0 +1,31 @@\n+#pragma once\n+\n+#include <libipa/pwl.h>\n+\n+#include \"../decompand_status.h\"\n+\n+#include \"algorithm.h\"\n+\n+namespace RPiController {\n+\n+struct DecompandConfig {\n+\tuint32_t bitdepth;\n+\tlibcamera::ipa::Pwl decompandCurve;\n+};\n+\n+class Decompand : public Algorithm\n+{\n+public:\n+\tDecompand(Controller *controller = NULL);\n+\tchar const *name() const override;\n+\tint read(const libcamera::YamlObject ¶ms) override;\n+\tvoid initialise() override;\n+\tvoid switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n+\tvoid prepare(Metadata *imageMetadata) override;\n+\n+private:\n+\tCameraMode mode_;\n+\tDecompandConfig config_;\n+};\n+\n+} /* namespace RPiController */\ndiff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp\nindex 829b91258522..e75c87df1924 100644\n--- a/src/ipa/rpi/pisp/pisp.cpp\n+++ b/src/ipa/rpi/pisp/pisp.cpp\n@@ -32,6 +32,7 @@\n #include \"controller/cac_status.h\"\n #include \"controller/ccm_status.h\"\n #include \"controller/contrast_status.h\"\n+#include \"controller/decompand_status.h\"\n #include \"controller/denoise_algorithm.h\"\n #include \"controller/denoise_status.h\"\n #include \"controller/dpc_status.h\"\n@@ -113,6 +114,25 @@ int generateLut(const ipa::Pwl &pwl, uint32_t *lut, std::size_t lutSize,\n \treturn 0;\n }\n \n+int generateDecompandLut(const ipa::Pwl &pwl, uint16_t *lut, std::size_t lutSize = 65)\n+{\n+\tif (pwl.empty())\n+\t\treturn -EINVAL;\n+\n+\tconstexpr int step = 1024;\n+\tfor (std::size_t i = 0; i < lutSize; ++i) {\n+\t\tint x = i * step;\n+\n+\t\tint y = pwl.eval(x);\n+\t\tif (y < 0)\n+\t\t\treturn -1;\n+\n+\t\tlut[i] = static_cast<uint16_t>(std::min(y, 65535));\n+\t}\n+\n+\treturn 0;\n+}\n+\n void packLscLut(uint32_t packed[NumLscVertexes][NumLscVertexes],\n \t\tdouble const rgb[3][NumLscVertexes][NumLscVertexes])\n {\n@@ -236,6 +256,7 @@ private:\n \tvoid applyLensShading(const AlscStatus *alscStatus,\n \t\t\t pisp_be_global_config &global);\n \tvoid applyDPC(const DpcStatus *dpcStatus, pisp_be_global_config &global);\n+\tvoid applyDecompand(const DecompandStatus *decompandStatus);\n \tvoid applySdn(const SdnStatus *sdnStatus, pisp_be_global_config &global);\n \tvoid applyTdn(const TdnStatus *tdnStatus, const DeviceStatus *deviceStatus,\n \t\t pisp_be_global_config &global);\n@@ -351,6 +372,11 @@ void IpaPiSP::platformPrepareIsp([[maybe_unused]] const PrepareParams ¶ms,\n \t\tif (noiseStatus)\n \t\t\tapplyFocusStats(noiseStatus);\n \n+\t\tDecompandStatus *decompandStatus =\n+\t\t\trpiMetadata.getLocked<DecompandStatus>(\"decompand.status\");\n+\t\tif (decompandStatus)\n+\t\t\tapplyDecompand(decompandStatus);\n+\n \t\tBlackLevelStatus *blackLevelStatus =\n \t\t\trpiMetadata.getLocked<BlackLevelStatus>(\"black_level.status\");\n \t\tif (blackLevelStatus)\n@@ -702,6 +728,20 @@ void IpaPiSP::applyDPC(const DpcStatus *dpcStatus, pisp_be_global_config &global\n \tbe_->SetDpc(dpc);\n }\n \n+void IpaPiSP::applyDecompand(const DecompandStatus *decompandStatus)\n+{\n+\tpisp_fe_global_config feGlobal;\n+\tpisp_fe_decompand_config decompand = {};\n+\n+\tfe_->GetGlobal(feGlobal);\n+\n+\tif (!generateDecompandLut(decompandStatus->decompandCurve, decompand.lut, PISP_FE_DECOMPAND_LUT_SIZE)) {\n+\t\tfe_->SetDecompand(decompand);\n+\t\tfeGlobal.enables |= PISP_FE_ENABLE_DECOMPAND;\n+\t\tfe_->SetGlobal(feGlobal);\n+\t}\n+}\n+\n void IpaPiSP::applySdn(const SdnStatus *sdnStatus, pisp_be_global_config &global)\n {\n \tpisp_be_sdn_config sdn = {};\n", "prefixes": [ "v1", "1/4" ] }