Patch Detail
Show a patch.
GET /api/1.1/patches/4136/?format=api
{ "id": 4136, "url": "https://patchwork.libcamera.org/api/1.1/patches/4136/?format=api", "web_url": "https://patchwork.libcamera.org/patch/4136/", "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": "<20200623020930.1781469-10-niklas.soderlund@ragnatech.se>", "date": "2020-06-23T02:09:29", "name": "[libcamera-devel,v3,09/10] libcamera: ipu3: cio2: Hide buffer allocation and freeing from users", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "78e8833a7d3e2ab18013e0d18bcc1a2e2d57a079", "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/4136/mbox/", "series": [ { "id": 1027, "url": "https://patchwork.libcamera.org/api/1.1/series/1027/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1027", "date": "2020-06-23T02:09:20", "name": "libcamera: ipu3: Allow zero-copy RAW stream", "version": 3, "mbox": "https://patchwork.libcamera.org/series/1027/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/4136/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/4136/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 83483603BD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 04:09:49 +0200 (CEST)", "from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de\n\t[79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 9d630613-b4f6-11ea-933e-005056917a89;\n\tTue, 23 Jun 2020 04:09:48 +0200 (CEST)" ], "X-Halon-ID": "9d630613-b4f6-11ea-933e-005056917a89", "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": "Tue, 23 Jun 2020 04:09:29 +0200", "Message-Id": "<20200623020930.1781469-10-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200623020930.1781469-1-niklas.soderlund@ragnatech.se>", "References": "<20200623020930.1781469-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 09/10] libcamera: ipu3: cio2: Hide\n\tbuffer allocation and freeing from users", "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": "Tue, 23 Jun 2020 02:09:49 -0000" }, "content": "The allocation and freeing of buffers for the CIO2 is handled in the\nIPU3 pipeline handlers start() and stop() functions. These functions\nalso call CIO2Device start() and stop() at the appropriate times so\nmove the CIO2 buffer allocation/freeing inside the CIO2Device and reduce\nthe complexity of the exposed interface.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n* Changes since v2\n- Stop IMGU before CIO2\n\n* Changes since v1\n- Fix potential leaking of buffers if start fails.\n---\n src/libcamera/pipeline/ipu3/cio2.cpp | 63 +++++++++++++---------------\n src/libcamera/pipeline/ipu3/cio2.h | 2 -\n src/libcamera/pipeline/ipu3/ipu3.cpp | 14 ++-----\n 3 files changed, 32 insertions(+), 47 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\nindex 3d7348782b0fa6cb..efaa460b246697a6 100644\n--- a/src/libcamera/pipeline/ipu3/cio2.cpp\n+++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n@@ -207,44 +207,12 @@ CIO2Device::generateConfiguration(const Size &desiredSize) const\n \treturn cfg;\n }\n \n-/**\n- * \\brief Allocate frame buffers for the CIO2 output\n- *\n- * Allocate frame buffers in the CIO2 video device to be used to capture frames\n- * from the CIO2 output. The buffers are stored in the CIO2Device::buffers_\n- * vector.\n- *\n- * \\return Number of buffers allocated or negative error code\n- */\n-int CIO2Device::allocateBuffers()\n-{\n-\tint ret = output_->allocateBuffers(CIO2_BUFFER_COUNT, &buffers_);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tfor (std::unique_ptr<FrameBuffer> &buffer : buffers_)\n-\t\tavailableBuffers_.push(buffer.get());\n-\n-\treturn ret;\n-}\n-\n int CIO2Device::exportBuffers(unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \treturn output_->exportBuffers(count, buffers);\n }\n \n-void CIO2Device::freeBuffers()\n-{\n-\t/* The default std::queue constructor is explicit with gcc 5 and 6. */\n-\tavailableBuffers_ = std::queue<FrameBuffer *>{};\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@@ -266,12 +234,39 @@ void CIO2Device::putBuffer(FrameBuffer *buffer)\n \n int CIO2Device::start()\n {\n-\treturn output_->streamOn();\n+\tint ret = output_->allocateBuffers(CIO2_BUFFER_COUNT, &buffers_);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tfor (std::unique_ptr<FrameBuffer> &buffer : buffers_)\n+\t\tavailableBuffers_.push(buffer.get());\n+\n+\tret = output_->streamOn();\n+\tif (ret) {\n+\t\t/* The default std::queue constructor is explicit with gcc 5 and 6. */\n+\t\tavailableBuffers_ = std::queue<FrameBuffer *>{};\n+\n+\t\tbuffers_.clear();\n+\n+\t\toutput_->releaseBuffers();\n+\t}\n+\n+\treturn ret;\n }\n \n int CIO2Device::stop()\n {\n-\treturn output_->streamOff();\n+\tint ret = output_->streamOff();\n+\n+\t/* The default std::queue constructor is explicit with gcc 5 and 6. */\n+\tavailableBuffers_ = std::queue<FrameBuffer *>{};\n+\n+\tbuffers_.clear();\n+\n+\tif (output_->releaseBuffers())\n+\t\tLOG(IPU3, Error) << \"Failed to release CIO2 buffers\";\n+\n+\treturn ret;\n }\n \n int CIO2Device::queueBuffer(FrameBuffer *buffer)\ndiff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\nindex cc898f13fd73f865..405e6c03755367c4 100644\n--- a/src/libcamera/pipeline/ipu3/cio2.h\n+++ b/src/libcamera/pipeline/ipu3/cio2.h\n@@ -37,10 +37,8 @@ public:\n \n \tStreamConfiguration generateConfiguration(const Size &desiredSize) const;\n \n-\tint allocateBuffers();\n \tint exportBuffers(unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n-\tvoid freeBuffers();\n \n \tFrameBuffer *getBuffer();\n \tvoid putBuffer(FrameBuffer *buffer);\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 2d1ec707ea4b08fe..4818027e8db1f7a3 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -658,15 +658,10 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,\n int PipelineHandlerIPU3::allocateBuffers(Camera *camera)\n {\n \tIPU3CameraData *data = cameraData(camera);\n-\tCIO2Device *cio2 = &data->cio2_;\n \tImgUDevice *imgu = data->imgu_;\n \tunsigned int bufferCount;\n \tint ret;\n \n-\tret = cio2->allocateBuffers();\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n \tbufferCount = std::max({\n \t\tdata->outStream_.configuration().bufferCount,\n \t\tdata->vfStream_.configuration().bufferCount,\n@@ -674,10 +669,8 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera)\n \t});\n \n \tret = imgu->allocateBuffers(data, bufferCount);\n-\tif (ret < 0) {\n-\t\tcio2->freeBuffers();\n+\tif (ret < 0)\n \t\treturn ret;\n-\t}\n \n \treturn 0;\n }\n@@ -686,7 +679,6 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera)\n {\n \tIPU3CameraData *data = cameraData(camera);\n \n-\tdata->cio2_.freeBuffers();\n \tdata->imgu_->freeBuffers(data);\n \n \treturn 0;\n@@ -731,10 +723,10 @@ error:\n void PipelineHandlerIPU3::stop(Camera *camera)\n {\n \tIPU3CameraData *data = cameraData(camera);\n-\tint ret;\n+\tint ret = 0;\n \n-\tret = data->cio2_.stop();\n \tret |= data->imgu_->stop();\n+\tret |= data->cio2_.stop();\n \tif (ret)\n \t\tLOG(IPU3, Warning) << \"Failed to stop camera \"\n \t\t\t\t << camera->name();\n", "prefixes": [ "libcamera-devel", "v3", "09/10" ] }