Patch Detail
Show a patch.
GET /api/patches/27124/?format=api
{ "id": 27124, "url": "https://patchwork.libcamera.org/api/patches/27124/?format=api", "web_url": "https://patchwork.libcamera.org/patch/27124/", "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-45-barnabas.pocze@ideasonboard.com>", "date": "2026-06-29T16:30:07", "name": "[RFC,v1,44/54] apps: qcam: Use camera buffer pool", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "14858d9b7b3221d4d4a56ab417c38a75c4d65066", "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/27124/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/27124/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/27124/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 E30AEC3303\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Jun 2026 16:31:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8EE5A65FBD;\n\tMon, 29 Jun 2026 18:31:37 +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 081CB65F5C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2026 18:30:31 +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 D01391044\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2026 18:29:47 +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=\"huKN8w6Q\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782750587;\n\tbh=I4ClZ5ta5pXE4oYt7eSCkwnoeLv+vpjFH1SChap4SfA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=huKN8w6QUiAsBq0CCs85wiS3pAvXjhwD/RwY2eQ40nZKd/rU/70JY0HFbLXEpnNwv\n\tmvsCDOiEmP37CLsxzM357MS41tuhK7eWzpr9OcQZSaNz1bZib5f0ZdEsJvlikWay9c\n\tR+JXbHezvP92WR4x8meHfqrCmYuKbpo6q7h2h+uc=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH v1 44/54] apps: qcam: Use camera buffer pool", "Date": "Mon, 29 Jun 2026 18:30:07 +0200", "Message-ID": "<20260629163017.863145-45-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": "Port to using the camera's buffer pool.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/apps/qcam/main_window.cpp | 82 ++++++++++++++---------------------\n src/apps/qcam/main_window.h | 1 -\n 2 files changed, 33 insertions(+), 50 deletions(-)", "diff": "diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp\nindex 59c2aa66cb..a0d5b0798c 100644\n--- a/src/apps/qcam/main_window.cpp\n+++ b/src/apps/qcam/main_window.cpp\n@@ -466,30 +466,7 @@ int MainWindow::startCapture()\n \t\t\t\tImage::fromFrameBuffer(buffer.get(), Image::MapMode::ReadOnly);\n \t\t\tassert(image != nullptr);\n \t\t\tmappedBuffers_[buffer.get()] = std::move(image);\n-\n-\t\t\t/* Store buffers on the free list. */\n-\t\t\tfreeBuffers_[stream].enqueue(buffer.get());\n-\t\t}\n-\t}\n-\n-\t/* Create requests and fill them with buffers from the viewfinder. */\n-\twhile (!freeBuffers_[vfStream_].isEmpty()) {\n-\t\tFrameBuffer *buffer = freeBuffers_[vfStream_].dequeue();\n-\n-\t\tstd::unique_ptr<Request> request = camera_->createRequest();\n-\t\tif (!request) {\n-\t\t\tqWarning() << \"Can't create request\";\n-\t\t\tret = -ENOMEM;\n-\t\t\tgoto error;\n-\t\t}\n-\n-\t\tret = request->addBuffer(vfStream_, buffer);\n-\t\tif (ret < 0) {\n-\t\t\tqWarning() << \"Can't set buffer for request\";\n-\t\t\tgoto error;\n \t\t}\n-\n-\t\trequests_.push_back(std::move(request));\n \t}\n \n \t/* Start the title timer and the camera. */\n@@ -507,13 +484,36 @@ int MainWindow::startCapture()\n \n \tcamera_->requestCompleted.connect(this, &MainWindow::requestComplete);\n \n+\tfor (StreamConfiguration &config : *config_) {\n+\t\tStream *stream = config.stream();\n+\n+\t\tfor (const std::unique_ptr<FrameBuffer> &buffer : allocator_->buffers(stream)) {\n+\t\t\tret = camera_->addBuffer(stream, buffer.get());\n+\t\t\tif (ret < 0) {\n+\t\t\t\tqWarning() << \"Can't add buffer\";\n+\t\t\t\tgoto error_disconnect;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n \t/* Queue all requests. */\n-\tfor (std::unique_ptr<Request> &request : requests_) {\n+\tfor ([[maybe_unused]] const auto &buffer : allocator_->buffers(vfStream_)) {\n+\t\tstd::unique_ptr<Request> request = camera_->createRequest();\n+\t\tif (!request) {\n+\t\t\tqWarning() << \"Can't create request\";\n+\t\t\tret = -ENOMEM;\n+\t\t\tgoto error_disconnect;\n+\t\t}\n+\n+\t\trequest->enableStream(vfStream_, true);\n+\n \t\tret = queueRequest(request.get());\n \t\tif (ret < 0) {\n \t\t\tqWarning() << \"Can't queue request\";\n \t\t\tgoto error_disconnect;\n \t\t}\n+\n+\t\trequests_.push_back(std::move(request));\n \t}\n \n \tisCapturing_ = true;\n@@ -529,8 +529,6 @@ error:\n \n \tmappedBuffers_.clear();\n \n-\tfreeBuffers_.clear();\n-\n \tallocator_.reset();\n \n \treturn ret;\n@@ -574,7 +572,6 @@ void MainWindow::stopCapture()\n \t * but not processed yet. Clear the queue of done buffers to avoid\n \t * racing with the event handler.\n \t */\n-\tfreeBuffers_.clear();\n \tdoneQueue_.clear();\n \n \ttitleTimer_.stop();\n@@ -661,11 +658,6 @@ void MainWindow::processRaw(FrameBuffer *buffer,\n \t\t\t\t memory);\n \t}\n #endif\n-\n-\t{\n-\t\tQMutexLocker locker(&mutex_);\n-\t\tfreeBuffers_[rawStream_].enqueue(buffer);\n-\t}\n }\n \n /* -----------------------------------------------------------------------------\n@@ -710,8 +702,10 @@ void MainWindow::processCapture()\n \tif (request->buffers().count(vfStream_))\n \t\tprocessViewfinder(request->buffers().at(vfStream_));\n \n-\tif (request->buffers().count(rawStream_))\n-\t\tprocessRaw(request->buffers().at(rawStream_), request->metadata());\n+\tif (auto it = request->buffers().find(rawStream_); it != request->buffers().end()) {\n+\t\tprocessRaw(it->second, request->metadata());\n+\t\tcamera_->addBuffer(it->first, it->second);\n+\t}\n \n \trequest->reuse();\n \tQMutexLocker locker(&mutex_);\n@@ -744,6 +738,8 @@ void MainWindow::processViewfinder(FrameBuffer *buffer)\n \n void MainWindow::renderComplete(FrameBuffer *buffer)\n {\n+\tcamera_->addBuffer(vfStream_, buffer);\n+\n \tRequest *request;\n \t{\n \t\tQMutexLocker locker(&mutex_);\n@@ -753,23 +749,11 @@ void MainWindow::renderComplete(FrameBuffer *buffer)\n \t\trequest = freeQueue_.dequeue();\n \t}\n \n-\trequest->addBuffer(vfStream_, buffer);\n+\trequest->enableStream(vfStream_, true);\n \n \tif (captureRaw_) {\n-\t\tFrameBuffer *rawBuffer = nullptr;\n-\n-\t\t{\n-\t\t\tQMutexLocker locker(&mutex_);\n-\t\t\tif (!freeBuffers_[rawStream_].isEmpty())\n-\t\t\t\trawBuffer = freeBuffers_[rawStream_].dequeue();\n-\t\t}\n-\n-\t\tif (rawBuffer) {\n-\t\t\trequest->addBuffer(rawStream_, rawBuffer);\n-\t\t\tcaptureRaw_ = false;\n-\t\t} else {\n-\t\t\tqWarning() << \"No free buffer available for RAW capture\";\n-\t\t}\n+\t\trequest->enableStream(rawStream_, true);\n+\t\tcaptureRaw_ = false;\n \t}\n \tqueueRequest(request);\n }\ndiff --git a/src/apps/qcam/main_window.h b/src/apps/qcam/main_window.h\nindex 20d369ad23..458c5a63b6 100644\n--- a/src/apps/qcam/main_window.h\n+++ b/src/apps/qcam/main_window.h\n@@ -119,7 +119,6 @@ private:\n \tbool captureRaw_;\n \tlibcamera::Stream *vfStream_;\n \tlibcamera::Stream *rawStream_;\n-\tstd::map<const libcamera::Stream *, QQueue<libcamera::FrameBuffer *>> freeBuffers_;\n \tQQueue<libcamera::Request *> doneQueue_;\n \tQQueue<libcamera::Request *> freeQueue_;\n \tQMutex mutex_; /* Protects freeBuffers_, doneQueue_, and freeQueue_ */\n", "prefixes": [ "RFC", "v1", "44/54" ] }