Skip to content

Commit b8a7954

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 <[email protected]>
1 parent 8d9d3e3 commit b8a7954

File tree

1 file changed

+13
-44
lines changed

1 file changed

+13
-44
lines changed

drivers/media/i2c/imx477.c

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ MODULE_PARM_DESC(trigger_mode, "Set vsync trigger mode: 1=source, 2=sink");
5353
/* V_TIMING internal */
5454
#define IMX477_REG_FRAME_LENGTH 0x0340
5555
#define IMX477_FRAME_LENGTH_MAX 0xffdc
56+
#define IMX477_VBLANK_MIN 4
5657

5758
/* H_TIMING internal */
5859
#define IMX477_REG_LINE_LENGTH 0x0342
@@ -157,11 +158,8 @@ struct imx477_mode {
157158
/* Analog crop rectangle. */
158159
struct v4l2_rect crop;
159160

160-
/* Highest possible framerate. */
161-
struct v4l2_fract timeperframe_min;
162-
163161
/* Default framerate. */
164-
struct v4l2_fract timeperframe_default;
162+
unsigned int framerate_default;
165163

166164
/* Default register values */
167165
struct imx477_reg_list reg_list;
@@ -869,14 +867,7 @@ static const struct imx477_mode supported_modes_12bit[] = {
869867
.width = 4056,
870868
.height = 3040,
871869
},
872-
.timeperframe_min = {
873-
.numerator = 100,
874-
.denominator = 1000
875-
},
876-
.timeperframe_default = {
877-
.numerator = 100,
878-
.denominator = 1000
879-
},
870+
.framerate_default = 10,
880871
.reg_list = {
881872
.num_of_regs = ARRAY_SIZE(mode_4056x3040_regs),
882873
.regs = mode_4056x3040_regs,
@@ -893,14 +884,7 @@ static const struct imx477_mode supported_modes_12bit[] = {
893884
.width = 4056,
894885
.height = 3040,
895886
},
896-
.timeperframe_min = {
897-
.numerator = 100,
898-
.denominator = 4000
899-
},
900-
.timeperframe_default = {
901-
.numerator = 100,
902-
.denominator = 3000
903-
},
887+
.framerate_default = 30,
904888
.reg_list = {
905889
.num_of_regs = ARRAY_SIZE(mode_2028x1520_regs),
906890
.regs = mode_2028x1520_regs,
@@ -917,14 +901,7 @@ static const struct imx477_mode supported_modes_12bit[] = {
917901
.width = 4056,
918902
.height = 2160,
919903
},
920-
.timeperframe_min = {
921-
.numerator = 100,
922-
.denominator = 5000
923-
},
924-
.timeperframe_default = {
925-
.numerator = 100,
926-
.denominator = 3000
927-
},
904+
.framerate_default = 30,
928905
.reg_list = {
929906
.num_of_regs = ARRAY_SIZE(mode_2028x1080_regs),
930907
.regs = mode_2028x1080_regs,
@@ -952,14 +929,7 @@ static const struct imx477_mode supported_modes_10bit[] = {
952929
.width = 2664,
953930
.height = 1980,
954931
},
955-
.timeperframe_min = {
956-
.numerator = 100,
957-
.denominator = 12000
958-
},
959-
.timeperframe_default = {
960-
.numerator = 100,
961-
.denominator = 12000
962-
},
932+
.framerate_default = 120,
963933
.reg_list = {
964934
.num_of_regs = ARRAY_SIZE(mode_1332x990_regs),
965935
.regs = mode_1332x990_regs,
@@ -1502,13 +1472,13 @@ static int imx477_get_pad_format(struct v4l2_subdev *sd,
15021472

15031473
static
15041474
unsigned int imx477_get_frame_length(const struct imx477_mode *mode,
1505-
const struct v4l2_fract *timeperframe)
1475+
unsigned int framerate_default)
15061476
{
15071477
u64 frame_length;
15081478

1509-
frame_length = (u64)timeperframe->numerator * IMX477_PIXEL_RATE;
1479+
frame_length = IMX477_PIXEL_RATE;
15101480
do_div(frame_length,
1511-
(u64)timeperframe->denominator * mode->line_length_pix);
1481+
(u64)framerate_default * mode->line_length_pix);
15121482

15131483
if (WARN_ON(frame_length > IMX477_FRAME_LENGTH_MAX))
15141484
frame_length = IMX477_FRAME_LENGTH_MAX;
@@ -1518,21 +1488,20 @@ unsigned int imx477_get_frame_length(const struct imx477_mode *mode,
15181488

15191489
static void imx477_set_framing_limits(struct imx477 *imx477)
15201490
{
1521-
unsigned int frm_length_min, frm_length_default, hblank_min;
1491+
unsigned int frm_length_default, hblank_min;
15221492
const struct imx477_mode *mode = imx477->mode;
15231493

1524-
frm_length_min = imx477_get_frame_length(mode, &mode->timeperframe_min);
15251494
frm_length_default =
1526-
imx477_get_frame_length(mode, &mode->timeperframe_default);
1495+
imx477_get_frame_length(mode, mode->framerate_default);
15271496

15281497
/* Default to no long exposure multiplier. */
15291498
imx477->long_exp_shift = 0;
15301499

15311500
/* Update limits and set FPS to default */
1532-
__v4l2_ctrl_modify_range(imx477->vblank, frm_length_min - mode->height,
1501+
__v4l2_ctrl_modify_range(imx477->vblank, 1,
15331502
((1 << IMX477_LONG_EXP_SHIFT_MAX) *
15341503
IMX477_FRAME_LENGTH_MAX) - mode->height,
1535-
1, frm_length_default - mode->height);
1504+
IMX477_VBLANK_MIN, frm_length_default - mode->height);
15361505

15371506
/* Setting this will adjust the exposure limits as well. */
15381507
__v4l2_ctrl_s_ctrl(imx477->vblank, frm_length_default - mode->height);

0 commit comments

Comments
 (0)