{"id":305,"url":"https://patchwork.libcamera.org/api/1.1/patches/305/?format=json","web_url":"https://patchwork.libcamera.org/patch/305/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190121172705.19985-5-jacopo@jmondi.org>","date":"2019-01-21T17:27:03","name":"[libcamera-devel,4/6] libcamera: v4l2_device: Add single/multiplane formats","commit_ref":null,"pull_url":null,"state":"rejected","archived":false,"hash":"00daa148c21815f8d406bdbf849004feb2f86a9a","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/305/mbox/","series":[{"id":105,"url":"https://patchwork.libcamera.org/api/1.1/series/105/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=105","date":"2019-01-21T17:26:59","name":"libcamera: Augment V4L2 device","version":1,"mbox":"https://patchwork.libcamera.org/series/105/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/305/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/305/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DEDE60C96\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jan 2019 18:27:05 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 03C7B1BF206;\n\tMon, 21 Jan 2019 17:27:04 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 21 Jan 2019 18:27:03 +0100","Message-Id":"<20190121172705.19985-5-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190121172705.19985-1-jacopo@jmondi.org>","References":"<20190121172705.19985-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 4/6] libcamera: v4l2_device: Add\n\tsingle/multiplane formats","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":"Mon, 21 Jan 2019 17:27:05 -0000"},"content":"Add a class hierarchy internal to V4L2Device to handle set/get format\noperations in the single/multi plane use case.\n\nProvide stubs only for  get/setFormat methods at the moment.\n---\n src/libcamera/include/v4l2_device.h | 34 +++++++++++++++++\n src/libcamera/v4l2_device.cpp       | 59 +++++++++++++++++++++++++++++\n 2 files changed, 93 insertions(+)","diff":"diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 0101a4b..81992dc 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -7,6 +7,7 @@\n #ifndef __LIBCAMERA_V4L2_DEVICE_H__\n #define __LIBCAMERA_V4L2_DEVICE_H__\n \n+#include <memory>\n #include <string>\n \n #include <linux/videodev2.h>\n@@ -54,11 +55,44 @@ public:\n \tconst char *busName() const { return caps_.bus_info(); }\n \n \tint setControl(unsigned int control, int value);\n+\tint getFormat();\n+\tint setFormat();\n \n private:\n+\tclass V4L2Format\n+\t{\n+\tpublic:\n+\t\tvirtual ~V4L2Format() { }\n+\t\tvirtual int setFormat() = 0;\n+\t\tvirtual int getFormat() = 0;\n+\n+\tprotected:\n+\t\tV4L2Format() { }\n+\t\tV4L2Format(V4L2Format &) = delete;\n+\t};\n+\n+\tclass V4L2FormatSPlane : public V4L2Format\n+\t{\n+\tpublic:\n+\t\tV4L2FormatSPlane() { }\n+\t\t~V4L2FormatSPlane() { }\n+\t\tint setFormat();\n+\t\tint getFormat();\n+\t};\n+\n+\tclass V4L2FormatMPlane : public V4L2Format\n+\t{\n+\tpublic:\n+\t\tV4L2FormatMPlane() { }\n+\t\t~V4L2FormatMPlane() { }\n+\t\tint setFormat();\n+\t\tint getFormat();\n+\t};\n+\n \tstd::string devnode_;\n \tint fd_;\n \tV4L2Capability caps_;\n+\tstd::unique_ptr<V4L2Format> format_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 7cd89d7..126f6f2 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -5,6 +5,8 @@\n  * v4l2_device.cpp - V4L2 Device\n  */\n \n+#include <memory>\n+\n #include <fcntl.h>\n #include <string.h>\n #include <sys/ioctl.h>\n@@ -13,6 +15,7 @@\n \n #include \"log.h\"\n #include \"media_object.h\"\n+#include \"utils.h\"\n #include \"v4l2_device.h\"\n \n /**\n@@ -182,6 +185,12 @@ int V4L2Device::open()\n \t\treturn -EINVAL;\n \t}\n \n+\t/* Create single/multi plane format handler. */\n+\tif (caps_.isSinglePlane())\n+\t\tformat_ = utils::make_unique<V4L2FormatSPlane>();\n+\telse\n+\t\tformat_ = utils::make_unique<V4L2FormatMPlane>();\n+\n \treturn 0;\n }\n \n@@ -262,4 +271,54 @@ int V4L2Device::setControl(unsigned int control, int value)\n \treturn v4l2_ctrl.value;\n }\n \n+/**\n+ * \\brief Retrieve the image format set on the V4L2 device\n+ *\n+ * TODO: define how the image format is encoded\n+ * FIXME: this function is a stub at the moment\n+ *\n+ * \\return 0 for success, a negative error code otherwise\n+ */\n+int V4L2Device::getFormat()\n+{\n+\treturn format_->getFormat();\n+}\n+\n+/**\n+ * \\brief Program an image format on the V4L2 device\n+ *\n+ * TODO: define how the image format is encoded\n+ * FIXME: this function is a stub at the moment\n+ *\n+ * \\return 0 for success, a negative error code otherwise\n+ */\n+int V4L2Device::setFormat()\n+{\n+\treturn format_->setFormat();\n+}\n+\n+/* FIXME: this function is a stub at the moment. */\n+int V4L2Device::V4L2FormatSPlane::getFormat()\n+{\n+\treturn 0;\n+}\n+\n+/* FIXME: this function is a stub at the moment. */\n+int V4L2Device::V4L2FormatSPlane::setFormat()\n+{\n+\treturn 0;\n+}\n+\n+/* FIXME: this function is a stub at the moment. */\n+int V4L2Device::V4L2FormatMPlane::getFormat()\n+{\n+\treturn 0;\n+}\n+\n+/* FIXME: this function is a stub at the moment. */\n+int V4L2Device::V4L2FormatMPlane::setFormat()\n+{\n+\treturn 0;\n+}\n+\n } /* namespace libcamera */\n","prefixes":["libcamera-devel","4/6"]}