Show a patch.

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

{
    "id": 10421,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10421/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10421/",
    "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": "<20201113085657.34086-1-naush@raspberrypi.com>",
    "date": "2020-11-13T08:56:56",
    "name": "[libcamera-devel,1/2] pipeline: raspberrypi: Use MappedFrameBuffer for embedded data buffers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f8c0d6f69abdd545ee65e6e7bcbcba5162dcea14",
    "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/10421/mbox/",
    "series": [
        {
            "id": 1459,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1459/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1459",
            "date": "2020-11-13T08:56:56",
            "name": "[libcamera-devel,1/2] pipeline: raspberrypi: Use MappedFrameBuffer for embedded data buffers",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1459/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10421/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10421/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 5FE2BBE082\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Nov 2020 08:57:03 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A8B46631BA;\n\tFri, 13 Nov 2020 09:57:02 +0100 (CET)",
            "from mail-wm1-x336.google.com (mail-wm1-x336.google.com\n\t[IPv6:2a00:1450:4864:20::336])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9DFE1631B0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Nov 2020 09:57:01 +0100 (CET)",
            "by mail-wm1-x336.google.com with SMTP id w24so7700632wmi.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Nov 2020 00:57:01 -0800 (PST)",
            "from naushir-VirtualBox.pitowers.org\n\t([2a00:1098:3142:14:a00:27ff:fe4d:f6a2])\n\tby smtp.gmail.com with ESMTPSA id\n\tv8sm9266184wmg.28.2020.11.13.00.56.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 13 Nov 2020 00:57:00 -0800 (PST)"
        ],
        "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=\"BzCxogPO\"; 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:mime-version\n\t:content-transfer-encoding;\n\tbh=UJdolys+WSJVKPXmuVms/SsEXhD62UGdUH3Pqy0i8ag=;\n\tb=BzCxogPOgSTXmQ0rKVDo9x6U2Rzd6BemQZiczcVY38u4JQ/82rCfaf9QNuHROdmrq1\n\tBXK3y+0WCRzXI7abyEDiivNQ3yPb5QvwX7dE/kpKfZk8FlA2FcmZ2kU39GDaUUuy9tMl\n\tCSJ6XmTI+0zITs6qdasNOwmYzVztY8QTjnqrTgZOL3fsKVN2HpN5t/ih8t3xH7at4n7w\n\tYwhMhKhskU82RppCmoskOrNgtVsPXHpgjHn8I4PtK3Sg5mAIXXvTb2mIYU5LvogOuKOX\n\t6PxtK7Mfs6RiOJJKdF8bkyV+ES21SI8Qs4WzdzplyzxaWSyWULWdajy2QeFSvUPj+kn1\n\t5iLQ==",
        "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:mime-version\n\t:content-transfer-encoding;\n\tbh=UJdolys+WSJVKPXmuVms/SsEXhD62UGdUH3Pqy0i8ag=;\n\tb=JqfCzPpNix006+KimsQvIJxrOhm2FkGk3U0CrjjCfN5+oxtLYSAA9raQU9l/tHZPt8\n\tfdaOcIW12v/pdY3xYt+WA5fySLfuaCDdlmZ98G02wef6Zh/7PmGpXCaR4BQGUw/Ofict\n\tXZ73S+xm5NPqLgBocjnpNHUfN/XX4xtRSYHslO08xQpLtaZGP70/R6/q4hFAcCJG9SRV\n\tOIqJ4sxw0tlxVFLFdEy/sZ74o0B8FwlIE8rdVvb4v9A/FZ/RFqcDI17sfWx+rd9UzKZ8\n\tNt9kQG8fghon1JlMyAPc8hEskWPPne3W/xwNXe9pHbYDYBNntVYQ4Sv380pONXamxj1N\n\tKQcA==",
        "X-Gm-Message-State": "AOAM5319e32NMxCMfttsgxIZiEaCZ1nqU3LS8CePq331a46ZpNmzC6uk\n\tLuwEgjQ6t7w1uFSnPJ7ywvLhu39P0doY7OZ2",
        "X-Google-Smtp-Source": "ABdhPJyWZGLvMSh19r9ePaoXzah0BlFjdl+t1RRTOcjUXf3c+LHUzQSEe09vV90R/JL2at/t1xR0KA==",
        "X-Received": "by 2002:a05:600c:288:: with SMTP id\n\t8mr1437382wmk.106.1605257820915; \n\tFri, 13 Nov 2020 00:57:00 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 13 Nov 2020 08:56:56 +0000",
        "Message-Id": "<20201113085657.34086-1-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 1/2] pipeline: raspberrypi: Use\n\tMappedFrameBuffer for embedded data buffers",
        "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": "Use a MappedFrameBuffer to mmap embedded data buffers for the pipeline\nhandler to use in the cases where the sensor does not fill it in. This\navoids the need to mmap and unmap on every frame.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 33 ++++++++++++++-----\n 1 file changed, 25 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex dd62dfc7..faa06c00 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -24,6 +24,7 @@\n #include <linux/videodev2.h>\n \n #include \"libcamera/internal/bayer_format.h\"\n+#include \"libcamera/internal/buffer.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/ipa_manager.h\"\n@@ -165,6 +166,12 @@ public:\n \t/* Stores the ids of the buffers mapped in the IPA. */\n \tstd::unordered_set<unsigned int> ipaBuffers_;\n \n+\t/*\n+\t * Map of (internal) mmaped embedded data buffers, to avoid having to\n+\t * map/unmap on every frame.\n+\t */\n+\tstd::map<unsigned int, MappedFrameBuffer> mappedEmbeddedBuffers_;\n+\n \t/* DMAHEAP allocation helper. */\n \tRPi::DmaHeap dmaHeap_;\n \tFileDescriptor lsTable_;\n@@ -1040,6 +1047,13 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t\t\treturn ret;\n \t}\n \n+\tif (!data->sensorMetadata_) {\n+\t\tfor (auto const &it : data->unicam_[Unicam::Embedded].getBuffers()) {\n+\t\t\tdata->mappedEmbeddedBuffers_.emplace(it.first,\n+\t\t\t\t\t\t\t     MappedFrameBuffer(it.second, PROT_READ | PROT_WRITE));\n+\t\t}\n+\t}\n+\n \t/*\n \t * Pass the stats and embedded data buffers to the IPA. No other\n \t * buffers need to be passed.\n@@ -1078,6 +1092,7 @@ void PipelineHandlerRPi::freeBuffers(Camera *camera)\n \tstd::vector<unsigned int> ipaBuffers(data->ipaBuffers_.begin(), data->ipaBuffers_.end());\n \tdata->ipa_->unmapBuffers(ipaBuffers);\n \tdata->ipaBuffers_.clear();\n+\tdata->mappedEmbeddedBuffers_.clear();\n \n \tfor (auto const stream : data->streams_)\n \t\tstream->releaseBuffers();\n@@ -1310,14 +1325,16 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n \t\t * metadata buffer.\n \t\t */\n \t\tif (!sensorMetadata_) {\n-\t\t\tconst FrameBuffer &fb = buffer->planes();\n-\t\t\tuint32_t *mem = static_cast<uint32_t *>(::mmap(nullptr, fb.planes()[0].length,\n-\t\t\t\t\t\t\t\t       PROT_READ | PROT_WRITE,\n-\t\t\t\t\t\t\t\t       MAP_SHARED,\n-\t\t\t\t\t\t\t\t       fb.planes()[0].fd.fd(), 0));\n-\t\t\tmem[0] = ctrl[V4L2_CID_EXPOSURE];\n-\t\t\tmem[1] = ctrl[V4L2_CID_ANALOGUE_GAIN];\n-\t\t\tmunmap(mem, fb.planes()[0].length);\n+\t\t\tunsigned int bufferId = unicam_[Unicam::Embedded].getBufferId(buffer);\n+\t\t\tauto it = mappedEmbeddedBuffers_.find(bufferId);\n+\t\t\tif (it != mappedEmbeddedBuffers_.end()) {\n+\t\t\t\tuint32_t *mem = reinterpret_cast<uint32_t *>(it->second.maps()[0].data());\n+\t\t\t\tmem[0] = ctrl[V4L2_CID_EXPOSURE];\n+\t\t\t\tmem[1] = ctrl[V4L2_CID_ANALOGUE_GAIN];\n+\t\t\t} else {\n+\t\t\t\tLOG(RPI, Warning) << \"Failed to find embedded buffer \"\n+\t\t\t\t\t\t  << bufferId;\n+\t\t\t}\n \t\t}\n \t}\n \n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}