Show a patch.

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

{
    "id": 964,
    "url": "https://patchwork.libcamera.org/api/patches/964/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/964/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20190409192548.20325-10-jacopo@jmondi.org>",
    "date": "2019-04-09T19:25:45",
    "name": "[libcamera-devel,v4,09/12] libcamera: buffer: Store Request reference in Buffer",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "d68d9595dfbfb9c7e15f61ed976282f7d9a38a31",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/964/mbox/",
    "series": [
        {
            "id": 247,
            "url": "https://patchwork.libcamera.org/api/series/247/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=247",
            "date": "2019-04-09T19:25:36",
            "name": "libcamera: ipu3: Multiple streams support",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/247/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/964/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/964/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D216360DC2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Apr 2019 21:25:10 +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 relay12.mail.gandi.net (Postfix) with ESMTPSA id 6CF5020000B;\n\tTue,  9 Apr 2019 19:25:10 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  9 Apr 2019 21:25:45 +0200",
        "Message-Id": "<20190409192548.20325-10-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190409192548.20325-1-jacopo@jmondi.org>",
        "References": "<20190409192548.20325-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 09/12] 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": "Tue, 09 Apr 2019 19:25:12 -0000"
    },
    "content": "Add to the Buffer class methods to set and retrieve a reference to the\nRequest instance this buffer is part of.\n\nAs Buffers might outlive the Request they are associated with, the\nreference is only temporarly valid during the buffer completion interval\n(since 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 |  5 +++++\n src/libcamera/buffer.cpp   | 39 +++++++++++++++++++++++++++++++++++++-\n src/libcamera/request.cpp  |  4 ++++\n 3 files changed, 47 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nindex 0c844d126a27..10c46cd57ab0 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@@ -53,6 +54,9 @@ public:\n \tStatus status() const { return status_; }\n \tstd::vector<Plane> &planes() { return planes_; }\n \n+\tvoid setRequest(Request *req) { request_ = req; }\n+\tRequest *request() const { return request_; }\n+\n private:\n \tfriend class BufferPool;\n \tfriend class PipelineHandler;\n@@ -67,6 +71,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..68738b733ba6 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,43 @@ Buffer::Buffer()\n  * \\return The buffer status\n  */\n \n+/**\n+ * \\fn Buffer::setRequest()\n+ * \\brief Set the request this buffer belongs to\n+ *\n+ * Buffers are associated to Streams in a Request, which is then sent to the\n+ * Camera for processing. This method stores in the Buffer a pointer to the\n+ * Request this Buffer is part of, for later retrieval through the\n+ * Buffer::request() method.\n+ *\n+ * Buffers are associated to requests at Request::prepare() time and said\n+ * association is valid until the buffer does not complete at\n+ * Request::completeBuffer() time. Before and after the buffer completion\n+ * interval (the time between when the request is queued to the Camera, and\n+ * the buffer is marked as 'complete' by pipeline handlers) the reference to\n+ * Request is set to nullptr.\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 slots\n+ * implemented in CameraData sub-classes which needs to associated a request\n+ * to the just completed buffer, before calling Request::completeBuffer().\n+ *\n+ * It is up to the caller of this function to deal with the case the buffer has\n+ * been already marked as complete, and the reference to the Request has been\n+ * invalidated and set to nullptr.\n+ *\n+ * See also Buffer::setRequest() for a more detailed explanation of the\n+ * validity interval of the Request reference contained in a Buffer.\n+ *\n+ * \\return The Request this Buffer belongs to or nullptr if the Buffer has\n+ * not been queued to the Camera for processing yet or it has completed already.\n+ * \\sa Buffer::setRequest()\n+ */\n+\n /**\n  * \\brief Mark a buffer as cancel by setting its status to BufferCancelled\n  */\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex 3e10c995a6fa..7d80c635fa92 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -130,6 +130,8 @@ int Request::prepare()\n {\n \tfor (auto const &pair : bufferMap_) {\n \t\tBuffer *buffer = pair.second;\n+\n+\t\tbuffer->setRequest(this);\n \t\tpending_.insert(buffer);\n \t}\n \n@@ -166,6 +168,8 @@ bool Request::completeBuffer(Buffer *buffer)\n \tint ret = pending_.erase(buffer);\n \tASSERT(ret == 1);\n \n+\tbuffer->setRequest(nullptr);\n+\n \treturn empty();\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "09/12"
    ]
}