[media] v4l2: replace try_mbus_fmt by set_fmt
[deliverable/linux.git] / drivers / media / i2c / soc_camera / mt9m001.c
index 06f4e116978de1ed9a58d42c13ac1e10d1d09bc5..4fbdd1e9f7ee0e85538174151114623f08030413 100644 (file)
@@ -205,7 +205,7 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
 
        /*
         * The caller provides a supported format, as verified per
-        * call to .try_mbus_fmt()
+        * call to .set_fmt(FORMAT_TRY).
         */
        if (!ret)
                ret = reg_write(client, MT9M001_COLUMN_START, rect.left);
@@ -298,13 +298,18 @@ static int mt9m001_s_fmt(struct v4l2_subdev *sd,
        return ret;
 }
 
-static int mt9m001_try_fmt(struct v4l2_subdev *sd,
-                          struct v4l2_mbus_framefmt *mf)
+static int mt9m001_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);
        struct mt9m001 *mt9m001 = to_mt9m001(client);
        const struct mt9m001_datafmt *fmt;
 
+       if (format->pad)
+               return -EINVAL;
+
        v4l_bound_align_image(&mf->width, MT9M001_MIN_WIDTH,
                MT9M001_MAX_WIDTH, 1,
                &mf->height, MT9M001_MIN_HEIGHT + mt9m001->y_skip_top,
@@ -322,6 +327,9 @@ static int mt9m001_try_fmt(struct v4l2_subdev *sd,
 
        mf->colorspace  = fmt->colorspace;
 
+       if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
+               return mt9m001_s_fmt(sd, mf);
+       cfg->try_fmt = *mf;
        return 0;
 }
 
@@ -617,8 +625,6 @@ static int mt9m001_s_mbus_config(struct v4l2_subdev *sd,
 
 static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = {
        .s_stream       = mt9m001_s_stream,
-       .s_mbus_fmt     = mt9m001_s_fmt,
-       .try_mbus_fmt   = mt9m001_try_fmt,
        .s_crop         = mt9m001_s_crop,
        .g_crop         = mt9m001_g_crop,
        .cropcap        = mt9m001_cropcap,
@@ -633,6 +639,7 @@ static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
 static const struct v4l2_subdev_pad_ops mt9m001_subdev_pad_ops = {
        .enum_mbus_code = mt9m001_enum_mbus_code,
        .get_fmt        = mt9m001_get_fmt,
+       .set_fmt        = mt9m001_set_fmt,
 };
 
 static struct v4l2_subdev_ops mt9m001_subdev_ops = {
This page took 0.025743 seconds and 5 git commands to generate.