Patch Detail
Show a patch.
GET /api/1.1/patches/1540/?format=api
{ "id": 1540, "url": "https://patchwork.libcamera.org/api/1.1/patches/1540/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1540/", "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": "<20190630181049.9548-8-jacopo@jmondi.org>", "date": "2019-06-30T18:10:48", "name": "[libcamera-devel,RFC,7/8] libcamera: request: Support buffer mapping", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "5b729ebc9be182702e56f76d12e8a32dabb56292", "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/1540/mbox/", "series": [ { "id": 383, "url": "https://patchwork.libcamera.org/api/1.1/series/383/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=383", "date": "2019-06-30T18:10:41", "name": "libcamera: Add support for importing external memory buffers", "version": 1, "mbox": "https://patchwork.libcamera.org/series/383/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1540/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1540/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 46FC561F63\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 30 Jun 2019 20:09:41 +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 DEDB2200003;\n\tSun, 30 Jun 2019 18:09:40 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 30 Jun 2019 20:10:48 +0200", "Message-Id": "<20190630181049.9548-8-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190630181049.9548-1-jacopo@jmondi.org>", "References": "<20190630181049.9548-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC 7/8] libcamera: request: Support buffer\n\tmapping", "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": "Sun, 30 Jun 2019 18:09:42 -0000" }, "content": "Use the Stream class buffer mapping operation to save the association in\nthe request at Request::findBuffer() time and reverse it with a new\noperation Request::unmapBuffer() used by the pipeline handler base class\nat buffer completion time, to return to the applications the Buffer they\noriginally provided with the Request without involving the pipeline\nhandlers.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/request.h | 4 +++-\n src/libcamera/pipeline_handler.cpp | 6 ++++--\n src/libcamera/request.cpp | 27 ++++++++++++++++++++++++++-\n 3 files changed, 33 insertions(+), 4 deletions(-)", "diff": "diff --git a/include/libcamera/request.h b/include/libcamera/request.h\nindex 7adb753b2706..c22b6be282b2 100644\n--- a/include/libcamera/request.h\n+++ b/include/libcamera/request.h\n@@ -34,7 +34,8 @@ public:\n \n \tconst std::map<Stream *, Buffer *> &buffers() const { return buffers_; }\n \tint setBuffers(const std::map<Stream *, Buffer *> &streamMap);\n-\tBuffer *findBuffer(Stream *stream) const;\n+\tBuffer *findBuffer(Stream *stream);\n+\tBuffer *unmapBuffer(Buffer *streamBuffer);\n \n \tStatus status() const { return status_; }\n \n@@ -52,6 +53,7 @@ private:\n \tCamera *camera_;\n \tstd::map<Stream *, Buffer *> buffers_;\n \tstd::unordered_set<Buffer *> pending_;\n+\tstd::map<Buffer *, Buffer *> bufferMap_;\n \n \tStatus status_;\n };\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex fbebe4a04acd..1dcfefaaf6eb 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -383,8 +383,10 @@ int PipelineHandler::queueRequest(Camera *camera, Request *request)\n bool PipelineHandler::completeBuffer(Camera *camera, Request *request,\n \t\t\t\t Buffer *buffer)\n {\n-\tcamera->bufferCompleted.emit(request, buffer);\n-\treturn request->completeBuffer(buffer);\n+\tBuffer *requestBuffer = request->unmapBuffer(buffer);\n+\n+\tcamera->bufferCompleted.emit(request, requestBuffer);\n+\treturn request->completeBuffer(requestBuffer);\n }\n \n /**\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex def7f2f21dc7..bfe6fc99a93b 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -94,12 +94,37 @@ int Request::setBuffers(const std::map<Stream *, Buffer *> &streamMap)\n * \\return The buffer associated with the stream, or nullptr if the stream is\n * not part of this request\n */\n-Buffer *Request::findBuffer(Stream *stream) const\n+Buffer *Request::findBuffer(Stream *stream)\n {\n \tauto it = buffers_.find(stream);\n \tif (it == buffers_.end())\n \t\treturn nullptr;\n \n+\t/*\n+\t * Streams with internal memory mode do not need to perform any mapping\n+\t * between the application provided buffers (part of the request)\n+\t * and the one actually used by the Stream.\n+\t *\n+\t * Streams using externally allocated buffers need to create a mapping\n+\t * between the application provided buffers and the one used by pipeline\n+\t * handlers.\n+\t */\n+\tBuffer *requestBuffer = it->second;\n+\tBuffer *mappedBuffer = stream->memoryType() == InternalMemory ?\n+\t\t\t it->second : stream->mapBuffer(it->second);\n+\tbufferMap_[mappedBuffer] = requestBuffer;\n+\n+\treturn mappedBuffer;\n+}\n+\n+/**\n+ * \\brief Retrieve the application buffer associated with \\a streamBuffer\n+ */\n+Buffer *Request::unmapBuffer(Buffer *streamBuffer)\n+{\n+\tauto it = bufferMap_.find(streamBuffer);\n+\tASSERT(it != bufferMap_.end());\n+\n \treturn it->second;\n }\n \n", "prefixes": [ "libcamera-devel", "RFC", "7/8" ] }