Commit bb0faebd authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] staging: v4l: davinci_vpbe: Use the new media graph walk interface

The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Cc: Prabhakar Lad <prabhakar.lad@ti.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 809fe79a
...@@ -127,13 +127,14 @@ __vpfe_video_get_format(struct vpfe_video_device *video, ...@@ -127,13 +127,14 @@ __vpfe_video_get_format(struct vpfe_video_device *video,
} }
/* make a note of pipeline details */ /* 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_entity *entity = &video->video_dev.entity;
struct media_device *mdev = entity->graph_obj.mdev; struct media_device *mdev = entity->graph_obj.mdev;
struct vpfe_pipeline *pipe = &video->pipe; struct vpfe_pipeline *pipe = &video->pipe;
struct vpfe_video_device *far_end = NULL; struct vpfe_video_device *far_end = NULL;
struct media_entity_graph graph; int ret;
pipe->input_num = 0; pipe->input_num = 0;
pipe->output_num = 0; pipe->output_num = 0;
...@@ -144,6 +145,11 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video) ...@@ -144,6 +145,11 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video)
pipe->outputs[pipe->output_num++] = video; pipe->outputs[pipe->output_num++] = video;
mutex_lock(&mdev->graph_mutex); 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); media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) { while ((entity = media_entity_graph_walk_next(&graph))) {
if (entity == &video->video_dev.entity) if (entity == &video->video_dev.entity)
...@@ -156,7 +162,10 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video) ...@@ -156,7 +162,10 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video)
else else
pipe->outputs[pipe->output_num++] = far_end; pipe->outputs[pipe->output_num++] = far_end;
} }
media_entity_graph_walk_cleanup(&graph);
mutex_unlock(&mdev->graph_mutex); mutex_unlock(&mdev->graph_mutex);
return 0;
} }
/* update pipe state selected by user */ /* update pipe state selected by user */
...@@ -165,7 +174,9 @@ static int vpfe_update_pipe_state(struct vpfe_video_device *video) ...@@ -165,7 +174,9 @@ static int vpfe_update_pipe_state(struct vpfe_video_device *video)
struct vpfe_pipeline *pipe = &video->pipe; struct vpfe_pipeline *pipe = &video->pipe;
int ret; int ret;
vpfe_prepare_pipeline(video); ret = vpfe_prepare_pipeline(video);
if (ret)
return ret;
/* Find out if there is any input video /* Find out if there is any input video
if yes, it is single shot. if yes, it is single shot.
...@@ -276,11 +287,10 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe) ...@@ -276,11 +287,10 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe)
*/ */
static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
{ {
struct media_entity_graph graph;
struct media_entity *entity; struct media_entity *entity;
struct v4l2_subdev *subdev; struct v4l2_subdev *subdev;
struct media_device *mdev; struct media_device *mdev;
int ret = 0; int ret;
if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS) if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS)
entity = vpfe_get_input_entity(pipe->outputs[0]); entity = vpfe_get_input_entity(pipe->outputs[0]);
...@@ -289,8 +299,12 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) ...@@ -289,8 +299,12 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
mdev = entity->graph_obj.mdev; mdev = entity->graph_obj.mdev;
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
media_entity_graph_walk_start(&graph, entity); ret = media_entity_graph_walk_init(&pipe->graph,
while ((entity = media_entity_graph_walk_next(&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)) if (!is_media_entity_v4l2_subdev(entity))
continue; continue;
...@@ -299,6 +313,9 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) ...@@ -299,6 +313,9 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
if (ret < 0 && ret != -ENOIOCTLCMD) if (ret < 0 && ret != -ENOIOCTLCMD)
break; break;
} }
out:
if (ret)
media_entity_graph_walk_cleanup(&pipe->graph);
mutex_unlock(&mdev->graph_mutex); mutex_unlock(&mdev->graph_mutex);
return ret; return ret;
} }
...@@ -316,7 +333,6 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) ...@@ -316,7 +333,6 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
*/ */
static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
{ {
struct media_entity_graph graph;
struct media_entity *entity; struct media_entity *entity;
struct v4l2_subdev *subdev; struct v4l2_subdev *subdev;
struct media_device *mdev; struct media_device *mdev;
...@@ -329,9 +345,9 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) ...@@ -329,9 +345,9 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
mdev = entity->graph_obj.mdev; mdev = entity->graph_obj.mdev;
mutex_lock(&mdev->graph_mutex); 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)) if (!is_media_entity_v4l2_subdev(entity))
continue; continue;
...@@ -342,6 +358,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) ...@@ -342,6 +358,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
} }
mutex_unlock(&mdev->graph_mutex); mutex_unlock(&mdev->graph_mutex);
media_entity_graph_walk_cleanup(&pipe->graph);
return ret ? -ETIMEDOUT : 0; return ret ? -ETIMEDOUT : 0;
} }
......
...@@ -52,6 +52,7 @@ enum vpfe_video_state { ...@@ -52,6 +52,7 @@ enum vpfe_video_state {
struct vpfe_pipeline { struct vpfe_pipeline {
/* media pipeline */ /* media pipeline */
struct media_pipeline *pipe; struct media_pipeline *pipe;
struct media_entity_graph graph;
/* state of the pipeline, continuous, /* state of the pipeline, continuous,
* single-shot or stopped * single-shot or stopped
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment