Show a patch.

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

{
    "id": 1692,
    "url": "https://patchwork.libcamera.org/api/patches/1692/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1692/",
    "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": "<20190713172351.25452-12-laurent.pinchart@ideasonboard.com>",
    "date": "2019-07-13T17:23:46",
    "name": "[libcamera-devel,v2,11/16] libcamera: stream: Add Stream memory type",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "0fe463a70e89aa3fa3691d79c222290440a74567",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/1692/mbox/",
    "series": [
        {
            "id": 430,
            "url": "https://patchwork.libcamera.org/api/series/430/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=430",
            "date": "2019-07-13T17:23:35",
            "name": "Add support for external buffers",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/430/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1692/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1692/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B3A436175B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jul 2019 19:24:43 +0200 (CEST)",
            "from pendragon.ideasonboard.com (softbank126209254147.bbtec.net\n\t[126.209.254.147])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6FA482B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jul 2019 19:24:42 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1563038683;\n\tbh=5VAj2gisFfQhEnJnqo7buZXlLkxoi+kGfK+QtD0il9k=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=ZZfbRSfwgs0+RCbPFi7efdaaHbZFpkNoynOna5rStK/F0YrOzv8fB1WBZtKnn8UzC\n\tbRUhaCL7XWUrpazwN3wlq78ie48kHimOGR5inu7OVEw0Im1AhQYs7GdXffojV/qO+b\n\tS7p/MCts38u/fFp1siGriCRMYtVxnLdFlUpdZe9g=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 13 Jul 2019 20:23:46 +0300",
        "Message-Id": "<20190713172351.25452-12-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190713172351.25452-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20190713172351.25452-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 11/16] libcamera: stream: Add Stream\n\tmemory type",
        "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": "Sat, 13 Jul 2019 17:24:44 -0000"
    },
    "content": "From: Jacopo Mondi <jacopo@jmondi.org>\n\nDefine the memory type a Stream uses and allow application to set it\nthrough the associated StreamConfiguration.\n\nA Stream can use either internal or external memory allocation methods,\ndepending on where the data produced by the stream is actually saved.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/stream.h | 10 +++++++++-\n src/libcamera/camera.cpp   |  2 +-\n src/libcamera/stream.cpp   | 35 ++++++++++++++++++++++++++++++++---\n 3 files changed, 42 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\nindex bc14fb60480e..08eb8cc7d5c7 100644\n--- a/include/libcamera/stream.h\n+++ b/include/libcamera/stream.h\n@@ -35,6 +35,11 @@ private:\n \tstd::map<unsigned int, std::vector<SizeRange>> formats_;\n };\n \n+enum MemoryType {\n+\tInternalMemory,\n+\tExternalMemory,\n+};\n+\n struct StreamConfiguration {\n \tStreamConfiguration();\n \tStreamConfiguration(const StreamFormats &formats);\n@@ -42,6 +47,7 @@ struct StreamConfiguration {\n \tunsigned int pixelFormat;\n \tSize size;\n \n+\tMemoryType memoryType;\n \tunsigned int bufferCount;\n \n \tStream *stream() const { return stream_; }\n@@ -73,15 +79,17 @@ public:\n \tBufferPool &bufferPool() { return bufferPool_; }\n \tstd::vector<BufferMemory> &buffers() { return bufferPool_.buffers(); }\n \tconst StreamConfiguration &configuration() const { return configuration_; }\n+\tMemoryType memoryType() const { return memoryType_; }\n \n protected:\n \tfriend class Camera;\n \n-\tvoid createBuffers(unsigned int count);\n+\tvoid createBuffers(MemoryType memory, unsigned int count);\n \tvoid destroyBuffers();\n \n \tBufferPool bufferPool_;\n \tStreamConfiguration configuration_;\n+\tMemoryType memoryType_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 61d3e821f48f..af69607b19e6 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -683,7 +683,7 @@ int Camera::configure(CameraConfiguration *config)\n \t\t * Allocate buffer objects in the pool.\n \t\t * Memory will be allocated and assigned later.\n \t\t */\n-\t\tstream->createBuffers(cfg.bufferCount);\n+\t\tstream->createBuffers(cfg.memoryType, cfg.bufferCount);\n \t}\n \n \tstate_ = CameraConfigured;\ndiff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\nindex 884fbfebd52c..94aa4810f6b9 100644\n--- a/src/libcamera/stream.cpp\n+++ b/src/libcamera/stream.cpp\n@@ -263,6 +263,17 @@ SizeRange StreamFormats::range(unsigned int pixelformat) const\n \treturn range;\n }\n \n+/**\n+ * \\enum MemoryType\n+ * \\brief Define the memory type used by a Stream\n+ * \\var MemoryType::InternalMemory\n+ * The Stream uses memory allocated internally by the library and exported to\n+ * applications.\n+ * \\var MemoryType::ExternalMemory\n+ * The Stream uses memory allocated externally by application and imported in\n+ * the library.\n+ */\n+\n /**\n  * \\struct StreamConfiguration\n  * \\brief Configuration parameters for a stream\n@@ -276,7 +287,7 @@ SizeRange StreamFormats::range(unsigned int pixelformat) const\n  * handlers provied StreamFormats.\n  */\n StreamConfiguration::StreamConfiguration()\n-\t: stream_(nullptr)\n+\t: memoryType(InternalMemory), stream_(nullptr)\n {\n }\n \n@@ -284,7 +295,7 @@ StreamConfiguration::StreamConfiguration()\n  * \\brief Construct a configuration with stream formats\n  */\n StreamConfiguration::StreamConfiguration(const StreamFormats &formats)\n-\t: stream_(nullptr), formats_(formats)\n+\t: memoryType(InternalMemory), stream_(nullptr), formats_(formats)\n {\n }\n \n@@ -301,6 +312,11 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats)\n  * format described in V4L2 using the V4L2_PIX_FMT_* definitions.\n  */\n \n+/**\n+ * \\var StreamConfiguration::memoryType\n+ * \\brief The memory type the stream shall use\n+ */\n+\n /**\n  * \\var StreamConfiguration::bufferCount\n  * \\brief Requested number of buffers to allocate for the stream\n@@ -454,18 +470,26 @@ std::unique_ptr<Buffer> Stream::createBuffer(unsigned int index)\n  * \\return The active configuration of the stream\n  */\n \n+/**\n+ * \\fn Stream::memoryType()\n+ * \\brief Retrieve the stream memory type\n+ * \\return The memory type used by the stream\n+ */\n+\n /**\n  * \\brief Create buffers for the stream\n  * \\param count The number of buffers to create\n+ * \\param memory The stream memory type\n  *\n  * Create \\a count empty buffers in the Stream's buffer pool.\n  */\n-void Stream::createBuffers(unsigned int count)\n+void Stream::createBuffers(MemoryType memory, unsigned int count)\n {\n \tdestroyBuffers();\n \tif (count == 0)\n \t\treturn;\n \n+\tmemoryType_ = memory;\n \tbufferPool_.createBuffers(count);\n }\n \n@@ -497,4 +521,9 @@ void Stream::destroyBuffers()\n  * next call to Camera::configure() regardless of if it includes the stream.\n  */\n \n+/**\n+ * \\var Stream::memoryType_\n+ * \\brief The stream memory type\n+ */\n+\n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "11/16"
    ]
}