mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-11 07:30:16 +00:00
V4L/DVB (10098): ov772x: fix try_fmt calculation method
Don't modify driver's state in try_fmt, just verify format acceptability or adjust it to driver's capabilities. Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.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
77fe3d4a44
commit
f82a8569bf
@ -766,6 +766,27 @@ static int ov772x_set_register(struct soc_camera_device *icd,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const struct ov772x_win_size*
|
||||||
|
ov772x_select_win(u32 width, u32 height)
|
||||||
|
{
|
||||||
|
__u32 diff;
|
||||||
|
const struct ov772x_win_size *win;
|
||||||
|
|
||||||
|
/* default is QVGA */
|
||||||
|
diff = abs(width - ov772x_win_qvga.width) +
|
||||||
|
abs(height - ov772x_win_qvga.height);
|
||||||
|
win = &ov772x_win_qvga;
|
||||||
|
|
||||||
|
/* VGA */
|
||||||
|
if (diff >
|
||||||
|
abs(width - ov772x_win_vga.width) +
|
||||||
|
abs(height - ov772x_win_vga.height))
|
||||||
|
win = &ov772x_win_vga;
|
||||||
|
|
||||||
|
return win;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ov772x_set_fmt(struct soc_camera_device *icd,
|
static int ov772x_set_fmt(struct soc_camera_device *icd,
|
||||||
__u32 pixfmt,
|
__u32 pixfmt,
|
||||||
struct v4l2_rect *rect)
|
struct v4l2_rect *rect)
|
||||||
@ -786,34 +807,28 @@ static int ov772x_set_fmt(struct soc_camera_device *icd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* select win
|
||||||
|
*/
|
||||||
|
priv->win = ov772x_select_win(rect->width, rect->height);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ov772x_try_fmt(struct soc_camera_device *icd,
|
static int ov772x_try_fmt(struct soc_camera_device *icd,
|
||||||
struct v4l2_format *f)
|
struct v4l2_format *f)
|
||||||
{
|
{
|
||||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||||
struct ov772x_priv *priv;
|
const struct ov772x_win_size *win;
|
||||||
|
|
||||||
priv = container_of(icd, struct ov772x_priv, icd);
|
/*
|
||||||
|
* select suitable win
|
||||||
|
*/
|
||||||
|
win = ov772x_select_win(pix->width, pix->height);
|
||||||
|
|
||||||
/* QVGA */
|
pix->width = win->width;
|
||||||
if (pix->width <= ov772x_win_qvga.width ||
|
pix->height = win->height;
|
||||||
pix->height <= ov772x_win_qvga.height) {
|
pix->field = V4L2_FIELD_NONE;
|
||||||
priv->win = &ov772x_win_qvga;
|
|
||||||
pix->width = ov772x_win_qvga.width;
|
|
||||||
pix->height = ov772x_win_qvga.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* VGA */
|
|
||||||
else if (pix->width <= ov772x_win_vga.width ||
|
|
||||||
pix->height <= ov772x_win_vga.height) {
|
|
||||||
priv->win = &ov772x_win_vga;
|
|
||||||
pix->width = ov772x_win_vga.width;
|
|
||||||
pix->height = ov772x_win_vga.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
pix->field = V4L2_FIELD_NONE;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user