{"id":23688,"url":"https://patchwork.libcamera.org/api/1.1/patches/23688/?format=json","web_url":"https://patchwork.libcamera.org/patch/23688/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250630081126.2384387-3-stefan.klug@ideasonboard.com>","date":"2025-06-30T08:11:17","name":"[v1,2/6] libcamera: pipeline_handler: Allow to limit the number of queued requests","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"0b00e2c5659d7d6756ff6b392cecabf2479099ec","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23688/mbox/","series":[{"id":5257,"url":"https://patchwork.libcamera.org/api/1.1/series/5257/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5257","date":"2025-06-30T08:11:15","name":"rkisp1: Allow usage of more than 4 buffers","version":1,"mbox":"https://patchwork.libcamera.org/series/5257/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23688/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23688/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 E802EC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Jun 2025 08:11:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 891E368E0D;\n\tMon, 30 Jun 2025 10:11:43 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3BB3068E00\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Jun 2025 10:11:38 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:883b:eaf8:7aec:d1d4])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id A95D1669;\n\tMon, 30 Jun 2025 10:11:16 +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=\"uXXH9s9B\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1751271076;\n\tbh=fXH2u5QudviAaFj6PUaJC5vmp1x8ZIBzh2+ntq/idfI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=uXXH9s9BzjDQkC8AQ6QqoaLzBKGehZTfxtRi6UBJCkDARpGpewfgX8bYImVDo0SPq\n\tdh991AUwzWBhBRbZKtZd0HJ7M3hupyZsASXwXTWxXRpllScmeTypSRI1ThlKHkORQ5\n\t8gz3SE1xoJDRgKJRGGEgqfSI/jPtPhX8M89xOypE=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH v1 2/6] libcamera: pipeline_handler: Allow to limit the\n\tnumber of queued requests","Date":"Mon, 30 Jun 2025 10:11:17 +0200","Message-ID":"<20250630081126.2384387-3-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.48.1","In-Reply-To":"<20250630081126.2384387-1-stefan.klug@ideasonboard.com>","References":"<20250630081126.2384387-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":"Add a maxQueuedRequestsDevice constructor parameter to allow pipeline\nhandler classes to limit the maximum number of requests that get queued\nto the device in queueRequestDevice().\n\nThe default value is set to an arbitrary number of 32 which is big\nenough for all currently known use cases.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\n---\n\nChanges in v1:\n- Used a const member variable to carry the maximum number of requests\n- Improved commit message\n- Added docs\n---\n include/libcamera/internal/pipeline_handler.h |  4 +++-\n src/libcamera/pipeline_handler.cpp            | 20 ++++++++++++++-----\n 2 files changed, 18 insertions(+), 6 deletions(-)","diff":"diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex be017ad47219..e89d6a33e398 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -33,7 +33,8 @@ class PipelineHandler : public std::enable_shared_from_this<PipelineHandler>,\n \t\t\tpublic Object\n {\n public:\n-\tPipelineHandler(CameraManager *manager);\n+\tPipelineHandler(CameraManager *manager,\n+\t\t\tunsigned int maxQueuedRequestsDevice = 32);\n \tvirtual ~PipelineHandler();\n \n \tvirtual bool match(DeviceEnumerator *enumerator) = 0;\n@@ -80,6 +81,7 @@ protected:\n \tvirtual void releaseDevice(Camera *camera);\n \n \tCameraManager *manager_;\n+\tconst unsigned int maxQueuedRequestsDevice_;\n \n private:\n \tvoid unlockMediaDevices();\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex dc4086aa9bb5..383c6ad0c4aa 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -62,13 +62,17 @@ LOG_DEFINE_CATEGORY(Pipeline)\n /**\n  * \\brief Construct a PipelineHandler instance\n  * \\param[in] manager The camera manager\n+ * \\param[in] maxQueuedRequestsDevice The maximum number of requests queued to\n+ * the device\n  *\n  * In order to honour the std::enable_shared_from_this<> contract,\n  * PipelineHandler instances shall never be constructed manually, but always\n  * through the PipelineHandlerFactoryBase::create() function.\n  */\n-PipelineHandler::PipelineHandler(CameraManager *manager)\n-\t: manager_(manager), useCount_(0)\n+PipelineHandler::PipelineHandler(CameraManager *manager,\n+\t\t\t\t unsigned int maxQueuedRequestsDevice)\n+\t: manager_(manager), maxQueuedRequestsDevice_(maxQueuedRequestsDevice),\n+\t  useCount_(0)\n {\n }\n \n@@ -430,9 +434,9 @@ void PipelineHandler::registerRequest(Request *request)\n  * requests which have to be prepared to make sure they are ready for being\n  * queued to the pipeline handler.\n  *\n- * The queue of waiting requests is iterated and all prepared requests are\n- * passed to the pipeline handler in the same order they have been queued by\n- * calling this function.\n+ * The queue of waiting requests is iterated and up to \\a\n+ * maxQueuedRequestsDevice_ prepared requests are passed to the pipeline handler\n+ * in the same order they have been queued by calling this function.\n  *\n  * If a Request fails during the preparation phase or if the pipeline handler\n  * fails in queuing the request to the hardware the request is cancelled.\n@@ -487,6 +491,9 @@ void PipelineHandler::doQueueRequests(Camera *camera)\n {\n \tCamera::Private *data = camera->_d();\n \twhile (!data->waitingRequests_.empty()) {\n+\t\tif (data->queuedRequests_.size() == maxQueuedRequestsDevice_)\n+\t\t\tbreak;\n+\n \t\tRequest *request = data->waitingRequests_.front();\n \t\tif (!request->_d()->prepared_)\n \t\t\tbreak;\n@@ -568,6 +575,9 @@ void PipelineHandler::completeRequest(Request *request)\n \t\tdata->queuedRequests_.pop_front();\n \t\tcamera->requestComplete(req);\n \t}\n+\n+\t/* Allow any waiting requests to be queued to the pipeline. */\n+\tdoQueueRequests(camera);\n }\n \n /**\n","prefixes":["v1","2/6"]}