Patch Detail
Show a patch.
GET /api/patches/21372/?format=api
{ "id": 21372, "url": "https://patchwork.libcamera.org/api/patches/21372/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21372/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20240925180713.27476-1-laurent.pinchart@ideasonboard.com>", "date": "2024-09-25T18:07:13", "name": "libcamera: v4l2_videodevice: Add getSelection() function", "commit_ref": "4cb3380f4d5615f041ed5698eb1fd12b2e46a720", "pull_url": null, "state": "accepted", "archived": false, "hash": "60826522928682ed5b8c68b3aa91051473f10aa2", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/21372/mbox/", "series": [ { "id": 4625, "url": "https://patchwork.libcamera.org/api/series/4625/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4625", "date": "2024-09-25T18:07:13", "name": "libcamera: v4l2_videodevice: Add getSelection() function", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4625/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21372/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21372/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 AA430C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Sep 2024 18:07:18 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9C6096350E;\n\tWed, 25 Sep 2024 20:07:17 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BDF14634F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Sep 2024 20:07:15 +0200 (CEST)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CD2705B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Sep 2024 20:05:47 +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=\"m6uQYd2f\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727287548;\n\tbh=zNd5CnW6BTLcawpOdUwpIU/EoHqANYyIg9RQCaC830Q=;\n\th=From:To:Subject:Date:From;\n\tb=m6uQYd2fayf3yYFqWiYSNUfd6JKLDChWwEYfEf7bLdmqd5ZcA2u37x5u0+NIKlx/H\n\teUq2aWlknvu+bib+xrxNVOiQw3Jb+JAOXJnkL0wDKo3N5MjHyGw5SXMlcM6uQMX2Qm\n\tstCTm2vtYXh4cPeaFi0+Ou+MSRCfZUEYnPHoGkdc=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH] libcamera: v4l2_videodevice: Add getSelection() function", "Date": "Wed, 25 Sep 2024 21:07:13 +0300", "Message-ID": "<20240925180713.27476-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.45.2", "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": "The V4L2VideoDevice class implements setSelection() but not\ngetSelection(). The latter is useful for instance to query crop bounds.\nImplement the function.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_videodevice.h | 1 +\n src/libcamera/v4l2_videodevice.cpp | 32 +++++++++++++++++++\n 2 files changed, 33 insertions(+)\n\n\nbase-commit: 8bcec687344e5cc2ccef1361c03b87f0fd2cc59b", "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 9057be08f18a..f021c2a0177b 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -208,6 +208,7 @@ public:\n \tint setFormat(V4L2DeviceFormat *format);\n \tFormats formats(uint32_t code = 0);\n \n+\tint getSelection(unsigned int target, Rectangle *rect);\n \tint setSelection(unsigned int target, Rectangle *rect);\n \n \tint allocateBuffers(unsigned int count,\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 93cb1697935e..14eba0561d6a 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1214,6 +1214,38 @@ std::vector<SizeRange> V4L2VideoDevice::enumSizes(V4L2PixelFormat pixelFormat)\n \treturn sizes;\n }\n \n+/**\n+ * \\brief Get the selection rectangle for \\a target\n+ * \\param[in] target The selection target defined by the V4L2_SEL_TGT_* flags\n+ * \\param[out] rect The selection rectangle to retrieve\n+ *\n+ * \\todo Define a V4L2SelectionTarget enum for the selection target\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2VideoDevice::getSelection(unsigned int target, Rectangle *rect)\n+{\n+\tstruct v4l2_selection sel = {};\n+\n+\tsel.type = bufferType_;\n+\tsel.target = target;\n+\tsel.flags = 0;\n+\n+\tint ret = ioctl(VIDIOC_G_SELECTION, &sel);\n+\tif (ret < 0) {\n+\t\tLOG(V4L2, Error) << \"Unable to get rectangle \" << target\n+\t\t\t\t << \": \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\trect->x = sel.r.left;\n+\trect->y = sel.r.top;\n+\trect->width = sel.r.width;\n+\trect->height = sel.r.height;\n+\n+\treturn 0;\n+}\n+\n /**\n * \\brief Set a selection rectangle \\a rect for \\a target\n * \\param[in] target The selection target defined by the V4L2_SEL_TGT_* flags\n", "prefixes": [] }