[media] media: rcar_vin: Use correct pad number in try_fmt
authorUlrich Hecht <ulrich.hecht+renesas@gmail.com>
Wed, 11 May 2016 14:02:51 +0000 (11:02 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 28 Jun 2016 12:05:59 +0000 (09:05 -0300)
Fix rcar_vin_try_fmt's use of an inappropriate pad number when calling
the subdev set_fmt function - for the ADV7612, IDs should be non-zero.

Signed-off-by: William Towle <william.towle@codethink.co.uk>
Reviewed-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

index 929816b609f7892a347ff065b61ada6c5b98af28..3788f8a5f856768edcfd292cabfa5a33148ccd04 100644 (file)
@@ -98,7 +98,7 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
                                        struct rvin_source_fmt *source)
 {
        struct v4l2_subdev *sd;
-       struct v4l2_subdev_pad_config pad_cfg;
+       struct v4l2_subdev_pad_config *pad_cfg;
        struct v4l2_subdev_format format = {
                .which = which,
        };
@@ -108,10 +108,16 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
 
        v4l2_fill_mbus_format(&format.format, pix, vin->source.code);
 
+       pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+       if (pad_cfg == NULL)
+               return -ENOMEM;
+
+       format.pad = vin->src_pad_idx;
+
        ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, pad, set_fmt,
-                                        &pad_cfg, &format);
+                                        pad_cfg, &format);
        if (ret < 0)
-               return ret;
+               goto cleanup;
 
        v4l2_fill_pix_format(pix, &format.format);
 
@@ -121,6 +127,8 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
        vin_dbg(vin, "Source resolution: %ux%u\n", source->width,
                source->height);
 
+cleanup:
+       v4l2_subdev_free_pad_config(pad_cfg);
        return 0;
 }