Commit 9bf1019c authored by Simon Ser's avatar Simon Ser Committed by Alex Deucher

drm/amd/display: add cursor pitch check

Replace the width check with a pitch check, which matches DM internals.
Add a new check to make sure the pitch (in pixels) matches the width.
Reviewed-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: default avatarSimon Ser <contact@emersion.fr>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Harry Wentland <hwentlan@amd.com>
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 03a66367
...@@ -8994,6 +8994,7 @@ static int dm_update_plane_state(struct dc *dc, ...@@ -8994,6 +8994,7 @@ static int dm_update_plane_state(struct dc *dc,
struct amdgpu_crtc *new_acrtc; struct amdgpu_crtc *new_acrtc;
bool needs_reset; bool needs_reset;
int ret = 0; int ret = 0;
unsigned int pitch;
new_plane_crtc = new_plane_state->crtc; new_plane_crtc = new_plane_state->crtc;
...@@ -9027,15 +9028,25 @@ static int dm_update_plane_state(struct dc *dc, ...@@ -9027,15 +9028,25 @@ static int dm_update_plane_state(struct dc *dc,
return -EINVAL; return -EINVAL;
} }
switch (new_plane_state->fb->width) { /* Pitch in pixels */
pitch = new_plane_state->fb->pitches[0] / new_plane_state->fb->format->cpp[0];
if (new_plane_state->fb->width != pitch) {
DRM_DEBUG_ATOMIC("Cursor FB width %d doesn't match pitch %d",
new_plane_state->fb->width,
pitch);
return -EINVAL;
}
switch (pitch) {
case 64: case 64:
case 128: case 128:
case 256: case 256:
/* FB width is supported by cursor plane */ /* FB pitch is supported by cursor plane */
break; break;
default: default:
DRM_DEBUG_ATOMIC("Bad cursor FB width %d\n", DRM_DEBUG_ATOMIC("Bad cursor FB pitch %d px\n",
new_plane_state->fb->width); pitch);
return -EINVAL; return -EINVAL;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment