Show a patch.

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

{
    "id": 1040,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/1040/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1040/",
    "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": "<20190418104715.22622-9-jacopo@jmondi.org>",
    "date": "2019-04-18T10:47:09",
    "name": "[libcamera-devel,v5,08/14] libcamera: buffer: Store Request reference in Buffer",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "62ffef6923c01968266362779a8bc0ed860b01b6",
    "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/1040/mbox/",
    "series": [
        {
            "id": 255,
            "url": "https://patchwork.libcamera.org/api/1.1/series/255/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=255",
            "date": "2019-04-18T10:47:01",
            "name": "libcamera: ipu3: Multiple streams support",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/255/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1040/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1040/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 055FA60DC8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Apr 2019 12:46:36 +0200 (CEST)",
            "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 8E5D61C0007;\n\tThu, 18 Apr 2019 10:46:35 +0000 (UTC)"
        ],
        "X-Originating-IP": "2.224.242.101",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 18 Apr 2019 12:47:09 +0200",
        "Message-Id": "<20190418104715.22622-9-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190418104715.22622-1-jacopo@jmondi.org>",
        "References": "<20190418104715.22622-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 08/14] libcamera: buffer: Store Request\n\treference in Buffer",
        "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": "Thu, 18 Apr 2019 10:46:37 -0000"
    },
    "content": "Add to the Buffer class methods to set and retrieve a reference to the\nRequest instance the buffer is part of.\n\nAs buffers might outlive the Request they are associated with, the\nreference is only temporary valid during the buffer completion interval\n(from when the buffer gets queued to Camera for processing, until it\ngets marked as completed).\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/buffer.h |  6 ++++++\n src/libcamera/buffer.cpp   | 25 ++++++++++++++++++++++++-\n src/libcamera/request.cpp  |  3 +++\n 3 files changed, 33 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nindex 0c844d126a27..8f9b42e39339 100644\n--- a/include/libcamera/buffer.h\n+++ b/include/libcamera/buffer.h\n@@ -13,6 +13,7 @@\n namespace libcamera {\n \n class BufferPool;\n+class Request;\n \n class Plane final\n {\n@@ -52,14 +53,18 @@ public:\n \tunsigned int sequence() const { return sequence_; }\n \tStatus status() const { return status_; }\n \tstd::vector<Plane> &planes() { return planes_; }\n+\tRequest *request() const { return request_; }\n \n private:\n \tfriend class BufferPool;\n \tfriend class PipelineHandler;\n+\tfriend class Request;\n \tfriend class V4L2Device;\n \n \tvoid cancel();\n \n+\tvoid setRequest(Request *request) { request_ = request; }\n+\n \tunsigned int index_;\n \tunsigned int bytesused_;\n \tuint64_t timestamp_;\n@@ -67,6 +72,7 @@ private:\n \tStatus status_;\n \n \tstd::vector<Plane> planes_;\n+\tRequest *request_;\n };\n \n class BufferPool final\ndiff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\nindex e2d1cf04411e..8261ca41d62e 100644\n--- a/src/libcamera/buffer.cpp\n+++ b/src/libcamera/buffer.cpp\n@@ -196,7 +196,7 @@ void *Plane::mem()\n  */\n \n Buffer::Buffer()\n-\t: index_(-1)\n+\t: index_(-1), request_(nullptr)\n {\n }\n \n@@ -248,6 +248,22 @@ Buffer::Buffer()\n  * \\return The buffer status\n  */\n \n+/**\n+ * \\fn Buffer::request()\n+ * \\brief Retrieve the request this buffer belongs to\n+ *\n+ * The intended callers of this method are buffer completion handlers that\n+ * needs to associate a buffer to the request it belongs to.\n+ *\n+ * A Buffer is associated to a request by Request::prepare() and the\n+ * association is valid until the buffer completes. The returned request\n+ * pointer is valid only during that interval.\n+ *\n+ * \\return The Request the Buffer belongs to, or nullptr if the buffer is\n+ * either completed or not associated with a request\n+ * \\sa Buffer::setRequest()\n+ */\n+\n /**\n  * \\brief Mark a buffer as cancel by setting its status to BufferCancelled\n  */\n@@ -259,6 +275,13 @@ void Buffer::cancel()\n \tstatus_ = BufferCancelled;\n }\n \n+/**\n+ * \\fn Buffer::setRequest()\n+ * \\brief Set the request this buffer belongs to\n+ *\n+ * The intended callers are Request::prepare() and Request::completeBuffer().\n+ */\n+\n /**\n  * \\class BufferPool\n  * \\brief A pool of buffers\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex c429d1fb2f8a..855da7c245e9 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -136,6 +136,7 @@ int Request::prepare()\n {\n \tfor (auto const &pair : bufferMap_) {\n \t\tBuffer *buffer = pair.second;\n+\t\tbuffer->setRequest(this);\n \t\tpending_.insert(buffer);\n \t}\n \n@@ -177,6 +178,8 @@ bool Request::completeBuffer(Buffer *buffer)\n \tint ret = pending_.erase(buffer);\n \tASSERT(ret == 1);\n \n+\tbuffer->setRequest(nullptr);\n+\n \treturn !hasPendingBuffers();\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "v5",
        "08/14"
    ]
}