@@ -248,6 +248,20 @@ bool media_entity_has_route(struct media_entity *entity, unsigned int pad0,
}
EXPORT_SYMBOL_GPL(media_entity_has_route);
+struct media_pad *__media_entity_next_routed_pad(struct media_pad *root,
+ struct media_pad *iter)
+{
+ struct media_entity *entity = root->entity;
+
+ for (; iter < &entity->pads[entity->num_pads]; iter++) {
+ if (media_entity_has_route(entity, root->index, iter->index))
+ return iter;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(__media_entity_next_routed_pad);
+
/* push an entity to traversal stack */
static void stack_push(struct media_graph *graph, struct media_pad *pad)
{
@@ -921,6 +921,32 @@ __must_check int media_graph_walk_init(
bool media_entity_has_route(struct media_entity *entity, unsigned int pad0,
unsigned int pad1);
+/**
+ * __media_entity_next_routed_pad - Get next pad connected to @root
+ *
+ * @root: The root pad to which the iterated pads have a route
+ * @iter: The iterator pad
+ *
+ * Get next pad which has a route to @root.
+ */
+struct media_pad *__media_entity_next_routed_pad(struct media_pad *root,
+ struct media_pad *iter);
+
+/**
+ * media_entity_for_each_routed_pad - Iterate over entity pads connected by routes
+ *
+ * @root: The root pad to which the iterated pads have a route
+ * @iter: The iterator pad
+ *
+ * Iterate over all pads of an entity which have an internal route to @root pad.
+ * The iteration will include the @root pad itself.
+ */
+#define media_entity_for_each_routed_pad(root, iter) \
+ for (iter = __media_entity_next_routed_pad(root, \
+ (root)->entity->pads); \
+ iter != NULL; \
+ iter = __media_entity_next_routed_pad(root, iter + 1))
+
/**
* media_graph_walk_cleanup - Release resources used by graph walk.
*