Patch Detail
Show a patch.
GET /api/patches/9527/?format=api
{ "id": 9527, "url": "https://patchwork.libcamera.org/api/patches/9527/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9527/", "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": "<20200908074913.109244-12-naush@raspberrypi.com>", "date": "2020-09-08T07:49:11", "name": "[libcamera-devel,v7,11/12] pipeline: raspberrypi: Use an unordered_set to store IPA buffer ids", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "1019b37960c3cf9040ed77b5b8faf6cf47935290", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9527/mbox/", "series": [ { "id": 1271, "url": "https://patchwork.libcamera.org/api/series/1271/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1271", "date": "2020-09-08T07:49:00", "name": "Zero-copy RAW stream work", "version": 7, "mbox": "https://patchwork.libcamera.org/series/1271/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9527/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9527/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 29077BDB1E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 8 Sep 2020 07:49:32 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E50D262C31;\n\tTue, 8 Sep 2020 09:49:31 +0200 (CEST)", "from mail-wr1-x444.google.com (mail-wr1-x444.google.com\n\t[IPv6:2a00:1450:4864:20::444])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0751D62C27\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Sep 2020 09:49:31 +0200 (CEST)", "by mail-wr1-x444.google.com with SMTP id c18so17983310wrm.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Sep 2020 00:49:31 -0700 (PDT)", "from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tq15sm32534502wrr.8.2020.09.08.00.49.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 08 Sep 2020 00:49:29 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"J3qecZdC\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=DXlCmLR+6xccYNyuaOP6y9KyOurPOW50qeSaoIlpP0U=;\n\tb=J3qecZdCdqzu4aTjuSiWiujdiDxwvaMFQ0RL1U0jlH4M+isLA0FXAdQ3TLF3nZLpp3\n\tTHNsv9D2T8OfiMZUFY1iMqs85jfbm6GLsE+Pyi8xskj/djVdcKyCE9P9vbFkIpIB+KMG\n\tJbGoVnnfjvN4sjFOB/Cg0m0Vzq9E0fjMT2o+JN9fT039PvC1IPQmA1yxS07+cchiOdae\n\tAJybdGpIBChYJwDGRg06bht0x2rHEvF673skikXT7kHcN95IU5uov2fU9gn+S+9a+UE2\n\tR2F8vWruGpvq9Dhao6s5NKqugUHnjuQvH74NDwNycweSSXMb00wc/0iq91ER8eRfuasX\n\tnoXA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=DXlCmLR+6xccYNyuaOP6y9KyOurPOW50qeSaoIlpP0U=;\n\tb=t9kUTa9d9a8hTQsGsSel+P2BU7sNdxWoMGFkIVfc76NbL8pWFebWAk72HJK/SiJeWq\n\tnYeZJiO13yEziojOzHz5rbR1PrHMGW2fomptrNccRms5RsKzTj4wshqYPb+d2GCMAA4B\n\tMsQ1zrBltfjCum7l46/hgTZIb3IGm9UaHy0IUOK6cMoGn7FNRPNegC+NH8RG3gWnJ0Nw\n\tnEyiCp+z6kDNLUS8ukyX0AiLR9v69iJiQyETVmXe/Jo5WoI+o48iGwmWr/gcseoyDKD/\n\tna3Q0vALuWhWvPlB6vVClBcZQmYrer8854VU+eo7OGhFSQnQnPPZgrsPBR1t9xoq8bue\n\t84ZA==", "X-Gm-Message-State": "AOAM532G/57jSVCTFSXmiwPzhKBbTvZ3DnlhOjaXJ+xzFRmhVD1D2Ju7\n\tDEuFGUcGNR4Bl+AhFnk01wVcqy1JeJZmeA==", "X-Google-Smtp-Source": "ABdhPJxK6sXfE5f4/mo4nxcSvi1JHTSv/LqPIgmo2VzgzpjW5vILEfiuJWeLupxpW3fXonsKkRmCsg==", "X-Received": "by 2002:adf:81c6:: with SMTP id\n\t64mr24475854wra.176.1599551370455; \n\tTue, 08 Sep 2020 00:49:30 -0700 (PDT)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 8 Sep 2020 08:49:11 +0100", "Message-Id": "<20200908074913.109244-12-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20200908074913.109244-1-naush@raspberrypi.com>", "References": "<20200908074913.109244-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v7 11/12] pipeline: raspberrypi: Use an\n\tunordered_set to store IPA buffer ids", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "By using a set container, we can easily insert/remove buffer ids that have\nbeen mmaped by the IPA. This will be required to track buffers allocated\nexternally and passed to the pipeline handler through a Request.\n\nMove the IPA buffer mapping code into a function to remove duplicated\ncode.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp | 48 +++++++++++--------\n 1 file changed, 28 insertions(+), 20 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 6aa13034..5621f182 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -10,6 +10,7 @@\n #include <mutex>\n #include <queue>\n #include <sys/mman.h>\n+#include <unordered_set>\n \n #include <libcamera/camera.h>\n #include <libcamera/control_ids.h>\n@@ -158,8 +159,8 @@ public:\n \tRPi::RPiDevice<Isp, 4> isp_;\n \t/* The vector below is just for convenience when iterating over all streams. */\n \tstd::vector<RPi::RPiStream *> streams_;\n-\t/* Buffers passed to the IPA. */\n-\tstd::vector<IPABuffer> ipaBuffers_;\n+\t/* Stores the ids of the buffers mapped in the IPA. */\n+\tstd::unordered_set<unsigned int> ipaBuffers_;\n \n \t/* DMAHEAP allocation helper. */\n \tRPi::DmaHeap dmaHeap_;\n@@ -230,6 +231,7 @@ private:\n \tint queueAllBuffers(Camera *camera);\n \tint prepareBuffers(Camera *camera);\n \tvoid freeBuffers(Camera *camera);\n+\tvoid mapBuffers(Camera *camera, const RPi::BufferMap &buffers, unsigned int mask);\n \n \tMediaDevice *unicam_;\n \tMediaDevice *isp_;\n@@ -910,36 +912,42 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t}\n \n \t/*\n-\t * Link the FrameBuffers with the index of their position in the vector\n-\t * stored in the RPi stream object.\n+\t * Pass the stats and embedded data buffers to the IPA. No other\n+\t * buffers need to be passed.\n+\t */\n+\tmapBuffers(camera, data->isp_[Isp::Stats].getBuffers(), RPiIpaMask::STATS);\n+\tmapBuffers(camera, data->unicam_[Unicam::Embedded].getBuffers(), RPiIpaMask::EMBEDDED_DATA);\n+\n+\treturn 0;\n+}\n+\n+void PipelineHandlerRPi::mapBuffers(Camera *camera, const RPi::BufferMap &buffers, unsigned int mask)\n+{\n+\tRPiCameraData *data = cameraData(camera);\n+\tstd::vector<IPABuffer> ipaBuffers;\n+\t/*\n+\t * Link the FrameBuffers with the id (key value) in the map stored in\n+\t * the RPi stream object - along with an identifer mask.\n \t *\n \t * This will allow us to identify buffers passed between the pipeline\n \t * handler and the IPA.\n \t */\n-\tfor (auto const &b : data->isp_[Isp::Stats].getBuffers()) {\n-\t\tdata->ipaBuffers_.push_back({ .id = RPiIpaMask::STATS | b.first,\n-\t\t\t\t\t .planes = b.second->planes() });\n-\t}\n-\n-\tfor (auto const &b : data->unicam_[Unicam::Embedded].getBuffers()) {\n-\t\tdata->ipaBuffers_.push_back({ .id = RPiIpaMask::EMBEDDED_DATA | b.first,\n-\t\t\t\t\t .planes = b.second->planes() });\n+\tfor (auto const &it : buffers) {\n+\t\tipaBuffers.push_back({ .id = mask | it.first,\n+\t\t\t\t .planes = it.second->planes() });\n+\t\tdata->ipaBuffers_.insert(mask | it.first);\n \t}\n \n-\tdata->ipa_->mapBuffers(data->ipaBuffers_);\n-\n-\treturn 0;\n+\tdata->ipa_->mapBuffers(ipaBuffers);\n }\n \n void PipelineHandlerRPi::freeBuffers(Camera *camera)\n {\n \tRPiCameraData *data = cameraData(camera);\n \n-\tstd::vector<unsigned int> ids;\n-\tfor (IPABuffer &ipabuf : data->ipaBuffers_)\n-\t\tids.push_back(ipabuf.id);\n-\n-\tdata->ipa_->unmapBuffers(ids);\n+\t/* Copy the buffer ids from the unordered_set to a vector to pass to the IPA. */\n+\tstd::vector<unsigned int> ipaBuffers(data->ipaBuffers_.begin(), data->ipaBuffers_.end());\n+\tdata->ipa_->unmapBuffers(ipaBuffers);\n \tdata->ipaBuffers_.clear();\n \n \tfor (auto const stream : data->streams_)\n", "prefixes": [ "libcamera-devel", "v7", "11/12" ] }