diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2020-07-16 14:53:51 +0200 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2020-07-20 09:16:11 +0200 |
commit | 0149e7805b3c52753d727a7c519757a77435967b (patch) | |
tree | 83d1b10c301359b1c240b29b6efd4a2c9cc35770 /drivers/gpu/drm/ast/ast_mm.c | |
parent | 8e46dc585389fedd1563698214b2153825789e1e (diff) |
drm/ast: Move VRAM size detection to ast_mm.c
VRAM size detection is only relevant to the memory management. Move
the code into ast_mm.c.
While at it, rename the function to ast_get_vram_size(). The function
argument's type is now struct ast_private. The result is stored in a
local variable and not in struct ast_private any longer.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200716125353.31512-5-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/ast/ast_mm.c')
-rw-r--r-- | drivers/gpu/drm/ast/ast_mm.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/drivers/gpu/drm/ast/ast_mm.c b/drivers/gpu/drm/ast/ast_mm.c index f0a96cae68c9..aaeb19d01052 100644 --- a/drivers/gpu/drm/ast/ast_mm.c +++ b/drivers/gpu/drm/ast/ast_mm.c @@ -33,13 +33,56 @@ #include "ast_drv.h" +static u32 ast_get_vram_size(struct ast_private *ast) +{ + u8 jreg; + u32 vram_size; + + ast_open_key(ast); + + vram_size = AST_VIDMEM_DEFAULT_SIZE; + jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xaa, 0xff); + switch (jreg & 3) { + case 0: + vram_size = AST_VIDMEM_SIZE_8M; + break; + case 1: + vram_size = AST_VIDMEM_SIZE_16M; + break; + case 2: + vram_size = AST_VIDMEM_SIZE_32M; + break; + case 3: + vram_size = AST_VIDMEM_SIZE_64M; + break; + } + + jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x99, 0xff); + switch (jreg & 0x03) { + case 1: + vram_size -= 0x100000; + break; + case 2: + vram_size -= 0x200000; + break; + case 3: + vram_size -= 0x400000; + break; + } + + return vram_size; +} + int ast_mm_init(struct ast_private *ast) { + u32 vram_size; int ret; struct drm_device *dev = ast->dev; + vram_size = ast_get_vram_size(ast); + ret = drmm_vram_helper_init(dev, pci_resource_start(dev->pdev, 0), - ast->vram_size); + vram_size); if (ret) { drm_err(dev, "Error initializing VRAM MM; %d\n", ret); return ret; |