{"id":716,"url":"https://patchwork.libcamera.org/api/patches/716/?format=json","web_url":"https://patchwork.libcamera.org/patch/716/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20190312121242.2253-2-jacopo@jmondi.org>","date":"2019-03-12T12:12:29","name":"[libcamera-devel,v2,01/14] libcamera: formats: Add toString() methods","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"043d1ec60b38677fa2e96fe9aac8166899cc7069","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/716/mbox/","series":[{"id":205,"url":"https://patchwork.libcamera.org/api/series/205/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=205","date":"2019-03-12T12:12:28","name":"libcamera: ipu3: ImgU support","version":2,"mbox":"https://patchwork.libcamera.org/series/205/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/716/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/716/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 187BF600FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Mar 2019 13:12:20 +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 relay5-d.mail.gandi.net (Postfix) with ESMTPSA id A15BD1C000A;\n\tTue, 12 Mar 2019 12:12:19 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 12 Mar 2019 13:12:29 +0100","Message-Id":"<20190312121242.2253-2-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190312121242.2253-1-jacopo@jmondi.org>","References":"<20190312121242.2253-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 01/14] libcamera: formats: Add\n\ttoString() methods","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":"Tue, 12 Mar 2019 12:12:20 -0000"},"content":"Add toString() helpers to pretty print out a V4L2Device or V4L2Subdevice\nformat.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_device.h    |  2 ++\n src/libcamera/include/v4l2_subdevice.h |  2 ++\n src/libcamera/v4l2_device.cpp          | 18 ++++++++++++++++++\n src/libcamera/v4l2_subdevice.cpp       | 18 ++++++++++++++++++\n 4 files changed, 40 insertions(+)","diff":"diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 5c379fac66dc..258deee8d461 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -100,6 +100,8 @@ public:\n \t\tuint32_t bpl;\n \t} planes[3];\n \tunsigned int planesCount;\n+\n+\tconst std::string toString() const;\n };\n \n class V4L2Device : protected Loggable\ndiff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex 1cc0fab73103..700e66bcddac 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -21,6 +21,8 @@ struct V4L2SubdeviceFormat {\n \tuint32_t mbus_code;\n \tuint32_t width;\n \tuint32_t height;\n+\n+\tconst std::string toString() const;\n };\n \n class V4L2Subdevice : protected Loggable\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex a88a5f5ff036..0bdcfc1d3c8f 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -6,6 +6,8 @@\n  */\n \n #include <fcntl.h>\n+#include <iomanip>\n+#include <sstream>\n #include <string.h>\n #include <sys/ioctl.h>\n #include <sys/mman.h>\n@@ -223,6 +225,22 @@ LOG_DEFINE_CATEGORY(V4L2)\n  * \\brief The number of valid data planes\n  */\n \n+/**\n+ * \\brief Assemble and return a string describing the format\n+ *\n+ * \\return A string describing the V4L2DeviceFormat\n+ */\n+const std::string V4L2DeviceFormat::toString() const\n+{\n+\tstd::stringstream ss;\n+\n+\tss.fill(0);\n+\tss << width << \"x\" << height << \"- 0x\" << std::hex\n+\t   << std::setw(8) << fourcc << \" planes: \" << planesCount;\n+\n+\treturn ss.str();\n+}\n+\n /**\n  * \\class V4L2Device\n  * \\brief V4L2Device object and API\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 5f58904bf9e6..7c56ba3ba510 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -6,6 +6,8 @@\n  */\n \n #include <fcntl.h>\n+#include <iomanip>\n+#include <sstream>\n #include <string.h>\n #include <sys/ioctl.h>\n #include <unistd.h>\n@@ -69,6 +71,22 @@ LOG_DEFINE_CATEGORY(V4L2Subdev)\n  * \\brief The image height in pixels\n  */\n \n+/**\n+ * \\brief Assemble and return a string describing the format\n+ *\n+ * \\return A string describing the V4L2SubdeviceFormat\n+ */\n+const std::string V4L2SubdeviceFormat::toString() const\n+{\n+\tstd::stringstream ss;\n+\n+\tss.fill(0);\n+\tss << width << \"x\" << height << \" - 0x\" << std::hex << std::setw(8)\n+\t   << mbus_code;\n+\n+\treturn ss.str();\n+}\n+\n /**\n  * \\class V4L2Subdevice\n  * \\brief A V4L2 subdevice as exposed by the Linux kernel\n","prefixes":["libcamera-devel","v2","01/14"]}