From 5a1505e7e668538d09e2e56e3296cee982a5a8e0 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Thu, 7 Nov 2019 09:33:56 +0100 Subject: drm/ast: Remove last traces of struct ast_gem_object The ast driver has switched to struct drm_vram_gem_object a while ago. This patch removes a function and forward declaration that were forgotten before. Signed-off-by: Thomas Zimmermann Acked-by: Gerd Hoffmann Link: https://patchwork.freedesktop.org/patch/msgid/20191107083404.6852-2-tzimmermann@suse.de --- drivers/gpu/drm/ast/ast_main.c | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'drivers/gpu/drm/ast/ast_main.c') diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index 21715d6a9b56..3a9b4cb73f2f 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -535,27 +535,3 @@ void ast_driver_unload(struct drm_device *dev) pci_iounmap(dev->pdev, ast->regs); kfree(ast); } - -int ast_gem_create(struct drm_device *dev, - u32 size, bool iskernel, - struct drm_gem_object **obj) -{ - struct drm_gem_vram_object *gbo; - int ret; - - *obj = NULL; - - size = roundup(size, PAGE_SIZE); - if (size == 0) - return -EINVAL; - - gbo = drm_gem_vram_create(dev, &dev->vram_mm->bdev, size, 0, false); - if (IS_ERR(gbo)) { - ret = PTR_ERR(gbo); - if (ret != -ERESTARTSYS) - DRM_ERROR("failed to allocate GEM object\n"); - return ret; - } - *obj = &gbo->bo.base; - return 0; -} -- cgit From 9253f830c9166bfa6cc07d5ed59e174e9d5ec6ca Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Thu, 7 Nov 2019 09:33:57 +0100 Subject: drm/ast: Check video-mode requirements against VRAM size Each video mode's primary plane requires a minimum amount of video memory. For double buffering, this is at most half the available VRAM. Check this constraint. Signed-off-by: Thomas Zimmermann Acked-by: Gerd Hoffmann Link: https://patchwork.freedesktop.org/patch/msgid/20191107083404.6852-3-tzimmermann@suse.de --- drivers/gpu/drm/ast/ast_main.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/drm/ast/ast_main.c') diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index 3a9b4cb73f2f..48d57ab42955 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -387,8 +387,31 @@ static int ast_get_dram_info(struct drm_device *dev) return 0; } +enum drm_mode_status ast_mode_config_mode_valid(struct drm_device *dev, + const struct drm_display_mode *mode) +{ + static const unsigned long max_bpp = 4; /* DRM_FORMAT_XRGBA8888 */ + + struct ast_private *ast = dev->dev_private; + unsigned long fbsize, fbpages, max_fbpages; + + /* To support double buffering, a framebuffer may not + * consume more than half of the available VRAM. + */ + max_fbpages = (ast->vram_size / 2) >> PAGE_SHIFT; + + fbsize = mode->hdisplay * mode->vdisplay * max_bpp; + fbpages = DIV_ROUND_UP(fbsize, PAGE_SIZE); + + if (fbpages > max_fbpages) + return MODE_MEM; + + return MODE_OK; +} + static const struct drm_mode_config_funcs ast_mode_funcs = { - .fb_create = drm_gem_fb_create + .fb_create = drm_gem_fb_create, + .mode_valid = ast_mode_config_mode_valid, }; static u32 ast_get_vram_info(struct drm_device *dev) -- cgit From 4961eb60f14553363a0a7a9fb7b20d9c57d3ebba Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Thu, 7 Nov 2019 09:34:04 +0100 Subject: drm/ast: Enable atomic modesetting This commit sets the remaining atomic-modesetting helpers and the flag DRIVER_ATOMIC. Legacy cursor functions are removed in favor of the cursor plane. For power management, atomic helpers replace the indvidual operations that the driver currently runs. Atomic modesetting is enabled with this commit. Signed-off-by: Thomas Zimmermann Acked-by: Gerd Hoffmann Link: https://patchwork.freedesktop.org/patch/msgid/20191107083404.6852-10-tzimmermann@suse.de --- drivers/gpu/drm/ast/ast_main.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/gpu/drm/ast/ast_main.c') diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index 48d57ab42955..b79f484e9bd2 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -28,6 +28,7 @@ #include +#include #include #include #include @@ -412,6 +413,8 @@ enum drm_mode_status ast_mode_config_mode_valid(struct drm_device *dev, static const struct drm_mode_config_funcs ast_mode_funcs = { .fb_create = drm_gem_fb_create, .mode_valid = ast_mode_config_mode_valid, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, }; static u32 ast_get_vram_info(struct drm_device *dev) @@ -529,6 +532,8 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) if (ret) goto out_free; + drm_mode_config_reset(dev); + ret = drm_fbdev_generic_setup(dev, 32); if (ret) goto out_free; -- cgit