Patch Detail
Show a patch.
GET /api/1.1/patches/1000/?format=api
{ "id": 1000, "url": "https://patchwork.libcamera.org/api/1.1/patches/1000/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1000/", "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": "<20190415231859.9747-8-jacopo@jmondi.org>", "date": "2019-04-15T23:18:59", "name": "[libcamera-devel,v5,7/7] libcamera: buffer: Store Request reference in Buffer", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9432835bb12a756438117277b151b7a849d8c3dc", "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/1000/mbox/", "series": [ { "id": 251, "url": "https://patchwork.libcamera.org/api/1.1/series/251/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=251", "date": "2019-04-15T23:18:52", "name": "libcamera: Framework changes to prepare for multiple streams support", "version": 5, "mbox": "https://patchwork.libcamera.org/series/251/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1000/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1000/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 89FC660DC1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2019 01:18:23 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 204781BF205;\n\tMon, 15 Apr 2019 23:18:22 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 16 Apr 2019 01:18:59 +0200", "Message-Id": "<20190415231859.9747-8-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190415231859.9747-1-jacopo@jmondi.org>", "References": "<20190415231859.9747-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 7/7] 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": "Mon, 15 Apr 2019 23:18:24 -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 temporary valid during the buffer completion interval\n(since when the buffer gets queued to Camera for processing, until it\ngets marked as completed).\n\nTo show this change purpose, use the new Buffer::request() method\nin IPU3 pipeline handler, as it will soon be moved to support multiple\nstreams where buffers might complete in an order different from the request\nqueuing one.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/buffer.h | 6 ++++\n src/libcamera/buffer.cpp | 45 +++++++++++++++++++++++++++-\n src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +-\n src/libcamera/request.cpp | 4 +++\n 4 files changed, 55 insertions(+), 2 deletions(-)", "diff": "diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nindex 0c844d126a27..a2daaaf346dc 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 *req) { request_ = req; }\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..790c6dcffe3a 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,26 @@ 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 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 */\n@@ -259,6 +279,29 @@ void Buffer::cancel()\n \tstatus_ = BufferCancelled;\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+ * The intended caller of this methods is the Request class at\n+ * Request::prepare() time, when it stores a reference to itself through a\n+ * call to this method, and at Request::completeBuffer() time, where it\n+ * invalidates the request_ reference by calling this method with a nullptr as\n+ * argument.\n+ */\n+\n /**\n * \\class BufferPool\n * \\brief A pool of buffers\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 7d865fa329ea..ce680835cec2 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -630,7 +630,7 @@ void PipelineHandlerIPU3::IPU3CameraData::imguInputBufferReady(Buffer *buffer)\n */\n void PipelineHandlerIPU3::IPU3CameraData::imguOutputBufferReady(Buffer *buffer)\n {\n-\tRequest *request = queuedRequests_.front();\n+\tRequest *request = buffer->request();\n \n \tpipe_->completeBuffer(camera_, request, buffer);\n \tpipe_->completeRequest(camera_, request);\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex 7fa034e6c747..6b175e125596 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", "v5", "7/7" ] }