Skip to content

Commit f73b18e

Browse files
6by9popcornmix
authored andcommitted
drm/vc4: Drop planes that are completely off-screen
It is permitted for a plane to be configured such that none of it is on-screen via either negative dest rectangle X,Y offset, or just an offset that is greater than the crtc dimensions. These planes were resized via drm_atomic_helper_check_plane_state such that the source rectangle had a zero width or height, but they still created a dlist entry even though they contributed no pixels. In the case of vc6_plane_mode_set, that it could result in negative values being written into registers, which caused incorrect behaviour. Drop planes that result in a source width or height of 0 pixels to avoid the incorrect rendering. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent d279825 commit f73b18e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/gpu/drm/vc4/vc4_plane.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,12 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
11081108
width = vc4_state->src_w[0] >> 16;
11091109
height = vc4_state->src_h[0] >> 16;
11101110

1111+
if (!width || !height) {
1112+
/* 0 source size probably means the plane is offscreen */
1113+
vc4_state->dlist_initialized = 1;
1114+
return 0;
1115+
}
1116+
11111117
/* SCL1 is used for Cb/Cr scaling of planar formats. For RGB
11121118
* and 4:4:4, scl1 should be set to scl0 so both channels of
11131119
* the scaler do the same thing. For YUV, the Y plane needs
@@ -1623,6 +1629,12 @@ static int vc6_plane_mode_set(struct drm_plane *plane,
16231629
width = vc4_state->src_w[0] >> 16;
16241630
height = vc4_state->src_h[0] >> 16;
16251631

1632+
if (!width || !height) {
1633+
/* 0 source size probably means the plane is offscreen */
1634+
vc4_state->dlist_initialized = 1;
1635+
return 0;
1636+
}
1637+
16261638
/* SCL1 is used for Cb/Cr scaling of planar formats. For RGB
16271639
* and 4:4:4, scl1 should be set to scl0 so both channels of
16281640
* the scaler do the same thing. For YUV, the Y plane needs
@@ -1994,6 +2006,9 @@ int vc4_plane_atomic_check(struct drm_plane *plane,
19942006
if (ret)
19952007
return ret;
19962008

2009+
if (!vc4_state->src_w[0] || !vc4_state->src_h[0])
2010+
return 0;
2011+
19972012
ret = vc4_plane_allocate_lbm(new_plane_state);
19982013
if (ret)
19992014
return ret;

0 commit comments

Comments
 (0)