Show a patch.

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

{
    "id": 23842,
    "url": "https://patchwork.libcamera.org/api/patches/23842/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23842/",
    "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": "<20250717125931.2848300-5-stefan.klug@ideasonboard.com>",
    "date": "2025-07-17T12:59:24",
    "name": "[v3,4/5] pipeline: rkisp1: Properly handle the bufferCount set in the stream configuration",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "3be7568650204a06f58a4a582aa8799985aac30d",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/23842/mbox/",
    "series": [
        {
            "id": 5294,
            "url": "https://patchwork.libcamera.org/api/series/5294/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5294",
            "date": "2025-07-17T12:59:20",
            "name": "rkisp1: Allow usage of more than 4 buffers",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/5294/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23842/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23842/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 8EF54C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Jul 2025 12:59:50 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 40BEA68F8D;\n\tThu, 17 Jul 2025 14:59:50 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6833C68F83\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Jul 2025 14:59:47 +0200 (CEST)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:7b93:8acd:d82d:248d])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 690F21FA4; \n\tThu, 17 Jul 2025 14:59:13 +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=\"AQM1X+yb\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1752757153;\n\tbh=cOJHLbFm28MpGeYPvx4YiwbaHud6V9ZzX9oVOBnr4ic=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=AQM1X+ybItgLgRZyzDi1sw2PdGZ3WqVtpFq3bxw5WFRo6EjNEjQ1xccH/iwElpFo1\n\tgYJrPlTI0vAANbui2kI3PtEmE0t159Ksh/k7kLH8xSI4YFC57PjpRj4UKwkNTMFGwz\n\t5ouA0DbnWBy9FJMNXjz1f/E4laDKnT9ydLA4jJ4A=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>, =?utf-8?q?Sven_P=C3=BCsche?=\n\t=?utf-8?q?l?= <s.pueschel@pengutronix.de>",
        "Subject": "[PATCH v3 4/5] pipeline: rkisp1: Properly handle the bufferCount set\n\tin the stream configuration",
        "Date": "Thu, 17 Jul 2025 14:59:24 +0200",
        "Message-ID": "<20250717125931.2848300-5-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.48.1",
        "In-Reply-To": "<20250717125931.2848300-1-stefan.klug@ideasonboard.com>",
        "References": "<20250717125931.2848300-1-stefan.klug@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "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 StreamConfiguration::bufferCount is reset to a hardcoded value of 4\nin RkISP1Path::validate(). Keep the minimum value of 4 but do not reset\nit, if it was set to a larger value.  This allows the user to set\nbufferCount to an arbitrary number of buffers which then can be\nallocated for example by the FrameBufferAllocator. If the bufferCount is\nset to a smaller value it gets reset to 4 again and the configuation is\nmarket as adjusted.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nTested-By: Sven Püschel<s.pueschel@pengutronix.de>\n\n---\n\nChanges in v3:\n- Introduced a new constant kRkISP1MinBufferCount\n- Ensure that bufferCount is at least 4 in validate\n- Use the stream bufferCount for the number of import buffers, so that\n  we don't issue cache flushes due to more buffers circulating than\nimported in V4L2\n\nChanges in v1:\n- Removed todo comment that was solved by this change\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      | 13 +++++++++++--\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp |  7 ++-----\n src/libcamera/pipeline/rkisp1/rkisp1_path.h   |  4 +---\n 3 files changed, 14 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 7954ea82fd0d..aee267a90f4b 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -164,6 +164,8 @@ namespace {\n  */\n static constexpr unsigned int kRkISP1MaxQueuedRequests = 4;\n \n+static constexpr unsigned int kRkISP1MinBufferCount = 4;\n+\n } // namespace\n \n class PipelineHandlerRkISP1 : public PipelineHandler\n@@ -607,6 +609,12 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n \t\t\t\treturn false;\n \t\t}\n \n+\t\tif (tryCfg.bufferCount < kRkISP1MinBufferCount) {\n+\t\t\ttryCfg.bufferCount = kRkISP1MinBufferCount;\n+\t\t\tif (expectedStatus == Valid)\n+\t\t\t\treturn false;\n+\t\t}\n+\n \t\tcfg = tryCfg;\n \t\tcfg.setStream(stream);\n \t\treturn true;\n@@ -796,6 +804,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,\n \t\t\treturn nullptr;\n \n \t\tcfg.colorSpace = colorSpace;\n+\t\tcfg.bufferCount = kRkISP1MinBufferCount;\n \t\tconfig->addConfiguration(cfg);\n \t}\n \n@@ -1129,14 +1138,14 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL\n \t}\n \n \tif (data->mainPath_->isEnabled()) {\n-\t\tret = mainPath_.start();\n+\t\tret = mainPath_.start(data->mainPathStream_.configuration().bufferCount);\n \t\tif (ret)\n \t\t\treturn ret;\n \t\tactions += [&]() { mainPath_.stop(); };\n \t}\n \n \tif (hasSelfPath_ && data->selfPath_->isEnabled()) {\n-\t\tret = selfPath_.start();\n+\t\tret = selfPath_.start(data->selfPathStream_.configuration().bufferCount);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex 64018dc5b2f4..8ea5500d4080 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -249,7 +249,6 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,\n \tStreamConfiguration cfg(formats);\n \tcfg.pixelFormat = format;\n \tcfg.size = streamSize;\n-\tcfg.bufferCount = RKISP1_BUFFER_COUNT;\n \n \treturn cfg;\n }\n@@ -383,7 +382,6 @@ RkISP1Path::validate(const CameraSensor *sensor,\n \n \tcfg->size.boundTo(maxResolution);\n \tcfg->size.expandTo(minResolution);\n-\tcfg->bufferCount = RKISP1_BUFFER_COUNT;\n \n \tV4L2DeviceFormat format;\n \tformat.fourcc = video_->toV4L2PixelFormat(cfg->pixelFormat);\n@@ -480,15 +478,14 @@ int RkISP1Path::configure(const StreamConfiguration &config,\n \treturn 0;\n }\n \n-int RkISP1Path::start()\n+int RkISP1Path::start(unsigned int bufferCount)\n {\n \tint ret;\n \n \tif (running_)\n \t\treturn -EBUSY;\n \n-\t/* \\todo Make buffer count user configurable. */\n-\tret = video_->importBuffers(RKISP1_BUFFER_COUNT);\n+\tret = video_->importBuffers(bufferCount);\n \tif (ret)\n \t\treturn ret;\n \ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\nindex 430181d371a7..0b60c499ac64 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n@@ -58,7 +58,7 @@ public:\n \t\treturn video_->exportBuffers(bufferCount, buffers);\n \t}\n \n-\tint start();\n+\tint start(unsigned int bufferCount);\n \tvoid stop();\n \n \tint queueBuffer(FrameBuffer *buffer) { return video_->queueBuffer(buffer); }\n@@ -69,8 +69,6 @@ private:\n \tvoid populateFormats();\n \tSize filterSensorResolution(const CameraSensor *sensor);\n \n-\tstatic constexpr unsigned int RKISP1_BUFFER_COUNT = 4;\n-\n \tconst char *name_;\n \tbool running_;\n \n",
    "prefixes": [
        "v3",
        "4/5"
    ]
}