Patch Detail
Show a patch.
GET /api/1.1/patches/3114/?format=api
{ "id": 3114, "url": "https://patchwork.libcamera.org/api/1.1/patches/3114/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3114/", "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": "<20200316024146.2474424-6-niklas.soderlund@ragnatech.se>", "date": "2020-03-16T02:41:45", "name": "[libcamera-devel,RFC,5/6] libcamera: ipu3: Do not unconditionally queue buffers to CIO2", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8a2a87c63e54848b2ae4dffda15dc26d7576029b", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3114/mbox/", "series": [ { "id": 722, "url": "https://patchwork.libcamera.org/api/1.1/series/722/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=722", "date": "2020-03-16T02:41:40", "name": "libcamera: Add support for a RAW still capture stream", "version": 1, "mbox": "https://patchwork.libcamera.org/series/722/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3114/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3114/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D604260417\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Mar 2020 03:42:33 +0100 (CET)", "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid b76e5d8f-672f-11ea-9f40-0050569116f7;\n\tMon, 16 Mar 2020 03:42:02 +0100 (CET)" ], "X-Halon-ID": "b76e5d8f-672f-11ea-9f40-0050569116f7", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 16 Mar 2020 03:41:45 +0100", "Message-Id": "<20200316024146.2474424-6-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20200316024146.2474424-1-niklas.soderlund@ragnatech.se>", "References": "<20200316024146.2474424-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC 5/6] libcamera: ipu3: Do not unconditionally\n\tqueue buffers to CIO2", "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": "Mon, 16 Mar 2020 02:42:34 -0000" }, "content": "Instead of unconditionally cycling buffers between the CIO2 and IMGU\npick a buffer when a request is queued to the pipeline. This is needed\nif operations are the be applied to the buffer coming from CIO2 with\nparameters coming from a Request.\n\nThe approach to pick a CIO2 buffer when a request is queued is similar\nto other pipelines, where parameters and statistic buffers are picked\nthis way.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 69 +++++++++++++++++++++++-----\n 1 file changed, 58 insertions(+), 11 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 0c2a217c9ea8f6ba..dbb0c4328aa0efe5 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -8,6 +8,7 @@\n #include <algorithm>\n #include <iomanip>\n #include <memory>\n+#include <queue>\n #include <vector>\n \n #include <linux/drm_fourcc.h>\n@@ -119,6 +120,10 @@ public:\n \tint allocateBuffers();\n \tvoid freeBuffers();\n \n+\tFrameBuffer *getBuffer();\n+\tvoid putBuffer(FrameBuffer *buffer);\n+\tint queueBuffer(FrameBuffer *buffer);\n+\n \tint start();\n \tint stop();\n \n@@ -130,6 +135,7 @@ public:\n \n private:\n \tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n+\tstd::queue<FrameBuffer *> availableBuffers_;\n };\n \n class IPU3Stream : public Stream\n@@ -157,6 +163,8 @@ public:\n \tvoid imguInputBufferReady(FrameBuffer *buffer);\n \tvoid cio2BufferReady(FrameBuffer *buffer);\n \n+\tstd::map<FrameBuffer *, Request *> cio2ToRequest_;\n+\n \tCIO2Device cio2_;\n \tImgUDevice *imgu_;\n \n@@ -717,11 +725,20 @@ void PipelineHandlerIPU3::stop(Camera *camera)\n \n int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request)\n {\n+\tIPU3CameraData *data = cameraData(camera);\n+\tFrameBuffer *buffer;\n \tint error = 0;\n \n+\t/* Get a CIO2 buffer and track it it's used for this request. */\n+\tbuffer = data->cio2_.getBuffer();\n+\tif (!buffer)\n+\t\treturn -EINVAL;\n+\tdata->cio2ToRequest_[buffer] = request;\n+\tdata->cio2_.queueBuffer(buffer);\n+\n \tfor (auto it : request->buffers()) {\n \t\tIPU3Stream *stream = static_cast<IPU3Stream *>(it.first);\n-\t\tFrameBuffer *buffer = it.second;\n+\t\tbuffer = it.second;\n \n \t\tint ret = stream->device_->dev->queueBuffer(buffer);\n \t\tif (ret < 0)\n@@ -893,7 +910,9 @@ void IPU3CameraData::imguInputBufferReady(FrameBuffer *buffer)\n \tif (buffer->metadata().status == FrameMetadata::FrameCancelled)\n \t\treturn;\n \n-\tcio2_.output_->queueBuffer(buffer);\n+\t/* Remove association between CIO2 buffer an Request. */\n+\tcio2ToRequest_.erase(buffer);\n+\tcio2_.putBuffer(buffer);\n }\n \n /**\n@@ -1416,30 +1435,58 @@ int CIO2Device::configure(const Size &size,\n int CIO2Device::allocateBuffers()\n {\n \tint ret = output_->allocateBuffers(CIO2_BUFFER_COUNT, &buffers_);\n-\tif (ret < 0)\n+\tif (ret < 0) {\n \t\tLOG(IPU3, Error) << \"Failed to allocate CIO2 buffers\";\n+\t\treturn ret;\n+\t}\n+\n+\tfor (std::unique_ptr<FrameBuffer> &buffer : buffers_)\n+\t\tavailableBuffers_.push(buffer.get());\n \n \treturn ret;\n }\n \n void CIO2Device::freeBuffers()\n {\n+\twhile (!availableBuffers_.empty())\n+\t\tavailableBuffers_.pop();\n+\n \tbuffers_.clear();\n \n \tif (output_->releaseBuffers())\n \t\tLOG(IPU3, Error) << \"Failed to release CIO2 buffers\";\n }\n \n+FrameBuffer *CIO2Device::getBuffer()\n+{\n+\tif (availableBuffers_.empty()) {\n+\t\tLOG(IPU3, Error) << \"CIO2 buffer underrun\";\n+\t\treturn nullptr;\n+\t}\n+\n+\tFrameBuffer *buffer = availableBuffers_.front();\n+\n+\tavailableBuffers_.pop();\n+\n+\treturn buffer;\n+}\n+\n+void CIO2Device::putBuffer(FrameBuffer *buffer)\n+{\n+\tavailableBuffers_.push(buffer);\n+}\n+\n+int CIO2Device::queueBuffer(FrameBuffer *buffer)\n+{\n+\tint ret = output_->queueBuffer(buffer);\n+\tif (ret)\n+\t\tLOG(IPU3, Error) << \"Failed to queue CIO2 buffer\";\n+\n+\treturn ret;\n+}\n+\n int CIO2Device::start()\n {\n-\tfor (const std::unique_ptr<FrameBuffer> &buffer : buffers_) {\n-\t\tint ret = output_->queueBuffer(buffer.get());\n-\t\tif (ret) {\n-\t\t\tLOG(IPU3, Error) << \"Failed to queue CIO2 buffer\";\n-\t\t\treturn ret;\n-\t\t}\n-\t}\n-\n \treturn output_->streamOn();\n }\n \n", "prefixes": [ "libcamera-devel", "RFC", "5/6" ] }