Patch Detail
Show a patch.
GET /api/1.1/patches/766/?format=api
{ "id": 766, "url": "https://patchwork.libcamera.org/api/1.1/patches/766/?format=api", "web_url": "https://patchwork.libcamera.org/patch/766/", "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": "<20190320163055.22056-21-jacopo@jmondi.org>", "date": "2019-03-20T16:30:44", "name": "[libcamera-devel,v4,20/31] libcamera: ipu3: Add multiple stream memory management", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "e9bb7f988b5bf98f5c3b6e4bdbea82d77d0a4478", "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/766/mbox/", "series": [ { "id": 214, "url": "https://patchwork.libcamera.org/api/1.1/series/214/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=214", "date": "2019-03-20T16:30:24", "name": "libcamera: ipu3: Add ImgU support + multiple streams", "version": 4, "mbox": "https://patchwork.libcamera.org/series/214/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/766/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/766/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 779986110A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Mar 2019 17:30: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 relay12.mail.gandi.net (Postfix) with ESMTPSA id 1779520000D;\n\tWed, 20 Mar 2019 16:30:39 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 20 Mar 2019 17:30:44 +0100", "Message-Id": "<20190320163055.22056-21-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190320163055.22056-1-jacopo@jmondi.org>", "References": "<20190320163055.22056-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 20/31] libcamera: ipu3: Add multiple\n\tstream memory management", "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": "Wed, 20 Mar 2019 16:30:40 -0000" }, "content": "Add support for allocating and freeing memory for multiple streams.\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 140 ++++++++++++++++++---------\n 1 file changed, 96 insertions(+), 44 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 4ed8c1fec1e3..0507fc380e68 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -70,6 +70,7 @@ public:\n \n \tBufferPool vfPool;\n \tBufferPool statPool;\n+\tBufferPool outputPool;\n };\n \n struct CIO2Device {\n@@ -458,42 +459,70 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\n \tV4L2Device *input = data->imgu->input;\n \tV4L2Device *cio2 = data->cio2.output;\n \tV4L2Device *stat = data->imgu->stat;\n+\tImgUDevice *imgu = data->imgu;\n \tint ret;\n \n-\t/* Share buffers between CIO2 output and ImgU input. */\n-\tdata->cio2.pool.createBuffers(IPU3_CIO2_BUFFER_COUNT);\n-\tret = cio2->exportBuffers(&data->cio2.pool);\n-\tif (ret) {\n-\t\tLOG(IPU3, Error) << \"Failed to reserve CIO2 memory\";\n-\t\treturn ret;\n-\t}\n+\tif (data->cio2.pool.count() == 0) {\n+\t\t/* Share buffers between CIO2 output and ImgU input. */\n+\t\tdata->cio2.pool.createBuffers(IPU3_CIO2_BUFFER_COUNT);\n+\t\tret = cio2->exportBuffers(&data->cio2.pool);\n+\t\tif (ret) {\n+\t\t\tLOG(IPU3, Error) << \"Failed to reserve CIO2 memory\";\n+\t\t\treturn ret;\n+\t\t}\n \n-\tret = input->importBuffers(&data->cio2.pool);\n-\tif (ret) {\n-\t\tLOG(IPU3, Error) << \"Failed to import ImgU memory\";\n-\t\treturn ret;\n-\t}\n+\t\tret = input->importBuffers(&data->cio2.pool);\n+\t\tif (ret) {\n+\t\t\tLOG(IPU3, Error) << \"Failed to import ImgU memory\";\n+\t\t\treturn ret;\n+\t\t}\n \n-\t/* Prepare the buffer pools for viewfinder and stat. */\n-\tdata->imgu->vfPool.createBuffers(IPU3_IMGU_BUFFER_COUNT);\n-\tret = viewfinder->exportBuffers(&data->imgu->vfPool);\n-\tif (ret) {\n-\t\tLOG(IPU3, Error) << \"Failed to reserve ImgU viewfinder memory\";\n-\t\treturn ret;\n+\t\timgu->statPool.createBuffers(IPU3_IMGU_BUFFER_COUNT);\n+\t\tret = stat->exportBuffers(&imgu->statPool);\n+\t\tif (ret) {\n+\t\t\tLOG(IPU3, Error) << \"Failed to reserve ImgU stat memory\";\n+\t\t\treturn ret;\n+\t\t}\n \t}\n \n-\tdata->imgu->statPool.createBuffers(IPU3_IMGU_BUFFER_COUNT);\n-\tret = stat->exportBuffers(&data->imgu->statPool);\n-\tif (ret) {\n-\t\tLOG(IPU3, Error) << \"Failed to reserve ImgU stat memory\";\n-\t\treturn ret;\n-\t}\n+\tif (isOutput(data, stream)) {\n+\t\t/* Export ImgU output buffers to the stream's pool. */\n+\t\tret = output->exportBuffers(&stream->bufferPool());\n+\t\tif (ret) {\n+\t\t\tLOG(IPU3, Error)\n+\t\t\t\t<< \"Failed to reserve ImgU output memory\";\n+\t\t\treturn ret;\n+\t\t}\n \n-\t/* Export ImgU output buffers to the stream's pool. */\n-\tret = output->exportBuffers(&stream->bufferPool());\n-\tif (ret) {\n-\t\tLOG(IPU3, Error) << \"Failed to reserve ImgU output memory\";\n-\t\treturn ret;\n+\t\tif (!isViewfinderActive(data)) {\n+\t\t\t/* Internally allocate buffers for viewfinder. */\n+\t\t\timgu->vfPool.createBuffers(IPU3_IMGU_BUFFER_COUNT);\n+\t\t\tret = viewfinder->exportBuffers(&imgu->vfPool);\n+\t\t\tif (ret) {\n+\t\t\t\tLOG(IPU3, Error)\n+\t\t\t\t\t<< \"Failed to reserve ImgU viewfinder memory\";\n+\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t}\n+\t} else if (isViewfinder(data, stream)) {\n+\t\t/* Export ImgU viewfinder buffers to the stream's pool. */\n+\t\tret = viewfinder->exportBuffers(&stream->bufferPool());\n+\t\tif (ret) {\n+\t\t\tLOG(IPU3, Error)\n+\t\t\t\t<< \"Failed to reserve ImgU viewfinder memory\";\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\tif (!isOutputActive(data)) {\n+\t\t\t/* Internally allocate buffers for output. */\n+\t\t\timgu->outputPool.createBuffers(IPU3_IMGU_BUFFER_COUNT);\n+\t\t\tret = output->exportBuffers(&imgu->outputPool);\n+\t\t\tif (ret) {\n+\t\t\t\tLOG(IPU3, Error)\n+\t\t\t\t\t<< \"Failed to reserve ImgU output memory\";\n+\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t}\n \t}\n \n \treturn 0;\n@@ -509,25 +538,48 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)\n \tV4L2Device *stat = data->imgu->stat;\n \tint ret;\n \n-\tret = output->releaseBuffers();\n-\tif (ret)\n-\t\tLOG(IPU3, Error) << \"Failed to release ImgU output memory\";\n+\tif (data->cio2.pool.count()) {\n+\t\tret = input->releaseBuffers();\n+\t\tif (ret)\n+\t\t\tLOG(IPU3, Error) << \"Failed to release ImgU input memory\";\n \n-\tret = stat->releaseBuffers();\n-\tif (ret)\n-\t\tLOG(IPU3, Error) << \"Failed to release ImgU stat memory\";\n+\t\tret = cio2->releaseBuffers();\n+\t\tif (ret)\n+\t\t\tLOG(IPU3, Error) << \"Failed to release CIO2 memory\";\n \n-\tret = viewfinder->releaseBuffers();\n-\tif (ret)\n-\t\tLOG(IPU3, Error) << \"Failed to release ImgU viewfinder memory\";\n+\t\tret = stat->releaseBuffers();\n+\t\tif (ret)\n+\t\t\tLOG(IPU3, Error) << \"Failed to release ImgU stat memory\";\n \n-\tret = input->releaseBuffers();\n-\tif (ret)\n-\t\tLOG(IPU3, Error) << \"Failed to release ImgU input memory\";\n+\t}\n \n-\tret = cio2->releaseBuffers();\n-\tif (ret)\n-\t\tLOG(IPU3, Error) << \"Failed to release CIO2 memory\";\n+\tif (isOutput(data, stream)) {\n+\t\tret = output->releaseBuffers();\n+\t\tif (ret)\n+\t\t\tLOG(IPU3, Error)\n+\t\t\t\t<< \"Failed to release ImgU output memory\";\n+\n+\t\tif (isViewfinderActive(data))\n+\t\t\treturn 0;\n+\n+\t\tret = viewfinder->releaseBuffers();\n+\t\tif (ret)\n+\t\t\tLOG(IPU3, Error)\n+\t\t\t\t<< \"Failed to release ImgU viewfinder memory\";\n+\t} else if (isViewfinder(data, stream)) {\n+\t\tret = viewfinder->releaseBuffers();\n+\t\tif (ret)\n+\t\t\tLOG(IPU3, Error)\n+\t\t\t\t<< \"Failed to release ImgU viewfinder memory\";\n+\n+\t\tif (isOutputActive(data))\n+\t\t\treturn 0;\n+\n+\t\tret = output->releaseBuffers();\n+\t\tif (ret)\n+\t\t\tLOG(IPU3, Error)\n+\t\t\t\t<< \"Failed to release ImgU output memory\";\n+\t}\n \n \treturn 0;\n }\n", "prefixes": [ "libcamera-devel", "v4", "20/31" ] }