Show a patch.

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

{
    "id": 8896,
    "url": "https://patchwork.libcamera.org/api/patches/8896/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/8896/",
    "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": "<20200720224232.153717-5-kieran.bingham@ideasonboard.com>",
    "date": "2020-07-20T22:42:28",
    "name": "[libcamera-devel,RFC,4/8] buffer: Provide a base MappedBuffer class",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": false,
    "hash": "e5e9c0cf9a4b32179799163adc4596f7a6781418",
    "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/8896/mbox/",
    "series": [
        {
            "id": 1119,
            "url": "https://patchwork.libcamera.org/api/series/1119/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1119",
            "date": "2020-07-20T22:42:24",
            "name": "RFC MappedBuffers",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1119/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/8896/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/8896/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 3D11AC0109\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jul 2020 22:42:43 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5695760890;\n\tTue, 21 Jul 2020 00:42:40 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 60DBC605BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Jul 2020 00:42:38 +0200 (CEST)",
            "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 E29122A4;\n\tTue, 21 Jul 2020 00:42:37 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SPkAmrb5\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1595284958;\n\tbh=Ao/ddpZ6hPuJ7yXhHH3kjZ7OtE5OS8ZtmY1Lkks+YPM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=SPkAmrb5AlGw3nalq1T0WNOtyaWGpFTF+2g8+SiPBRfrC6/gXwo8PZE8ZZugJzGQ2\n\t6XJh8zrrkf4UtUlJTJ+5A1T5sieaxZ+CnbWG2zl2+MJfRPDDoG/csPNo9mXKdT9ELp\n\t6bfqsTPcDRlvdBi1SR80UHvybH+s9jx8WkBAvpEw=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Mon, 20 Jul 2020 23:42:28 +0100",
        "Message-Id": "<20200720224232.153717-5-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200720224232.153717-1-kieran.bingham@ideasonboard.com>",
        "References": "<20200720224232.153717-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [RFC PATCH 4/8] buffer: Provide a base\n\tMappedBuffer 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>",
        "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": "Move the interface of the MappedFrameBuffer to a MappedBuffer class\nto provide a common interface of mapped buffers from different sources.\n\nThis allows MappedBuffer instances to be created from Camera3Buffer types.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n\nNow we can create our new base class, the MappedBuffer. I can see this\ngoing further to also push the mmap down to a MappedDmaBuf, but that can\nbe on top/later or if this general automatic mapping approach is desired\nat all....\n\n\n include/libcamera/buffer.h | 16 +++++---\n src/libcamera/buffer.cpp   | 80 +++++++++++++++++++++++++++++++-------\n 2 files changed, 76 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nindex 881d736da2db..558204e5a09b 100644\n--- a/include/libcamera/buffer.h\n+++ b/include/libcamera/buffer.h\n@@ -71,13 +71,12 @@ private:\n \tunsigned int cookie_;\n };\n \n-class MappedFrameBuffer {\n+class MappedBuffer {\n public:\n-\tMappedFrameBuffer(const FrameBuffer *buffer, int flags);\n-\t~MappedFrameBuffer();\n-\n+\tMappedBuffer();\n \t/* Move constructor only, copying is not permitted. */\n-\tMappedFrameBuffer(MappedFrameBuffer &&rhs);\n+\tMappedBuffer(MappedBuffer &&rhs);\n+\t~MappedBuffer();\n \n \tstruct MappedPlane {\n \t\tvoid *address;\n@@ -88,12 +87,17 @@ public:\n \tint error() const { return error_; }\n \tconst std::vector<MappedPlane> &maps() const { return maps_; }\n \n-private:\n+protected:\n \tint error_;\n \tbool valid_;\n \tstd::vector<MappedPlane> maps_;\n };\n \n+class MappedFrameBuffer : public MappedBuffer {\n+public:\n+\tMappedFrameBuffer(const FrameBuffer *buffer, int flags);\n+};\n+\n } /* namespace libcamera */\n \n #endif /* __LIBCAMERA_BUFFER_H__ */\ndiff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\nindex af5345b91195..0fe12ab93b58 100644\n--- a/src/libcamera/buffer.cpp\n+++ b/src/libcamera/buffer.cpp\n@@ -281,6 +281,72 @@ int FrameBuffer::copyFrom(const FrameBuffer *src)\n \treturn 0;\n }\n \n+/**\n+ * \\brief Construct an empty MappedBuffer\n+ *\n+ * A default constructor is required to allow subclassing the MappedBuffer\n+ * class. Construct an initialised, but invalid MappedBuffer.\n+ */\n+MappedBuffer::MappedBuffer()\n+\t: error_(0), valid_(false)\n+{\n+}\n+\n+/**\n+ * \\brief Move constructor, create a MappedBuffer by taking the \\a rhs mappings\n+ * \\param[in] rhs The other MappedBuffer\n+ *\n+ * Moving a MappedBuffer moves the mappings contained in the \\a rhs to the new\n+ * MappedBuffer and invalidates the \\a rhs. No mappings are unmapped or\n+ * destroyed in this process.\n+ */\n+MappedBuffer::MappedBuffer(MappedBuffer &&rhs)\n+{\n+\terror_ = rhs.error_;\n+\tvalid_ = rhs.valid_;\n+\tmaps_ = std::move(rhs.maps_);\n+\trhs.valid_ = false;\n+\trhs.error_ = 0;\n+}\n+\n+MappedBuffer::~MappedBuffer()\n+{\n+\tfor (MappedPlane map : maps_)\n+\t\tmunmap(map.address, map.length);\n+}\n+\n+/**\n+ * \\fn MappedBuffer::isValid()\n+ * \\brief Check if the MappedBuffer instance is valid\n+ * \\return True if the MappedBuffer has valid mappings, false otherwise\n+ */\n+\n+/**\n+ * \\fn MappedBuffer::error()\n+ * \\brief Retrieve the map error status\n+ *\n+ * This function retrieves the error status from the MappedBuffer.\n+ * The error status is a negative number as defined by errno.h. If\n+ * no error occurred, this function returns 0.\n+ */\n+\n+/**\n+ * \\var MappedBuffer::valid_\n+ * \\brief Stores the status of the mapping\n+ *\n+ * MappedBuffer implementations shall set this to represent if the mapping\n+ * was successfully completed without errors.\n+ */\n+\n+\n+/**\n+ * \\var MappedBuffer::error_\n+ * \\brief Stores the error value if present\n+ *\n+ * MappedBuffer implementations shall set this to a negative value as defined\n+ * by errno.h if an error occured during the mapping process\n+ */\n+\n /**\n  * \\brief Map all planes of a FrameBuffer\n  * \\param[in] src Buffer to be mapped\n@@ -291,7 +357,6 @@ int FrameBuffer::copyFrom(const FrameBuffer *src)\n  * PROT_WRITE, or a bitwise-or combination of both.\n  */\n MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, int flags)\n-\t: error_(0)\n {\n \tmaps_.reserve(buffer->planes().size());\n \n@@ -311,17 +376,4 @@ MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, int flags)\n \tvalid_ = buffer->planes().size() == maps_.size();\n }\n \n-MappedFrameBuffer::~MappedFrameBuffer()\n-{\n-\tfor (MappedPlane map : maps_)\n-\t\tmunmap(map.address, map.length);\n-}\n-\n-MappedFrameBuffer::MappedFrameBuffer(MappedFrameBuffer &&rhs)\n-{\n-\terror_ = rhs.error_;\n-\tvalid_ = rhs.valid_;\n-\tmaps_ = std::move(rhs.maps_);\n-}\n-\n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "4/8"
    ]
}