[libcamera-devel] [PATCH] libcamera: vimc: Adjust crop rectangle

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri May 1 18:19:09 CEST 2020


Hi Jacopo,

Thank you for the patch.

On Fri, May 01, 2020 at 05:16:51PM +0200, Jacopo Mondi wrote:
> Since the Linux kernel commit:
> 69e39d40587b ("media: vimc: Implement get/set selection in sink")
> the crop rectangle on the VIMC scaler sink pad needs to be
> reset to match the requested format to avoid hitting a pipeline format
> mis-configurations when the applied format is larger than the one

s/mis-configurations/misconfiguration/

> set in a previous capture session.
> 
> As the V4L2 specification is not clear on what the correct behaviour
> is, if the crop rectangle should be reset automatically or not on a
> set_fmt operation, momentary fix the pipeline handler to please the
> driver and manually reset the crop rectangle.
> 
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>

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

> ---
> 
> Tested on v5.6, please test on older kernel releases.

I'll test it now.

> 
> ---
>  src/libcamera/pipeline/vimc/vimc.cpp | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
> index ccfd7f86d158..339d1cf653fb 100644
> --- a/src/libcamera/pipeline/vimc/vimc.cpp
> +++ b/src/libcamera/pipeline/vimc/vimc.cpp
> @@ -224,6 +224,16 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)
>  	if (ret)
>  		return ret;
> 
> +	Rectangle crop = {
> +		.x = 0,
> +		.y = 0,
> +		.width = subformat.size.width,
> +		.height = subformat.size.height,
> +	};
> +	ret = data->scaler_->setSelection(0, V4L2_SEL_TGT_CROP, &crop);
> +	if (ret && ret != -ENOTTY)
> +		return ret;
> +
>  	subformat.size = cfg.size;
>  	ret = data->scaler_->setFormat(1, &subformat);
>  	if (ret)

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list