All of lore.kernel.org
 help / color / mirror / Atom feed
From: jacopo mondi <jacopo@jmondi.org>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 15/30] media: entity: Look for indirect routes
Date: Fri, 28 Sep 2018 18:58:52 +0200	[thread overview]
Message-ID: <20180928165852.GD20786@w540> (raw)
In-Reply-To: <20180823132544.521-16-niklas.soderlund+renesas@ragnatech.se>

[-- Attachment #1: Type: text/plain, Size: 3521 bytes --]

Hi Sakari,

On Thu, Aug 23, 2018 at 03:25:29PM +0200, Niklas Söderlund wrote:
> From: Sakari Ailus <sakari.ailus@linux.intel.com>
>
> Two pads are considered having an active route for the purpose of
> has_route() if an indirect active route can be found between the two pads.
> An simple example of this is that a source pad has an active route to
> another source pad if both of the pads have an active route to the same
> sink pad.
>
> Make media_entity_has_route() return true in that case, and do not rely on
> drivers performing this by themselves.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/media-entity.c | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index 3912bc75651fe0b7..29e732a130667ae9 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -240,6 +240,9 @@ EXPORT_SYMBOL_GPL(media_entity_pads_init);
>  bool media_entity_has_route(struct media_entity *entity, unsigned int pad0,
>  			    unsigned int pad1)
>  {
> +	unsigned int i;
> +	bool has_route;
> +
>  	if (pad0 >= entity->num_pads || pad1 >= entity->num_pads)
>  		return false;
>
> @@ -253,7 +256,34 @@ bool media_entity_has_route(struct media_entity *entity, unsigned int pad0,
>  	    && entity->pads[pad1].flags & MEDIA_PAD_FL_SINK)
>  		swap(pad0, pad1);
>
> -	return entity->ops->has_route(entity, pad0, pad1);
> +	has_route = entity->ops->has_route(entity, pad0, pad1);
> +	/* A direct route is returned immediately */
> +	if (has_route ||
> +	    (entity->pads[pad0].flags & MEDIA_PAD_FL_SINK &&
> +	     entity->pads[pad1].flags & MEDIA_PAD_FL_SOURCE))

I'm not sure I get why you're using the || condition here.

I suspect it is in order to make sure the driver implementation of
ops->has_route() only checks for direct links, but wouldn't it be
better to clarify the function semantics instead of catching
'non-direct' routes returned here?

More generally, why not call ops->has_route() only in case pad0 and
pad1 have different type, and check for indirect links otherwise?

> +		return true;
> +
> +	/* Look for indirect routes */
> +	for (i = 0; i < entity->num_pads; i++) {
> +		if (i == pad0 || i == pad1)
> +			continue;

This is correct, but the following check catches this condition as
well I think.

I assume if we fall down here pad0 and pad1 are of the same type and
if 'i' is one of the two pads it will have the same type as pad0, and
you're checking for this here below.

> +
> +		/*
> +		 * There are no direct routes between same types of
> +		 * pads, so skip checking this route
> +		 */
> +		if (!((entity->pads[pad0].flags ^ entity->pads[i].flags) &
> +		      (MEDIA_PAD_FL_SOURCE | MEDIA_PAD_FL_SINK)))
> +			continue;
> +
> +		/* Is there an indirect route? */
> +		if (entity->ops->has_route(entity, i, pad0) &&
> +		    entity->ops->has_route(entity, i, pad1))

What guarantees here that i is a sink and pad0/pad1 are sources? It seems
the 'has_route' operation wants this, otherwise I don't see a reason
for "[PATCH 09/30] media: entity: Swap pads if route is checked from
source to sink". Did I miss something from that patch?

Sorry, lot of questions. I might be confused :/
Thanks
   j

> +			return true;
> +	}
> +
> +	return false;
> +
>  }
>  EXPORT_SYMBOL_GPL(media_entity_has_route);
>
> --
> 2.18.0
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2018-09-28 23:23 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23 13:25 [PATCH 00/30] v4l: add support for multiplexed streams Niklas Söderlund
2018-08-23 13:25 ` [PATCH 01/30] media: entity: Use pad as a starting point for graph walk Niklas Söderlund
2018-08-23 13:25 ` [PATCH 02/30] media: entity: Use pads instead of entities in the media graph walk stack Niklas Söderlund
2018-08-23 13:25 ` [PATCH 03/30] media: entity: Walk the graph based on pads Niklas Söderlund
2018-08-23 13:25 ` [PATCH 04/30] v4l: mc: Start walk from a specific pad in use count calculation Niklas Söderlund
2018-08-23 13:25 ` [PATCH 05/30] media: entity: Move the pipeline from entity to pads Niklas Söderlund
2018-08-23 13:25 ` [PATCH 06/30] media: entity: Use pad as the starting point for a pipeline Niklas Söderlund
2018-08-23 13:25 ` [PATCH 07/30] media: entity: Add has_route entity operation Niklas Söderlund
2018-09-27 12:58   ` jacopo mondi
2018-08-23 13:25 ` [PATCH 08/30] media: entity: Add media_has_route() function Niklas Söderlund
2018-08-23 13:25 ` [PATCH 09/30] media: entity: Swap pads if route is checked from source to sink Niklas Söderlund
2018-08-23 13:25 ` [PATCH 10/30] media: entity: Use routing information during graph traversal Niklas Söderlund
2018-08-23 13:25 ` [PATCH 11/30] media: entity: Skip link validation for pads to which there is no route to Niklas Söderlund
2018-08-23 13:25 ` [PATCH 12/30] media: entity: Add an iterator helper for connected pads Niklas Söderlund
2018-08-23 13:25 ` [PATCH 13/30] media: entity: Add only connected pads to the pipeline Niklas Söderlund
2018-08-23 13:25 ` [PATCH 14/30] media: entity: Add debug information in graph walk route check Niklas Söderlund
2018-08-23 13:25 ` [PATCH 15/30] media: entity: Look for indirect routes Niklas Söderlund
2018-09-28 16:58   ` jacopo mondi [this message]
2018-08-23 13:25 ` [PATCH 16/30] v4l: subdev: Add [GS]_ROUTING subdev ioctls and operations Niklas Söderlund
2018-08-23 13:25 ` [PATCH 17/30] v4l: subdev: compat: Implement handling for VIDIOC_SUBDEV_[GS]_ROUTING Niklas Söderlund
2018-08-23 13:25 ` [PATCH 18/30] v4l: subdev: Take routing information into account in link validation Niklas Söderlund
2018-08-23 13:25 ` [PATCH 19/30] v4l: subdev: Improve link format validation debug messages Niklas Söderlund
2018-08-23 13:25 ` [PATCH 20/30] v4l: mc: Add an S_ROUTING helper function for power state changes Niklas Söderlund
2018-08-23 13:25 ` [PATCH 21/30] v4l: Add bus type to frame descriptors Niklas Söderlund
2018-11-02 12:27   ` Kieran Bingham
2018-11-02 13:15     ` Sakari Ailus
2018-11-02 13:15       ` Sakari Ailus
2018-11-02 13:35       ` Kieran Bingham
2018-11-02 14:18         ` Sakari Ailus
2018-11-02 14:18           ` Sakari Ailus
2018-11-02 14:40           ` Kieran Bingham
2018-08-23 13:25 ` [PATCH 22/30] v4l: Add CSI-2 bus configuration " Niklas Söderlund
2018-08-23 13:25 ` [PATCH 23/30] v4l: Add stream to frame descriptor Niklas Söderlund
2018-08-23 13:25 ` [PATCH 24/30] adv748x: csi2: add translation from pixelcode to CSI-2 datatype Niklas Söderlund
2018-08-23 13:25 ` [PATCH 25/30] adv748x: csi2: only allow formats on sink pads Niklas Söderlund
2018-08-23 13:25 ` [PATCH 26/30] adv748x: csi2: describe the multiplexed stream Niklas Söderlund
2018-08-23 13:25 ` [PATCH 27/30] adv748x: csi2: add internal routing configuration Niklas Söderlund
2018-08-23 13:25 ` [PATCH 28/30] adv748x: afe: add routing support Niklas Söderlund
2018-08-23 13:25 ` [PATCH 29/30] rcar-csi2: use frame description information to configure CSI-2 bus Niklas Söderlund
2018-09-24 14:39   ` Kieran Bingham
2018-09-26 14:23     ` Niklas Söderlund
2018-09-26 14:23       ` Niklas Söderlund
2018-08-23 13:25 ` [PATCH 30/30] rcar-csi2: expose the subdevice internal routing Niklas Söderlund
2018-08-27 11:50 ` [PATCH 00/30] v4l: add support for multiplexed streams Sakari Ailus
2018-08-27 11:50   ` Sakari Ailus
2018-08-27 13:11   ` Niklas Söderlund
2018-08-27 13:11     ` Niklas Söderlund

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=20180928165852.GD20786@w540 \
    --to=jacopo@jmondi.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=sakari.ailus@linux.intel.com \
    /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.