[PATCH 06/22] media: adv748x: csi2: Implement get_fwnode_pad

From: Steve Longerbeam
Date: Mon Aug 05 2019 - 19:35:24 EST


If the given endpoint fwnode passed to the .get_fwnode_pad() op is
the adv748x-csi2 TXA/TXB source endpoint, return the associated media
pad index ADV748X_CSI2_SOURCE. The adv748x-csi2 has no other media pads
that are associated with fwnode endpoints.

Signed-off-by: Steve Longerbeam <slongerbeam@xxxxxxxxx>
---
drivers/media/i2c/adv748x/adv748x-csi2.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
index 2091cda50935..810085a1f2f0 100644
--- a/drivers/media/i2c/adv748x/adv748x-csi2.c
+++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
@@ -228,6 +228,24 @@ static const struct v4l2_subdev_ops adv748x_csi2_ops = {
.pad = &adv748x_csi2_pad_ops,
};

+/* -----------------------------------------------------------------------------
+ * media_entity_operations
+ */
+
+static int adv748x_csi2_get_fwnode_pad(struct media_entity *entity,
+ struct fwnode_endpoint *endpoint)
+{
+ struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
+ struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
+
+ return endpoint->local_fwnode == tx->sd.fwnode ?
+ ADV748X_CSI2_SOURCE : -ENXIO;
+}
+
+static const struct media_entity_operations adv748x_csi2_entity_ops = {
+ .get_fwnode_pad = adv748x_csi2_get_fwnode_pad,
+};
+
/* -----------------------------------------------------------------------------
* Subdev module and controls
*/
@@ -295,6 +313,9 @@ int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx)
/* Register internal ops for incremental subdev registration */
tx->sd.internal_ops = &adv748x_csi2_internal_ops;

+ /* Register media_entity ops */
+ tx->sd.entity.ops = &adv748x_csi2_entity_ops;
+
tx->pads[ADV748X_CSI2_SINK].flags = MEDIA_PAD_FL_SINK;
tx->pads[ADV748X_CSI2_SOURCE].flags = MEDIA_PAD_FL_SOURCE;

--
2.17.1