bcm27xx: update 6.1 patches from RPi foundation
[openwrt/staging/xback.git] / target / linux / bcm27xx / patches-6.1 / 950-0633-media-i2c-imx290-Factor-out-control-update-code-to-a.patch
1 From d28f7567b1043aec24558bd72dc10983db25f25c Mon Sep 17 00:00:00 2001
2 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 Date: Mon, 16 Jan 2023 15:44:40 +0100
4 Subject: [PATCH] media: i2c: imx290: Factor out control update code to
5 a function
6
7 Upstream commit a7941da37c43
8
9 Move the control update code to a separate function to group it with all
10 the control-related code and make imx290_set_fmt() more readable.
11
12 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
13 Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com>
14 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
15 Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
16 ---
17 drivers/media/i2c/imx290.c | 43 ++++++++++++++++++++------------------
18 1 file changed, 23 insertions(+), 20 deletions(-)
19
20 --- a/drivers/media/i2c/imx290.c
21 +++ b/drivers/media/i2c/imx290.c
22 @@ -639,6 +639,28 @@ static const char * const imx290_test_pa
23 "000/555h Toggle Pattern",
24 };
25
26 +static void imx290_ctrl_update(struct imx290 *imx290,
27 + const struct imx290_mode *mode)
28 +{
29 + unsigned int hblank = mode->hmax - mode->width;
30 + unsigned int vblank = IMX290_VMAX_DEFAULT - mode->height;
31 +
32 + /*
33 + * This function may be called from imx290_set_fmt() before controls
34 + * get created by imx290_ctrl_init(). Return immediately in that case.
35 + */
36 + if (!imx290->ctrls.lock)
37 + return;
38 +
39 + __v4l2_ctrl_s_ctrl(imx290->link_freq,
40 + imx290_get_link_freq_index(imx290));
41 + __v4l2_ctrl_s_ctrl_int64(imx290->pixel_rate,
42 + imx290_calc_pixel_rate(imx290));
43 +
44 + __v4l2_ctrl_modify_range(imx290->hblank, hblank, hblank, 1, hblank);
45 + __v4l2_ctrl_modify_range(imx290->vblank, vblank, vblank, 1, vblank);
46 +}
47 +
48 static int imx290_ctrl_init(struct imx290 *imx290)
49 {
50 struct v4l2_fwnode_device_properties props;
51 @@ -904,26 +926,7 @@ static int imx290_set_fmt(struct v4l2_su
52 imx290->current_mode = mode;
53 imx290->bpp = imx290_formats[i].bpp;
54
55 - if (imx290->link_freq)
56 - __v4l2_ctrl_s_ctrl(imx290->link_freq,
57 - imx290_get_link_freq_index(imx290));
58 - if (imx290->pixel_rate)
59 - __v4l2_ctrl_s_ctrl_int64(imx290->pixel_rate,
60 - imx290_calc_pixel_rate(imx290));
61 -
62 - if (imx290->hblank) {
63 - unsigned int hblank = mode->hmax - mode->width;
64 -
65 - __v4l2_ctrl_modify_range(imx290->hblank, hblank, hblank,
66 - 1, hblank);
67 - }
68 -
69 - if (imx290->vblank) {
70 - unsigned int vblank = IMX290_VMAX_DEFAULT - mode->height;
71 -
72 - __v4l2_ctrl_modify_range(imx290->vblank, vblank, vblank,
73 - 1, vblank);
74 - }
75 + imx290_ctrl_update(imx290, mode);
76 }
77
78 *format = fmt->format;