Patch Detail
Show a patch.
GET /api/patches/26852/?format=api
{ "id": 26852, "url": "https://patchwork.libcamera.org/api/patches/26852/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26852/", "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": "<20260608150349.134371-11-mzamazal@redhat.com>", "date": "2026-06-08T15:03:39", "name": "[RFC,v4,10/17] libcamera: software_isp: Use multiple parameters buffers in IPA", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "cc9c83144bf83a74e675390b6f6000edac4f608c", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26852/mbox/", "series": [ { "id": 5982, "url": "https://patchwork.libcamera.org/api/series/5982/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5982", "date": "2026-06-08T15:03:29", "name": "Software ISP: Share params and stats buffers", "version": 4, "mbox": "https://patchwork.libcamera.org/series/5982/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26852/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26852/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 0108BC328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 8 Jun 2026 15:04:31 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 865AF61F0E;\n\tMon, 8 Jun 2026 17:04:30 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4BFBD61EF3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 8 Jun 2026 17:04:28 +0200 (CEST)", "from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-455-jZF5YDPBPUe0W8Nz6a5wrg-1;\n\tMon, 08 Jun 2026 11:04:22 -0400", "from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.111])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id BFFD81800590; Mon, 8 Jun 2026 15:04:21 +0000 (UTC)", "from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.48.51])\n\tby mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id C7B911800361; Mon, 8 Jun 2026 15:04:19 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"fnHZGv2a\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1780931067;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=682wowaOie8lHYf8tLjJbnf75N3CCILappnXvI/DGMs=;\n\tb=fnHZGv2aqvuQCpNrSBtlJayJS8luE6vywJTY/hSWBVooN/8Idss7PjQPEsKVpXVF0CH6HS\n\t+XZb4mlLrrDg+zzAQP9+wtMEyVUqX4SnnyTBG3BzFT3VUnqulBhPgcc7bYmS2qJmRhoifj\n\tCam8YycYp4ltwLXnksnxEBLWSWG0bYU=", "X-MC-Unique": "jZF5YDPBPUe0W8Nz6a5wrg-1", "X-Mimecast-MFC-AGG-ID": "jZF5YDPBPUe0W8Nz6a5wrg_1780931061", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>, Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>, =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?=\n\t<barnabas.pocze@ideasonboard.com>, johannes.goede@oss.qualcomm.com", "Subject": "[RFC PATCH v4 10/17] libcamera: software_isp: Use multiple\n\tparameters buffers in IPA", "Date": "Mon, 8 Jun 2026 17:03:39 +0200", "Message-ID": "<20260608150349.134371-11-mzamazal@redhat.com>", "In-Reply-To": "<20260608150349.134371-1-mzamazal@redhat.com>", "References": "<20260608150349.134371-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.111", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "SZNlQ7usiNXP1MDnLJTg8nvSLgdrDi_OpG7PvSNCPOg_1780931061", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "content-type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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": "Instead of the single parameters buffer file descriptor, pass the file\ndescriptors of all the parameters buffers to the IPA and let it use them\naccording to the passed buffer id.\n\nThis means:\n\n- The file descriptors of all the buffers must be passed to the IPA.\n\n- The IPA must store mappings of the buffer ids to the corresponding\n buffers.\n\n- The current buffer id is passed to/from the IPA.\n\nThe parameters buffers are still copied for debayering, this will be\naddressed in the next patch.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n include/libcamera/ipa/soft.mojom | 2 +-\n src/ipa/simple/soft_simple.cpp | 40 ++++++++++-----------\n src/libcamera/software_isp/software_isp.cpp | 10 ++++--\n 3 files changed, 28 insertions(+), 24 deletions(-)", "diff": "diff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom\nindex 18789d5de..f348f582d 100644\n--- a/include/libcamera/ipa/soft.mojom\n+++ b/include/libcamera/ipa/soft.mojom\n@@ -15,7 +15,7 @@ struct IPAConfigInfo {\n interface IPASoftInterface {\n \tinit(libcamera.IPASettings settings,\n \t libcamera.SharedFD fdStats,\n-\t libcamera.SharedFD fdParams,\n+\t map<uint32, libcamera.SharedFD> fdParams,\n \t libcamera.IPACameraSensorInfo sensorInfo,\n \t libcamera.ControlInfoMap sensorControls)\n \t\t=> (int32 ret, libcamera.ControlInfoMap ipaControls, bool ccmEnabled);\ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex 69bfef302..0212a3b52 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -53,7 +53,7 @@ public:\n \n \tint init(const IPASettings &settings,\n \t\t const SharedFD &fdStats,\n-\t\t const SharedFD &fdParams,\n+\t\t const std::map<uint32_t, SharedFD> &fdParams,\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n \t\t ControlInfoMap *ipaControls,\n@@ -75,7 +75,7 @@ protected:\n private:\n \tvoid updateExposure(double exposureMSV);\n \n-\tDebayerParams *params_;\n+\tstd::map<unsigned int, DebayerParams *> paramsBuffers_;\n \tSwIspStats *stats_;\n \tstd::unique_ptr<CameraSensorHelper> camHelper_;\n \tControlInfoMap sensorInfoMap_;\n@@ -88,13 +88,13 @@ IPASoftSimple::~IPASoftSimple()\n {\n \tif (stats_)\n \t\tmunmap(stats_, sizeof(SwIspStats));\n-\tif (params_)\n-\t\tmunmap(params_, sizeof(DebayerParams));\n+\tfor (auto &item : paramsBuffers_)\n+\t\tmunmap(item.second, sizeof(DebayerParams));\n }\n \n int IPASoftSimple::init(const IPASettings &settings,\n \t\t\tconst SharedFD &fdStats,\n-\t\t\tconst SharedFD &fdParams,\n+\t\t\tconst std::map<uint32_t, SharedFD> &fdParams,\n \t\t\tconst IPACameraSensorInfo &sensorInfo,\n \t\t\tconst ControlInfoMap &sensorControls,\n \t\t\tControlInfoMap *ipaControls,\n@@ -137,8 +137,6 @@ int IPASoftSimple::init(const IPASettings &settings,\n \t\treturn ret;\n \n \t*ccmEnabled = context_.ccmEnabled;\n-\n-\tparams_ = nullptr;\n \tstats_ = nullptr;\n \n \tif (!fdStats.isValid()) {\n@@ -146,25 +144,26 @@ int IPASoftSimple::init(const IPASettings &settings,\n \t\treturn -ENODEV;\n \t}\n \n-\tif (!fdParams.isValid()) {\n-\t\tLOG(IPASoft, Error) << \"Invalid Parameters handle\";\n-\t\treturn -ENODEV;\n-\t}\n+\tfor (auto &[bufferId, sharedFd] : fdParams) {\n+\t\tif (!sharedFd.isValid()) {\n+\t\t\tLOG(IPASoft, Error) << \"Invalid Parameters handle\";\n+\t\t\treturn -ENODEV;\n+\t\t}\n \n-\t{\n \t\tvoid *mem = mmap(nullptr, sizeof(DebayerParams), PROT_WRITE,\n-\t\t\t\t MAP_SHARED, fdParams.get(), 0);\n+\t\t\t\t MAP_SHARED, sharedFd.get(), 0);\n \t\tif (mem == MAP_FAILED) {\n \t\t\tLOG(IPASoft, Error) << \"Unable to map Parameters\";\n \t\t\treturn -errno;\n \t\t}\n \n-\t\tparams_ = static_cast<DebayerParams *>(mem);\n-\t\tparams_->blackLevel = { { 0.0, 0.0, 0.0 } };\n-\t\tparams_->gamma = 1.0 / algorithms::kDefaultGamma;\n-\t\tparams_->contrastExp = 1.0;\n-\t\tparams_->gains = { { 1.0, 1.0, 1.0 } };\n+\t\tDebayerParams *params = static_cast<DebayerParams *>(mem);\n+\t\tparams->blackLevel = { { 0.0, 0.0, 0.0 } };\n+\t\tparams->gamma = 1.0 / algorithms::kDefaultGamma;\n+\t\tparams->contrastExp = 1.0;\n+\t\tparams->gains = { { 1.0, 1.0, 1.0 } };\n \t\t/* combinedMatrix is reset for each frame. */\n+\t\tparamsBuffers_[bufferId] = params;\n \t}\n \n \t{\n@@ -290,9 +289,10 @@ void IPASoftSimple::computeParams(const uint32_t frame,\n \tcontext_.activeState.combinedMatrix = Matrix<float, 3, 3>::identity();\n \n \tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n+\tDebayerParams *params = paramsBuffers_.at(paramsBufferId);\n \tfor (const auto &algo : algorithms())\n-\t\talgo->prepare(context_, frame, frameContext, params_);\n-\tparams_->combinedMatrix = context_.activeState.combinedMatrix;\n+\t\talgo->prepare(context_, frame, frameContext, params);\n+\tparams->combinedMatrix = context_.activeState.combinedMatrix;\n \n \tparamsComputed.emit(paramsBufferId);\n }\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex 97b423434..7f3bfe812 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -16,6 +16,7 @@\n #include <unistd.h>\n \n #include <libcamera/base/log.h>\n+#include <libcamera/base/shared_fd.h>\n #include <libcamera/base/thread.h>\n #include <libcamera/base/utils.h>\n \n@@ -125,6 +126,9 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe,\n \tif (!debayer_)\n \t\tdebayer_ = std::make_unique<DebayerCpu>(std::move(stats), cm);\n \n+\tstd::map<uint32_t, SharedFD> fdParams;\n+\tfor (auto &[bufferId, item] : sharedParams_)\n+\t\tfdParams[bufferId] = item.fd();\n \tdebayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady);\n \tdebayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady);\n \tdebayer_->paramsBufferReady.connect(this, &SoftwareIsp::paramsBufferReady);\n@@ -153,7 +157,7 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe,\n \n \tret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() },\n \t\t\t debayer_->getStatsFD(),\n-\t\t\t sharedParams_.begin()->second.fd(),\n+\t\t\t fdParams,\n \t\t\t sensorInfo,\n \t\t\t sensor->controls(),\n \t\t\t ipaControls,\n@@ -445,9 +449,9 @@ int SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n \treturn 0;\n }\n \n-void SoftwareIsp::saveIspParams([[maybe_unused]] const uint32_t paramsBufferId)\n+void SoftwareIsp::saveIspParams(const uint32_t paramsBufferId)\n {\n-\tdebayerParams_ = *sharedParams_.begin()->second;\n+\tdebayerParams_ = *sharedParams_.at(paramsBufferId);\n }\n \n void SoftwareIsp::paramsBufferReady(const uint32_t paramsBufferId)\n", "prefixes": [ "RFC", "v4", "10/17" ] }