Show a patch.

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

{
    "id": 10422,
    "url": "https://patchwork.libcamera.org/api/patches/10422/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10422/",
    "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": "<20201113085657.34086-2-naush@raspberrypi.com>",
    "date": "2020-11-13T08:56:57",
    "name": "[libcamera-devel,2/2] ipa: raspberrypi: Use MappedFrameBuffer for the IPA buffers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "253d7e76cc1e415b25b321eeb3615cf12f774cbd",
    "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/10422/mbox/",
    "series": [
        {
            "id": 1459,
            "url": "https://patchwork.libcamera.org/api/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/10422/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10422/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 58176BE082\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Nov 2020 08:57:05 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 20FA0631BC;\n\tFri, 13 Nov 2020 09:57:05 +0100 (CET)",
            "from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com\n\t[IPv6:2a00:1450:4864:20::42e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D70CE631BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Nov 2020 09:57:02 +0100 (CET)",
            "by mail-wr1-x42e.google.com with SMTP id d12so8821317wrr.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Nov 2020 00:57:02 -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.57.00\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 13 Nov 2020 00:57:01 -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=\"VTa/ZBeW\"; 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=MFxOD1RHH9DUpvo3uH9tZAAzL14TCR0C3W6cmDAUVGs=;\n\tb=VTa/ZBeWRbcUyGiUK6RC1wSgXbocFoyQ5OGG4OxKLmBUhoaunnlHGSz1htD7gg4q9p\n\tn98Z0Eteb5lJaEggr2U9QQbOpGqTCWiRlAxz2qhQuGR6BDsgOqVmQR4KhD4X6iyEplJL\n\tBGTG6chnyyk54Qd6OcoAwKQWijSThIYm0sium06FA+w6HfdKDPHv9txV7tnok4Qmnr11\n\tPjnEooWop2pAiAuper5tBOFN3qpOUPTNzAjY7BYlac4ssVHHhoL6jBsMNGGdvBUyAGSt\n\tddGHh6xfutmiUGsRHNCwe2i1wrfUxTIFVmfJ4t+yr0rkGycx/yZzIAMdG3DjF139uGgz\n\tYY6Q==",
        "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=MFxOD1RHH9DUpvo3uH9tZAAzL14TCR0C3W6cmDAUVGs=;\n\tb=mmOJ51Ap0zZ5ICbww9MJ1lAGA+n4AjTpvi5/XFqHOVg78aXd1lYSqhdsW+0bRPgufx\n\t2RLDZLGfZoMiEZ/ErOswG3nagQriR2sA4iry0bexf9VasWfI5GpOeEu+TNyXILOuCbLf\n\tzMqI3I9ZKD6Y+o2oRau/uetmJQ7WvkXVcIWv9QuNQnqRG7NRS9MvomhHnWyVH2vURf1j\n\tr0wPtx4BY74ouOU3516pdhuJQEJVBflPd8y2Xkl0rp3WODEG1/W+bw9cw29zCsLwH7al\n\tpdk9LWefF7NDy0RKAFRn+6o9dwIQphHneeFTJ4GNP98+xa5dy++qyEDJVpSBDzRXvKqH\n\tQzwg==",
        "X-Gm-Message-State": "AOAM5319eleKTxRBEB7SFxLHTnIGOlXdG9laoA1O2nSyxharXpwfk6uL\n\tT9uBgeafNnS2Z+3W1XeUoZMXGLHrBw/y5e1w",
        "X-Google-Smtp-Source": "ABdhPJylizeOEmH0zTxH2irylsJftS8Mzi6+M8V887zLRzFYHcDwKp3mC2aUKymcMj6E3dEQDCV8Mw==",
        "X-Received": "by 2002:a5d:510a:: with SMTP id\n\ts10mr2004024wrt.402.1605257822172; \n\tFri, 13 Nov 2020 00:57:02 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 13 Nov 2020 08:56:57 +0000",
        "Message-Id": "<20201113085657.34086-2-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20201113085657.34086-1-naush@raspberrypi.com>",
        "References": "<20201113085657.34086-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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 41 +++++++++++------------------\n 1 file changed, 15 insertions(+), 26 deletions(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 1c255aa2..6bb45b75 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,18 @@ 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(buffer.id, 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 +772,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 +808,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"
    ]
}