Re: [PATCH v4 2/8] media-ctl: Add support for routes and streams

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24/04/2023 10:29, Laurent Pinchart wrote:

+
  	if (media_entity_type(entity) != MEDIA_ENT_T_V4L2_SUBDEV)
  		return;
- v4l2_subdev_print_format(entity, pad->index, V4L2_SUBDEV_FORMAT_ACTIVE);
-	v4l2_subdev_print_pad_dv(entity, pad->index, V4L2_SUBDEV_FORMAT_ACTIVE);
+	if (!routes) {
+		v4l2_subdev_print_format(entity, pad->index, 0, V4L2_SUBDEV_FORMAT_ACTIVE);
+		v4l2_subdev_print_pad_dv(entity, pad->index, V4L2_SUBDEV_FORMAT_ACTIVE);
+
+		if (pad->flags & MEDIA_PAD_FL_SOURCE)
+			v4l2_subdev_print_subdev_dv(entity);
+
+		return;
+	}
+
+	printed_streams_mask = 0;
+
+	for (i = 0; i < num_routes; ++i) {
+		const struct v4l2_subdev_route *r = &routes[i];

Naming the variable 'route' would be more explicit.

+		unsigned int stream;
- if (pad->flags & MEDIA_PAD_FL_SOURCE)
-		v4l2_subdev_print_subdev_dv(entity);
+		if (!(r->flags & V4L2_SUBDEV_ROUTE_FL_ACTIVE))
+			continue;
+
+		if (pad->flags & MEDIA_PAD_FL_SINK) {
+			if (r->sink_pad != pad->index)
+				continue;
+
+			stream = r->sink_stream;
+		} else {
+			if (r->source_pad != pad->index)
+				continue;
+
+			stream = r->source_stream;
+		}
+
+		if (printed_streams_mask & (1 << stream))
+			continue;
+
+		v4l2_subdev_print_format(entity, pad->index, stream, V4L2_SUBDEV_FORMAT_ACTIVE);
+		v4l2_subdev_print_pad_dv(entity, pad->index, V4L2_SUBDEV_FORMAT_ACTIVE);
+
+		if (pad->flags & MEDIA_PAD_FL_SOURCE)
+			v4l2_subdev_print_subdev_dv(entity);

v4l2_subdev_print_pad_dv() and v4l2_subdev_print_subdev_dv() don't
depend on routes or streams, should they be printed outside of the loop
?

There's an if-block above the for loop which handles the no-routes case.

 Tomi




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux