Patch Detail
Show a patch.
GET /api/patches/2637/?format=api
{ "id": 2637, "url": "https://patchwork.libcamera.org/api/patches/2637/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2637/", "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": "<20200113164245.52535-22-jacopo@jmondi.org>", "date": "2020-01-13T16:42:43", "name": "[libcamera-devel,21/23] libcamera: byte_stream_buffer: Support span<>", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "1bf53f689ac89188626217dfbf8c5e7910203460", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/2637/mbox/", "series": [ { "id": 618, "url": "https://patchwork.libcamera.org/api/series/618/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=618", "date": "2020-01-13T16:42:22", "name": "Properties and compound controls", "version": 1, "mbox": "https://patchwork.libcamera.org/series/618/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2637/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2637/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C0F36074A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jan 2020 17:40:40 +0100 (CET)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 92526100005;\n\tMon, 13 Jan 2020 16:40:39 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 13 Jan 2020 17:42:43 +0100", "Message-Id": "<20200113164245.52535-22-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.24.0", "In-Reply-To": "<20200113164245.52535-1-jacopo@jmondi.org>", "References": "<20200113164245.52535-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 21/23] libcamera: byte_stream_buffer:\n\tSupport span<>", "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, 13 Jan 2020 16:40:42 -0000" }, "content": "Add support to write and read span<> of data to the ByteStreamBuffer\nclass.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/byte_stream_buffer.cpp | 31 ++++++++++++++++++++--\n src/libcamera/include/byte_stream_buffer.h | 14 ++++++++++\n 2 files changed, 43 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/libcamera/byte_stream_buffer.cpp b/src/libcamera/byte_stream_buffer.cpp\nindex 23d624dd0a06..9fb14508722f 100644\n--- a/src/libcamera/byte_stream_buffer.cpp\n+++ b/src/libcamera/byte_stream_buffer.cpp\n@@ -225,22 +225,49 @@ int ByteStreamBuffer::skip(size_t size)\n \n /**\n * \\fn template<typename T> int ByteStreamBuffer::read(T *t)\n- * \\brief Read \\a size \\a data from the managed memory buffer\n+ * \\brief Read data from the managed memory buffer into \\a t\n * \\param[out] t Pointer to the memory containing the read data\n * \\return 0 on success, a negative error code otherwise\n * \\retval -EACCES attempting to read from a write buffer\n * \\retval -ENOSPC no more space is available in the managed memory buffer\n */\n \n+/**\n+ * \\fn template<typename T> int ByteStreamBuffer::read(Span<T> *t)\n+ * \\brief Read a sequence of data from the managed memory buffer into span \\a t\n+ * \\param[out] t Pointer to an intialized span where to read data\n+ *\n+ * This function reads data from managed memory and writes it to an initialized\n+ * memory location represented by the span \\a t.\n+ *\n+ * The provided span \\a t should be initialized with a memory area large\n+ * enough to contain the read data. This function does not perform any\n+ * memory allocation or initialization in the span \\a t. It is responsibility of\n+ * the caller to do so.\n+ *\n+ * \\return 0 on success, a negative error code otherwise\n+ * \\retval -EACCES attempting to read from a write buffer\n+ * \\retval -ENOSPC no more space is available in the managed memory buffer\n+ */\n+\n /**\n * \\fn template<typename T> int ByteStreamBuffer::write(const T *t)\n- * \\brief Write \\a data of \\a size to the managed memory buffer\n+ * \\brief Write \\a t to the managed memory buffer\n * \\param[in] t The data to write to memory\n * \\return 0 on success, a negative error code otherwise\n * \\retval -EACCES attempting to write to a read buffer\n * \\retval -ENOSPC no more space is available in the managed memory buffer\n */\n \n+/**\n+ * \\fn template<typename T> int ByteStreamBuffer::write(const Span<T> &t)\n+ * \\brief Write a span of data \\a t to the managed memory buffer\n+ * \\param[in] t The span of data to write to memory\n+ * \\return 0 on success, a negative error code otherwise\n+ * \\retval -EACCES attempting to write to a read buffer\n+ * \\retval -ENOSPC no more space is available in the managed memory buffer\n+ */\n+\n int ByteStreamBuffer::read(uint8_t *data, size_t size)\n {\n \tif (!read_)\ndiff --git a/src/libcamera/include/byte_stream_buffer.h b/src/libcamera/include/byte_stream_buffer.h\nindex b5274c62b85e..2d5267ac06c0 100644\n--- a/src/libcamera/include/byte_stream_buffer.h\n+++ b/src/libcamera/include/byte_stream_buffer.h\n@@ -10,6 +10,8 @@\n #include <stddef.h>\n #include <stdint.h>\n \n+#include <libcamera/span.h>\n+\n namespace libcamera {\n \n class ByteStreamBuffer\n@@ -34,10 +36,22 @@ public:\n \t\treturn read(reinterpret_cast<uint8_t *>(t), sizeof(*t));\n \t}\n \ttemplate<typename T>\n+\tint read(Span<T> *t)\n+\t{\n+\t\treturn read(reinterpret_cast<uint8_t *>(t->data()),\n+\t\t\t sizeof(t->data()[0]) * t->size());\n+\t}\n+\ttemplate<typename T>\n \tint write(const T *t)\n \t{\n \t\treturn write(reinterpret_cast<const uint8_t *>(t), sizeof(*t));\n \t}\n+\ttemplate<typename T>\n+\tint write(const Span<T> &t)\n+\t{\n+\t\treturn write(reinterpret_cast<const uint8_t *>(t.data()),\n+\t\t\t sizeof(t.data()[0]) * t.size());\n+\t}\n \n private:\n \tByteStreamBuffer(const ByteStreamBuffer &other) = delete;\n", "prefixes": [ "libcamera-devel", "21/23" ] }