From 58889181538a4458ba3b012f1c69a98138447a2e Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 1 May 2020 17:09:37 +0200 Subject: libcamera: vimc: Adjust crop rectangle 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 misconfiguration 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 Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/vimc/vimc.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/libcamera/pipeline/vimc') diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index d9f53adb..128301e3 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -226,6 +227,18 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config) if (ret) return ret; + if (data->media_->version() >= KERNEL_VERSION(5, 6, 0)) { + 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) + return ret; + } + subformat.size = cfg.size; ret = data->scaler_->setFormat(1, &subformat); if (ret) -- cgit v1.2.1