Show a patch.

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

{
    "id": 1564,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/1564/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1564/",
    "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": "<20190701201504.28487-6-laurent.pinchart@ideasonboard.com>",
    "date": "2019-07-01T20:14:56",
    "name": "[libcamera-devel,v4,05/13] libcamera: controls: Extend ControlList to access controls by ID",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c3cfd11a5f73a38bbf3f02bc08d7327db63b4e9e",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/1564/mbox/",
    "series": [
        {
            "id": 386,
            "url": "https://patchwork.libcamera.org/api/1.1/series/386/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=386",
            "date": "2019-07-01T20:14:51",
            "name": "libcamera Controls",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/386/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1564/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1564/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0EFD461F5D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Jul 2019 22:15:30 +0200 (CEST)",
            "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A72F3524\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Jul 2019 22:15:29 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562012129;\n\tbh=gzY+WTMrt6THi+MJDLwq3yf0fYjtI98VzNuphVal/Oo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=kNFvimjHJMy/fVE+PI0u6vXHKhO6bgVSmc+3wn4NuMe8b5eUXIB5bwSiQh1UggjeQ\n\tohmtIsRI3jG1GlFl+Aec1pKj1WBkbrj8UR5419gbMIz2s2kX0XzhmzHEzPf76u+wYy\n\t03AspPhc3R0kgAG8IHrCrI6sBGfjo8kFhD6Wo1Pw=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon,  1 Jul 2019 23:14:56 +0300",
        "Message-Id": "<20190701201504.28487-6-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190701201504.28487-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20190701201504.28487-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 05/13] libcamera: controls: Extend\n\tControlList to access controls by ID",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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, 01 Jul 2019 20:15:31 -0000"
    },
    "content": "The ControlList class implements a map from control specifier to control\nID. To avoid constant lookups of ControlInfo when using the class in the\nlibcamera core or in pipeline handlers, the map uses ControlInfo\npointers instead of ControlId values. This is however not very\nconvenient for applications or pipeline handlers, as they would be\nforced to first look up the ControlInfo pointers for the controls they\nwant to access. Facilitate ease of use of ControlLists by implementing\nan internal lookup of the ControlInfo from the controls provided by the\nCamera.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges since v3:\n\n- Typo fixes\n---\n include/libcamera/controls.h |  2 ++\n src/libcamera/controls.cpp   | 54 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 56 insertions(+)",
    "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 18293c9462cf..fbb3a62274c6 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -117,11 +117,13 @@ public:\n \tconst_iterator begin() const { return controls_.begin(); }\n \tconst_iterator end() const { return controls_.end(); }\n \n+\tbool contains(ControlId id) const;\n \tbool contains(const ControlInfo *info) const;\n \tbool empty() const { return controls_.empty(); }\n \tstd::size_t size() const { return controls_.size(); }\n \tvoid clear() { controls_.clear(); }\n \n+\tControlValue &operator[](ControlId id);\n \tControlValue &operator[](const ControlInfo *info) { return controls_[info]; }\n \n \tvoid update(const ControlList &list);\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex cd2cf337b379..42a2f8990bf6 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -10,6 +10,8 @@\n #include <sstream>\n #include <string>\n \n+#include <libcamera/camera.h>\n+\n #include \"log.h\"\n #include \"utils.h\"\n \n@@ -387,6 +389,30 @@ ControlList::ControlList(Camera *camera)\n  * list\n  */\n \n+/**\n+ * \\brief Check if the list contains a control with the specified \\a id\n+ * \\param[in] id The control ID\n+ *\n+ * The behaviour is undefined if the control \\a id is not supported by the\n+ * camera that the ControlList refers to.\n+ *\n+ * \\return True if the list contains a matching control, false otherwise\n+ */\n+bool ControlList::contains(ControlId id) const\n+{\n+\tconst ControlInfoMap &controls = camera_->controls();\n+\tconst auto iter = controls.find(id);\n+\tif (iter == controls.end()) {\n+\t\tLOG(Controls, Error)\n+\t\t\t<< \"Camera \" << camera_->name()\n+\t\t\t<< \" does not support control \" << id;\n+\n+\t\treturn false;\n+\t}\n+\n+\treturn controls_.find(&iter->second) != controls_.end();\n+}\n+\n /**\n  * \\brief Check if the list contains a control with the specified \\a info\n  * \\param[in] info The control info\n@@ -414,6 +440,34 @@ bool ControlList::contains(const ControlInfo *info) const\n  * \\brief Removes all controls from the list\n  */\n \n+/**\n+ * \\brief Access or insert the control specified by \\a id\n+ * \\param[in] id The control ID\n+ *\n+ * This method returns a reference to the control identified by \\a id, inserting\n+ * it in the list if the ID is not already present.\n+ *\n+ * The behaviour is undefined if the control \\a id is not supported by the\n+ * camera that the ControlList refers to.\n+ *\n+ * \\return A reference to the value of the control identified by \\a id\n+ */\n+ControlValue &ControlList::operator[](ControlId id)\n+{\n+\tconst ControlInfoMap &controls = camera_->controls();\n+\tconst auto iter = controls.find(id);\n+\tif (iter == controls.end()) {\n+\t\tLOG(Controls, Error)\n+\t\t\t<< \"Camera \" << camera_->name()\n+\t\t\t<< \" does not support control \" << id;\n+\n+\t\tstatic ControlValue empty;\n+\t\treturn empty;\n+\t}\n+\n+\treturn controls_[&iter->second];\n+}\n+\n /**\n  * \\fn ControlList::operator[](const ControlInfo *info)\n  * \\brief Access or insert the control specified by \\a info\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "05/13"
    ]
}