[media] staging: omap4iss: separate links creation from entities init
authorJavier Martinez Canillas <javier@osg.samsung.com>
Wed, 2 Sep 2015 14:28:08 +0000 (11:28 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:18:45 +0000 (12:18 -0200)
The omap4iss driver initializes the entities and creates the pads links
before the entities are registered with the media device. This does not
work now that object IDs are used to create links so the media_device
has to be set.

Split out the pads links creation from the entity initialization so are
made after the entities registration.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/staging/media/omap4iss/iss.c
drivers/staging/media/omap4iss/iss_csi2.c
drivers/staging/media/omap4iss/iss_csi2.h
drivers/staging/media/omap4iss/iss_ipipeif.c
drivers/staging/media/omap4iss/iss_ipipeif.h
drivers/staging/media/omap4iss/iss_resizer.c
drivers/staging/media/omap4iss/iss_resizer.h

index b405dc93d90ac02d1cdb4025157eac2fe271d8c2..fa761669fd863e05d31f93d09a05bf2eb0dfe6f4 100644 (file)
@@ -1274,6 +1274,68 @@ done:
        return ret;
 }
 
+/*
+ * iss_create_pads_links() - Pads links creation for the subdevices
+ * @iss : Pointer to ISS device
+ *
+ * return negative error code or zero on success
+ */
+static int iss_create_pads_links(struct iss_device *iss)
+{
+       int ret;
+
+       ret = omap4iss_csi2_create_pads_links(iss);
+       if (ret < 0) {
+               dev_err(iss->dev, "CSI2 pads links creation failed\n");
+               return ret;
+       }
+
+       ret = omap4iss_ipipeif_create_pads_links(iss);
+       if (ret < 0) {
+               dev_err(iss->dev, "ISP IPIPEIF pads links creation failed\n");
+               return ret;
+       }
+
+       ret = omap4iss_resizer_create_pads_links(iss);
+       if (ret < 0) {
+               dev_err(iss->dev, "ISP RESIZER pads links creation failed\n");
+               return ret;
+       }
+
+       /* Connect the submodules. */
+       ret = media_create_pad_link(
+                       &iss->csi2a.subdev.entity, CSI2_PAD_SOURCE,
+                       &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0);
+       if (ret < 0)
+               return ret;
+
+       ret = media_create_pad_link(
+                       &iss->csi2b.subdev.entity, CSI2_PAD_SOURCE,
+                       &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0);
+       if (ret < 0)
+               return ret;
+
+       ret = media_create_pad_link(
+                       &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP,
+                       &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0);
+       if (ret < 0)
+               return ret;
+
+       ret = media_create_pad_link(
+                       &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP,
+                       &iss->ipipe.subdev.entity, IPIPE_PAD_SINK, 0);
+       if (ret < 0)
+               return ret;
+
+       ret = media_create_pad_link(
+                       &iss->ipipe.subdev.entity, IPIPE_PAD_SOURCE_VP,
+                       &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+};
+
 static void iss_cleanup_modules(struct iss_device *iss)
 {
        omap4iss_csi2_cleanup(iss);
@@ -1316,41 +1378,8 @@ static int iss_initialize_modules(struct iss_device *iss)
                goto error_resizer;
        }
 
-       /* Connect the submodules. */
-       ret = media_create_pad_link(
-                       &iss->csi2a.subdev.entity, CSI2_PAD_SOURCE,
-                       &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0);
-       if (ret < 0)
-               goto error_link;
-
-       ret = media_create_pad_link(
-                       &iss->csi2b.subdev.entity, CSI2_PAD_SOURCE,
-                       &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0);
-       if (ret < 0)
-               goto error_link;
-
-       ret = media_create_pad_link(
-                       &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP,
-                       &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0);
-       if (ret < 0)
-               goto error_link;
-
-       ret = media_create_pad_link(
-                       &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP,
-                       &iss->ipipe.subdev.entity, IPIPE_PAD_SINK, 0);
-       if (ret < 0)
-               goto error_link;
-
-       ret = media_create_pad_link(
-                       &iss->ipipe.subdev.entity, IPIPE_PAD_SOURCE_VP,
-                       &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0);
-       if (ret < 0)
-               goto error_link;
-
        return 0;
 
-error_link:
-       omap4iss_resizer_cleanup(iss);
 error_resizer:
        omap4iss_ipipe_cleanup(iss);
 error_ipipe:
@@ -1464,10 +1493,16 @@ static int iss_probe(struct platform_device *pdev)
        if (ret < 0)
                goto error_modules;
 
+       ret = iss_create_pads_links(iss);
+       if (ret < 0)
+               goto error_entities;
+
        omap4iss_put(iss);
 
        return 0;
 
+error_entities:
+       iss_unregister_entities(iss);
 error_modules:
        iss_cleanup_modules(iss);
 error_iss:
index c6eb5a7a593f35bd8d744a3efb58fec7f09528ed..13878a2752779580973e0d984b890a3255442ae1 100644 (file)
@@ -1290,16 +1290,8 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname)
        if (ret < 0)
                goto error_video;
 
-       /* Connect the CSI2 subdev to the video node. */
-       ret = media_create_pad_link(&csi2->subdev.entity, CSI2_PAD_SOURCE,
-                                      &csi2->video_out.video.entity, 0, 0);
-       if (ret < 0)
-               goto error_link;
-
        return 0;
 
-error_link:
-       omap4iss_video_cleanup(&csi2->video_out);
 error_video:
        media_entity_cleanup(&csi2->subdev.entity);
        return ret;
@@ -1341,6 +1333,33 @@ int omap4iss_csi2_init(struct iss_device *iss)
        return 0;
 }
 
+/*
+ * omap4iss_csi2_create_pads_links() - CSI2 pads links creation
+ * @iss: Pointer to ISS device
+ *
+ * return negative error code or zero on success
+ */
+int omap4iss_csi2_create_pads_links(struct iss_device *iss)
+{
+       struct iss_csi2_device *csi2a = &iss->csi2a;
+       struct iss_csi2_device *csi2b = &iss->csi2b;
+       int ret;
+
+       /* Connect the CSI2a subdev to the video node. */
+       ret = media_create_pad_link(&csi2a->subdev.entity, CSI2_PAD_SOURCE,
+                                   &csi2a->video_out.video.entity, 0, 0);
+       if (ret < 0)
+               return ret;
+
+       /* Connect the CSI2b subdev to the video node. */
+       ret = media_create_pad_link(&csi2b->subdev.entity, CSI2_PAD_SOURCE,
+                                   &csi2b->video_out.video.entity, 0, 0);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
 /*
  * omap4iss_csi2_cleanup - Routine for module driver cleanup
  */
index f2f5343b4a800984e12b363abbf64d35dbe28855..1d5a0d8222a95fd8caae4f15420daae56a07817b 100644 (file)
@@ -151,6 +151,7 @@ struct iss_csi2_device {
 void omap4iss_csi2_isr(struct iss_csi2_device *csi2);
 int omap4iss_csi2_reset(struct iss_csi2_device *csi2);
 int omap4iss_csi2_init(struct iss_device *iss);
+int omap4iss_csi2_create_pads_links(struct iss_device *iss);
 void omap4iss_csi2_cleanup(struct iss_device *iss);
 void omap4iss_csi2_unregister_entities(struct iss_csi2_device *csi2);
 int omap4iss_csi2_register_entities(struct iss_csi2_device *csi2,
index b0c5f2431b62635f4fcc9dfa0543711aac07902c..82608cbb1f5fa00afeafe43c859f0c1ee1ca7d27 100644 (file)
@@ -757,18 +757,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif)
        ipipeif->video_out.bpl_zero_padding = 1;
        ipipeif->video_out.bpl_max = 0x1ffe0;
 
-       ret = omap4iss_video_init(&ipipeif->video_out, "ISP IPIPEIF");
-       if (ret < 0)
-               return ret;
-
-       /* Connect the IPIPEIF subdev to the video node. */
-       ret = media_create_pad_link(&ipipeif->subdev.entity,
-                                      IPIPEIF_PAD_SOURCE_ISIF_SF,
-                                      &ipipeif->video_out.video.entity, 0, 0);
-       if (ret < 0)
-               return ret;
-
-       return 0;
+       return omap4iss_video_init(&ipipeif->video_out, "ISP IPIPEIF");
 }
 
 void omap4iss_ipipeif_unregister_entities(struct iss_ipipeif_device *ipipeif)
@@ -820,6 +809,22 @@ int omap4iss_ipipeif_init(struct iss_device *iss)
        return ipipeif_init_entities(ipipeif);
 }
 
+/*
+ * omap4iss_ipipeif_create_pads_links() - IPIPEIF pads links creation
+ * @iss: Pointer to ISS device
+ *
+ * return negative error code or zero on success
+ */
+int omap4iss_ipipeif_create_pads_links(struct iss_device *iss)
+{
+       struct iss_ipipeif_device *ipipeif = &iss->ipipeif;
+
+       /* Connect the IPIPEIF subdev to the video node. */
+       return media_create_pad_link(&ipipeif->subdev.entity,
+                                    IPIPEIF_PAD_SOURCE_ISIF_SF,
+                                    &ipipeif->video_out.video.entity, 0, 0);
+}
+
 /*
  * omap4iss_ipipeif_cleanup - IPIPEIF module cleanup.
  * @iss: Device pointer specific to the OMAP4 ISS.
index c6bd96d9656cf871049c17046bed93839b234412..dd906b41cf9be1650bb146634faacb628942a27b 100644 (file)
@@ -78,6 +78,7 @@ struct iss_ipipeif_device {
 struct iss_device;
 
 int omap4iss_ipipeif_init(struct iss_device *iss);
+int omap4iss_ipipeif_create_pads_links(struct iss_device *iss);
 void omap4iss_ipipeif_cleanup(struct iss_device *iss);
 int omap4iss_ipipeif_register_entities(struct iss_ipipeif_device *ipipeif,
                                       struct v4l2_device *vdev);
index a2cb57cb460dad35951c380a3991e6a2075988ec..4a474873a8df0d42f4b5ce6615edb19aebc40edf 100644 (file)
@@ -799,18 +799,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer)
        resizer->video_out.bpl_zero_padding = 1;
        resizer->video_out.bpl_max = 0x1ffe0;
 
-       ret = omap4iss_video_init(&resizer->video_out, "ISP resizer a");
-       if (ret < 0)
-               return ret;
-
-       /* Connect the RESIZER subdev to the video node. */
-       ret = media_create_pad_link(&resizer->subdev.entity,
-                                      RESIZER_PAD_SOURCE_MEM,
-                                      &resizer->video_out.video.entity, 0, 0);
-       if (ret < 0)
-               return ret;
-
-       return 0;
+       return omap4iss_video_init(&resizer->video_out, "ISP resizer a");
 }
 
 void omap4iss_resizer_unregister_entities(struct iss_resizer_device *resizer)
@@ -862,6 +851,22 @@ int omap4iss_resizer_init(struct iss_device *iss)
        return resizer_init_entities(resizer);
 }
 
+/*
+ * omap4iss_resizer_create_pads_links() - RESIZER pads links creation
+ * @iss: Pointer to ISS device
+ *
+ * return negative error code or zero on success
+ */
+int omap4iss_resizer_create_pads_links(struct iss_device *iss)
+{
+       struct iss_resizer_device *resizer = &iss->resizer;
+
+       /* Connect the RESIZER subdev to the video node. */
+       return media_create_pad_link(&resizer->subdev.entity,
+                                    RESIZER_PAD_SOURCE_MEM,
+                                    &resizer->video_out.video.entity, 0, 0);
+}
+
 /*
  * omap4iss_resizer_cleanup - RESIZER module cleanup.
  * @iss: Device pointer specific to the OMAP4 ISS.
index 1e145abafc656241af648c3d2902c38a85d03b32..98ab950253d0f9f2e8b3c433f5289038cc0033e5 100644 (file)
@@ -61,6 +61,7 @@ struct iss_resizer_device {
 struct iss_device;
 
 int omap4iss_resizer_init(struct iss_device *iss);
+int omap4iss_resizer_create_pads_links(struct iss_device *iss);
 void omap4iss_resizer_cleanup(struct iss_device *iss);
 int omap4iss_resizer_register_entities(struct iss_resizer_device *resizer,
                                       struct v4l2_device *vdev);