bcm27xx: update 6.1 patches to latest version
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-6.1 / 950-1161-drm-vc4-Drop-planes-that-are-completely-off-screen.patch
1 From 444884f7b62bfe5ef313dd1d47f81a40e695ab0b Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 17 Nov 2023 14:43:44 +0000
4 Subject: [PATCH] drm/vc4: Drop planes that are completely off-screen
5
6 It is permitted for a plane to be configured such that none
7 of it is on-screen via either negative dest rectangle X,Y
8 offset, or just an offset that is greater than the crtc
9 dimensions.
10
11 These planes were resized via drm_atomic_helper_check_plane_state
12 such that the source rectangle had a zero width or height, but
13 they still created a dlist entry even though they contributed
14 no pixels. In the case of vc6_plane_mode_set, that it could result
15 in negative values being written into registers, which caused
16 incorrect behaviour.
17
18 Drop planes that result in a source width or height of 0 pixels
19 to avoid the incorrect rendering.
20
21 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
22 ---
23 drivers/gpu/drm/vc4/vc4_plane.c | 15 +++++++++++++++
24 1 file changed, 15 insertions(+)
25
26 --- a/drivers/gpu/drm/vc4/vc4_plane.c
27 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
28 @@ -1108,6 +1108,12 @@ static int vc4_plane_mode_set(struct drm
29 width = vc4_state->src_w[0] >> 16;
30 height = vc4_state->src_h[0] >> 16;
31
32 + if (!width || !height) {
33 + /* 0 source size probably means the plane is offscreen */
34 + vc4_state->dlist_initialized = 1;
35 + return 0;
36 + }
37 +
38 /* SCL1 is used for Cb/Cr scaling of planar formats. For RGB
39 * and 4:4:4, scl1 should be set to scl0 so both channels of
40 * the scaler do the same thing. For YUV, the Y plane needs
41 @@ -1623,6 +1629,12 @@ static int vc6_plane_mode_set(struct drm
42 width = vc4_state->src_w[0] >> 16;
43 height = vc4_state->src_h[0] >> 16;
44
45 + if (!width || !height) {
46 + /* 0 source size probably means the plane is offscreen */
47 + vc4_state->dlist_initialized = 1;
48 + return 0;
49 + }
50 +
51 /* SCL1 is used for Cb/Cr scaling of planar formats. For RGB
52 * and 4:4:4, scl1 should be set to scl0 so both channels of
53 * the scaler do the same thing. For YUV, the Y plane needs
54 @@ -1994,6 +2006,9 @@ int vc4_plane_atomic_check(struct drm_pl
55 if (ret)
56 return ret;
57
58 + if (!vc4_state->src_w[0] || !vc4_state->src_h[0])
59 + return 0;
60 +
61 ret = vc4_plane_allocate_lbm(new_plane_state);
62 if (ret)
63 return ret;