From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Helen Koike <helen.koike@collabora.com>
Cc: linux-media@vger.kernel.org, kernel@collabora.com,
linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
hans.verkuil@cisco.com, skhan@linuxfoundation.org,
mchehab@kernel.org
Subject: Re: [PATCH v3 1/4] media: mc-entity.c: add media_graph_walk_next_stream()
Date: Fri, 24 Apr 2020 15:46:09 +0200 [thread overview]
Message-ID: <20200424134609.GD4040416@oden.dyn.berto.se> (raw)
In-Reply-To: <20200415013044.1778572-2-helen.koike@collabora.com>
Hi Helen,
Thanks for your work.
On 2020-04-14 22:30:41 -0300, Helen Koike wrote:
> 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 <helen.koike@collabora.com>
>
> ---
>
> Changes in v3:
> - Patch re-added in the series from version 1
>
> Changes in v2: None
>
> 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 211279c5fd77d..0d44c2de23e6f 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);
One space to much after the ','. With this fixed,
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> +}
> +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 8cb2c504a05c7..f17a5180ce524 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -927,6 +927,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
> --
> 2.26.0
>
--
Regards,
Niklas Söderlund
next prev parent reply other threads:[~2020-04-24 13:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 1:30 [PATCH v3 0/4] media: add v4l2_pipeline_stream_{enable,disable} helpers Helen Koike
2020-04-15 1:30 ` [PATCH v3 1/4] media: mc-entity.c: add media_graph_walk_next_stream() Helen Koike
2020-04-24 13:46 ` Niklas Söderlund [this message]
2020-04-15 1:30 ` [PATCH v3 2/4] media: v4l2-common: add helper functions to call s_stream() callbacks Helen Koike
2020-04-24 13:41 ` Niklas Söderlund
2020-04-27 13:49 ` Helen Koike
2020-05-21 12:03 ` Dafna Hirschfeld
2020-05-21 12:53 ` Helen Koike
2020-04-15 1:30 ` [PATCH v3 3/4] media: staging: rkisp1: use v4l2_pipeline_stream_{enable,disable} helpers Helen Koike
2020-04-24 13:42 ` Niklas Söderlund
2020-04-15 1:30 ` [PATCH v3 4/4] media: vimc: " Helen Koike
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=20200424134609.GD4040416@oden.dyn.berto.se \
--to=niklas.soderlund@ragnatech.se \
--cc=hans.verkuil@cisco.com \
--cc=helen.koike@collabora.com \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=skhan@linuxfoundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).