From patchwork Fri Oct 26 19:46:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 1658791 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id BA747DFABE for ; Sun, 28 Oct 2012 20:05:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48A7D9F396 for ; Sun, 28 Oct 2012 13:05:27 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 597 seconds by postgrey-1.32 at gabe; Fri, 26 Oct 2012 21:56:18 CEST Received: from hillosipuli.retiisi.org.uk (nblzone-211-213.nblnetworks.fi [83.145.211.213]) by gabe.freedesktop.org (Postfix) with ESMTP id F1CAD9E7D2 for ; Fri, 26 Oct 2012 12:56:18 -0700 (PDT) Received: from salottisipuli.retiisi.org.uk (salottisipuli.retiisi.org.uk [IPv6:2001:1bc8:102:6d9a::83:2]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 520A760099; Fri, 26 Oct 2012 22:46:18 +0300 (EEST) Received: by salottisipuli.retiisi.org.uk (Postfix, from userid 1000) id ACA4F20A7E; Fri, 26 Oct 2012 22:46:17 +0300 (EEST) From: Sakari Ailus To: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, alsa-devel@alsa-project.org 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 Message-Id: <1351280777-4936-1-git-send-email-sakari.ailus@iki.fi> X-Mailer: git-send-email 1.7.2.5 X-Mailman-Approved-At: Sun, 28 Oct 2012 13:04:09 -0700 Cc: laurent.pinchart@ideasonboard.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org 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 --- 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);