[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>
This commit is contained in:
parent
69c80dc901
commit
9f717e9022
1 changed files with 7 additions and 29 deletions
|
@ -919,38 +919,16 @@ static int ov772x_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
|
||||||
static int ov772x_try_fmt(struct v4l2_subdev *sd,
|
static int ov772x_try_fmt(struct v4l2_subdev *sd,
|
||||||
struct v4l2_mbus_framefmt *mf)
|
struct v4l2_mbus_framefmt *mf)
|
||||||
{
|
{
|
||||||
struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev);
|
const struct ov772x_color_format *cfmt;
|
||||||
const struct ov772x_win_size *win;
|
const struct ov772x_win_size *win;
|
||||||
int i;
|
|
||||||
|
|
||||||
/*
|
ov772x_select_params(mf, &cfmt, &win);
|
||||||
* select suitable win
|
|
||||||
*/
|
|
||||||
win = ov772x_select_win(mf->width, mf->height);
|
|
||||||
|
|
||||||
mf->width = win->width;
|
mf->code = cfmt->code;
|
||||||
mf->height = win->height;
|
mf->width = win->width;
|
||||||
mf->field = V4L2_FIELD_NONE;
|
mf->height = win->height;
|
||||||
|
mf->field = V4L2_FIELD_NONE;
|
||||||
for (i = 0; i < ARRAY_SIZE(ov772x_cfmts); i++)
|
mf->colorspace = cfmt->colorspace;
|
||||||
if (mf->code == ov772x_cfmts[i].code)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (i == ARRAY_SIZE(ov772x_cfmts)) {
|
|
||||||
/* Unsupported format requested. Propose either */
|
|
||||||
if (priv->cfmt) {
|
|
||||||
/* the current one or */
|
|
||||||
mf->colorspace = priv->cfmt->colorspace;
|
|
||||||
mf->code = priv->cfmt->code;
|
|
||||||
} else {
|
|
||||||
/* the default one */
|
|
||||||
mf->colorspace = ov772x_cfmts[0].colorspace;
|
|
||||||
mf->code = ov772x_cfmts[0].code;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Also return the colorspace */
|
|
||||||
mf->colorspace = ov772x_cfmts[i].colorspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue