Show a patch.

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

{
    "id": 3350,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3350/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3350/",
    "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": "<20200326225844.4117712-7-niklas.soderlund@ragnatech.se>",
    "date": "2020-03-26T22:58:43",
    "name": "[libcamera-devel,v2,6/7] libcamera: ipu3: Do not unconditionally queue buffers to CIO2",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "02fb2ebbae92cc0ac607605ead318155c4942385",
    "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/3350/mbox/",
    "series": [
        {
            "id": 785,
            "url": "https://patchwork.libcamera.org/api/1.1/series/785/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=785",
            "date": "2020-03-26T22:58:37",
            "name": "libcamera: Add support for a RAW still capture",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/785/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3350/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3350/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 2149862D31\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Mar 2020 23:59:01 +0100 (CET)",
            "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 60183a52-6fb5-11ea-aeed-005056917f90;\n\tThu, 26 Mar 2020 23:58:58 +0100 (CET)"
        ],
        "X-Halon-ID": "60183a52-6fb5-11ea-aeed-005056917f90",
        "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": "Thu, 26 Mar 2020 23:58:43 +0100",
        "Message-Id": "<20200326225844.4117712-7-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200326225844.4117712-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200326225844.4117712-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 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": "Thu, 26 Mar 2020 22:59:01 -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>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n* Changes since v1\n- Update comments\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..0933a03c9f718591 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, associate it with the request and queue it. */\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",
        "v2",
        "6/7"
    ]
}