From patchwork Fri May 1 15:16:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3650 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CEC6603F3 for ; Fri, 1 May 2020 17:13:46 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from localhost.localdomain (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id EF4C31BF204; Fri, 1 May 2020 15:13:45 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 1 May 2020 17:16:51 +0200 Message-Id: <20200501151651.864358-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.26.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: vimc: Adjust crop rectangle X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2020 15:13:46 -0000 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 Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Tested-by: Laurent Pinchart # on v5.4.28 --- Tested on v5.6, please test on older kernel releases. --- src/libcamera/pipeline/vimc/vimc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.26.1 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)