Patch Detail
Show a patch.
GET /api/patches/1536/?format=api
{ "id": 1536, "url": "https://patchwork.libcamera.org/api/patches/1536/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1536/", "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": "<20190630181049.9548-4-jacopo@jmondi.org>", "date": "2019-06-30T18:10:44", "name": "[libcamera-devel,RFC,3/8] libcamera: stream: Add Stream memory type", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "a1f0d1d47843618ab52b410b24cf669ee3db3386", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1536/mbox/", "series": [ { "id": 383, "url": "https://patchwork.libcamera.org/api/series/383/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=383", "date": "2019-06-30T18:10:41", "name": "libcamera: Add support for importing external memory buffers", "version": 1, "mbox": "https://patchwork.libcamera.org/series/383/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1536/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1536/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 441E761F28\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 30 Jun 2019 20:09:39 +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 relay12.mail.gandi.net (Postfix) with ESMTPSA id DA275200004;\n\tSun, 30 Jun 2019 18:09:38 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 30 Jun 2019 20:10:44 +0200", "Message-Id": "<20190630181049.9548-4-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190630181049.9548-1-jacopo@jmondi.org>", "References": "<20190630181049.9548-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC 3/8] 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": "Sun, 30 Jun 2019 18:09:40 -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\nUse the memory type flag in pipeline handlers (todo: change all pipeline\nhandlers) during buffer setup operations, to decide if the Stream's\ninternal memory has to be exported to applications, or the Stream\nshould prepare to use buffers whose memory is allocated elsewhere.\n\nTo support the last use case, a translation mechanism between the external\nbuffers provided by applications and internal ones used by pipeline\nhandlers to feed the video device will be implemented on top of this\nchange.\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/pipeline/uvcvideo.cpp | 8 +++++++-\n src/libcamera/pipeline/vimc.cpp | 8 +++++++-\n src/libcamera/stream.cpp | 14 ++++++++++++--\n 5 files changed, 35 insertions(+), 4 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 023ae53e5f9d..662406b970dc 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -671,6 +671,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/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 2e22523d7cb1..5112356c25ac 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -190,10 +190,16 @@ int PipelineHandlerUVC::allocateBuffers(Camera *camera,\n \tUVCCameraData *data = cameraData(camera);\n \tStream *stream = *streams.begin();\n \tconst StreamConfiguration &cfg = stream->configuration();\n+\tint ret;\n \n \tLOG(UVC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n \n-\treturn data->video_->exportBuffers(&stream->bufferPool());\n+\tif (stream->memoryType() == InternalMemory)\n+\t\tret = data->video_->exportBuffers(&stream->bufferPool());\n+\telse\n+\t\tret = data->video_->importBuffers(&stream->bufferPool());\n+\n+\treturn ret;\n }\n \n int PipelineHandlerUVC::freeBuffers(Camera *camera,\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 6833213650dc..21a37dba1fc6 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -189,10 +189,16 @@ int PipelineHandlerVimc::allocateBuffers(Camera *camera,\n \tVimcCameraData *data = cameraData(camera);\n \tStream *stream = *streams.begin();\n \tconst StreamConfiguration &cfg = stream->configuration();\n+\tint ret;\n \n \tLOG(VIMC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n \n-\treturn data->video_->exportBuffers(&stream->bufferPool());\n+\tif (stream->memoryType() == InternalMemory)\n+\t\tret = data->video_->exportBuffers(&stream->bufferPool());\n+\telse\n+\t\tret = data->video_->importBuffers(&stream->bufferPool());\n+\n+\treturn ret;\n }\n \n int PipelineHandlerVimc::freeBuffers(Camera *camera,\ndiff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\nindex c6701e5f9921..b6292427d3a2 100644\n--- a/src/libcamera/stream.cpp\n+++ b/src/libcamera/stream.cpp\n@@ -263,6 +263,11 @@ SizeRange StreamFormats::range(unsigned int pixelformat) const\n \treturn range;\n }\n \n+/**\n+ * \\enum MemoryType\n+ * \\todo\n+ */\n+\n /**\n * \\struct StreamConfiguration\n * \\brief Configuration parameters for a stream\n@@ -276,7 +281,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 +289,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 +306,11 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats)\n * format described in V4L2 using the V4L2_PIX_FMT_* definitions.\n */\n \n+/**\n+ * \\var memoryType\n+ * \\todo\n+ */\n+\n /**\n * \\var StreamConfiguration::bufferCount\n * \\brief Requested number of buffers to allocate for the stream\n", "prefixes": [ "libcamera-devel", "RFC", "3/8" ] }