Show a patch.

GET /api/1.1/patches/3305/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 3305,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3305/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3305/",
    "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": "<20200324155145.3896183-7-niklas.soderlund@ragnatech.se>",
    "date": "2020-03-24T15:51:44",
    "name": "[libcamera-devel,6/7] libcamera: ipu3: Do not unconditionally queue buffers to CIO2",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "083b0ca9c18ad16b4d6788b0bf590af83cf8e430",
    "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/3305/mbox/",
    "series": [
        {
            "id": 770,
            "url": "https://patchwork.libcamera.org/api/1.1/series/770/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=770",
            "date": "2020-03-24T15:51:39",
            "name": "libcamera: Add support for a RAW still capture",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/770/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3305/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3305/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 428A462CF0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Mar 2020 16:51:56 +0100 (CET)",
            "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 60d9750c-6de7-11ea-b7d8-005056917a89;\n\tTue, 24 Mar 2020 16:51:51 +0100 (CET)"
        ],
        "X-Halon-ID": "60d9750c-6de7-11ea-b7d8-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, 24 Mar 2020 16:51:44 +0100",
        "Message-Id": "<20200324155145.3896183-7-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200324155145.3896183-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200324155145.3896183-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 6/7] libcamera: ipu3: Do not\n\tunconditionally queue 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": "Tue, 24 Mar 2020 15:51:58 -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 to 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* Changes since RFC\n- Drop cio2ToRequest_ lookup map and use Request * in FrameBuffer.\n- Removed duplicated LOG() from CIO2Device::allocateBuffers.\n- Reassign instead of iterate to empty availableBuffers_.\n- Fold CIO2Device::queueBuffer() into the only caller.\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 53 ++++++++++++++++++++++------\n 1 file changed, 42 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 1b44460e4d887d14..cc602834f24108a7 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/media-bus-format.h>\n@@ -118,6 +119,9 @@ public:\n \tint allocateBuffers();\n \tvoid freeBuffers();\n \n+\tFrameBuffer *getBuffer();\n+\tvoid putBuffer(FrameBuffer *buffer);\n+\n \tint start();\n \tint stop();\n \n@@ -129,6 +133,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@@ -716,11 +721,21 @@ 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+\n+\tbuffer->setRequest(request);\n+\tdata->cio2_.output_->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@@ -892,7 +907,7 @@ void IPU3CameraData::imguInputBufferReady(FrameBuffer *buffer)\n \tif (buffer->metadata().status == FrameMetadata::FrameCancelled)\n \t\treturn;\n \n-\tcio2_.output_->queueBuffer(buffer);\n+\tcio2_.putBuffer(buffer);\n }\n \n /**\n@@ -1416,29 +1431,45 @@ int CIO2Device::allocateBuffers()\n {\n \tint ret = output_->allocateBuffers(CIO2_BUFFER_COUNT, &buffers_);\n \tif (ret < 0)\n-\t\tLOG(IPU3, Error) << \"Failed to allocate CIO2 buffers\";\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 void CIO2Device::freeBuffers()\n {\n+\tavailableBuffers_ = {};\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::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",
        "6/7"
    ]
}