From patchwork Tue Jul 19 14:20:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9237559 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6C36B6075D for ; Tue, 19 Jul 2016 14:23:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CBCD27165 for ; Tue, 19 Jul 2016 14:23:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 511A02787C; Tue, 19 Jul 2016 14:23:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E54CF27165 for ; Tue, 19 Jul 2016 14:23:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753804AbcGSOXK (ORCPT ); Tue, 19 Jul 2016 10:23:10 -0400 Received: from smtp-4.sys.kth.se ([130.237.48.193]:55994 "EHLO smtp-4.sys.kth.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753497AbcGSOXJ (ORCPT ); Tue, 19 Jul 2016 10:23:09 -0400 Received: from smtp-4.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-4.sys.kth.se (Postfix) with ESMTP id BDA242AAB; Tue, 19 Jul 2016 16:23:07 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-4.sys.kth.se ([127.0.0.1]) by smtp-4.sys.kth.se (smtp-4.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7Wxa6kghIH-Z; Tue, 19 Jul 2016 16:23:07 +0200 (CEST) X-KTH-Auth: niso [89.233.230.99] X-KTH-mail-from: niklas.soderlund+renesas@ragnatech.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by smtp-4.sys.kth.se (Postfix) with ESMTPSA id AF5BA321; Tue, 19 Jul 2016 16:23:06 +0200 (CEST) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: linux-media@vger.kernel.org, ulrich.hecht@gmail.com, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com Cc: linux-renesas-soc@vger.kernel.org, Michal Simek , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCHv2 02/16] media: entity: Add media_entity_has_route() function Date: Tue, 19 Jul 2016 16:20:53 +0200 Message-Id: <20160719142107.22358-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160719142107.22358-1-niklas.soderlund+renesas@ragnatech.se> References: <20160719142107.22358-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Pinchart This is a wrapper around the media entity has_route operation. Signed-off-by: Laurent Pinchart Signed-off-by: Michal Simek Signed-off-by: Niklas Söderlund --- drivers/media/media-entity.c | 29 +++++++++++++++++++++++++++++ include/media/media-entity.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index d8a2299..8732579 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -240,6 +240,35 @@ EXPORT_SYMBOL_GPL(media_entity_pads_init); * Graph traversal */ +/** + * media_entity_has_route - Check if two entity pads are connected internally + * @entity: The entity + * @pad0: The first pad index + * @pad1: The second pad index + * + * This function can be used to check whether two pads of an entity are + * connected internally in the entity. + * + * The caller must hold entity->source->parent->mutex. + * + * Return: true if the pads are connected internally and false otherwise. + */ +bool media_entity_has_route(struct media_entity *entity, unsigned int pad0, + unsigned int pad1) +{ + if (pad0 >= entity->num_pads || pad1 >= entity->num_pads) + return false; + + if (pad0 == pad1) + return true; + + if (!entity->ops || !entity->ops->has_route) + return true; + + return entity->ops->has_route(entity, pad0, pad1); +} +EXPORT_SYMBOL_GPL(media_entity_has_route); + static struct media_entity * media_entity_other(struct media_entity *entity, struct media_link *link) { diff --git a/include/media/media-entity.h b/include/media/media-entity.h index c4b2dca..68af160 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -796,6 +796,9 @@ void media_entity_graph_walk_cleanup(struct media_entity_graph *graph); */ void media_entity_put(struct media_entity *entity); +bool media_entity_has_route(struct media_entity *entity, unsigned int sink, + unsigned int source); + /** * media_entity_graph_walk_start - Start walking the media graph at a given entity * @graph: Media graph structure that will be used to walk the graph