Patch Detail
Show a patch.
GET /api/1.1/patches/18066/?format=api
{ "id": 18066, "url": "https://patchwork.libcamera.org/api/1.1/patches/18066/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18066/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20221228223003.2265712-11-paul.elder@ideasonboard.com>", "date": "2022-12-28T22:29:54", "name": "[libcamera-devel,v10,10/19] v4l2: Allocate buffers based on requested count and MinimumRequests", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "5b5eea40b9da30e8b261714f65f86654b4d78275", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18066/mbox/", "series": [ { "id": 3691, "url": "https://patchwork.libcamera.org/api/1.1/series/3691/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3691", "date": "2022-12-28T22:29:44", "name": "lc-compliance: Add test to queue more requests than hardware depth", "version": 10, "mbox": "https://patchwork.libcamera.org/series/3691/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18066/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18066/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 2F0AFC3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 28 Dec 2022 22:30:38 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CBB86625FE;\n\tWed, 28 Dec 2022 23:30:37 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E789625EB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Dec 2022 23:30:29 +0100 (CET)", "from pyrite.mediacom.info (unknown\n\t[IPv6:2604:2d80:ad8a:9000:1bf9:855b:22de:3645])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6E121109;\n\tWed, 28 Dec 2022 23:30:28 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1672266637;\n\tbh=CgTVHMsudzEX7Z7J8lk8mQNzHP/BX6KslEspC+7juCw=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=U4vN2VmZEujhPe+1gjbY7R8Z0bd0vojns9l9j8BOCqLbw4fHgJmeHcxNB1iYvknjV\n\t4bxNcKg95cjIlEof1b/GgyN/azuQ7qsHyL3q0axjQRNes3Zj9kIwAH4+4F276LUo4/\n\tHxvrryQZl6c1tx6wJNjCCJMVZYEN7eEW7fxCwJGf/PMzvNR6IQV6nu6DJ32swRbStY\n\tEe2Doany/rh5yPbd+ioK46RoDNHOvZmBaSeSD589YDj4pqC2ft8UortMfD9pq1jklw\n\ts9Y+Fb8ItnObI3SqZyUnl5sgeGYPMm6E3oxQ8Bktc9Yn6sUM1zFPDz3u692ytmnA1v\n\tI/g0tyJJqzS/Q==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1672266629;\n\tbh=CgTVHMsudzEX7Z7J8lk8mQNzHP/BX6KslEspC+7juCw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=eXj6PT2qpMZr2WApM98NrqEvlZ3TxEcFd1n2rcth8yuMPfxE7Vm1VNhWqY63Bynf+\n\t2jE3Dtrh6ClXGSxhD0vl3L2/7b8PUGCRVg8ig8BavJZoxeFvsKgBlo1+X6ukafVePe\n\tkeEKMhvp2MxPnruWy/TnoDHe7AdFaxxKOiKeodx4=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"eXj6PT2q\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 28 Dec 2022 16:29:54 -0600", "Message-Id": "<20221228223003.2265712-11-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20221228223003.2265712-1-paul.elder@ideasonboard.com>", "References": "<20221228223003.2265712-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v10 10/19] v4l2: Allocate buffers based on\n\trequested count and MinimumRequests", "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>", "From": "Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Paul Elder <paul.elder@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n\nCurrently the number of buffers allocated is based on bufferCount, which\nis hardcoded to 1. Instead allocate buffers based on the requested count\nand on the MinimumRequests property for the camera, which is accessed\nthrough a newly added getter.\n\nThis allows the removal of bufferCount.\n\nWhile at it, fix a typo: s/interval/internal/.\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v9:\n- rebased\n\nChanges in v8:\n- New\n- Fixed typo: s/interval/internal/\n---\n src/v4l2/v4l2_camera.cpp | 20 +++++++++++++-------\n src/v4l2/v4l2_camera.h | 5 +++--\n src/v4l2/v4l2_camera_proxy.cpp | 10 +++++-----\n 3 files changed, 21 insertions(+), 14 deletions(-)", "diff": "diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp\nindex 1c5fab64..eb0fd239 100644\n--- a/src/v4l2/v4l2_camera.cpp\n+++ b/src/v4l2/v4l2_camera.cpp\n@@ -12,6 +12,8 @@\n \n #include <libcamera/base/log.h>\n \n+#include <libcamera/property_ids.h>\n+\n using namespace libcamera;\n \n LOG_DECLARE_CATEGORY(V4L2Compat)\n@@ -106,15 +108,13 @@ void V4L2Camera::requestComplete(Request *request)\n }\n \n int V4L2Camera::configure(StreamConfiguration *streamConfigOut,\n-\t\t\t const Size &size, const PixelFormat &pixelformat,\n-\t\t\t unsigned int bufferCount)\n+\t\t\t const Size &size, const PixelFormat &pixelformat)\n {\n \tStreamConfiguration &streamConfig = config_->at(0);\n \tstreamConfig.size.width = size.width;\n \tstreamConfig.size.height = size.height;\n \tstreamConfig.pixelFormat = pixelformat;\n-\tstreamConfig.bufferCount = bufferCount;\n-\t/* \\todo memoryType (interval vs external) */\n+\t/* \\todo memoryType (internal vs external) */\n \n \tCameraConfiguration::Status validation = config_->validate();\n \tif (validation == CameraConfiguration::Invalid) {\n@@ -145,7 +145,6 @@ int V4L2Camera::validateConfiguration(const PixelFormat &pixelFormat,\n \tStreamConfiguration &cfg = config->at(0);\n \tcfg.size = size;\n \tcfg.pixelFormat = pixelFormat;\n-\tcfg.bufferCount = 1;\n \n \tCameraConfiguration::Status validation = config->validate();\n \tif (validation == CameraConfiguration::Invalid)\n@@ -164,7 +163,9 @@ int V4L2Camera::allocBuffers(unsigned int count)\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tfor (unsigned int i = 0; i < count; i++) {\n+\tunsigned int allocatedCount = ret;\n+\n+\tfor (unsigned int i = 0; i < allocatedCount; i++) {\n \t\tstd::unique_ptr<Request> request = camera_->createRequest(i);\n \t\tif (!request) {\n \t\t\trequestPool_.clear();\n@@ -173,7 +174,7 @@ int V4L2Camera::allocBuffers(unsigned int count)\n \t\trequestPool_.push_back(std::move(request));\n \t}\n \n-\treturn ret;\n+\treturn allocatedCount;\n }\n \n void V4L2Camera::freeBuffers()\n@@ -298,3 +299,8 @@ bool V4L2Camera::isRunning()\n {\n \treturn isRunning_;\n }\n+\n+unsigned int V4L2Camera::minimumRequests()\n+{\n+\treturn camera_->properties().get(properties::MinimumRequests).value();\n+}\ndiff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\nindex d3483444..ada66421 100644\n--- a/src/v4l2/v4l2_camera.h\n+++ b/src/v4l2/v4l2_camera.h\n@@ -43,8 +43,7 @@ public:\n \n \tint configure(libcamera::StreamConfiguration *streamConfigOut,\n \t\t const libcamera::Size &size,\n-\t\t const libcamera::PixelFormat &pixelformat,\n-\t\t unsigned int bufferCount);\n+\t\t const libcamera::PixelFormat &pixelformat);\n \tint validateConfiguration(const libcamera::PixelFormat &pixelformat,\n \t\t\t\t const libcamera::Size &size,\n \t\t\t\t libcamera::StreamConfiguration *streamConfigOut);\n@@ -63,6 +62,8 @@ public:\n \n \tbool isRunning();\n \n+\tunsigned int minimumRequests();\n+\n private:\n \tvoid requestComplete(libcamera::Request *request)\n \t\tLIBCAMERA_TSA_EXCLUDES(bufferLock_);\ndiff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 55ff62cd..bcf9c2ab 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -367,8 +367,7 @@ int V4L2CameraProxy::vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg)\n \n \tSize size(arg->fmt.pix.width, arg->fmt.pix.height);\n \tV4L2PixelFormat v4l2Format = V4L2PixelFormat(arg->fmt.pix.pixelformat);\n-\tret = vcam_->configure(&streamConfig_, size, v4l2Format.toPixelFormat(),\n-\t\t\t bufferCount_);\n+\tret = vcam_->configure(&streamConfig_, size, v4l2Format.toPixelFormat());\n \tif (ret < 0)\n \t\treturn -EINVAL;\n \n@@ -514,14 +513,13 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n \tSize size(v4l2PixFormat_.width, v4l2PixFormat_.height);\n \tV4L2PixelFormat v4l2Format = V4L2PixelFormat(v4l2PixFormat_.pixelformat);\n \tint ret = vcam_->configure(&streamConfig_, size,\n-\t\t\t\t v4l2Format.toPixelFormat(), arg->count);\n+\t\t\t\t v4l2Format.toPixelFormat());\n \tif (ret < 0)\n \t\treturn -EINVAL;\n \n \tsetFmtFromConfig(streamConfig_);\n \n-\targ->count = streamConfig_.bufferCount;\n-\tbufferCount_ = arg->count;\n+\targ->count = std::max(arg->count, vcam_->minimumRequests());\n \n \tret = vcam_->allocBuffers(arg->count);\n \tif (ret < 0) {\n@@ -529,6 +527,8 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n \t\treturn ret;\n \t}\n \n+\tbufferCount_ = arg->count = ret;\n+\n \tbuffers_.resize(arg->count);\n \tfor (unsigned int i = 0; i < arg->count; i++) {\n \t\tstruct v4l2_buffer buf = {};\n", "prefixes": [ "libcamera-devel", "v10", "10/19" ] }