Skip to contentSkip to conversation

media: v4l2-subdev: Document that routing support depends on streams

PATCH In review Laurent Pinchart 3 participants 8 messages Aug 18, 2023 – Sep 4, 2023 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: v4l2-subdev: Document that routing support depends on streams

Routing support, through the subdev .set_routing() operation, requires the subdev to support streams. This is however not clearly documented anywhere. Fix it by expanding the operation's documentation to indicate that subdevs must set the V4L2_SUBDEV_FL_STREAMS flag.

---
 include/media/v4l2-subdev.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/media/v4l2-subdev.h +3 -2
index b325df0d54d6..0b04ed1994b6 100644
@@ -822,8 +822,9 @@ struct v4l2_subdev_state {
  *		     operation shall fail if the pad index it has been called on
  *		     is not valid or in case of unrecoverable failures.
  *
- * @set_routing: enable or disable data connection routes described in the
- *		 subdevice routing table.
+ * @set_routing: Enable or disable data connection routes described in the
+ *		 subdevice routing table. Subdevs that implement this operation
+ *		 must set the V4L2_SUBDEV_FL_STREAMS flag.
  *
  * @enable_streams: Enable the streams defined in streams_mask on the given
  *	source pad. Subdevs that implement this operation must use the active
Signature · 3 lines
Regards,

Laurent Pinchart
#1 lore raw

Hi Laurent,

Quoted 15 lines · Laurent Pinchart

Routing support, through the subdev .set_routing() operation, requires the subdev to support streams. This is however not clearly documented anywhere. Fix it by expanding the operation's documentation to indicate that subdevs must set the V4L2_SUBDEV_FL_STREAMS flag.

---
 include/media/v4l2-subdev.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/media/v4l2-subdev.h +0 -0
index b325df0d54d6..0b04ed1994b6 100644

include/media/v4l2-subdev.h struct v4l2_subdev_state { · line 827

Quoted 8 lines
include/media/v4l2-subdev.h +3 -2
@@ -822,8 +822,9 @@ struct v4l2_subdev_state {
  *		     operation shall fail if the pad index it has been called on
  *		     is not valid or in case of unrecoverable failures.
  *
- * @set_routing: enable or disable data connection routes described in the
- *		 subdevice routing table.
+ * @set_routing: Enable or disable data connection routes described in the
+ *		 subdevice routing table. Subdevs that implement this operation
+ *		 must set the V4L2_SUBDEV_FL_STREAMS flag.

Could we set the flag in the core when this op exists for a sub-device?

We could do similarly for events when the sub-device has a control handler.

The device node should probably exist in almost all cases, but I'm not sure right now whether there is a reasonable test for it.

Signature · 3 lines
Regards,

Sakari Ailus
#2 lore raw

Hi Sakari,

Quoted 11 lines · Sakari Ailus
Quoted 10 lines · Laurent Pinchart

Routing support, through the subdev .set_routing() operation, requires the subdev to support streams. This is however not clearly documented anywhere. Fix it by expanding the operation's documentation to indicate that subdevs must set the V4L2_SUBDEV_FL_STREAMS flag.

---
 include/media/v4l2-subdev.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 15 lines

include/media/v4l2-subdev.h struct v4l2_subdev_state { · line 827

Quoted 13 lines
include/media/v4l2-subdev.h +3 -2
index b325df0d54d6..0b04ed1994b6 100644
@@ -822,8 +822,9 @@ struct v4l2_subdev_state {
  *		     operation shall fail if the pad index it has been called on
  *		     is not valid or in case of unrecoverable failures.
  *
- * @set_routing: enable or disable data connection routes described in the
- *		 subdevice routing table.
+ * @set_routing: Enable or disable data connection routes described in the
+ *		 subdevice routing table. Subdevs that implement this operation
+ *		 must set the V4L2_SUBDEV_FL_STREAMS flag.

Could we set the flag in the core when this op exists for a sub-device?

That won't work in all cases, as a driver could expose immutable routes by creating them in the .init_cfg() function, without implementing .set_routing().

Another option would be to check if the drivers has created routes after the .init_cfg() called (indirectly) from v4l2_subdev_init_finalize(). It may be a bit fragile though.

Quoted 1 line

We could do similarly for events when the sub-device has a control handler.

A subdev could generate non-control events too. In most cases I suppose it would still create a control handler, but I don't think we should require that.

Quoted 2 lines

The device node should probably exist in almost all cases, but I'm not sure right now whether there is a reasonable test for it.

Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

Hi Laurent,

Quoted 30 lines · Laurent Pinchart

Hi Sakari,

Quoted 11 lines · Sakari Ailus
Quoted 10 lines · Laurent Pinchart

Routing support, through the subdev .set_routing() operation, requires the subdev to support streams. This is however not clearly documented anywhere. Fix it by expanding the operation's documentation to indicate that subdevs must set the V4L2_SUBDEV_FL_STREAMS flag.

---
 include/media/v4l2-subdev.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 15 lines

include/media/v4l2-subdev.h struct v4l2_subdev_state { · line 827

Quoted 13 lines
include/media/v4l2-subdev.h +3 -2
index b325df0d54d6..0b04ed1994b6 100644
@@ -822,8 +822,9 @@ struct v4l2_subdev_state {
  *		     operation shall fail if the pad index it has been called on
  *		     is not valid or in case of unrecoverable failures.
  *
- * @set_routing: enable or disable data connection routes described in the
- *		 subdevice routing table.
+ * @set_routing: Enable or disable data connection routes described in the
+ *		 subdevice routing table. Subdevs that implement this operation
+ *		 must set the V4L2_SUBDEV_FL_STREAMS flag.

Could we set the flag in the core when this op exists for a sub-device?

Quoted 7 lines

That won't work in all cases, as a driver could expose immutable routes by creating them in the .init_cfg() function, without implementing .set_routing().

Another option would be to check if the drivers has created routes after the .init_cfg() called (indirectly) from v4l2_subdev_init_finalize(). It may be a bit fragile though.

If you have either, then the sub-device does support streams. As otherwise, there are no streams exposed to the user space. Right?

Quoted 6 lines
Quoted 2 lines

We could do similarly for events when the sub-device has a control handler.

A subdev could generate non-control events too. In most cases I suppose it would still create a control handler, but I don't think we should require that.

I suggested this mainly as there are tonnes of drivers that expose controls (and thus control events) but do not have the events flag set. Doing this automatically for almost all drivers would reduce bugs.

Quoted 3 lines
Quoted 3 lines

The device node should probably exist in almost all cases, but I'm not sure right now whether there is a reasonable test for it.

Signature · 3 lines
Regards,

Sakari Ailus
#4 lore raw
Quoted 37 lines · Sakari Ailus

Hi Laurent,

Quoted 34 lines · Laurent Pinchart

Hi Sakari,

Quoted 11 lines · Sakari Ailus
Quoted 10 lines · Laurent Pinchart

Routing support, through the subdev .set_routing() operation, requires the subdev to support streams. This is however not clearly documented anywhere. Fix it by expanding the operation's documentation to indicate that subdevs must set the V4L2_SUBDEV_FL_STREAMS flag.

---
  include/media/v4l2-subdev.h | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 15 lines

include/media/v4l2-subdev.h struct v4l2_subdev_state { · line 827

Quoted 13 lines
include/media/v4l2-subdev.h +3 -2
index b325df0d54d6..0b04ed1994b6 100644
@@ -822,8 +822,9 @@ struct v4l2_subdev_state {
   *		     operation shall fail if the pad index it has been called on
   *		     is not valid or in case of unrecoverable failures.
   *
- * @set_routing: enable or disable data connection routes described in the
- *		 subdevice routing table.
+ * @set_routing: Enable or disable data connection routes described in the
+ *		 subdevice routing table. Subdevs that implement this operation
+ *		 must set the V4L2_SUBDEV_FL_STREAMS flag.

Could we set the flag in the core when this op exists for a sub-device?

That won't work in all cases, as a driver could expose immutable routes by creating them in the .init_cfg() function, without implementing .set_routing().

Quoted 6 lines
Quoted 3 lines

Another option would be to check if the drivers has created routes after the .init_cfg() called (indirectly) from v4l2_subdev_init_finalize(). It may be a bit fragile though.

If you have either, then the sub-device does support streams. As otherwise, there are no streams exposed to the user space. Right?

We need to know the existence of V4L2_SUBDEV_FL_STREAMS flag before calling init_cfg, in __v4l2_subdev_state_alloc.

Tomi

#5 lore raw
Quoted 42 lines · Tomi Valkeinen
Quoted 41 lines · Sakari Ailus

Hi Laurent,

Quoted 37 lines · Laurent Pinchart

Hi Sakari,

Quoted 11 lines · Sakari Ailus
Quoted 10 lines · Laurent Pinchart

Routing support, through the subdev .set_routing() operation, requires the subdev to support streams. This is however not clearly documented anywhere. Fix it by expanding the operation's documentation to indicate that subdevs must set the V4L2_SUBDEV_FL_STREAMS flag.

---
  include/media/v4l2-subdev.h | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 15 lines

include/media/v4l2-subdev.h struct v4l2_subdev_state { · line 827

Quoted 13 lines
include/media/v4l2-subdev.h +3 -2
index b325df0d54d6..0b04ed1994b6 100644
@@ -822,8 +822,9 @@ struct v4l2_subdev_state {
   *		     operation shall fail if the pad index it has been called on
   *		     is not valid or in case of unrecoverable failures.
   *
- * @set_routing: enable or disable data connection routes described in the
- *		 subdevice routing table.
+ * @set_routing: Enable or disable data connection routes described in the
+ *		 subdevice routing table. Subdevs that implement this operation
+ *		 must set the V4L2_SUBDEV_FL_STREAMS flag.

Could we set the flag in the core when this op exists for a sub-device?

That won't work in all cases, as a driver could expose immutable routes by creating them in the .init_cfg() function, without implementing .set_routing().

Another option would be to check if the drivers has created routes after the .init_cfg() called (indirectly) from v4l2_subdev_init_finalize(). It may be a bit fragile though.

Quoted 5 lines
Quoted 2 lines

If you have either, then the sub-device does support streams. As otherwise, there are no streams exposed to the user space. Right?

We need to know the existence of V4L2_SUBDEV_FL_STREAMS flag before calling init_cfg, in __v4l2_subdev_state_alloc.

Good point. Still, it'd be great to get rid of such flags. They are incorrectly set in so many places. :-(

Signature · 1 line
Sakari Ailus
#6 lore raw
Quoted 43 lines · Sakari Ailus
Quoted 42 lines · Tomi Valkeinen
Quoted 41 lines · Sakari Ailus

Hi Laurent,

Quoted 37 lines · Laurent Pinchart

Hi Sakari,

Quoted 11 lines · Sakari Ailus
Quoted 10 lines · Laurent Pinchart

Routing support, through the subdev .set_routing() operation, requires the subdev to support streams. This is however not clearly documented anywhere. Fix it by expanding the operation's documentation to indicate that subdevs must set the V4L2_SUBDEV_FL_STREAMS flag.

---
   include/media/v4l2-subdev.h | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 15 lines

include/media/v4l2-subdev.h struct v4l2_subdev_state { · line 827

Quoted 13 lines
include/media/v4l2-subdev.h +3 -2
index b325df0d54d6..0b04ed1994b6 100644
@@ -822,8 +822,9 @@ struct v4l2_subdev_state {
    *		     operation shall fail if the pad index it has been called on
    *		     is not valid or in case of unrecoverable failures.
    *
- * @set_routing: enable or disable data connection routes described in the
- *		 subdevice routing table.
+ * @set_routing: Enable or disable data connection routes described in the
+ *		 subdevice routing table. Subdevs that implement this operation
+ *		 must set the V4L2_SUBDEV_FL_STREAMS flag.

Could we set the flag in the core when this op exists for a sub-device?

That won't work in all cases, as a driver could expose immutable routes by creating them in the .init_cfg() function, without implementing .set_routing().

Another option would be to check if the drivers has created routes after the .init_cfg() called (indirectly) from v4l2_subdev_init_finalize(). It may be a bit fragile though.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

If you have either, then the sub-device does support streams. As otherwise, there are no streams exposed to the user space. Right?

We need to know the existence of V4L2_SUBDEV_FL_STREAMS flag before calling init_cfg, in __v4l2_subdev_state_alloc.

Good point. Still, it'd be great to get rid of such flags. They are incorrectly set in so many places. :-(

Hmm, well, if we want, we could return an error at the end of __v4l2_subdev_init_finalize, if V4L2_SUBDEV_FL_STREAMS is set, but there is no .set_routing and .init_cfg did not set up routing, OR if V4L2_SUBDEV_FL_STREAMS is not set, but .set_routing exists. We could also check for V4L2_SUBDEV_FL_STREAMS in v4l2_subdev_set_routing, and return an error if it's not set.

I think if a subdev erroneously does not set V4L2_SUBDEV_FL_STREAMS, the driver won't get very far. So it's not an issue that can go hidden for very long.

Tomi

Reviewed-by on v1 1/1
#7 lore raw
In reply to Laurent Pinchart
Quoted 16 lines · Laurent Pinchart

Routing support, through the subdev .set_routing() operation, requires the subdev to support streams. This is however not clearly documented anywhere. Fix it by expanding the operation's documentation to indicate that subdevs must set the V4L2_SUBDEV_FL_STREAMS flag.

---
  include/media/v4l2-subdev.h | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
include/media/v4l2-subdev.h +0 -0
index b325df0d54d6..0b04ed1994b6 100644
@@ -822,8 +822,9 @@ struct v4l2_subdev_state {
   *		     operation shall fail if the pad index it has been called on

include/media/v4l2-subdev.h struct v4l2_subdev_state { · line 830

Quoted 10 lines
include/media/v4l2-subdev.h +3 -2
   *		     is not valid or in case of unrecoverable failures.
   *
- * @set_routing: enable or disable data connection routes described in the
- *		 subdevice routing table.
+ * @set_routing: Enable or disable data connection routes described in the
+ *		 subdevice routing table. Subdevs that implement this operation
+ *		 must set the V4L2_SUBDEV_FL_STREAMS flag.
   *
   * @enable_streams: Enable the streams defined in streams_mask on the given
   *	source pad. Subdevs that implement this operation must use the active

Tomi