提交 aa23c053 编写于 作者: H Hans Verkuil 提交者: Mauro Carvalho Chehab

[media] ov2640: avoid calling ov2640_select_win() twice

Simplify ov2640_set_params and ov2640_set_fmt.
Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
Acked-by: NGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
上级 34b92def
...@@ -772,15 +772,15 @@ static const struct ov2640_win_size *ov2640_select_win(u32 *width, u32 *height) ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册