Patch Detail
Show a patch.
GET /api/patches/489/?format=api
{ "id": 489, "url": "https://patchwork.libcamera.org/api/patches/489/?format=api", "web_url": "https://patchwork.libcamera.org/patch/489/", "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": "<20190203110102.5663-3-kieran.bingham@ideasonboard.com>", "date": "2019-02-03T11:00:53", "name": "[libcamera-devel,02/11] libcamera: buffer: Support v4l2_buffer construction", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "6a7423ae4993fb2b3b9198c4dcec2eb8acfb2766", "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/489/mbox/", "series": [ { "id": 165, "url": "https://patchwork.libcamera.org/api/series/165/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=165", "date": "2019-02-03T11:00:51", "name": "libcamera: V4L2 Streams", "version": 1, "mbox": "https://patchwork.libcamera.org/series/165/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/489/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/489/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 4594260B1B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 3 Feb 2019 12:01:07 +0100 (CET)", "from localhost.localdomain\n\t(218.182-78-194.adsl-static.isp.belgacom.be [194.78.182.218])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DFEBBD4A;\n\tSun, 3 Feb 2019 12:01:06 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549191667;\n\tbh=nne7oU1/bxd+Fc8K/U1tQc528Ql3yyAVTq5vnd9egA0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Hs3gWRHjUo7ahm4JEEs50o/Q6NG7Lm2Jbrv9vDHQSVI65JXxNAnCpnKMoxq50Htdf\n\tQ8tSUGmkmdBidAyBmhSEl9HhGopMztuzoQSECJU38tiqbf8FLkBpb2DSeR+KfW70NZ\n\t50qznOM39EqHqYwLKtHUXrWrO3wBXYn8R8fhQNQ4=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>", "Date": "Sun, 3 Feb 2019 12:00:53 +0100", "Message-Id": "<20190203110102.5663-3-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.1", "In-Reply-To": "<20190203110102.5663-1-kieran.bingham@ideasonboard.com>", "References": "<20190203110102.5663-1-kieran.bingham@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 02/11] libcamera: buffer: Support\n\tv4l2_buffer construction", "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": "Sun, 03 Feb 2019 11:01:07 -0000" }, "content": "Provide a constructor to create a Buffer object directly from a v4l2_buffer as\na V4L2Buffer type. This allows the Buffers to be created directly following a\nv4l2_reqbufs operation.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/buffer.h | 2 +-\n src/libcamera/buffer.cpp | 27 +++++++++++++++++++++++++++\n src/libcamera/include/v4l2_device.h | 8 ++++++++\n src/libcamera/v4l2_device.cpp | 27 +++++++++++++++++++++++++++\n 4 files changed, 63 insertions(+), 1 deletion(-)", "diff": "diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nindex afe99d5c4ab0..e730fc0f84fd 100644\n--- a/include/libcamera/buffer.h\n+++ b/include/libcamera/buffer.h\n@@ -46,7 +46,7 @@ public:\n \tunsigned int index() const { return index_; };\n \tconst std::vector<Plane *> &planes() { return planes_; };\n \n-private:\n+protected:\n \tunsigned int index_;\n \n \tunsigned int format_;\ndiff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\nindex 887863b2af2e..c21994d7c035 100644\n--- a/src/libcamera/buffer.cpp\n+++ b/src/libcamera/buffer.cpp\n@@ -10,6 +10,8 @@\n #include <sys/mman.h>\n #include <unistd.h>\n \n+#include <linux/videodev2.h>\n+\n #include <libcamera/buffer.h>\n \n #include \"log.h\"\n@@ -241,6 +243,31 @@ int Buffer::munmap()\n * \\brief Return a reference to the vector holding all Planes within the buffer\n */\n \n+/**\n+ * \\enum Buffer::BufferType\n+ * \\brief Identify the type of buffer for derived types\n+ *\n+ * Buffers may be derived to support specific buffer type features on top of the\n+ * generic interface. The BufferType is used internally to assert compatibility\n+ * in the event of any generic Buffer object being upcast to a specific type.\n+ */\n+\n+/**\n+ * \\var Buffer::BufferTypeGeneric\n+ * \\brief The Buffer can only be supported through the public Buffer API\n+ */\n+\n+/**\n+ * \\var Buffer::BufferTypeV4L2\n+ * \\brief The Buffer can supported through both the public Buffer API and the\n+ * internal V4L2 API.\n+ */\n+\n+/**\n+ * \\var Buffer::type_\n+ * \\brief An internal BufferType to describe the construction of the Buffer.\n+ */\n+\n /**\n * \\class BufferPool\n * \\brief A pool of buffers\ndiff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex f68b2b1df525..9e9eada94130 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -11,6 +11,8 @@\n \n #include <linux/videodev2.h>\n \n+#include <libcamera/buffer.h>\n+\n namespace libcamera {\n \n struct V4L2Capability final : v4l2_capability {\n@@ -53,6 +55,12 @@ struct V4L2Capability final : v4l2_capability {\n \t}\n };\n \n+class V4L2Buffer : public Buffer\n+{\n+public:\n+\tV4L2Buffer(struct v4l2_buffer &vb);\n+};\n+\n class V4L2DeviceFormat\n {\n public:\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 5c415d0bddbc..d507ea9700b3 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -80,6 +80,33 @@ LOG_DEFINE_CATEGORY(V4L2)\n * \\return True if the device provides Streaming I/O IOCTLs\n */\n \n+/**\n+ * \\brief Construct a Buffer object from a v4l2_buffer description\n+ *\n+ * Buffers are abstracted in the same format regardless of using the single\n+ * planar API or multi-planar API. The buffer object contains a Plane for each\n+ * memory plane required to represent the buffer.\n+ */\n+V4L2Buffer::V4L2Buffer(struct v4l2_buffer &vb)\n+\t: Buffer()\n+{\n+\tindex_ = vb.index;\n+\n+\tif (V4L2_TYPE_IS_MULTIPLANAR(vb.type)) {\n+\t\tunsigned int i;\n+\t\tfor (i = 0; i < vb.length; ++i) {\n+\t\t\t/* TODO: dmaBuf should retrieve FD here */\n+\t\t\tPlane *plane = new Plane(vb.m.planes[i].length,\n+\t\t\t\t\t\t vb.m.planes[i].m.mem_offset);\n+\t\t\tplanes_.push_back(plane);\n+\t\t}\n+\t} else {\n+\t\t/* TODO: dmaBuf should retrieve FD here */\n+\t\tPlane *plane = new Plane(vb.length, vb.m.offset);\n+\t\tplanes_.push_back(plane);\n+\t}\n+}\n+\n /**\n * \\class V4L2DeviceFormat\n * \\brief The V4L2 device image format and sizes\n", "prefixes": [ "libcamera-devel", "02/11" ] }