Show a patch.

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

{
    "id": 14670,
    "url": "https://patchwork.libcamera.org/api/patches/14670/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14670/",
    "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": "<20211120111313.106621-3-jacopo@jmondi.org>",
    "date": "2021-11-20T11:13:03",
    "name": "[libcamera-devel,v2,02/12] libcamera: fence: Introduce Fence",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "57592aa8c0ea5bb17f851f2c9904a1125f7a96a6",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14670/mbox/",
    "series": [
        {
            "id": 2739,
            "url": "https://patchwork.libcamera.org/api/series/2739/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2739",
            "date": "2021-11-20T11:13:01",
            "name": "libcamera: Add support for Fence",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2739/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14670/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14670/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 9F43EBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 20 Nov 2021 11:12:26 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3D412603BE;\n\tSat, 20 Nov 2021 12:12:26 +0100 (CET)",
            "from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E8B0C6037A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 20 Nov 2021 12:12:23 +0100 (CET)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 68847100002;\n\tSat, 20 Nov 2021 11:12:23 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 20 Nov 2021 12:13:03 +0100",
        "Message-Id": "<20211120111313.106621-3-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.33.1",
        "In-Reply-To": "<20211120111313.106621-1-jacopo@jmondi.org>",
        "References": "<20211120111313.106621-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 02/12] libcamera: fence: Introduce Fence",
        "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": "Introduce a Fence class which models a synchronization primitive that\nallows to notify the availability of a resource.\n\nThe Fence is modeled as a wrapper of a FileDescriptor instance where\nread events are used to signal the Fence. The class can be later\nextended to support additional signalling mechanisms.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/fence.h              |  36 +++++++++\n include/libcamera/internal/fence.h     |  37 +++++++++\n include/libcamera/internal/meson.build |   1 +\n include/libcamera/meson.build          |   1 +\n src/libcamera/fence.cpp                | 104 +++++++++++++++++++++++++\n src/libcamera/meson.build              |   1 +\n 6 files changed, 180 insertions(+)\n create mode 100644 include/libcamera/fence.h\n create mode 100644 include/libcamera/internal/fence.h\n create mode 100644 src/libcamera/fence.cpp",
    "diff": "diff --git a/include/libcamera/fence.h b/include/libcamera/fence.h\nnew file mode 100644\nindex 000000000000..5ae0ff6208d7\n--- /dev/null\n+++ b/include/libcamera/fence.h\n@@ -0,0 +1,36 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google Inc.\n+ *\n+ * internal/fence.h - Synchronization fence\n+ */\n+#ifndef __LIBCAMERA_FENCE_H__\n+#define __LIBCAMERA_FENCE_H__\n+\n+#include <memory>\n+\n+#include <libcamera/base/class.h>\n+\n+#include <libcamera/file_descriptor.h>\n+\n+namespace libcamera {\n+\n+class Fence : public Extensible\n+{\n+\tLIBCAMERA_DECLARE_PRIVATE()\n+\n+public:\n+\tFence(const FileDescriptor &fd);\n+\n+\tbool isValid() const;\n+\tconst FileDescriptor &fd();\n+\n+\tvoid close();\n+\n+private:\n+\tLIBCAMERA_DISABLE_COPY_AND_MOVE(Fence)\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_FENCE_H__ */\ndiff --git a/include/libcamera/internal/fence.h b/include/libcamera/internal/fence.h\nnew file mode 100644\nindex 000000000000..5f03c0804d44\n--- /dev/null\n+++ b/include/libcamera/internal/fence.h\n@@ -0,0 +1,37 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google Inc.\n+ *\n+ * internal/fence.h - Internal synchronization fence\n+ */\n+#ifndef __LIBCAMERA_INTERNAL_FENCE_H__\n+#define __LIBCAMERA_INTERNAL_FENCE_H__\n+\n+#include <memory>\n+\n+#include <libcamera/base/class.h>\n+#include <libcamera/base/event_notifier.h>\n+\n+#include <libcamera/fence.h>\n+#include <libcamera/file_descriptor.h>\n+\n+namespace libcamera {\n+\n+class Fence::Private : public Extensible::Private\n+{\n+\tLIBCAMERA_DECLARE_PUBLIC(Fence)\n+\n+public:\n+\tPrivate(const FileDescriptor &fd);\n+\n+\tbool isValid() const { return fd_.isValid(); }\n+\tconst FileDescriptor &fd() { return fd_; }\n+\tvoid close();\n+\n+private:\n+\tFileDescriptor fd_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_INTERNAL_FENCE_H__ */\ndiff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex cae65b0604ff..32d5c3387de3 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -22,6 +22,7 @@ libcamera_internal_headers = files([\n     'device_enumerator.h',\n     'device_enumerator_sysfs.h',\n     'device_enumerator_udev.h',\n+    'fence.h',\n     'formats.h',\n     'framebuffer.h',\n     'ipa_manager.h',\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 7155ff203f6e..3721feb1ec92 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -7,6 +7,7 @@ libcamera_public_headers = files([\n     'camera_manager.h',\n     'compiler.h',\n     'controls.h',\n+    'fence.h',\n     'file_descriptor.h',\n     'framebuffer.h',\n     'framebuffer_allocator.h',\ndiff --git a/src/libcamera/fence.cpp b/src/libcamera/fence.cpp\nnew file mode 100644\nindex 000000000000..9ad86b3fa115\n--- /dev/null\n+++ b/src/libcamera/fence.cpp\n@@ -0,0 +1,104 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google Inc.\n+ *\n+ * fence.cpp - Synchronization fence\n+ */\n+\n+#include \"libcamera/internal/fence.h\"\n+\n+#include <libcamera/base/log.h>\n+#include <libcamera/base/thread.h>\n+\n+namespace libcamera {\n+\n+/**\n+ *\n+ * \\file libcamera/fence.h\n+ * \\brief Synchronization fence\n+ *\n+ * \\file internal/fence.h\n+ * \\brief Internal synchronization fence representation\n+ */\n+\n+/**\n+ * \\class Fence::Private\n+ * \\brief Private synchronization Fence implementation\n+ */\n+\n+/**\n+ * \\brief Construct a Fence::Private\n+ * \\param[in] fd The filedescriptor owned by the Fence\n+ */\n+Fence::Private::Private(const FileDescriptor &fd)\n+\t: fd_(std::move(fd))\n+{\n+}\n+\n+/**\n+ * \\fn Fence::Private::isValid()\n+ * \\brief Retrieve if a Fence is valid\n+ *\n+ * A Fence is valid if the FileDescriptor it wraps is valid\n+ *\n+ * \\return True if the Fence is valid, false otherwise\n+ */\n+\n+/**\n+ * \\fn Fence::Private::fd()\n+ * \\brief Retrieve a refernce to the FileDescriptor wrapped by this Fence\n+ *\n+ * \\todo Document how to extract the FileDescriptor in case the Fence has failed\n+ *\n+ * \\return A reference to the FileDescriptor this Fence wraps\n+ */\n+\n+/**\n+ * \\brief Close the Fence by releasing the wrapped FileDescriptor\n+ */\n+void Fence::Private::close()\n+{\n+\tfd_ = FileDescriptor();\n+}\n+\n+/**\n+ * \\class Fence\n+ * \\brief Synchronization fence class\n+ *\n+ * \\todo Documentation\n+ */\n+\n+/**\n+ * \\brief Create a synchronization fence\n+ * \\param[in] fd The synchronization fence file descriptor\n+ */\n+Fence::Fence(const FileDescriptor &fd)\n+\t: Extensible(std::make_unique<Private>(fd))\n+{\n+}\n+\n+/**\n+ * \\copydoc Fence::Private::isValid()\n+ */\n+bool Fence::isValid() const\n+{\n+\treturn _d()->isValid();\n+}\n+\n+/**\n+ * \\copydoc Fence::Private::fd()\n+ */\n+const FileDescriptor &Fence::fd()\n+{\n+\treturn _d()->fd();\n+}\n+\n+/**\n+ * \\copydoc Fence::Private::close()\n+ */\n+void Fence::close()\n+{\n+\t_d()->close();\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 6727a777d804..6fb0d5f49b63 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -14,6 +14,7 @@ libcamera_sources = files([\n     'delayed_controls.cpp',\n     'device_enumerator.cpp',\n     'device_enumerator_sysfs.cpp',\n+    'fence.cpp',\n     'file_descriptor.cpp',\n     'formats.cpp',\n     'framebuffer.cpp',\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "02/12"
    ]
}