media: ti: omap4iss: Use media_pipeline_for_each_entity()
Replace usage of the deprecated media graph walk API with the new media_pipeline_for_each_entity() and media_pipeline_for_each_pad() macros. Even though the entity iterator may seem a better match when build the entity bitmap in iss_video_stream(), it would not be more efficient as it would still iterate internally over all pads. As the entity iterator requires explicit iterator initialization and cleanup calls, the code would be more complex. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
Родитель
3e8537b4c1
Коммит
27e45f2e59
|
@ -201,39 +201,34 @@ iss_video_remote_subdev(struct iss_video *video, u32 *pad)
|
||||||
|
|
||||||
/* Return a pointer to the ISS video instance at the far end of the pipeline. */
|
/* Return a pointer to the ISS video instance at the far end of the pipeline. */
|
||||||
static struct iss_video *
|
static struct iss_video *
|
||||||
iss_video_far_end(struct iss_video *video)
|
iss_video_far_end(struct iss_video *video, struct iss_pipeline *pipe)
|
||||||
{
|
{
|
||||||
struct media_graph graph;
|
struct media_pipeline_entity_iter iter;
|
||||||
struct media_entity *entity = &video->video.entity;
|
struct media_entity *entity;
|
||||||
struct media_device *mdev = entity->graph_obj.mdev;
|
|
||||||
struct iss_video *far_end = NULL;
|
struct iss_video *far_end = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&mdev->graph_mutex);
|
ret = media_pipeline_entity_iter_init(&pipe->pipe, &iter);
|
||||||
|
if (ret)
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
if (media_graph_walk_init(&graph, mdev)) {
|
media_pipeline_for_each_entity(&pipe->pipe, &iter, entity) {
|
||||||
mutex_unlock(&mdev->graph_mutex);
|
struct iss_video *other;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
media_graph_walk_start(&graph, entity);
|
|
||||||
|
|
||||||
while ((entity = media_graph_walk_next(&graph))) {
|
|
||||||
if (entity == &video->video.entity)
|
if (entity == &video->video.entity)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!is_media_entity_v4l2_video_device(entity))
|
if (!is_media_entity_v4l2_video_device(entity))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
far_end = to_iss_video(media_entity_to_video_device(entity));
|
other = to_iss_video(media_entity_to_video_device(entity));
|
||||||
if (far_end->type != video->type)
|
if (other->type != video->type) {
|
||||||
|
far_end = other;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
far_end = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&mdev->graph_mutex);
|
media_pipeline_entity_iter_cleanup(&iter);
|
||||||
|
|
||||||
media_graph_walk_cleanup(&graph);
|
|
||||||
|
|
||||||
return far_end;
|
return far_end;
|
||||||
}
|
}
|
||||||
|
@ -850,12 +845,12 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
||||||
{
|
{
|
||||||
struct iss_video_fh *vfh = to_iss_video_fh(fh);
|
struct iss_video_fh *vfh = to_iss_video_fh(fh);
|
||||||
struct iss_video *video = video_drvdata(file);
|
struct iss_video *video = video_drvdata(file);
|
||||||
struct media_graph graph;
|
struct media_device *mdev = video->video.entity.graph_obj.mdev;
|
||||||
struct media_entity *entity = &video->video.entity;
|
struct media_pipeline_pad_iter iter;
|
||||||
struct media_device *mdev = entity->graph_obj.mdev;
|
|
||||||
enum iss_pipeline_state state;
|
enum iss_pipeline_state state;
|
||||||
struct iss_pipeline *pipe;
|
struct iss_pipeline *pipe;
|
||||||
struct iss_video *far_end;
|
struct iss_video *far_end;
|
||||||
|
struct media_pad *pad;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -873,13 +868,9 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
||||||
pipe->external_rate = 0;
|
pipe->external_rate = 0;
|
||||||
pipe->external_bpp = 0;
|
pipe->external_bpp = 0;
|
||||||
|
|
||||||
ret = media_entity_enum_init(&pipe->ent_enum, entity->graph_obj.mdev);
|
ret = media_entity_enum_init(&pipe->ent_enum, mdev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_graph_walk_init;
|
goto err_entity_enum_init;
|
||||||
|
|
||||||
ret = media_graph_walk_init(&graph, entity->graph_obj.mdev);
|
|
||||||
if (ret)
|
|
||||||
goto err_graph_walk_init;
|
|
||||||
|
|
||||||
if (video->iss->pdata->set_constraints)
|
if (video->iss->pdata->set_constraints)
|
||||||
video->iss->pdata->set_constraints(video->iss, true);
|
video->iss->pdata->set_constraints(video->iss, true);
|
||||||
|
@ -888,11 +879,8 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_media_pipeline_start;
|
goto err_media_pipeline_start;
|
||||||
|
|
||||||
mutex_lock(&mdev->graph_mutex);
|
media_pipeline_for_each_pad(&pipe->pipe, &iter, pad)
|
||||||
media_graph_walk_start(&graph, entity);
|
media_entity_enum_set(&pipe->ent_enum, pad->entity);
|
||||||
while ((entity = media_graph_walk_next(&graph)))
|
|
||||||
media_entity_enum_set(&pipe->ent_enum, entity);
|
|
||||||
mutex_unlock(&mdev->graph_mutex);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Verify that the currently configured format matches the output of
|
* Verify that the currently configured format matches the output of
|
||||||
|
@ -909,7 +897,11 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
||||||
* Find the ISS video node connected at the far end of the pipeline and
|
* Find the ISS video node connected at the far end of the pipeline and
|
||||||
* update the pipeline.
|
* update the pipeline.
|
||||||
*/
|
*/
|
||||||
far_end = iss_video_far_end(video);
|
far_end = iss_video_far_end(video, pipe);
|
||||||
|
if (IS_ERR(far_end)) {
|
||||||
|
ret = PTR_ERR(far_end);
|
||||||
|
goto err_iss_video_check_format;
|
||||||
|
}
|
||||||
|
|
||||||
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
|
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
|
||||||
state = ISS_PIPELINE_STREAM_OUTPUT | ISS_PIPELINE_IDLE_OUTPUT;
|
state = ISS_PIPELINE_STREAM_OUTPUT | ISS_PIPELINE_IDLE_OUTPUT;
|
||||||
|
@ -966,8 +958,6 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
||||||
spin_unlock_irqrestore(&video->qlock, flags);
|
spin_unlock_irqrestore(&video->qlock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
media_graph_walk_cleanup(&graph);
|
|
||||||
|
|
||||||
mutex_unlock(&video->stream_lock);
|
mutex_unlock(&video->stream_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -981,9 +971,7 @@ err_media_pipeline_start:
|
||||||
video->iss->pdata->set_constraints(video->iss, false);
|
video->iss->pdata->set_constraints(video->iss, false);
|
||||||
video->queue = NULL;
|
video->queue = NULL;
|
||||||
|
|
||||||
media_graph_walk_cleanup(&graph);
|
err_entity_enum_init:
|
||||||
|
|
||||||
err_graph_walk_init:
|
|
||||||
media_entity_enum_cleanup(&pipe->ent_enum);
|
media_entity_enum_cleanup(&pipe->ent_enum);
|
||||||
|
|
||||||
mutex_unlock(&video->stream_lock);
|
mutex_unlock(&video->stream_lock);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче