bcm27xx: 6.1: add kernel patches
[openwrt/staging/stintel.git] / target / linux / bcm27xx / patches-6.1 / 950-0663-media-i2c-imx290-VMAX-is-mode-dependent.patch
1 From ea3632a2047fe42351c806dddb3d42f96137876e Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 16 Feb 2023 00:29:59 +0200
4 Subject: [PATCH] media: i2c: imx290: VMAX is mode dependent
5
6 Should be upstream commit b3aa351ea88a
7
8 The default VMAX for 60fps in 720p mode is 750 according to the
9 datasheet, however the driver always left it at 1125 thereby stopping
10 60fps being achieved.
11
12 Make VMAX (and therefore V4L2_CID_VBLANK) mode dependent so that 720p60
13 can be achieved.
14
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
16 Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
17 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
18 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
19 ---
20 drivers/media/i2c/imx290.c | 9 ++++++---
21 1 file changed, 6 insertions(+), 3 deletions(-)
22
23 --- a/drivers/media/i2c/imx290.c
24 +++ b/drivers/media/i2c/imx290.c
25 @@ -113,8 +113,6 @@
26 /* Number of lines by which exposure must be less than VMAX */
27 #define IMX290_EXPOSURE_OFFSET 2
28
29 -#define IMX290_VMAX_DEFAULT 1125
30 -
31 #define IMX290_PIXEL_RATE 148500000
32
33 /*
34 @@ -192,6 +190,7 @@ struct imx290_mode {
35 u32 width;
36 u32 height;
37 u32 hmax_min;
38 + u32 vmax_min;
39 u8 link_freq_index;
40
41 const struct imx290_regval *data;
42 @@ -435,6 +434,7 @@ static const struct imx290_mode imx290_m
43 .width = 1920,
44 .height = 1080,
45 .hmax_min = 2200,
46 + .vmax_min = 1125,
47 .link_freq_index = FREQ_INDEX_1080P,
48 .data = imx290_1080p_settings,
49 .data_size = ARRAY_SIZE(imx290_1080p_settings),
50 @@ -443,6 +443,7 @@ static const struct imx290_mode imx290_m
51 .width = 1280,
52 .height = 720,
53 .hmax_min = 3300,
54 + .vmax_min = 750,
55 .link_freq_index = FREQ_INDEX_720P,
56 .data = imx290_720p_settings,
57 .data_size = ARRAY_SIZE(imx290_720p_settings),
58 @@ -454,6 +455,7 @@ static const struct imx290_mode imx290_m
59 .width = 1920,
60 .height = 1080,
61 .hmax_min = 2200,
62 + .vmax_min = 1125,
63 .link_freq_index = FREQ_INDEX_1080P,
64 .data = imx290_1080p_settings,
65 .data_size = ARRAY_SIZE(imx290_1080p_settings),
66 @@ -462,6 +464,7 @@ static const struct imx290_mode imx290_m
67 .width = 1280,
68 .height = 720,
69 .hmax_min = 3300,
70 + .vmax_min = 750,
71 .link_freq_index = FREQ_INDEX_720P,
72 .data = imx290_720p_settings,
73 .data_size = ARRAY_SIZE(imx290_720p_settings),
74 @@ -784,7 +787,7 @@ static void imx290_ctrl_update(struct im
75 {
76 unsigned int hblank_min = mode->hmax_min - mode->width;
77 unsigned int hblank_max = IMX290_HMAX_MAX - mode->width;
78 - unsigned int vblank_min = IMX290_VMAX_DEFAULT - mode->height;
79 + unsigned int vblank_min = mode->vmax_min - mode->height;
80 unsigned int vblank_max = IMX290_VMAX_MAX - mode->height;
81
82 __v4l2_ctrl_s_ctrl(imx290->link_freq, mode->link_freq_index);