Commit 09e620c6 authored by Akinobu Mita's avatar Akinobu Mita Committed by Mauro Carvalho Chehab

media: ov772x: use v4l2_ctrl to get current control value

The ov772x driver provides three V4L2 controls and the current value of
each control is saved as a variable in the private data structure.

We don't need to keep track of the current value by ourself, if we use
v4l2_ctrl returned from v4l2_ctrl_new_std() instead.

This is a preparatory change to avoid accessing registers under power
saving mode.  This simplifies s_ctrl() by making it just return without
saving the current control value in private area when it is called under
power saving mode.

Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 80dc2a49
...@@ -419,10 +419,10 @@ struct ov772x_priv { ...@@ -419,10 +419,10 @@ struct ov772x_priv {
struct gpio_desc *rstb_gpio; struct gpio_desc *rstb_gpio;
const struct ov772x_color_format *cfmt; const struct ov772x_color_format *cfmt;
const struct ov772x_win_size *win; const struct ov772x_win_size *win;
unsigned short flag_vflip:1; struct v4l2_ctrl *vflip_ctrl;
unsigned short flag_hflip:1; struct v4l2_ctrl *hflip_ctrl;
/* band_filter = COM8[5] ? 256 - BDBASE : 0 */ /* band_filter = COM8[5] ? 256 - BDBASE : 0 */
unsigned short band_filter; struct v4l2_ctrl *band_filter_ctrl;
unsigned int fps; unsigned int fps;
/* lock to protect power_count */ /* lock to protect power_count */
struct mutex lock; struct mutex lock;
...@@ -768,13 +768,11 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -768,13 +768,11 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl)
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_VFLIP: case V4L2_CID_VFLIP:
val = ctrl->val ? VFLIP_IMG : 0x00; val = ctrl->val ? VFLIP_IMG : 0x00;
priv->flag_vflip = ctrl->val;
if (priv->info && (priv->info->flags & OV772X_FLAG_VFLIP)) if (priv->info && (priv->info->flags & OV772X_FLAG_VFLIP))
val ^= VFLIP_IMG; val ^= VFLIP_IMG;
return ov772x_mask_set(client, COM3, VFLIP_IMG, val); return ov772x_mask_set(client, COM3, VFLIP_IMG, val);
case V4L2_CID_HFLIP: case V4L2_CID_HFLIP:
val = ctrl->val ? HFLIP_IMG : 0x00; val = ctrl->val ? HFLIP_IMG : 0x00;
priv->flag_hflip = ctrl->val;
if (priv->info && (priv->info->flags & OV772X_FLAG_HFLIP)) if (priv->info && (priv->info->flags & OV772X_FLAG_HFLIP))
val ^= HFLIP_IMG; val ^= HFLIP_IMG;
return ov772x_mask_set(client, COM3, HFLIP_IMG, val); return ov772x_mask_set(client, COM3, HFLIP_IMG, val);
...@@ -794,8 +792,7 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -794,8 +792,7 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl)
ret = ov772x_mask_set(client, BDBASE, ret = ov772x_mask_set(client, BDBASE,
0xff, val); 0xff, val);
} }
if (!ret)
priv->band_filter = ctrl->val;
return ret; return ret;
} }
...@@ -1075,9 +1072,9 @@ static int ov772x_set_params(struct ov772x_priv *priv, ...@@ -1075,9 +1072,9 @@ static int ov772x_set_params(struct ov772x_priv *priv,
val |= VFLIP_IMG; val |= VFLIP_IMG;
if (priv->info && (priv->info->flags & OV772X_FLAG_HFLIP)) if (priv->info && (priv->info->flags & OV772X_FLAG_HFLIP))
val |= HFLIP_IMG; val |= HFLIP_IMG;
if (priv->flag_vflip) if (priv->vflip_ctrl->val)
val ^= VFLIP_IMG; val ^= VFLIP_IMG;
if (priv->flag_hflip) if (priv->hflip_ctrl->val)
val ^= HFLIP_IMG; val ^= HFLIP_IMG;
ret = ov772x_mask_set(client, ret = ov772x_mask_set(client,
...@@ -1096,11 +1093,13 @@ static int ov772x_set_params(struct ov772x_priv *priv, ...@@ -1096,11 +1093,13 @@ static int ov772x_set_params(struct ov772x_priv *priv,
goto ov772x_set_fmt_error; goto ov772x_set_fmt_error;
/* Set COM8. */ /* Set COM8. */
if (priv->band_filter) { if (priv->band_filter_ctrl->val) {
unsigned short band_filter = priv->band_filter_ctrl->val;
ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, BNDF_ON_OFF); ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, BNDF_ON_OFF);
if (!ret) if (!ret)
ret = ov772x_mask_set(client, BDBASE, ret = ov772x_mask_set(client, BDBASE,
0xff, 256 - priv->band_filter); 0xff, 256 - band_filter);
if (ret < 0) if (ret < 0)
goto ov772x_set_fmt_error; goto ov772x_set_fmt_error;
} }
...@@ -1341,12 +1340,13 @@ static int ov772x_probe(struct i2c_client *client, ...@@ -1341,12 +1340,13 @@ static int ov772x_probe(struct i2c_client *client,
v4l2_i2c_subdev_init(&priv->subdev, client, &ov772x_subdev_ops); v4l2_i2c_subdev_init(&priv->subdev, client, &ov772x_subdev_ops);
v4l2_ctrl_handler_init(&priv->hdl, 3); v4l2_ctrl_handler_init(&priv->hdl, 3);
v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, priv->vflip_ctrl = v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops,
V4L2_CID_VFLIP, 0, 1, 1, 0); V4L2_CID_VFLIP, 0, 1, 1, 0);
v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, priv->hflip_ctrl = v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops,
V4L2_CID_HFLIP, 0, 1, 1, 0); V4L2_CID_HFLIP, 0, 1, 1, 0);
v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, priv->band_filter_ctrl = v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops,
V4L2_CID_BAND_STOP_FILTER, 0, 256, 1, 0); V4L2_CID_BAND_STOP_FILTER,
0, 256, 1, 0);
priv->subdev.ctrl_handler = &priv->hdl; priv->subdev.ctrl_handler = &priv->hdl;
if (priv->hdl.error) { if (priv->hdl.error) {
ret = priv->hdl.error; ret = priv->hdl.error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment