Show a patch.

GET /api/1.1/patches/26176/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 26176,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/26176/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26176/",
    "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": "<20260216203034.27558-8-mzamazal@redhat.com>",
    "date": "2026-02-16T20:30:26",
    "name": "[RFC,v2,07/14] libcamera: software_isp: Use multiple parameters buffers in IPA",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "fe16d3939ea46d25bd082e81e7c7e812ca89e9a5",
    "submitter": {
        "id": 177,
        "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api",
        "name": "Milan Zamazal",
        "email": "mzamazal@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26176/mbox/",
    "series": [
        {
            "id": 5795,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5795/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5795",
            "date": "2026-02-16T20:30:19",
            "name": "Software ISP: Share params and stats buffers",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5795/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26176/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26176/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 54EA6C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Feb 2026 20:30:59 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1F3296221A;\n\tMon, 16 Feb 2026 21:30:59 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 058656220C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Feb 2026 21:30:56 +0100 (CET)",
            "from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-346--S1uuduGNz662YgwhEmjsA-1;\n\tMon, 16 Feb 2026 15:30:54 -0500",
            "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.93])\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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS\n\tid AB80A1955D8F for <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Feb 2026 20:30:53 +0000 (UTC)",
            "from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.25])\n\tby mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 6E0651800464; Mon, 16 Feb 2026 20:30:52 +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=\"GwGKe/mF\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1771273855;\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=Ld0wUn/+nR/TQtrMxBgNUzu+VA8koimtcWOyHHwSsJU=;\n\tb=GwGKe/mFkHXryvMMQJTVFDEsOeMt5+ITEW4qqvLFgnA4JJI7svHaEC0zy9ehyDml/0dahy\n\tL7q61R58SYsanNzszriOnR1SEgtKmTBEGjp85e7x+5qa8KTX6PKox4Xz8aqMtWDB4fxvR3\n\t6IRv6W9cqAcDVFM0x54ZcMoiirav1ow=",
        "X-MC-Unique": "-S1uuduGNz662YgwhEmjsA-1",
        "X-Mimecast-MFC-AGG-ID": "-S1uuduGNz662YgwhEmjsA_1771273853",
        "From": "Milan Zamazal <mzamazal@redhat.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Milan Zamazal <mzamazal@redhat.com>",
        "Subject": "[RFC PATCH v2 07/14] libcamera: software_isp: Use multiple\n\tparameters buffers in IPA",
        "Date": "Mon, 16 Feb 2026 21:30:26 +0100",
        "Message-ID": "<20260216203034.27558-8-mzamazal@redhat.com>",
        "In-Reply-To": "<20260216203034.27558-1-mzamazal@redhat.com>",
        "References": "<20260216203034.27558-1-mzamazal@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-MFC-PROC-ID": "XRy0da1NKtwDu7XMRaLctr53x5hPOBLeLKwfXv_HemA_1771273853",
        "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              | 41 +++++++++++----------\n src/libcamera/software_isp/software_isp.cpp | 11 ++++--\n 3 files changed, 30 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom\nindex f37c1e747..4738a1b46 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     array<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 1e8b5334c..f212fabe3 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::vector<SharedFD> &fdParams,\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n \t\t ControlInfoMap *ipaControls,\n@@ -76,7 +76,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@@ -89,13 +89,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::vector<SharedFD> &fdParams,\n \t\t\tconst IPACameraSensorInfo &sensorInfo,\n \t\t\tconst ControlInfoMap &sensorControls,\n \t\t\tControlInfoMap *ipaControls,\n@@ -138,8 +138,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@@ -147,25 +145,27 @@ 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 &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\tASSERT(sharedFd.get() >= 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_[sharedFd.get()] = params;\n \t}\n \n \t{\n@@ -291,9 +291,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 (auto const &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 \tsetIspParams.emit(paramsBufferId);\n }\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex 02d1c4c12..2bc0d30b1 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -14,6 +14,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@@ -118,6 +119,9 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\n \tif (!debayer_)\n \t\tdebayer_ = std::make_unique<DebayerCpu>(std::move(stats), configuration);\n \n+\tstd::vector<SharedFD> fdParams;\n+\tfor (auto &item : sharedParams_)\n+\t\tfdParams.emplace_back(item.second.fd());\n \tdebayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady);\n \tdebayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady);\n \tdebayer_->releaseIspParams.connect(this, &SoftwareIsp::releaseIspParams);\n@@ -146,7 +150,7 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\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@@ -422,13 +426,14 @@ void SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *outpu\n \tconst uint32_t paramsBufferId = availableParams_.front();\n \tavailableParams_.pop();\n \tipa_->computeParams(frame, paramsBufferId);\n+\tdebayerParams_ = *sharedParams_.at(paramsBufferId);\n \tdebayer_->invokeMethod(&Debayer::process,\n \t\t\t       ConnectionTypeQueued, frame, paramsBufferId, input, output, debayerParams_);\n }\n \n-void SoftwareIsp::saveIspParams([[maybe_unused]] uint32_t paramsBufferId)\n+void SoftwareIsp::saveIspParams(uint32_t paramsBufferId)\n {\n-\tdebayerParams_ = *sharedParams_.begin()->second;\n+\tdebayerParams_ = *sharedParams_.at(paramsBufferId);\n }\n \n void SoftwareIsp::releaseIspParams(uint32_t paramsBufferId)\n",
    "prefixes": [
        "RFC",
        "v2",
        "07/14"
    ]
}