Show a patch.

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

{
    "id": 26369,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/26369/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26369/",
    "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": "<20260325151416.2114564-28-stefan.klug@ideasonboard.com>",
    "date": "2026-03-25T15:13:59",
    "name": "[v2,27/32] pipeline: rkisp1: Correctly handle params buffer for frame 0",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "4e208826c045ae5269fe39d860603c75befe7518",
    "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/26369/mbox/",
    "series": [
        {
            "id": 5849,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5849/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5849",
            "date": "2026-03-25T15:13:32",
            "name": "rkisp1: pipeline rework for PFC",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5849/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26369/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26369/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 0144FC32F9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Mar 2026 15:15:58 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A3D2362CD6;\n\tWed, 25 Mar 2026 16:15:58 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BAAC562CC8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Mar 2026 16:15:57 +0100 (CET)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:b16a:5ed9:4ada:a95a])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id B0D871ADE; \n\tWed, 25 Mar 2026 16:14:39 +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=\"eEhLazop\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1774451679;\n\tbh=L6I3QomOQk/0PnCjuQoct8dbyFwyDZCKEHWfkXWWUJo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=eEhLazopPUNP1pzA24CGstZDeN777YH5oqQuYU3wRgiMOVRSvuZWV/AnEXuYduhMw\n\tQ+j1ri+ItUaZTVlMOgMBHr0OJVcnGEdTShk4CMul64kxKiTJhCr+O15o5B1LmWaoML\n\tRsaSFGB+JgretuaXIoyxdqxS54dNzejGGynHa6Ec=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>",
        "Subject": "[PATCH v2 27/32] pipeline: rkisp1: Correctly handle params buffer\n\tfor frame 0",
        "Date": "Wed, 25 Mar 2026 16:13:59 +0100",
        "Message-ID": "<20260325151416.2114564-28-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.51.0",
        "In-Reply-To": "<20260325151416.2114564-1-stefan.klug@ideasonboard.com>",
        "References": "<20260325151416.2114564-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 parameters for frame 0 are only active on frame 0 if the\ncorresponding parameter buffer is queued before STREAMON is called on\nthe isp. Therefore the normal mechanics of calling ipa->computeParams()\ndo not work, as it gets called after the first request is queued and\ntherefore the isp is already started. To fix that, handle the parameter\nbuffer the same way the initial sensor controls are handled by passing\nit to the ipa->start() function and then queuing the params buffer\nbefore starting the isp.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\n\nChanges in v2:\n- Small cleanup\n- Fixed crash in raw case where a null buffer is passed on start\n- Collected tag\n---\n include/libcamera/ipa/rkisp1.mojom       |  5 ++-\n src/ipa/rkisp1/rkisp1.cpp                | 39 +++++++++++++-----------\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 19 ++++++++++--\n 3 files changed, 42 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom\nindex 4c29b53cd7f9..56c9fe8ab92a 100644\n--- a/include/libcamera/ipa/rkisp1.mojom\n+++ b/include/libcamera/ipa/rkisp1.mojom\n@@ -17,6 +17,7 @@ struct IPAConfigInfo {\n struct StartResult {\n \tlibcamera.ControlList controls;\n \tint32 code;\n+\tuint32 paramBufferBytesUsed;\n };\n \n interface IPARkISP1Interface {\n@@ -25,7 +26,9 @@ interface IPARkISP1Interface {\n \t     libcamera.IPACameraSensorInfo sensorInfo,\n \t     libcamera.ControlInfoMap sensorControls)\n \t\t=> (int32 ret, libcamera.ControlInfoMap ipaControls);\n-\tstart(libcamera.ControlList controls) => (StartResult result);\n+\tstart(libcamera.ControlList controls,\n+\t      uint32 paramBufferId)\n+\t\t=> (StartResult result);\n \tstop();\n \n \tconfigure(IPAConfigInfo configInfo,\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex d0c753976dd4..8a657a170b0d 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -57,7 +57,8 @@ public:\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n \t\t ControlInfoMap *ipaControls) override;\n-\tvoid start(const ControlList &controls, StartResult *result) override;\n+\tvoid start(const ControlList &controls, const uint32_t paramBufferId,\n+\t\t   StartResult *result) override;\n \tvoid stop() override;\n \n \tint configure(const IPAConfigInfo &ipaConfig,\n@@ -77,6 +78,8 @@ protected:\n \tstd::string logPrefix() const override;\n \n private:\n+\tuint32_t computeParamsInternal(IPAFrameContext &frameContext, const uint32_t bufferId);\n+\n \tvoid updateControls(const IPACameraSensorInfo &sensorInfo,\n \t\t\t    const ControlInfoMap &sensorControls,\n \t\t\t    ControlInfoMap *ipaControls);\n@@ -219,9 +222,11 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n \treturn 0;\n }\n \n-void IPARkISP1::start(const ControlList &controls, StartResult *result)\n+void IPARkISP1::start(const ControlList &controls, const uint32_t paramBufferId,\n+\t\t      StartResult *result)\n {\n \tIPAFrameContext &frameContext = context_.frameContexts.getOrInitContext(0, controls);\n+\tresult->paramBufferBytesUsed = computeParamsInternal(frameContext, paramBufferId);\n \tresult->controls = getSensorControls(frameContext);\n \tresult->code = 0;\n }\n@@ -353,32 +358,30 @@ void IPARkISP1::initializeFrameContext(IPAFrameContext &fc, const ControlList &c\n \t}\n }\n \n-void IPARkISP1::computeParams(const uint32_t frame, const uint32_t bufferId)\n+uint32_t IPARkISP1::computeParamsInternal(IPAFrameContext &frameContext, const uint32_t bufferId)\n {\n-\tIPAFrameContext &frameContext = context_.frameContexts.getOrInitContext(frame);\n-\n-\t/*\n-\t * \\todo: This needs discussion. In raw mode, computeParams is\n-\t * called without a params buffer, to trigger the setSensorControls\n-\t * signal. Currently our algorithms don't support prepare calls with\n-\t * a nullptr. Do we need that or can we safely skip it?\n-\t */\n-\tif (bufferId == 0) {\n-\t\tControlList ctrls = getSensorControls(frameContext);\n-\t\tsetSensorControls.emit(frame, ctrls);\n-\t\treturn;\n-\t}\n+\tif (bufferId == 0)\n+\t\treturn 0;\n \n \tRkISP1Params params(context_.configuration.paramFormat,\n \t\t\t    mappedBuffers_.at(bufferId).planes()[0]);\n \n \tfor (const auto &algo : algorithms())\n-\t\talgo->prepare(context_, frame, frameContext, &params);\n+\t\talgo->prepare(context_, frameContext.frame(), frameContext, &params);\n \n+\treturn params.bytesused();\n+}\n+\n+void IPARkISP1::computeParams(const uint32_t frame, const uint32_t bufferId)\n+{\n+\tIPAFrameContext &frameContext = context_.frameContexts.getOrInitContext(frame);\n+\n+\tuint32_t size = computeParamsInternal(frameContext, bufferId);\n \tControlList ctrls = getSensorControls(frameContext);\n \tsetSensorControls.emit(frame, ctrls);\n \n-\tparamsComputed.emit(frame, params.bytesused());\n+\tif (bufferId != 0)\n+\t\tparamsComputed.emit(frame, size);\n }\n \n void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId,\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 46c157526ea1..c2af5ef8897f 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -105,8 +105,8 @@ public:\n \tbool canUseDewarper_;\n \tbool usesDewarper_;\n \n-private:\n \tvoid paramsComputed(unsigned int frame, unsigned int bytesused);\n+private:\n \tvoid setSensorControls(unsigned int frame,\n \t\t\t       const ControlList &sensorControls);\n \n@@ -1202,13 +1202,28 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL\n \tnextStatsToProcess_ = 0;\n \tdata->frame_ = 0;\n \n+\tuint32_t paramBufferId = 0;\n+\tFrameBuffer *paramBuffer = nullptr;\n+\tif (!isRaw_) {\n+\t\tparamBuffer = availableParamBuffers_.front();\n+\t\tparamBufferId = paramBuffer->cookie();\n+\t}\n+\n \tipa::rkisp1::StartResult res;\n-\tdata->ipa_->start(ctrls, &res);\n+\tdata->ipa_->start(ctrls, paramBufferId, &res);\n \tif (res.code) {\n \t\tLOG(RkISP1, Error)\n \t\t\t<< \"Failed to start IPA \" << camera->id();\n \t\treturn ret;\n \t}\n+\n+\tif (paramBuffer) {\n+\t\tavailableParamBuffers_.pop();\n+\t\tcomputingParamBuffers_.push({ paramBuffer, nextParamsSequence_++ });\n+\t\tparamsSyncHelper_.pushCorrection(0);\n+\t\tdata->paramsComputed(0, res.paramBufferBytesUsed);\n+\t}\n+\n \tactions += [&]() { data->ipa_->stop(); };\n \tdata->sensor_->setControls(&res.controls);\n \tdata->delayedCtrls_->reset();\n",
    "prefixes": [
        "v2",
        "27/32"
    ]
}