linux-stable/drivers/media/mc
Laurent Pinchart 3056a8e936 media: media-entity: Simplify media_pipeline_start()
The media_pipeline_start() function has two purposes: it constructs a
pipeline by recording the entities that are part of it, gathered from a
graph walk, and validate the media links. The pipeline pointer is stored
in the media_entity structure as part of this process, and the entity's
stream count is increased, to record that the entity is streaming.

When multiple video nodes are present in a pipeline,
media_pipeline_start() is typically called on all of them, with the same
pipeline pointer. This is taken into account in media_pipeline_start()
by skipping validation for entities that are already part of the
pipeline, while returning an error if an entity is part of a different
pipeline.

It turns out that this process is overly complicated. When
media_pipeline_start() is called for the first time, it constructs the
full pipeline, adding all entities and validating all the links.
Subsequent calls to media_pipeline_start() are then nearly no-ops, they
only increase the stream count on the pipeline and on all entities.

The media_entity stream_count field is used for two purposes: checking
if the entity is streaming, and detecting when a call to
media_pipeline_stop() balances needs to reset the entity pipe pointer to
NULL. The former can easily be replaced by a check of the pipe pointer.

Simplify media_pipeline_start() by avoiding the pipeline walk on all
calls but the first one, and drop the media_entity stream_count field.
media_pipeline_stop() is updated accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Sakari Ailus: Drop redundant '!= NULL' as discussed]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
2022-03-04 00:27:06 +02:00
..
Kconfig media: Request API is no longer experimental 2021-09-30 10:07:55 +02:00
Makefile media: Fix Media Controller API config checks 2021-06-24 14:26:00 +02:00
mc-dev-allocator.c
mc-device.c media: mc-device.c: use DEVICE_ATTR_RO() helper macro 2021-08-04 14:43:50 +02:00
mc-devnode.c all: replace find_next{,_zero}_bit with find_first{,_zero}_bit where appropriate 2022-01-15 08:47:31 -08:00
mc-entity.c media: media-entity: Simplify media_pipeline_start() 2022-03-04 00:27:06 +02:00
mc-request.c media: mc-request.c: allow object_bind in QUEUED state 2021-06-02 11:41:54 +02:00