Patch Detail
Show a patch.
GET /api/patches/12856/?format=api
{ "id": 12856, "url": "https://patchwork.libcamera.org/api/patches/12856/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12856/", "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": "<20210707144202.1327061-3-nfraprado@collabora.com>", "date": "2021-07-07T14:41:54", "name": "[libcamera-devel,v5,02/10] libcamera: framebuffer_allocator: Make allocate() require count", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "7200426e2d4625a9999ffb762b07885deb2a15f2", "submitter": { "id": 84, "url": "https://patchwork.libcamera.org/api/people/84/?format=api", "name": "Nícolas F. R. A. Prado", "email": "nfraprado@collabora.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/12856/mbox/", "series": [ { "id": 2216, "url": "https://patchwork.libcamera.org/api/series/2216/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2216", "date": "2021-07-07T14:41:52", "name": "lc-compliance: Add test to queue more requests than hardware depth", "version": 5, "mbox": "https://patchwork.libcamera.org/series/2216/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12856/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12856/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 5264BBD794\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 7 Jul 2021 14:42:24 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1D2A368500;\n\tWed, 7 Jul 2021 16:42:24 +0200 (CEST)", "from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 27F386851A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 7 Jul 2021 16:42:23 +0200 (CEST)", "from localhost.localdomain (unknown\n\t[IPv6:2804:14c:1a9:2434:6553:ad0c:9d2a:24db])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits))\n\t(No client certificate requested) (Authenticated sender: nfraprado)\n\tby bhuna.collabora.co.uk (Postfix) with ESMTPSA id 7F35C1F434AE;\n\tWed, 7 Jul 2021 15:42:21 +0100 (BST)" ], "From": "=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 7 Jul 2021 11:41:54 -0300", "Message-Id": "<20210707144202.1327061-3-nfraprado@collabora.com>", "X-Mailer": "git-send-email 2.32.0", "In-Reply-To": "<20210707144202.1327061-1-nfraprado@collabora.com>", "References": "<20210707144202.1327061-1-nfraprado@collabora.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 02/10] libcamera:\n\tframebuffer_allocator: Make allocate() require count", "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>", "Cc": "kernel@collabora.com, =?utf-8?q?Andr=C3=A9_Almeida?=\n\t<andrealmeid@collabora.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Make FrameBufferAllocator::allocate() require a 'count' argument for the\nnumber of buffers to be allocated.\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n---\n\nChanges in v5:\n- Made sure that qcam allocates at least 2 buffers\n\n include/libcamera/camera.h | 2 +-\n include/libcamera/framebuffer_allocator.h | 2 +-\n include/libcamera/internal/pipeline_handler.h | 2 +-\n src/android/camera_stream.cpp | 5 ++++-\n src/cam/capture.cpp | 9 +++------\n src/gstreamer/gstlibcameraallocator.cpp | 4 +++-\n src/lc-compliance/simple_capture.cpp | 7 +++++--\n src/libcamera/camera.cpp | 4 ++--\n src/libcamera/framebuffer_allocator.cpp | 5 +++--\n src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ++--\n src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 ++--\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 ++--\n src/libcamera/pipeline/simple/simple.cpp | 4 ++--\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 7 ++++---\n src/libcamera/pipeline/vimc/vimc.cpp | 7 ++++---\n src/libcamera/pipeline_handler.cpp | 1 +\n src/qcam/main_window.cpp | 11 ++++++++++-\n src/v4l2/v4l2_camera.cpp | 2 +-\n test/camera/capture.cpp | 4 +++-\n test/camera/statemachine.cpp | 4 +++-\n test/mapped-buffer.cpp | 4 +++-\n 21 files changed, 60 insertions(+), 36 deletions(-)", "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex b081907e0cb1..9f1767e4c406 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -116,7 +116,7 @@ private:\n \tvoid requestComplete(Request *request);\n \n \tfriend class FrameBufferAllocator;\n-\tint exportFrameBuffers(Stream *stream,\n+\tint exportFrameBuffers(Stream *stream, unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n };\n \ndiff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h\nindex cbc9ce101889..2d5a6e98e10c 100644\n--- a/include/libcamera/framebuffer_allocator.h\n+++ b/include/libcamera/framebuffer_allocator.h\n@@ -25,7 +25,7 @@ public:\n \tFrameBufferAllocator(std::shared_ptr<Camera> camera);\n \t~FrameBufferAllocator();\n \n-\tint allocate(Stream *stream);\n+\tint allocate(Stream *stream, unsigned int count);\n \tint free(Stream *stream);\n \n \tbool allocated() const { return !buffers_.empty(); }\ndiff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex 9e2d65d6f2c5..0b4b2e4947c0 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -76,7 +76,7 @@ public:\n \t\tconst StreamRoles &roles) = 0;\n \tvirtual int configure(Camera *camera, CameraConfiguration *config) = 0;\n \n-\tvirtual int exportFrameBuffers(Camera *camera, Stream *stream,\n+\tvirtual int exportFrameBuffers(Camera *camera, Stream *stream, unsigned int count,\n \t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;\n \n \tvirtual int start(Camera *camera, const ControlList *controls) = 0;\ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex bf4a7b41a70a..6e1e17b2e748 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -13,6 +13,7 @@\n #include \"jpeg/post_processor_jpeg.h\"\n \n #include <libcamera/formats.h>\n+#include <libcamera/property_ids.h>\n \n using namespace libcamera;\n \n@@ -81,8 +82,10 @@ int CameraStream::configure()\n \t\t\treturn ret;\n \t}\n \n+\tunsigned int bufferCount = cameraDevice_->camera()->properties().get(properties::MinNumRequests);\n+\n \tif (allocator_) {\n-\t\tint ret = allocator_->allocate(stream());\n+\t\tint ret = allocator_->allocate(stream(), bufferCount);\n \t\tif (ret < 0)\n \t\t\treturn ret;\n \ndiff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\nindex 3c3e3a53adf7..584097fae38c 100644\n--- a/src/cam/capture.cpp\n+++ b/src/cam/capture.cpp\n@@ -11,6 +11,7 @@\n #include <sstream>\n \n #include <libcamera/control_ids.h>\n+#include <libcamera/property_ids.h>\n \n #include \"capture.h\"\n #include \"main.h\"\n@@ -81,17 +82,13 @@ int Capture::capture(FrameBufferAllocator *allocator)\n {\n \tint ret;\n \n-\t/* Identify the stream with the least number of buffers. */\n-\tunsigned int nbuffers = UINT_MAX;\n+\tunsigned int nbuffers = camera_->properties().get(properties::MinNumRequests);\n \tfor (StreamConfiguration &cfg : *config_) {\n-\t\tret = allocator->allocate(cfg.stream());\n+\t\tret = allocator->allocate(cfg.stream(), nbuffers);\n \t\tif (ret < 0) {\n \t\t\tstd::cerr << \"Can't allocate buffers\" << std::endl;\n \t\t\treturn -ENOMEM;\n \t\t}\n-\n-\t\tunsigned int allocated = allocator->buffers(cfg.stream()).size();\n-\t\tnbuffers = std::min(nbuffers, allocated);\n \t}\n \n \t/*\ndiff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp\nindex 7bd8ba2db71d..37fe809bc575 100644\n--- a/src/gstreamer/gstlibcameraallocator.cpp\n+++ b/src/gstreamer/gstlibcameraallocator.cpp\n@@ -10,6 +10,7 @@\n \n #include <libcamera/camera.h>\n #include <libcamera/framebuffer_allocator.h>\n+#include <libcamera/property_ids.h>\n #include <libcamera/stream.h>\n \n #include \"gstlibcamera-utils.h\"\n@@ -188,13 +189,14 @@ gst_libcamera_allocator_new(std::shared_ptr<Camera> camera,\n {\n \tauto *self = GST_LIBCAMERA_ALLOCATOR(g_object_new(GST_TYPE_LIBCAMERA_ALLOCATOR,\n \t\t\t\t\t\t\t nullptr));\n+\tunsigned int bufferCount = camera->properties().get(properties::MinNumRequests);\n \n \tself->fb_allocator = new FrameBufferAllocator(camera);\n \tfor (StreamConfiguration &streamCfg : *config_) {\n \t\tStream *stream = streamCfg.stream();\n \t\tgint ret;\n \n-\t\tret = self->fb_allocator->allocate(stream);\n+\t\tret = self->fb_allocator->allocate(stream, bufferCount);\n \t\tif (ret == 0)\n \t\t\treturn nullptr;\n \ndiff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp\nindex 25097f28a603..35dfccd664eb 100644\n--- a/src/lc-compliance/simple_capture.cpp\n+++ b/src/lc-compliance/simple_capture.cpp\n@@ -7,6 +7,8 @@\n \n #include <gtest/gtest.h>\n \n+#include <libcamera/property_ids.h>\n+\n #include \"simple_capture.h\"\n \n using namespace libcamera;\n@@ -44,11 +46,12 @@ void SimpleCapture::configure(StreamRole role)\n \n void SimpleCapture::start()\n {\n+\tunsigned int bufferCount = camera_->properties().get(properties::MinNumRequests);\n \tStream *stream = config_->at(0).stream();\n-\tint count = allocator_->allocate(stream);\n+\tint count = allocator_->allocate(stream, bufferCount);\n \n \tASSERT_GE(count, 0) << \"Failed to allocate buffers\";\n-\tEXPECT_EQ(count, config_->at(0).bufferCount) << \"Allocated less buffers than expected\";\n+\tEXPECT_EQ(count, static_cast<int>(bufferCount)) << \"Allocated less buffers than expected\";\n \n \tcamera_->requestCompleted.connect(this, &SimpleCapture::requestComplete);\n \ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 29f2d91d05d3..7a2885465ca5 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -663,7 +663,7 @@ void Camera::disconnect()\n \tdisconnected.emit(this);\n }\n \n-int Camera::exportFrameBuffers(Stream *stream,\n+int Camera::exportFrameBuffers(Stream *stream, unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \tPrivate *const d = LIBCAMERA_D_PTR();\n@@ -680,7 +680,7 @@ int Camera::exportFrameBuffers(Stream *stream,\n \n \treturn d->pipe_->invokeMethod(&PipelineHandler::exportFrameBuffers,\n \t\t\t\t ConnectionTypeBlocking, this, stream,\n-\t\t\t\t buffers);\n+\t\t\t\t count, buffers);\n }\n \n /**\ndiff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp\nindex 86a57923286c..42c5679e6610 100644\n--- a/src/libcamera/framebuffer_allocator.cpp\n+++ b/src/libcamera/framebuffer_allocator.cpp\n@@ -71,6 +71,7 @@ FrameBufferAllocator::~FrameBufferAllocator()\n /**\n * \\brief Allocate buffers for a configured stream\n * \\param[in] stream The stream to allocate buffers for\n+ * \\param[in] count The number of buffers to allocate\n *\n * Allocate buffers suitable for capturing frames from the \\a stream. The Camera\n * shall have been previously configured with Camera::configure() and shall be\n@@ -86,14 +87,14 @@ FrameBufferAllocator::~FrameBufferAllocator()\n * not part of the active camera configuration\n * \\retval -EBUSY Buffers are already allocated for the \\a stream\n */\n-int FrameBufferAllocator::allocate(Stream *stream)\n+int FrameBufferAllocator::allocate(Stream *stream, unsigned int count)\n {\n \tif (buffers_.count(stream)) {\n \t\tLOG(Allocator, Error) << \"Buffers already allocated for stream\";\n \t\treturn -EBUSY;\n \t}\n \n-\tint ret = camera_->exportFrameBuffers(stream, &buffers_[stream]);\n+\tint ret = camera_->exportFrameBuffers(stream, count, &buffers_[stream]);\n \tif (ret == -EINVAL)\n \t\tLOG(Allocator, Error)\n \t\t\t<< \"Stream is not part of \" << camera_->id()\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 017018c845fa..f3b456ba3afa 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -134,7 +134,7 @@ public:\n \t\tconst StreamRoles &roles) override;\n \tint configure(Camera *camera, CameraConfiguration *config) override;\n \n-\tint exportFrameBuffers(Camera *camera, Stream *stream,\n+\tint exportFrameBuffers(Camera *camera, Stream *stream, unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n \n \tint start(Camera *camera, const ControlList *controls) override;\n@@ -654,10 +654,10 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n }\n \n int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,\n+\t\t\t\t\t unsigned int count,\n \t\t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \tIPU3CameraData *data = cameraData(camera);\n-\tunsigned int count = stream->configuration().bufferCount;\n \n \tif (stream == &data->outStream_)\n \t\treturn data->imgu_->output_->exportBuffers(count, buffers);\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex f99a21de6918..33d826433668 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -250,7 +250,7 @@ public:\n \tCameraConfiguration *generateConfiguration(Camera *camera, const StreamRoles &roles) override;\n \tint configure(Camera *camera, CameraConfiguration *config) override;\n \n-\tint exportFrameBuffers(Camera *camera, Stream *stream,\n+\tint exportFrameBuffers(Camera *camera, Stream *stream, unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n \n \tint start(Camera *camera, const ControlList *controls) override;\n@@ -794,10 +794,10 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n }\n \n int PipelineHandlerRPi::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n+\t\t\t\t\t unsigned int count,\n \t\t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \tRPi::Stream *s = static_cast<RPi::Stream *>(stream);\n-\tunsigned int count = stream->configuration().bufferCount;\n \tint ret = s->dev()->exportBuffers(count, buffers);\n \n \ts->setExportedBuffers(buffers);\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex b5cbf2394b1c..768969f4194a 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -141,7 +141,7 @@ public:\n \t\tconst StreamRoles &roles) override;\n \tint configure(Camera *camera, CameraConfiguration *config) override;\n \n-\tint exportFrameBuffers(Camera *camera, Stream *stream,\n+\tint exportFrameBuffers(Camera *camera, Stream *stream, unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n \n \tint start(Camera *camera, const ControlList *controls) override;\n@@ -671,10 +671,10 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n }\n \n int PipelineHandlerRkISP1::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n+\t\t\t\t\t unsigned int count,\n \t\t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \tRkISP1CameraData *data = cameraData(camera);\n-\tunsigned int count = stream->configuration().bufferCount;\n \n \tif (stream == &data->mainPathStream_)\n \t\treturn mainPath_.exportBuffers(count, buffers);\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex c4adea61519f..37e880db0782 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -228,7 +228,7 @@ public:\n \t\t\t\t\t\t const StreamRoles &roles) override;\n \tint configure(Camera *camera, CameraConfiguration *config) override;\n \n-\tint exportFrameBuffers(Camera *camera, Stream *stream,\n+\tint exportFrameBuffers(Camera *camera, Stream *stream, unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n \n \tint start(Camera *camera, const ControlList *controls) override;\n@@ -776,10 +776,10 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n }\n \n int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,\n+\t\t\t\t\t unsigned int count,\n \t\t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \tSimpleCameraData *data = cameraData(camera);\n-\tunsigned int count = stream->configuration().bufferCount;\n \n \t/*\n \t * Export buffers on the converter or capture video node, depending on\ndiff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 0258111ad6cf..a1fa295a6456 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -69,7 +69,7 @@ public:\n \t\tconst StreamRoles &roles) override;\n \tint configure(Camera *camera, CameraConfiguration *config) override;\n \n-\tint exportFrameBuffers(Camera *camera, Stream *stream,\n+\tint exportFrameBuffers(Camera *camera, Stream *stream, unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n \n \tint start(Camera *camera, const ControlList *controls) override;\n@@ -223,11 +223,12 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config)\n \treturn 0;\n }\n \n-int PipelineHandlerUVC::exportFrameBuffers(Camera *camera, Stream *stream,\n+int PipelineHandlerUVC::exportFrameBuffers(Camera *camera,\n+\t\t\t\t\t [[maybe_unused]] Stream *stream,\n+\t\t\t\t\t unsigned int count,\n \t\t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \tUVCCameraData *data = cameraData(camera);\n-\tunsigned int count = stream->configuration().bufferCount;\n \n \treturn data->video_->exportBuffers(count, buffers);\n }\ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex 8c3f7ccb46bd..d163e6b9767d 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -84,7 +84,7 @@ public:\n \t\tconst StreamRoles &roles) override;\n \tint configure(Camera *camera, CameraConfiguration *config) override;\n \n-\tint exportFrameBuffers(Camera *camera, Stream *stream,\n+\tint exportFrameBuffers(Camera *camera, Stream *stream, unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n \n \tint start(Camera *camera, const ControlList *controls) override;\n@@ -299,11 +299,12 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n \treturn 0;\n }\n \n-int PipelineHandlerVimc::exportFrameBuffers(Camera *camera, Stream *stream,\n+int PipelineHandlerVimc::exportFrameBuffers(Camera *camera,\n+\t\t\t\t\t [[maybe_unused]] Stream *stream,\n+\t\t\t\t\t unsigned int count,\n \t\t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \tVimcCameraData *data = cameraData(camera);\n-\tunsigned int count = stream->configuration().bufferCount;\n \n \treturn data->video_->exportBuffers(count, buffers);\n }\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 0ed172dcd750..93f62fc5bb4e 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -323,6 +323,7 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const\n * \\brief Allocate and export buffers for \\a stream\n * \\param[in] camera The camera\n * \\param[in] stream The stream to allocate buffers for\n+ * \\param[in] count The number of buffers to allocate\n * \\param[out] buffers Array of buffers successfully allocated\n *\n * This method allocates buffers for the \\a stream from the devices associated\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 39d034de6bb2..e8b348470466 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -25,6 +25,7 @@\n #include <QtDebug>\n \n #include <libcamera/camera_manager.h>\n+#include <libcamera/property_ids.h>\n #include <libcamera/version.h>\n \n #include \"dng_writer.h\"\n@@ -463,7 +464,15 @@ int MainWindow::startCapture()\n \tfor (StreamConfiguration &config : *config_) {\n \t\tStream *stream = config.stream();\n \n-\t\tret = allocator_->allocate(stream);\n+\t\tunsigned int bufferCount = camera_->properties().get(properties::MinNumRequests);\n+\n+\t\t/*\n+\t\t * Need at least two buffers, one for capture and another for\n+\t\t * display\n+\t\t */\n+\t\tbufferCount = std::max(bufferCount, 2U);\n+\n+\t\tret = allocator_->allocate(stream, bufferCount);\n \t\tif (ret < 0) {\n \t\t\tqWarning() << \"Failed to allocate capture buffers\";\n \t\t\tgoto error;\ndiff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp\nindex 157ab94e0544..d01eacfa2b84 100644\n--- a/src/v4l2/v4l2_camera.cpp\n+++ b/src/v4l2/v4l2_camera.cpp\n@@ -161,7 +161,7 @@ int V4L2Camera::allocBuffers(unsigned int count)\n {\n \tStream *stream = config_->at(0).stream();\n \n-\tint ret = bufferAllocator_->allocate(stream);\n+\tint ret = bufferAllocator_->allocate(stream, count);\n \tif (ret < 0)\n \t\treturn ret;\n \ndiff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\nindex 238d98dbba16..fdb168dd5efa 100644\n--- a/test/camera/capture.cpp\n+++ b/test/camera/capture.cpp\n@@ -8,6 +8,7 @@\n #include <iostream>\n \n #include <libcamera/framebuffer_allocator.h>\n+#include <libcamera/property_ids.h>\n \n #include <libcamera/base/event_dispatcher.h>\n #include <libcamera/base/thread.h>\n@@ -96,7 +97,8 @@ protected:\n \n \t\tStream *stream = cfg.stream();\n \n-\t\tint ret = allocator_->allocate(stream);\n+\t\tunsigned int bufferCount = camera_->properties().get(properties::MinNumRequests);\n+\t\tint ret = allocator_->allocate(stream, bufferCount);\n \t\tif (ret < 0)\n \t\t\treturn TestFail;\n \ndiff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\nindex 26fb5ca17139..6f9a6b6f758c 100644\n--- a/test/camera/statemachine.cpp\n+++ b/test/camera/statemachine.cpp\n@@ -8,6 +8,7 @@\n #include <iostream>\n \n #include <libcamera/framebuffer_allocator.h>\n+#include <libcamera/property_ids.h>\n \n #include \"camera_test.h\"\n #include \"test.h\"\n@@ -119,7 +120,8 @@ protected:\n \t\t/* Use internally allocated buffers. */\n \t\tallocator_ = new FrameBufferAllocator(camera_);\n \t\tStream *stream = *camera_->streams().begin();\n-\t\tif (allocator_->allocate(stream) < 0)\n+\t\tunsigned int bufferCount = camera_->properties().get(properties::MinNumRequests);\n+\t\tif (allocator_->allocate(stream, bufferCount) < 0)\n \t\t\treturn TestFail;\n \n \t\tif (camera_->start())\ndiff --git a/test/mapped-buffer.cpp b/test/mapped-buffer.cpp\nindex 5de8201e45f6..c6b9e5882045 100644\n--- a/test/mapped-buffer.cpp\n+++ b/test/mapped-buffer.cpp\n@@ -8,6 +8,7 @@\n #include <iostream>\n \n #include <libcamera/framebuffer_allocator.h>\n+#include <libcamera/property_ids.h>\n \n #include \"libcamera/internal/buffer.h\"\n \n@@ -54,7 +55,8 @@ protected:\n \n \t\tstream_ = cfg.stream();\n \n-\t\tint ret = allocator_->allocate(stream_);\n+\t\tunsigned int bufferCount = camera_->properties().get(properties::MinNumRequests);\n+\t\tint ret = allocator_->allocate(stream_, bufferCount);\n \t\tif (ret < 0)\n \t\t\treturn TestFail;\n \n", "prefixes": [ "libcamera-devel", "v5", "02/10" ] }