forked from Minki/linux
[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: Sakari Ailus <sakari.ailus@linux.intel.com> Cc: Prabhakar Lad <prabhakar.lad@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
809fe79a5f
commit
bb0faebdc1
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user