[PATCH v4 28/31] adv748x: afe: Implement has_route()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 drivers/media/i2c/adv748x/adv748x-afe.c | 26 +++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

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)
-- 
2.21.0




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux