[libcamera-devel] [PATCH] libcamera: vimc: Adjust crop rectangle
Niklas Söderlund
niklas.soderlund at ragnatech.se
Fri May 1 17:24:15 CEST 2020
Hi Jacopo,
Thanks for your work.
On 2020-05-01 17:16:51 +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
> 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: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
>
> Tested on v5.6, please test on older kernel releases.
>
> ---
> 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)
> --
> 2.26.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list