Commit 9e3576a1 authored by Tomi Valkeinen's avatar Tomi Valkeinen Committed by Mauro Carvalho Chehab

media: mc: convert pipeline funcs to take media_pad

Now that the pipeline is stored into pads instead of entities, we can
change the relevant functions to take pads instead of entities.
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 5b4f9a72
...@@ -700,29 +700,21 @@ static int media_pipeline_populate(struct media_pipeline *pipe, ...@@ -700,29 +700,21 @@ static int media_pipeline_populate(struct media_pipeline *pipe,
return ret; return ret;
} }
__must_check int __media_pipeline_start(struct media_entity *entity, __must_check int __media_pipeline_start(struct media_pad *pad,
struct media_pipeline *pipe) struct media_pipeline *pipe)
{ {
struct media_device *mdev = entity->graph_obj.mdev; struct media_device *mdev = pad->entity->graph_obj.mdev;
struct media_pipeline_pad *err_ppad; struct media_pipeline_pad *err_ppad;
struct media_pipeline_pad *ppad; struct media_pipeline_pad *ppad;
int ret; int ret;
lockdep_assert_held(&mdev->graph_mutex); lockdep_assert_held(&mdev->graph_mutex);
/*
* media_pipeline_start(entity) only makes sense with entities that have
* a single pad.
*/
if (WARN_ON(entity->num_pads != 1))
return -EINVAL;
/* /*
* If the entity is already part of a pipeline, that pipeline must * If the entity is already part of a pipeline, that pipeline must
* be the same as the pipe given to media_pipeline_start(). * be the same as the pipe given to media_pipeline_start().
*/ */
if (WARN_ON(entity->pads->pipe && entity->pads->pipe != pipe)) if (WARN_ON(pad->pipe && pad->pipe != pipe))
return -EINVAL; return -EINVAL;
/* /*
...@@ -739,7 +731,7 @@ __must_check int __media_pipeline_start(struct media_entity *entity, ...@@ -739,7 +731,7 @@ __must_check int __media_pipeline_start(struct media_entity *entity,
* with media_pipeline_pad instances for each pad found during graph * with media_pipeline_pad instances for each pad found during graph
* walk. * walk.
*/ */
ret = media_pipeline_populate(pipe, entity->pads); ret = media_pipeline_populate(pipe, pad);
if (ret) if (ret)
return ret; return ret;
...@@ -856,22 +848,22 @@ __must_check int __media_pipeline_start(struct media_entity *entity, ...@@ -856,22 +848,22 @@ __must_check int __media_pipeline_start(struct media_entity *entity,
} }
EXPORT_SYMBOL_GPL(__media_pipeline_start); EXPORT_SYMBOL_GPL(__media_pipeline_start);
__must_check int media_pipeline_start(struct media_entity *entity, __must_check int media_pipeline_start(struct media_pad *pad,
struct media_pipeline *pipe) struct media_pipeline *pipe)
{ {
struct media_device *mdev = entity->graph_obj.mdev; struct media_device *mdev = pad->entity->graph_obj.mdev;
int ret; int ret;
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
ret = __media_pipeline_start(entity, pipe); ret = __media_pipeline_start(pad, pipe);
mutex_unlock(&mdev->graph_mutex); mutex_unlock(&mdev->graph_mutex);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(media_pipeline_start); EXPORT_SYMBOL_GPL(media_pipeline_start);
void __media_pipeline_stop(struct media_entity *entity) void __media_pipeline_stop(struct media_pad *pad)
{ {
struct media_pipeline *pipe = entity->pads->pipe; struct media_pipeline *pipe = pad->pipe;
struct media_pipeline_pad *ppad; struct media_pipeline_pad *ppad;
/* /*
...@@ -894,19 +886,19 @@ void __media_pipeline_stop(struct media_entity *entity) ...@@ -894,19 +886,19 @@ void __media_pipeline_stop(struct media_entity *entity)
} }
EXPORT_SYMBOL_GPL(__media_pipeline_stop); EXPORT_SYMBOL_GPL(__media_pipeline_stop);
void media_pipeline_stop(struct media_entity *entity) void media_pipeline_stop(struct media_pad *pad)
{ {
struct media_device *mdev = entity->graph_obj.mdev; struct media_device *mdev = pad->entity->graph_obj.mdev;
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
__media_pipeline_stop(entity); __media_pipeline_stop(pad);
mutex_unlock(&mdev->graph_mutex); mutex_unlock(&mdev->graph_mutex);
} }
EXPORT_SYMBOL_GPL(media_pipeline_stop); EXPORT_SYMBOL_GPL(media_pipeline_stop);
__must_check int media_pipeline_alloc_start(struct media_entity *entity) __must_check int media_pipeline_alloc_start(struct media_pad *pad)
{ {
struct media_device *mdev = entity->graph_obj.mdev; struct media_device *mdev = pad->entity->graph_obj.mdev;
struct media_pipeline *new_pipe = NULL; struct media_pipeline *new_pipe = NULL;
struct media_pipeline *pipe; struct media_pipeline *pipe;
int ret; int ret;
...@@ -917,7 +909,7 @@ __must_check int media_pipeline_alloc_start(struct media_entity *entity) ...@@ -917,7 +909,7 @@ __must_check int media_pipeline_alloc_start(struct media_entity *entity)
* Is the entity already part of a pipeline? If not, we need to allocate * Is the entity already part of a pipeline? If not, we need to allocate
* a pipe. * a pipe.
*/ */
pipe = media_entity_pipeline(entity); pipe = media_pad_pipeline(pad);
if (!pipe) { if (!pipe) {
new_pipe = kzalloc(sizeof(*new_pipe), GFP_KERNEL); new_pipe = kzalloc(sizeof(*new_pipe), GFP_KERNEL);
if (!new_pipe) { if (!new_pipe) {
...@@ -929,7 +921,7 @@ __must_check int media_pipeline_alloc_start(struct media_entity *entity) ...@@ -929,7 +921,7 @@ __must_check int media_pipeline_alloc_start(struct media_entity *entity)
pipe->allocated = true; pipe->allocated = true;
} }
ret = __media_pipeline_start(entity, pipe); ret = __media_pipeline_start(pad, pipe);
if (ret) if (ret)
kfree(new_pipe); kfree(new_pipe);
......
...@@ -848,13 +848,13 @@ static int s3c_camif_streamon(struct file *file, void *priv, ...@@ -848,13 +848,13 @@ static int s3c_camif_streamon(struct file *file, void *priv,
if (s3c_vp_active(vp)) if (s3c_vp_active(vp))
return 0; return 0;
ret = media_pipeline_start(sensor, camif->m_pipeline); ret = media_pipeline_start(sensor->pads, camif->m_pipeline);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = camif_pipeline_validate(camif); ret = camif_pipeline_validate(camif);
if (ret < 0) { if (ret < 0) {
media_pipeline_stop(sensor); media_pipeline_stop(sensor->pads);
return ret; return ret;
} }
...@@ -878,7 +878,7 @@ static int s3c_camif_streamoff(struct file *file, void *priv, ...@@ -878,7 +878,7 @@ static int s3c_camif_streamoff(struct file *file, void *priv,
ret = vb2_streamoff(&vp->vb_queue, type); ret = vb2_streamoff(&vp->vb_queue, type);
if (ret == 0) if (ret == 0)
media_pipeline_stop(&camif->sensor.sd->entity); media_pipeline_stop(camif->sensor.sd->entity.pads);
return ret; return ret;
} }
......
...@@ -410,7 +410,7 @@ static int au0828_enable_source(struct media_entity *entity, ...@@ -410,7 +410,7 @@ static int au0828_enable_source(struct media_entity *entity,
goto end; goto end;
} }
ret = __media_pipeline_start(entity, pipe); ret = __media_pipeline_start(entity->pads, pipe);
if (ret) { if (ret) {
pr_err("Start Pipeline: %s->%s Error %d\n", pr_err("Start Pipeline: %s->%s Error %d\n",
source->name, entity->name, ret); source->name, entity->name, ret);
...@@ -501,12 +501,12 @@ static void au0828_disable_source(struct media_entity *entity) ...@@ -501,12 +501,12 @@ static void au0828_disable_source(struct media_entity *entity)
return; return;
/* stop pipeline */ /* stop pipeline */
__media_pipeline_stop(dev->active_link_owner); __media_pipeline_stop(dev->active_link_owner->pads);
pr_debug("Pipeline stop for %s\n", pr_debug("Pipeline stop for %s\n",
dev->active_link_owner->name); dev->active_link_owner->name);
ret = __media_pipeline_start( ret = __media_pipeline_start(
dev->active_link_user, dev->active_link_user->pads,
dev->active_link_user_pipe); dev->active_link_user_pipe);
if (ret) { if (ret) {
pr_err("Start Pipeline: %s->%s %d\n", pr_err("Start Pipeline: %s->%s %d\n",
...@@ -532,7 +532,7 @@ static void au0828_disable_source(struct media_entity *entity) ...@@ -532,7 +532,7 @@ static void au0828_disable_source(struct media_entity *entity)
return; return;
/* stop pipeline */ /* stop pipeline */
__media_pipeline_stop(dev->active_link_owner); __media_pipeline_stop(dev->active_link_owner->pads);
pr_debug("Pipeline stop for %s\n", pr_debug("Pipeline stop for %s\n",
dev->active_link_owner->name); dev->active_link_owner->name);
......
...@@ -1105,7 +1105,7 @@ __must_check int video_device_pipeline_start(struct video_device *vdev, ...@@ -1105,7 +1105,7 @@ __must_check int video_device_pipeline_start(struct video_device *vdev,
if (entity->num_pads != 1) if (entity->num_pads != 1)
return -ENODEV; return -ENODEV;
return media_pipeline_start(entity, pipe); return media_pipeline_start(&entity->pads[0], pipe);
} }
EXPORT_SYMBOL_GPL(video_device_pipeline_start); EXPORT_SYMBOL_GPL(video_device_pipeline_start);
...@@ -1117,7 +1117,7 @@ __must_check int __video_device_pipeline_start(struct video_device *vdev, ...@@ -1117,7 +1117,7 @@ __must_check int __video_device_pipeline_start(struct video_device *vdev,
if (entity->num_pads != 1) if (entity->num_pads != 1)
return -ENODEV; return -ENODEV;
return __media_pipeline_start(entity, pipe); return __media_pipeline_start(&entity->pads[0], pipe);
} }
EXPORT_SYMBOL_GPL(__video_device_pipeline_start); EXPORT_SYMBOL_GPL(__video_device_pipeline_start);
...@@ -1128,7 +1128,7 @@ void video_device_pipeline_stop(struct video_device *vdev) ...@@ -1128,7 +1128,7 @@ void video_device_pipeline_stop(struct video_device *vdev)
if (WARN_ON(entity->num_pads != 1)) if (WARN_ON(entity->num_pads != 1))
return; return;
return media_pipeline_stop(entity); return media_pipeline_stop(&entity->pads[0]);
} }
EXPORT_SYMBOL_GPL(video_device_pipeline_stop); EXPORT_SYMBOL_GPL(video_device_pipeline_stop);
...@@ -1139,7 +1139,7 @@ void __video_device_pipeline_stop(struct video_device *vdev) ...@@ -1139,7 +1139,7 @@ void __video_device_pipeline_stop(struct video_device *vdev)
if (WARN_ON(entity->num_pads != 1)) if (WARN_ON(entity->num_pads != 1))
return; return;
return __media_pipeline_stop(entity); return __media_pipeline_stop(&entity->pads[0]);
} }
EXPORT_SYMBOL_GPL(__video_device_pipeline_stop); EXPORT_SYMBOL_GPL(__video_device_pipeline_stop);
...@@ -1150,7 +1150,7 @@ __must_check int video_device_pipeline_alloc_start(struct video_device *vdev) ...@@ -1150,7 +1150,7 @@ __must_check int video_device_pipeline_alloc_start(struct video_device *vdev)
if (entity->num_pads != 1) if (entity->num_pads != 1)
return -ENODEV; return -ENODEV;
return media_pipeline_alloc_start(entity); return media_pipeline_alloc_start(&entity->pads[0]);
} }
EXPORT_SYMBOL_GPL(video_device_pipeline_alloc_start); EXPORT_SYMBOL_GPL(video_device_pipeline_alloc_start);
...@@ -1161,7 +1161,7 @@ struct media_pipeline *video_device_pipeline(struct video_device *vdev) ...@@ -1161,7 +1161,7 @@ struct media_pipeline *video_device_pipeline(struct video_device *vdev)
if (WARN_ON(entity->num_pads != 1)) if (WARN_ON(entity->num_pads != 1))
return NULL; return NULL;
return media_entity_pipeline(entity); return media_pad_pipeline(&entity->pads[0]);
} }
EXPORT_SYMBOL_GPL(video_device_pipeline); EXPORT_SYMBOL_GPL(video_device_pipeline);
......
...@@ -863,16 +863,16 @@ int imx_media_pipeline_set_stream(struct imx_media_dev *imxmd, ...@@ -863,16 +863,16 @@ int imx_media_pipeline_set_stream(struct imx_media_dev *imxmd,
mutex_lock(&imxmd->md.graph_mutex); mutex_lock(&imxmd->md.graph_mutex);
if (on) { if (on) {
ret = __media_pipeline_start(entity, &imxmd->pipe); ret = __media_pipeline_start(entity->pads, &imxmd->pipe);
if (ret) if (ret)
goto out; goto out;
ret = v4l2_subdev_call(sd, video, s_stream, 1); ret = v4l2_subdev_call(sd, video, s_stream, 1);
if (ret) if (ret)
__media_pipeline_stop(entity); __media_pipeline_stop(entity->pads);
} else { } else {
v4l2_subdev_call(sd, video, s_stream, 0); v4l2_subdev_call(sd, video, s_stream, 0);
if (media_entity_pipeline(entity)) if (media_pad_pipeline(entity->pads))
__media_pipeline_stop(entity); __media_pipeline_stop(entity->pads);
} }
out: out:
......
...@@ -1115,66 +1115,66 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph); ...@@ -1115,66 +1115,66 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph);
/** /**
* media_pipeline_start - Mark a pipeline as streaming * media_pipeline_start - Mark a pipeline as streaming
* @entity: Starting entity * @pad: Starting pad
* @pipe: Media pipeline to be assigned to all entities in the pipeline. * @pipe: Media pipeline to be assigned to all pads in the pipeline.
* *
* Mark all entities connected to a given entity through enabled links, either * Mark all pads connected to a given pad through enabled links, either
* directly or indirectly, as streaming. The given pipeline object is assigned * directly or indirectly, as streaming. The given pipeline object is assigned
* to every entity in the pipeline and stored in the media_entity pipe field. * to every pad in the pipeline and stored in the media_pad pipe field.
* *
* Calls to this function can be nested, in which case the same number of * Calls to this function can be nested, in which case the same number of
* media_pipeline_stop() calls will be required to stop streaming. The * media_pipeline_stop() calls will be required to stop streaming. The
* pipeline pointer must be identical for all nested calls to * pipeline pointer must be identical for all nested calls to
* media_pipeline_start(). * media_pipeline_start().
*/ */
__must_check int media_pipeline_start(struct media_entity *entity, __must_check int media_pipeline_start(struct media_pad *pad,
struct media_pipeline *pipe); struct media_pipeline *pipe);
/** /**
* __media_pipeline_start - Mark a pipeline as streaming * __media_pipeline_start - Mark a pipeline as streaming
* *
* @entity: Starting entity * @pad: Starting pad
* @pipe: Media pipeline to be assigned to all entities in the pipeline. * @pipe: Media pipeline to be assigned to all pads in the pipeline.
* *
* ..note:: This is the non-locking version of media_pipeline_start() * ..note:: This is the non-locking version of media_pipeline_start()
*/ */
__must_check int __media_pipeline_start(struct media_entity *entity, __must_check int __media_pipeline_start(struct media_pad *pad,
struct media_pipeline *pipe); struct media_pipeline *pipe);
/** /**
* media_pipeline_stop - Mark a pipeline as not streaming * media_pipeline_stop - Mark a pipeline as not streaming
* @entity: Starting entity * @pad: Starting pad
* *
* Mark all entities connected to a given entity through enabled links, either * Mark all pads connected to a given pads through enabled links, either
* directly or indirectly, as not streaming. The media_entity pipe field is * directly or indirectly, as not streaming. The media_pad pipe field is
* reset to %NULL. * reset to %NULL.
* *
* If multiple calls to media_pipeline_start() have been made, the same * If multiple calls to media_pipeline_start() have been made, the same
* number of calls to this function are required to mark the pipeline as not * number of calls to this function are required to mark the pipeline as not
* streaming. * streaming.
*/ */
void media_pipeline_stop(struct media_entity *entity); void media_pipeline_stop(struct media_pad *pad);
/** /**
* __media_pipeline_stop - Mark a pipeline as not streaming * __media_pipeline_stop - Mark a pipeline as not streaming
* *
* @entity: Starting entity * @pad: Starting pad
* *
* .. note:: This is the non-locking version of media_pipeline_stop() * .. note:: This is the non-locking version of media_pipeline_stop()
*/ */
void __media_pipeline_stop(struct media_entity *entity); void __media_pipeline_stop(struct media_pad *pad);
/** /**
* media_pipeline_alloc_start - Mark a pipeline as streaming * media_pipeline_alloc_start - Mark a pipeline as streaming
* @entity: Starting entity * @pad: Starting pad
* *
* media_pipeline_alloc_start() is similar to media_pipeline_start() but instead * media_pipeline_alloc_start() is similar to media_pipeline_start() but instead
* of working on a given pipeline the function will use an existing pipeline if * of working on a given pipeline the function will use an existing pipeline if
* the entity is already part of a pipeline, or allocate a new pipeline. * the pad is already part of a pipeline, or allocate a new pipeline.
* *
* Calls to media_pipeline_alloc_start() must be matched with * Calls to media_pipeline_alloc_start() must be matched with
* media_pipeline_stop(). * media_pipeline_stop().
*/ */
__must_check int media_pipeline_alloc_start(struct media_entity *entity); __must_check int media_pipeline_alloc_start(struct media_pad *pad);
/** /**
* media_devnode_create() - creates and initializes a device node interface * media_devnode_create() - creates and initializes a device node interface
......
...@@ -548,7 +548,7 @@ static inline int video_is_registered(struct video_device *vdev) ...@@ -548,7 +548,7 @@ static inline int video_is_registered(struct video_device *vdev)
* *
* Mark all entities connected to a given video device through enabled links, * Mark all entities connected to a given video device through enabled links,
* either directly or indirectly, as streaming. The given pipeline object is * either directly or indirectly, as streaming. The given pipeline object is
* assigned to every entity in the pipeline and stored in the media_entity pipe * assigned to every pad in the pipeline and stored in the media_pad pipe
* field. * field.
* *
* Calls to this function can be nested, in which case the same number of * Calls to this function can be nested, in which case the same number of
...@@ -582,7 +582,7 @@ __must_check int __video_device_pipeline_start(struct video_device *vdev, ...@@ -582,7 +582,7 @@ __must_check int __video_device_pipeline_start(struct video_device *vdev,
* @vdev: Starting video device * @vdev: Starting video device
* *
* Mark all entities connected to a given video device through enabled links, * Mark all entities connected to a given video device through enabled links,
* either directly or indirectly, as not streaming. The media_entity pipe field * either directly or indirectly, as not streaming. The media_pad pipe field
* is reset to %NULL. * is reset to %NULL.
* *
* If multiple calls to media_pipeline_start() have been made, the same * If multiple calls to media_pipeline_start() have been made, the same
......
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