These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / media / i2c / soc_camera / ov9740.c
index 841dc55..03a7fc7 100644 (file)
@@ -704,25 +704,35 @@ static int ov9740_s_fmt(struct v4l2_subdev *sd,
        return ret;
 }
 
-static int ov9740_try_fmt(struct v4l2_subdev *sd,
-                         struct v4l2_mbus_framefmt *mf)
+static int ov9740_set_fmt(struct v4l2_subdev *sd,
+               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_format *format)
 {
+       struct v4l2_mbus_framefmt *mf = &format->format;
+
+       if (format->pad)
+               return -EINVAL;
+
        ov9740_res_roundup(&mf->width, &mf->height);
 
        mf->field = V4L2_FIELD_NONE;
        mf->code = MEDIA_BUS_FMT_YUYV8_2X8;
        mf->colorspace = V4L2_COLORSPACE_SRGB;
 
+       if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
+               return ov9740_s_fmt(sd, mf);
+       cfg->try_fmt = *mf;
        return 0;
 }
 
-static int ov9740_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-                          u32 *code)
+static int ov9740_enum_mbus_code(struct v4l2_subdev *sd,
+               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_mbus_code_enum *code)
 {
-       if (index >= ARRAY_SIZE(ov9740_codes))
+       if (code->pad || code->index >= ARRAY_SIZE(ov9740_codes))
                return -EINVAL;
 
-       *code = ov9740_codes[index];
+       code->code = ov9740_codes[code->index];
 
        return 0;
 }
@@ -904,9 +914,6 @@ static int ov9740_g_mbus_config(struct v4l2_subdev *sd,
 
 static struct v4l2_subdev_video_ops ov9740_video_ops = {
        .s_stream       = ov9740_s_stream,
-       .s_mbus_fmt     = ov9740_s_fmt,
-       .try_mbus_fmt   = ov9740_try_fmt,
-       .enum_mbus_fmt  = ov9740_enum_fmt,
        .cropcap        = ov9740_cropcap,
        .g_crop         = ov9740_g_crop,
        .g_mbus_config  = ov9740_g_mbus_config,
@@ -920,9 +927,15 @@ static struct v4l2_subdev_core_ops ov9740_core_ops = {
 #endif
 };
 
+static const struct v4l2_subdev_pad_ops ov9740_pad_ops = {
+       .enum_mbus_code = ov9740_enum_mbus_code,
+       .set_fmt        = ov9740_set_fmt,
+};
+
 static struct v4l2_subdev_ops ov9740_subdev_ops = {
-       .core                   = &ov9740_core_ops,
-       .video                  = &ov9740_video_ops,
+       .core   = &ov9740_core_ops,
+       .video  = &ov9740_video_ops,
+       .pad    = &ov9740_pad_ops,
 };
 
 static const struct v4l2_ctrl_ops ov9740_ctrl_ops = {