[v11,07/19] libcamera: pipeline: vimc, uvcvideo: Don't rely on bufferCount
diff mbox series

Message ID 20250428090413.38234-8-s.pueschel@pengutronix.de
State New
Headers show
Series
  • lc-compliance: Add test to queue more requests than hardware depth
Related show

Commit Message

Sven Püschel April 28, 2025, 9:02 a.m. UTC
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Instead of using bufferCount as the number of V4L2 buffer slots to
reserve in the vimc and uvcvideo pipeline handlers, use a reasonably
high constant: 16. Overallocating isn't a problem as buffer slots are
cheap. Having too few, on the other hand, could degrade performance. It
is expected that this number will be more than enough for most, if not
all, use cases.

This makes way for removing bufferCount.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>

---
Changes in v11:
- rebased

Changes in v9:
- rebased

Changes in v8:
- New
---
 src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 5 +++--
 src/libcamera/pipeline/vimc/vimc.cpp         | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
index 60c82364..e1259cf3 100644
--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
@@ -109,6 +109,8 @@  private:
 	{
 		return static_cast<UVCCameraData *>(camera->_d());
 	}
+
+	static constexpr unsigned int kUVCBufferSlotCount = 16;
 };
 
 namespace {
@@ -291,9 +293,8 @@  int PipelineHandlerUVC::exportFrameBuffers(Camera *camera,
 int PipelineHandlerUVC::start(Camera *camera, [[maybe_unused]] const ControlList *controls)
 {
 	UVCCameraData *data = cameraData(camera);
-	unsigned int count = data->stream_.configuration().bufferCount;
 
-	int ret = data->video_->importBuffers(count);
+	int ret = data->video_->importBuffers(kUVCBufferSlotCount);
 	if (ret < 0)
 		return ret;
 
diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
index 8833647a..e66dbd78 100644
--- a/src/libcamera/pipeline/vimc/vimc.cpp
+++ b/src/libcamera/pipeline/vimc/vimc.cpp
@@ -109,6 +109,8 @@  private:
 	{
 		return static_cast<VimcCameraData *>(camera->_d());
 	}
+
+	static constexpr unsigned int kVimcBufferSlotCount = 16;
 };
 
 namespace {
@@ -356,9 +358,8 @@  int PipelineHandlerVimc::exportFrameBuffers(Camera *camera,
 int PipelineHandlerVimc::start(Camera *camera, [[maybe_unused]] const ControlList *controls)
 {
 	VimcCameraData *data = cameraData(camera);
-	unsigned int count = data->stream_.configuration().bufferCount;
 
-	int ret = data->video_->importBuffers(count);
+	int ret = data->video_->importBuffers(kVimcBufferSlotCount);
 	if (ret < 0)
 		return ret;