[v4,28/31] adv748x: afe: Implement has_route()
diff mbox series

Message ID 20190328200608.9463-29-jacopo+renesas@jmondi.org
State New
Delegated to: Kieran Bingham
Headers show
Series
  • v4l: add support for multiplexed streams
Related show

Commit Message

Jacopo Mondi March 28, 2019, 8:06 p.m. UTC
Now that the adv748x subdevice supports internal routing, add an
has_route() operation used during media graph traversal.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/adv748x/adv748x-afe.c | 26 +++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Patch
diff mbox series

diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c
index 3f770f71413f..1ba78d45abd5 100644
--- a/drivers/media/i2c/adv748x/adv748x-afe.c
+++ b/drivers/media/i2c/adv748x/adv748x-afe.c
@@ -463,6 +463,30 @@  static const struct v4l2_subdev_ops adv748x_afe_ops = {
 	.pad = &adv748x_afe_pad_ops,
 };
 
+/* -----------------------------------------------------------------------------
+ * media_entity_operations
+ */
+
+static bool adv748x_afe_has_route(struct media_entity *entity,
+				  unsigned int pad0, unsigned int pad1)
+{
+	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
+	struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
+
+	/* Only consider direct sink->source routes. */
+	if (pad0 > ADV748X_AFE_SINK_AIN7 || pad1 != ADV748X_AFE_SOURCE)
+		return false;
+
+	if (pad0 != afe->input)
+		return false;
+
+	return true;
+}
+
+static const struct media_entity_operations adv748x_afe_entity_ops = {
+	.has_route = adv748x_afe_has_route,
+};
+
 /* -----------------------------------------------------------------------------
  * Controls
  */
@@ -595,6 +619,8 @@  int adv748x_afe_init(struct adv748x_afe *afe)
 
 	afe->pads[ADV748X_AFE_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
 
+	afe->sd.entity.ops = &adv748x_afe_entity_ops;
+
 	ret = media_entity_pads_init(&afe->sd.entity, ADV748X_AFE_NR_PADS,
 			afe->pads);
 	if (ret)