All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] media: entity: add operation to help map DT node to media pad
@ 2017-06-15  9:17 Niklas Söderlund
  2017-06-15  9:17 ` [PATCH v4 1/2] media: entity: Add get_fwnode_pad entity operation Niklas Söderlund
  2017-06-15  9:17 ` [PATCH v4 2/2] media: entity: Add media_entity_get_fwnode_pad() function Niklas Söderlund
  0 siblings, 2 replies; 4+ messages in thread
From: Niklas Söderlund @ 2017-06-15  9:17 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Sakari Ailus, linux-media, Hans Verkuil
  Cc: Kieran Bingham, linux-renesas-soc, Laurent Pinchart,
	Niklas Söderlund

Hi,

This series add a new entity operation which will aid capture
drivers to map a port/endpoint in DT to a media graph pad.

This series is implemented support for the ongoing ADV748x work by
Kieran Bingham. In his work he have a driver which registers more then
one subdevice. So when a driver finds this subdevice it must be able to
ask the subdevice itself which pad number correspond to the DT endpoint
the driver used to bind subdevice in the first place.

This is tested on Renesas H3 and M3-W together with the Renesas CSI-2
and VIN Gen3 driver (posted separately). It is based on top media-tree.

* Changes since v3
- Rename argument direction to direction_flags and changed type from 
  unsigned int to unsigned long for media_entity_get_fwnode_pad().
- Changed loop data type from int to unsigned int.
- Added Acked-by from Sakari, thanks!

* Changes since v2
- Renamed pad_from_fwnode to get_fwnode_pad as suggested by Sakari.
- Return pad number instead of passing it as a pointer to both
  get_fwnode_pad() and media_entity_pad_from_fwnode().
- Document possible flags of the direction argument to
  media_entity_pad_from_fwnode().
- Use unsigned int instead of int for bitmask.
- Fix numerous spelling mistakes, thanks Hans!
- Rebased to latest media-tree.

* Changes since v1
- Rebased work ontop of Sakaris fwnode branch and make use of the fwnode
  instead of the raw DT port/reg numbers.
- Do not assume DT port is equal to pad number if the driver do not
  implement the lookup function. Instead search for the first pad with
  the correct direction and use that. Thanks Sakari for the suggestion!
- Use ENXIO instead of EINVAL to signal lookup error.

Niklas Söderlund (2):
  media: entity: Add get_fwnode_pad entity operation
  media: entity: Add media_entity_get_fwnode_pad() function

 drivers/media/media-entity.c | 36 ++++++++++++++++++++++++++++++++++++
 include/media/media-entity.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

-- 
2.13.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v4 1/2] media: entity: Add get_fwnode_pad entity operation
  2017-06-15  9:17 [PATCH v4 0/2] media: entity: add operation to help map DT node to media pad Niklas Söderlund
@ 2017-06-15  9:17 ` Niklas Söderlund
  2017-06-15  9:17 ` [PATCH v4 2/2] media: entity: Add media_entity_get_fwnode_pad() function Niklas Söderlund
  1 sibling, 0 replies; 4+ messages in thread
From: Niklas Söderlund @ 2017-06-15  9:17 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Sakari Ailus, linux-media, Hans Verkuil
  Cc: Kieran Bingham, linux-renesas-soc, Laurent Pinchart,
	Niklas Söderlund

The optional operation can be used by entities to report how it maps its
fwnode endpoints to media pad numbers. This is useful for devices which
require advanced mappings of pads.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 include/media/media-entity.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index c7c254c5bca1761b..46eeb036aa330534 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -21,6 +21,7 @@
 
 #include <linux/bitmap.h>
 #include <linux/bug.h>
+#include <linux/fwnode.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/media.h>
@@ -171,6 +172,9 @@ struct media_pad {
 
 /**
  * struct media_entity_operations - Media entity operations
+ * @get_fwnode_pad:	Return the pad number based on a fwnode endpoint or
+ *			a negative value on error. This operation can be used
+ *			to map a fwnode to a media pad number. Optional.
  * @link_setup:		Notify the entity of link changes. The operation can
  *			return an error, in which case link setup will be
  *			cancelled. Optional.
@@ -184,6 +188,7 @@ struct media_pad {
  *    mutex held.
  */
 struct media_entity_operations {
+	int (*get_fwnode_pad)(struct fwnode_endpoint *endpoint);
 	int (*link_setup)(struct media_entity *entity,
 			  const struct media_pad *local,
 			  const struct media_pad *remote, u32 flags);
-- 
2.13.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v4 2/2] media: entity: Add media_entity_get_fwnode_pad() function
  2017-06-15  9:17 [PATCH v4 0/2] media: entity: add operation to help map DT node to media pad Niklas Söderlund
  2017-06-15  9:17 ` [PATCH v4 1/2] media: entity: Add get_fwnode_pad entity operation Niklas Söderlund
@ 2017-06-15  9:17 ` Niklas Söderlund
  2017-07-18 14:38   ` Kieran Bingham
  1 sibling, 1 reply; 4+ messages in thread
From: Niklas Söderlund @ 2017-06-15  9:17 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Sakari Ailus, linux-media, Hans Verkuil
  Cc: Kieran Bingham, linux-renesas-soc, Laurent Pinchart,
	Niklas Söderlund

This is a wrapper around the media entity get_fwnode_pad operation.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/media-entity.c | 36 ++++++++++++++++++++++++++++++++++++
 include/media/media-entity.h | 23 +++++++++++++++++++++++
 2 files changed, 59 insertions(+)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index bc44193efa4798b4..82d6755bd5d0d5f0 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,41 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph)
 }
 EXPORT_SYMBOL_GPL(media_graph_walk_next);
 
+int media_entity_get_fwnode_pad(struct media_entity *entity,
+				struct fwnode_handle *fwnode,
+				unsigned long direction_flags)
+{
+	struct fwnode_endpoint endpoint;
+	unsigned int i;
+	int ret;
+
+	if (!entity->ops || !entity->ops->get_fwnode_pad) {
+		for (i = 0; i < entity->num_pads; i++) {
+			if (entity->pads[i].flags & direction_flags)
+				return i;
+		}
+
+		return -ENXIO;
+	}
+
+	ret = fwnode_graph_parse_endpoint(fwnode, &endpoint);
+	if (ret)
+		return ret;
+
+	ret = entity->ops->get_fwnode_pad(&endpoint);
+	if (ret < 0)
+		return ret;
+
+	if (ret >= entity->num_pads)
+		return -ENXIO;
+
+	if (!(entity->pads[ret].flags & direction_flags))
+		return -ENXIO;
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(media_entity_get_fwnode_pad);
+
 /* -----------------------------------------------------------------------------
  * Pipeline management
  */
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 46eeb036aa330534..754182d296689675 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -821,6 +821,29 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad);
 struct media_entity *media_entity_get(struct media_entity *entity);
 
 /**
+ * media_entity_get_fwnode_pad - Get pad number from fwnode
+ *
+ * @entity: The entity
+ * @fwnode: Pointer to the fwnode_handle which should be used to find the pad
+ * @direction_flags: Expected direction of the pad, as defined in
+ *		     :ref:`include/uapi/linux/media.h <media_header>`
+ *		     (seek for ``MEDIA_PAD_FL_*``)
+ *
+ * This function can be used to resolve the media pad number from
+ * a fwnode. This is useful for devices which use more complex
+ * mappings of media pads.
+ *
+ * If the entity dose not implement the get_fwnode_pad() operation
+ * then this function searches the entity for the first pad that
+ * matches the @direction_flags.
+ *
+ * Return: returns the pad number on success or a negative error code.
+ */
+int media_entity_get_fwnode_pad(struct media_entity *entity,
+				struct fwnode_handle *fwnode,
+				unsigned long direction_flags);
+
+/**
  * media_graph_walk_init - Allocate resources used by graph walk.
  *
  * @graph: Media graph structure that will be used to walk the graph
-- 
2.13.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v4 2/2] media: entity: Add media_entity_get_fwnode_pad() function
  2017-06-15  9:17 ` [PATCH v4 2/2] media: entity: Add media_entity_get_fwnode_pad() function Niklas Söderlund
@ 2017-07-18 14:38   ` Kieran Bingham
  0 siblings, 0 replies; 4+ messages in thread
From: Kieran Bingham @ 2017-07-18 14:38 UTC (permalink / raw)
  To: Niklas Söderlund, Mauro Carvalho Chehab, Sakari Ailus,
	linux-media, Hans Verkuil
  Cc: Kieran Bingham, linux-renesas-soc, Laurent Pinchart

Hi Niklas,

Small spelling error discovered in here:

On 15/06/17 10:17, Niklas Söderlund wrote:
> This is a wrapper around the media entity get_fwnode_pad operation.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/media-entity.c | 36 ++++++++++++++++++++++++++++++++++++
>  include/media/media-entity.h | 23 +++++++++++++++++++++++
>  2 files changed, 59 insertions(+)
> 
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index bc44193efa4798b4..82d6755bd5d0d5f0 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,41 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph)
>  }
>  EXPORT_SYMBOL_GPL(media_graph_walk_next);
>  
> +int media_entity_get_fwnode_pad(struct media_entity *entity,
> +				struct fwnode_handle *fwnode,

Could fwnode be 'ep' or such to show that we want the pad of the remote endpoint?

fwnode is confusing ...

> +				unsigned long direction_flags)
> +{
> +	struct fwnode_endpoint endpoint;
> +	unsigned int i;
> +	int ret;
> +
> +	if (!entity->ops || !entity->ops->get_fwnode_pad) {
> +		for (i = 0; i < entity->num_pads; i++) {
> +			if (entity->pads[i].flags & direction_flags)
> +				return i;
> +		}
> +
> +		return -ENXIO;
> +	}
> +
> +	ret = fwnode_graph_parse_endpoint(fwnode, &endpoint);
> +	if (ret)
> +		return ret;
> +
> +	ret = entity->ops->get_fwnode_pad(&endpoint);
> +	if (ret < 0)
> +		return ret;
> +
> +	if (ret >= entity->num_pads)
> +		return -ENXIO;
> +
> +	if (!(entity->pads[ret].flags & direction_flags))
> +		return -ENXIO;
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(media_entity_get_fwnode_pad);
> +
>  /* -----------------------------------------------------------------------------
>   * Pipeline management
>   */
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 46eeb036aa330534..754182d296689675 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -821,6 +821,29 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad);
>  struct media_entity *media_entity_get(struct media_entity *entity);
>  
>  /**
> + * media_entity_get_fwnode_pad - Get pad number from fwnode
> + *
> + * @entity: The entity
> + * @fwnode: Pointer to the fwnode_handle which should be used to find the pad
> + * @direction_flags: Expected direction of the pad, as defined in
> + *		     :ref:`include/uapi/linux/media.h <media_header>`
> + *		     (seek for ``MEDIA_PAD_FL_*``)
> + *
> + * This function can be used to resolve the media pad number from
> + * a fwnode. This is useful for devices which use more complex
> + * mappings of media pads.
> + *
> + * If the entity dose not implement the get_fwnode_pad() operation

s/dose/does/

> + * then this function searches the entity for the first pad that
> + * matches the @direction_flags.
> + *
> + * Return: returns the pad number on success or a negative error code.
> + */
> +int media_entity_get_fwnode_pad(struct media_entity *entity,
> +				struct fwnode_handle *fwnode,
> +				unsigned long direction_flags);
> +
> +/**
>   * media_graph_walk_init - Allocate resources used by graph walk.
>   *
>   * @graph: Media graph structure that will be used to walk the graph
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-18 14:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-15  9:17 [PATCH v4 0/2] media: entity: add operation to help map DT node to media pad Niklas Söderlund
2017-06-15  9:17 ` [PATCH v4 1/2] media: entity: Add get_fwnode_pad entity operation Niklas Söderlund
2017-06-15  9:17 ` [PATCH v4 2/2] media: entity: Add media_entity_get_fwnode_pad() function Niklas Söderlund
2017-07-18 14:38   ` Kieran Bingham

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.