Commit 985cdcb0 authored by Hugues Fruchet's avatar Hugues Fruchet Committed by Mauro Carvalho Chehab

media: ov5640: fix restore of last mode set

Mode setting depends on last mode set, in particular
because of exposure calculation when downscale mode
change between subsampling and scaling.
At stream on the last mode was wrongly set to current mode,
so no change was detected and exposure calculation
was not made, fix this.
Signed-off-by: default avatarHugues Fruchet <hugues.fruchet@st.com>
Reviewed-by: default avatarJacopo Mondi <jacopo@jmondi.org>
Tested-by: default avatarJacopo Mondi <jacopo@jmondi.org>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent a8f438c6
...@@ -226,6 +226,7 @@ struct ov5640_dev { ...@@ -226,6 +226,7 @@ struct ov5640_dev {
bool pending_fmt_change; bool pending_fmt_change;
const struct ov5640_mode_info *current_mode; const struct ov5640_mode_info *current_mode;
const struct ov5640_mode_info *last_mode;
enum ov5640_frame_rate current_fr; enum ov5640_frame_rate current_fr;
struct v4l2_fract frame_interval; struct v4l2_fract frame_interval;
...@@ -1629,10 +1630,10 @@ static int ov5640_set_mode_direct(struct ov5640_dev *sensor, ...@@ -1629,10 +1630,10 @@ static int ov5640_set_mode_direct(struct ov5640_dev *sensor,
return ov5640_load_regs(sensor, mode); return ov5640_load_regs(sensor, mode);
} }
static int ov5640_set_mode(struct ov5640_dev *sensor, static int ov5640_set_mode(struct ov5640_dev *sensor)
const struct ov5640_mode_info *orig_mode)
{ {
const struct ov5640_mode_info *mode = sensor->current_mode; const struct ov5640_mode_info *mode = sensor->current_mode;
const struct ov5640_mode_info *orig_mode = sensor->last_mode;
enum ov5640_downsize_mode dn_mode, orig_dn_mode; enum ov5640_downsize_mode dn_mode, orig_dn_mode;
bool auto_gain = sensor->ctrls.auto_gain->val == 1; bool auto_gain = sensor->ctrls.auto_gain->val == 1;
bool auto_exp = sensor->ctrls.auto_exp->val == V4L2_EXPOSURE_AUTO; bool auto_exp = sensor->ctrls.auto_exp->val == V4L2_EXPOSURE_AUTO;
...@@ -1694,6 +1695,7 @@ static int ov5640_set_mode(struct ov5640_dev *sensor, ...@@ -1694,6 +1695,7 @@ static int ov5640_set_mode(struct ov5640_dev *sensor,
return ret; return ret;
sensor->pending_mode_change = false; sensor->pending_mode_change = false;
sensor->last_mode = mode;
return 0; return 0;
...@@ -1719,6 +1721,7 @@ static int ov5640_restore_mode(struct ov5640_dev *sensor) ...@@ -1719,6 +1721,7 @@ static int ov5640_restore_mode(struct ov5640_dev *sensor)
ret = ov5640_load_regs(sensor, &ov5640_mode_init_data); ret = ov5640_load_regs(sensor, &ov5640_mode_init_data);
if (ret < 0) if (ret < 0)
return ret; return ret;
sensor->last_mode = &ov5640_mode_init_data;
ret = ov5640_mod_reg(sensor, OV5640_REG_SYS_ROOT_DIVIDER, 0x3f, ret = ov5640_mod_reg(sensor, OV5640_REG_SYS_ROOT_DIVIDER, 0x3f,
(ilog2(OV5640_SCLK2X_ROOT_DIVIDER_DEFAULT) << 2) | (ilog2(OV5640_SCLK2X_ROOT_DIVIDER_DEFAULT) << 2) |
...@@ -1727,7 +1730,7 @@ static int ov5640_restore_mode(struct ov5640_dev *sensor) ...@@ -1727,7 +1730,7 @@ static int ov5640_restore_mode(struct ov5640_dev *sensor)
return ret; return ret;
/* now restore the last capture mode */ /* now restore the last capture mode */
ret = ov5640_set_mode(sensor, &ov5640_mode_init_data); ret = ov5640_set_mode(sensor);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -2610,7 +2613,7 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable) ...@@ -2610,7 +2613,7 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
if (sensor->streaming == !enable) { if (sensor->streaming == !enable) {
if (enable && sensor->pending_mode_change) { if (enable && sensor->pending_mode_change) {
ret = ov5640_set_mode(sensor, sensor->current_mode); ret = ov5640_set_mode(sensor);
if (ret) if (ret)
goto out; goto out;
} }
...@@ -2733,6 +2736,7 @@ static int ov5640_probe(struct i2c_client *client, ...@@ -2733,6 +2736,7 @@ static int ov5640_probe(struct i2c_client *client,
sensor->current_fr = OV5640_30_FPS; sensor->current_fr = OV5640_30_FPS;
sensor->current_mode = sensor->current_mode =
&ov5640_mode_data[OV5640_30_FPS][OV5640_MODE_VGA_640_480]; &ov5640_mode_data[OV5640_30_FPS][OV5640_MODE_VGA_640_480];
sensor->last_mode = sensor->current_mode;
sensor->ae_target = 52; sensor->ae_target = 52;
......
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