{"id":2940,"url":"https://patchwork.libcamera.org/api/patches/2940/?format=json","web_url":"https://patchwork.libcamera.org/patch/2940/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","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-24-laurent.pinchart@ideasonboard.com>","date":"2020-02-29T16:42:46","name":"[libcamera-devel,23/31] libcamera: byte_stream_buffer: Add Span<> support","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c39eaca4e44bf20babd8f7e808ae4b3d469013a1","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2940/mbox/","series":[{"id":696,"url":"https://patchwork.libcamera.org/api/series/696/?format=json","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/2940/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2940/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 6B2F86279C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Feb 2020 17:43:30 +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 0100EA28;\n\tSat, 29 Feb 2020 17:43:29 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1582994610;\n\tbh=zSHTjgu+vDt7JU2m5H9mOXFBD8jOA4e7olWkvvLRQQs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=PrKDDiOr86GLcgnjl+PD+cSwauwMG0nVNlpkH/UpKeXv1Y6DY4TtO08wCGrGV5knw\n\tWWyuTraDOMZhLr5mI2S4jMmh+gz2Uhcz3UEkzqbt9TDDRGFXZS0h3+31zN6/B7qWny\n\tjLWpPfXPcqXzYgaKxTAmI8bq86H5EYZjp7lEtc1M=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 29 Feb 2020 18:42:46 +0200","Message-Id":"<20200229164254.23604-24-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 23/31] libcamera: byte_stream_buffer: Add\n\tSpan<> support","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:36 -0000"},"content":"From: Jacopo Mondi <jacopo@jmondi.org>\n\nAdd support to read and write a Span<> from and to the ByteStreamBuffer\nclass.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/byte_stream_buffer.cpp       | 18 ++++++++++++++++++\n src/libcamera/include/byte_stream_buffer.h | 17 +++++++++++++++++\n 2 files changed, 35 insertions(+)","diff":"diff --git a/src/libcamera/byte_stream_buffer.cpp b/src/libcamera/byte_stream_buffer.cpp\nindex cd1d8a36d464..40380bf0434a 100644\n--- a/src/libcamera/byte_stream_buffer.cpp\n+++ b/src/libcamera/byte_stream_buffer.cpp\n@@ -232,6 +232,15 @@ int ByteStreamBuffer::skip(size_t size)\n  * \\retval -ENOSPC no more space is available in the managed memory buffer\n  */\n \n+/**\n+ * \\fn template<typename T> int ByteStreamBuffer::read(const Span<T> &data)\n+ * \\brief Read data from the managed memory buffer into span \\a data\n+ * \\param[out] data Span representing the destination memory\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 t to the managed memory buffer\n@@ -241,6 +250,15 @@ int ByteStreamBuffer::skip(size_t size)\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> &data)\n+ * \\brief Write \\a data to the managed memory buffer\n+ * \\param[in] data 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 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..17cb0146061e 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@@ -33,12 +35,27 @@ public:\n \t{\n \t\treturn read(reinterpret_cast<uint8_t *>(t), sizeof(*t));\n \t}\n+\n+\ttemplate<typename T>\n+\tint read(const Span<T> &data)\n+\t{\n+\t\treturn read(reinterpret_cast<uint8_t *>(data.data()),\n+\t\t\t    data.size_bytes());\n+\t}\n+\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 \n+\ttemplate<typename T>\n+\tint write(const Span<T> &data)\n+\t{\n+\t\treturn write(reinterpret_cast<const uint8_t *>(data.data()),\n+\t\t\t     data.size_bytes());\n+\t}\n+\n private:\n \tByteStreamBuffer(const ByteStreamBuffer &other) = delete;\n \tByteStreamBuffer &operator=(const ByteStreamBuffer &other) = delete;\n","prefixes":["libcamera-devel","23/31"]}