Patch Detail
Show a patch.
GET /api/patches/3001/?format=api
{ "id": 3001, "url": "https://patchwork.libcamera.org/api/patches/3001/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3001/", "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": "<20200306160002.30549-30-laurent.pinchart@ideasonboard.com>", "date": "2020-03-06T15:59:59", "name": "[libcamera-devel,v2,29/32] libcamera: control_serializer: Add support for array controls", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "a7cd84fb06c1cfa5abdfd1e5acc5d08887fbcd89", "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/3001/mbox/", "series": [ { "id": 703, "url": "https://patchwork.libcamera.org/api/series/703/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=703", "date": "2020-03-06T15:59:30", "name": "libcamera: Add support for array controls", "version": 2, "mbox": "https://patchwork.libcamera.org/series/703/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3001/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3001/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 76179628A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 6 Mar 2020 17:00: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 0EB3FA48;\n\tFri, 6 Mar 2020 17:00:27 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1583510427;\n\tbh=6koFU6JlzRHu8uQAgNwR89vLNf0jsUTxuw+NVjBWtXA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=M1VuD4cPRpt8shYnySnYNasZEW7/ugKkjkBVsFtybNtD19y+gyxiUwaOipsJefCvl\n\tIZbe3aH+QCuwoW+VXXUHHGFhR+DgIK9yFijGlQBRDFRpjW1VbYGOwQbdBZXiwOp1K1\n\t+JWUw6X8IrR+5v1Ypeg4uZetdushnJaBeZEB8UM4=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 6 Mar 2020 17:59:59 +0200", "Message-Id": "<20200306160002.30549-30-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200306160002.30549-1-laurent.pinchart@ideasonboard.com>", "References": "<20200306160002.30549-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 29/32] libcamera: control_serializer:\n\tAdd support for array controls", "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, 06 Mar 2020 16:00:28 -0000" }, "content": "From: Jacopo Mondi <jacopo@jmondi.org>\n\nAdd support for serializing and deserializing control values that store\narrays of values. The serialized format is extended to explicitly handle\narrays.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/control_serializer.cpp | 80 ++++++++++++----------\n src/libcamera/include/control_serializer.h | 6 +-\n 2 files changed, 49 insertions(+), 37 deletions(-)", "diff": "diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp\nindex b4c1ed410b92..004735fb2aa0 100644\n--- a/src/libcamera/control_serializer.cpp\n+++ b/src/libcamera/control_serializer.cpp\n@@ -14,6 +14,7 @@\n #include <ipa/ipa_controls.h>\n #include <libcamera/control_ids.h>\n #include <libcamera/controls.h>\n+#include <libcamera/span.h>\n \n #include \"byte_stream_buffer.h\"\n #include \"log.h\"\n@@ -279,8 +280,9 @@ int ControlSerializer::serialize(const ControlList &list,\n \n \t\tstruct ipa_control_value_entry entry;\n \t\tentry.id = id;\n-\t\tentry.count = 1;\n \t\tentry.type = value.type();\n+\t\tentry.is_array = value.isArray();\n+\t\tentry.count = value.numElements();\n \t\tentry.offset = values.offset();\n \t\tentries.write(&entry);\n \n@@ -293,40 +295,45 @@ int ControlSerializer::serialize(const ControlList &list,\n \treturn 0;\n }\n \n-template<>\n-ControlValue ControlSerializer::load<ControlValue>(ControlType type,\n-\t\t\t\t\t\t ByteStreamBuffer &b)\n+template<typename T>\n+ControlValue ControlSerializer::loadControlValue(ByteStreamBuffer &buffer,\n+\t\t\t\t\t\t bool isArray,\n+\t\t\t\t\t\t unsigned int count)\n+{\n+\tControlValue value;\n+\n+\tconst T *data = buffer.read<T>(count);\n+\tif (!data)\n+\t\treturn value;\n+\n+\tif (isArray)\n+\t\tvalue.set(Span<const T>{ data, count });\n+\telse\n+\t\tvalue.set(*data);\n+\n+\treturn value;\n+}\n+\n+ControlValue ControlSerializer::loadControlValue(ControlType type,\n+\t\t\t\t\t\t ByteStreamBuffer &buffer,\n+\t\t\t\t\t\t bool isArray,\n+\t\t\t\t\t\t unsigned int count)\n {\n \tswitch (type) {\n-\tcase ControlTypeBool: {\n-\t\tbool value;\n-\t\tb.read(&value);\n-\t\treturn ControlValue(value);\n-\t}\n+\tcase ControlTypeBool:\n+\t\treturn loadControlValue<bool>(buffer, isArray, count);\n \n-\tcase ControlTypeByte: {\n-\t\tuint8_t value;\n-\t\tb.read(&value);\n-\t\treturn ControlValue(value);\n-\t}\n+\tcase ControlTypeByte:\n+\t\treturn loadControlValue<uint8_t>(buffer, isArray, count);\n \n-\tcase ControlTypeInteger32: {\n-\t\tint32_t value;\n-\t\tb.read(&value);\n-\t\treturn ControlValue(value);\n-\t}\n+\tcase ControlTypeInteger32:\n+\t\treturn loadControlValue<int32_t>(buffer, isArray, count);\n \n-\tcase ControlTypeInteger64: {\n-\t\tint64_t value;\n-\t\tb.read(&value);\n-\t\treturn ControlValue(value);\n-\t}\n+\tcase ControlTypeInteger64:\n+\t\treturn loadControlValue<int64_t>(buffer, isArray, count);\n \n-\tcase ControlTypeFloat: {\n-\t\tfloat value;\n-\t\tb.read(&value);\n-\t\treturn ControlValue(value);\n-\t}\n+\tcase ControlTypeFloat:\n+\t\treturn loadControlValue<float>(buffer, isArray, count);\n \n \tcase ControlTypeNone:\n \t\treturn ControlValue();\n@@ -335,12 +342,11 @@ ControlValue ControlSerializer::load<ControlValue>(ControlType type,\n \treturn ControlValue();\n }\n \n-template<>\n-ControlRange ControlSerializer::load<ControlRange>(ControlType type,\n-\t\t\t\t\t\t ByteStreamBuffer &b)\n+ControlRange ControlSerializer::loadControlRange(ControlType type,\n+\t\t\t\t\t\t ByteStreamBuffer &b)\n {\n-\tControlValue min = load<ControlValue>(type, b);\n-\tControlValue max = load<ControlValue>(type, b);\n+\tControlValue min = loadControlValue(type, b);\n+\tControlValue max = loadControlValue(type, b);\n \n \treturn ControlRange(min, max);\n }\n@@ -414,7 +420,7 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &\n \n \t\t/* Create and store the ControlRange. */\n \t\tctrls.emplace(controlIds_.back().get(),\n-\t\t\t load<ControlRange>(type, values));\n+\t\t\t loadControlRange(type, values));\n \t}\n \n \t/*\n@@ -502,7 +508,9 @@ ControlList ControlSerializer::deserialize<ControlList>(ByteStreamBuffer &buffer\n \t\t}\n \n \t\tControlType type = static_cast<ControlType>(entry->type);\n-\t\tctrls.set(entry->id, load<ControlValue>(type, values));\n+\t\tctrls.set(entry->id,\n+\t\t\t loadControlValue(type, values, entry->is_array,\n+\t\t\t\t\t entry->count));\n \t}\n \n \treturn ctrls;\ndiff --git a/src/libcamera/include/control_serializer.h b/src/libcamera/include/control_serializer.h\nindex 55259913a2ca..b91d13155f5e 100644\n--- a/src/libcamera/include/control_serializer.h\n+++ b/src/libcamera/include/control_serializer.h\n@@ -41,7 +41,11 @@ private:\n \tstatic void store(const ControlRange &range, ByteStreamBuffer &buffer);\n \n \ttemplate<typename T>\n-\tT load(ControlType type, ByteStreamBuffer &b);\n+\tControlValue loadControlValue(ByteStreamBuffer &buffer, bool isArray,\n+\t\t\t\t unsigned int count);\n+\tControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer,\n+\t\t\t\t bool isArray = false, unsigned int count = 1);\n+\tControlRange loadControlRange(ControlType type, ByteStreamBuffer &buffer);\n \n \tunsigned int serial_;\n \tstd::vector<std::unique_ptr<ControlId>> controlIds_;\n", "prefixes": [ "libcamera-devel", "v2", "29/32" ] }