Skip to content

Commit 751565c

Browse files
committed
media: i2c: imx477: Extend V4L2_CID_VBLANK range
The driver was using a struct v4l2_fract for the min frame time to determine the range for V4L2_CID_VBLANK, and a second to set the default VBLANK value for each mode. However actually the sensor will accept any VBLANK value down to 1 line, and using a struct v4l2_fract to hold the default framerate (which is an integer in all cases) is rather overkill. Drop the minimum frame time, and use a simple integer to set the default. This actually increases the max frame rate in all modes slightly. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 8791851 commit 751565c

File tree

1 file changed

+11
-43
lines changed

1 file changed

+11
-43
lines changed

drivers/media/i2c/imx477.c

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,8 @@ struct imx477_mode {
154154
/* Analog crop rectangle. */
155155
struct v4l2_rect crop;
156156

157-
/* Highest possible framerate. */
158-
struct v4l2_fract timeperframe_min;
159-
160157
/* Default framerate. */
161-
struct v4l2_fract timeperframe_default;
158+
unsigned int framerate_default;
162159

163160
/* Default register values */
164161
struct imx477_reg_list reg_list;
@@ -795,14 +792,7 @@ static const struct imx477_mode supported_modes_12bit[] = {
795792
.width = 4056,
796793
.height = 3040,
797794
},
798-
.timeperframe_min = {
799-
.numerator = 100,
800-
.denominator = 1000
801-
},
802-
.timeperframe_default = {
803-
.numerator = 100,
804-
.denominator = 1000
805-
},
795+
.framerate_default = 10,
806796
.reg_list = {
807797
.num_of_regs = ARRAY_SIZE(mode_4056x3040_regs),
808798
.regs = mode_4056x3040_regs,
@@ -819,14 +809,7 @@ static const struct imx477_mode supported_modes_12bit[] = {
819809
.width = 4056,
820810
.height = 3040,
821811
},
822-
.timeperframe_min = {
823-
.numerator = 100,
824-
.denominator = 4000
825-
},
826-
.timeperframe_default = {
827-
.numerator = 100,
828-
.denominator = 3000
829-
},
812+
.framerate_default = 30,
830813
.reg_list = {
831814
.num_of_regs = ARRAY_SIZE(mode_2028x1520_regs),
832815
.regs = mode_2028x1520_regs,
@@ -843,14 +826,7 @@ static const struct imx477_mode supported_modes_12bit[] = {
843826
.width = 4056,
844827
.height = 2160,
845828
},
846-
.timeperframe_min = {
847-
.numerator = 100,
848-
.denominator = 5000
849-
},
850-
.timeperframe_default = {
851-
.numerator = 100,
852-
.denominator = 3000
853-
},
829+
.framerate_default = 30,
854830
.reg_list = {
855831
.num_of_regs = ARRAY_SIZE(mode_2028x1080_regs),
856832
.regs = mode_2028x1080_regs,
@@ -878,14 +854,7 @@ static const struct imx477_mode supported_modes_10bit[] = {
878854
.width = 2664,
879855
.height = 1980,
880856
},
881-
.timeperframe_min = {
882-
.numerator = 100,
883-
.denominator = 12000
884-
},
885-
.timeperframe_default = {
886-
.numerator = 100,
887-
.denominator = 12000
888-
},
857+
.framerate_default = 120,
889858
.reg_list = {
890859
.num_of_regs = ARRAY_SIZE(mode_1332x990_regs),
891860
.regs = mode_1332x990_regs,
@@ -1419,13 +1388,13 @@ static int imx477_get_pad_format(struct v4l2_subdev *sd,
14191388

14201389
static
14211390
unsigned int imx477_get_frame_length(const struct imx477_mode *mode,
1422-
const struct v4l2_fract *timeperframe)
1391+
unsigned int framerate_default)
14231392
{
14241393
u64 frame_length;
14251394

1426-
frame_length = (u64)timeperframe->numerator * IMX477_PIXEL_RATE;
1395+
frame_length = IMX477_PIXEL_RATE;
14271396
do_div(frame_length,
1428-
(u64)timeperframe->denominator * mode->line_length_pix);
1397+
(u64)framerate_default * mode->line_length_pix);
14291398

14301399
if (WARN_ON(frame_length > IMX477_FRAME_LENGTH_MAX))
14311400
frame_length = IMX477_FRAME_LENGTH_MAX;
@@ -1435,18 +1404,17 @@ unsigned int imx477_get_frame_length(const struct imx477_mode *mode,
14351404

14361405
static void imx477_set_framing_limits(struct imx477 *imx477)
14371406
{
1438-
unsigned int frm_length_min, frm_length_default, hblank_min;
1407+
unsigned int frm_length_default, hblank_min;
14391408
const struct imx477_mode *mode = imx477->mode;
14401409

1441-
frm_length_min = imx477_get_frame_length(mode, &mode->timeperframe_min);
14421410
frm_length_default =
1443-
imx477_get_frame_length(mode, &mode->timeperframe_default);
1411+
imx477_get_frame_length(mode, mode->framerate_default);
14441412

14451413
/* Default to no long exposure multiplier. */
14461414
imx477->long_exp_shift = 0;
14471415

14481416
/* Update limits and set FPS to default */
1449-
__v4l2_ctrl_modify_range(imx477->vblank, frm_length_min - mode->height,
1417+
__v4l2_ctrl_modify_range(imx477->vblank, 1,
14501418
((1 << IMX477_LONG_EXP_SHIFT_MAX) *
14511419
IMX477_FRAME_LENGTH_MAX) - mode->height,
14521420
1, frm_length_default - mode->height);

0 commit comments

Comments
 (0)