{"id":1623,"url":"https://patchwork.libcamera.org/api/1.1/patches/1623/?format=json","web_url":"https://patchwork.libcamera.org/patch/1623/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20190704225334.26170-3-jacopo@jmondi.org>","date":"2019-07-04T22:53:27","name":"[libcamera-devel,2/9] libcamera: stream: Add Stream memory type","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"c806d7b41921282e76208cfccf7409742a927706","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1623/mbox/","series":[{"id":407,"url":"https://patchwork.libcamera.org/api/1.1/series/407/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=407","date":"2019-07-04T22:53:25","name":"Add support for external bufferes","version":1,"mbox":"https://patchwork.libcamera.org/series/407/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1623/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1623/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 10ECA60C2C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Jul 2019 00:52:28 +0200 (CEST)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9ED701C0002;\n\tThu,  4 Jul 2019 22:52:27 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  5 Jul 2019 00:53:27 +0200","Message-Id":"<20190704225334.26170-3-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190704225334.26170-1-jacopo@jmondi.org>","References":"<20190704225334.26170-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/9] libcamera: stream: Add Stream memory\n\ttype","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Thu, 04 Jul 2019 22:52:28 -0000"},"content":"Define the memory type a Stream uses and allow application to set it\nthrough the associated StreamConfiguration.\n\nA Stream can use either internal or external memory allocation methods,\ndepending on where the data produced by the stream is actually saved.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/stream.h |  8 ++++++++\n src/libcamera/camera.cpp   |  1 +\n src/libcamera/stream.cpp   | 30 ++++++++++++++++++++++++++++--\n 3 files changed, 37 insertions(+), 2 deletions(-)","diff":"diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\nindex fa7d6ba4987c..796f1aff2602 100644\n--- a/include/libcamera/stream.h\n+++ b/include/libcamera/stream.h\n@@ -34,6 +34,11 @@ private:\n \tstd::map<unsigned int, std::vector<SizeRange>> formats_;\n };\n \n+enum MemoryType {\n+\tInternalMemory,\n+\tExternalMemory,\n+};\n+\n struct StreamConfiguration {\n \tStreamConfiguration();\n \tStreamConfiguration(const StreamFormats &formats);\n@@ -41,6 +46,7 @@ struct StreamConfiguration {\n \tunsigned int pixelFormat;\n \tSize size;\n \n+\tMemoryType memoryType;\n \tunsigned int bufferCount;\n \n \tStream *stream() const { return stream_; }\n@@ -77,6 +83,7 @@ public:\n \tstd::vector<Buffer> &buffers() { return bufferPool_.buffers(); }\n \tunsigned int bufferCount() const { return bufferPool_.count(); }\n \tconst StreamConfiguration &configuration() const { return configuration_; }\n+\tMemoryType memoryType() const { return memoryType_; }\n \n protected:\n \tfriend class Camera;\n@@ -86,6 +93,7 @@ protected:\n \n \tBufferPool bufferPool_;\n \tStreamConfiguration configuration_;\n+\tMemoryType memoryType_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 088a39623e36..5f756d41744a 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -683,6 +683,7 @@ int Camera::configure(CameraConfiguration *config)\n \t\t * Allocate buffer objects in the pool.\n \t\t * Memory will be allocated and assigned later.\n \t\t */\n+\t\tstream->memoryType_ = cfg.memoryType;\n \t\tstream->createBuffers(cfg.bufferCount);\n \t}\n \ndiff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\nindex 35197be09c26..97e0f429c9fb 100644\n--- a/src/libcamera/stream.cpp\n+++ b/src/libcamera/stream.cpp\n@@ -263,6 +263,16 @@ SizeRange StreamFormats::range(unsigned int pixelformat) const\n \treturn range;\n }\n \n+/**\n+ * \\enum MemoryType\n+ * \\brief Define the memory type used by a Stream\n+ * \\var MemoryType::InternalMemory\n+ * The Stream uses memory allocated internally to the library and export that\n+ * to applications.\n+ * \\var MemoryType::ExternalMemory\n+ * The Stream uses buffers whose memory is allocated outside from the library.\n+ */\n+\n /**\n  * \\struct StreamConfiguration\n  * \\brief Configuration parameters for a stream\n@@ -276,7 +286,7 @@ SizeRange StreamFormats::range(unsigned int pixelformat) const\n  * handlers provied StreamFormats.\n  */\n StreamConfiguration::StreamConfiguration()\n-\t: stream_(nullptr)\n+\t: memoryType(InternalMemory), stream_(nullptr)\n {\n }\n \n@@ -284,7 +294,7 @@ StreamConfiguration::StreamConfiguration()\n  * \\brief Construct a configuration with stream formats\n  */\n StreamConfiguration::StreamConfiguration(const StreamFormats &formats)\n-\t: stream_(nullptr), formats_(formats)\n+\t: memoryType(InternalMemory), stream_(nullptr), formats_(formats)\n {\n }\n \n@@ -301,6 +311,11 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats)\n  * format described in V4L2 using the V4L2_PIX_FMT_* definitions.\n  */\n \n+/**\n+ * \\var StreamConfiguration::memoryType\n+ * \\brief The memory type the stream shall use\n+ */\n+\n /**\n  * \\var StreamConfiguration::bufferCount\n  * \\brief Requested number of buffers to allocate for the stream\n@@ -436,6 +451,12 @@ Stream::Stream()\n  * \\return The active configuration of the stream\n  */\n \n+/**\n+ * \\fn Stream::memoryType()\n+ * \\brief Retrieve the stream memory type\n+ * \\return The memory type used by the stream\n+ */\n+\n /**\n  * \\brief Create buffers for the stream\n  * \\param count The number of buffers to create\n@@ -476,4 +497,9 @@ void Stream::destroyBuffers()\n  * next call to Camera::configure() regardless of if it includes the stream.\n  */\n \n+/**\n+ * \\var Stream::memoryType_\n+ * \\brief The stream memory type\n+ */\n+\n } /* namespace libcamera */\n","prefixes":["libcamera-devel","2/9"]}