[media] staging: v4l: davinci_vpbe: Use the new media graph walk interface
authorSakari Ailus <sakari.ailus@iki.fi>
Wed, 16 Dec 2015 13:32:35 +0000 (11:32 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:19:22 +0000 (12:19 -0200)
The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Prabhakar Lad <prabhakar.lad@ti.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/staging/media/davinci_vpfe/vpfe_video.c
drivers/staging/media/davinci_vpfe/vpfe_video.h

index 285dc1a69b2ca097860924291da78af3fe3cbf52..3ec7e65a3ffa524efb6e95d98bbc6916592d2a18 100644 (file)
@@ -127,13 +127,14 @@ __vpfe_video_get_format(struct vpfe_video_device *video,
 }
 
 /* make a note of pipeline details */
-static void vpfe_prepare_pipeline(struct vpfe_video_device *video)
+static int vpfe_prepare_pipeline(struct vpfe_video_device *video)
 {
+       struct media_entity_graph graph;
        struct media_entity *entity = &video->video_dev.entity;
        struct media_device *mdev = entity->graph_obj.mdev;
        struct vpfe_pipeline *pipe = &video->pipe;
        struct vpfe_video_device *far_end = NULL;
-       struct media_entity_graph graph;
+       int ret;
 
        pipe->input_num = 0;
        pipe->output_num = 0;
@@ -144,6 +145,11 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video)
                pipe->outputs[pipe->output_num++] = video;
 
        mutex_lock(&mdev->graph_mutex);
+       ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev);
+       if (ret) {
+               mutex_unlock(&video->lock);
+               return -ENOMEM;
+       }
        media_entity_graph_walk_start(&graph, entity);
        while ((entity = media_entity_graph_walk_next(&graph))) {
                if (entity == &video->video_dev.entity)
@@ -156,7 +162,10 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video)
                else
                        pipe->outputs[pipe->output_num++] = far_end;
        }
+       media_entity_graph_walk_cleanup(&graph);
        mutex_unlock(&mdev->graph_mutex);
+
+       return 0;
 }
 
 /* update pipe state selected by user */
@@ -165,7 +174,9 @@ static int vpfe_update_pipe_state(struct vpfe_video_device *video)
        struct vpfe_pipeline *pipe = &video->pipe;
        int ret;
 
-       vpfe_prepare_pipeline(video);
+       ret = vpfe_prepare_pipeline(video);
+       if (ret)
+               return ret;
 
        /* Find out if there is any input video
          if yes, it is single shot.
@@ -276,11 +287,10 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe)
  */
 static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
 {
-       struct media_entity_graph graph;
        struct media_entity *entity;
        struct v4l2_subdev *subdev;
        struct media_device *mdev;
-       int ret = 0;
+       int ret;
 
        if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS)
                entity = vpfe_get_input_entity(pipe->outputs[0]);
@@ -289,8 +299,12 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
 
        mdev = entity->graph_obj.mdev;
        mutex_lock(&mdev->graph_mutex);
-       media_entity_graph_walk_start(&graph, entity);
-       while ((entity = media_entity_graph_walk_next(&graph))) {
+       ret = media_entity_graph_walk_init(&pipe->graph,
+                                          entity->graph_obj.mdev);
+       if (ret)
+               goto out;
+       media_entity_graph_walk_start(&pipe->graph, entity);
+       while ((entity = media_entity_graph_walk_next(&pipe->graph))) {
 
                if (!is_media_entity_v4l2_subdev(entity))
                        continue;
@@ -299,6 +313,9 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
                if (ret < 0 && ret != -ENOIOCTLCMD)
                        break;
        }
+out:
+       if (ret)
+               media_entity_graph_walk_cleanup(&pipe->graph);
        mutex_unlock(&mdev->graph_mutex);
        return ret;
 }
@@ -316,7 +333,6 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
  */
 static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
 {
-       struct media_entity_graph graph;
        struct media_entity *entity;
        struct v4l2_subdev *subdev;
        struct media_device *mdev;
@@ -329,9 +345,9 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
 
        mdev = entity->graph_obj.mdev;
        mutex_lock(&mdev->graph_mutex);
-       media_entity_graph_walk_start(&graph, entity);
+       media_entity_graph_walk_start(&pipe->graph, entity);
 
-       while ((entity = media_entity_graph_walk_next(&graph))) {
+       while ((entity = media_entity_graph_walk_next(&pipe->graph))) {
 
                if (!is_media_entity_v4l2_subdev(entity))
                        continue;
@@ -342,6 +358,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
        }
        mutex_unlock(&mdev->graph_mutex);
 
+       media_entity_graph_walk_cleanup(&pipe->graph);
        return ret ? -ETIMEDOUT : 0;
 }
 
index 673cefe3ef61f1091578679667a7901954054e90..653334d537d3bab2187a80407a3de987f3906b4b 100644 (file)
@@ -52,6 +52,7 @@ enum vpfe_video_state {
 struct vpfe_pipeline {
        /* media pipeline */
        struct media_pipeline           *pipe;
+       struct media_entity_graph       graph;
        /* state of the pipeline, continuous,
         * single-shot or stopped
         */