diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-07-18 09:58:21 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-15 16:10:18 -0400 |
commit | 9f717e9022d60fb653bad47a320bf0499c6fb549 (patch) | |
tree | 3c1e0f724f6494bf105f6b96ebf3ca66f244ffd5 /drivers/media/i2c | |
parent | 69c80dc90146463bf9a6820e5c0432fad8e0d0c1 (diff) |
[media] ov772x: try_fmt must not default to the current format
If the requested format isn't supported, return a fixed default format
instead of the current format.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r-- | drivers/media/i2c/soc_camera/ov772x.c | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c index c7bb988e295e..c02676b023f2 100644 --- a/drivers/media/i2c/soc_camera/ov772x.c +++ b/drivers/media/i2c/soc_camera/ov772x.c | |||
@@ -919,38 +919,16 @@ static int ov772x_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) | |||
919 | static int ov772x_try_fmt(struct v4l2_subdev *sd, | 919 | static int ov772x_try_fmt(struct v4l2_subdev *sd, |
920 | struct v4l2_mbus_framefmt *mf) | 920 | struct v4l2_mbus_framefmt *mf) |
921 | { | 921 | { |
922 | struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev); | 922 | const struct ov772x_color_format *cfmt; |
923 | const struct ov772x_win_size *win; | 923 | const struct ov772x_win_size *win; |
924 | int i; | ||
925 | |||
926 | /* | ||
927 | * select suitable win | ||
928 | */ | ||
929 | win = ov772x_select_win(mf->width, mf->height); | ||
930 | 924 | ||
931 | mf->width = win->width; | 925 | ov772x_select_params(mf, &cfmt, &win); |
932 | mf->height = win->height; | ||
933 | mf->field = V4L2_FIELD_NONE; | ||
934 | |||
935 | for (i = 0; i < ARRAY_SIZE(ov772x_cfmts); i++) | ||
936 | if (mf->code == ov772x_cfmts[i].code) | ||
937 | break; | ||
938 | 926 | ||
939 | if (i == ARRAY_SIZE(ov772x_cfmts)) { | 927 | mf->code = cfmt->code; |
940 | /* Unsupported format requested. Propose either */ | 928 | mf->width = win->width; |
941 | if (priv->cfmt) { | 929 | mf->height = win->height; |
942 | /* the current one or */ | 930 | mf->field = V4L2_FIELD_NONE; |
943 | mf->colorspace = priv->cfmt->colorspace; | 931 | mf->colorspace = cfmt->colorspace; |
944 | mf->code = priv->cfmt->code; | ||
945 | } else { | ||
946 | /* the default one */ | ||
947 | mf->colorspace = ov772x_cfmts[0].colorspace; | ||
948 | mf->code = ov772x_cfmts[0].code; | ||
949 | } | ||
950 | } else { | ||
951 | /* Also return the colorspace */ | ||
952 | mf->colorspace = ov772x_cfmts[i].colorspace; | ||
953 | } | ||
954 | 932 | ||
955 | return 0; | 933 | return 0; |
956 | } | 934 | } |