Commit 20b85227 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab
Browse files

[media] media: Rename graph and pipeline structs and functions



The media_entity_pipeline_start() and media_entity_pipeline_stop()
functions are renamed as media_pipeline_start() and media_pipeline_stop(),
respectively. The reason is two-fold: the pipeline struct is, rightly,
already called media_pipeline (rather than media_entity_pipeline) and what
this really is about is a pipeline. A pipeline consists of entities ---
and, well, other objects embedded in these entities.

As the pipeline object will be in the future moved from entities to pads
in order to support multiple pipelines through a single entity, do the
renaming now.

Similarly, functions operating on struct media_entity_graph as well as the
struct itself are renamed by dropping the "entity_" part from the prefix
of the function family and the data structure. The graph traversal which
is what the functions are about is not specifically about entities only
and will operate on pads for the same reason as the media pipeline.

The patch has been generated using the following command:

git grep -l media_entity |xargs perl -i -pe '
	s/media_entity_pipeline/media_pipeline/g;
	s/media_entity_graph/media_graph/g'

And a few manual edits related to line start alignment and line wrapping.

Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 12030f48
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -162,13 +162,13 @@ framework provides a depth-first graph traversal API for that purpose.
   currently defined as 16.

Drivers initiate a graph traversal by calling
:c:func:`media_entity_graph_walk_start()`
:c:func:`media_graph_walk_start()`

The graph structure, provided by the caller, is initialized to start graph
traversal at the given entity.

Drivers can then retrieve the next entity by calling
:c:func:`media_entity_graph_walk_next()`
:c:func:`media_graph_walk_next()`

When the graph traversal is complete the function will return ``NULL``.

@@ -206,7 +206,7 @@ Pipelines and media streams

When starting streaming, drivers must notify all entities in the pipeline to
prevent link states from being modified during streaming by calling
:c:func:`media_entity_pipeline_start()`.
:c:func:`media_pipeline_start()`.

The function will mark all entities connected to the given entity through
enabled links, either directly or indirectly, as streaming.
@@ -218,17 +218,17 @@ in higher-level pipeline structures and can then access the
pipeline through the struct :c:type:`media_entity`
pipe field.

Calls to :c:func:`media_entity_pipeline_start()` can be nested.
Calls to :c:func:`media_pipeline_start()` can be nested.
The pipeline pointer must be identical for all nested calls to the function.

:c:func:`media_entity_pipeline_start()` may return an error. In that case,
:c:func:`media_pipeline_start()` may return an error. In that case,
it will clean up any of the changes it did by itself.

When stopping the stream, drivers must notify the entities with
:c:func:`media_entity_pipeline_stop()`.
:c:func:`media_pipeline_stop()`.

If multiple calls to :c:func:`media_entity_pipeline_start()` have been
made the same number of :c:func:`media_entity_pipeline_stop()` calls
If multiple calls to :c:func:`media_pipeline_start()` have been
made the same number of :c:func:`media_pipeline_stop()` calls
are required to stop streaming.
The :c:type:`media_entity`.\ ``pipe`` field is reset to ``NULL`` on the last
nested stop call.
@@ -245,7 +245,7 @@ operation must be done with the media_device graph_mutex held.
Link validation
^^^^^^^^^^^^^^^

Link validation is performed by :c:func:`media_entity_pipeline_start()`
Link validation is performed by :c:func:`media_pipeline_start()`
for any entity which has sink pads in the pipeline. The
:c:type:`media_entity`.\ ``link_validate()`` callback is used for that
purpose. In ``link_validate()`` callback, entity driver should check
+4 −4
Original line number Diff line number Diff line
@@ -597,19 +597,19 @@ int __must_check media_device_register_entity(struct media_device *mdev,

	if (mdev->entity_internal_idx_max
	    >= mdev->pm_count_walk.ent_enum.idx_max) {
		struct media_entity_graph new = { .top = 0 };
		struct media_graph new = { .top = 0 };

		/*
		 * Initialise the new graph walk before cleaning up
		 * the old one in order not to spoil the graph walk
		 * object of the media device if graph walk init fails.
		 */
		ret = media_entity_graph_walk_init(&new, mdev);
		ret = media_graph_walk_init(&new, mdev);
		if (ret) {
			mutex_unlock(&mdev->graph_mutex);
			return ret;
		}
		media_entity_graph_walk_cleanup(&mdev->pm_count_walk);
		media_graph_walk_cleanup(&mdev->pm_count_walk);
		mdev->pm_count_walk = new;
	}
	mutex_unlock(&mdev->graph_mutex);
@@ -691,7 +691,7 @@ void media_device_cleanup(struct media_device *mdev)
{
	ida_destroy(&mdev->entity_internal_idx);
	mdev->entity_internal_idx_max = 0;
	media_entity_graph_walk_cleanup(&mdev->pm_count_walk);
	media_graph_walk_cleanup(&mdev->pm_count_walk);
	mutex_destroy(&mdev->graph_mutex);
}
EXPORT_SYMBOL_GPL(media_device_cleanup);
+38 −39
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ media_entity_other(struct media_entity *entity, struct media_link *link)
}

/* push an entity to traversal stack */
static void stack_push(struct media_entity_graph *graph,
static void stack_push(struct media_graph *graph,
		       struct media_entity *entity)
{
	if (graph->top == MEDIA_ENTITY_ENUM_MAX_DEPTH - 1) {
@@ -266,7 +266,7 @@ static void stack_push(struct media_entity_graph *graph,
	graph->stack[graph->top].entity = entity;
}

static struct media_entity *stack_pop(struct media_entity_graph *graph)
static struct media_entity *stack_pop(struct media_graph *graph)
{
	struct media_entity *entity;

@@ -285,34 +285,34 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph)
#define MEDIA_ENTITY_MAX_PADS		512

/**
 * media_entity_graph_walk_init - Allocate resources for graph walk
 * media_graph_walk_init - Allocate resources for graph walk
 * @graph: Media graph structure that will be used to walk the graph
 * @mdev: Media device
 *
 * Reserve resources for graph walk in media device's current
 * state. The memory must be released using
 * media_entity_graph_walk_free().
 * media_graph_walk_free().
 *
 * Returns error on failure, zero on success.
 */
__must_check int media_entity_graph_walk_init(
	struct media_entity_graph *graph, struct media_device *mdev)
__must_check int media_graph_walk_init(
	struct media_graph *graph, struct media_device *mdev)
{
	return media_entity_enum_init(&graph->ent_enum, mdev);
}
EXPORT_SYMBOL_GPL(media_entity_graph_walk_init);
EXPORT_SYMBOL_GPL(media_graph_walk_init);

/**
 * media_entity_graph_walk_cleanup - Release resources related to graph walking
 * media_graph_walk_cleanup - Release resources related to graph walking
 * @graph: Media graph structure that was used to walk the graph
 */
void media_entity_graph_walk_cleanup(struct media_entity_graph *graph)
void media_graph_walk_cleanup(struct media_graph *graph)
{
	media_entity_enum_cleanup(&graph->ent_enum);
}
EXPORT_SYMBOL_GPL(media_entity_graph_walk_cleanup);
EXPORT_SYMBOL_GPL(media_graph_walk_cleanup);

void media_entity_graph_walk_start(struct media_entity_graph *graph,
void media_graph_walk_start(struct media_graph *graph,
			    struct media_entity *entity)
{
	media_entity_enum_zero(&graph->ent_enum);
@@ -322,10 +322,9 @@ void media_entity_graph_walk_start(struct media_entity_graph *graph,
	graph->stack[graph->top].entity = NULL;
	stack_push(graph, entity);
}
EXPORT_SYMBOL_GPL(media_entity_graph_walk_start);
EXPORT_SYMBOL_GPL(media_graph_walk_start);

struct media_entity *
media_entity_graph_walk_next(struct media_entity_graph *graph)
struct media_entity *media_graph_walk_next(struct media_graph *graph)
{
	if (stack_top(graph) == NULL)
		return NULL;
@@ -364,30 +363,30 @@ media_entity_graph_walk_next(struct media_entity_graph *graph)

	return stack_pop(graph);
}
EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);
EXPORT_SYMBOL_GPL(media_graph_walk_next);

/* -----------------------------------------------------------------------------
 * Pipeline management
 */

__must_check int __media_entity_pipeline_start(struct media_entity *entity,
__must_check int __media_pipeline_start(struct media_entity *entity,
					struct media_pipeline *pipe)
{
	struct media_device *mdev = entity->graph_obj.mdev;
	struct media_entity_graph *graph = &pipe->graph;
	struct media_graph *graph = &pipe->graph;
	struct media_entity *entity_err = entity;
	struct media_link *link;
	int ret;

	if (!pipe->streaming_count++) {
		ret = media_entity_graph_walk_init(&pipe->graph, mdev);
		ret = media_graph_walk_init(&pipe->graph, mdev);
		if (ret)
			goto error_graph_walk_start;
	}

	media_entity_graph_walk_start(&pipe->graph, entity);
	media_graph_walk_start(&pipe->graph, entity);

	while ((entity = media_entity_graph_walk_next(graph))) {
	while ((entity = media_graph_walk_next(graph))) {
		DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS);
		DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS);

@@ -466,9 +465,9 @@ error:
	 * Link validation on graph failed. We revert what we did and
	 * return the error.
	 */
	media_entity_graph_walk_start(graph, entity_err);
	media_graph_walk_start(graph, entity_err);

	while ((entity_err = media_entity_graph_walk_next(graph))) {
	while ((entity_err = media_graph_walk_next(graph))) {
		/* Sanity check for negative stream_count */
		if (!WARN_ON_ONCE(entity_err->stream_count <= 0)) {
			entity_err->stream_count--;
@@ -486,35 +485,35 @@ error:

error_graph_walk_start:
	if (!--pipe->streaming_count)
		media_entity_graph_walk_cleanup(graph);
		media_graph_walk_cleanup(graph);

	return ret;
}
EXPORT_SYMBOL_GPL(__media_entity_pipeline_start);
EXPORT_SYMBOL_GPL(__media_pipeline_start);

__must_check int media_entity_pipeline_start(struct media_entity *entity,
__must_check int media_pipeline_start(struct media_entity *entity,
				      struct media_pipeline *pipe)
{
	struct media_device *mdev = entity->graph_obj.mdev;
	int ret;

	mutex_lock(&mdev->graph_mutex);
	ret = __media_entity_pipeline_start(entity, pipe);
	ret = __media_pipeline_start(entity, pipe);
	mutex_unlock(&mdev->graph_mutex);
	return ret;
}
EXPORT_SYMBOL_GPL(media_entity_pipeline_start);
EXPORT_SYMBOL_GPL(media_pipeline_start);

void __media_entity_pipeline_stop(struct media_entity *entity)
void __media_pipeline_stop(struct media_entity *entity)
{
	struct media_entity_graph *graph = &entity->pipe->graph;
	struct media_graph *graph = &entity->pipe->graph;
	struct media_pipeline *pipe = entity->pipe;


	WARN_ON(!pipe->streaming_count);
	media_entity_graph_walk_start(graph, entity);
	media_graph_walk_start(graph, entity);

	while ((entity = media_entity_graph_walk_next(graph))) {
	while ((entity = media_graph_walk_next(graph))) {
		/* Sanity check for negative stream_count */
		if (!WARN_ON_ONCE(entity->stream_count <= 0)) {
			entity->stream_count--;
@@ -524,20 +523,20 @@ void __media_entity_pipeline_stop(struct media_entity *entity)
	}

	if (!--pipe->streaming_count)
		media_entity_graph_walk_cleanup(graph);
		media_graph_walk_cleanup(graph);

}
EXPORT_SYMBOL_GPL(__media_entity_pipeline_stop);
EXPORT_SYMBOL_GPL(__media_pipeline_stop);

void media_entity_pipeline_stop(struct media_entity *entity)
void media_pipeline_stop(struct media_entity *entity)
{
	struct media_device *mdev = entity->graph_obj.mdev;

	mutex_lock(&mdev->graph_mutex);
	__media_entity_pipeline_stop(entity);
	__media_pipeline_stop(entity);
	mutex_unlock(&mdev->graph_mutex);
}
EXPORT_SYMBOL_GPL(media_entity_pipeline_stop);
EXPORT_SYMBOL_GPL(media_pipeline_stop);

/* -----------------------------------------------------------------------------
 * Module use count
+4 −4
Original line number Diff line number Diff line
@@ -536,7 +536,7 @@ static int fimc_capture_release(struct file *file)
	mutex_lock(&fimc->lock);

	if (close && vc->streaming) {
		media_entity_pipeline_stop(&vc->ve.vdev.entity);
		media_pipeline_stop(&vc->ve.vdev.entity);
		vc->streaming = false;
	}

@@ -1195,7 +1195,7 @@ static int fimc_cap_streamon(struct file *file, void *priv,
	if (fimc_capture_active(fimc))
		return -EBUSY;

	ret = media_entity_pipeline_start(entity, &vc->ve.pipe->mp);
	ret = media_pipeline_start(entity, &vc->ve.pipe->mp);
	if (ret < 0)
		return ret;

@@ -1229,7 +1229,7 @@ static int fimc_cap_streamon(struct file *file, void *priv,
	}

err_p_stop:
	media_entity_pipeline_stop(entity);
	media_pipeline_stop(entity);
	return ret;
}

@@ -1244,7 +1244,7 @@ static int fimc_cap_streamoff(struct file *file, void *priv,
	if (ret < 0)
		return ret;

	media_entity_pipeline_stop(&vc->ve.vdev.entity);
	media_pipeline_stop(&vc->ve.vdev.entity);
	vc->streaming = false;
	return 0;
}
+4 −4
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ static int isp_video_release(struct file *file)
	mutex_lock(&isp->video_lock);

	if (v4l2_fh_is_singular_file(file) && ivc->streaming) {
		media_entity_pipeline_stop(entity);
		media_pipeline_stop(entity);
		ivc->streaming = 0;
	}

@@ -489,7 +489,7 @@ static int isp_video_streamon(struct file *file, void *priv,
	struct media_entity *me = &ve->vdev.entity;
	int ret;

	ret = media_entity_pipeline_start(me, &ve->pipe->mp);
	ret = media_pipeline_start(me, &ve->pipe->mp);
	if (ret < 0)
		return ret;

@@ -504,7 +504,7 @@ static int isp_video_streamon(struct file *file, void *priv,
	isp->video_capture.streaming = 1;
	return 0;
p_stop:
	media_entity_pipeline_stop(me);
	media_pipeline_stop(me);
	return ret;
}

@@ -519,7 +519,7 @@ static int isp_video_streamoff(struct file *file, void *priv,
	if (ret < 0)
		return ret;

	media_entity_pipeline_stop(&video->ve.vdev.entity);
	media_pipeline_stop(&video->ve.vdev.entity);
	video->streaming = 0;
	return 0;
}
Loading