Show a patch.

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

{
    "id": 441,
    "url": "https://patchwork.libcamera.org/api/patches/441/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/441/",
    "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": "<20190129135357.32339-2-kieran.bingham@ideasonboard.com>",
    "date": "2019-01-29T13:53:54",
    "name": "[libcamera-devel,1/4] libcamera: Add Buffer and BufferPool classes",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "8aef8848ae11bae4df1907b0197117d0efe03e64",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/441/mbox/",
    "series": [
        {
            "id": 154,
            "url": "https://patchwork.libcamera.org/api/series/154/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=154",
            "date": "2019-01-29T13:53:53",
            "name": "libcamera: Buffer Objects",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/154/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/441/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/441/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2CEE260DB6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Jan 2019 14:54:02 +0100 (CET)",
            "from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9887185;\n\tTue, 29 Jan 2019 14:54:01 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548770041;\n\tbh=mpJhigK67X9Dl/OhAeAIAWF/WJ/ksRHJbPvIx1oPqMc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=OjSxGv0bWICmo5gj2TG37zW9ePNc/XjPx+BPYsdaxUIdY8MyzPxnu+W3oA3Hg1c3r\n\t9IJrM+FTu8sJBJe2rVZRMT8iq9DIqyLOk22CGSAmxMBwY88YlIrKE/N00+e/lg+d2t\n\tf3vMtupo3Wt6zCL31nEcDCMkfek/esiwfnkT4mHY=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Tue, 29 Jan 2019 13:53:54 +0000",
        "Message-Id": "<20190129135357.32339-2-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.19.1",
        "In-Reply-To": "<20190129135357.32339-1-kieran.bingham@ideasonboard.com>",
        "References": "<20190129135357.32339-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/4] libcamera: Add Buffer and BufferPool\n\tclasses",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Tue, 29 Jan 2019 13:54:02 -0000"
    },
    "content": "From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nProvide classes that represent frame buffers and pools of frame buffers.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nKieran\n - Fix checkstyle.py diff\n---\n include/libcamera/buffer.h    |  55 ++++++++++++++++++\n include/libcamera/libcamera.h |   1 +\n include/libcamera/meson.build |   1 +\n src/libcamera/buffer.cpp      | 102 ++++++++++++++++++++++++++++++++++\n src/libcamera/meson.build     |   1 +\n 5 files changed, 160 insertions(+)\n create mode 100644 include/libcamera/buffer.h\n create mode 100644 src/libcamera/buffer.cpp",
    "diff": "diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nnew file mode 100644\nindex 000000000000..97c8025d9e77\n--- /dev/null\n+++ b/include/libcamera/buffer.h\n@@ -0,0 +1,55 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * buffer.h - Buffer handling\n+ */\n+#ifndef __LIBCAMERA_BUFFER_H__\n+#define __LIBCAMERA_BUFFER_H__\n+\n+#include <vector>\n+\n+namespace libcamera {\n+\n+class Buffer\n+{\n+public:\n+\tBuffer();\n+\t~Buffer();\n+\n+\tint dmabuf() const { return fd_; };\n+\tint setDmabuf(int fd);\n+\n+\tint mmap();\n+\tvoid munmap();\n+\n+private:\n+\tint fd_;\n+};\n+\n+class BufferPool\n+{\n+public:\n+\tenum Memory {\n+\t\tInternal,\n+\t\tExternal,\n+\t};\n+\n+\tBufferPool(Memory memory);\n+\tvirtual ~BufferPool();\n+\n+\tint allocate(unsigned int count);\n+\tvoid free();\n+\n+\tunsigned int count() const { return buffers_.size(); };\n+\n+private:\n+\tvirtual int allocateMemory() = 0;\n+\n+\tBufferPool::Memory memory_;\n+\tstd::vector<Buffer *> buffers_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_BUFFER_H__ */\ndiff --git a/include/libcamera/libcamera.h b/include/libcamera/libcamera.h\nindex c0511cf6d662..6619e556ebbd 100644\n--- a/include/libcamera/libcamera.h\n+++ b/include/libcamera/libcamera.h\n@@ -7,6 +7,7 @@\n #ifndef __LIBCAMERA_LIBCAMERA_H__\n #define __LIBCAMERA_LIBCAMERA_H__\n \n+#include <libcamera/buffer.h>\n #include <libcamera/camera.h>\n #include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex d7cb55ba4a49..8fcbbf7892ea 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -1,4 +1,5 @@\n libcamera_api = files([\n+    'buffer.h',\n     'camera.h',\n     'camera_manager.h',\n     'event_dispatcher.h',\ndiff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\nnew file mode 100644\nindex 000000000000..6dfebfc6bb28\n--- /dev/null\n+++ b/src/libcamera/buffer.cpp\n@@ -0,0 +1,102 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * buffer.cpp - Buffer handling\n+ */\n+\n+#include <errno.h>\n+#include <unistd.h>\n+\n+#include <libcamera/buffer.h>\n+\n+/**\n+ * \\file buffer.h\n+ * \\brief Buffer handling\n+ */\n+\n+namespace libcamera {\n+\n+/**\n+ * \\class Buffer\n+ * \\brief A memory buffer to store a frame\n+ *\n+ * The Buffer class represents a memory buffer used to store a frame.\n+ */\n+Buffer::Buffer()\n+\t: fd_(-1)\n+{\n+}\n+\n+Buffer::~Buffer()\n+{\n+\tif (fd_ != -1)\n+\t\tclose(fd_);\n+}\n+\n+/**\n+ * \\fn Buffer::dmabuf()\n+ * \\brief Get the dmabuf file handle backing the buffer\n+ */\n+\n+/**\n+ * \\brief Set the dmabuf file handle backing the buffer\n+ *\n+ * The \\a fd dmabuf file handle is duplicated and stored.\n+ */\n+int Buffer::setDmabuf(int fd)\n+{\n+\tif (fd_ != -1) {\n+\t\tclose(fd_);\n+\t\tfd_ = -1;\n+\t}\n+\n+\tif (fd != -1)\n+\t\treturn 0;\n+\n+\tfd_ = dup(fd);\n+\tif (fd_ == -1)\n+\t\treturn -errno;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\class BufferPool\n+ * \\brief A pool of buffers\n+ */\n+BufferPool::BufferPool(BufferPool::Memory memory)\n+\t: memory_(memory)\n+{\n+}\n+\n+BufferPool::~BufferPool()\n+{\n+\tfree();\n+}\n+\n+int BufferPool::allocate(unsigned int count)\n+{\n+\tfor (unsigned int i = 0; i < count; ++i) {\n+\t\tBuffer *buffer = new Buffer();\n+\t\tbuffers_.push_back(buffer);\n+\t}\n+\n+\tif (memory_ == Memory::Internal) {\n+\t\tint ret = allocateMemory();\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+void BufferPool::free()\n+{\n+\tfor (Buffer *buffer : buffers_)\n+\t\tdelete buffer;\n+\n+\tbuffers_.clear();\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex f9f25c0ecf15..b5b25965fd12 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -1,4 +1,5 @@\n libcamera_sources = files([\n+    'buffer.cpp',\n     'camera.cpp',\n     'camera_manager.cpp',\n     'device_enumerator.cpp',\n",
    "prefixes": [
        "libcamera-devel",
        "1/4"
    ]
}