Skip to contentSkip to conversation

Add debug prints to help working with streams

PATCH New Sakari Ailus 1 participant 3 messages Jul 10, 2025 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

v2 cover Add debug prints to help working with streams

Hi folks,

These two patches add debug prints to help working with streams. They were previously a part of my MC streaming control set <[email protected]>.

since v1:

- Align debug print formatting with the rest of the framework.

Sakari Ailus (2):
media: v4l2-subdev: Print early in

    v4l2_subdev_{enable,disable}_streams()

media: v4l2-subdev: Add debug prints to v4l2_subdev_collect_streams()

 drivers/media/v4l2-core/v4l2-subdev.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
Signature · 1 line
2.39.5
#1 lore raw

PATCH v2 1/2 media: v4l2-subdev: Print early in v4l2_subdev_{enable,disable}_streams()

Print debug messages early in v4l2_subdev_enable_streams() and v4l2_subdev_disable_streams(), before sanity checks take place. This can help figuring out why something goes wrong, in driver development or otherwise.

Also print the name of the sub-device where streaming is to be enabled or disabled.

---
 drivers/media/v4l2-core/v4l2-subdev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/media/v4l2-core/v4l2-subdev.c +6 -4
index c69d1aff701f..7b1a67a52efa 100644
@@ -2285,6 +2285,9 @@ int v4l2_subdev_enable_streams(struct v4l2_subdev *sd, u32 pad,
 	bool use_s_stream;
 	int ret;
 
+	dev_dbg(dev, "enable streams \"%s\":%u/%#llx\n", sd->entity.name, pad,
+		streams_mask);
+
 	/* A few basic sanity checks first. */
 	if (pad >= sd->entity.num_pads)
 		return -EINVAL;
@@ -2332,8 +2335,6 @@ int v4l2_subdev_enable_streams(struct v4l2_subdev *sd, u32 pad,
 		goto done;
 	}
 
-	dev_dbg(dev, "enable streams %u:%#llx\n", pad, streams_mask);
-
 	already_streaming = v4l2_subdev_is_streaming(sd);
 
 	if (!use_s_stream) {
@@ -2385,6 +2386,9 @@ int v4l2_subdev_disable_streams(struct v4l2_subdev *sd, u32 pad,
 	bool use_s_stream;
 	int ret;
 
+	dev_dbg(dev, "disable streams \"%s\":%u/%#llx\n", sd->entity.name, pad,
+		streams_mask);
+
 	/* A few basic sanity checks first. */
 	if (pad >= sd->entity.num_pads)
 		return -EINVAL;
@@ -2432,8 +2436,6 @@ int v4l2_subdev_disable_streams(struct v4l2_subdev *sd, u32 pad,
 		goto done;
 	}
 
-	dev_dbg(dev, "disable streams %u:%#llx\n", pad, streams_mask);
-
 	if (!use_s_stream) {
 		/* Call the .disable_streams() operation. */
 		ret = v4l2_subdev_call(sd, pad, disable_streams, state, pad,
Signature · 1 line
2.39.5
#2 lore raw

PATCH v2 2/2 media: v4l2-subdev: Add debug prints to v4l2_subdev_collect_streams()

In reply to Sakari Ailus

Print streams found by v4l2_subdev_collect_streams() at debug level. This could be useful in debugging drivers, userspace programs or the framework itself.

---
 drivers/media/v4l2-core/v4l2-subdev.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/media/v4l2-core/v4l2-subdev.c +7 -0
index 7b1a67a52efa..4fd25fea3b58 100644
@@ -2233,6 +2233,9 @@ static void v4l2_subdev_collect_streams(struct v4l2_subdev *sd,
 		*found_streams = BIT_ULL(0);
 		*enabled_streams =
 			(sd->enabled_pads & BIT_ULL(pad)) ? BIT_ULL(0) : 0;
+		dev_dbg(sd->dev,
+			"collect_streams: sub-device \"%s\" does not support streams\n",
+			sd->entity.name);
 		return;
 	}
 
@@ -2250,6 +2253,10 @@ static void v4l2_subdev_collect_streams(struct v4l2_subdev *sd,
 		if (cfg->enabled)
 			*enabled_streams |= BIT_ULL(cfg->stream);
 	}
+
+	dev_dbg(sd->dev,
+		"collect_streams: \"%s\":%u: found %#llx enabled %#llx\n",
+		sd->entity.name, pad, *found_streams, *enabled_streams);
 }
 
 static void v4l2_subdev_set_streams_enabled(struct v4l2_subdev *sd,
Signature · 1 line
2.39.5