1 From 0094eba3f2a4338cfa6854b0b5104d02ba0fa01f Mon Sep 17 00:00:00 2001
2 From: Naushir Patuck <naush@raspberrypi.com>
3 Date: Thu, 26 Sep 2024 13:12:23 +0100
4 Subject: [PATCH 1287/1350] drivers: media: imx500: Simplify the vblank control
7 Set the VBLANK control minimum and default values to IMX500_VBLANK_MIN
8 unconditionally everywhere.
10 Remove the mode specific framerate_default parameter, it is now unused.
12 Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
14 drivers/media/i2c/imx500.c | 32 +++++---------------------------
15 1 file changed, 5 insertions(+), 27 deletions(-)
17 --- a/drivers/media/i2c/imx500.c
18 +++ b/drivers/media/i2c/imx500.c
19 @@ -274,9 +274,6 @@ struct imx500_mode {
20 /* Analog crop rectangle. */
21 struct v4l2_rect crop;
23 - /* Default framerate. */
24 - unsigned int framerate_default;
26 /* Default register values */
27 struct imx500_reg_list reg_list;
29 @@ -905,7 +902,6 @@ static const struct imx500_mode imx500_s
33 - .framerate_default = 10,
35 .num_of_regs = ARRAY_SIZE(mode_4056x3040_regs),
36 .regs = mode_4056x3040_regs,
37 @@ -922,7 +918,6 @@ static const struct imx500_mode imx500_s
41 - .framerate_default = 30,
43 .num_of_regs = ARRAY_SIZE(mode_2028x1520_regs),
44 .regs = mode_2028x1520_regs,
45 @@ -1744,28 +1739,11 @@ static int imx500_get_pad_format(struct
49 -static unsigned int imx500_get_frame_length(const struct imx500_mode *mode,
50 - unsigned int framerate_default)
54 - frame_length = IMX500_PIXEL_RATE;
55 - do_div(frame_length, (u64)framerate_default * mode->line_length_pix);
57 - if (WARN_ON(frame_length > IMX500_FRAME_LENGTH_MAX))
58 - frame_length = IMX500_FRAME_LENGTH_MAX;
60 - return max_t(unsigned int, frame_length, mode->height);
63 static void imx500_set_framing_limits(struct imx500 *imx500)
65 - unsigned int frm_length_default, hblank_min;
66 + unsigned int hblank_min;
67 const struct imx500_mode *mode = imx500->mode;
69 - frm_length_default =
70 - imx500_get_frame_length(mode, mode->framerate_default);
72 /* Default to no long exposure multiplier. */
73 imx500->long_exp_shift = 0;
75 @@ -1773,11 +1751,10 @@ static void imx500_set_framing_limits(st
76 __v4l2_ctrl_modify_range(
77 imx500->vblank, IMX500_VBLANK_MIN,
78 ((1 << IMX500_LONG_EXP_SHIFT_MAX) * IMX500_FRAME_LENGTH_MAX) -
80 - 1, frm_length_default - mode->height);
81 + mode->height, 1, IMX500_VBLANK_MIN);
83 /* Setting this will adjust the exposure limits as well. */
84 - __v4l2_ctrl_s_ctrl(imx500->vblank, frm_length_default - mode->height);
85 + __v4l2_ctrl_s_ctrl(imx500->vblank, IMX500_VBLANK_MIN);
87 hblank_min = mode->line_length_pix - mode->width;
88 __v4l2_ctrl_modify_range(imx500->hblank, hblank_min, hblank_min, 1,
89 @@ -2499,7 +2476,8 @@ static int imx500_init_controls(struct i
90 * in the imx500_set_framing_limits() call below.
92 imx500->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx500_ctrl_ops,
93 - V4L2_CID_VBLANK, 0, 0xffff, 1, 0);
94 + V4L2_CID_VBLANK, IMX500_VBLANK_MIN,
95 + 0xffff, 1, IMX500_VBLANK_MIN);
96 imx500->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx500_ctrl_ops,
97 V4L2_CID_HBLANK, 0, 0xffff, 1, 0);