@@ -229,6 +229,25 @@ EXPORT_SYMBOL_GPL(media_entity_pads_init);
* Graph traversal
*/
+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;
+
+ if (entity->pads[pad1].index < entity->pads[pad0].index)
+ swap(pad0, pad1);
+
+ return entity->ops->has_route(entity, pad0, pad1);
+}
+EXPORT_SYMBOL_GPL(media_entity_has_route);
+
static struct media_pad *
media_pad_other(struct media_pad *pad, struct media_link *link)
{
@@ -899,6 +899,23 @@ int media_entity_get_fwnode_pad(struct media_entity *entity,
__must_check int media_graph_walk_init(
struct media_graph *graph, struct media_device *mdev);
+/**
+ * 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->graph_obj.mdev->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);
+
/**
* media_graph_walk_cleanup - Release resources used by graph walk.
*