These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / media / i2c / soc_camera / ov2640.c
index e3c907a..9b4f5de 100644 (file)
@@ -845,12 +845,17 @@ err:
        return ret;
 }
 
-static int ov2640_g_fmt(struct v4l2_subdev *sd,
-                       struct v4l2_mbus_framefmt *mf)
+static int ov2640_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 ov2640_priv *priv = to_ov2640(client);
 
+       if (format->pad)
+               return -EINVAL;
+
        if (!priv->win) {
                u32 width = SVGA_WIDTH, height = SVGA_HEIGHT;
                priv->win = ov2640_select_win(&width, &height);
@@ -876,33 +881,16 @@ static int ov2640_g_fmt(struct v4l2_subdev *sd,
        return 0;
 }
 
-static int ov2640_s_fmt(struct v4l2_subdev *sd,
-                       struct v4l2_mbus_framefmt *mf)
+static int ov2640_set_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);
-       int ret;
 
+       if (format->pad)
+               return -EINVAL;
 
-       switch (mf->code) {
-       case MEDIA_BUS_FMT_RGB565_2X8_BE:
-       case MEDIA_BUS_FMT_RGB565_2X8_LE:
-               mf->colorspace = V4L2_COLORSPACE_SRGB;
-               break;
-       default:
-               mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
-       case MEDIA_BUS_FMT_YUYV8_2X8:
-       case MEDIA_BUS_FMT_UYVY8_2X8:
-               mf->colorspace = V4L2_COLORSPACE_JPEG;
-       }
-
-       ret = ov2640_set_params(client, &mf->width, &mf->height, mf->code);
-
-       return ret;
-}
-
-static int ov2640_try_fmt(struct v4l2_subdev *sd,
-                         struct v4l2_mbus_framefmt *mf)
-{
        /*
         * select suitable win, but don't store it
         */
@@ -922,16 +910,21 @@ static int ov2640_try_fmt(struct v4l2_subdev *sd,
                mf->colorspace = V4L2_COLORSPACE_JPEG;
        }
 
+       if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
+               return ov2640_set_params(client, &mf->width,
+                                        &mf->height, mf->code);
+       cfg->try_fmt = *mf;
        return 0;
 }
 
-static int ov2640_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-                          u32 *code)
+static int ov2640_enum_mbus_code(struct v4l2_subdev *sd,
+               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_mbus_code_enum *code)
 {
-       if (index >= ARRAY_SIZE(ov2640_codes))
+       if (code->pad || code->index >= ARRAY_SIZE(ov2640_codes))
                return -EINVAL;
 
-       *code = ov2640_codes[index];
+       code->code = ov2640_codes[code->index];
        return 0;
 }
 
@@ -1031,18 +1024,21 @@ static int ov2640_g_mbus_config(struct v4l2_subdev *sd,
 
 static struct v4l2_subdev_video_ops ov2640_subdev_video_ops = {
        .s_stream       = ov2640_s_stream,
-       .g_mbus_fmt     = ov2640_g_fmt,
-       .s_mbus_fmt     = ov2640_s_fmt,
-       .try_mbus_fmt   = ov2640_try_fmt,
        .cropcap        = ov2640_cropcap,
        .g_crop         = ov2640_g_crop,
-       .enum_mbus_fmt  = ov2640_enum_fmt,
        .g_mbus_config  = ov2640_g_mbus_config,
 };
 
+static const struct v4l2_subdev_pad_ops ov2640_subdev_pad_ops = {
+       .enum_mbus_code = ov2640_enum_mbus_code,
+       .get_fmt        = ov2640_get_fmt,
+       .set_fmt        = ov2640_set_fmt,
+};
+
 static struct v4l2_subdev_ops ov2640_subdev_ops = {
        .core   = &ov2640_subdev_core_ops,
        .video  = &ov2640_subdev_video_ops,
+       .pad    = &ov2640_subdev_pad_ops,
 };
 
 /* OF probe functions */