Patch Detail
Show a patch.
GET /api/patches/27107/?format=api
{ "id": 27107, "url": "https://patchwork.libcamera.org/api/patches/27107/?format=api", "web_url": "https://patchwork.libcamera.org/patch/27107/", "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": "<20260629163017.863145-29-barnabas.pocze@ideasonboard.com>", "date": "2026-06-29T16:29:51", "name": "[RFC,v1,28/54] libcamera: pipeline_handler: Acquire buffers if not using pool", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "7388266334b0d2e786e4e6a5fbf16f4dc67359c7", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/27107/mbox/", "series": [ { "id": 6025, "url": "https://patchwork.libcamera.org/api/series/6025/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6025", "date": "2026-06-29T16:29:23", "name": "libcamera: Split requests and buffers", "version": 1, "mbox": "https://patchwork.libcamera.org/series/6025/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/27107/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/27107/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 84A0CC3261\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Jun 2026 16:31:19 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0B3E865FA9;\n\tMon, 29 Jun 2026 18:31:19 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 44E0365F32\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2026 18:30:27 +0200 (CEST)", "from pb-laptop.local (185.221.140.128.nat.pool.zt.hu\n\t[185.221.140.128])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 21F2B8D4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2026 18:29:44 +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=\"HKQYbxnZ\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782750584;\n\tbh=rKHRs0PTnPSsrt/YEvBC7o9qWbw+5n2Y4Q5hgJakESI=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=HKQYbxnZVlVhuPODkNQRdMBI8ULPN/qsAEZoa6DoFklSzBAutPg9bysNrHfFh646n\n\tLwrzmJrCHa0YsJPdTklueJsC9pprP6iDb0DO4eHscBKT5xhUI5yF6Iok+LDEes7Ui7\n\tzKHRZLZFUXfUC3seTUUJdwGLlw2zrrMMM37gYjM0=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH v1 28/54] libcamera: pipeline_handler: Acquire buffers if\n\tnot using pool", "Date": "Mon, 29 Jun 2026 18:29:51 +0200", "Message-ID": "<20260629163017.863145-29-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.54.0", "In-Reply-To": "<20260629163017.863145-1-barnabas.pocze@ideasonboard.com>", "References": "<20260629163017.863145-1-barnabas.pocze@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": "If the pipeline handler itself is not using the camera's buffer pool,\nthen ensure that each stream of the request has a buffer by retrieving\nbuffers before `queueRequestDevice()`.\n\nAdditionally, try to queue the waiting requests if a buffer has been\nadded to the pool.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/internal/pipeline_handler.h | 4 ++\n include/libcamera/internal/request.h | 2 +\n src/libcamera/pipeline_handler.cpp | 61 ++++++++++++++++++-\n src/libcamera/request.cpp | 5 ++\n 4 files changed, 71 insertions(+), 1 deletion(-)", "diff": "diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex e978557036..d7544642fb 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -39,6 +39,7 @@ class PipelineHandler : public std::enable_shared_from_this<PipelineHandler>,\n public:\n \tstruct Options {\n \t\tunsigned int maxQueuedRequestsDevice = 32;\n+\t\tbool usesBufferPool = false;\n \t};\n \n \tPipelineHandler(CameraManager *manager, const Options &options);\n@@ -110,9 +111,12 @@ private:\n \tvoid mediaDeviceDisconnected(std::shared_ptr<MediaDevice> media);\n \tvirtual void disconnect();\n \n+\t[[nodiscard]] bool prepareRequest(Request *request);\n \tvoid doQueueRequest(Request *request);\n \tvoid doQueueRequests(Camera *camera);\n \n+\tvoid buffersAdded(Camera *camera);\n+\n \tstd::vector<std::shared_ptr<MediaDevice>> mediaDevices_;\n \tstd::vector<std::weak_ptr<Camera>> cameras_;\n \ndiff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h\nindex 922d14f14c..f5aae3c1dc 100644\n--- a/include/libcamera/internal/request.h\n+++ b/include/libcamera/internal/request.h\n@@ -29,6 +29,8 @@ public:\n \tCamera *camera() const { return camera_; }\n \tbool hasPendingBuffers() const { return pending_ > 0; }\n \n+\t[[nodiscard]] Request::BufferMap &buffers() { return LIBCAMERA_O_PTR()->bufferMap_; } // \\todo fixme suboptimal\n+\n \tControlList &metadata() { return metadata_; }\n \n \tbool completeBuffer(FrameBuffer *buffer);\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex efea534649..36e1509b2b 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -78,6 +78,16 @@ LOG_DEFINE_CATEGORY(Pipeline)\n * queue, to be queued at a later stage.\n */\n \n+/**\n+ * \\var PipelineHandler::Options::usesBufferPool\n+ * \\brief Whether or not the pipeline handler uses the camera's buffer pool\n+ *\n+ * If this option is set to \\a false, then the pipeline handler base class\n+ * will ensure that the requests have the necessary buffers when queueRequestDevice()\n+ * is called. Otherwise it is the responsibility of the derived class to\n+ * manage the buffers.\n+ */\n+\n /**\n * \\brief Construct a PipelineHandler instance\n * \\param[in] manager The camera manager\n@@ -493,6 +503,38 @@ void PipelineHandler::queueRequest(Request *request)\n \tdoQueueRequests(camera);\n }\n \n+bool PipelineHandler::prepareRequest(Request *request)\n+{\n+\tif (!options_.usesBufferPool) {\n+\t\tCamera *camera = request->_d()->camera();\n+\t\tCamera::Private *data = camera->_d();\n+\t\tauto &buffers = request->_d()->buffers();\n+\n+\t\tASSERT(request->_d()->pending_ == buffers.size());\n+\n+\t\tfor (auto &[stream, buffer] : buffers) {\n+\t\t\tauto it = data->streamData_.find(stream);\n+\t\t\tASSERT(it != data->streamData_.end());\n+\t\t\tASSERT(it->second.active);\n+\n+\t\t\tif (buffer)\n+\t\t\t\tcontinue;\n+\n+\t\t\tauto &pool = it->second.buffers;\n+\t\t\tif (pool.empty())\n+\t\t\t\treturn false;\n+\n+\t\t\tbuffer = pool.back();\n+\t\t\tpool.pop_back();\n+\n+\t\t\tbuffer->_d()->setRequest(request);\n+\t\t\tbuffer->_d()->stream_ = stream;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n /**\n * \\brief Queue one requests to the device\n */\n@@ -514,6 +556,9 @@ void PipelineHandler::doQueueRequest(Request *request)\n \tint ret = queueRequestDevice(camera, request);\n \tif (ret)\n \t\tcancelRequest(request);\n+\t\t// \\todo what to do with buffers from pool? probably nothing?\n+\t\t// let's say it's the applications responsibility to process\n+\t\t// *all* buffers in *all* completed requests\n }\n \n /**\n@@ -530,6 +575,8 @@ void PipelineHandler::doQueueRequests(Camera *camera)\n \t\t\tbreak;\n \n \t\tRequest *request = data->waitingRequests_.front();\n+\t\tif (!prepareRequest(request))\n+\t\t\tbreak;\n \n \t\t/*\n \t\t * Pop the request first, in case doQueueRequests() is called\n@@ -625,6 +672,12 @@ void PipelineHandler::cancelRequest(Request *request)\n \tcompleteRequest(request);\n }\n \n+void PipelineHandler::buffersAdded(Camera *camera)\n+{\n+\tif (!options_.usesBufferPool)\n+\t\tdoQueueRequests(camera);\n+}\n+\n /**\n * \\fn PipelineHandler::addBuffer()\n * \\brief Add buffers to the buffer pool of the camera\n@@ -679,18 +732,24 @@ void PipelineHandler::addBuffer(Camera *camera,\n \t\t\t<< \"Waiting on fence:\" << buffer->_d()->fence()->fd().get()\n \t\t\t<< \" for stream:\" << stream << \" buffer:\" << buffer;\n \n-\t\tit2->notifier.activated.connect(this, [=] {\n+\t\tit2->notifier.activated.connect(this, [=, this] {\n \t\t\tLOG(Pipeline, Debug)\n \t\t\t\t<< \"Activated fence:\" << it2->buffer->_d()->fence()->fd().get()\n \t\t\t\t<< \" for stream:\" << it2->stream << \" buffer:\" << it2->buffer;\n \n+\t\t\tPipelineHandler *self = this;\n+\t\t\tCamera *cam = camera;\n+\n \t\t\tstd::ignore = it2->buffer->releaseFence();\n \t\t\tit->second.buffers.push_back(it2->buffer);\n \t\t\td->pendingFences_.erase(it2);\n \t\t\t/* Lambda is now destroy, no captured variable should be accessed. */\n+\n+\t\t\tself->buffersAdded(cam);\n \t\t});\n \t} else {\n \t\tit->second.buffers.push_back(buffer);\n+\t\tbuffersAdded(camera);\n \t}\n }\n \ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex 4df8b0f1ad..5bb1617b51 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -79,6 +79,11 @@ Request::Private::~Private()\n * otherwise\n */\n \n+/**\n+ * \\fn Request::Private::buffers()\n+ * \\copydoc Request::buffers()\n+ */\n+\n /**\n * \\fn Request::Private::metadata()\n * \\brief Retrieve the request's metadata\n", "prefixes": [ "RFC", "v1", "28/54" ] }