diff mbox series

[13/30] media: entity: Add only connected pads to the pipeline

Message ID 20180823132544.521-14-niklas.soderlund+renesas@ragnatech.se (mailing list archive)
State New, archived
Headers show
Series v4l: add support for multiplexed streams | expand

Commit Message

Niklas Söderlund Aug. 23, 2018, 1:25 p.m. UTC
From: Sakari Ailus <sakari.ailus@linux.intel.com>

A single entity may contain multiple pipelines. Only add pads that were
connected to the pad through which the entity was reached to the pipeline.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/media-entity.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 0395d58b2e233d88..c11cf684b336f87e 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -460,15 +460,13 @@  __must_check int __media_pipeline_start(struct media_pad *pad,
 
 	while ((pad = media_graph_walk_next(graph))) {
 		struct media_entity *entity = pad->entity;
-		unsigned int i;
+		struct media_pad *iter;
 		bool skip_validation = pad->pipe;
 
 		DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS);
 		DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS);
 
-		for (i = 0; i < entity->num_pads; i++) {
-			struct media_pad *iter = &entity->pads[i];
-
+		media_entity_for_routed_pads(pad, iter) {
 			if (iter->pipe && WARN_ON(iter->pipe != pipe))
 				ret = -EBUSY;
 			else
@@ -553,12 +551,9 @@  __must_check int __media_pipeline_start(struct media_pad *pad,
 	media_graph_walk_start(graph, pad_err);
 
 	while ((pad_err = media_graph_walk_next(graph))) {
-		struct media_entity *entity_err = pad_err->entity;
-		unsigned int i;
-
-		for (i = 0; i < entity_err->num_pads; i++) {
-			struct media_pad *iter = &entity_err->pads[i];
+		struct media_pad *iter;
 
+		media_entity_for_routed_pads(pad_err, iter) {
 			/* Sanity check for negative stream_count */
 			if (!WARN_ON_ONCE(iter->stream_count <= 0)) {
 				--iter->stream_count;
@@ -611,12 +606,9 @@  void __media_pipeline_stop(struct media_pad *pad)
 	media_graph_walk_start(graph, pad);
 
 	while ((pad = media_graph_walk_next(graph))) {
-		struct media_entity *entity = pad->entity;
-		unsigned int i;
-
-		for (i = 0; i < entity->num_pads; i++) {
-			struct media_pad *iter = &entity->pads[i];
+		struct media_pad *iter;
 
+		media_entity_for_routed_pads(pad, iter) {
 			/* Sanity check for negative stream_count */
 			if (!WARN_ON_ONCE(iter->stream_count <= 0)) {
 				iter->stream_count--;