{"id":15758,"url":"https://patchwork.libcamera.org/api/patches/15758/?format=json","web_url":"https://patchwork.libcamera.org/patch/15758/","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":"<20220429212348.18063-5-laurent.pinchart@ideasonboard.com>","date":"2022-04-29T21:23:47","name":"[libcamera-devel,4/5] libcamera: Add operator<<() for V4L2 format classes","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d01d9eca0cb717bcae0a939ba95454eded0a86f8","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15758/mbox/","series":[{"id":3084,"url":"https://patchwork.libcamera.org/api/series/3084/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3084","date":"2022-04-29T21:23:43","name":"libcamera: More operator<<() for stream output","version":1,"mbox":"https://patchwork.libcamera.org/series/3084/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15758/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15758/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E95DBC326D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 29 Apr 2022 21:23:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7CF906564A;\n\tFri, 29 Apr 2022 23:23:58 +0200 (CEST)","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 B77EB65648\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Apr 2022 23:23:54 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4B0058EB;\n\tFri, 29 Apr 2022 23:23:54 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1651267438;\n\tbh=W76n6HoevJoFngdULGEdm7WOQ2oOHCc3vwuiacl57so=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=i7moMaLhBKUGNh0QMBZm9XxI25JxA5WpBbPL1dwr+iuTMkIXeUfl3HebjHzsH8McD\n\tcUMnTxLfxotuzI8Fr0rIA8OM+VXxc/IuNYGF5gRv6v4ng2xxNL7XGszLyZ9NEIPxjq\n\tFxQ2IAyu5q0Lr86fmd2kSqms+68AheTDEFSsY1joIQenAA0wqQxy/iwm/ztgT6Fpuk\n\tUhaQ6iNn71+kqS1jdxKXHiFZbGBpAx5p+O/1WTAxXBtfh6wlgUl19i6nqIyl5hh3rK\n\tVRWCga4SJZLJ42IfgLETjk5T3LpR3d9InMeFFPbGnmdvrABxvJ4cbmeM0zGBElZgkQ\n\trMV2zbu8rlllQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1651267434;\n\tbh=W76n6HoevJoFngdULGEdm7WOQ2oOHCc3vwuiacl57so=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=gvmuhQlCoI0DPq3BagAPCiOlb2fo7OJBCGLX1LL8s9p7k2DaSYT3WQxV7L6HB37E5\n\tFcGRsSdDWW2GR+qV0ECQwfVFSLrXyj1hjI5wFEJZiSFCutTrtIGAasRDfhuI5DgDzX\n\ts0ZDhgiGIjK07+GlwqhWqLMlkUfcSW5zq3GUBQpo="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"gvmuhQlC\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 30 Apr 2022 00:23:47 +0300","Message-Id":"<20220429212348.18063-5-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220429212348.18063-1-laurent.pinchart@ideasonboard.com>","References":"<20220429212348.18063-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 4/5] libcamera: Add operator<<() for V4L2\n\tformat classes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Implement the stream output operator<<() for the V4L2DeviceFormat and\nV4L2SubdeviceFormat classes to simplify printing them.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_subdevice.h   |  3 ++\n include/libcamera/internal/v4l2_videodevice.h |  3 ++\n src/libcamera/v4l2_subdevice.cpp              | 34 +++++++++++++------\n src/libcamera/v4l2_videodevice.cpp            | 16 ++++++++-\n 4 files changed, 45 insertions(+), 11 deletions(-)","diff":"diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex 58d1e5114e7b..6fda52ada41b 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -9,6 +9,7 @@\n \n #include <memory>\n #include <optional>\n+#include <ostream>\n #include <string>\n #include <vector>\n \n@@ -35,6 +36,8 @@ struct V4L2SubdeviceFormat {\n \tuint8_t bitsPerPixel() const;\n };\n \n+std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f);\n+\n class V4L2Subdevice : public V4L2Device\n {\n public:\ndiff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 9c9493cc16ed..23f37f83f8e2 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -11,6 +11,7 @@\n #include <atomic>\n #include <memory>\n #include <optional>\n+#include <ostream>\n #include <stdint.h>\n #include <string>\n #include <vector>\n@@ -180,6 +181,8 @@ public:\n \tconst std::string toString() const;\n };\n \n+std::ostream &operator<<(std::ostream &out, const V4L2DeviceFormat &f);\n+\n class V4L2VideoDevice : public V4L2Device\n {\n public:\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex d5ae460571d8..b3d0ddad83db 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -190,17 +190,10 @@ const std::map<uint32_t, V4L2SubdeviceFormatInfo> formatInfoMap = {\n  */\n const std::string V4L2SubdeviceFormat::toString() const\n {\n-\tstd::stringstream mbus;\n-\tmbus << size << \"-\";\n+\tstd::stringstream ss;\n+\tss << *this;\n \n-\tconst auto it = formatInfoMap.find(mbus_code);\n-\n-\tif (it == formatInfoMap.end())\n-\t\tmbus << utils::hex(mbus_code, 4);\n-\telse\n-\t\tmbus << it->second.name;\n-\n-\treturn mbus.str();\n+\treturn ss.str();\n }\n \n /**\n@@ -220,6 +213,27 @@ uint8_t V4L2SubdeviceFormat::bitsPerPixel() const\n \treturn it->second.bitsPerPixel;\n }\n \n+/**\n+ * \\brief Insert a text representation of a V4L2SubdeviceFormat into an output\n+ * stream\n+ * \\param[in] out The output stream\n+ * \\param[in] f The V4L2SubdeviceFormat\n+ * \\return The output stream \\a out\n+ */\n+std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f)\n+{\n+\tout << f.size << \"-\";\n+\n+\tconst auto it = formatInfoMap.find(f.mbus_code);\n+\n+\tif (it == formatInfoMap.end())\n+\t\tout << utils::hex(f.mbus_code, 4);\n+\telse\n+\t\tout << it->second.name;\n+\n+\treturn out;\n+}\n+\n /**\n  * \\class V4L2Subdevice\n  * \\brief A V4L2 subdevice as exposed by the Linux kernel\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 5ba866ad71bb..5b4637b1a39e 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -433,10 +433,24 @@ bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const\n const std::string V4L2DeviceFormat::toString() const\n {\n \tstd::stringstream ss;\n-\tss << size << \"-\" << fourcc.toString();\n+\tss << *this;\n+\n \treturn ss.str();\n }\n \n+/**\n+ * \\brief Insert a text representation of a V4L2DeviceFormat into an output\n+ * stream\n+ * \\param[in] out The output stream\n+ * \\param[in] f The V4L2DeviceFormat\n+ * \\return The output stream \\a out\n+ */\n+std::ostream &operator<<(std::ostream &out, const V4L2DeviceFormat &f)\n+{\n+\tout << f.size << \"-\" << f.fourcc;\n+\treturn out;\n+}\n+\n /**\n  * \\class V4L2VideoDevice\n  * \\brief V4L2VideoDevice object and API\n","prefixes":["libcamera-devel","4/5"]}