Show a patch.

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

{
    "id": 3527,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3527/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3527/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20200424215304.558317-10-jacopo@jmondi.org>",
    "date": "2020-04-24T21:53:00",
    "name": "[libcamera-devel,v3,09/13] libcamera: v4l2_device: Add method to read a control",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "e9fb6312edb2e225a2403c74b89010c232567b39",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3527/mbox/",
    "series": [
        {
            "id": 822,
            "url": "https://patchwork.libcamera.org/api/1.1/series/822/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=822",
            "date": "2020-04-24T21:52:51",
            "name": "libcamera: Add CameraSensorInfo",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/822/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3527/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3527/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2194C62E5D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2020 23:50:13 +0200 (CEST)",
            "from uno.homenet.telecomitalia.it\n\t(host240-55-dynamic.3-87-r.retail.telecomitalia.it [87.3.55.240])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 4F43060002;\n\tFri, 24 Apr 2020 21:50:12 +0000 (UTC)"
        ],
        "X-Originating-IP": "87.3.55.240",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 24 Apr 2020 23:53:00 +0200",
        "Message-Id": "<20200424215304.558317-10-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.26.1",
        "In-Reply-To": "<20200424215304.558317-1-jacopo@jmondi.org>",
        "References": "<20200424215304.558317-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 09/13] libcamera: v4l2_device: Add\n\tmethod to read a control",
        "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": "Fri, 24 Apr 2020 21:50:13 -0000"
    },
    "content": "Add a method to the V4L2Device class to read a single control from a\ndevice.\n\nThe current procedure to read a V4L2 Control from a device requires the\nuser to setup a list and populate it using ControlList::set(), with a\nvalue that is ignored if the only interest is reading the control out.\n\nProvide a method to read a single control by just providing its id.\nThe newly added method only supports non-span e non-string control but\ncould be easily expanded later.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_device.h | 18 ++++++++++++++++++\n src/libcamera/v4l2_device.cpp       | 11 +++++++++++\n 2 files changed, 29 insertions(+)",
    "diff": "diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex ce8edd98a01d..23cff08bbfd0 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -11,6 +11,7 @@\n #include <memory>\n #include <vector>\n \n+#include <libcamera/controls.h>\n #include <linux/videodev2.h>\n \n #include \"log.h\"\n@@ -27,6 +28,23 @@ public:\n \tconst ControlInfoMap &controls() const { return controls_; }\n \n \tint getControls(ControlList *ctrls);\n+\ttemplate<typename T, typename std::enable_if_t<!details::is_span<T>::value &&\n+\t\t\t\t\t\t       !std::is_same<std::string, std::remove_cv_t<T>>::value,\n+\t\t\t\t\t\t       std::nullptr_t> = nullptr>\n+\tint getControl(unsigned int id, T *val)\n+\t{\n+\t\tControlList list(controls_);\n+\t\t/* Reuse 'val' as we're only interested in reading. */\n+\t\tlist.set(id, *val);\n+\n+\t\tint ret = getControls(&list);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t\t*val = list.get(id).get<T>();\n+\n+\t\treturn 0;\n+\t}\n+\n \tint setControls(ControlList *ctrls);\n \n \tconst std::string &deviceNode() const { return deviceNode_; }\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 03e305165096..9d67e0f63b1e 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -242,6 +242,17 @@ int V4L2Device::getControls(ControlList *ctrls)\n \treturn ret;\n }\n \n+/**\n+ * \\fn int V4L2Device::getControl(unsigned int id, T *val) const\n+ * \\brief Get the value of the V4L2 control \\a id from the device\n+ * \\param[in] id The V4L2 control ID\n+ * \\param[out] val The control value\n+ *\n+ * \\todo This only supports non-span and non-string controls.\n+ *\n+ * \\return 0 on success, a negative error code otherwise\n+ */\n+\n /**\n  * \\brief Write controls to the device\n  * \\param[in] ctrls The list of controls to write\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "09/13"
    ]
}