aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/i2c/soc_camera/ov772x.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c
index 657d67294686..0f7b9d1b9c57 100644
--- a/drivers/media/i2c/soc_camera/ov772x.c
+++ b/drivers/media/i2c/soc_camera/ov772x.c
@@ -894,38 +894,15 @@ static int ov772x_get_fmt(struct v4l2_subdev *sd,
894 return 0; 894 return 0;
895} 895}
896 896
897static int ov772x_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
898{
899 struct ov772x_priv *priv = to_ov772x(sd);
900 const struct ov772x_color_format *cfmt;
901 const struct ov772x_win_size *win;
902 int ret;
903
904 ov772x_select_params(mf, &cfmt, &win);
905
906 ret = ov772x_set_params(priv, cfmt, win);
907 if (ret < 0)
908 return ret;
909
910 priv->win = win;
911 priv->cfmt = cfmt;
912
913 mf->code = cfmt->code;
914 mf->width = win->rect.width;
915 mf->height = win->rect.height;
916 mf->field = V4L2_FIELD_NONE;
917 mf->colorspace = cfmt->colorspace;
918
919 return 0;
920}
921
922static int ov772x_set_fmt(struct v4l2_subdev *sd, 897static int ov772x_set_fmt(struct v4l2_subdev *sd,
923 struct v4l2_subdev_pad_config *cfg, 898 struct v4l2_subdev_pad_config *cfg,
924 struct v4l2_subdev_format *format) 899 struct v4l2_subdev_format *format)
925{ 900{
901 struct ov772x_priv *priv = to_ov772x(sd);
926 struct v4l2_mbus_framefmt *mf = &format->format; 902 struct v4l2_mbus_framefmt *mf = &format->format;
927 const struct ov772x_color_format *cfmt; 903 const struct ov772x_color_format *cfmt;
928 const struct ov772x_win_size *win; 904 const struct ov772x_win_size *win;
905 int ret;
929 906
930 if (format->pad) 907 if (format->pad)
931 return -EINVAL; 908 return -EINVAL;
@@ -938,9 +915,17 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
938 mf->field = V4L2_FIELD_NONE; 915 mf->field = V4L2_FIELD_NONE;
939 mf->colorspace = cfmt->colorspace; 916 mf->colorspace = cfmt->colorspace;
940 917
941 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 918 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
942 return ov772x_s_fmt(sd, mf); 919 cfg->try_fmt = *mf;
943 cfg->try_fmt = *mf; 920 return 0;
921 }
922
923 ret = ov772x_set_params(priv, cfmt, win);
924 if (ret < 0)
925 return ret;
926
927 priv->win = win;
928 priv->cfmt = cfmt;
944 return 0; 929 return 0;
945} 930}
946 931