From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org
Cc: "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: [PATCH v2 2/2] media: entity: Add media_entity_pad_from_fwnode() function
Date: Wed, 24 May 2017 02:09:07 +0200 [thread overview]
Message-ID: <20170524000907.13061-3-niklas.soderlund@ragnatech.se> (raw)
In-Reply-To: <20170524000907.13061-1-niklas.soderlund@ragnatech.se>
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;
+}
+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
+ * @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
--
2.13.0
next prev parent reply other threads:[~2017-05-24 0:09 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 ` Niklas Söderlund [this message]
2017-05-24 13:27 ` [PATCH v2 2/2] media: entity: Add media_entity_pad_from_fwnode() function Sakari Ailus
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=20170524000907.13061-3-niklas.soderlund@ragnatech.se \
--to=niklas.soderlund@ragnatech.se \
--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=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;
as well as URLs for NNTP newsgroup(s).