{"id":20067,"url":"https://patchwork.libcamera.org/api/1.1/patches/20067/?format=json","web_url":"https://patchwork.libcamera.org/patch/20067/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240519081539.29832-3-umang.jain@ideasonboard.com>","date":"2024-05-19T08:15:37","name":"[2/4] libcamera: converter_v4l2_m2m: Support crop selection","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e159f07f9e6971a43afb82469e37863a8278a564","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20067/mbox/","series":[{"id":4314,"url":"https://patchwork.libcamera.org/api/1.1/series/4314/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4314","date":"2024-05-19T08:15:35","name":"libcamera: rkisp1: Plumb i.MX8MP DW100 dewarper","version":1,"mbox":"https://patchwork.libcamera.org/series/4314/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20067/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20067/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id ABBBDBD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 19 May 2024 08:15:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 00C4C6347E;\n\tSun, 19 May 2024 10:15:54 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EADDD63480\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 19 May 2024 10:15:50 +0200 (CEST)","from fedora.local (unknown\n\t[IPv6:2405:201:2015:f873:9278:2c85:fd02:c5f5])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A51B85A4;\n\tSun, 19 May 2024 10:15:39 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"cW2wULCg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716106540;\n\tbh=ZyOTc94RM3gN+8FzYyzXlDr4n2wQ/pw8HRPfwnqXfvo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=cW2wULCg0Jta+eaeMb58naLhjcYo1PWV7QTIKQU+71o/H5fEE4UtJg6VIzN0S9Oky\n\tk7Hp4K1dIJaYterVcSCRAuKre/NfokSk+L5iMSMS9kLhLNrL5OG2W4I8GVdn4pJzPL\n\t6ryNSF9Z8yEy5GRULJd/7xMT5hzs5VvGm7TVc5L8=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Umang Jain <umang.jain@ideasonboard.com>","Subject":"[PATCH 2/4] libcamera: converter_v4l2_m2m: Support crop selection","Date":"Sun, 19 May 2024 13:45:37 +0530","Message-ID":"<20240519081539.29832-3-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.44.0","In-Reply-To":"<20240519081539.29832-1-umang.jain@ideasonboard.com>","References":"<20240519081539.29832-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a helper to set selection rectangle on the video node\nto support cropping and scaling capabilites.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n .../internal/converter/converter_v4l2_m2m.h   |  5 ++++\n .../converter/converter_v4l2_m2m.cpp          | 26 +++++++++++++++++++\n 2 files changed, 31 insertions(+)","diff":"diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h\nindex 1126050c..acc6424c 100644\n--- a/include/libcamera/internal/converter/converter_v4l2_m2m.h\n+++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h\n@@ -29,6 +29,7 @@ class MediaDevice;\n class Size;\n class SizeRange;\n struct StreamConfiguration;\n+class Rectangle;\n class V4L2M2MDevice;\n \n class V4L2M2MConverter : public Converter\n@@ -56,6 +57,8 @@ public:\n \tint queueBuffers(FrameBuffer *input,\n \t\t\t const std::map<unsigned int, FrameBuffer *> &outputs);\n \n+\tint setSelection(unsigned int output, unsigned int target, Rectangle *rect);\n+\n private:\n \tclass Stream : protected Loggable\n \t{\n@@ -74,6 +77,8 @@ private:\n \n \t\tint queueBuffers(FrameBuffer *input, FrameBuffer *output);\n \n+\t\tint setSelection(unsigned int target, Rectangle *rect);\n+\n \tprotected:\n \t\tstd::string logPrefix() const override;\n \ndiff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp\nindex d8929fc5..2d3ee257 100644\n--- a/src/libcamera/converter/converter_v4l2_m2m.cpp\n+++ b/src/libcamera/converter/converter_v4l2_m2m.cpp\n@@ -155,6 +155,15 @@ int V4L2M2MConverter::Stream::queueBuffers(FrameBuffer *input, FrameBuffer *outp\n \treturn 0;\n }\n \n+int V4L2M2MConverter::Stream::setSelection(unsigned int target, Rectangle *rect)\n+{\n+\tint ret = m2m_->output()->setSelection(target, rect);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n std::string V4L2M2MConverter::Stream::logPrefix() const\n {\n \treturn \"stream\" + std::to_string(index_);\n@@ -370,6 +379,23 @@ int V4L2M2MConverter::exportBuffers(unsigned int output, unsigned int count,\n \treturn streams_[output].exportBuffers(count, buffers);\n }\n \n+/**\n+ * \\brief Set a selection rectangle \\a rect for \\a target\n+ * \\param[in] output Index of the output stream\n+ * \\param[in] target The selection target defined by the V4L2_SEL_TGT_* flags\n+ * \\param[inout] rect The selection rectangle to be applied\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2M2MConverter::setSelection(unsigned int output, unsigned int target,\n+\t\t\t\t   Rectangle *rect)\n+{\n+\tif (output >= streams_.size())\n+\t\treturn -EINVAL;\n+\n+\treturn streams_[output].setSelection(target, rect);\n+}\n+\n /**\n  * \\copydoc libcamera::Converter::start\n  */\n","prefixes":["2/4"]}