From dc2cdd17d1fe25c8d25c306a90cfc9ff17a7ca4f Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann <tzimmermann@suse.de> Date: Fri, 17 Jun 2022 12:32:25 +0200 Subject: [PATCH] drm/simple-kms: Use drm_atomic_helper_check_crtc_state() Simple-KMS helpers guarantee that the CRTC and plane enable flags are synchronized. Implement this with atomic helpers drm_atomic_helper_check_crtc_state() on the CRTC side, and drm_atomic_helper_check_plane_state() on the plane side. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220617103226.25617-3-tzimmermann@suse.de --- drivers/gpu/drm/drm_simple_kms_helper.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c index 72989ed1baba..36633590ebf3 100644 --- a/drivers/gpu/drm/drm_simple_kms_helper.c +++ b/drivers/gpu/drm/drm_simple_kms_helper.c @@ -100,14 +100,12 @@ drm_simple_kms_crtc_mode_valid(struct drm_crtc *crtc, static int drm_simple_kms_crtc_check(struct drm_crtc *crtc, struct drm_atomic_state *state) { - struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, - crtc); - bool has_primary = crtc_state->plane_mask & - drm_plane_mask(crtc->primary); + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc); + int ret; - /* We always want to have an active plane with an active CRTC */ - if (has_primary != crtc_state->enable) - return -EINVAL; + ret = drm_atomic_helper_check_crtc_state(crtc_state, false); + if (ret) + return ret; return drm_atomic_add_affected_planes(state, crtc); } @@ -227,7 +225,7 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane, ret = drm_atomic_helper_check_plane_state(plane_state, crtc_state, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, - false, true); + false, false); if (ret) return ret; -- 2.30.9