All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
	alsa-devel@alsa-project.org
Cc: laurent.pinchart@ideasonboard.com
Subject: [PATCH 1/1] media: Entities with sink pads must have at least one enabled link
Date: Fri, 26 Oct 2012 22:46:17 +0300	[thread overview]
Message-ID: <1351280777-4936-1-git-send-email-sakari.ailus@iki.fi> (raw)

If an entity has sink pads, at least one of them must be connected to
another pad with an enabled link. If a driver with multiple sink pads has
more strict requirements the check should be done in the driver itself.

Just requiring one sink pad is connected with an enabled link is enough
API-wise: entities with sink pads with only disabled links should not be
allowed to stream in the first place, but also in a different operation mode
a device might require only one of its pads connected with an active link.

If an entity has an ability to function as a source entity another logical
entity connected to the aforementioned one should be used for the purpose.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/media-entity.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index e1cd132..8846ea7 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -227,6 +227,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
 	media_entity_graph_walk_start(&graph, entity);
 
 	while ((entity = media_entity_graph_walk_next(&graph))) {
+		bool has_sink = false, active_sink = false;
 		unsigned int i;
 
 		entity->stream_count++;
@@ -243,18 +244,27 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
 		for (i = 0; i < entity->num_links; i++) {
 			struct media_link *link = &entity->links[i];
 
+			/* Are we the sink or not? */
+			if (link->sink->entity != entity)
+				continue;
+
+			has_sink = true;
+
 			/* Is this pad part of an enabled link? */
 			if (!(link->flags & MEDIA_LNK_FL_ENABLED))
 				continue;
 
-			/* Are we the sink or not? */
-			if (link->sink->entity != entity)
-				continue;
+			active_sink = true;
 
 			ret = entity->ops->link_validate(link);
 			if (ret < 0 && ret != -ENOIOCTLCMD)
 				goto error;
 		}
+
+		if (has_sink && !active_sink) {
+			ret = -EPIPE;
+			goto error;
+		}
 	}
 
 	mutex_unlock(&mdev->graph_mutex);
-- 
1.7.2.5


             reply	other threads:[~2012-10-26 19:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26 19:46 Sakari Ailus [this message]
2012-11-13 14:24 ` [PATCH 1/1] media: Entities with sink pads must have at least one enabled link Sakari Ailus
2012-11-14  9:23   ` Sylwester Nawrocki
2012-11-14 10:58     ` Laurent Pinchart
2012-11-14 21:15       ` Sakari Ailus
2012-11-14 21:13     ` Sakari Ailus
2012-11-15  0:46       ` Laurent Pinchart
2012-11-15 20:25         ` Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351280777-4936-1-git-send-email-sakari.ailus@iki.fi \
    --to=sakari.ailus@iki.fi \
    --cc=alsa-devel@alsa-project.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.