linux-sunxi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] media: sunxi: MIPI CSI-2 controllers link fixups
@ 2022-09-09 13:39 Paul Kocialkowski
  2022-09-09 13:39 ` [PATCH 1/4] media: sun6i-mipi-csi2: Require both pads to be connected for streaming Paul Kocialkowski
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Paul Kocialkowski @ 2022-09-09 13:39 UTC (permalink / raw)
  To: linux-media, linux-arm-kernel, linux-sunxi, linux-kernel
  Cc: Paul Kocialkowski, Mauro Carvalho Chehab, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Hans Verkuil, Maxime Ripard,
	Thomas Petazzoni, Laurent Pinchart

Fix the MIPI CSI-2 drivers to correctly check enabled links and to
register their subdev even without a sensor attached. This allows
their parent driver to register in that situation and makes it
possible to use a parallel sensor when both parallel and MIPI CSI-2
are fed to the same controller but no sensor is connected to the
MIPI CSI-2 bridge.

With this change, it becomes possible to always describe the links
between the CSI and MIPI CSI-2 blocks in device-tree.

This series is based atop Christophe JAILLET's fixes at:
https://patchwork.kernel.org/project/linux-media/list/?series=670059

Paul Kocialkowski (4):
  media: sun6i-mipi-csi2: Require both pads to be connected for
    streaming
  media: sun8i-a83t-mipi-csi2: Require both pads to be connected for
    streaming
  media: sun6i-mipi-csi2: Register async subdev with no sensor attached
  media: sun8i-a83t-mipi-csi2: Register async subdev with no sensor
    attached

 .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c   | 23 +++++++++++++------
 .../sun8i_a83t_mipi_csi2.c                    | 23 +++++++++++++------
 2 files changed, 32 insertions(+), 14 deletions(-)

-- 
2.37.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] media: sun6i-mipi-csi2: Require both pads to be connected for streaming
  2022-09-09 13:39 [PATCH 0/4] media: sunxi: MIPI CSI-2 controllers link fixups Paul Kocialkowski
@ 2022-09-09 13:39 ` Paul Kocialkowski
  2022-09-09 13:39 ` [PATCH 2/4] media: sun8i-a83t-mipi-csi2: " Paul Kocialkowski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Kocialkowski @ 2022-09-09 13:39 UTC (permalink / raw)
  To: linux-media, linux-arm-kernel, linux-sunxi, linux-kernel
  Cc: Paul Kocialkowski, Mauro Carvalho Chehab, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Hans Verkuil, Maxime Ripard,
	Thomas Petazzoni, Laurent Pinchart

The bridge needs both its pads connected to be able to stream data.
Enforcing this is useful to produce an error when no sensor is
connected.

Fixes: af54b4f4c17f ("media: sunxi: Add support for the A31 MIPI CSI-2 controller")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 .../media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
index 30d6c0c5161f..340380a5f66f 100644
--- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
+++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
@@ -519,8 +519,10 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mipi_csi2_device *csi2_dev)
 
 	/* Media Pads */
 
-	pads[SUN6I_MIPI_CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-	pads[SUN6I_MIPI_CSI2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
+	pads[SUN6I_MIPI_CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK |
+					       MEDIA_PAD_FL_MUST_CONNECT;
+	pads[SUN6I_MIPI_CSI2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE |
+						 MEDIA_PAD_FL_MUST_CONNECT;
 
 	ret = media_entity_pads_init(&subdev->entity, SUN6I_MIPI_CSI2_PAD_COUNT,
 				     pads);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] media: sun8i-a83t-mipi-csi2: Require both pads to be connected for streaming
  2022-09-09 13:39 [PATCH 0/4] media: sunxi: MIPI CSI-2 controllers link fixups Paul Kocialkowski
  2022-09-09 13:39 ` [PATCH 1/4] media: sun6i-mipi-csi2: Require both pads to be connected for streaming Paul Kocialkowski
@ 2022-09-09 13:39 ` Paul Kocialkowski
  2022-09-09 13:39 ` [PATCH 3/4] media: sun6i-mipi-csi2: Register async subdev with no sensor attached Paul Kocialkowski
  2022-09-09 13:39 ` [PATCH 4/4] media: sun8i-a83t-mipi-csi2: " Paul Kocialkowski
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Kocialkowski @ 2022-09-09 13:39 UTC (permalink / raw)
  To: linux-media, linux-arm-kernel, linux-sunxi, linux-kernel
  Cc: Paul Kocialkowski, Mauro Carvalho Chehab, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Hans Verkuil, Maxime Ripard,
	Thomas Petazzoni, Laurent Pinchart

The bridge needs both its pads connected to be able to stream data.
Enforcing this is useful to produce an error when no sensor is
connected.

Fixes: 576d196c522b ("media: sunxi: Add support for the A83T MIPI CSI-2 controller")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 .../sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c       | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
index b032ec13a683..5e1c25db7bc4 100644
--- a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
+++ b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
@@ -557,8 +557,10 @@ sun8i_a83t_mipi_csi2_bridge_setup(struct sun8i_a83t_mipi_csi2_device *csi2_dev)
 
 	/* Media Pads */
 
-	pads[SUN8I_A83T_MIPI_CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-	pads[SUN8I_A83T_MIPI_CSI2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
+	pads[SUN8I_A83T_MIPI_CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK |
+						    MEDIA_PAD_FL_MUST_CONNECT;
+	pads[SUN8I_A83T_MIPI_CSI2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE |
+						      MEDIA_PAD_FL_MUST_CONNECT;
 
 	ret = media_entity_pads_init(&subdev->entity,
 				     SUN8I_A83T_MIPI_CSI2_PAD_COUNT, pads);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] media: sun6i-mipi-csi2: Register async subdev with no sensor attached
  2022-09-09 13:39 [PATCH 0/4] media: sunxi: MIPI CSI-2 controllers link fixups Paul Kocialkowski
  2022-09-09 13:39 ` [PATCH 1/4] media: sun6i-mipi-csi2: Require both pads to be connected for streaming Paul Kocialkowski
  2022-09-09 13:39 ` [PATCH 2/4] media: sun8i-a83t-mipi-csi2: " Paul Kocialkowski
@ 2022-09-09 13:39 ` Paul Kocialkowski
  2022-09-09 13:39 ` [PATCH 4/4] media: sun8i-a83t-mipi-csi2: " Paul Kocialkowski
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Kocialkowski @ 2022-09-09 13:39 UTC (permalink / raw)
  To: linux-media, linux-arm-kernel, linux-sunxi, linux-kernel
  Cc: Paul Kocialkowski, Mauro Carvalho Chehab, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Hans Verkuil, Maxime Ripard,
	Thomas Petazzoni, Laurent Pinchart

This allows the device to probe and register its async subdev without
a sensor attached.

The rationale is that the parent driver might otherwise wait for the
subdev to be registered when it should be available (from the fwnode
graph endpoint perspective). This is generally not problematic when
the MIPI CSI-2 bridge is the only device attached to the parent, but
in the case of a CSI controller that can feed from both MIPI CSI-2
and parallel, it would prevent using the parallel sensor due to the
parent waiting for the MIPI CSI-2 subdev to register.

Fixes: af54b4f4c17f ("media: sunxi: Add support for the A31 MIPI CSI-2 controller")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c     | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
index 340380a5f66f..484ac5f054d5 100644
--- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
+++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
@@ -498,6 +498,7 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mipi_csi2_device *csi2_dev)
 	struct v4l2_async_notifier *notifier = &bridge->notifier;
 	struct media_pad *pads = bridge->pads;
 	struct device *dev = csi2_dev->dev;
+	bool notifier_registered = false;
 	int ret;
 
 	mutex_init(&bridge->lock);
@@ -535,12 +536,17 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mipi_csi2_device *csi2_dev)
 	notifier->ops = &sun6i_mipi_csi2_notifier_ops;
 
 	ret = sun6i_mipi_csi2_bridge_source_setup(csi2_dev);
-	if (ret)
+	if (ret && ret != -ENODEV)
 		goto error_v4l2_notifier_cleanup;
 
-	ret = v4l2_async_subdev_nf_register(subdev, notifier);
-	if (ret < 0)
-		goto error_v4l2_notifier_cleanup;
+	/* Only register the notifier when a sensor is connected. */
+	if (ret != -ENODEV) {
+		ret = v4l2_async_subdev_nf_register(subdev, notifier);
+		if (ret < 0)
+			goto error_v4l2_notifier_cleanup;
+
+		notifier_registered = true;
+	}
 
 	/* V4L2 Subdev */
 
@@ -551,7 +557,8 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mipi_csi2_device *csi2_dev)
 	return 0;
 
 error_v4l2_notifier_unregister:
-	v4l2_async_nf_unregister(notifier);
+	if (notifier_registered)
+		v4l2_async_nf_unregister(notifier);
 
 error_v4l2_notifier_cleanup:
 	v4l2_async_nf_cleanup(notifier);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] media: sun8i-a83t-mipi-csi2: Register async subdev with no sensor attached
  2022-09-09 13:39 [PATCH 0/4] media: sunxi: MIPI CSI-2 controllers link fixups Paul Kocialkowski
                   ` (2 preceding siblings ...)
  2022-09-09 13:39 ` [PATCH 3/4] media: sun6i-mipi-csi2: Register async subdev with no sensor attached Paul Kocialkowski
@ 2022-09-09 13:39 ` Paul Kocialkowski
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Kocialkowski @ 2022-09-09 13:39 UTC (permalink / raw)
  To: linux-media, linux-arm-kernel, linux-sunxi, linux-kernel
  Cc: Paul Kocialkowski, Mauro Carvalho Chehab, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Hans Verkuil, Maxime Ripard,
	Thomas Petazzoni, Laurent Pinchart

This allows the device to probe and register its async subdev without
a sensor attached.

The rationale is that the parent driver might otherwise wait for the
subdev to be registered when it should be available (from the fwnode
graph endpoint perspective). This is generally not problematic when
the MIPI CSI-2 bridge is the only device attached to the parent, but
in the case of a CSI controller that can feed from both MIPI CSI-2
and parallel, it would prevent using the parallel sensor due to the
parent waiting for the MIPI CSI-2 subdev to register.

Fixes: 576d196c522b ("media: sunxi: Add support for the A83T MIPI CSI-2 controller")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 .../sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
index 5e1c25db7bc4..d993c09a4820 100644
--- a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
+++ b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
@@ -536,6 +536,7 @@ sun8i_a83t_mipi_csi2_bridge_setup(struct sun8i_a83t_mipi_csi2_device *csi2_dev)
 	struct v4l2_async_notifier *notifier = &bridge->notifier;
 	struct media_pad *pads = bridge->pads;
 	struct device *dev = csi2_dev->dev;
+	bool notifier_registered = false;
 	int ret;
 
 	mutex_init(&bridge->lock);
@@ -573,12 +574,17 @@ sun8i_a83t_mipi_csi2_bridge_setup(struct sun8i_a83t_mipi_csi2_device *csi2_dev)
 	notifier->ops = &sun8i_a83t_mipi_csi2_notifier_ops;
 
 	ret = sun8i_a83t_mipi_csi2_bridge_source_setup(csi2_dev);
-	if (ret)
+	if (ret && ret != -ENODEV)
 		goto error_v4l2_notifier_cleanup;
 
-	ret = v4l2_async_subdev_nf_register(subdev, notifier);
-	if (ret < 0)
-		goto error_v4l2_notifier_cleanup;
+	/* Only register the notifier when a sensor is connected. */
+	if (ret != -ENODEV) {
+		ret = v4l2_async_subdev_nf_register(subdev, notifier);
+		if (ret < 0)
+			goto error_v4l2_notifier_cleanup;
+
+		notifier_registered = true;
+	}
 
 	/* V4L2 Subdev */
 
@@ -589,7 +595,8 @@ sun8i_a83t_mipi_csi2_bridge_setup(struct sun8i_a83t_mipi_csi2_device *csi2_dev)
 	return 0;
 
 error_v4l2_notifier_unregister:
-	v4l2_async_nf_unregister(notifier);
+	if (notifier_registered)
+		v4l2_async_nf_unregister(notifier);
 
 error_v4l2_notifier_cleanup:
 	v4l2_async_nf_cleanup(notifier);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-09 13:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09 13:39 [PATCH 0/4] media: sunxi: MIPI CSI-2 controllers link fixups Paul Kocialkowski
2022-09-09 13:39 ` [PATCH 1/4] media: sun6i-mipi-csi2: Require both pads to be connected for streaming Paul Kocialkowski
2022-09-09 13:39 ` [PATCH 2/4] media: sun8i-a83t-mipi-csi2: " Paul Kocialkowski
2022-09-09 13:39 ` [PATCH 3/4] media: sun6i-mipi-csi2: Register async subdev with no sensor attached Paul Kocialkowski
2022-09-09 13:39 ` [PATCH 4/4] media: sun8i-a83t-mipi-csi2: " Paul Kocialkowski

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