Patch Detail
Show a patch.
GET /api/patches/2933/?format=api
{ "id": 2933, "url": "https://patchwork.libcamera.org/api/patches/2933/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2933/", "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": "<20200229164254.23604-16-laurent.pinchart@ideasonboard.com>", "date": "2020-02-29T16:42:38", "name": "[libcamera-devel,15/31] libcamera: controls: Expose raw data in ControlValue", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "19c22514be7df7d9d982baba666526ecf4edebe9", "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/2933/mbox/", "series": [ { "id": 696, "url": "https://patchwork.libcamera.org/api/series/696/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=696", "date": "2020-02-29T16:42:23", "name": "libcamera: Add support for array controls", "version": 1, "mbox": "https://patchwork.libcamera.org/series/696/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2933/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2933/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D987627AB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Feb 2020 17:43:27 +0100 (CET)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0672FA49\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Feb 2020 17:43:26 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1582994607;\n\tbh=Jr+UsjTu+IpR948LvDC61E8yrlBuGmxw5fm5LwXPVT4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=BPhPuXgoKDXIBPRlADGlaJKCDrNiZyypkK4UCkNLhAcn40AeZ2o4Kd7HdxhR5PFXi\n\t+xH5+ablleNHy1m66XXawEJAyoVLvOpCEtIgQIFM91DfJvvjFQUbgbOe8toQSgYEmh\n\tBc/I7wB00UhIpa4vt2btBLKudXOtoGvw2nzPQBzQ=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 29 Feb 2020 18:42:38 +0200", "Message-Id": "<20200229164254.23604-16-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200229164254.23604-1-laurent.pinchart@ideasonboard.com>", "References": "<20200229164254.23604-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 15/31] libcamera: controls: Expose raw\n\tdata in ControlValue", "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": "Sat, 29 Feb 2020 16:43:31 -0000" }, "content": "Add a data() function to the ControlValue class to expose the raw data\nstored by the class as a Span<const uint8_t>. This will be useful to\nsimplify the serialization of ControlValue instances.\n\nThe size computation for the raw data is moved from the\nControlSerializer, which is updated accordingly to use the data()\nfunction in order to access the size. Simplification of the\nControlSerializer will happen in a subsequent change.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/controls.h | 3 +++\n src/libcamera/control_serializer.cpp | 13 +------------\n src/libcamera/controls.cpp | 23 +++++++++++++++++++++++\n 3 files changed, 27 insertions(+), 12 deletions(-)", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 6f0ebf4f3ca5..4538be06af93 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -12,6 +12,8 @@\n #include <string>\n #include <unordered_map>\n \n+#include <libcamera/span.h>\n+\n namespace libcamera {\n \n class ControlValidator;\n@@ -65,6 +67,7 @@ public:\n \n \tControlType type() const { return type_; }\n \tbool isNone() const { return type_ == ControlTypeNone; }\n+\tSpan<const uint8_t> data() const;\n \n \tstd::string toString() const;\n \ndiff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp\nindex 803ac16c2456..2b66ab978f81 100644\n--- a/src/libcamera/control_serializer.cpp\n+++ b/src/libcamera/control_serializer.cpp\n@@ -27,17 +27,6 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(Serializer)\n \n-namespace {\n-\n-static constexpr size_t ControlValueSize[] = {\n-\t[ControlTypeNone]\t= 1,\n-\t[ControlTypeBool]\t= sizeof(bool),\n-\t[ControlTypeInteger32]\t= sizeof(int32_t),\n-\t[ControlTypeInteger64]\t= sizeof(int64_t),\n-};\n-\n-} /* namespace */\n-\n /**\n * \\class ControlSerializer\n * \\brief Serializer and deserializer for control-related classes\n@@ -106,7 +95,7 @@ void ControlSerializer::reset()\n \n size_t ControlSerializer::binarySize(const ControlValue &value)\n {\n-\treturn ControlValueSize[value.type()];\n+\treturn value.data().size_bytes();\n }\n \n size_t ControlSerializer::binarySize(const ControlRange &range)\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 76230a052de1..b2331ab7540d 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -47,6 +47,17 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(Controls)\n \n+namespace {\n+\n+static constexpr size_t ControlValueSize[] = {\n+\t[ControlTypeNone]\t\t= 1,\n+\t[ControlTypeBool]\t\t= sizeof(bool),\n+\t[ControlTypeInteger32]\t\t= sizeof(int32_t),\n+\t[ControlTypeInteger64]\t\t= sizeof(int64_t),\n+};\n+\n+} /* namespace */\n+\n /**\n * \\enum ControlType\n * \\brief Define the data type of a Control\n@@ -91,6 +102,18 @@ ControlValue::ControlValue()\n * \\return True if the value type is ControlTypeNone, false otherwise\n */\n \n+/**\n+ * \\brief Retrieve the raw of a control value\n+ * \\return The raw data of the control value as a span of uint8_t\n+ */\n+Span<const uint8_t> ControlValue::data() const\n+{\n+\treturn {\n+\t\treinterpret_cast<const uint8_t *>(&bool_),\n+\t\tControlValueSize[type_]\n+\t};\n+}\n+\n /**\n * \\brief Assemble and return a string describing the value\n * \\return A string describing the ControlValue\n", "prefixes": [ "libcamera-devel", "15/31" ] }