[v1,1/3] libcamera: v4l2_videodevice: V4L2DeviceFormat: Expand formatting
diff mbox series

Message ID 20260908073640.39654-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1,1/3] libcamera: v4l2_videodevice: V4L2DeviceFormat: Expand formatting
Related show

Commit Message

Barnabás Pőcze Sept. 8, 2026, 7:36 a.m. UTC
Currently, only the size, the pixel format, and the color space is included
when a `V4L2DeviceFormat` is formatted into a stream.

Print the data about the planes as well (size and bytes-per-line), as it can
immensely help debugging if it is readily available in the log.

Example:

  640x480-YUYV[614400/1280]/Rec709/Rec709/Rec601/Limited

where the <size>/<bpl> pairs are printed inside the "[]" separated by ':'.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/libcamera/v4l2_videodevice.cpp | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 41dc5d0f65..bc539884e5 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -447,8 +447,19 @@  std::string V4L2DeviceFormat::toString() const
  */
 std::ostream &operator<<(std::ostream &out, const V4L2DeviceFormat &f)
 {
-	out << f.size << "-" << f.fourcc << "/"
-	    << ColorSpace::toString(f.colorSpace);
+	out << f.size << '-' << f.fourcc << '[';
+
+	for (size_t i = 0; i < f.planesCount; i++) {
+		const auto &p = f.planes[i];
+
+		out << p.size << '/' << p.bpl;
+
+		if (i + 1 < f.planesCount)
+			out << ':';
+	}
+
+	out << "]/" << ColorSpace::toString(f.colorSpace);
+
 	return out;
 }