diff mbox series

[v4,12/12] ov5640: Enforce a mode change when changing the framerate

Message ID 20181011092107.30715-13-maxime.ripard@bootlin.com (mailing list archive)
State New, archived
Headers show
Series media: ov5640: Misc cleanup and improvements | expand

Commit Message

Maxime Ripard Oct. 11, 2018, 9:21 a.m. UTC
The current logic only requires to call ov5640_set_mode, which will in turn
change the clock rates according to the mode and frame interval, when a new
mode is set up.

However, when only the frame interval is changed but the mode isn't,
ov5640_set_mode is never called and the resulting frame rate will be old or
default one. Fix this by requiring that ov5640_set_mode is called when the
frame interval is changed as well.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 drivers/media/i2c/ov5640.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Hugues FRUCHET Oct. 15, 2018, 1:57 p.m. UTC | #1
Hi Maxime,

This is already fixed in media tree:
0929983e49c81c1d413702cd9b83bb06c4a2555c media: ov5640: fix framerate update


On 10/11/2018 11:21 AM, Maxime Ripard wrote:
> The current logic only requires to call ov5640_set_mode, which will in turn
> change the clock rates according to the mode and frame interval, when a new
> mode is set up.
> 
> However, when only the frame interval is changed but the mode isn't,
> ov5640_set_mode is never called and the resulting frame rate will be old or
> default one. Fix this by requiring that ov5640_set_mode is called when the
> frame interval is changed as well.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> ---
>   drivers/media/i2c/ov5640.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> index 818411400ef6..e01d2cb93c67 100644
> --- a/drivers/media/i2c/ov5640.c
> +++ b/drivers/media/i2c/ov5640.c
> @@ -2638,8 +2638,12 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
>   		goto out;
>   	}
>   
> -	sensor->current_fr = frame_rate;
> -	sensor->frame_interval = fi->interval;
> +	if (frame_rate != sensor->current_fr) {
> +		sensor->current_fr = frame_rate;
> +		sensor->frame_interval = fi->interval;
> +		sensor->pending_mode_change = true;
> +	}
> +
>   	mode = ov5640_find_mode(sensor, frame_rate, mode->hact,
>   				mode->vact, true);
>   	if (!mode) {
> 

BR,
Hugues.
Maxime Ripard Oct. 16, 2018, 7:10 a.m. UTC | #2
Hi Hugues,

On Mon, Oct 15, 2018 at 01:57:40PM +0000, Hugues FRUCHET wrote:
> This is already fixed in media tree:
> 0929983e49c81c1d413702cd9b83bb06c4a2555c media: ov5640: fix framerate update

My bad then, I missed it, thanks!
Maxime
Hugues FRUCHET Oct. 16, 2018, 8:45 a.m. UTC | #3
You're welcome ;)

On 10/16/2018 09:10 AM, Maxime Ripard wrote:
> Hi Hugues,
> 
> On Mon, Oct 15, 2018 at 01:57:40PM +0000, Hugues FRUCHET wrote:
>> This is already fixed in media tree:
>> 0929983e49c81c1d413702cd9b83bb06c4a2555c media: ov5640: fix framerate update
> 
> My bad then, I missed it, thanks!
> Maxime
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 818411400ef6..e01d2cb93c67 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -2638,8 +2638,12 @@  static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
 		goto out;
 	}
 
-	sensor->current_fr = frame_rate;
-	sensor->frame_interval = fi->interval;
+	if (frame_rate != sensor->current_fr) {
+		sensor->current_fr = frame_rate;
+		sensor->frame_interval = fi->interval;
+		sensor->pending_mode_change = true;
+	}
+
 	mode = ov5640_find_mode(sensor, frame_rate, mode->hact,
 				mode->vact, true);
 	if (!mode) {