]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
drm/ast: Move VRAM size detection to ast_mm.c
authorThomas Zimmermann <tzimmermann@suse.de>
Thu, 16 Jul 2020 12:53:51 +0000 (14:53 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 20 Jul 2020 07:16:11 +0000 (09:16 +0200)
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
drivers/gpu/drm/ast/ast_drv.h
drivers/gpu/drm/ast/ast_main.c
drivers/gpu/drm/ast/ast_mm.c

index c8c442e9efdce608dbb46391c8170350bea5a125..9a770e5b36d193f49a70bc5919bf9d4459534fc2 100644 (file)
@@ -110,7 +110,6 @@ struct ast_private {
        uint32_t dram_bus_width;
        uint32_t dram_type;
        uint32_t mclk;
-       uint32_t vram_size;
 
        int fb_mtrr;
 
index 860a43a64b3194cb4ba7d86a802c25ce040d50d2..b162cc82204d1668ae9e18e59259442cc5aac315 100644 (file)
@@ -378,38 +378,6 @@ static int ast_get_dram_info(struct drm_device *dev)
        return 0;
 }
 
-static u32 ast_get_vram_info(struct drm_device *dev)
-{
-       struct ast_private *ast = to_ast_private(dev);
-       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_driver_load(struct drm_device *dev, unsigned long flags)
 {
        struct ast_private *ast;
@@ -456,10 +424,8 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
        ret = ast_get_dram_info(dev);
        if (ret)
                goto out_free;
-       ast->vram_size = ast_get_vram_info(dev);
-       drm_info(dev, "dram MCLK=%u Mhz type=%d bus_width=%d size=%08x\n",
-                ast->mclk, ast->dram_type,
-                ast->dram_bus_width, ast->vram_size);
+       drm_info(dev, "dram MCLK=%u Mhz type=%d bus_width=%d\n",
+                ast->mclk, ast->dram_type, ast->dram_bus_width);
 
        ret = ast_mm_init(ast);
        if (ret)
index f0a96cae68c9238c67aae962956ede62743d768f..aaeb19d01052ce3e372ed6205c1045148c7d1b5a 100644 (file)
 
 #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;