Patch Detail
Show a patch.
GET /api/patches/372/?format=api
{ "id": 372, "url": "https://patchwork.libcamera.org/api/patches/372/?format=api", "web_url": "https://patchwork.libcamera.org/patch/372/", "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": "<20190124153135.378-1-jacopo@jmondi.org>", "date": "2019-01-24T15:31:35", "name": "[libcamera-devel] libcamera: v4l2_device: Group base operations in V4L2Base", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "bdc344fc1e10146ac5a203c1bc9bb4face693212", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/372/mbox/", "series": [ { "id": 128, "url": "https://patchwork.libcamera.org/api/series/128/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=128", "date": "2019-01-24T15:31:35", "name": "[libcamera-devel] libcamera: v4l2_device: Group base operations in V4L2Base", "version": 1, "mbox": "https://patchwork.libcamera.org/series/128/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/372/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/372/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6011A60C80\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Jan 2019 16:31:32 +0100 (CET)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id D0405E0004;\n\tThu, 24 Jan 2019 15:31:31 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 24 Jan 2019 16:31:35 +0100", "Message-Id": "<20190124153135.378-1-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.20.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] libcamera: v4l2_device: Group base\n\toperations in V4L2Base", "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": "Thu, 24 Jan 2019 15:31:32 -0000" }, "content": "Group operations commont to V4L2Device and the forthcoming V4L2Subdevice\nin a common V4L2Base class.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nAs I started implementing V4L2Subdevice support, I realized I was going to\nre-implement what is now part of V4L2Base.\n\nI would like to develop V4L2Subdevice on top of this.\nPatch to be applied on top of my latest:\n[PATCH v2 0/2] Add mplane support to V4L2 device\n\nThanks\n j\n---\n src/libcamera/include/v4l2_device.h | 38 ++++++---\n src/libcamera/v4l2_device.cpp | 127 ++++++++++++++++++----------\n 2 files changed, 112 insertions(+), 53 deletions(-)\n\n--\n2.20.1", "diff": "diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 2da30d1..08bfe9f 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -54,30 +54,48 @@ struct V4L2Capability final : v4l2_capability {\n };\n\n class MediaEntity;\n-class V4L2Device\n+class V4L2Base\n {\n public:\n-\texplicit V4L2Device(const std::string &deviceNode);\n-\texplicit V4L2Device(const MediaEntity &entity);\n+\tvirtual ~V4L2Base() { close(); }\n+\n+\tvirtual int open();\n+\tbool isOpen() const { return fd_ != -1; }\n+\tvirtual void close();\n+\n+protected:\n+\tV4L2Base(const std::string &deviceNode);\n+\tV4L2Base(const MediaEntity &entity);\n+\tV4L2Base(const V4L2Base &) = delete;\n+\tbool operator=(const V4L2Base &) = delete;\n+\n+\tstd::string deviceNode_;\n+\tint fd_;\n+};\n+\n+class V4L2Device : public V4L2Base\n+{\n+public:\n+\texplicit V4L2Device(const std::string &deviceNode)\n+\t\t: V4L2Base(deviceNode) {}\n+\texplicit V4L2Device(const MediaEntity &entity)\n+\t\t: V4L2Base(entity) {}\n \tV4L2Device(const V4L2Device &) = delete;\n-\t~V4L2Device();\n\n-\tvoid operator=(const V4L2Device &) = delete;\n+\t~V4L2Device() {}\n\n-\tint open();\n-\tbool isOpen() const;\n-\tvoid close();\n+\tvoid operator=(const V4L2Device &) = delete;\n\n \tconst char *driverName() const { return caps_.driver(); }\n \tconst char *deviceName() const { return caps_.card(); }\n \tconst char *busName() const { return caps_.bus_info(); }\n\n+\tint open();\n+\n \tint format();\n \tint setFormat();\n\n private:\n-\tstd::string deviceNode_;\n-\tint fd_;\n \tV4L2Capability caps_;\n\n \tint getFormatSingleplane();\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 2ddb800..f505240 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -81,16 +81,15 @@ LOG_DEFINE_CATEGORY(V4L2)\n */\n\n /**\n- * \\class V4L2Device\n- * \\brief V4L2Device object and API\n+ * \\class V4L2Base\n+ * \\brief Group methods and field common to V4L2 devices and subdevices\n *\n- * The V4L2 Device API class models an instance of a V4L2 device node.\n- * It is constructed with the path to a V4L2 video device node. The device node\n- * is only opened upon a call to open() which must be checked for success.\n+ * Represents the base class for V4L2 devices and sub-devices.\n+ * It is constructed with the path to a V4L2 video (sub-)device node or\n+ * with a MediaEntity, provided its deviceNode() path has been set.\n *\n- * The device capabilities are validated when the device is opened and the\n- * device is rejected if it is not a suitable V4L2 capture or output device, or\n- * if the device does not support streaming I/O.\n+ * The device node is only opened upon a call to open() which must be\n+ * checked for success.\n *\n * No API call other than open(), isOpen() and close() shall be called on an\n * unopened device instance.\n@@ -100,35 +99,32 @@ LOG_DEFINE_CATEGORY(V4L2)\n */\n\n /**\n- * \\brief Construct a V4L2Device\n- * \\param deviceNode The file-system path to the video device node\n+ * \\fn V4L2Base::V4L2Base(const std::string &deviceNode)\n+ * \\brief Construct a V4L2 base instance\n+ * \\param deviceNode The file-system path to the video (sub-)device node\n */\n-V4L2Device::V4L2Device(const std::string &deviceNode)\n+V4L2Base::V4L2Base(const std::string &deviceNode)\n \t: deviceNode_(deviceNode), fd_(-1)\n {\n }\n\n /**\n- * \\brief Construct a V4L2Device from a MediaEntity\n+ * \\fn V4L2Base::V4L2Base(const MediaEntity &entity)\n+ * \\brief Construct a V4L2 base instance from a MediaEntity\n * \\param entity The MediaEntity to build the device from\n *\n- * Construct a V4L2Device from a MediaEntity's device node path.\n+ * Construct a V4L2 base instance from a MediaEntity's device node path.\n */\n-V4L2Device::V4L2Device(const MediaEntity &entity)\n-\t: V4L2Device(entity.deviceNode())\n-{\n-}\n-\n-V4L2Device::~V4L2Device()\n+V4L2Base::V4L2Base(const MediaEntity &entity)\n+\t: V4L2Base(entity.deviceNode())\n {\n-\tclose();\n }\n\n /**\n- * \\brief Open a V4L2 device and query its capabilities\n+ * \\brief Open a device node associated with a V4L2 device or subdevice\n * \\return 0 on success, or a negative error code otherwise\n */\n-int V4L2Device::open()\n+int V4L2Base::open()\n {\n \tint ret;\n\n@@ -147,6 +143,72 @@ int V4L2Device::open()\n \t}\n \tfd_ = ret;\n\n+\treturn 0;\n+}\n+\n+/**\n+ * \\fn V4L2Base::isOpen()\n+ * \\brief Check if device is successfully opened\n+ * \\return True if the device is open, false otherwise\n+ */\n+\n+/**\n+ * \\brief Close the device node, releasing any resources acquired by open()\n+ */\n+void V4L2Base::close()\n+{\n+\tif (fd_ < 0)\n+\t\treturn;\n+\n+\t::close(fd_);\n+\tfd_ = -1;\n+}\n+\n+/**\n+ * \\var V4L2Base::deviceNode_\n+ * \\brief The device node path associated with the V4L2 instance.\n+ */\n+\n+/**\n+ * \\var V4L2Base::fd_\n+ * \\brief The file descriptor associated with an open device node\n+ */\n+\n+/**\n+ * \\class V4L2Device\n+ * \\brief V4L2Device object and API\n+ *\n+ * The V4L2 Device API class models an instance of a V4L2 device node.\n+ *\n+ * The device capabilities are validated when the device is opened and the\n+ * device is rejected if it is not a suitable V4L2 capture or output device, or\n+ * if the device does not support streaming I/O.\n+ */\n+\n+/**\n+ * \\fn V4L2Device::V4L2Device(const std::string &deviceNode)\n+ * \\brief Construct a V4L2Device\n+ * \\param deviceNode The file-system path to the video (sub)device node\n+ */\n+\n+/**\n+ * \\fn V4L2Device::V4L2Device(const MediaEntity &entity)\n+ * \\brief Construct a V4L2Device from a MediaEntity\n+ * \\param entity The MediaEntity to build the device from\n+ *\n+ * Construct a V4L2Device from a MediaEntity's device node path.\n+ */\n+\n+/**\n+ * \\brief Open a V4L2 device and query its capabilities\n+ * \\return 0 on success, or a negative error code otherwise\n+ */\n+int V4L2Device::open()\n+{\n+\tint ret = V4L2Base::open();\n+\tif (ret)\n+\t\treturn ret;\n+\n \tret = ioctl(fd_, VIDIOC_QUERYCAP, &caps_);\n \tif (ret < 0) {\n \t\tret = -errno;\n@@ -174,27 +236,6 @@ int V4L2Device::open()\n \treturn 0;\n }\n\n-/**\n- * \\brief Check if device is successfully opened\n- * \\return True if the device is open, false otherwise\n- */\n-bool V4L2Device::isOpen() const\n-{\n-\treturn fd_ != -1;\n-}\n-\n-/**\n- * \\brief Close the device, releasing any resources acquired by open()\n- */\n-void V4L2Device::close()\n-{\n-\tif (fd_ < 0)\n-\t\treturn;\n-\n-\t::close(fd_);\n-\tfd_ = -1;\n-}\n-\n /**\n * \\fn const char *V4L2Device::driverName()\n * \\brief Retrieve the name of the V4L2 device driver\n", "prefixes": [ "libcamera-devel" ] }