media: sunxi: MIPI CSI-2 controllers link fixups
Subsystems (3)
cover media: sunxi: MIPI CSI-2 controllers link fixups
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(-)
Signature · 1 line
2.37.3
PATCH 1/4 media: sun6i-mipi-csi2: Require both pads to be connected for streaming
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.
--- .../media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c +4 -2
@@ -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);
Signature · 1 line
2.37.3
PATCH 2/4 media: sun8i-a83t-mipi-csi2: Require both pads to be connected for streaming
In reply to Paul KocialkowskiThe 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.
--- .../sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c +4 -2
@@ -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);
Signature · 1 line
2.37.3
PATCH 3/4 media: sun6i-mipi-csi2: Register async subdev with no sensor attached
In reply to Paul KocialkowskiThis 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.
--- .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c +12 -5
@@ -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);
Signature · 1 line
2.37.3
PATCH 4/4 media: sun8i-a83t-mipi-csi2: Register async subdev with no sensor attached
In reply to Paul KocialkowskiThis 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.
--- .../sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c +12 -5
@@ -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);
Signature · 1 line
2.37.3