From: Laurent Pinchart <laurent.pinch...@ideasonboard.com>

This is a wrapper around the media entity has_route operation.

Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
Signed-off-by: Michal Simek <michal.si...@xilinx.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+rene...@ragnatech.se>
---
 drivers/media/media-entity.c | 29 +++++++++++++++++++++++++++++
 include/media/media-entity.h |  3 +++
 2 files changed, 32 insertions(+)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index d8a2299..8732579 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -240,6 +240,35 @@ EXPORT_SYMBOL_GPL(media_entity_pads_init);
  * Graph traversal
  */
 
+/**
+ * media_entity_has_route - Check if two entity pads are connected internally
+ * @entity: The entity
+ * @pad0: The first pad index
+ * @pad1: The second pad index
+ *
+ * This function can be used to check whether two pads of an entity are
+ * connected internally in the entity.
+ *
+ * The caller must hold entity->source->parent->mutex.
+ *
+ * Return: true if the pads are connected internally and false otherwise.
+ */
+bool media_entity_has_route(struct media_entity *entity, unsigned int pad0,
+                           unsigned int pad1)
+{
+       if (pad0 >= entity->num_pads || pad1 >= entity->num_pads)
+               return false;
+
+       if (pad0 == pad1)
+               return true;
+
+       if (!entity->ops || !entity->ops->has_route)
+               return true;
+
+       return entity->ops->has_route(entity, pad0, pad1);
+}
+EXPORT_SYMBOL_GPL(media_entity_has_route);
+
 static struct media_entity *
 media_entity_other(struct media_entity *entity, struct media_link *link)
 {
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index c4b2dca..68af160 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -796,6 +796,9 @@ void media_entity_graph_walk_cleanup(struct 
media_entity_graph *graph);
  */
 void media_entity_put(struct media_entity *entity);
 
+bool media_entity_has_route(struct media_entity *entity, unsigned int sink,
+                           unsigned int source);
+
 /**
  * media_entity_graph_walk_start - Start walking the media graph at a given 
entity
  * @graph: Media graph structure that will be used to walk the graph
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to