[libcamera-devel] [PATCH v8 07/17] libcamera: pipeline: vimc, uvcvideo: Don't rely on bufferCount

Paul Elder paul.elder at ideasonboard.com
Wed Nov 30 12:20:38 CET 2022


On Tue, Aug 24, 2021 at 04:56:26PM -0300, Nícolas F. R. A. Prado wrote:
> 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 at collabora.com>

Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>

> 
> ---
> 
> 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(-)
> 
> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> index 7821cacfa883..c210cf57750f 100644
> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> @@ -91,6 +91,8 @@ private:
>  	{
>  		return static_cast<UVCCameraData *>(camera->_d());
>  	}
> +
> +	static constexpr unsigned int kUVCBufferSlotCount = 16;
>  };
>  
>  UVCCameraConfiguration::UVCCameraConfiguration(UVCCameraData *data)
> @@ -236,9 +238,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 eebdfd1a4c01..d2943f61a745 100644
> --- a/src/libcamera/pipeline/vimc/vimc.cpp
> +++ b/src/libcamera/pipeline/vimc/vimc.cpp
> @@ -105,6 +105,8 @@ private:
>  	{
>  		return static_cast<VimcCameraData *>(camera->_d());
>  	}
> +
> +	static constexpr unsigned int kVimcBufferSlotCount = 16;
>  };
>  
>  namespace {
> @@ -331,9 +333,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;
>  
> -- 
> 2.33.0
> 


More information about the libcamera-devel mailing list