{"id":3589,"url":"https://patchwork.libcamera.org/api/patches/3589/?format=json","web_url":"https://patchwork.libcamera.org/patch/3589/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20200428091934.341550-3-jacopo@jmondi.org>","date":"2020-04-28T09:19:30","name":"[libcamera-devel,v5,3/7] libcamera: v4l2_subdevice: Implement getSelection()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"e5f50453d841de7193d0961292ad63b6f7bb870b","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3589/mbox/","series":[{"id":842,"url":"https://patchwork.libcamera.org/api/series/842/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=842","date":"2020-04-28T09:17:13","name":"libcamera: Add CameraSensorInfo","version":5,"mbox":"https://patchwork.libcamera.org/series/842/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3589/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3589/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 13136603F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Apr 2020 11:16:36 +0200 (CEST)","from uno.homenet.telecomitalia.it (a-ur1-85.tin.it\n\t[212.216.150.148]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id D97B14000C;\n\tTue, 28 Apr 2020 09:16:34 +0000 (UTC)"],"X-Originating-IP":"212.216.150.148","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 28 Apr 2020 11:19:30 +0200","Message-Id":"<20200428091934.341550-3-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.26.1","In-Reply-To":"<20200428091934.341550-1-jacopo@jmondi.org>","References":"<20200428091934.341550-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 3/7] libcamera: v4l2_subdevice:\n\tImplement getSelection()","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>","X-List-Received-Date":"Tue, 28 Apr 2020 09:16:36 -0000"},"content":"Implement V4L2Subdevice::getSelection() to support retrieving selection\nrectangles from the V4L2 subdevice.\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_subdevice.h |  2 ++\n src/libcamera/v4l2_subdevice.cpp       | 33 ++++++++++++++++++++++++++\n 2 files changed, 35 insertions(+)","diff":"diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex 9a5c812db9b6..27ba5b17f61e 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -46,6 +46,8 @@ public:\n \n \tconst MediaEntity *entity() const { return entity_; }\n \n+\tint getSelection(unsigned int pad, unsigned int target,\n+\t\t\t Rectangle *rect);\n \tint setSelection(unsigned int pad, unsigned int target,\n \t\t\t Rectangle *rect);\n \ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 432e89eacbd3..74788ce7cf4f 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -133,6 +133,39 @@ int V4L2Subdevice::open()\n  * \\return The subdevice's associated media entity.\n  */\n \n+/**\n+ * \\brief Get selection rectangle \\a rect for \\a target\n+ * \\param[in] pad The 0-indexed pad number the rectangle is retrieved from\n+ * \\param[in] target The selection target defined by the V4L2_SEL_TGT_* flags\n+ * \\param[out] rect The retrieved selection rectangle\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2Subdevice::getSelection(unsigned int pad, unsigned int target,\n+\t\t\t\tRectangle *rect)\n+{\n+\tstruct v4l2_subdev_selection sel = {};\n+\n+\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n+\tsel.pad = pad;\n+\tsel.target = target;\n+\tsel.flags = 0;\n+\n+\tint ret = ioctl(VIDIOC_SUBDEV_G_SELECTION, &sel);\n+\tif (ret < 0) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Unable to get rectangle \" << target << \" on pad \"\n+\t\t\t<< pad << \": \" << 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 selection rectangle \\a rect for \\a target\n  * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\n","prefixes":["libcamera-devel","v5","3/7"]}