[libcamera-devel] [PATCH v4 19/21] libcamera: vimc: Fill stride and frameSize at config validation

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Jul 8 17:30:41 CEST 2020


Hi Paul,

Thank you for the patch.

On Wed, Jul 08, 2020 at 10:44:15PM +0900, Paul Elder wrote:
> Fill the stride and frameSize fields of the StreamConfiguration at
> configuration validation time instead of at camera configuration time.
> This allows applications to get the stride when trying a configuration
> without modifying the active configuration of the camera.
> 
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
> Changes in v4:
> - mention motivation in commit message
> - get stride and frameSize from tryFormat on capture video node
> 
> New in v3
> ---
>  src/libcamera/pipeline/vimc/vimc.cpp | 23 ++++++++++++++++++-----
>  1 file changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
> index b653066..a6f457c 100644
> --- a/src/libcamera/pipeline/vimc/vimc.cpp
> +++ b/src/libcamera/pipeline/vimc/vimc.cpp
> @@ -72,9 +72,12 @@ public:
>  class VimcCameraConfiguration : public CameraConfiguration
>  {
>  public:
> -	VimcCameraConfiguration();
> +	VimcCameraConfiguration(VimcCameraData *data);
>  
>  	Status validate() override;
> +
> +private:
> +	VimcCameraData *data_;
>  };
>  
>  class PipelineHandlerVimc : public PipelineHandler
> @@ -115,8 +118,8 @@ static const std::map<PixelFormat, uint32_t> pixelformats{
>  
>  } /* namespace */
>  
> -VimcCameraConfiguration::VimcCameraConfiguration()
> -	: CameraConfiguration()
> +VimcCameraConfiguration::VimcCameraConfiguration(VimcCameraData *data)
> +	: CameraConfiguration(), data_(data)
>  {
>  }
>  
> @@ -160,6 +163,17 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()
>  
>  	cfg.bufferCount = 4;
>  
> +	V4L2DeviceFormat format = {};
> +	format.fourcc = data_->video_->toV4L2PixelFormat(cfg.pixelFormat);
> +	format.size = cfg.size;
> +
> +	int ret = data_->video_->tryFormat(&format);
> +	if (ret)
> +		return Invalid;
> +
> +	cfg.stride = format.planes[0].bpl;
> +	cfg.frameSize = format.planes[0].size;
> +
>  	return status;
>  }
>  
> @@ -171,8 +185,8 @@ PipelineHandlerVimc::PipelineHandlerVimc(CameraManager *manager)
>  CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,
>  	const StreamRoles &roles)
>  {
> -	CameraConfiguration *config = new VimcCameraConfiguration();
>  	VimcCameraData *data = cameraData(camera);
> +	CameraConfiguration *config = new VimcCameraConfiguration(data);
>  
>  	if (roles.empty())
>  		return config;
> @@ -282,7 +296,6 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)
>  		return ret;
>  
>  	cfg.setStream(&data->stream_);
> -	cfg.stride = format.planes[0].bpl;
>  
>  	return 0;
>  }

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list