[PATCH 46/55] media: rkisp1: Make the internal CSI-2 receiver optional
Paul Elder
paul.elder at ideasonboard.com
Tue Jun 14 12:11:18 PDT 2022
From: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Not all ISP versions integrate a MIPI CSI-2 receiver.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
.../platform/rockchip/rkisp1/rkisp1-dev.c | 50 +++++++++++++------
1 file changed, 34 insertions(+), 16 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
index 8ccd4042f3f3..62fa2bd275fe 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
@@ -195,6 +195,14 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
switch (reg) {
case 0:
+ /* MIPI CSI-2 port */
+ if (!(rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2)) {
+ dev_err(rkisp1->dev,
+ "internal CSI must be available for port 0\n");
+ ret = -EINVAL;
+ break;
+ }
+
vep.bus_type = V4L2_MBUS_CSI2_DPHY;
break;
@@ -320,13 +328,16 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1)
unsigned int i;
int ret;
- /* Link the CSI receiver to the ISP. */
- ret = media_create_pad_link(&rkisp1->csi.sd.entity, RKISP1_CSI_PAD_SRC,
- &rkisp1->isp.sd.entity,
- RKISP1_ISP_PAD_SINK_VIDEO,
- MEDIA_LNK_FL_ENABLED);
- if (ret)
- return ret;
+ if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) {
+ /* Link the CSI receiver to the ISP. */
+ ret = media_create_pad_link(&rkisp1->csi.sd.entity,
+ RKISP1_CSI_PAD_SRC,
+ &rkisp1->isp.sd.entity,
+ RKISP1_ISP_PAD_SINK_VIDEO,
+ MEDIA_LNK_FL_ENABLED);
+ if (ret)
+ return ret;
+ }
/* create ISP->RSZ->CAP links */
for (i = 0; i < 2; i++) {
@@ -369,7 +380,8 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1)
static void rkisp1_entities_unregister(struct rkisp1_device *rkisp1)
{
- rkisp1_csi_unregister(rkisp1);
+ if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2)
+ rkisp1_csi_unregister(rkisp1);
rkisp1_params_unregister(rkisp1);
rkisp1_stats_unregister(rkisp1);
rkisp1_capture_devs_unregister(rkisp1);
@@ -401,9 +413,11 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1)
if (ret)
goto error;
- ret = rkisp1_csi_register(rkisp1);
- if (ret)
- goto error;
+ if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) {
+ ret = rkisp1_csi_register(rkisp1);
+ if (ret)
+ goto error;
+ }
ret = rkisp1_create_links(rkisp1);
if (ret)
@@ -566,9 +580,11 @@ static int rkisp1_probe(struct platform_device *pdev)
goto err_unreg_v4l2_dev;
}
- ret = rkisp1_csi_init(rkisp1);
- if (ret)
- goto err_unreg_media_dev;
+ if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) {
+ ret = rkisp1_csi_init(rkisp1);
+ if (ret)
+ goto err_unreg_media_dev;
+ }
ret = rkisp1_entities_register(rkisp1);
if (ret)
@@ -585,7 +601,8 @@ static int rkisp1_probe(struct platform_device *pdev)
err_unreg_entities:
rkisp1_entities_unregister(rkisp1);
err_cleanup_csi:
- rkisp1_csi_cleanup(rkisp1);
+ if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2)
+ rkisp1_csi_cleanup(rkisp1);
err_unreg_media_dev:
media_device_unregister(&rkisp1->media_dev);
err_unreg_v4l2_dev:
@@ -603,7 +620,8 @@ static int rkisp1_remove(struct platform_device *pdev)
v4l2_async_nf_cleanup(&rkisp1->notifier);
rkisp1_entities_unregister(rkisp1);
- rkisp1_csi_cleanup(rkisp1);
+ if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2)
+ rkisp1_csi_cleanup(rkisp1);
rkisp1_debug_cleanup(rkisp1);
media_device_unregister(&rkisp1->media_dev);
--
2.30.2
More information about the Linux-rockchip
mailing list