@@ -94,9 +94,38 @@ static int video_mux_link_setup(struct media_entity *entity,
return ret;
}
+static int video_mux_get_fwnode_pad(struct media_entity *entity,
+ struct fwnode_endpoint *endpoint)
+{
+ struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
+ struct video_mux *vmux = v4l2_subdev_to_video_mux(sd);
+ struct fwnode_handle *vmux_fwnode = dev_fwnode(vmux->subdev.dev);
+ struct fwnode_handle *vmux_ep;
+
+ /*
+ * If the endpoint is one of ours, return the endpoint's port
+ * number. This device maps port numbers and pad indexes 1:1.
+ */
+ fwnode_graph_for_each_endpoint(vmux_fwnode, vmux_ep) {
+ if (endpoint->local_fwnode == vmux_ep) {
+ struct fwnode_endpoint fwep;
+ int ret;
+
+ ret = fwnode_graph_parse_endpoint(vmux_ep, &fwep);
+
+ fwnode_handle_put(vmux_ep);
+
+ return ret ? ret : fwep.port;
+ }
+ }
+
+ return -ENXIO;
+}
+
static const struct media_entity_operations video_mux_ops = {
.link_setup = video_mux_link_setup,
.link_validate = v4l2_subdev_link_validate,
+ .get_fwnode_pad = video_mux_get_fwnode_pad,
};
static int video_mux_s_stream(struct v4l2_subdev *sd, int enable)
Implement get_fwnode_pad operation. If the endpoint is owned by the video mux, return the endpoint's port number. The video mux maps fwnode port numbers and pad indexes 1:1. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> --- drivers/media/platform/video-mux.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)