@@ -228,6 +228,11 @@ EXPORT_SYMBOL_GPL(media_entity_pads_init);
* Graph traversal
*/
+enum media_graph_walk_type {
+ MEDIA_GRAPH_WALK_CONNECTED_NODES,
+ MEDIA_GRAPH_WALK_STREAM_NODES,
+};
+
static struct media_entity *
media_entity_other(struct media_entity *entity, struct media_link *link)
{
@@ -305,7 +310,8 @@ void media_graph_walk_start(struct media_graph *graph,
}
EXPORT_SYMBOL_GPL(media_graph_walk_start);
-static void media_graph_walk_iter(struct media_graph *graph)
+static void media_graph_walk_iter(struct media_graph *graph,
+ enum media_graph_walk_type type)
{
struct media_entity *entity = stack_top(graph);
struct media_link *link;
@@ -326,6 +332,15 @@ static void media_graph_walk_iter(struct media_graph *graph)
/* Get the entity in the other end of the link . */
next = media_entity_other(entity, link);
+ if (type == MEDIA_GRAPH_WALK_STREAM_NODES &&
+ next == link->sink->entity) {
+ link_top(graph) = link_top(graph)->next;
+ dev_dbg(entity->graph_obj.mdev->dev,
+ "walk: skipping '%s' (outside of the stream path)\n",
+ link->sink->entity->name);
+ return;
+ }
+
/* Has the entity already been visited? */
if (media_entity_enum_test_and_set(&graph->ent_enum, next)) {
link_top(graph) = link_top(graph)->next;
@@ -342,7 +357,9 @@ static void media_graph_walk_iter(struct media_graph *graph)
next->name);
}
-struct media_entity *media_graph_walk_next(struct media_graph *graph)
+static struct media_entity *
+__media_graph_walk_next(struct media_graph *graph,
+ enum media_graph_walk_type type)
{
struct media_entity *entity;
@@ -355,7 +372,7 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph)
* found.
*/
while (link_top(graph) != &stack_top(graph)->links)
- media_graph_walk_iter(graph);
+ media_graph_walk_iter(graph, type);
entity = stack_pop(graph);
dev_dbg(entity->graph_obj.mdev->dev,
@@ -363,8 +380,19 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph)
return entity;
}
+
+struct media_entity *media_graph_walk_next(struct media_graph *graph)
+{
+ return __media_graph_walk_next(graph, MEDIA_GRAPH_WALK_CONNECTED_NODES);
+}
EXPORT_SYMBOL_GPL(media_graph_walk_next);
+struct media_entity *media_graph_walk_next_stream(struct media_graph *graph)
+{
+ return __media_graph_walk_next(graph, MEDIA_GRAPH_WALK_STREAM_NODES);
+}
+EXPORT_SYMBOL_GPL(media_graph_walk_next_stream);
+
int media_entity_get_fwnode_pad(struct media_entity *entity,
struct fwnode_handle *fwnode,
unsigned long direction_flags)
@@ -928,6 +928,21 @@ void media_graph_walk_start(struct media_graph *graph,
*/
struct media_entity *media_graph_walk_next(struct media_graph *graph);
+/**
+ * media_graph_walk_next_stream - Get the next entity in the graph
+ * @graph: Media graph structure
+ *
+ * Perform a depth-first traversal of the given media entities graph only
+ * following links from sink to source (and not the opposite).
+ *
+ * The graph structure must have been previously initialized with a call to
+ * media_graph_walk_start().
+ *
+ * Return: returns the next entity in the graph in the stream path
+ * or %NULL if the whole stream path have been traversed.
+ */
+struct media_entity *media_graph_walk_next_stream(struct media_graph *graph);
+
/**
* media_pipeline_start - Mark a pipeline as streaming
* @entity: Starting entity