From ee8127523879b2573893545f35c0f94b7d9f5deb Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Mon, 11 Mar 2019 16:32:06 +0100 Subject: libcamera: formats: Add toString() methods Add toString() helpers to pretty print out a V4L2Device or V4L2Subdevice format. Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Signed-off-by: Jacopo Mondi --- src/libcamera/v4l2_subdevice.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/libcamera/v4l2_subdevice.cpp') diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 5f58904b..cf873487 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -6,6 +6,8 @@ */ #include +#include +#include #include #include #include @@ -69,6 +71,22 @@ LOG_DEFINE_CATEGORY(V4L2Subdev) * \brief The image height in pixels */ +/** + * \brief Assemble and return a string describing the format + * + * \return A string describing the V4L2SubdeviceFormat + */ +const std::string V4L2SubdeviceFormat::toString() const +{ + std::stringstream ss; + + ss.fill(0); + ss << width << "x" << height << "-0x" << std::hex + << std::setw(4) << mbus_code; + + return ss.str(); +} + /** * \class V4L2Subdevice * \brief A V4L2 subdevice as exposed by the Linux kernel -- cgit v1.2.1