From patchwork Fri May 22 07:55:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11564911 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F4A4739 for ; Fri, 22 May 2020 07:56:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1EA6820757 for ; Fri, 22 May 2020 07:56:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Fd/Q1bBA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EA6820757 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+K1/BjPUbpcG9NkrRFo1y/gUly+WOSCTti3UmpdWltg=; b=Fd/Q1bBAEU5o97 npGyW3XVYb7E/sD9ki1fjMl4nNRmCkWO6A6QJyWO8yNUFXcwrGpzeQrAIcNWqoxxaCGMVT47Dftr5 tZm6daJ/4oCd/YBZcuQdl4t/zA9LlAFFDT/M08Q2mseUBMzuOEd5ADnsBCdH9NgdpjJ9suE816lmK INSGTAhXYQWhw/aFLoHKX4HYnTFw89NQ3HA3fr5bQJx/wWyAPL70vigtLNbD31+J1Nxr5dF0ohe+q PNR7FDr52SAlwL/s7i59lBDXRu98uQHv5EA1Jfssso8ZO82eZ2ZEvDpu2+Ua9/d/yPc8znHJiX2UA j/KJaXQKBPPH4aGUECdg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jc2XO-0000kq-3Z; Fri, 22 May 2020 07:56:14 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jc2XK-0000iU-LN for linux-rockchip@lists.infradead.org; Fri, 22 May 2020 07:56:12 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 443A22A3537 From: Dafna Hirschfeld To: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com Subject: [PATCH v4 1/5] media: mc-entity.c: add media_graph_walk_next_stream() Date: Fri, 22 May 2020 09:55:18 +0200 Message-Id: <20200522075522.6190-2-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522075522.6190-1-dafna.hirschfeld@collabora.com> References: <20200522075522.6190-1-dafna.hirschfeld@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200522_005610_827908_3E5B266E X-CRM114-Status: GOOD ( 11.62 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: niklas.soderlund@ragnatech.se--annotate, mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, sakari.ailus@linux.intel.com, skhan@linuxfoundation.org, kernel@collabora.com, ezequiel@collabora.com Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org From: Helen Koike Add media_graph_walk_next_stream() function to follow links only from sink to source (not the opposite) to allow iteration only through the entities participating in a given stream. This is useful to allow calling .s_stream() callback only in the subdevices that requires to be enabled/disabled, and avoid calling this callback when not required. Signed-off-by: Helen Koike Reviewed-by: Niklas Söderlund [Dafna: fixing coding style issues] Signed-off-by: Dafna Hirschfeld --- drivers/media/mc/mc-entity.c | 34 +++++++++++++++++++++++++++++++--- include/media/media-entity.h | 15 +++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 12b45e669bcc..555f9dd9f7f2 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -228,6 +228,11 @@ EXPORT_SYMBOL_GPL(media_entity_pads_init); * Graph traversal */ +enum media_graph_walk_type { + MEDIA_GRAPH_WALK_CONNECTED_NODES, + MEDIA_GRAPH_WALK_STREAM_NODES, +}; + static struct media_entity * media_entity_other(struct media_entity *entity, struct media_link *link) { @@ -305,7 +310,8 @@ void media_graph_walk_start(struct media_graph *graph, } EXPORT_SYMBOL_GPL(media_graph_walk_start); -static void media_graph_walk_iter(struct media_graph *graph) +static void media_graph_walk_iter(struct media_graph *graph, + enum media_graph_walk_type type) { struct media_entity *entity = stack_top(graph); struct media_link *link; @@ -326,6 +332,15 @@ static void media_graph_walk_iter(struct media_graph *graph) /* Get the entity in the other end of the link . */ next = media_entity_other(entity, link); + if (type == MEDIA_GRAPH_WALK_STREAM_NODES && + next == link->sink->entity) { + link_top(graph) = link_top(graph)->next; + dev_dbg(entity->graph_obj.mdev->dev, + "walk: skipping '%s' (outside of the stream path)\n", + link->sink->entity->name); + return; + } + /* Has the entity already been visited? */ if (media_entity_enum_test_and_set(&graph->ent_enum, next)) { link_top(graph) = link_top(graph)->next; @@ -342,7 +357,9 @@ static void media_graph_walk_iter(struct media_graph *graph) next->name); } -struct media_entity *media_graph_walk_next(struct media_graph *graph) +static struct media_entity * +__media_graph_walk_next(struct media_graph *graph, + enum media_graph_walk_type type) { struct media_entity *entity; @@ -355,7 +372,7 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph) * found. */ while (link_top(graph) != &stack_top(graph)->links) - media_graph_walk_iter(graph); + media_graph_walk_iter(graph, type); entity = stack_pop(graph); dev_dbg(entity->graph_obj.mdev->dev, @@ -363,8 +380,19 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph) return entity; } + +struct media_entity *media_graph_walk_next(struct media_graph *graph) +{ + return __media_graph_walk_next(graph, MEDIA_GRAPH_WALK_CONNECTED_NODES); +} EXPORT_SYMBOL_GPL(media_graph_walk_next); +struct media_entity *media_graph_walk_next_stream(struct media_graph *graph) +{ + return __media_graph_walk_next(graph, MEDIA_GRAPH_WALK_STREAM_NODES); +} +EXPORT_SYMBOL_GPL(media_graph_walk_next_stream); + int media_entity_get_fwnode_pad(struct media_entity *entity, struct fwnode_handle *fwnode, unsigned long direction_flags) diff --git a/include/media/media-entity.h b/include/media/media-entity.h index cde80ad029b7..9035a36e9442 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -928,6 +928,21 @@ void media_graph_walk_start(struct media_graph *graph, */ struct media_entity *media_graph_walk_next(struct media_graph *graph); +/** + * media_graph_walk_next_stream - Get the next entity in the graph + * @graph: Media graph structure + * + * Perform a depth-first traversal of the given media entities graph only + * following links from sink to source (and not the opposite). + * + * The graph structure must have been previously initialized with a call to + * media_graph_walk_start(). + * + * Return: returns the next entity in the graph in the stream path + * or %NULL if the whole stream path have been traversed. + */ +struct media_entity *media_graph_walk_next_stream(struct media_graph *graph); + /** * media_pipeline_start - Mark a pipeline as streaming * @entity: Starting entity