These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / media / i2c / soc_camera / imx074.c
index ec89cfa..f68c235 100644 (file)
@@ -153,14 +153,24 @@ static int reg_read(struct i2c_client *client, const u16 addr)
        return buf[0] & 0xff; /* no sign-extension */
 }
 
-static int imx074_try_fmt(struct v4l2_subdev *sd,
-                         struct v4l2_mbus_framefmt *mf)
+static int imx074_set_fmt(struct v4l2_subdev *sd,
+               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_format *format)
 {
+       struct v4l2_mbus_framefmt *mf = &format->format;
        const struct imx074_datafmt *fmt = imx074_find_datafmt(mf->code);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+       struct imx074 *priv = to_imx074(client);
+
+       if (format->pad)
+               return -EINVAL;
 
        dev_dbg(sd->v4l2_dev->dev, "%s(%u)\n", __func__, mf->code);
 
        if (!fmt) {
+               /* MIPI CSI could have changed the format, double-check */
+               if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
+                       return -EINVAL;
                mf->code        = imx074_colour_fmts[0].code;
                mf->colorspace  = imx074_colour_fmts[0].colorspace;
        }
@@ -169,36 +179,27 @@ static int imx074_try_fmt(struct v4l2_subdev *sd,
        mf->height      = IMX074_HEIGHT;
        mf->field       = V4L2_FIELD_NONE;
 
-       return 0;
-}
-
-static int imx074_s_fmt(struct v4l2_subdev *sd,
-                       struct v4l2_mbus_framefmt *mf)
-{
-       struct i2c_client *client = v4l2_get_subdevdata(sd);
-       struct imx074 *priv = to_imx074(client);
-
-       dev_dbg(sd->v4l2_dev->dev, "%s(%u)\n", __func__, mf->code);
-
-       /* MIPI CSI could have changed the format, double-check */
-       if (!imx074_find_datafmt(mf->code))
-               return -EINVAL;
-
-       imx074_try_fmt(sd, mf);
-
-       priv->fmt = imx074_find_datafmt(mf->code);
+       if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
+               priv->fmt = imx074_find_datafmt(mf->code);
+       else
+               cfg->try_fmt = *mf;
 
        return 0;
 }
 
-static int imx074_g_fmt(struct v4l2_subdev *sd,
-                       struct v4l2_mbus_framefmt *mf)
+static int imx074_get_fmt(struct v4l2_subdev *sd,
+               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_format *format)
 {
+       struct v4l2_mbus_framefmt *mf = &format->format;
        struct i2c_client *client = v4l2_get_subdevdata(sd);
        struct imx074 *priv = to_imx074(client);
 
        const struct imx074_datafmt *fmt = priv->fmt;
 
+       if (format->pad)
+               return -EINVAL;
+
        mf->code        = fmt->code;
        mf->colorspace  = fmt->colorspace;
        mf->width       = IMX074_WIDTH;
@@ -235,13 +236,15 @@ static int imx074_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
        return 0;
 }
 
-static int imx074_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-                          u32 *code)
+static int imx074_enum_mbus_code(struct v4l2_subdev *sd,
+               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_mbus_code_enum *code)
 {
-       if ((unsigned int)index >= ARRAY_SIZE(imx074_colour_fmts))
+       if (code->pad ||
+           (unsigned int)code->index >= ARRAY_SIZE(imx074_colour_fmts))
                return -EINVAL;
 
-       *code = imx074_colour_fmts[index].code;
+       code->code = imx074_colour_fmts[code->index].code;
        return 0;
 }
 
@@ -275,10 +278,6 @@ static int imx074_g_mbus_config(struct v4l2_subdev *sd,
 
 static struct v4l2_subdev_video_ops imx074_subdev_video_ops = {
        .s_stream       = imx074_s_stream,
-       .s_mbus_fmt     = imx074_s_fmt,
-       .g_mbus_fmt     = imx074_g_fmt,
-       .try_mbus_fmt   = imx074_try_fmt,
-       .enum_mbus_fmt  = imx074_enum_fmt,
        .g_crop         = imx074_g_crop,
        .cropcap        = imx074_cropcap,
        .g_mbus_config  = imx074_g_mbus_config,
@@ -288,9 +287,16 @@ static struct v4l2_subdev_core_ops imx074_subdev_core_ops = {
        .s_power        = imx074_s_power,
 };
 
+static const struct v4l2_subdev_pad_ops imx074_subdev_pad_ops = {
+       .enum_mbus_code = imx074_enum_mbus_code,
+       .get_fmt        = imx074_get_fmt,
+       .set_fmt        = imx074_set_fmt,
+};
+
 static struct v4l2_subdev_ops imx074_subdev_ops = {
        .core   = &imx074_subdev_core_ops,
        .video  = &imx074_subdev_video_ops,
+       .pad    = &imx074_subdev_pad_ops,
 };
 
 static int imx074_video_probe(struct i2c_client *client)