summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ast
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2019-12-02 12:15:54 +0100
committerThomas Zimmermann <tzimmermann@suse.de>2019-12-10 14:25:59 +0100
commitae46a57d52c265948761cc17a754f99b0c495473 (patch)
tree6be658ff6d1118907fc7626913171f37c71cf4f7 /drivers/gpu/drm/ast
parentdrm/ast: Clean up arguments of register functions (diff)
downloadlinux-ae46a57d52c265948761cc17a754f99b0c495473.tar.xz
linux-ae46a57d52c265948761cc17a754f99b0c495473.zip
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 <tzimmermann@suse.de> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-5-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/ast')
-rw-r--r--drivers/gpu/drm/ast/ast_mode.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 873756cdb7e2..59c0c702857d 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -31,6 +31,7 @@
#include <linux/export.h>
#include <linux/pci.h>
+#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_atomic_state_helper.h>
#include <drm/drm_crtc.h>
@@ -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;
}