OSDN Git Service

media: imx: imx7-mipi-csis: Implement the .enum_mbus_code() operation
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Thu, 12 Mar 2020 23:47:22 +0000 (00:47 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 14 Apr 2020 10:45:25 +0000 (12:45 +0200)
Implement the subdev pad .enum_mbus_code() operation to enumerate media
bus codes on the sink and source pads.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/imx/imx7-mipi-csis.c

index 1ccbea2..e2403b4 100644 (file)
@@ -752,6 +752,38 @@ static int mipi_csis_get_fmt(struct v4l2_subdev *mipi_sd,
        return 0;
 }
 
+static int mipi_csis_enum_mbus_code(struct v4l2_subdev *mipi_sd,
+                                   struct v4l2_subdev_pad_config *cfg,
+                                   struct v4l2_subdev_mbus_code_enum *code)
+{
+       struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
+
+       /*
+        * The CSIS can't transcode in any way, the source format is identical
+        * to the sink format.
+        */
+       if (code->pad == CSIS_PAD_SOURCE) {
+               struct v4l2_mbus_framefmt *fmt;
+
+               if (code->index > 0)
+                       return -EINVAL;
+
+               fmt = mipi_csis_get_format(state, cfg, code->which, code->pad);
+               code->code = fmt->code;
+               return 0;
+       }
+
+       if (code->pad != CSIS_PAD_SINK)
+               return -EINVAL;
+
+       if (code->index >= ARRAY_SIZE(mipi_csis_formats))
+               return -EINVAL;
+
+       code->code = mipi_csis_formats[code->index].code;
+
+       return 0;
+}
+
 static int mipi_csis_set_fmt(struct v4l2_subdev *mipi_sd,
                             struct v4l2_subdev_pad_config *cfg,
                             struct v4l2_subdev_format *sdformat)
@@ -881,6 +913,7 @@ static const struct v4l2_subdev_video_ops mipi_csis_video_ops = {
 
 static const struct v4l2_subdev_pad_ops mipi_csis_pad_ops = {
        .init_cfg               = mipi_csis_init_cfg,
+       .enum_mbus_code         = mipi_csis_enum_mbus_code,
        .get_fmt                = mipi_csis_get_fmt,
        .set_fmt                = mipi_csis_set_fmt,
 };