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 <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi
2020-05-01 17:09:37 +02:00
committed by Laurent Pinchart
parent 4d50cc9404
commit 5888918153

View File

@@ -12,6 +12,7 @@
#include <tuple>
#include <linux/media-bus-format.h>
#include <linux/version.h>
#include <ipa/ipa_interface.h>
#include <ipa/ipa_module_info.h>
@@ -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)