[media] ov2640: avoid calling ov2640_select_win() twice
Simplify ov2640_set_params and ov2640_set_fmt. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:

committed by
Mauro Carvalho Chehab

parent
34b92def75
commit
aa23c0533c
@@ -772,15 +772,15 @@ static const struct ov2640_win_size *ov2640_select_win(u32 *width, u32 *height)
|
|||||||
return &ov2640_supported_win_sizes[default_size];
|
return &ov2640_supported_win_sizes[default_size];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
|
static int ov2640_set_params(struct i2c_client *client,
|
||||||
u32 code)
|
const struct ov2640_win_size *win, u32 code)
|
||||||
{
|
{
|
||||||
struct ov2640_priv *priv = to_ov2640(client);
|
struct ov2640_priv *priv = to_ov2640(client);
|
||||||
const struct regval_list *selected_cfmt_regs;
|
const struct regval_list *selected_cfmt_regs;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* select win */
|
/* select win */
|
||||||
priv->win = ov2640_select_win(width, height);
|
priv->win = win;
|
||||||
|
|
||||||
/* select format */
|
/* select format */
|
||||||
priv->cfmt_code = 0;
|
priv->cfmt_code = 0;
|
||||||
@@ -836,8 +836,6 @@ static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
priv->cfmt_code = code;
|
priv->cfmt_code = code;
|
||||||
*width = priv->win->width;
|
|
||||||
*height = priv->win->height;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -881,14 +879,13 @@ static int ov2640_set_fmt(struct v4l2_subdev *sd,
|
|||||||
{
|
{
|
||||||
struct v4l2_mbus_framefmt *mf = &format->format;
|
struct v4l2_mbus_framefmt *mf = &format->format;
|
||||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||||
|
const struct ov2640_win_size *win;
|
||||||
|
|
||||||
if (format->pad)
|
if (format->pad)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
/* select suitable win */
|
||||||
* select suitable win, but don't store it
|
win = ov2640_select_win(&mf->width, &mf->height);
|
||||||
*/
|
|
||||||
ov2640_select_win(&mf->width, &mf->height);
|
|
||||||
|
|
||||||
mf->field = V4L2_FIELD_NONE;
|
mf->field = V4L2_FIELD_NONE;
|
||||||
mf->colorspace = V4L2_COLORSPACE_SRGB;
|
mf->colorspace = V4L2_COLORSPACE_SRGB;
|
||||||
@@ -905,8 +902,7 @@ static int ov2640_set_fmt(struct v4l2_subdev *sd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
|
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
|
||||||
return ov2640_set_params(client, &mf->width,
|
return ov2640_set_params(client, win, mf->code);
|
||||||
&mf->height, mf->code);
|
|
||||||
cfg->try_fmt = *mf;
|
cfg->try_fmt = *mf;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user