Show a patch.

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

{
    "id": 10251,
    "url": "https://patchwork.libcamera.org/api/patches/10251/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10251/",
    "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": "<20201026095356.442605-2-naush@raspberrypi.com>",
    "date": "2020-10-26T09:53:56",
    "name": "[libcamera-devel,2/2] ipa: raspberrypi: Use MappedFrameBuffer for the IPA buffers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b8b57bb0de08f5ba7313515dc41c10ed96f54ca1",
    "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/10251/mbox/",
    "series": [
        {
            "id": 1415,
            "url": "https://patchwork.libcamera.org/api/series/1415/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1415",
            "date": "2020-10-26T09:53:55",
            "name": "[libcamera-devel,1/2] pipeline: raspberrypi: Use MappedFrameBuffer for embedded data buffers",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1415/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10251/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10251/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 2B2E7BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Oct 2020 09:54:02 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4668961E50;\n\tMon, 26 Oct 2020 10:54:01 +0100 (CET)",
            "from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 296986034D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Oct 2020 10:54:00 +0100 (CET)",
            "by mail-wr1-x42a.google.com with SMTP id h5so11623683wrv.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Oct 2020 02:54:00 -0700 (PDT)",
            "from naushir-VirtualBox.pitowers.org\n\t([2a00:1098:3142:14:a00:27ff:fe4d:f6a2])\n\tby smtp.gmail.com with ESMTPSA id\n\tl8sm22157508wrn.28.2020.10.26.02.53.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 26 Oct 2020 02:53:59 -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=\"ICcPY5mM\"; 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=axdIkUOCwWKpcn72pibLJwnDUtNLUKVs1vvylM5oKSY=;\n\tb=ICcPY5mM6cTPkYU0PuAStn9u1irIbwn+FZ5jrc+UO1dYkhzA8/8Dx8im18m/i1+Sx2\n\tx4XJ8ycT6TtSHEs5GENABfsE/Lh4vLTruo9yl9g/TnDeUbLetQEcgPjiiShSi0QlwGl7\n\tzGcqroLiQK1EArRFWn6VQ5ZBWIsHMRAwx7OlclENLxt6OF0DWxO2b4PjfvCuxw/b1UTh\n\tQjp9BKAmThuujT3lPiy2ErOwsywx/AM5oLlZSrswAAONu0DCFm4AVLCBf+trKgtu7c5R\n\tb/t4CfexK8rn0oeXO69fWOECnD5/GNhA8GXpveKY2JBcvdSsIF6SZU08tGsa63+UGSXa\n\tAAzg==",
        "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=axdIkUOCwWKpcn72pibLJwnDUtNLUKVs1vvylM5oKSY=;\n\tb=qbrFwM8BRFt8L66gCyfsAPN7JE/uMOjNvrDEQQBZkXq3MHj1nsXXuSdbsDTj60zjXw\n\tTi/C3e8vfFv+ojAwk+9XJDMY7l1OhZIbHXvnIAFS2a3ffscc3f/oVgsHjVRENCdg96Lk\n\tqq82Iblj5po0jnyOWFjtYToxIzElFm3pifPSV6NL1sSyjAL6oWUeWAdm4rW8YXDSa4Sh\n\tfbI89LZDpVtkOzNe+hUJqxBymL1qlNKkwMeStzxvR4l5R5yW8DIkZykU9lm7G18BdzNa\n\tg66zZeoEO5iT/aUxJpsxwzOC70XI3P1ELRks9vLOGcsT/Rc9xmnOLBDGCJYeFsk+sHm/\n\t5Gdw==",
        "X-Gm-Message-State": "AOAM530+pkr/PhcYm+G+PXYA9sLmdxDoqnszHfS5goEg8NgC4xBvkj7T\n\t2OYkA9HgfJCL1OOUeIRItJJ6VPmDo5GdfQ==",
        "X-Google-Smtp-Source": "ABdhPJx7vx+dNm9+xeiW8e8cZh/EpK5e6/cz6wQEDQ+zIOwr5tYJOaPW0C81uaxl5+Ysawce0kooLA==",
        "X-Received": "by 2002:adf:c3cd:: with SMTP id\n\td13mr16792964wrg.15.1603706039627; \n\tMon, 26 Oct 2020 02:53:59 -0700 (PDT)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 26 Oct 2020 09:53:56 +0000",
        "Message-Id": "<20201026095356.442605-2-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20201026095356.442605-1-naush@raspberrypi.com>",
        "References": "<20201026095356.442605-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Use\n\tMappedFrameBuffer for the IPA 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": "Instead of directly mmaping/unmapping buffers passed to the IPA, use\na MappedFrameBuffer. The latter is a cleaner interface, and avoid\ncode duplication.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 43 ++++++++++++-----------------\n 1 file changed, 17 insertions(+), 26 deletions(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 1c255aa2..8d204082 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -24,6 +24,7 @@\n \n #include <libipa/ipa_interface_wrapper.h>\n \n+#include \"libcamera/internal/buffer.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/log.h\"\n #include \"libcamera/internal/utils.h\"\n@@ -110,8 +111,7 @@ private:\n \tvoid applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls);\n \tvoid resampleTable(uint16_t dest[], double const src[12][16], int destW, int destH);\n \n-\tstd::map<unsigned int, FrameBuffer> buffers_;\n-\tstd::map<unsigned int, void *> buffersMemory_;\n+\tstd::map<unsigned int, MappedFrameBuffer> buffers_;\n \n \tControlInfoMap unicamCtrls_;\n \tControlInfoMap ispCtrls_;\n@@ -319,31 +319,20 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n void IPARPi::mapBuffers(const std::vector<IPABuffer> &buffers)\n {\n \tfor (const IPABuffer &buffer : buffers) {\n-\t\tauto elem = buffers_.emplace(std::piecewise_construct,\n-\t\t\t\t\t     std::forward_as_tuple(buffer.id),\n-\t\t\t\t\t     std::forward_as_tuple(buffer.planes));\n-\t\tconst FrameBuffer &fb = elem.first->second;\n-\n-\t\tbuffersMemory_[buffer.id] = mmap(nullptr, fb.planes()[0].length,\n-\t\t\t\t\t\t PROT_READ | PROT_WRITE, MAP_SHARED,\n-\t\t\t\t\t\t fb.planes()[0].fd.fd(), 0);\n-\n-\t\tif (buffersMemory_[buffer.id] == MAP_FAILED) {\n-\t\t\tint ret = -errno;\n-\t\t\tLOG(IPARPI, Fatal) << \"Failed to mmap buffer: \" << strerror(-ret);\n-\t\t}\n+\t\tconst FrameBuffer fb = FrameBuffer(buffer.planes);\n+\t\tbuffers_.emplace(std::piecewise_construct,\n+\t\t\t\t std::forward_as_tuple(buffer.id),\n+\t\t\t\t std::forward_as_tuple(MappedFrameBuffer(&fb, PROT_READ | PROT_WRITE)));\n \t}\n }\n \n void IPARPi::unmapBuffers(const std::vector<unsigned int> &ids)\n {\n \tfor (unsigned int id : ids) {\n-\t\tconst auto fb = buffers_.find(id);\n-\t\tif (fb == buffers_.end())\n+\t\tauto it = buffers_.find(id);\n+\t\tif (it == buffers_.end())\n \t\t\tcontinue;\n \n-\t\tmunmap(buffersMemory_[id], fb->second.planes()[0].length);\n-\t\tbuffersMemory_.erase(id);\n \t\tbuffers_.erase(id);\n \t}\n }\n@@ -785,15 +774,16 @@ void IPARPi::prepareISP(unsigned int bufferId)\n \n bool IPARPi::parseEmbeddedData(unsigned int bufferId, struct DeviceStatus &deviceStatus)\n {\n-\tauto it = buffersMemory_.find(bufferId);\n-\tif (it == buffersMemory_.end()) {\n+\tauto it = buffers_.find(bufferId);\n+\tif (it == buffers_.end()) {\n \t\tLOG(IPARPI, Error) << \"Could not find embedded buffer!\";\n \t\treturn false;\n \t}\n \n-\tint size = buffers_.find(bufferId)->second.planes()[0].length;\n+\tint size = buffers_.find(bufferId)->second.maps()[0].size();\n+\tvoid *ptr = buffers_.find(bufferId)->second.maps()[0].data();\n \thelper_->Parser().SetBufferSize(size);\n-\tRPiController::MdParser::Status status = helper_->Parser().Parse(it->second);\n+\tRPiController::MdParser::Status status = helper_->Parser().Parse(ptr);\n \tif (status != RPiController::MdParser::Status::OK) {\n \t\tLOG(IPARPI, Error) << \"Embedded Buffer parsing failed, error \" << status;\n \t} else {\n@@ -820,13 +810,14 @@ bool IPARPi::parseEmbeddedData(unsigned int bufferId, struct DeviceStatus &devic\n \n void IPARPi::processStats(unsigned int bufferId)\n {\n-\tauto it = buffersMemory_.find(bufferId);\n-\tif (it == buffersMemory_.end()) {\n+\tauto it = buffers_.find(bufferId);\n+\tif (it == buffers_.end()) {\n \t\tLOG(IPARPI, Error) << \"Could not find stats buffer!\";\n \t\treturn;\n \t}\n \n-\tbcm2835_isp_stats *stats = static_cast<bcm2835_isp_stats *>(it->second);\n+\tvoid *ptr = buffers_.find(bufferId)->second.maps()[0].data();\n+\tbcm2835_isp_stats *stats = static_cast<bcm2835_isp_stats *>(ptr);\n \tRPiController::StatisticsPtr statistics = std::make_shared<bcm2835_isp_stats>(*stats);\n \tcontroller_.Process(statistics, &rpiMetadata_);\n \n",
    "prefixes": [
        "libcamera-devel",
        "2/2"
    ]
}