Show a patch.

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

{
    "id": 19127,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19127/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19127/",
    "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": "<20231013074841.16972-4-naush@raspberrypi.com>",
    "date": "2023-10-13T07:48:24",
    "name": "[libcamera-devel,v2,03/20] pipeline: rpi: Add SharedMemObject class",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "61613a0f7b3289c09eaf7c732a137c178a72504d",
    "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/19127/mbox/",
    "series": [
        {
            "id": 4049,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4049/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4049",
            "date": "2023-10-13T07:48:21",
            "name": "Raspberry Pi: Preliminary PiSP support",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4049/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19127/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19127/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 89BCDC32B7\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Oct 2023 07:48:54 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D053D6298E;\n\tFri, 13 Oct 2023 09:48:52 +0200 (CEST)",
            "from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D67162980\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 09:48:49 +0200 (CEST)",
            "by mail-wr1-x42f.google.com with SMTP id\n\tffacd0b85a97d-3232be274a0so1920952f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 00:48:49 -0700 (PDT)",
            "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tm16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 13 Oct 2023 00:48:48 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697183332;\n\tbh=U+LuW5XpM1TGIphdq0IiFVOuYqOc16ZDNqA+E0cEDeA=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=x+K3bRBjpW+qKtWNWdqb5DpAzHfH3rgdubvjLMAThWt8nNjzJF4KNGyzcN+67UVUA\n\t495MEzczzGO9DcHGHGr7gpUxorW3Ve3bPL2IOteJL1J9p+KYjq1K3Nwv8ykix3giId\n\tKXsRtFeFMtg13iqdnA97fPuNS8i0bVKNN2xMAN7VGhIC8v2+c6VXPAYwoDqx4Y4pPF\n\ti6CCxpPnTKi8xbM5c0NWNuUPR8ahZdDbGbLCbdJHllnxNdiOMEexjFpzmDOc0kPtF6\n\tWVFml3fs01+dL1gKmrIvv1HrEMCuCm1Dpk+HFE6i0EUZcIMek2YZoXYzb16j5trXf1\n\tj7JCcsHrKn6qQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1697183329; x=1697788129;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=Tf9cMYwANGl6wI2KKAEoNBPrx/L8GaWXI40cn6J1ToE=;\n\tb=IbewTnlyU1GW04W+JKOYc0F6Yd5LWxF/tXOYlQalNgBz1tCwosfa1tZWNDA1/F/f0y\n\tByI2tw+WheeKplMjrJ42mGQQSDBPTAelxlGSVgOAgiqrIED1zaqfoVEtQQtNT528Pv6T\n\tzSejb6ygt7ajRnlHQ1BM805qDAGq5mWEritn6c9CDcz3E2BIy3lsyK1Ogq4Dxmp/N9so\n\tj+dk94C4QapqMIRfDNYIANoUTBeeXJ9Yx3giLVHsPO1hAq5PlpzDlkAIl2aS3xf4DLhi\n\tKWMaqddt4kdKbPVuUvnnIvyiLKHgxu4twxniGgie+7imLnWzjYjBPYlSUUqkjzmXdRaz\n\ttq8g=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"IbewTnly\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1697183329; x=1697788129;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=Tf9cMYwANGl6wI2KKAEoNBPrx/L8GaWXI40cn6J1ToE=;\n\tb=I1CaeXozWcG7bma9ecaNF29IihpsvzcJt0tXqZX4n0AoWfJ+HNhVITzsGBtFUdRz7/\n\tTk+EflBVz1F6N9/xCCcYy26s7MhFUoe/hUTZ9aQz6YG6bjjQ83ydh7V9dhc/zfYNcUc6\n\ttq5QxGg0cIovYNoGV7blX2f/VkZiNGfL8r/57DixpcG+JCm5mBGJeqgUhoK9X0h9+j25\n\t0JoPlXaeht8HrjJ2kgBmnGxTtRP/0WYzudtvXmKpF+CPxBbec6yyJxwYMvH1to5UTdjK\n\tWLeH6buYGH/VDzV6/AqTriyQQyvBEbd+ACGHcoHmKFJkoIhKXEht5h7jI1AHIrvhDkeP\n\txuNA==",
        "X-Gm-Message-State": "AOJu0Yxe5tukCKXaQQMsaLgC4Gh5pnvAoKc3Puv+xmlDLM78VQwEc2gZ\n\tQRM3UoMku+7/HN2TVRGN2jjvrhaeUb8zlGYWzfk5KQ==",
        "X-Google-Smtp-Source": "AGHT+IGrV7VQi2p4m1VWoVxVHepXo60OLME3mGMYohrmv+Y2prtOitBULGxypvWjVjl73hx5nUO7SQ==",
        "X-Received": "by 2002:a5d:6904:0:b0:31f:fc9a:a03 with SMTP id\n\tt4-20020a5d6904000000b0031ffc9a0a03mr18498993wru.20.1697183328798; \n\tFri, 13 Oct 2023 00:48:48 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 13 Oct 2023 08:48:24 +0100",
        "Message-Id": "<20231013074841.16972-4-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20231013074841.16972-1-naush@raspberrypi.com>",
        "References": "<20231013074841.16972-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 03/20] pipeline: rpi: Add\n\tSharedMemObject class",
        "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>",
        "From": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Naushir Patuck <naush@raspberrypi.com>",
        "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add new SharedMemObject class that wraps a memfd memory allocation and\nconstructs a templated object in the memory. With appropriate locking,\nthis object can then be shared across different processes using the\nassociated allocation file handle.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n .../pipeline/rpi/common/shared_mem_object.h   | 128 ++++++++++++++++++\n 1 file changed, 128 insertions(+)\n create mode 100644 src/libcamera/pipeline/rpi/common/shared_mem_object.h",
    "diff": "diff --git a/src/libcamera/pipeline/rpi/common/shared_mem_object.h b/src/libcamera/pipeline/rpi/common/shared_mem_object.h\nnew file mode 100644\nindex 000000000000..aa56c2209201\n--- /dev/null\n+++ b/src/libcamera/pipeline/rpi/common/shared_mem_object.h\n@@ -0,0 +1,128 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Raspberry Pi Ltd\n+ *\n+ * shared_mem_object.h - Helper class for shared memory allocations\n+ */\n+#pragma once\n+\n+#include <cstddef>\n+#include <fcntl.h>\n+#include <string>\n+#include <sys/mman.h>\n+#include <sys/stat.h>\n+#include <unistd.h>\n+#include <utility>\n+\n+#include <libcamera/base/class.h>\n+#include <libcamera/base/shared_fd.h>\n+\n+namespace libcamera {\n+\n+namespace RPi {\n+\n+template<class T>\n+class SharedMemObject\n+{\n+public:\n+\tstatic constexpr std::size_t SIZE = sizeof(T);\n+\n+\tSharedMemObject()\n+\t\t: obj_(nullptr)\n+\t{\n+\t}\n+\n+\ttemplate<class... Args>\n+\tSharedMemObject(const std::string &name, Args &&...args)\n+\t\t: name_(name), obj_(nullptr)\n+\t{\n+\t\tvoid *mem;\n+\t\tint ret;\n+\n+\t\tret = memfd_create(name_.c_str(), MFD_CLOEXEC);\n+\t\tif (ret < 0)\n+\t\t\treturn;\n+\n+\t\tfd_ = SharedFD(std::move(ret));\n+\t\tif (!fd_.isValid())\n+\t\t\treturn;\n+\n+\t\tret = ftruncate(fd_.get(), SIZE);\n+\t\tif (ret < 0)\n+\t\t\treturn;\n+\n+\t\tmem = mmap(nullptr, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,\n+\t\t\t   fd_.get(), 0);\n+\t\tif (mem == MAP_FAILED)\n+\t\t\treturn;\n+\n+\t\tobj_ = new (mem) T(std::forward<Args>(args)...);\n+\t}\n+\n+\tSharedMemObject(SharedMemObject<T> &&rhs)\n+\t{\n+\t\tthis->name_ = std::move(rhs.name_);\n+\t\tthis->fd_ = std::move(rhs.fd_);\n+\t\tthis->obj_ = rhs.obj_;\n+\t\trhs.obj_ = nullptr;\n+\t}\n+\n+\t~SharedMemObject()\n+\t{\n+\t\tif (obj_) {\n+\t\t\tobj_->~T();\n+\t\t\tmunmap(obj_, SIZE);\n+\t\t}\n+\t}\n+\n+\t/* Make SharedMemObject non-copyable for now. */\n+\tLIBCAMERA_DISABLE_COPY(SharedMemObject)\n+\n+\tSharedMemObject<T> &operator=(SharedMemObject<T> &&rhs)\n+\t{\n+\t\tthis->name_ = std::move(rhs.name_);\n+\t\tthis->fd_ = std::move(rhs.fd_);\n+\t\tthis->obj_ = rhs.obj_;\n+\t\trhs.obj_ = nullptr;\n+\t\treturn *this;\n+\t}\n+\n+\tT *operator->()\n+\t{\n+\t\treturn obj_;\n+\t}\n+\n+\tconst T *operator->() const\n+\t{\n+\t\treturn obj_;\n+\t}\n+\n+\tT &operator*()\n+\t{\n+\t\treturn *obj_;\n+\t}\n+\n+\tconst T &operator*() const\n+\t{\n+\t\treturn *obj_;\n+\t}\n+\n+\tconst SharedFD &fd() const\n+\t{\n+\t\treturn fd_;\n+\t}\n+\n+\texplicit operator bool() const\n+\t{\n+\t\treturn !!obj_;\n+\t}\n+\n+private:\n+\tstd::string name_;\n+\tSharedFD fd_;\n+\tT *obj_;\n+};\n+\n+} /* namespace RPi */\n+\n+} /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "03/20"
    ]
}