On 29/05/2023 10:49, Laurent Pinchart wrote:
On Mon, May 29, 2023 at 10:34:16AM +0300, Tomi Valkeinen wrote:
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.
What I meant is that the pad and entity variables are constant through
the whole loop, so why should the pad dv and subdev dv information be
printed for each route?
I see. Yes, you're right. Previously the DV prints happened after the
pad format print. So I could move them after the for loop which prints
all the streams. I don't have any DV devices (and they wouldn't have
streams anyway), but after hacking the code so that it always prints
some DV prints, it doesn't look too bad.
Tomi