media: rcar-vin: Invalidate pipeline if conversion is not possible on input formats
authorLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Wed, 27 May 2020 12:16:48 +0000 (14:16 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sat, 4 Jul 2020 10:28:46 +0000 (12:28 +0200)
Up until now the VIN was capable to convert any of its supported input mbus
formats to any of it's supported output pixel formats. With the addition of
RAW formats this is no longer true.

This patch invalidates the pipeline by adding a check if given vin input
format can be converted to supported output pixel format.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/rcar-vin/rcar-dma.c
drivers/media/platform/rcar-vin/rcar-v4l2.c

index 1a30cd03637116be3bf52fd0e2d7ecc0052acd86..2b26204910fd6cd1bb8e1dacfacdc501d84c038e 100644 (file)
@@ -1110,11 +1110,15 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
        case MEDIA_BUS_FMT_UYVY8_2X8:
        case MEDIA_BUS_FMT_UYVY10_2X10:
        case MEDIA_BUS_FMT_RGB888_1X24:
-               vin->mbus_code = fmt.format.code;
+               break;
+       case MEDIA_BUS_FMT_SRGGB8_1X8:
+               if (vin->format.pixelformat != V4L2_PIX_FMT_SRGGB8)
+                       return -EPIPE;
                break;
        default:
                return -EPIPE;
        }
+       vin->mbus_code = fmt.format.code;
 
        switch (fmt.format.field) {
        case V4L2_FIELD_TOP:
index f421e25848756c97c79fc2c07c1840c6545e87ad..d3b6a992b4a24bd18218ff66cdfcb6a12cbe3dc0 100644 (file)
@@ -350,9 +350,9 @@ static int rvin_enum_fmt_vid_cap(struct file *file, void *priv,
         * all of the related pixel formats. If mbus_code is not set enumerate
         * all possible pixelformats.
         *
-        * TODO: Once raw capture formats are added to the driver this needs
-        * to be extended so raw media bus codes only result in raw pixel
-        * formats.
+        * TODO: Once raw MEDIA_BUS_FMT_SRGGB12_1X12 format is added to the
+        * driver this needs to be extended so raw media bus code only result in
+        * raw pixel format.
         */
        switch (f->mbus_code) {
        case 0:
@@ -362,6 +362,11 @@ static int rvin_enum_fmt_vid_cap(struct file *file, void *priv,
        case MEDIA_BUS_FMT_UYVY10_2X10:
        case MEDIA_BUS_FMT_RGB888_1X24:
                break;
+       case MEDIA_BUS_FMT_SRGGB8_1X8:
+               if (f->index)
+                       return -EINVAL;
+               f->pixelformat = V4L2_PIX_FMT_SRGGB8;
+               return 0;
        default:
                return -EINVAL;
        }