Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: ov5640: report correct frame rate to user

In commit 3145efcdb4d0 ("media: ov5640: Rework timings programming"),
it defines max_fps field in ov5640_mode_info structure to store maximum
frame rate supported by each mode. But in ov5640_try_frame_interval(), it
assumes the maximum frame rate supported by all modes is 60. But actually,
only VGA support it. For others, the maximum frame rate supported is 30.
So correct it by taking the maximum frame rate supported by each mode as
the initialization value of the local variable maxfps.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Guoniu.zhou and committed by
Mauro Carvalho Chehab
f33b56d3 1b584f20

+12 -10
+12 -10
drivers/media/i2c/ov5640.c
··· 2715 2715 2716 2716 static int ov5640_try_frame_interval(struct ov5640_dev *sensor, 2717 2717 struct v4l2_fract *fi, 2718 - u32 width, u32 height) 2718 + const struct ov5640_mode_info *mode_info) 2719 2719 { 2720 - const struct ov5640_mode_info *mode; 2720 + const struct ov5640_mode_info *mode = mode_info; 2721 2721 enum ov5640_frame_rate rate = OV5640_15_FPS; 2722 2722 int minfps, maxfps, best_fps, fps; 2723 2723 int i; 2724 2724 2725 2725 minfps = ov5640_framerates[OV5640_15_FPS]; 2726 - maxfps = ov5640_framerates[OV5640_60_FPS]; 2726 + maxfps = ov5640_framerates[mode->max_fps]; 2727 2727 2728 2728 if (fi->numerator == 0) { 2729 2729 fi->denominator = maxfps; 2730 2730 fi->numerator = 1; 2731 - rate = OV5640_60_FPS; 2731 + rate = mode->max_fps; 2732 2732 goto find_mode; 2733 2733 } 2734 2734 ··· 2749 2749 fi->denominator = best_fps; 2750 2750 2751 2751 find_mode: 2752 - mode = ov5640_find_mode(sensor, width, height, false); 2752 + mode = ov5640_find_mode(sensor, mode->width, mode->height, false); 2753 2753 return mode ? rate : -EINVAL; 2754 2754 } 2755 2755 ··· 3554 3554 struct v4l2_subdev_frame_interval_enum *fie) 3555 3555 { 3556 3556 struct ov5640_dev *sensor = to_ov5640_dev(sd); 3557 + const struct ov5640_mode_info *mode; 3557 3558 struct v4l2_fract tpf; 3558 3559 int ret; 3559 3560 ··· 3563 3562 if (fie->index >= OV5640_NUM_FRAMERATES) 3564 3563 return -EINVAL; 3565 3564 3565 + mode = ov5640_find_mode(sensor, fie->width, fie->height, false); 3566 + if (!mode) 3567 + return -EINVAL; 3568 + 3566 3569 tpf.numerator = 1; 3567 3570 tpf.denominator = ov5640_framerates[fie->index]; 3568 3571 3569 - ret = ov5640_try_frame_interval(sensor, &tpf, 3570 - fie->width, fie->height); 3572 + ret = ov5640_try_frame_interval(sensor, &tpf, mode); 3571 3573 if (ret < 0) 3572 3574 return -EINVAL; 3573 3575 ··· 3609 3605 3610 3606 mode = sensor->current_mode; 3611 3607 3612 - frame_rate = ov5640_try_frame_interval(sensor, &fi->interval, 3613 - mode->width, 3614 - mode->height); 3608 + frame_rate = ov5640_try_frame_interval(sensor, &fi->interval, mode); 3615 3609 if (frame_rate < 0) { 3616 3610 /* Always return a valid frame interval value */ 3617 3611 fi->interval = sensor->frame_interval;