Show a patch.

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

{
    "id": 9176,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/9176/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9176/",
    "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": "<20200804095850.275499-12-naush@raspberrypi.com>",
    "date": "2020-08-04T09:58:49",
    "name": "[libcamera-devel,v6,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/1.1/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/9176/mbox/",
    "series": [
        {
            "id": 1187,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1187/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1187",
            "date": "2020-08-04T09:58:38",
            "name": "Zero-copy RAW stream work",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/1187/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9176/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9176/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 CF995BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  4 Aug 2020 09:59:09 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7E5FB60550;\n\tTue,  4 Aug 2020 11:59:09 +0200 (CEST)",
            "from mail-wm1-x343.google.com (mail-wm1-x343.google.com\n\t[IPv6:2a00:1450:4864:20::343])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E9D2A60553\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Aug 2020 11:59:07 +0200 (CEST)",
            "by mail-wm1-x343.google.com with SMTP id k8so2295194wma.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 04 Aug 2020 02:59:07 -0700 (PDT)",
            "from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\t32sm34047234wrh.18.2020.08.04.02.59.06\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 04 Aug 2020 02:59:06 -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=\"hpy6X1SM\"; 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=Ryz+jGxeBqsKM7XD/dNKRoalEXGdhWc/8wLotbzodnc=;\n\tb=hpy6X1SMG640fhafI/7ZOndJb7T698yNo1CAqXPeBy/V5YYS63yjFVKqgVszx334Bi\n\tbEK14MRKXjmQ83YKG4TxWyxG81aBds9jUk/F0LF8yH2w/29vwOlLK72JsvadKZbQWs9U\n\tuZk4WYMKrrupnOaZYGheoWFQb8IXf3TmNeQfSwQFd3AgN0nWbPp4SHsrZwI1VvwpyqJj\n\tfWC4guxQZF0f/yCoSUQnbDKF1izUS0+3gr7RQzKq7QiBK/7lPK6/mrVUwSqK1uud5AyX\n\tSk7XxTTEwZ/EFnw83vhr+FgQ4WVjTep1kgIXeMz6zACzm315UEC06Fa1T7Pu31778tI3\n\tk8bA==",
        "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=Ryz+jGxeBqsKM7XD/dNKRoalEXGdhWc/8wLotbzodnc=;\n\tb=pePGEjCvou32IacNKjibglElOWR9sb2Gb+iNkCf/9V4O48lz1R60dKTHB7XWS2ZA2+\n\trA0K5mnFJhCC0aFpBqWCHoYKe49XcxqTUTT8vCh7uYRqXj1876y3pDlzcGZyGFPpbTgQ\n\t/TMm+jOPHuzGW9ydilIEVtHqQFueZaA9aSmoTK/xWjjCGcRWeFHRRVYmXPoCryO5ix3i\n\tw7p9ztxnrgx1rYLXkVe08XNf5BwQEfthKd1XXpi6cIHtxrYezXBhxD3ueA3LYPTkt1D+\n\tyL+w7vOnrKnMwKnnjf20F37fslN+bRaov+U8q/XL//pqJDrXSGbFTcLhbCffdFwCsOrp\n\tO6xg==",
        "X-Gm-Message-State": "AOAM533kyY7St53JZprdbbISg9EiW/AlVMKZLucbA2PpG0x9HQe/42Kx\n\tjbl4XboefZl93W36s31Yzz40MnO7vv0wWQ==",
        "X-Google-Smtp-Source": "ABdhPJx2rLcGRa2zpPy50K6RliXtgW69q7a2kbinFvuEoWDWQ7NzNYUb31E8YJoGZl4JzAiyzDAxBQ==",
        "X-Received": "by 2002:a1c:1f12:: with SMTP id f18mr3513251wmf.66.1596535147261;\n\tTue, 04 Aug 2020 02:59:07 -0700 (PDT)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  4 Aug 2020 10:58:49 +0100",
        "Message-Id": "<20200804095850.275499-12-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200804095850.275499-1-naush@raspberrypi.com>",
        "References": "<20200804095850.275499-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v6 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 8cfa87be..b059c582 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@@ -901,36 +903,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",
        "v6",
        "11/12"
    ]
}