[libcamera-devel,v10,08/19] libcamera: pipeline: vimc, uvcvideo: Don't rely on bufferCount
diff mbox series

Message ID 20221228223003.2265712-9-paul.elder@ideasonboard.com
State New
Headers show
Series
  • lc-compliance: Add test to queue more requests than hardware depth
Related show

Commit Message

Paul Elder Dec. 28, 2022, 10:29 p.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>

---
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 4ce240a4..18966d01 100644
--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
@@ -97,6 +97,8 @@  private:
 	{
 		return static_cast<UVCCameraData *>(camera->_d());
 	}
+
+	static constexpr unsigned int kUVCBufferSlotCount = 16;
 };
 
 UVCCameraConfiguration::UVCCameraConfiguration(UVCCameraData *data)
@@ -239,9 +241,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 e58caf99..eaa6ebf7 100644
--- a/src/libcamera/pipeline/vimc/vimc.cpp
+++ b/src/libcamera/pipeline/vimc/vimc.cpp
@@ -106,6 +106,8 @@  private:
 	{
 		return static_cast<VimcCameraData *>(camera->_d());
 	}
+
+	static constexpr unsigned int kVimcBufferSlotCount = 16;
 };
 
 namespace {
@@ -334,9 +336,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;