Patch Detail
Show a patch.
GET /api/patches/1548/?format=api
{ "id": 1548, "url": "https://patchwork.libcamera.org/api/patches/1548/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1548/", "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": "<20190630233817.10130-7-laurent.pinchart@ideasonboard.com>", "date": "2019-06-30T23:38:09", "name": "[libcamera-devel,v3,06/14] libcamera: controls: Extend ControlList to access controls by ID", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "6342aed64774c3a998b42a6fa03842727ea73853", "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/1548/mbox/", "series": [ { "id": 384, "url": "https://patchwork.libcamera.org/api/series/384/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=384", "date": "2019-06-30T23:38:03", "name": "libcamera Controls", "version": 3, "mbox": "https://patchwork.libcamera.org/series/384/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1548/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1548/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 8C8EF61F61\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 1 Jul 2019 01:38:44 +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 37DBB2F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 1 Jul 2019 01:38:44 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1561937924;\n\tbh=BVBYFu6vhfXllwt0xV1LM/j7sKp//ptRiAWJEu60Rlo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=U0lnhRxaeYY/wl62pwxSVbzDRSxGOGZ1kN/NGwGBhTfiRfh23iLCMkSs8kOSckXrl\n\tmLCCeo3hFgG7PZFfl+sAJ/Ddmm6/zfBREziiASjR55/Eos5pvjKZ1s9nDSPV0lm0gJ\n\tC2j19FfL06vBPDErbPbJaDtyPl7/qFCPznTBk7Lo=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 1 Jul 2019 02:38:09 +0300", "Message-Id": "<20190630233817.10130-7-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190630233817.10130-1-laurent.pinchart@ideasonboard.com>", "References": "<20190630233817.10130-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 06/14] 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": "Sun, 30 Jun 2019 23:38:45 -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.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/controls.h | 2 ++\n src/libcamera/controls.cpp | 57 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 59 insertions(+)", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 9b37dfb16b89..d827318ee0fa 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 { return controls_.count(info); };\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 e4c41b97a354..17e09fc7f153 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@@ -372,6 +374,30 @@ ControlList::ControlList(Camera *camera)\n * instance\n */\n \n+/**\n+ * \\brief Check if the ist 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 * \\fn ControlList::contains(const ControlInfo *info) const\n * \\brief Check if the ist contains a control with the specified \\a info\n@@ -396,6 +422,34 @@ ControlList::ControlList(Camera *camera)\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@@ -413,6 +467,9 @@ ControlList::ControlList(Camera *camera)\n *\n * Update all controls in the ControlList, by the values given by \\a list\n * If the list already contains a control of this ID then it will be overwritten\n+ *\n+ * The behaviour is undefined if the two lists refer to different Camera\n+ * instances.\n */\n void ControlList::update(const ControlList &list)\n {\n", "prefixes": [ "libcamera-devel", "v3", "06/14" ] }