Skip to content

Commit 985cdcb

Browse files
hfruchet-stmchehab
authored andcommitted
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: Hugues Fruchet <hugues.fruchet@st.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
1 parent a8f438c commit 985cdcb

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎drivers/media/i2c/ov5640.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ struct ov5640_dev {
226226
bool pending_fmt_change;
227227

228228
const struct ov5640_mode_info *current_mode;
229+
const struct ov5640_mode_info *last_mode;
229230
enum ov5640_frame_rate current_fr;
230231
struct v4l2_fract frame_interval;
231232

@@ -1629,10 +1630,10 @@ static int ov5640_set_mode_direct(struct ov5640_dev *sensor,
16291630
return ov5640_load_regs(sensor, mode);
16301631
}
16311632

1632-
static int ov5640_set_mode(struct ov5640_dev *sensor,
1633-
const struct ov5640_mode_info *orig_mode)
1633+
static int ov5640_set_mode(struct ov5640_dev *sensor)
16341634
{
16351635
const struct ov5640_mode_info *mode = sensor->current_mode;
1636+
const struct ov5640_mode_info *orig_mode = sensor->last_mode;
16361637
enum ov5640_downsize_mode dn_mode, orig_dn_mode;
16371638
bool auto_gain = sensor->ctrls.auto_gain->val == 1;
16381639
bool auto_exp = sensor->ctrls.auto_exp->val == V4L2_EXPOSURE_AUTO;
@@ -1694,6 +1695,7 @@ static int ov5640_set_mode(struct ov5640_dev *sensor,
16941695
return ret;
16951696

16961697
sensor->pending_mode_change = false;
1698+
sensor->last_mode = mode;
16971699

16981700
return 0;
16991701

@@ -1719,6 +1721,7 @@ static int ov5640_restore_mode(struct ov5640_dev *sensor)
17191721
ret = ov5640_load_regs(sensor, &ov5640_mode_init_data);
17201722
if (ret < 0)
17211723
return ret;
1724+
sensor->last_mode = &ov5640_mode_init_data;
17221725

17231726
ret = ov5640_mod_reg(sensor, OV5640_REG_SYS_ROOT_DIVIDER, 0x3f,
17241727
(ilog2(OV5640_SCLK2X_ROOT_DIVIDER_DEFAULT) << 2) |
@@ -1727,7 +1730,7 @@ static int ov5640_restore_mode(struct ov5640_dev *sensor)
17271730
return ret;
17281731

17291732
/* now restore the last capture mode */
1730-
ret = ov5640_set_mode(sensor, &ov5640_mode_init_data);
1733+
ret = ov5640_set_mode(sensor);
17311734
if (ret < 0)
17321735
return ret;
17331736

@@ -2610,7 +2613,7 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
26102613

26112614
if (sensor->streaming == !enable) {
26122615
if (enable && sensor->pending_mode_change) {
2613-
ret = ov5640_set_mode(sensor, sensor->current_mode);
2616+
ret = ov5640_set_mode(sensor);
26142617
if (ret)
26152618
goto out;
26162619
}
@@ -2733,6 +2736,7 @@ static int ov5640_probe(struct i2c_client *client,
27332736
sensor->current_fr = OV5640_30_FPS;
27342737
sensor->current_mode =
27352738
&ov5640_mode_data[OV5640_30_FPS][OV5640_MODE_VGA_640_480];
2739+
sensor->last_mode = sensor->current_mode;
27362740

27372741
sensor->ae_target = 52;
27382742

0 commit comments

Comments
 (0)