Show a patch.

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

{
    "id": 13504,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/13504/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13504/",
    "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": "<20210826112539.170694-4-hiroh@chromium.org>",
    "date": "2021-08-26T11:25:33",
    "name": "[libcamera-devel,v3,3/9] cam: file_sink: Use offset in mapping FrameBuffer",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "9b0f5c4e13f20e131ae28465088f16e7820a89cb",
    "submitter": {
        "id": 63,
        "url": "https://patchwork.libcamera.org/api/1.1/people/63/?format=api",
        "name": "Hirokazu Honda",
        "email": "hiroh@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13504/mbox/",
    "series": [
        {
            "id": 2398,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2398/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2398",
            "date": "2021-08-26T11:25:30",
            "name": "Add offset to FrameBuffer::Plane",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2398/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13504/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13504/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 C569CC3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Aug 2021 11:25:54 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 74E8D68911;\n\tThu, 26 Aug 2021 13:25:54 +0200 (CEST)",
            "from mail-pf1-x429.google.com (mail-pf1-x429.google.com\n\t[IPv6:2607:f8b0:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B77AB6888F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Aug 2021 13:25:52 +0200 (CEST)",
            "by mail-pf1-x429.google.com with SMTP id t42so2469815pfg.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Aug 2021 04:25:52 -0700 (PDT)",
            "from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:a5bc:b3dd:7208:bec1])\n\tby smtp.gmail.com with ESMTPSA id\n\ts29sm3472057pgl.38.2021.08.26.04.25.49\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 26 Aug 2021 04:25:50 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"WBphvbHn\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=q/Zu6lDSYz71bUvfOG/40k/PmICM3E/IwpM3XH1WsjU=;\n\tb=WBphvbHnfI372IWs7vpZsRjGeiCg8YAK6X2ViDip3GdWYyx46HHuRot1c2Ada8gceX\n\tJNQz7cOCx/Z1p42w8shJHjkxfSKjjUm+daEB3rgYg6JqJMSb2anX0vILTBTiQ4U2D7rB\n\tUfx6k2J63K2Y3I8dbOqag4YoHaVg6L6WsFHGs=",
        "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=q/Zu6lDSYz71bUvfOG/40k/PmICM3E/IwpM3XH1WsjU=;\n\tb=BvFBGB4HoKjzdC8PGJ/lrT3IN34BP67OKuegVZIr2PrcQHQiya27nUb0wCXMIBiPqz\n\t92kz08TiNgG1LWiiJP0LQUy7J40JLoBtapssgw+61W9SIPHLecmhCy26WrDynoE8Sd5o\n\t3uYK5WYKAvhdes9vXBbeNzGBKSn3xBeD2hO+HFcVKK0s13UEleG6ySU3rqnrV5JOE31g\n\tAWFEToeHkbhGsAJwGikSooZ/P/JuDVFUHP5Ptd0lxydZUv6GjWQJ6XiNGWVJcpdNpSiD\n\tB1cfpzYymF+6mmBiMQacmTmbTLNlPt7mFxEFBWk1E/V/dsOKbfKAUvxsIj3u69RTfw8R\n\tE6KA==",
        "X-Gm-Message-State": "AOAM532whiEyKoNW0UNjvbbbAtRc/HT4Ev3SwjUFPnrUokaQxALe5q2i\n\tfkLLHrVSWJI6dRGR+Hv4x8Ymrdsk0pXn6w==",
        "X-Google-Smtp-Source": "ABdhPJzsK0Nko9nEck78hKdBCoqdfLRbNDu4QnifLpWoMFpp/k8usaWzbuTZULKJ64kjfLo1GkcWcQ==",
        "X-Received": "by 2002:aa7:94ac:0:b0:3e0:f21a:e6ff with SMTP id\n\ta12-20020aa794ac000000b003e0f21ae6ffmr3283615pfl.76.1629977151036; \n\tThu, 26 Aug 2021 04:25:51 -0700 (PDT)",
        "From": "Hirokazu Honda <hiroh@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 26 Aug 2021 20:25:33 +0900",
        "Message-Id": "<20210826112539.170694-4-hiroh@chromium.org>",
        "X-Mailer": "git-send-email 2.33.0.rc2.250.ged5fa647cd-goog",
        "In-Reply-To": "<20210826112539.170694-1-hiroh@chromium.org>",
        "References": "<20210826112539.170694-1-hiroh@chromium.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 3/9] cam: file_sink: Use offset in\n\tmapping FrameBuffer",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "This fixes the way of mapping FrameBuffer in FrameSink by\nusing offset.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/cam/file_sink.cpp | 20 +++++++++++++++-----\n src/cam/file_sink.h   |  1 +\n 2 files changed, 16 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/cam/file_sink.cpp b/src/cam/file_sink.cpp\nindex 2d30694a..0b529e3e 100644\n--- a/src/cam/file_sink.cpp\n+++ b/src/cam/file_sink.cpp\n@@ -51,12 +51,22 @@ int FileSink::configure(const libcamera::CameraConfiguration &config)\n \n void FileSink::mapBuffer(FrameBuffer *buffer)\n {\n+\t/* \\todo use MappedFrameBuffer. */\n \tfor (const FrameBuffer::Plane &plane : buffer->planes()) {\n-\t\tvoid *memory = mmap(NULL, plane.length, PROT_READ, MAP_SHARED,\n-\t\t\t\t    plane.fd.fd(), 0);\n+\t\tconst int fd = plane.fd.fd();\n+\t\tif (mappedBuffers_.find(fd) == mappedBuffers_.end()) {\n+\t\t\t/**\n+\t\t\t * \\todo Should we try to only map the portions of the\n+\t\t\t * dmabuf that are used by planes ?\n+\t\t\t */\n+\t\t\tsize_t length = lseek(fd, 0, SEEK_END);\n+\t\t\tvoid *memory = mmap(NULL, plane.length, PROT_READ,\n+\t\t\t\t\t    MAP_SHARED, fd, 0);\n+\t\t\tmappedBuffers_[fd] = std::make_pair(memory, length);\n+\t\t}\n \n-\t\tmappedBuffers_[plane.fd.fd()] =\n-\t\t\tstd::make_pair(memory, plane.length);\n+\t\tvoid *memory = mappedBuffers_[fd].first;\n+\t\tplaneData_[&plane] = static_cast<uint8_t *>(memory) + plane.offset;\n \t}\n }\n \n@@ -102,7 +112,7 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer)\n \t\tconst FrameBuffer::Plane &plane = buffer->planes()[i];\n \t\tconst FrameMetadata::Plane &meta = buffer->metadata().planes[i];\n \n-\t\tvoid *data = mappedBuffers_[plane.fd.fd()].first;\n+\t\tuint8_t *data = planeData_[&plane];\n \t\tunsigned int length = std::min(meta.bytesused, plane.length);\n \n \t\tif (meta.bytesused > plane.length)\ndiff --git a/src/cam/file_sink.h b/src/cam/file_sink.h\nindex c3eb230a..c12325d9 100644\n--- a/src/cam/file_sink.h\n+++ b/src/cam/file_sink.h\n@@ -33,6 +33,7 @@ private:\n \tstd::map<const libcamera::Stream *, std::string> streamNames_;\n \tstd::string pattern_;\n \tstd::map<int, std::pair<void *, unsigned int>> mappedBuffers_;\n+\tstd::map<const libcamera::FrameBuffer::Plane *, uint8_t *> planeData_;\n };\n \n #endif /* __CAM_FILE_SINK_H__ */\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "3/9"
    ]
}