Commit b6ae5022 authored by Jacopo Mondi's avatar Jacopo Mondi Committed by Mauro Carvalho Chehab

media: ov5640: Remove frame rate check from find_mode()

The current implementation of ov5640_find_mode() fails if the
frame rate programmed with s_frame_interval doesn't match the
maximum frame rate for the current mode.

This causes issues when moving from one mode with higher FPS to another
one which only supports a lower FPS range with tools like media-ctl.

It also forces users that do not use s_frame_interval(), but rather
configure blankings explicitly, to adjust the programmed FPS range to
avoid failures.

For this reason, remove the FPS check from ov5640_find_mode() and only
perform it at s_frame_interval() time.
Signed-off-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@kernel.org>
parent 19f2e3e6
...@@ -1995,8 +1995,7 @@ static int ov5640_set_virtual_channel(struct ov5640_dev *sensor) ...@@ -1995,8 +1995,7 @@ static int ov5640_set_virtual_channel(struct ov5640_dev *sensor)
} }
static const struct ov5640_mode_info * static const struct ov5640_mode_info *
ov5640_find_mode(struct ov5640_dev *sensor, enum ov5640_frame_rate fr, ov5640_find_mode(struct ov5640_dev *sensor, int width, int height, bool nearest)
int width, int height, bool nearest)
{ {
const struct ov5640_mode_info *mode; const struct ov5640_mode_info *mode;
...@@ -2009,10 +2008,6 @@ ov5640_find_mode(struct ov5640_dev *sensor, enum ov5640_frame_rate fr, ...@@ -2009,10 +2008,6 @@ ov5640_find_mode(struct ov5640_dev *sensor, enum ov5640_frame_rate fr,
(mode->width != width || mode->height != height))) (mode->width != width || mode->height != height)))
return NULL; return NULL;
/* Check to see if the current mode exceeds the max frame rate */
if (ov5640_framerates[fr] > ov5640_framerates[mode->max_fps])
return NULL;
return mode; return mode;
} }
...@@ -2649,7 +2644,7 @@ static int ov5640_try_frame_interval(struct ov5640_dev *sensor, ...@@ -2649,7 +2644,7 @@ static int ov5640_try_frame_interval(struct ov5640_dev *sensor,
fi->denominator = best_fps; fi->denominator = best_fps;
find_mode: find_mode:
mode = ov5640_find_mode(sensor, rate, width, height, false); mode = ov5640_find_mode(sensor, width, height, false);
return mode ? rate : -EINVAL; return mode ? rate : -EINVAL;
} }
...@@ -2687,7 +2682,7 @@ static int ov5640_try_fmt_internal(struct v4l2_subdev *sd, ...@@ -2687,7 +2682,7 @@ static int ov5640_try_fmt_internal(struct v4l2_subdev *sd,
const struct ov5640_mode_info *mode; const struct ov5640_mode_info *mode;
int i; int i;
mode = ov5640_find_mode(sensor, fr, fmt->width, fmt->height, true); mode = ov5640_find_mode(sensor, fmt->width, fmt->height, true);
if (!mode) if (!mode)
return -EINVAL; return -EINVAL;
fmt->width = mode->width; fmt->width = mode->width;
...@@ -3481,13 +3476,17 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd, ...@@ -3481,13 +3476,17 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
goto out; goto out;
} }
mode = ov5640_find_mode(sensor, frame_rate, mode->width, mode = ov5640_find_mode(sensor, mode->width, mode->height, true);
mode->height, true);
if (!mode) { if (!mode) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if (ov5640_framerates[frame_rate] > ov5640_framerates[mode->max_fps]) {
ret = -EINVAL;
goto out;
}
if (mode != sensor->current_mode || if (mode != sensor->current_mode ||
frame_rate != sensor->current_fr) { frame_rate != sensor->current_fr) {
sensor->current_fr = frame_rate; sensor->current_fr = frame_rate;
......
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