These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / media / i2c / ak881x.c
index 69aeaf3..d3b965e 100644 (file)
@@ -93,12 +93,17 @@ static int ak881x_s_register(struct v4l2_subdev *sd,
 }
 #endif
 
-static int ak881x_try_g_mbus_fmt(struct v4l2_subdev *sd,
-                                struct v4l2_mbus_framefmt *mf)
+static int ak881x_fill_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 ak881x *ak881x = to_ak881x(client);
 
+       if (format->pad)
+               return -EINVAL;
+
        v4l_bound_align_image(&mf->width, 0, 720, 2,
                              &mf->height, 0, ak881x->lines, 1, 0);
        mf->field       = V4L2_FIELD_INTERLACED;
@@ -108,23 +113,14 @@ static int ak881x_try_g_mbus_fmt(struct v4l2_subdev *sd,
        return 0;
 }
 
-static int ak881x_s_mbus_fmt(struct v4l2_subdev *sd,
-                            struct v4l2_mbus_framefmt *mf)
-{
-       if (mf->field != V4L2_FIELD_INTERLACED ||
-           mf->code != MEDIA_BUS_FMT_YUYV8_2X8)
-               return -EINVAL;
-
-       return ak881x_try_g_mbus_fmt(sd, mf);
-}
-
-static int ak881x_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index,
-                               u32 *code)
+static int ak881x_enum_mbus_code(struct v4l2_subdev *sd,
+               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_mbus_code_enum *code)
 {
-       if (index)
+       if (code->pad || code->index)
                return -EINVAL;
 
-       *code = MEDIA_BUS_FMT_YUYV8_2X8;
+       code->code = MEDIA_BUS_FMT_YUYV8_2X8;
        return 0;
 }
 
@@ -160,12 +156,12 @@ static int ak881x_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
        } else if (std == V4L2_STD_PAL_60) {
                vp1 = 7;
                ak881x->lines = 480;
-       } else if (std && !(std & ~V4L2_STD_PAL)) {
-               vp1 = 0xf;
-               ak881x->lines = 576;
-       } else if (std && !(std & ~V4L2_STD_NTSC)) {
+       } else if (std & V4L2_STD_NTSC) {
                vp1 = 0;
                ak881x->lines = 480;
+       } else if (std & V4L2_STD_PAL) {
+               vp1 = 0xf;
+               ak881x->lines = 576;
        } else {
                /* No SECAM or PAL_N/Nc supported */
                return -EINVAL;
@@ -211,18 +207,21 @@ static struct v4l2_subdev_core_ops ak881x_subdev_core_ops = {
 };
 
 static struct v4l2_subdev_video_ops ak881x_subdev_video_ops = {
-       .s_mbus_fmt     = ak881x_s_mbus_fmt,
-       .g_mbus_fmt     = ak881x_try_g_mbus_fmt,
-       .try_mbus_fmt   = ak881x_try_g_mbus_fmt,
        .cropcap        = ak881x_cropcap,
-       .enum_mbus_fmt  = ak881x_enum_mbus_fmt,
        .s_std_output   = ak881x_s_std_output,
        .s_stream       = ak881x_s_stream,
 };
 
+static const struct v4l2_subdev_pad_ops ak881x_subdev_pad_ops = {
+       .enum_mbus_code = ak881x_enum_mbus_code,
+       .set_fmt        = ak881x_fill_fmt,
+       .get_fmt        = ak881x_fill_fmt,
+};
+
 static struct v4l2_subdev_ops ak881x_subdev_ops = {
        .core   = &ak881x_subdev_core_ops,
        .video  = &ak881x_subdev_video_ops,
+       .pad    = &ak881x_subdev_pad_ops,
 };
 
 static int ak881x_probe(struct i2c_client *client,