Patch Detail
Show a patch.
GET /api/1.1/patches/1624/?format=api
{ "id": 1624, "url": "https://patchwork.libcamera.org/api/1.1/patches/1624/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1624/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20190704225334.26170-4-jacopo@jmondi.org>", "date": "2019-07-04T22:53:28", "name": "[libcamera-devel,3/9] libcamera: pipeline: Support external buffers", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "5db41e22abbc19b8c9b455585b6d5cc2dae8cdc9", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1624/mbox/", "series": [ { "id": 407, "url": "https://patchwork.libcamera.org/api/1.1/series/407/?format=api", "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/1624/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1624/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 A09E060C2C\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 36F2C1C0002;\n\tThu, 4 Jul 2019 22:52:28 +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:28 +0200", "Message-Id": "<20190704225334.26170-4-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 3/9] libcamera: pipeline: Support external\n\tbuffers", "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:29 -0000" }, "content": "Add support for use external buffers to libcamera pipeline handlers.\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 src/libcamera/pipeline/ipu3/ipu3.cpp | 31 +++++++++++++++++++++++-\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 ++++++-\n src/libcamera/pipeline/uvcvideo.cpp | 8 +++++-\n src/libcamera/pipeline/vimc.cpp | 8 +++++-\n 4 files changed, 52 insertions(+), 4 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 2de0892138a8..6f14da1f8c70 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -71,6 +71,7 @@ public:\n \n \tint importBuffers(BufferPool *pool);\n \tint exportBuffers(ImgUOutput *output, BufferPool *pool);\n+\tint reserveDmabufBuffers(ImgUOutput *output, BufferPool *pool);\n \tvoid freeBuffers();\n \n \tint start();\n@@ -624,7 +625,11 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \t\tIPU3Stream *stream = static_cast<IPU3Stream *>(s);\n \t\tImgUDevice::ImgUOutput *dev = stream->device_;\n \n-\t\tret = imgu->exportBuffers(dev, &stream->bufferPool());\n+\t\tif (stream->memoryType() == ExternalMemory)\n+\t\t\tret = imgu->reserveDmabufBuffers(dev,\n+\t\t\t\t\t\t\t &stream->bufferPool());\n+\t\telse\n+\t\t\tret = imgu->exportBuffers(dev, &stream->bufferPool());\n \t\tif (ret)\n \t\t\tgoto error;\n \t}\n@@ -1153,6 +1158,30 @@ int ImgUDevice::exportBuffers(ImgUOutput *output, BufferPool *pool)\n \treturn 0;\n }\n \n+/**\n+ * \\brief Reserve buffers in \\a output from the provided \\a pool\n+ * \\param[in] output The ImgU output device\n+ * \\param[in] pool The buffer pool used to reserve buffers in \\a output\n+ *\n+ * Reserve a number of buffers equal to the number of buffers in \\a pool\n+ * in the \\a output device to prepare for streaming operations using buffers\n+ * whose memory has been reserved elsewhere identified with DMABUF file\n+ * descriptors.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int ImgUDevice::reserveDmabufBuffers(ImgUOutput *output, BufferPool *pool)\n+{\n+\tint ret = output->dev->importBuffers(pool);\n+\tif (ret) {\n+\t\tLOG(IPU3, Error) << \"Failed to import buffer in \"\n+\t\t\t\t << output->name << \" ImgU device\";\n+\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n /**\n * \\brief Release buffers for all the ImgU video devices\n */\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 4a5898d25f91..dbb61a21354d 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -319,7 +319,14 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera,\n \t\t\t\t\t const std::set<Stream *> &streams)\n {\n \tStream *stream = *streams.begin();\n-\treturn video_->exportBuffers(&stream->bufferPool());\n+\tint ret;\n+\n+\tif (stream->memoryType() == InternalMemory)\n+\t\tret = video_->exportBuffers(&stream->bufferPool());\n+\telse\n+\t\tret = video_->importBuffers(&stream->bufferPool());\n+\n+\treturn ret;\n }\n \n int PipelineHandlerRkISP1::freeBuffers(Camera *camera,\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 72313cfd246f..5b3c79dda6dd 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -197,10 +197,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 f8a58be060bb..c67bdb0ecbff 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -199,10 +199,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,\n", "prefixes": [ "libcamera-devel", "3/9" ] }