Show a patch.

GET /api/patches/3572/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 3572,
    "url": "https://patchwork.libcamera.org/api/patches/3572/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3572/",
    "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": "<20200427213236.333777-4-jacopo@jmondi.org>",
    "date": "2020-04-27T21:32:32",
    "name": "[libcamera-devel,v4,3/7] libcamera: v4l2_subdevice: Implement getSelection()",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "e5f50453d841de7193d0961292ad63b6f7bb870b",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3572/mbox/",
    "series": [
        {
            "id": 837,
            "url": "https://patchwork.libcamera.org/api/series/837/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=837",
            "date": "2020-04-27T21:32:29",
            "name": "libcamera: Add CameraSensorInfo",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/837/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3572/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3572/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 AC59F6121D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Apr 2020 23:29:34 +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 D732740007;\n\tMon, 27 Apr 2020 21:29:33 +0000 (UTC)"
        ],
        "X-Originating-IP": "212.216.150.148",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 27 Apr 2020 23:32:32 +0200",
        "Message-Id": "<20200427213236.333777-4-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.26.1",
        "In-Reply-To": "<20200427213236.333777-1-jacopo@jmondi.org>",
        "References": "<20200427213236.333777-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 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": "Mon, 27 Apr 2020 21:29:35 -0000"
    },
    "content": "Implement V4L2Subdevice::getSelection() to support retrieving selection\nrectangles from the v4l2 subdevice.\n\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",
        "v4",
        "3/7"
    ]
}