Patch Detail
Show a patch.
GET /api/1.1/patches/2130/?format=api
{ "id": 2130, "url": "https://patchwork.libcamera.org/api/1.1/patches/2130/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2130/", "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": "<20191007224642.6597-3-laurent.pinchart@ideasonboard.com>", "date": "2019-10-07T22:46:35", "name": "[libcamera-devel,2/9] libcamera: controls: Support getting and setting controls by ControlId", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "e5ae4a489212ce08f6d5972c9c8d1f707ea50814", "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/2130/mbox/", "series": [ { "id": 526, "url": "https://patchwork.libcamera.org/api/1.1/series/526/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=526", "date": "2019-10-07T22:46:33", "name": "Use ControlList for both libcamera and V4L2 controls", "version": 1, "mbox": "https://patchwork.libcamera.org/series/526/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2130/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2130/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 B764560E1F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Oct 2019 00:46:52 +0200 (CEST)", "from pendragon.ideasonboard.com\n\t(modemcable118.64-20-96.mc.videotron.ca [96.20.64.118])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D8A8AB2D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Oct 2019 00:46:51 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570488412;\n\tbh=l7hpykS7uvEgF6n4GRYEzSmexVZKkNXXwkjQMQ9sanY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=fqx2TNzQJwROO85aGJHCNvRVDfGp2CDQR46+9xDDgbTQbtNS/Amv7goupFnUe/ftU\n\tIogNbMg4bVIKk4xL4XBnMey4TLa0DausB70sYEUfyWJgcOf8AGpnP/73+ANosTfqx5\n\tFUwo1oJ5k3xMxGmCJQXRXlojKLDp/VX1mZ+NzMaU=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 8 Oct 2019 01:46:35 +0300", "Message-Id": "<20191007224642.6597-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20191007224642.6597-1-laurent.pinchart@ideasonboard.com>", "References": "<20191007224642.6597-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/9] libcamera: controls: Support getting\n\tand setting controls by ControlId", "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, 07 Oct 2019 22:46:53 -0000" }, "content": "The ControlList class has template get() and set() methods to get and\nset control values. The methods require a reference to a Control\ninstance, which is only available when calling them with a hardcoded\ncontrol. In order to support serialisation and deserialisation of\nControlList, we need a way to get and set control values based on a\nControlId. Add new get() and set() overload methods to do so.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/controls.h | 3 +++\n src/libcamera/controls.cpp | 46 ++++++++++++++++++++++++++++++++++--\n 2 files changed, 47 insertions(+), 2 deletions(-)", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 90426753f40f..49ff1a6f747f 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -156,6 +156,9 @@ public:\n \t\tval->set<T>(value);\n \t}\n \n+\tconst ControlValue &get(const ControlId &id) const;\n+\tvoid set(const ControlId &id, const ControlValue &value);\n+\n private:\n \tconst ControlValue *find(const ControlId &id) const;\n \tControlValue *find(const ControlId &id);\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex f3260edce0bc..f862a09adef9 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -445,7 +445,7 @@ bool ControlList::contains(const ControlId &id) const\n */\n \n /**\n- * \\fn template<typename T> const T &ControlList::get() const\n+ * \\fn template<typename T> const T &ControlList::get(const Control<T> &ctrl) const\n * \\brief Get the value of a control\n * \\param[in] ctrl The control\n *\n@@ -460,7 +460,7 @@ bool ControlList::contains(const ControlId &id) const\n */\n \n /**\n- * \\fn template<typename T> void ControlList::set()\n+ * \\fn template<typename T> void ControlList::set(const Control< T > &ctrl, const T &value)\n * \\brief Set the control value to \\a value\n * \\param[in] ctrl The control\n * \\param[in] value The control value\n@@ -473,6 +473,48 @@ bool ControlList::contains(const ControlId &id) const\n * camera that the list refers to.\n */\n \n+/**\n+ * \\brief Get the value of control \\a id\n+ * \\param[in] id The control ID\n+ *\n+ * The behaviour is undefined if the control \\a id is not present in the list.\n+ * Use ControlList::contains() to test for the presence of a control in the\n+ * list before retrieving its value.\n+ *\n+ * \\return The control value\n+ */\n+const ControlValue &ControlList::get(const ControlId &id) const\n+{\n+\tconst ControlValue *val = find(id);\n+\tif (!val) {\n+\t\tstatic ControlValue zero;\n+\t\treturn zero;\n+\t}\n+\n+\treturn *val;\n+}\n+\n+/**\n+ * \\brief Set the value of control \\a id to \\a value\n+ * \\param[in] id The control ID\n+ * \\param[in] value The control value\n+ *\n+ * This method sets the value of a control in the control list. If the control\n+ * is already present in the list, its value is updated, otherwise it is added\n+ * to the list.\n+ *\n+ * The behaviour is undefined if the control \\a ctrl is not supported by the\n+ * camera that the list refers to.\n+ */\n+void ControlList::set(const ControlId &id, const ControlValue &value)\n+{\n+\tControlValue *val = find(id);\n+\tif (!val)\n+\t\treturn;\n+\n+\t*val = value;\n+}\n+\n const ControlValue *ControlList::find(const ControlId &id) const\n {\n \tconst auto iter = controls_.find(&id);\n", "prefixes": [ "libcamera-devel", "2/9" ] }