summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-05-04 07:25:51 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-04-14 22:32:56 -0300
commitaa23c0533c340fe37f290fa7fd112713434942a6 (patch)
treee080e3367fd3315cf7d30439aee62de50caf0d8a
parent34b92def75da204c1cb75d43f55bc99ac371531a (diff)
[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>
-rw-r--r--drivers/media/i2c/ov2640.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c
index b67e44c6f48c..d55ca37dc12f 100644
--- a/drivers/media/i2c/ov2640.c
+++ b/drivers/media/i2c/ov2640.c
@@ -772,15 +772,15 @@ static const struct ov2640_win_size *ov2640_select_win(u32 *width, u32 *height)
return &ov2640_supported_win_sizes[default_size];
}
-static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
- u32 code)
+static int ov2640_set_params(struct i2c_client *client,
+ const struct ov2640_win_size *win, u32 code)
{
struct ov2640_priv *priv = to_ov2640(client);
const struct regval_list *selected_cfmt_regs;
int ret;
/* select win */
- priv->win = ov2640_select_win(width, height);
+ priv->win = win;
/* select format */
priv->cfmt_code = 0;
@@ -836,8 +836,6 @@ static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
goto err;
priv->cfmt_code = code;
- *width = priv->win->width;
- *height = priv->win->height;
return 0;
@@ -881,14 +879,13 @@ static int ov2640_set_fmt(struct v4l2_subdev *sd,
{
struct v4l2_mbus_framefmt *mf = &format->format;
struct i2c_client *client = v4l2_get_subdevdata(sd);
+ const struct ov2640_win_size *win;
if (format->pad)
return -EINVAL;
- /*
- * select suitable win, but don't store it
- */
- ov2640_select_win(&mf->width, &mf->height);
+ /* select suitable win */
+ win = ov2640_select_win(&mf->width, &mf->height);
mf->field = V4L2_FIELD_NONE;
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)
- return ov2640_set_params(client, &mf->width,
- &mf->height, mf->code);
+ return ov2640_set_params(client, win, mf->code);
cfg->try_fmt = *mf;
return 0;
}