From: Thomas Zimmermann Date: Mon, 2 Dec 2019 11:15:54 +0000 (+0100) Subject: drm/ast: Add plane atomic_check() functions X-Git-Tag: v5.15~303^2~28^2~3890 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ae46a57d52c265948761cc17a754f99b0c495473;p=platform%2Fkernel%2Flinux-starfive.git drm/ast: Add plane atomic_check() functions Introducing atomic_check() for priamry and cursor plane. The functions validate the plane state and will later set format information for the CRTC's atomic_flush(). Signed-off-by: Thomas Zimmermann Acked-by: Gerd Hoffmann Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-5-tzimmermann@suse.de --- diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index 873756c..59c0c70 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -530,9 +531,24 @@ static const uint32_t ast_primary_plane_formats[] = { DRM_FORMAT_C8, }; -int ast_primary_plane_helper_atomic_check(struct drm_plane *plane, - struct drm_plane_state *state) +static int ast_primary_plane_helper_atomic_check(struct drm_plane *plane, + struct drm_plane_state *state) { + struct drm_crtc_state *crtc_state; + int ret; + + if (!state->crtc) + return 0; + + crtc_state = drm_atomic_get_new_crtc_state(state->state, state->crtc); + + ret = drm_atomic_helper_check_plane_state(state, crtc_state, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING, + false, true); + if (ret) + return ret; + return 0; } @@ -603,8 +619,9 @@ ast_cursor_plane_helper_prepare_fb(struct drm_plane *plane, if (!crtc || !fb) return 0; - if (fb->width > AST_MAX_HWC_WIDTH || fb->height > AST_MAX_HWC_HEIGHT) - return -EINVAL; + if (WARN_ON_ONCE(fb->width > AST_MAX_HWC_WIDTH) || + WARN_ON_ONCE(fb->height > AST_MAX_HWC_HEIGHT)) + return -EINVAL; /* BUG: didn't test in atomic_check() */ ast = crtc->dev->dev_private; @@ -646,6 +663,28 @@ err_drm_gem_vram_unpin: static int ast_cursor_plane_helper_atomic_check(struct drm_plane *plane, struct drm_plane_state *state) { + struct drm_framebuffer *fb = state->fb; + struct drm_crtc_state *crtc_state; + int ret; + + if (!state->crtc) + return 0; + + crtc_state = drm_atomic_get_new_crtc_state(state->state, state->crtc); + + ret = drm_atomic_helper_check_plane_state(state, crtc_state, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING, + true, true); + if (ret) + return ret; + + if (!state->visible) + return 0; + + if (fb->width > AST_MAX_HWC_WIDTH || fb->height > AST_MAX_HWC_HEIGHT) + return -EINVAL; + return 0; }