[media] media: rcar-vin: pad-aware driver initialisation
authorUlrich Hecht <ulrich.hecht+renesas@gmail.com>
Wed, 11 May 2016 14:02:52 +0000 (11:02 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 28 Jun 2016 12:05:17 +0000 (09:05 -0300)
Add detection of source pad number for drivers aware of the media controller
API, so that rcar-vin can create device nodes to support modern drivers such
as adv7604.c (for HDMI on Lager) and the converted adv7180.c (for composite)
underneath.

Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
line with requirements for building the drivers associated with it.

Signed-off-by: William Towle <william.towle@codethink.co.uk>
Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
[ulrich.hecht+renesas@gmail.com: adapted to rcar-vin rewrite]
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/rcar-vin/rcar-v4l2.c
drivers/media/platform/rcar-vin/rcar-vin.h

index 0bc4487e2482346220f1692338ed9247e10ac66b..929816b609f7892a347ff065b61ada6c5b98af28 100644 (file)
@@ -683,6 +683,9 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
        struct v4l2_mbus_framefmt *mf = &fmt.format;
        struct video_device *vdev = &vin->vdev;
        struct v4l2_subdev *sd = vin_to_source(vin);
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       int pad_idx;
+#endif
        int ret;
 
        v4l2_set_subdev_hostdata(sd, vin);
@@ -729,6 +732,19 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
        vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
                V4L2_CAP_READWRITE;
 
+       vin->src_pad_idx = 0;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
+               if (sd->entity.pads[pad_idx].flags
+                               == MEDIA_PAD_FL_SOURCE)
+                       break;
+       if (pad_idx >= sd->entity.num_pads)
+               return -EINVAL;
+
+       vin->src_pad_idx = pad_idx;
+#endif
+       fmt.pad = vin->src_pad_idx;
+
        /* Try to improve our guess of a reasonable window format */
        ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt);
        if (ret) {
index 544a3b36280874faa6b96442804efc6045234e5b..a6dd6db246ab924bf6f22ab91a797d8b98598c76 100644 (file)
@@ -87,6 +87,7 @@ struct rvin_graph_entity {
  *
  * @vdev:              V4L2 video device associated with VIN
  * @v4l2_dev:          V4L2 device
+ * @src_pad_idx:       source pad index for media controller drivers
  * @ctrl_handler:      V4L2 control handler
  * @notifier:          V4L2 asynchronous subdevs notifier
  * @entity:            entity in the DT for subdevice
@@ -117,6 +118,7 @@ struct rvin_dev {
 
        struct video_device vdev;
        struct v4l2_device v4l2_dev;
+       int src_pad_idx;
        struct v4l2_ctrl_handler ctrl_handler;
        struct v4l2_async_notifier notifier;
        struct rvin_graph_entity entity;