[PATCH v3 05/17] media: video-mux: Implement get_fwnode_pad op
From: Steve Longerbeam
Date: Tue Feb 04 2020 - 18:49:47 EST
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@xxxxxxxxx>
---
drivers/media/platform/video-mux.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c
index 3d2a5c2b4c08..c1c477e4e33f 100644
--- a/drivers/media/platform/video-mux.c
+++ b/drivers/media/platform/video-mux.c
@@ -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)
--
2.17.1