Skip to contentSkip to conversation

media: v4l: implement virtual channels

RFC PATCH In review Cosmin Tanislav 3 participants 6 messages Jan 10, 2024 – Jan 14, 2024 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 media: v4l: implement virtual channels

With experimental support for multiple streams per pad being added, the pieces are in place to support a virtual channel id per stream.

This is necessary because stream ids cannot be directly mapped to a virtual channel id, since the same virtual channel id can be assigned to multiple streams of data, each with a different data type.

To implement this, the following steps have been taken.

Add subdev ioctls for getting and setting the virtual channel for a specific pad and stream.

Add pad .get_vc() and .set_vc() ops.

Add the virtual channel to the stream config in V4L2 subdev central state.

Add a default .get_vc() implementation that retrieves the virtual channel from the central state, or, if that is not supported, default to virtual channel 0.

---
 drivers/media/v4l2-core/v4l2-subdev.c | 57 +++++++++++++++++++++++++++
 include/media/v4l2-subdev.h           | 39 ++++++++++++++++++
 include/uapi/linux/v4l2-subdev.h      | 18 +++++++++
 3 files changed, 114 insertions(+)
drivers/media/v4l2-core/v4l2-subdev.c +57 -0
index be86b906c985..8945bfd0fe12 100644
@@ -535,6 +535,9 @@ subdev_ioctl_get_state(struct v4l2_subdev *sd, struct v4l2_subdev_fh *subdev_fh,
 	case VIDIOC_SUBDEV_S_ROUTING:
 		which = ((struct v4l2_subdev_routing *)arg)->which;
 		break;
+	case VIDIOC_SUBDEV_G_VC:
+	case VIDIOC_SUBDEV_S_VC:
+		which = ((struct v4l2_subdev_vc *)arg)->which;
 	}
 
 	return which == V4L2_SUBDEV_FORMAT_TRY ?
@@ -969,6 +972,26 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
 					routing->which, &krouting);
 	}
 
+	case VIDIOC_SUBDEV_G_VC: {
+		struct v4l2_subdev_vc *vc = arg;
+
+		if (!client_supports_streams)
+			vc->stream = 0;
+
+		memset(vc->reserved, 0, sizeof(vc->reserved));
+		return v4l2_subdev_call(sd, pad, get_vc, state, vc);
+	}
+
+	case VIDIOC_SUBDEV_S_VC: {
+		struct v4l2_subdev_vc *vc = arg;
+
+		if (!client_supports_streams)
+			vc->stream = 0;
+
+		memset(vc->reserved, 0, sizeof(vc->reserved));
+		return v4l2_subdev_call(sd, pad, set_vc, state, vc);
+	}
+
 	case VIDIOC_SUBDEV_G_CLIENT_CAP: {
 		struct v4l2_subdev_client_capability *client_cap = arg;
 
@@ -1602,6 +1625,20 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt);
 
+int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
+		       struct v4l2_subdev_vc *vc)
+{
+	u32 vc_id = 0;
+
+	if (sd->flags & V4L2_SUBDEV_FL_STREAMS)
+		vc_id = v4l2_subdev_state_get_stream_vc(state, vc->pad, vc->stream);
+
+	vc->vc = vc_id;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_get_vc);
+
 int v4l2_subdev_set_routing(struct v4l2_subdev *sd,
 			    struct v4l2_subdev_state *state,
 			    const struct v4l2_subdev_krouting *routing)
@@ -1745,6 +1782,26 @@ v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_compose);
 
+u32 v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+				    unsigned int pad, u32 stream)
+{
+	struct v4l2_subdev_stream_configs *stream_configs;
+	unsigned int i;
+
+	lockdep_assert_held(state->lock);
+
+	stream_configs = &state->stream_configs;
+
+	for (i = 0; i < stream_configs->num_configs; ++i) {
+		if (stream_configs->configs[i].pad == pad &&
+		    stream_configs->configs[i].stream == stream)
+			return stream_configs->configs[i].vc;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_vc);
+
 int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
 					  u32 pad, u32 stream, u32 *other_pad,
 					  u32 *other_stream)
include/media/v4l2-subdev.h +39 -0
index c1f90c1223a7..ed1fdd79c2bb 100644
@@ -722,6 +722,7 @@ struct v4l2_subdev_stream_config {
 	u32 stream;
 	bool enabled;
 
+	u32 vc;
 	struct v4l2_mbus_framefmt fmt;
 	struct v4l2_rect crop;
 	struct v4l2_rect compose;
@@ -858,6 +859,12 @@ struct v4l2_subdev_pad_ops {
 	int (*set_fmt)(struct v4l2_subdev *sd,
 		       struct v4l2_subdev_state *state,
 		       struct v4l2_subdev_format *format);
+	int (*get_vc)(struct v4l2_subdev *sd,
+		      struct v4l2_subdev_state *state,
+		      struct v4l2_subdev_vc *vc);
+	int (*set_vc)(struct v4l2_subdev *sd,
+		      struct v4l2_subdev_state *state,
+		      struct v4l2_subdev_vc *vc);
 	int (*get_selection)(struct v4l2_subdev *sd,
 			     struct v4l2_subdev_state *state,
 			     struct v4l2_subdev_selection *sel);
@@ -1494,6 +1501,23 @@ v4l2_subdev_lock_and_get_active_state(struct v4l2_subdev *sd)
 int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
 			struct v4l2_subdev_format *format);
 
+/**
+ * v4l2_subdev_get_vc() - Fill virtual channel based on state
+ * @sd: subdevice
+ * @state: subdevice state
+ * @vc: pointer to &struct v4l2_subdev_vc
+ *
+ * Fill @vc->vc field based on the information in the @vc struct.
+ *
+ * This function can be used by the subdev drivers which support active state to
+ * implement v4l2_subdev_pad_ops.get_vc if the subdev driver does not need to
+ * do anything special in their get_vc op.
+ *
+ * Returns 0 on success, error value otherwise.
+ */
+int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
+		       struct v4l2_subdev_vc *vc);
+
 /**
  * v4l2_subdev_set_routing() - Set given routing to subdev state
  * @sd: The subdevice
@@ -1585,6 +1609,21 @@ struct v4l2_rect *
 v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
 				     unsigned int pad, u32 stream);
 
+/**
+ * v4l2_subdev_state_get_stream_vc() - Get the virtual channel of a stream
+ * @state: subdevice state
+ * @pad: pad id
+ * @stream: stream id
+ *
+ * This returns the virtual channel for the given pad + stream in the
+ * subdev state.
+ *
+ * If the state does not contain the given pad + stream, 0 is returned.
+ */
+u32
+v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+				unsigned int pad, u32 stream);
+
 /**
  * v4l2_subdev_routing_find_opposite_end() - Find the opposite stream
  * @routing: routing used to find the opposite side
include/uapi/linux/v4l2-subdev.h +18 -0
index b383c2fe0cf3..8e90405bb1e6 100644
@@ -187,6 +187,22 @@ struct v4l2_subdev_capability {
 	__u32 reserved[14];
 };
 
+/**
+ * struct v4l2_subdev_vc - Pad-level virtual channel settings
+ * @which: format type (from enum v4l2_subdev_format_whence)
+ * @pad: pad number, as reported by the media API
+ * @vc: virtual channel
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
+ */
+struct v4l2_subdev_vc {
+	__u32 which;
+	__u32 pad;
+	__u32 vc;
+	__u32 stream;
+	__u32 reserved[7];
+};
+
 /* The v4l2 sub-device video device node is registered in read-only mode. */
 #define V4L2_SUBDEV_CAP_RO_SUBDEV		0x00000001
 
@@ -268,6 +284,8 @@ struct v4l2_subdev_client_capability {
 #define VIDIOC_SUBDEV_S_SELECTION		_IOWR('V', 62, struct v4l2_subdev_selection)
 #define VIDIOC_SUBDEV_G_ROUTING			_IOWR('V', 38, struct v4l2_subdev_routing)
 #define VIDIOC_SUBDEV_S_ROUTING			_IOWR('V', 39, struct v4l2_subdev_routing)
+#define VIDIOC_SUBDEV_G_VC			_IOWR('V', 40, struct v4l2_subdev_vc)
+#define VIDIOC_SUBDEV_S_VC			_IOWR('V', 41, struct v4l2_subdev_vc)
 #define VIDIOC_SUBDEV_G_CLIENT_CAP		_IOR('V',  101, struct v4l2_subdev_client_capability)
 #define VIDIOC_SUBDEV_S_CLIENT_CAP		_IOWR('V',  102, struct v4l2_subdev_client_capability)
 
Signature · 1 line
2.43.0
#1 lore raw

Hi!

Quoted 12 lines · Cosmin Tanislav

With experimental support for multiple streams per pad being added, the pieces are in place to support a virtual channel id per stream.

This is necessary because stream ids cannot be directly mapped to a virtual channel id, since the same virtual channel id can be assigned to multiple streams of data, each with a different data type.

To implement this, the following steps have been taken.

Add subdev ioctls for getting and setting the virtual channel for a specific pad and stream.

Quoted 7 lines

Add pad .get_vc() and .set_vc() ops.

Add the virtual channel to the stream config in V4L2 subdev central state.

Add a default .get_vc() implementation that retrieves the virtual channel from the central state, or, if that is not supported, default to virtual channel 0.

Why do you need this?

The design idea with streams was that the streams are not tied to CSI-2 streams (or to any specific HW). The CSI-2 virtual channels should be handled by the drivers internally, and they should not be visible to the userspace at all.

Tomi

Quoted 203 lines
---
  drivers/media/v4l2-core/v4l2-subdev.c | 57 +++++++++++++++++++++++++++
  include/media/v4l2-subdev.h           | 39 ++++++++++++++++++
  include/uapi/linux/v4l2-subdev.h      | 18 +++++++++
  3 files changed, 114 insertions(+)
drivers/media/v4l2-core/v4l2-subdev.c +57 -0
index be86b906c985..8945bfd0fe12 100644
@@ -535,6 +535,9 @@ subdev_ioctl_get_state(struct v4l2_subdev *sd, struct v4l2_subdev_fh *subdev_fh,
  	case VIDIOC_SUBDEV_S_ROUTING:
  		which = ((struct v4l2_subdev_routing *)arg)->which;
  		break;
+	case VIDIOC_SUBDEV_G_VC:
+	case VIDIOC_SUBDEV_S_VC:
+		which = ((struct v4l2_subdev_vc *)arg)->which;
  	}
 
  	return which == V4L2_SUBDEV_FORMAT_TRY ?
@@ -969,6 +972,26 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
  					routing->which, &krouting);
  	}
 
+	case VIDIOC_SUBDEV_G_VC: {
+		struct v4l2_subdev_vc *vc = arg;
+
+		if (!client_supports_streams)
+			vc->stream = 0;
+
+		memset(vc->reserved, 0, sizeof(vc->reserved));
+		return v4l2_subdev_call(sd, pad, get_vc, state, vc);
+	}
+
+	case VIDIOC_SUBDEV_S_VC: {
+		struct v4l2_subdev_vc *vc = arg;
+
+		if (!client_supports_streams)
+			vc->stream = 0;
+
+		memset(vc->reserved, 0, sizeof(vc->reserved));
+		return v4l2_subdev_call(sd, pad, set_vc, state, vc);
+	}
+
  	case VIDIOC_SUBDEV_G_CLIENT_CAP: {
  		struct v4l2_subdev_client_capability *client_cap = arg;
 
@@ -1602,6 +1625,20 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
  }
  EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt);
 
+int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
+		       struct v4l2_subdev_vc *vc)
+{
+	u32 vc_id = 0;
+
+	if (sd->flags & V4L2_SUBDEV_FL_STREAMS)
+		vc_id = v4l2_subdev_state_get_stream_vc(state, vc->pad, vc->stream);
+
+	vc->vc = vc_id;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_get_vc);
+
  int v4l2_subdev_set_routing(struct v4l2_subdev *sd,
  			    struct v4l2_subdev_state *state,
  			    const struct v4l2_subdev_krouting *routing)
@@ -1745,6 +1782,26 @@ v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
  }
  EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_compose);
 
+u32 v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+				    unsigned int pad, u32 stream)
+{
+	struct v4l2_subdev_stream_configs *stream_configs;
+	unsigned int i;
+
+	lockdep_assert_held(state->lock);
+
+	stream_configs = &state->stream_configs;
+
+	for (i = 0; i < stream_configs->num_configs; ++i) {
+		if (stream_configs->configs[i].pad == pad &&
+		    stream_configs->configs[i].stream == stream)
+			return stream_configs->configs[i].vc;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_vc);
+
  int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
  					  u32 pad, u32 stream, u32 *other_pad,
  					  u32 *other_stream)
include/media/v4l2-subdev.h +39 -0
index c1f90c1223a7..ed1fdd79c2bb 100644
@@ -722,6 +722,7 @@ struct v4l2_subdev_stream_config {
  	u32 stream;
  	bool enabled;
 
+	u32 vc;
  	struct v4l2_mbus_framefmt fmt;
  	struct v4l2_rect crop;
  	struct v4l2_rect compose;
@@ -858,6 +859,12 @@ struct v4l2_subdev_pad_ops {
  	int (*set_fmt)(struct v4l2_subdev *sd,
  		       struct v4l2_subdev_state *state,
  		       struct v4l2_subdev_format *format);
+	int (*get_vc)(struct v4l2_subdev *sd,
+		      struct v4l2_subdev_state *state,
+		      struct v4l2_subdev_vc *vc);
+	int (*set_vc)(struct v4l2_subdev *sd,
+		      struct v4l2_subdev_state *state,
+		      struct v4l2_subdev_vc *vc);
  	int (*get_selection)(struct v4l2_subdev *sd,
  			     struct v4l2_subdev_state *state,
  			     struct v4l2_subdev_selection *sel);
@@ -1494,6 +1501,23 @@ v4l2_subdev_lock_and_get_active_state(struct v4l2_subdev *sd)
  int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
  			struct v4l2_subdev_format *format);
 
+/**
+ * v4l2_subdev_get_vc() - Fill virtual channel based on state
+ * @sd: subdevice
+ * @state: subdevice state
+ * @vc: pointer to &struct v4l2_subdev_vc
+ *
+ * Fill @vc->vc field based on the information in the @vc struct.
+ *
+ * This function can be used by the subdev drivers which support active state to
+ * implement v4l2_subdev_pad_ops.get_vc if the subdev driver does not need to
+ * do anything special in their get_vc op.
+ *
+ * Returns 0 on success, error value otherwise.
+ */
+int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
+		       struct v4l2_subdev_vc *vc);
+
  /**
   * v4l2_subdev_set_routing() - Set given routing to subdev state
   * @sd: The subdevice
@@ -1585,6 +1609,21 @@ struct v4l2_rect *
  v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
  				     unsigned int pad, u32 stream);
 
+/**
+ * v4l2_subdev_state_get_stream_vc() - Get the virtual channel of a stream
+ * @state: subdevice state
+ * @pad: pad id
+ * @stream: stream id
+ *
+ * This returns the virtual channel for the given pad + stream in the
+ * subdev state.
+ *
+ * If the state does not contain the given pad + stream, 0 is returned.
+ */
+u32
+v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+				unsigned int pad, u32 stream);
+
  /**
   * v4l2_subdev_routing_find_opposite_end() - Find the opposite stream
   * @routing: routing used to find the opposite side
include/uapi/linux/v4l2-subdev.h +18 -0
index b383c2fe0cf3..8e90405bb1e6 100644
@@ -187,6 +187,22 @@ struct v4l2_subdev_capability {
  	__u32 reserved[14];
  };
 
+/**
+ * struct v4l2_subdev_vc - Pad-level virtual channel settings
+ * @which: format type (from enum v4l2_subdev_format_whence)
+ * @pad: pad number, as reported by the media API
+ * @vc: virtual channel
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
+ */
+struct v4l2_subdev_vc {
+	__u32 which;
+	__u32 pad;
+	__u32 vc;
+	__u32 stream;
+	__u32 reserved[7];
+};
+
  /* The v4l2 sub-device video device node is registered in read-only mode. */
  #define V4L2_SUBDEV_CAP_RO_SUBDEV		0x00000001
 
@@ -268,6 +284,8 @@ struct v4l2_subdev_client_capability {
  #define VIDIOC_SUBDEV_S_SELECTION		_IOWR('V', 62, struct v4l2_subdev_selection)
  #define VIDIOC_SUBDEV_G_ROUTING			_IOWR('V', 38, struct v4l2_subdev_routing)
  #define VIDIOC_SUBDEV_S_ROUTING			_IOWR('V', 39, struct v4l2_subdev_routing)
+#define VIDIOC_SUBDEV_G_VC			_IOWR('V', 40, struct v4l2_subdev_vc)
+#define VIDIOC_SUBDEV_S_VC			_IOWR('V', 41, struct v4l2_subdev_vc)
  #define VIDIOC_SUBDEV_G_CLIENT_CAP		_IOR('V',  101, struct v4l2_subdev_client_capability)
  #define VIDIOC_SUBDEV_S_CLIENT_CAP		_IOWR('V',  102, struct v4l2_subdev_client_capability)
 
#2 lore raw

Hi, Tomi.

The usecase for this is crossbar devices that allow for mapping virtual channel

ids dynamically.

The remapping happens based on VC and DT. DT can be determined based on

the pixel code, but VC has no way of being determined at runtime through

standard V4L2 APIs.

The alternative would be to hardcode them in device tree, which is not very

nice, and cannot account for all possible user configurations.

I'm aware that VC is a bus-specific feature, which is why this is an RFC.

Having a V4L2 implementation would solve a lot of devices having to

hardcode VCs.

Quoted 223 lines · Tomi Valkeinen

Hi!

Quoted 12 lines · Cosmin Tanislav

With experimental support for multiple streams per pad being added, the pieces are in place to support a virtual channel id per stream.

This is necessary because stream ids cannot be directly mapped to a virtual channel id, since the same virtual channel id can be assigned to multiple streams of data, each with a different data type.

To implement this, the following steps have been taken.

Add subdev ioctls for getting and setting the virtual channel for a specific pad and stream.

Quoted 7 lines

Add pad .get_vc() and .set_vc() ops.

Add the virtual channel to the stream config in V4L2 subdev central state.

Add a default .get_vc() implementation that retrieves the virtual channel from the central state, or, if that is not supported, default to virtual channel 0.

Why do you need this?

The design idea with streams was that the streams are not tied to CSI-2 streams (or to any specific HW). The CSI-2 virtual channels should be handled by the drivers internally, and they should not be visible to the userspace at all.

 Tomi

Quoted 193 lines

---
  drivers/media/v4l2-core/v4l2-subdev.c | 57 +++++++++++++++++++++++++++ include/media/v4l2-subdev.h           | 39 ++++++++++++++++++ include/uapi/linux/v4l2-subdev.h      | 18 +++++++++

  3 files changed, 114 insertions(+)
drivers/media/v4l2-core/v4l2-subdev.c +0 -0
index be86b906c985..8945bfd0fe12 100644
@@ -535,6 +535,9 @@ subdev_ioctl_get_state(struct v4l2_subdev *sd, struct v4l2_subdev_fh *subdev_fh,

      case VIDIOC_SUBDEV_S_ROUTING:
          which = ((struct v4l2_subdev_routing *)arg)->which; break;
+    case VIDIOC_SUBDEV_G_VC:
+    case VIDIOC_SUBDEV_S_VC:
+        which = ((struct v4l2_subdev_vc *)arg)->which; }
        return which == V4L2_SUBDEV_FORMAT_TRY ?

drivers/media/v4l2-core/v4l2-subdev.c +19 -0
@@ -969,6 +972,26 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
                       routing->which, &krouting);
       }
   +    case VIDIOC_SUBDEV_G_VC: {
+        struct v4l2_subdev_vc *vc = arg;
+
+        if (!client_supports_streams)
+            vc->stream = 0;
+
+        memset(vc->reserved, 0, sizeof(vc->reserved));
+        return v4l2_subdev_call(sd, pad, get_vc, state, vc);
+    }
+
+    case VIDIOC_SUBDEV_S_VC: {
+        struct v4l2_subdev_vc *vc = arg;
+
+        if (!client_supports_streams)
+            vc->stream = 0;
+
+        memset(vc->reserved, 0, sizeof(vc->reserved));
+        return v4l2_subdev_call(sd, pad, set_vc, state, vc);
+    }
+
       case VIDIOC_SUBDEV_G_CLIENT_CAP: {
           struct v4l2_subdev_client_capability *client_cap = arg;
   @@ -1602,6 +1625,20 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,

  }
  EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt);
  +int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, +               struct v4l2_subdev_vc *vc)

drivers/media/v4l2-core/v4l2-subdev.c +12 -0
+{
+    u32 vc_id = 0;
+
+    if (sd->flags & V4L2_SUBDEV_FL_STREAMS)
+        vc_id = v4l2_subdev_state_get_stream_vc(state, vc->pad, vc->stream);
+
+    vc->vc = vc_id;
+
+    return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_get_vc);
+

  int v4l2_subdev_set_routing(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, const struct v4l2_subdev_krouting *routing)

drivers/media/v4l2-core/v4l2-subdev.c +19 -0
@@ -1745,6 +1782,26 @@ v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
   }
   EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_compose);
   +u32 v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+                    unsigned int pad, u32 stream)
+{
+    struct v4l2_subdev_stream_configs *stream_configs;
+    unsigned int i;
+
+    lockdep_assert_held(state->lock);
+
+    stream_configs = &state->stream_configs;
+
+    for (i = 0; i < stream_configs->num_configs; ++i) {
+        if (stream_configs->configs[i].pad == pad &&
+            stream_configs->configs[i].stream == stream)
+            return stream_configs->configs[i].vc;
+    }
+
+    return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_vc);
+
   int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
                         u32 pad, u32 stream, u32 *other_pad,
                         u32 *other_stream)
include/media/v4l2-subdev.h +6 -0
index c1f90c1223a7..ed1fdd79c2bb 100644
@@ -722,6 +722,7 @@ struct v4l2_subdev_stream_config {
       u32 stream;
       bool enabled;
   +    u32 vc;
       struct v4l2_mbus_framefmt fmt;
       struct v4l2_rect crop;
       struct v4l2_rect compose;
@@ -858,6 +859,12 @@ struct v4l2_subdev_pad_ops {
       int (*set_fmt)(struct v4l2_subdev *sd,
                  struct v4l2_subdev_state *state,
                  struct v4l2_subdev_format *format);
+    int (*get_vc)(struct v4l2_subdev *sd,
+              struct v4l2_subdev_state *state,
+              struct v4l2_subdev_vc *vc);
+    int (*set_vc)(struct v4l2_subdev *sd,
+              struct v4l2_subdev_state *state,
+              struct v4l2_subdev_vc *vc);
       int (*get_selection)(struct v4l2_subdev *sd,
                    struct v4l2_subdev_state *state,
                    struct v4l2_subdev_selection *sel);
@@ -1494,6 +1501,23 @@ v4l2_subdev_lock_and_get_active_state(struct v4l2_subdev *sd)
   int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
               struct v4l2_subdev_format *format);

  +/**
+ * v4l2_subdev_get_vc() - Fill virtual channel based on state
+ * @sd: subdevice
+ * @state: subdevice state
+ * @vc: pointer to &struct v4l2_subdev_vc
+ *
+ * Fill @vc->vc field based on the information in the @vc struct.
+ *
+ * This function can be used by the subdev drivers which support active state to
+ * implement v4l2_subdev_pad_ops.get_vc if the subdev driver does not need to
+ * do anything special in their get_vc op.
+ *
+ * Returns 0 on success, error value otherwise.
+ */

include/media/v4l2-subdev.h +3 -0
+int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
+               struct v4l2_subdev_vc *vc);
+

  /**
   * v4l2_subdev_set_routing() - Set given routing to subdev state
   * @sd: The subdevice

include/media/v4l2-subdev.h +0 -0
@@ -1585,6 +1609,21 @@ struct v4l2_rect *
   v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
                        unsigned int pad, u32 stream);

  +/**
+ * v4l2_subdev_state_get_stream_vc() - Get the virtual channel of a stream
+ * @state: subdevice state
+ * @pad: pad id
+ * @stream: stream id
+ *
+ * This returns the virtual channel for the given pad + stream in the
+ * subdev state.
+ *
+ * If the state does not contain the given pad + stream, 0 is returned.
+ */

include/media/v4l2-subdev.h +4 -0
+u32
+v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+                unsigned int pad, u32 stream);
+

  /**
   * v4l2_subdev_routing_find_opposite_end() - Find the opposite stream
   * @routing: routing used to find the opposite side

include/uapi/linux/v4l2-subdev.h +0 -0
index b383c2fe0cf3..8e90405bb1e6 100644
@@ -187,6 +187,22 @@ struct v4l2_subdev_capability {
       __u32 reserved[14];
   };

  +/**
+ * struct v4l2_subdev_vc - Pad-level virtual channel settings
+ * @which: format type (from enum v4l2_subdev_format_whence)
+ * @pad: pad number, as reported by the media API
+ * @vc: virtual channel
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
+ */

include/uapi/linux/v4l2-subdev.h +8 -0
+struct v4l2_subdev_vc {
+    __u32 which;
+    __u32 pad;
+    __u32 vc;
+    __u32 stream;
+    __u32 reserved[7];
+};
+

  /* The v4l2 sub-device video device node is registered in read-only mode. */ #define V4L2_SUBDEV_CAP_RO_SUBDEV        0x00000001
  @@ -268,6 +284,8 @@ struct v4l2_subdev_client_capability {
  #define VIDIOC_SUBDEV_S_SELECTION        _IOWR('V', 62, struct v4l2_subdev_selection) #define VIDIOC_SUBDEV_G_ROUTING            _IOWR('V', 38, struct v4l2_subdev_routing) #define VIDIOC_SUBDEV_S_ROUTING            _IOWR('V', 39, struct v4l2_subdev_routing)

include/uapi/linux/v4l2-subdev.h +2 -0
+#define VIDIOC_SUBDEV_G_VC            _IOWR('V', 40, struct v4l2_subdev_vc)
+#define VIDIOC_SUBDEV_S_VC            _IOWR('V', 41, struct v4l2_subdev_vc)

  #define VIDIOC_SUBDEV_G_CLIENT_CAP        _IOR('V',  101, struct v4l2_subdev_client_capability) #define VIDIOC_SUBDEV_S_CLIENT_CAP        _IOWR('V',  102, struct v4l2_subdev_client_capability)

#3 lore raw

Hi,

Quoted 11 lines · Cosmin Tanislav

Hi, Tomi.

The usecase for this is crossbar devices that allow for mapping virtual channel

ids dynamically.

The remapping happens based on VC and DT. DT can be determined based on

the pixel code, but VC has no way of being determined at runtime through

standard V4L2 APIs.

The DT shouldn't be determined based on the pixel code. The DT, and the VC, should be queried from the source subdev using the get_frame_desc() subdev op.

So, in general, the streams API presents a logical view of the streams without a strict direct mapping to the hardware. When the streaming is started, the subdev drivers need to figure out the hardware details, and, specifically for the DT & VC of incoming streams, can ask details from the source subdevice using get_frame_desc().

Or if I misunderstand your case, can you provide a concrete example of the pipeline and the media tree in question to help the discussion.

Tomi

Quoted 236 lines

The alternative would be to hardcode them in device tree, which is not very

nice, and cannot account for all possible user configurations.

I'm aware that VC is a bus-specific feature, which is why this is an RFC.

Having a V4L2 implementation would solve a lot of devices having to

hardcode VCs.

Quoted 223 lines · Tomi Valkeinen

Hi!

Quoted 12 lines · Cosmin Tanislav

With experimental support for multiple streams per pad being added, the pieces are in place to support a virtual channel id per stream.

This is necessary because stream ids cannot be directly mapped to a virtual channel id, since the same virtual channel id can be assigned to multiple streams of data, each with a different data type.

To implement this, the following steps have been taken.

Add subdev ioctls for getting and setting the virtual channel for a specific pad and stream.

Quoted 7 lines

Add pad .get_vc() and .set_vc() ops.

Add the virtual channel to the stream config in V4L2 subdev central state.

Add a default .get_vc() implementation that retrieves the virtual channel from the central state, or, if that is not supported, default to virtual channel 0.

Why do you need this?

The design idea with streams was that the streams are not tied to CSI-2 streams (or to any specific HW). The CSI-2 virtual channels should be handled by the drivers internally, and they should not be visible to the userspace at all.

 Tomi

Quoted 193 lines
---
   drivers/media/v4l2-core/v4l2-subdev.c | 57 +++++++++++++++++++++++++++
   include/media/v4l2-subdev.h           | 39 ++++++++++++++++++
   include/uapi/linux/v4l2-subdev.h      | 18 +++++++++
   3 files changed, 114 insertions(+)
drivers/media/v4l2-core/v4l2-subdev.c +54 -0
index be86b906c985..8945bfd0fe12 100644
@@ -535,6 +535,9 @@ subdev_ioctl_get_state(struct v4l2_subdev *sd, struct v4l2_subdev_fh *subdev_fh,
       case VIDIOC_SUBDEV_S_ROUTING:
           which = ((struct v4l2_subdev_routing *)arg)->which;
           break;
+    case VIDIOC_SUBDEV_G_VC:
+    case VIDIOC_SUBDEV_S_VC:
+        which = ((struct v4l2_subdev_vc *)arg)->which;
       }
         return which == V4L2_SUBDEV_FORMAT_TRY ?
@@ -969,6 +972,26 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
                       routing->which, &krouting);
       }
   +    case VIDIOC_SUBDEV_G_VC: {
+        struct v4l2_subdev_vc *vc = arg;
+
+        if (!client_supports_streams)
+            vc->stream = 0;
+
+        memset(vc->reserved, 0, sizeof(vc->reserved));
+        return v4l2_subdev_call(sd, pad, get_vc, state, vc);
+    }
+
+    case VIDIOC_SUBDEV_S_VC: {
+        struct v4l2_subdev_vc *vc = arg;
+
+        if (!client_supports_streams)
+            vc->stream = 0;
+
+        memset(vc->reserved, 0, sizeof(vc->reserved));
+        return v4l2_subdev_call(sd, pad, set_vc, state, vc);
+    }
+
       case VIDIOC_SUBDEV_G_CLIENT_CAP: {
           struct v4l2_subdev_client_capability *client_cap = arg;
   @@ -1602,6 +1625,20 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
   }
   EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt);
   +int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
+               struct v4l2_subdev_vc *vc)
+{
+    u32 vc_id = 0;
+
+    if (sd->flags & V4L2_SUBDEV_FL_STREAMS)
+        vc_id = v4l2_subdev_state_get_stream_vc(state, vc->pad, vc->stream);
+
+    vc->vc = vc_id;
+
+    return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_get_vc);
+
   int v4l2_subdev_set_routing(struct v4l2_subdev *sd,
                   struct v4l2_subdev_state *state,
                   const struct v4l2_subdev_krouting *routing)
@@ -1745,6 +1782,26 @@ v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
   }
   EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_compose);
   +u32 v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+                    unsigned int pad, u32 stream)
+{
+    struct v4l2_subdev_stream_configs *stream_configs;
+    unsigned int i;
+
+    lockdep_assert_held(state->lock);
+
+    stream_configs = &state->stream_configs;
+
+    for (i = 0; i < stream_configs->num_configs; ++i) {
+        if (stream_configs->configs[i].pad == pad &&
+            stream_configs->configs[i].stream == stream)
+            return stream_configs->configs[i].vc;
+    }
+
+    return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_vc);
+
   int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
                         u32 pad, u32 stream, u32 *other_pad,
                         u32 *other_stream)
include/media/v4l2-subdev.h +36 -0
index c1f90c1223a7..ed1fdd79c2bb 100644
@@ -722,6 +722,7 @@ struct v4l2_subdev_stream_config {
       u32 stream;
       bool enabled;
   +    u32 vc;
       struct v4l2_mbus_framefmt fmt;
       struct v4l2_rect crop;
       struct v4l2_rect compose;
@@ -858,6 +859,12 @@ struct v4l2_subdev_pad_ops {
       int (*set_fmt)(struct v4l2_subdev *sd,
                  struct v4l2_subdev_state *state,
                  struct v4l2_subdev_format *format);
+    int (*get_vc)(struct v4l2_subdev *sd,
+              struct v4l2_subdev_state *state,
+              struct v4l2_subdev_vc *vc);
+    int (*set_vc)(struct v4l2_subdev *sd,
+              struct v4l2_subdev_state *state,
+              struct v4l2_subdev_vc *vc);
       int (*get_selection)(struct v4l2_subdev *sd,
                    struct v4l2_subdev_state *state,
                    struct v4l2_subdev_selection *sel);
@@ -1494,6 +1501,23 @@ v4l2_subdev_lock_and_get_active_state(struct v4l2_subdev *sd)
   int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
               struct v4l2_subdev_format *format);
   +/**
+ * v4l2_subdev_get_vc() - Fill virtual channel based on state
+ * @sd: subdevice
+ * @state: subdevice state
+ * @vc: pointer to &struct v4l2_subdev_vc
+ *
+ * Fill @vc->vc field based on the information in the @vc struct.
+ *
+ * This function can be used by the subdev drivers which support active state to
+ * implement v4l2_subdev_pad_ops.get_vc if the subdev driver does not need to
+ * do anything special in their get_vc op.
+ *
+ * Returns 0 on success, error value otherwise.
+ */
+int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
+               struct v4l2_subdev_vc *vc);
+
   /**
    * v4l2_subdev_set_routing() - Set given routing to subdev state
    * @sd: The subdevice
@@ -1585,6 +1609,21 @@ struct v4l2_rect *
   v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
                        unsigned int pad, u32 stream);
   +/**
+ * v4l2_subdev_state_get_stream_vc() - Get the virtual channel of a stream
+ * @state: subdevice state
+ * @pad: pad id
+ * @stream: stream id
+ *
+ * This returns the virtual channel for the given pad + stream in the
+ * subdev state.
+ *
+ * If the state does not contain the given pad + stream, 0 is returned.
+ */
+u32
+v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+                unsigned int pad, u32 stream);
+
   /**
    * v4l2_subdev_routing_find_opposite_end() - Find the opposite stream
    * @routing: routing used to find the opposite side
include/uapi/linux/v4l2-subdev.h +17 -0
index b383c2fe0cf3..8e90405bb1e6 100644
@@ -187,6 +187,22 @@ struct v4l2_subdev_capability {
       __u32 reserved[14];
   };
   +/**
+ * struct v4l2_subdev_vc - Pad-level virtual channel settings
+ * @which: format type (from enum v4l2_subdev_format_whence)
+ * @pad: pad number, as reported by the media API
+ * @vc: virtual channel
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
+ */
+struct v4l2_subdev_vc {
+    __u32 which;
+    __u32 pad;
+    __u32 vc;
+    __u32 stream;
+    __u32 reserved[7];
+};
+
   /* The v4l2 sub-device video device node is registered in read-only mode. */
   #define V4L2_SUBDEV_CAP_RO_SUBDEV        0x00000001
   @@ -268,6 +284,8 @@ struct v4l2_subdev_client_capability {
   #define VIDIOC_SUBDEV_S_SELECTION        _IOWR('V', 62, struct v4l2_subdev_selection)
   #define VIDIOC_SUBDEV_G_ROUTING            _IOWR('V', 38, struct v4l2_subdev_routing)
   #define VIDIOC_SUBDEV_S_ROUTING            _IOWR('V', 39, struct v4l2_subdev_routing)
+#define VIDIOC_SUBDEV_G_VC            _IOWR('V', 40, struct v4l2_subdev_vc)
+#define VIDIOC_SUBDEV_S_VC            _IOWR('V', 41, struct v4l2_subdev_vc)
   #define VIDIOC_SUBDEV_G_CLIENT_CAP        _IOR('V',  101, struct v4l2_subdev_client_capability)
   #define VIDIOC_SUBDEV_S_CLIENT_CAP        _IOWR('V',  102, struct v4l2_subdev_client_capability)
#4 lore raw
Quoted 15 lines · Tomi Valkeinen

Hi,

Quoted 11 lines · Cosmin Tanislav

Hi, Tomi.

The usecase for this is crossbar devices that allow for mapping virtual channel

ids dynamically.

The remapping happens based on VC and DT. DT can be determined based on

the pixel code, but VC has no way of being determined at runtime through

standard V4L2 APIs.

Quoted 7 lines

The DT shouldn't be determined based on the pixel code. The DT, and the VC, should be queried from the source subdev using the get_frame_desc() subdev op.

So, in general, the streams API presents a logical view of the streams without a strict direct mapping to the hardware. When the streaming is started, the subdev drivers need to figure out the hardware details, and, specifically for the DT & VC of incoming streams, can ask details from the source subdevice using get_frame_desc().

Or if I misunderstand your case, can you provide a concrete example of the pipeline and the media tree in question to help the discussion.

 Tomi

---------------------------------------------------------------------------

I've attached the result of media-ctl --print-dot. I'm not sure if this is visible in the mailing list.

There are 4 cameras attached to 4 serializers, which connect to 4 ports of a single deserializer.

I've split each device into multiple subdevs and introduced crossbar devices which can have their routing table changed.
This mostly matches the hardware blocks available within the chip.

The connection between cameras and serializer PHYs, and between serializer links and deserializer links are specified in device tree using the standard graph API.

In each serializer, the phy_pipe_xbar subdev allows mapping the output of each PHY to a pipe, allowing stream duplication. One serializer can have multiple PHYs, although this is not pictured here.
The pipe_link_xbar subdev allows mapping the output of each pipe to a hardware stream of the link. This mapping is 1:1. One serializer can have multiple pipes, as pictured here for serializer 0 and serializer 1.

On the deserializer side, the link_pipe_xbar subdev allows selecting which link maps to which pipe. Some deserializer chips don't support automatic link hardware stream detection, in which case each deserializer link will have a source port for each hardware stream, and the link_pipe_xbar will have a source port for each hardware stream of each link too. This subdev also allows stream duplication by having multiple pipes receive data from the same link + hardware stream. It also allows multiple pipes to receive data from the same link but different hardware streams.

Further down there's a pipe_phy_xbar subdev. This is the one where this patch is necessary. It allows remapping the DT and VC of all incoming data streams to new values. This is useful because we might have a downstream device that is able to multiplex the incoming data streams into separate video devices based on VC, allowing us to connect multiple cameras over the same CSI interface, but having them show up as multiple video devices.

I know this is a very complicated pipeline, but doing all this logic automatically and correctly is very hard, while configuring it manually is pretty easy, which is why we would like to expose all these configurations to the user, which is able to take better decisions based on their usecase.

Quoted 238 lines
Quoted 237 lines

The alternative would be to hardcode them in device tree, which is not very

nice, and cannot account for all possible user configurations.

I'm aware that VC is a bus-specific feature, which is why this is an RFC.

Having a V4L2 implementation would solve a lot of devices having to

hardcode VCs.

Quoted 223 lines · Tomi Valkeinen

Hi!

Quoted 12 lines · Cosmin Tanislav

With experimental support for multiple streams per pad being added, the pieces are in place to support a virtual channel id per stream.

This is necessary because stream ids cannot be directly mapped to a virtual channel id, since the same virtual channel id can be assigned to multiple streams of data, each with a different data type.

To implement this, the following steps have been taken.

Add subdev ioctls for getting and setting the virtual channel for a specific pad and stream.

Quoted 7 lines

Add pad .get_vc() and .set_vc() ops.

Add the virtual channel to the stream config in V4L2 subdev central state.

Add a default .get_vc() implementation that retrieves the virtual channel from the central state, or, if that is not supported, default to virtual channel 0.

Why do you need this?

The design idea with streams was that the streams are not tied to CSI-2 streams (or to any specific HW). The CSI-2 virtual channels should be handled by the drivers internally, and they should not be visible to the userspace at all.

  Tomi

Quoted 193 lines

---
   drivers/media/v4l2-core/v4l2-subdev.c | 57 +++++++++++++++++++++++++++ include/media/v4l2-subdev.h           | 39 ++++++++++++++++++ include/uapi/linux/v4l2-subdev.h      | 18 +++++++++

   3 files changed, 114 insertions(+)
drivers/media/v4l2-core/v4l2-subdev.c +0 -0
index be86b906c985..8945bfd0fe12 100644
@@ -535,6 +535,9 @@ subdev_ioctl_get_state(struct v4l2_subdev *sd, struct v4l2_subdev_fh *subdev_fh,

       case VIDIOC_SUBDEV_S_ROUTING:
           which = ((struct v4l2_subdev_routing *)arg)->which; break;
+    case VIDIOC_SUBDEV_G_VC:
+    case VIDIOC_SUBDEV_S_VC:
+        which = ((struct v4l2_subdev_vc *)arg)->which; }
         return which == V4L2_SUBDEV_FORMAT_TRY ?

drivers/media/v4l2-core/v4l2-subdev.c +19 -0
@@ -969,6 +972,26 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
                        routing->which, &krouting);
        }
    +    case VIDIOC_SUBDEV_G_VC: {
+        struct v4l2_subdev_vc *vc = arg;
+
+        if (!client_supports_streams)
+            vc->stream = 0;
+
+        memset(vc->reserved, 0, sizeof(vc->reserved));
+        return v4l2_subdev_call(sd, pad, get_vc, state, vc);
+    }
+
+    case VIDIOC_SUBDEV_S_VC: {
+        struct v4l2_subdev_vc *vc = arg;
+
+        if (!client_supports_streams)
+            vc->stream = 0;
+
+        memset(vc->reserved, 0, sizeof(vc->reserved));
+        return v4l2_subdev_call(sd, pad, set_vc, state, vc);
+    }
+
        case VIDIOC_SUBDEV_G_CLIENT_CAP: {
            struct v4l2_subdev_client_capability *client_cap = arg;
    @@ -1602,6 +1625,20 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,

   }
   EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt);
   +int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, +               struct v4l2_subdev_vc *vc)

drivers/media/v4l2-core/v4l2-subdev.c +12 -0
+{
+    u32 vc_id = 0;
+
+    if (sd->flags & V4L2_SUBDEV_FL_STREAMS)
+        vc_id = v4l2_subdev_state_get_stream_vc(state, vc->pad, vc->stream);
+
+    vc->vc = vc_id;
+
+    return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_get_vc);
+

   int v4l2_subdev_set_routing(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, const struct v4l2_subdev_krouting *routing)

drivers/media/v4l2-core/v4l2-subdev.c +19 -0
@@ -1745,6 +1782,26 @@ v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
    }
    EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_compose);
    +u32 v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+                    unsigned int pad, u32 stream)
+{
+    struct v4l2_subdev_stream_configs *stream_configs;
+    unsigned int i;
+
+    lockdep_assert_held(state->lock);
+
+    stream_configs = &state->stream_configs;
+
+    for (i = 0; i < stream_configs->num_configs; ++i) {
+        if (stream_configs->configs[i].pad == pad &&
+            stream_configs->configs[i].stream == stream)
+            return stream_configs->configs[i].vc;
+    }
+
+    return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_vc);
+
    int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
                          u32 pad, u32 stream, u32 *other_pad,
                          u32 *other_stream)
include/media/v4l2-subdev.h +6 -0
index c1f90c1223a7..ed1fdd79c2bb 100644
@@ -722,6 +722,7 @@ struct v4l2_subdev_stream_config {
        u32 stream;
        bool enabled;
    +    u32 vc;
        struct v4l2_mbus_framefmt fmt;
        struct v4l2_rect crop;
        struct v4l2_rect compose;
@@ -858,6 +859,12 @@ struct v4l2_subdev_pad_ops {
        int (*set_fmt)(struct v4l2_subdev *sd,
                   struct v4l2_subdev_state *state,
                   struct v4l2_subdev_format *format);
+    int (*get_vc)(struct v4l2_subdev *sd,
+              struct v4l2_subdev_state *state,
+              struct v4l2_subdev_vc *vc);
+    int (*set_vc)(struct v4l2_subdev *sd,
+              struct v4l2_subdev_state *state,
+              struct v4l2_subdev_vc *vc);
        int (*get_selection)(struct v4l2_subdev *sd,
                     struct v4l2_subdev_state *state,
                     struct v4l2_subdev_selection *sel);
@@ -1494,6 +1501,23 @@ v4l2_subdev_lock_and_get_active_state(struct v4l2_subdev *sd)
    int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
                struct v4l2_subdev_format *format);

   +/**
+ * v4l2_subdev_get_vc() - Fill virtual channel based on state
+ * @sd: subdevice
+ * @state: subdevice state
+ * @vc: pointer to &struct v4l2_subdev_vc
+ *
+ * Fill @vc->vc field based on the information in the @vc struct.
+ *
+ * This function can be used by the subdev drivers which support active state to
+ * implement v4l2_subdev_pad_ops.get_vc if the subdev driver does not need to
+ * do anything special in their get_vc op.
+ *
+ * Returns 0 on success, error value otherwise.
+ */

include/media/v4l2-subdev.h +3 -0
+int v4l2_subdev_get_vc(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
+               struct v4l2_subdev_vc *vc);
+

   /**
    * v4l2_subdev_set_routing() - Set given routing to subdev state
    * @sd: The subdevice

include/media/v4l2-subdev.h +0 -0
@@ -1585,6 +1609,21 @@ struct v4l2_rect *
    v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
                         unsigned int pad, u32 stream);

   +/**
+ * v4l2_subdev_state_get_stream_vc() - Get the virtual channel of a stream
+ * @state: subdevice state
+ * @pad: pad id
+ * @stream: stream id
+ *
+ * This returns the virtual channel for the given pad + stream in the
+ * subdev state.
+ *
+ * If the state does not contain the given pad + stream, 0 is returned.
+ */

include/media/v4l2-subdev.h +4 -0
+u32
+v4l2_subdev_state_get_stream_vc(struct v4l2_subdev_state *state,
+                unsigned int pad, u32 stream);
+

   /**
    * v4l2_subdev_routing_find_opposite_end() - Find the opposite stream
    * @routing: routing used to find the opposite side

include/uapi/linux/v4l2-subdev.h +0 -0
index b383c2fe0cf3..8e90405bb1e6 100644
@@ -187,6 +187,22 @@ struct v4l2_subdev_capability {
        __u32 reserved[14];
    };

   +/**
+ * struct v4l2_subdev_vc - Pad-level virtual channel settings
+ * @which: format type (from enum v4l2_subdev_format_whence)
+ * @pad: pad number, as reported by the media API
+ * @vc: virtual channel
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
+ */

include/uapi/linux/v4l2-subdev.h +8 -0
+struct v4l2_subdev_vc {
+    __u32 which;
+    __u32 pad;
+    __u32 vc;
+    __u32 stream;
+    __u32 reserved[7];
+};
+

   /* The v4l2 sub-device video device node is registered in read-only mode. */ #define V4L2_SUBDEV_CAP_RO_SUBDEV        0x00000001
   @@ -268,6 +284,8 @@ struct v4l2_subdev_client_capability {
   #define VIDIOC_SUBDEV_S_SELECTION        _IOWR('V', 62, struct v4l2_subdev_selection) #define VIDIOC_SUBDEV_G_ROUTING            _IOWR('V', 38, struct v4l2_subdev_routing) #define VIDIOC_SUBDEV_S_ROUTING            _IOWR('V', 39, struct v4l2_subdev_routing)

include/uapi/linux/v4l2-subdev.h +2 -0
+#define VIDIOC_SUBDEV_G_VC            _IOWR('V', 40, struct v4l2_subdev_vc)
+#define VIDIOC_SUBDEV_S_VC            _IOWR('V', 41, struct v4l2_subdev_vc)

   #define VIDIOC_SUBDEV_G_CLIENT_CAP        _IOR('V',  101, struct v4l2_subdev_client_capability) #define VIDIOC_SUBDEV_S_CLIENT_CAP        _IOWR('V',  102, struct v4l2_subdev_client_capability)

#5 lore raw
In reply to Cosmin Tanislav
kernel test robot noticed the following build warnings:

Hi Cosmin,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:

[auto build test WARNING on v6.7]
[cannot apply to media-tree/master linuxtv-media-stage/master sailus-media-tree/streams linus/master next-20240112] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Cosmin-Tanislav/media-v4l-implement-virtual-channels/20240110-204915
base:   v6.7
patch link:    https://lore.kernel.org/r/20240110125103.215267-1-demonsingur%40gmail.com
patch subject: [RFC PATCH] media: v4l: implement virtual channels
reproduce: (https://download.01.org/0day-ci/archive/20240114/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> ./include/media/v4l2-subdev.h:729: warning: Function parameter or member 'vc' not described in 'v4l2_subdev_stream_config'
>> ./include/media/v4l2-subdev.h:901: warning: Function parameter or member 'get_vc' not described in 'v4l2_subdev_pad_ops'
>> ./include/media/v4l2-subdev.h:901: warning: Function parameter or member 'set_vc' not described in 'v4l2_subdev_pad_ops'

vim +729 ./include/media/v4l2-subdev.h

f7234138f14c22 Hans Verkuil          2015-03-04  707  
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  708  /**
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  709   * struct v4l2_subdev_stream_config - Used for storing stream configuration.
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  710   *
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  711   * @pad: pad number
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  712   * @stream: stream number
d0749adb30706f Laurent Pinchart      2021-12-13  713   * @enabled: has the stream been enabled with v4l2_subdev_enable_stream()
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  714   * @fmt: &struct v4l2_mbus_framefmt
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  715   * @crop: &struct v4l2_rect to be used for crop
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  716   * @compose: &struct v4l2_rect to be used for compose
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  717   *
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  718   * This structure stores configuration for a stream.
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  719   */
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  720  struct v4l2_subdev_stream_config {
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  721  	u32 pad;
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  722  	u32 stream;
d0749adb30706f Laurent Pinchart      2021-12-13  723  	bool enabled;
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  724  
c6b46aa829653e Cosmin Tanislav       2024-01-10  725  	u32 vc;
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  726  	struct v4l2_mbus_framefmt fmt;
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  727  	struct v4l2_rect crop;
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  728  	struct v4l2_rect compose;
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21 @729  };
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  730  
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  731  /**
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  732   * struct v4l2_subdev_stream_configs - A collection of stream configs.
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  733   *
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  734   * @num_configs: number of entries in @config.
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  735   * @configs: an array of &struct v4l2_subdev_stream_configs.
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  736   */
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  737  struct v4l2_subdev_stream_configs {
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  738  	u32 num_configs;
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  739  	struct v4l2_subdev_stream_config *configs;
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  740  };
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  741  
a418bb3f30d9ac Laurent Pinchart      2021-04-23  742  /**
a418bb3f30d9ac Laurent Pinchart      2021-04-23  743   * struct v4l2_subdev_krouting - subdev routing table
a418bb3f30d9ac Laurent Pinchart      2021-04-23  744   *
a418bb3f30d9ac Laurent Pinchart      2021-04-23  745   * @num_routes: number of routes
a418bb3f30d9ac Laurent Pinchart      2021-04-23  746   * @routes: &struct v4l2_subdev_route
a418bb3f30d9ac Laurent Pinchart      2021-04-23  747   *
a418bb3f30d9ac Laurent Pinchart      2021-04-23  748   * This structure contains the routing table for a subdev.
a418bb3f30d9ac Laurent Pinchart      2021-04-23  749   */
a418bb3f30d9ac Laurent Pinchart      2021-04-23  750  struct v4l2_subdev_krouting {
a418bb3f30d9ac Laurent Pinchart      2021-04-23  751  	unsigned int num_routes;
a418bb3f30d9ac Laurent Pinchart      2021-04-23  752  	struct v4l2_subdev_route *routes;
a418bb3f30d9ac Laurent Pinchart      2021-04-23  753  };
a418bb3f30d9ac Laurent Pinchart      2021-04-23  754  
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  755  /**
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  756   * struct v4l2_subdev_state - Used for storing subdev state information.
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  757   *
ed647ea668fb27 Tomi Valkeinen        2022-04-12  758   * @_lock: default for 'lock'
ed647ea668fb27 Tomi Valkeinen        2022-04-12  759   * @lock: mutex for the state. May be replaced by the user.
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  760   * @pads: &struct v4l2_subdev_pad_config array
a418bb3f30d9ac Laurent Pinchart      2021-04-23  761   * @routing: routing table for the subdev
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  762   * @stream_configs: stream configurations (only for V4L2_SUBDEV_FL_STREAMS)
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  763   *
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  764   * This structure only needs to be passed to the pad op if the 'which' field
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  765   * of the main argument is set to %V4L2_SUBDEV_FORMAT_TRY. For
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  766   * %V4L2_SUBDEV_FORMAT_ACTIVE it is safe to pass %NULL.
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  767   */
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  768  struct v4l2_subdev_state {
ed647ea668fb27 Tomi Valkeinen        2022-04-12  769  	/* lock for the struct v4l2_subdev_state fields */
ed647ea668fb27 Tomi Valkeinen        2022-04-12  770  	struct mutex _lock;
ed647ea668fb27 Tomi Valkeinen        2022-04-12  771  	struct mutex *lock;
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  772  	struct v4l2_subdev_pad_config *pads;
a418bb3f30d9ac Laurent Pinchart      2021-04-23  773  	struct v4l2_subdev_krouting routing;
2f91e10ee6fd4c Tomi Valkeinen        2021-12-21  774  	struct v4l2_subdev_stream_configs stream_configs;
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  775  };
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  776  
291031192426bf Sylwester Nawrocki    2012-05-17  777  /**
291031192426bf Sylwester Nawrocki    2012-05-17  778   * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  779   *
9b02cbb3ede89b Laurent Pinchart      2015-04-24  780   * @init_cfg: initialize the pad config to default values
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  781   * @enum_mbus_code: callback for VIDIOC_SUBDEV_ENUM_MBUS_CODE() ioctl handler
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  782   *		    code.
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  783   * @enum_frame_size: callback for VIDIOC_SUBDEV_ENUM_FRAME_SIZE() ioctl handler
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  784   *		     code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  785   *
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  786   * @enum_frame_interval: callback for VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL() ioctl
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  787   *			 handler code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  788   *
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  789   * @get_fmt: callback for VIDIOC_SUBDEV_G_FMT() ioctl handler code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  790   *
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  791   * @set_fmt: callback for VIDIOC_SUBDEV_S_FMT() ioctl handler code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  792   *
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  793   * @get_selection: callback for VIDIOC_SUBDEV_G_SELECTION() ioctl handler code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  794   *
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  795   * @set_selection: callback for VIDIOC_SUBDEV_S_SELECTION() ioctl handler code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  796   *
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  797   * @get_edid: callback for VIDIOC_SUBDEV_G_EDID() ioctl handler code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  798   *
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  799   * @set_edid: callback for VIDIOC_SUBDEV_S_EDID() ioctl handler code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  800   *
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  801   * @dv_timings_cap: callback for VIDIOC_SUBDEV_DV_TIMINGS_CAP() ioctl handler
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  802   *		    code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  803   *
3fb558f6c3bbcc Mauro Carvalho Chehab 2017-10-05  804   * @enum_dv_timings: callback for VIDIOC_SUBDEV_ENUM_DV_TIMINGS() ioctl handler
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  805   *		     code.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  806   *
1d8955b2c3fa47 Mauro Carvalho Chehab 2015-08-22  807   * @link_validate: used by the media controller code to check if the links
1d8955b2c3fa47 Mauro Carvalho Chehab 2015-08-22  808   *		   that belongs to a pipeline can be used for stream.
1d8955b2c3fa47 Mauro Carvalho Chehab 2015-08-22  809   *
291031192426bf Sylwester Nawrocki    2012-05-17  810   * @get_frame_desc: get the current low level media bus frame parameters.
e44cc20a1d0952 Mauro Carvalho Chehab 2015-08-22  811   *
1d8955b2c3fa47 Mauro Carvalho Chehab 2015-08-22  812   * @set_frame_desc: set the low level media bus frame parameters, @fd array
291031192426bf Sylwester Nawrocki    2012-05-17  813   *                  may be adjusted by the subdev driver to device capabilities.
38df0b8506130c Jacopo Mondi          2020-07-17  814   *
38df0b8506130c Jacopo Mondi          2020-07-17  815   * @get_mbus_config: get the media bus configuration of a remote sub-device.
38df0b8506130c Jacopo Mondi          2020-07-17  816   *		     The media bus configuration is usually retrieved from the
38df0b8506130c Jacopo Mondi          2020-07-17  817   *		     firmware interface at sub-device probe time, immediately
38df0b8506130c Jacopo Mondi          2020-07-17  818   *		     applied to the hardware and eventually adjusted by the
38df0b8506130c Jacopo Mondi          2020-07-17  819   *		     driver. Remote sub-devices (usually video receivers) shall
38df0b8506130c Jacopo Mondi          2020-07-17  820   *		     use this operation to query the transmitting end bus
38df0b8506130c Jacopo Mondi          2020-07-17  821   *		     configuration in order to adjust their own one accordingly.
38df0b8506130c Jacopo Mondi          2020-07-17  822   *		     Callers should make sure they get the most up-to-date as
38df0b8506130c Jacopo Mondi          2020-07-17  823   *		     possible configuration from the remote end, likely calling
38df0b8506130c Jacopo Mondi          2020-07-17  824   *		     this operation as close as possible to stream on time. The
38df0b8506130c Jacopo Mondi          2020-07-17  825   *		     operation shall fail if the pad index it has been called on
38df0b8506130c Jacopo Mondi          2020-07-17  826   *		     is not valid or in case of unrecoverable failures.
a418bb3f30d9ac Laurent Pinchart      2021-04-23  827   *
da7e34e558a522 Laurent Pinchart      2023-08-18  828   * @set_routing: Enable or disable data connection routes described in the
da7e34e558a522 Laurent Pinchart      2023-08-18  829   *		 subdevice routing table. Subdevs that implement this operation
da7e34e558a522 Laurent Pinchart      2023-08-18  830   *		 must set the V4L2_SUBDEV_FL_STREAMS flag.
d0749adb30706f Laurent Pinchart      2021-12-13  831   *
d0749adb30706f Laurent Pinchart      2021-12-13  832   * @enable_streams: Enable the streams defined in streams_mask on the given
d0749adb30706f Laurent Pinchart      2021-12-13  833   *	source pad. Subdevs that implement this operation must use the active
d0749adb30706f Laurent Pinchart      2021-12-13  834   *	state management provided by the subdev core (enabled through a call to
d0749adb30706f Laurent Pinchart      2021-12-13  835   *	v4l2_subdev_init_finalize() at initialization time). Do not call
d0749adb30706f Laurent Pinchart      2021-12-13  836   *	directly, use v4l2_subdev_enable_streams() instead.
d0749adb30706f Laurent Pinchart      2021-12-13  837   *
d0749adb30706f Laurent Pinchart      2021-12-13  838   * @disable_streams: Disable the streams defined in streams_mask on the given
d0749adb30706f Laurent Pinchart      2021-12-13  839   *	source pad. Subdevs that implement this operation must use the active
d0749adb30706f Laurent Pinchart      2021-12-13  840   *	state management provided by the subdev core (enabled through a call to
d0749adb30706f Laurent Pinchart      2021-12-13  841   *	v4l2_subdev_init_finalize() at initialization time). Do not call
d0749adb30706f Laurent Pinchart      2021-12-13  842   *	directly, use v4l2_subdev_disable_streams() instead.
291031192426bf Sylwester Nawrocki    2012-05-17  843   */
eb08f35480869f Laurent Pinchart      2009-12-09  844  struct v4l2_subdev_pad_ops {
9b02cbb3ede89b Laurent Pinchart      2015-04-24  845  	int (*init_cfg)(struct v4l2_subdev *sd,
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  846  			struct v4l2_subdev_state *state);
f7234138f14c22 Hans Verkuil          2015-03-04  847  	int (*enum_mbus_code)(struct v4l2_subdev *sd,
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  848  			      struct v4l2_subdev_state *state,
333c8b97785d5a Laurent Pinchart      2010-03-15  849  			      struct v4l2_subdev_mbus_code_enum *code);
333c8b97785d5a Laurent Pinchart      2010-03-15  850  	int (*enum_frame_size)(struct v4l2_subdev *sd,
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  851  			       struct v4l2_subdev_state *state,
333c8b97785d5a Laurent Pinchart      2010-03-15  852  			       struct v4l2_subdev_frame_size_enum *fse);
35c3017a29d278 Laurent Pinchart      2010-05-05  853  	int (*enum_frame_interval)(struct v4l2_subdev *sd,
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  854  				   struct v4l2_subdev_state *state,
35c3017a29d278 Laurent Pinchart      2010-05-05  855  				   struct v4l2_subdev_frame_interval_enum *fie);
f7234138f14c22 Hans Verkuil          2015-03-04  856  	int (*get_fmt)(struct v4l2_subdev *sd,
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  857  		       struct v4l2_subdev_state *state,
333c8b97785d5a Laurent Pinchart      2010-03-15  858  		       struct v4l2_subdev_format *format);
f7234138f14c22 Hans Verkuil          2015-03-04  859  	int (*set_fmt)(struct v4l2_subdev *sd,
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  860  		       struct v4l2_subdev_state *state,
333c8b97785d5a Laurent Pinchart      2010-03-15  861  		       struct v4l2_subdev_format *format);
c6b46aa829653e Cosmin Tanislav       2024-01-10  862  	int (*get_vc)(struct v4l2_subdev *sd,
c6b46aa829653e Cosmin Tanislav       2024-01-10  863  		      struct v4l2_subdev_state *state,
c6b46aa829653e Cosmin Tanislav       2024-01-10  864  		      struct v4l2_subdev_vc *vc);
c6b46aa829653e Cosmin Tanislav       2024-01-10  865  	int (*set_vc)(struct v4l2_subdev *sd,
c6b46aa829653e Cosmin Tanislav       2024-01-10  866  		      struct v4l2_subdev_state *state,
c6b46aa829653e Cosmin Tanislav       2024-01-10  867  		      struct v4l2_subdev_vc *vc);
f7234138f14c22 Hans Verkuil          2015-03-04  868  	int (*get_selection)(struct v4l2_subdev *sd,
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  869  			     struct v4l2_subdev_state *state,
ae184cda8d0eeb Sakari Ailus          2011-10-14  870  			     struct v4l2_subdev_selection *sel);
f7234138f14c22 Hans Verkuil          2015-03-04  871  	int (*set_selection)(struct v4l2_subdev *sd,
0d346d2a6f54f0 Tomi Valkeinen        2021-06-10  872  			     struct v4l2_subdev_state *state,
ae184cda8d0eeb Sakari Ailus          2011-10-14  873  			     struct v4l2_subdev_selection *sel);
dd519bb34a09d8 Hans Verkuil          2014-03-07  874  	int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
dd519bb34a09d8 Hans Verkuil          2014-03-07  875  	int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
0349f6a5f18e92 Laurent Pinchart      2014-01-29  876  	int (*dv_timings_cap)(struct v4l2_subdev *sd,
0349f6a5f18e92 Laurent Pinchart      2014-01-29  877  			      struct v4l2_dv_timings_cap *cap);
0349f6a5f18e92 Laurent Pinchart      2014-01-29  878  	int (*enum_dv_timings)(struct v4l2_subdev *sd,
0349f6a5f18e92 Laurent Pinchart      2014-01-29  879  			       struct v4l2_enum_dv_timings *timings);
8227c92b696884 Sakari Ailus          2011-10-10  880  #ifdef CONFIG_MEDIA_CONTROLLER
8227c92b696884 Sakari Ailus          2011-10-10  881  	int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link,
8227c92b696884 Sakari Ailus          2011-10-10  882  			     struct v4l2_subdev_format *source_fmt,
8227c92b696884 Sakari Ailus          2011-10-10  883  			     struct v4l2_subdev_format *sink_fmt);
8227c92b696884 Sakari Ailus          2011-10-10  884  #endif /* CONFIG_MEDIA_CONTROLLER */
291031192426bf Sylwester Nawrocki    2012-05-17  885  	int (*get_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
291031192426bf Sylwester Nawrocki    2012-05-17  886  			      struct v4l2_mbus_frame_desc *fd);
291031192426bf Sylwester Nawrocki    2012-05-17  887  	int (*set_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
291031192426bf Sylwester Nawrocki    2012-05-17  888  			      struct v4l2_mbus_frame_desc *fd);
38df0b8506130c Jacopo Mondi          2020-07-17  889  	int (*get_mbus_config)(struct v4l2_subdev *sd, unsigned int pad,
38df0b8506130c Jacopo Mondi          2020-07-17  890  			       struct v4l2_mbus_config *config);
a418bb3f30d9ac Laurent Pinchart      2021-04-23  891  	int (*set_routing)(struct v4l2_subdev *sd,
a418bb3f30d9ac Laurent Pinchart      2021-04-23  892  			   struct v4l2_subdev_state *state,
a418bb3f30d9ac Laurent Pinchart      2021-04-23  893  			   enum v4l2_subdev_format_whence which,
a418bb3f30d9ac Laurent Pinchart      2021-04-23  894  			   struct v4l2_subdev_krouting *route);
d0749adb30706f Laurent Pinchart      2021-12-13  895  	int (*enable_streams)(struct v4l2_subdev *sd,
d0749adb30706f Laurent Pinchart      2021-12-13  896  			      struct v4l2_subdev_state *state, u32 pad,
d0749adb30706f Laurent Pinchart      2021-12-13  897  			      u64 streams_mask);
d0749adb30706f Laurent Pinchart      2021-12-13  898  	int (*disable_streams)(struct v4l2_subdev *sd,
d0749adb30706f Laurent Pinchart      2021-12-13  899  			       struct v4l2_subdev_state *state, u32 pad,
d0749adb30706f Laurent Pinchart      2021-12-13  900  			       u64 streams_mask);

eb08f35480869f Laurent Pinchart 2009-12-09 @901 };
eb08f35480869f Laurent Pinchart 2009-12-09 902

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki