]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
[media] media: Keep using the same graph walk object for a given pipeline
authorSakari Ailus <sakari.ailus@iki.fi>
Wed, 16 Dec 2015 13:32:29 +0000 (11:32 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:19:20 +0000 (12:19 -0200)
Initialise a given graph walk object once, and then keep using it whilst
the same pipeline is running. Once the pipeline is stopped, release the
graph walk object.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/media-entity.c
include/media/media-entity.h

index 86a8396f6ec286dae1d847060c4b2a51222e9aa3..3cad525c2ac1feefe5191e4c32794afb27effd3a 100644 (file)
@@ -379,10 +379,10 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
 
        mutex_lock(&mdev->graph_mutex);
 
-       ret = media_entity_graph_walk_init(&pipe->graph, mdev);
-       if (ret) {
-               mutex_unlock(&mdev->graph_mutex);
-               return ret;
+       if (!pipe->streaming_count++) {
+               ret = media_entity_graph_walk_init(&pipe->graph, mdev);
+               if (ret)
+                       goto error_graph_walk_start;
        }
 
        media_entity_graph_walk_start(&pipe->graph, entity);
@@ -483,7 +483,9 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
                        break;
        }
 
-       media_entity_graph_walk_cleanup(graph);
+error_graph_walk_start:
+       if (!--pipe->streaming_count)
+               media_entity_graph_walk_cleanup(graph);
 
        mutex_unlock(&mdev->graph_mutex);
 
@@ -495,9 +497,11 @@ void media_entity_pipeline_stop(struct media_entity *entity)
 {
        struct media_device *mdev = entity->graph_obj.mdev;
        struct media_entity_graph *graph = &entity->pipe->graph;
+       struct media_pipeline *pipe = entity->pipe;
 
        mutex_lock(&mdev->graph_mutex);
 
+       WARN_ON(!pipe->streaming_count);
        media_entity_graph_walk_start(graph, entity);
 
        while ((entity = media_entity_graph_walk_next(graph))) {
@@ -506,7 +510,8 @@ void media_entity_pipeline_stop(struct media_entity *entity)
                        entity->pipe = NULL;
        }
 
-       media_entity_graph_walk_cleanup(graph);
+       if (!--pipe->streaming_count)
+               media_entity_graph_walk_cleanup(graph);
 
        mutex_unlock(&mdev->graph_mutex);
 }
index a53acb099c16f50aff444a47665cd238e30bb8dd..a47a7c8a93cfdfbe0c3967813e8f23456600a9ae 100644 (file)
@@ -119,9 +119,11 @@ struct media_entity_graph {
 /*
  * struct media_pipeline - Media pipeline related information
  *
- * @graph:     Media graph walk during pipeline start / stop
+ * @streaming_count:   Streaming start count - streaming stop count
+ * @graph:             Media graph walk during pipeline start / stop
  */
 struct media_pipeline {
+       int streaming_count;
        struct media_entity_graph graph;
 };