Linux Renesas SOC kernel development
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
Cc: "Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	linux-media@vger.kernel.org,
	"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
	linux-renesas-soc@vger.kernel.org,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: Re: [PATCH v2 2/2] media: entity: Add media_entity_pad_from_fwnode() function
Date: Wed, 24 May 2017 16:27:42 +0300	[thread overview]
Message-ID: <20170524132741.GL29527@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <20170524000907.13061-3-niklas.soderlund@ragnatech.se>

Hi Niklas,

On Wed, May 24, 2017 at 02:09:07AM +0200, Niklas S�derlund wrote:
> From: Niklas S�derlund <niklas.soderlund+renesas@ragnatech.se>
> 
> This is a wrapper around the media entity pad_from_fwnode operation.
> 
> Signed-off-by: Niklas S�derlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/media/media-entity.c | 39 +++++++++++++++++++++++++++++++++++++++
>  include/media/media-entity.h | 22 ++++++++++++++++++++++
>  2 files changed, 61 insertions(+)
> 
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index bc44193efa4798b4..c124754f739a8b94 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -18,6 +18,7 @@
>  
>  #include <linux/bitmap.h>
>  #include <linux/module.h>
> +#include <linux/property.h>
>  #include <linux/slab.h>
>  #include <media/media-entity.h>
>  #include <media/media-device.h>
> @@ -386,6 +387,44 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph)
>  }
>  EXPORT_SYMBOL_GPL(media_graph_walk_next);
>  
> +int media_entity_pad_from_fwnode(struct media_entity *entity,
> +				 struct fwnode_handle *fwnode,
> +				 int direction, unsigned int *pad)
> +{
> +	struct fwnode_endpoint endpoint;
> +	int i, tmp, ret;
> +
> +	if (!entity->ops || !entity->ops->pad_from_fwnode) {
> +		for (i = 0; i < entity->num_pads; i++) {
> +			if (entity->pads[i].flags & direction) {
> +				*pad = i;
> +				return 0;
> +			}
> +		}
> +
> +		return -ENXIO;
> +	}
> +
> +	ret = fwnode_graph_parse_endpoint(fwnode, &endpoint);
> +	if (ret)
> +		return ret;
> +
> +	ret = entity->ops->pad_from_fwnode(&endpoint, &tmp);
> +	if (ret)
> +		return ret;
> +
> +	if (tmp >= entity->num_pads)
> +		return -ENXIO;
> +
> +	if (!(entity->pads[tmp].flags & direction))
> +		return -ENXIO;
> +
> +	*pad = tmp;
> +
> +	return 0;

I'd just return the pad number to the caller.

> +}
> +EXPORT_SYMBOL_GPL(media_entity_pad_from_fwnode);
> +
>  /* -----------------------------------------------------------------------------
>   * Pipeline management
>   */
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 2aea22b0409d1070..7507181609bec43c 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -822,6 +822,28 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad);
>  struct media_entity *media_entity_get(struct media_entity *entity);
>  
>  /**
> + * media_entity_pad_from_fwnode - Get pad number from fwnode
> + *
> + * @entity: The entity
> + * @fwnode: Pointer to fwnode_handle which should be used to find pad
> + * @direction: Expected direction of the pad

You should document the possible values for this. What would you think about
using a bool called e.g. is_sink? I don't have a strong opinion either way
though.

> + * @pad: Pointer to pad which will should be filled in
> + *
> + * This function can be used to resolve the media pad number from
> + * a fwnode. This is useful for devices which uses more complex
> + * mappings of media pads.
> + *
> + * If the entity do not implement the pad_from_fwnode() operation
> + * this function searches the entity for the first pad that matches
> + * the @direction.
> + *
> + * Return: return 0 on success.
> + */
> +int media_entity_pad_from_fwnode(struct media_entity *entity,
> +				 struct fwnode_handle *fwnode,
> +				 int direction, unsigned int *pad);
> +
> +/**
>   * media_graph_walk_init - Allocate resources used by graph walk.
>   *
>   * @graph: Media graph structure that will be used to walk the graph

-- 
Regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

  reply	other threads:[~2017-05-24 13:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24  0:09 [PATCH v2 0/2] media: entity: add operation to help map DT node to media pad Niklas Söderlund
2017-05-24  0:09 ` [PATCH v2 1/2] media: entity: Add pad_from_fwnode entity operation Niklas Söderlund
2017-05-24 13:21   ` Sakari Ailus
2017-05-24 14:07     ` Niklas Söderlund
2017-05-26 21:52       ` Sakari Ailus
2017-05-24  0:09 ` [PATCH v2 2/2] media: entity: Add media_entity_pad_from_fwnode() function Niklas Söderlund
2017-05-24 13:27   ` Sakari Ailus [this message]
2017-05-24 14:09     ` Niklas Söderlund
2017-05-29 10:32   ` Hans Verkuil

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=20170524132741.GL29527@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=niklas.soderlund@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox