media: staging/imx: Implement init_cfg subdev pad op
authorSteve Longerbeam <slongerbeam@gmail.com>
Sun, 11 Feb 2018 18:29:34 +0000 (13:29 -0500)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 26 Feb 2018 15:32:06 +0000 (10:32 -0500)
Implement the init_cfg pad op in all imx-media subdevices. The try
formats are initialized to the current active formats on all pads.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/staging/media/imx/imx-ic-prp.c
drivers/staging/media/imx/imx-ic-prpencvf.c
drivers/staging/media/imx/imx-media-csi.c
drivers/staging/media/imx/imx-media-utils.c
drivers/staging/media/imx/imx-media-vdic.c
drivers/staging/media/imx/imx-media.h
drivers/staging/media/imx/imx6-mipi-csi2.c

index c6d7e80932add0171d3cb2baeb0d5edadd52a840..98923fc844cef32e6e4744d7774a02a64648f98c 100644 (file)
@@ -462,6 +462,7 @@ static int prp_registered(struct v4l2_subdev *sd)
 }
 
 static const struct v4l2_subdev_pad_ops prp_pad_ops = {
+       .init_cfg = imx_media_init_cfg,
        .enum_mbus_code = prp_enum_mbus_code,
        .get_fmt = prp_get_fmt,
        .set_fmt = prp_set_fmt,
index 60f392aca5532d2d325b74090033ae97c254d4fb..ae453fd422f061f834372abf4c9bf42e02bf165a 100644 (file)
@@ -1253,6 +1253,7 @@ static void prp_unregistered(struct v4l2_subdev *sd)
 }
 
 static const struct v4l2_subdev_pad_ops prp_pad_ops = {
+       .init_cfg = imx_media_init_cfg,
        .enum_mbus_code = prp_enum_mbus_code,
        .enum_frame_size = prp_enum_frame_size,
        .get_fmt = prp_get_fmt,
index 49b57466e88dc69fa3a7a40c818d48f9323e4276..5a195f80a24d7021f376f9b0b72f8ba56be7e631 100644 (file)
@@ -1714,6 +1714,7 @@ static const struct v4l2_subdev_video_ops csi_video_ops = {
 };
 
 static const struct v4l2_subdev_pad_ops csi_pad_ops = {
+       .init_cfg = imx_media_init_cfg,
        .enum_mbus_code = csi_enum_mbus_code,
        .enum_frame_size = csi_enum_frame_size,
        .enum_frame_interval = csi_enum_frame_interval,
index 13dafa77a2eba898a3e9cbf08ad4437cf1ea4ab7..8920f9b6eb0c682213573550cece8c575ff177bc 100644 (file)
@@ -464,6 +464,35 @@ int imx_media_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus,
 }
 EXPORT_SYMBOL_GPL(imx_media_init_mbus_fmt);
 
+/*
+ * Initializes the TRY format to the ACTIVE format on all pads
+ * of a subdev. Can be used as the .init_cfg pad operation.
+ */
+int imx_media_init_cfg(struct v4l2_subdev *sd,
+                      struct v4l2_subdev_pad_config *cfg)
+{
+       struct v4l2_mbus_framefmt *mf_try;
+       struct v4l2_subdev_format format;
+       unsigned int pad;
+       int ret;
+
+       for (pad = 0; pad < sd->entity.num_pads; pad++) {
+               memset(&format, 0, sizeof(format));
+
+               format.pad = pad;
+               format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+               ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &format);
+               if (ret)
+                       continue;
+
+               mf_try = v4l2_subdev_get_try_format(sd, cfg, pad);
+               *mf_try = format.format;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(imx_media_init_cfg);
+
 /*
  * Check whether the field and colorimetry parameters in tryfmt are
  * uninitialized, and if so fill them with the values from fmt,
index ed356844cdf62df1281fd4477d8aa7aa93a0e746..482250d47e7cbb7a8b748b976646f29aae2aed3f 100644 (file)
@@ -909,6 +909,7 @@ static void vdic_unregistered(struct v4l2_subdev *sd)
 }
 
 static const struct v4l2_subdev_pad_ops vdic_pad_ops = {
+       .init_cfg = imx_media_init_cfg,
        .enum_mbus_code = vdic_enum_mbus_code,
        .get_fmt = vdic_get_fmt,
        .set_fmt = vdic_set_fmt,
index 2fd6dfdf37d649cb8e6af42b56bfa8400cd665b5..e945e0ed6dd61956592fef2a88afab96c946fb46 100644 (file)
@@ -172,6 +172,8 @@ int imx_media_enum_ipu_format(u32 *code, u32 index, enum codespace_sel cs_sel);
 int imx_media_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus,
                            u32 width, u32 height, u32 code, u32 field,
                            const struct imx_media_pixfmt **cc);
+int imx_media_init_cfg(struct v4l2_subdev *sd,
+                      struct v4l2_subdev_pad_config *cfg);
 void imx_media_fill_default_mbus_fields(struct v4l2_mbus_framefmt *tryfmt,
                                        struct v4l2_mbus_framefmt *fmt,
                                        bool ic_route);
index 477d191c568bd4a1550f8c4d07b998aca02bf4ea..f74c61022b007b321a3e2fc607b28c14e2914a6b 100644 (file)
@@ -531,6 +531,7 @@ static const struct v4l2_subdev_video_ops csi2_video_ops = {
 };
 
 static const struct v4l2_subdev_pad_ops csi2_pad_ops = {
+       .init_cfg = imx_media_init_cfg,
        .get_fmt = csi2_get_fmt,
        .set_fmt = csi2_set_fmt,
 };