Show a patch.

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

{
    "id": 23744,
    "url": "https://patchwork.libcamera.org/api/patches/23744/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23744/",
    "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": "<20250707075400.9079-2-stefan.klug@ideasonboard.com>",
    "date": "2025-07-07T07:53:35",
    "name": "[v2,1/5] libcamera: pipeline_handler: Move waitingRequests_ into camera class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "40f06d5e154f2e42ef273a62cbd0895f893046ba",
    "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/23744/mbox/",
    "series": [
        {
            "id": 5272,
            "url": "https://patchwork.libcamera.org/api/series/5272/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5272",
            "date": "2025-07-07T07:53:34",
            "name": "rkisp1: Allow usage of more than 4 buffers",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5272/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23744/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23744/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 65E2AC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  7 Jul 2025 07:54:21 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0FFF968E7F;\n\tMon,  7 Jul 2025 09:54:20 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4904868E81\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Jul 2025 09:54:16 +0200 (CEST)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 078B9526;\n\tMon,  7 Jul 2025 09:53:48 +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=\"jVX+gAeb\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1751874829;\n\tbh=pyOXhjpFCrj4pGIMuD0VpZ7r6CxT8aZTU1KTUkQFM2o=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=jVX+gAebAdyR/MrOKqjgloc+yU23DbMhO4hHpI1aag+mxXza/sK3pJ+x6KNJF/lhe\n\tiRxKyoxQ/55baDs4KJBhHMgLOrGu/xHu2CR/rX5eQXjcCuhhvM4hQHPTMSeGkWhUUS\n\tW1mqNEXYtx/Ut9M4ophnd2Fb2NY6tzlOP24fP/cU=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tUmang Jain <uajain@igalia.com>",
        "Subject": "[PATCH v2 1/5] libcamera: pipeline_handler: Move waitingRequests_\n\tinto camera class",
        "Date": "Mon,  7 Jul 2025 09:53:35 +0200",
        "Message-ID": "<20250707075400.9079-2-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.48.1",
        "In-Reply-To": "<20250707075400.9079-1-stefan.klug@ideasonboard.com>",
        "References": "<20250707075400.9079-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 waiting requests of one camera should not be able to influence\nqueuing to another camera. Currently a request that is in the\nwaitingQUeue and waiting for preparation blocks all requests of other\ncameras even if they are already prepared. To fix that replace the\nsingle waitingRequests_ queue with one queue per camera.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Umang Jain <uajain@igalia.com>\n\n---\n\nChanges in v2:\n- Fixed capturing on lambda expression\n- Added documentation for waitingRequests_\n- Improved commit message\n\nChanges in v1:\n- Added camera param to doQueueRequests() which allows to remove a loop\n---\n include/libcamera/internal/camera.h           |  2 ++\n include/libcamera/internal/pipeline_handler.h |  5 +---\n src/libcamera/camera.cpp                      |  9 +++++++\n src/libcamera/pipeline_handler.cpp            | 26 ++++++++++++-------\n 4 files changed, 28 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h\nindex 18f5c32a18e4..8a2e9ed5894d 100644\n--- a/include/libcamera/internal/camera.h\n+++ b/include/libcamera/internal/camera.h\n@@ -10,6 +10,7 @@\n #include <atomic>\n #include <list>\n #include <memory>\n+#include <queue>\n #include <set>\n #include <stdint.h>\n #include <string>\n@@ -36,6 +37,7 @@ public:\n \tconst PipelineHandler *pipe() const { return pipe_.get(); }\n \n \tstd::list<Request *> queuedRequests_;\n+\tstd::queue<Request *> waitingRequests_;\n \tControlInfoMap controlInfo_;\n \tControlList properties_;\n \ndiff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex 972a2fa65310..be017ad47219 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -8,7 +8,6 @@\n #pragma once\n \n #include <memory>\n-#include <queue>\n #include <string>\n #include <sys/types.h>\n #include <vector>\n@@ -89,13 +88,11 @@ private:\n \tvirtual void disconnect();\n \n \tvoid doQueueRequest(Request *request);\n-\tvoid doQueueRequests();\n+\tvoid doQueueRequests(Camera *camera);\n \n \tstd::vector<std::shared_ptr<MediaDevice>> mediaDevices_;\n \tstd::vector<std::weak_ptr<Camera>> cameras_;\n \n-\tstd::queue<Request *> waitingRequests_;\n-\n \tconst char *name_;\n \tunsigned int useCount_;\n \ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex c180a5fdde93..2ae50eaeaa5a 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -628,6 +628,15 @@ Camera::Private::~Private()\n  * PipelineHandler::completeRequest()\n  */\n \n+/**\n+ * \\var Camera::Private::waitingRequests_\n+ * \\brief The queue of waiting requests\n+ *\n+ * This queue tracks all requests that can not yet be queued to the device.\n+ * Either because they are not yet prepared or because the maximum number of\n+ * queued requests was reached.\n+ */\n+\n /**\n  * \\var Camera::Private::controlInfo_\n  * \\brief The set of controls supported by the camera\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex d84dff3c9f19..b50eda5e0f86 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -363,15 +363,16 @@ void PipelineHandler::stop(Camera *camera)\n \t/* Stop the pipeline handler and let the queued requests complete. */\n \tstopDevice(camera);\n \n+\tCamera::Private *data = camera->_d();\n+\n \t/* Cancel and signal as complete all waiting requests. */\n-\twhile (!waitingRequests_.empty()) {\n-\t\tRequest *request = waitingRequests_.front();\n-\t\twaitingRequests_.pop();\n+\twhile (!data->waitingRequests_.empty()) {\n+\t\tRequest *request = data->waitingRequests_.front();\n+\t\tdata->waitingRequests_.pop();\n \t\tcancelRequest(request);\n \t}\n \n \t/* Make sure no requests are pending. */\n-\tCamera::Private *data = camera->_d();\n \tASSERT(data->queuedRequests_.empty());\n \n \tdata->requestSequence_ = 0;\n@@ -414,7 +415,9 @@ void PipelineHandler::registerRequest(Request *request)\n \t * Connect the request prepared signal to notify the pipeline handler\n \t * when a request is ready to be processed.\n \t */\n-\trequest->_d()->prepared.connect(this, &PipelineHandler::doQueueRequests);\n+\trequest->_d()->prepared.connect(this, [this, request]() {\n+\t\tdoQueueRequests(request->_d()->camera());\n+\t});\n }\n \n /**\n@@ -444,7 +447,9 @@ void PipelineHandler::queueRequest(Request *request)\n {\n \tLIBCAMERA_TRACEPOINT(request_queue, request);\n \n-\twaitingRequests_.push(request);\n+\tCamera *camera = request->_d()->camera();\n+\tCamera::Private *data = camera->_d();\n+\tdata->waitingRequests_.push(request);\n \n \trequest->_d()->prepare(300ms);\n }\n@@ -478,15 +483,16 @@ void PipelineHandler::doQueueRequest(Request *request)\n  * Iterate the list of waiting requests and queue them to the device one\n  * by one if they have been prepared.\n  */\n-void PipelineHandler::doQueueRequests()\n+void PipelineHandler::doQueueRequests(Camera *camera)\n {\n-\twhile (!waitingRequests_.empty()) {\n-\t\tRequest *request = waitingRequests_.front();\n+\tCamera::Private *data = camera->_d();\n+\twhile (!data->waitingRequests_.empty()) {\n+\t\tRequest *request = data->waitingRequests_.front();\n \t\tif (!request->_d()->prepared_)\n \t\t\tbreak;\n \n \t\tdoQueueRequest(request);\n-\t\twaitingRequests_.pop();\n+\t\tdata->waitingRequests_.pop();\n \t}\n }\n \n",
    "prefixes": [
        "v2",
        "1/5"
    ]
}