Skip to content

Commit 69cb562

Browse files
zzagalexdeucher
authored andcommitted
drm/amd/display: Use oriented source size when checking cursor scaling
dm_check_crtc_cursor() doesn't take into account plane transforms when calculating plane scaling, this can result in false positives. For example, if there's an output with resolution 3840x2160 and the output is rotated 90 degrees, CRTC_W and CRTC_H will be 3840 and 2160, respectively, but SRC_W and SRC_H will be 2160 and 3840, respectively. Since the cursor plane usually has a square buffer attached to it, the dm_check_crtc_cursor() will think that there's a scale factor mismatch even though there isn't really. This fixes an issue where kwin fails to use hardware plane transforms. Changes since version 1: - s/orientated/oriented/g Reviewed-by: Nicholas Kazlauskas <[email protected]> Signed-off-by: Vlad Zahorodnii <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent b220110 commit 69cb562

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10736,6 +10736,24 @@ static int dm_update_plane_state(struct dc *dc,
1073610736
return ret;
1073710737
}
1073810738

10739+
static void dm_get_oriented_plane_size(struct drm_plane_state *plane_state,
10740+
int *src_w, int *src_h)
10741+
{
10742+
switch (plane_state->rotation & DRM_MODE_ROTATE_MASK) {
10743+
case DRM_MODE_ROTATE_90:
10744+
case DRM_MODE_ROTATE_270:
10745+
*src_w = plane_state->src_h >> 16;
10746+
*src_h = plane_state->src_w >> 16;
10747+
break;
10748+
case DRM_MODE_ROTATE_0:
10749+
case DRM_MODE_ROTATE_180:
10750+
default:
10751+
*src_w = plane_state->src_w >> 16;
10752+
*src_h = plane_state->src_h >> 16;
10753+
break;
10754+
}
10755+
}
10756+
1073910757
static int dm_check_crtc_cursor(struct drm_atomic_state *state,
1074010758
struct drm_crtc *crtc,
1074110759
struct drm_crtc_state *new_crtc_state)
@@ -10744,6 +10762,8 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
1074410762
struct drm_plane_state *new_cursor_state, *new_underlying_state;
1074510763
int i;
1074610764
int cursor_scale_w, cursor_scale_h, underlying_scale_w, underlying_scale_h;
10765+
int cursor_src_w, cursor_src_h;
10766+
int underlying_src_w, underlying_src_h;
1074710767

1074810768
/* On DCE and DCN there is no dedicated hardware cursor plane. We get a
1074910769
* cursor per pipe but it's going to inherit the scaling and
@@ -10755,10 +10775,9 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
1075510775
return 0;
1075610776
}
1075710777

10758-
cursor_scale_w = new_cursor_state->crtc_w * 1000 /
10759-
(new_cursor_state->src_w >> 16);
10760-
cursor_scale_h = new_cursor_state->crtc_h * 1000 /
10761-
(new_cursor_state->src_h >> 16);
10778+
dm_get_oriented_plane_size(new_cursor_state, &cursor_src_w, &cursor_src_h);
10779+
cursor_scale_w = new_cursor_state->crtc_w * 1000 / cursor_src_w;
10780+
cursor_scale_h = new_cursor_state->crtc_h * 1000 / cursor_src_h;
1076210781

1076310782
for_each_new_plane_in_state_reverse(state, underlying, new_underlying_state, i) {
1076410783
/* Narrow down to non-cursor planes on the same CRTC as the cursor */
@@ -10769,10 +10788,10 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
1076910788
if (!new_underlying_state->fb)
1077010789
continue;
1077110790

10772-
underlying_scale_w = new_underlying_state->crtc_w * 1000 /
10773-
(new_underlying_state->src_w >> 16);
10774-
underlying_scale_h = new_underlying_state->crtc_h * 1000 /
10775-
(new_underlying_state->src_h >> 16);
10791+
dm_get_oriented_plane_size(new_underlying_state,
10792+
&underlying_src_w, &underlying_src_h);
10793+
underlying_scale_w = new_underlying_state->crtc_w * 1000 / underlying_src_w;
10794+
underlying_scale_h = new_underlying_state->crtc_h * 1000 / underlying_src_h;
1077610795

1077710796
if (cursor_scale_w != underlying_scale_w ||
1077810797
cursor_scale_h != underlying_scale_h) {

0 commit comments

Comments
 (0)