summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-05-01 17:09:37 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-02 01:35:18 +0300
commit58889181538a4458ba3b012f1c69a98138447a2e (patch)
tree3f4a6c973b624008e945877e99436822cf34cb68
parent4d50cc9404353810ecc890cca969cbd7dad000df (diff)
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>
-rw-r--r--src/libcamera/pipeline/vimc/vimc.cpp13
1 files changed, 13 insertions, 0 deletions
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 <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)