[PATCH 13/22] media: imx: mipi csi-2: Create media links in bound notifier

From: Steve Longerbeam
Date: Mon Aug 05 2019 - 19:36:21 EST


Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the mipi csi-2 receiver sink pad.

Signed-off-by: Steve Longerbeam <slongerbeam@xxxxxxxxx>
---
drivers/staging/media/imx/imx6-mipi-csi2.c | 24 ++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c
index 408ee2765e77..5b2258156781 100644
--- a/drivers/staging/media/imx/imx6-mipi-csi2.c
+++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
@@ -91,6 +91,11 @@ static inline struct csi2_dev *sd_to_dev(struct v4l2_subdev *sdev)
return container_of(sdev, struct csi2_dev, sd);
}

+static inline struct csi2_dev *notifier_to_dev(struct v4l2_async_notifier *n)
+{
+ return container_of(n, struct csi2_dev, notifier);
+}
+
/*
* The required sequence of MIPI CSI-2 startup as specified in the i.MX6
* reference manual is as follows:
@@ -573,6 +578,23 @@ static int csi2_parse_endpoint(struct device *dev,
return 0;
}

+static int csi2_notify_bound(struct v4l2_async_notifier *notifier,
+ struct v4l2_subdev *sd,
+ struct v4l2_async_subdev *asd)
+{
+ struct csi2_dev *csi2 = notifier_to_dev(notifier);
+ struct media_pad *sink = &csi2->sd.entity.pads[CSI2_SINK_PAD];
+
+ return media_create_fwnode_pad_links(sink,
+ dev_fwnode(csi2->dev),
+ &sd->entity,
+ dev_fwnode(sd->dev), 0);
+}
+
+static const struct v4l2_async_notifier_operations csi2_notify_ops = {
+ .bound = csi2_notify_bound,
+};
+
static int csi2_probe(struct platform_device *pdev)
{
unsigned int sink_port = 0;
@@ -646,6 +668,8 @@ static int csi2_probe(struct platform_device *pdev)

v4l2_async_notifier_init(&csi2->notifier);

+ csi2->notifier.ops = &csi2_notify_ops;
+
ret = v4l2_async_register_fwnode_subdev(
&csi2->sd, &csi2->notifier, sizeof(struct v4l2_async_subdev),
&sink_port, 1, csi2_parse_endpoint);
--
2.17.1