drm/ast: Initialize mode setting in ast_mode_config_init()
There's modesetting init code in ast_main.c. Move it to ast_mode.c and merge it with the modesetting init code in ast_mode_init(). The result is ast_mode_config_init(), which initalizes the whole modesetting. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-15-tzimmermann@suse.de
This commit is contained in:
parent
1728bf6402
commit
e6949ff3ca
@ -286,7 +286,7 @@ struct ast_crtc_state {
|
|||||||
|
|
||||||
#define to_ast_crtc_state(state) container_of(state, struct ast_crtc_state, base)
|
#define to_ast_crtc_state(state) container_of(state, struct ast_crtc_state, base)
|
||||||
|
|
||||||
extern int ast_mode_init(struct drm_device *dev);
|
int ast_mode_config_init(struct ast_private *ast);
|
||||||
|
|
||||||
#define AST_MM_ALIGN_SHIFT 4
|
#define AST_MM_ALIGN_SHIFT 4
|
||||||
#define AST_MM_ALIGN_MASK ((1 << AST_MM_ALIGN_SHIFT) - 1)
|
#define AST_MM_ALIGN_MASK ((1 << AST_MM_ALIGN_SHIFT) - 1)
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <drm/drm_atomic_helper.h>
|
#include <drm/drm_atomic_helper.h>
|
||||||
#include <drm/drm_crtc_helper.h>
|
#include <drm/drm_crtc_helper.h>
|
||||||
#include <drm/drm_gem.h>
|
#include <drm/drm_gem.h>
|
||||||
#include <drm/drm_gem_framebuffer_helper.h>
|
|
||||||
#include <drm/drm_gem_vram_helper.h>
|
#include <drm/drm_gem_vram_helper.h>
|
||||||
|
|
||||||
#include "ast_drv.h"
|
#include "ast_drv.h"
|
||||||
@ -379,13 +378,6 @@ static int ast_get_dram_info(struct drm_device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct drm_mode_config_funcs ast_mode_funcs = {
|
|
||||||
.fb_create = drm_gem_fb_create,
|
|
||||||
.mode_valid = drm_vram_helper_mode_valid,
|
|
||||||
.atomic_check = drm_atomic_helper_check,
|
|
||||||
.atomic_commit = drm_atomic_helper_commit,
|
|
||||||
};
|
|
||||||
|
|
||||||
static u32 ast_get_vram_info(struct drm_device *dev)
|
static u32 ast_get_vram_info(struct drm_device *dev)
|
||||||
{
|
{
|
||||||
struct ast_private *ast = to_ast_private(dev);
|
struct ast_private *ast = to_ast_private(dev);
|
||||||
@ -473,35 +465,10 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
ret = drmm_mode_config_init(dev);
|
ret = ast_mode_config_init(ast);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
dev->mode_config.funcs = (void *)&ast_mode_funcs;
|
|
||||||
dev->mode_config.min_width = 0;
|
|
||||||
dev->mode_config.min_height = 0;
|
|
||||||
dev->mode_config.preferred_depth = 24;
|
|
||||||
dev->mode_config.prefer_shadow = 1;
|
|
||||||
dev->mode_config.fb_base = pci_resource_start(ast->dev->pdev, 0);
|
|
||||||
|
|
||||||
if (ast->chip == AST2100 ||
|
|
||||||
ast->chip == AST2200 ||
|
|
||||||
ast->chip == AST2300 ||
|
|
||||||
ast->chip == AST2400 ||
|
|
||||||
ast->chip == AST2500) {
|
|
||||||
dev->mode_config.max_width = 1920;
|
|
||||||
dev->mode_config.max_height = 2048;
|
|
||||||
} else {
|
|
||||||
dev->mode_config.max_width = 1600;
|
|
||||||
dev->mode_config.max_height = 1200;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ast_mode_init(dev);
|
|
||||||
if (ret)
|
|
||||||
goto out_free;
|
|
||||||
|
|
||||||
drm_mode_config_reset(dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
out_free:
|
out_free:
|
||||||
kfree(ast);
|
kfree(ast);
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <drm/drm_crtc.h>
|
#include <drm/drm_crtc.h>
|
||||||
#include <drm/drm_crtc_helper.h>
|
#include <drm/drm_crtc_helper.h>
|
||||||
#include <drm/drm_fourcc.h>
|
#include <drm/drm_fourcc.h>
|
||||||
|
#include <drm/drm_gem_framebuffer_helper.h>
|
||||||
#include <drm/drm_gem_vram_helper.h>
|
#include <drm/drm_gem_vram_helper.h>
|
||||||
#include <drm/drm_plane_helper.h>
|
#include <drm/drm_plane_helper.h>
|
||||||
#include <drm/drm_probe_helper.h>
|
#include <drm/drm_probe_helper.h>
|
||||||
@ -1069,15 +1070,49 @@ static int ast_connector_init(struct drm_device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_mode_init(struct drm_device *dev)
|
/*
|
||||||
|
* Mode config
|
||||||
|
*/
|
||||||
|
|
||||||
|
static const struct drm_mode_config_funcs ast_mode_config_funcs = {
|
||||||
|
.fb_create = drm_gem_fb_create,
|
||||||
|
.mode_valid = drm_vram_helper_mode_valid,
|
||||||
|
.atomic_check = drm_atomic_helper_check,
|
||||||
|
.atomic_commit = drm_atomic_helper_commit,
|
||||||
|
};
|
||||||
|
|
||||||
|
int ast_mode_config_init(struct ast_private *ast)
|
||||||
{
|
{
|
||||||
struct ast_private *ast = to_ast_private(dev);
|
struct drm_device *dev = ast->dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = ast_cursor_init(ast);
|
ret = ast_cursor_init(ast);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
ret = drmm_mode_config_init(dev);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
dev->mode_config.funcs = &ast_mode_config_funcs;
|
||||||
|
dev->mode_config.min_width = 0;
|
||||||
|
dev->mode_config.min_height = 0;
|
||||||
|
dev->mode_config.preferred_depth = 24;
|
||||||
|
dev->mode_config.prefer_shadow = 1;
|
||||||
|
dev->mode_config.fb_base = pci_resource_start(ast->dev->pdev, 0);
|
||||||
|
|
||||||
|
if (ast->chip == AST2100 ||
|
||||||
|
ast->chip == AST2200 ||
|
||||||
|
ast->chip == AST2300 ||
|
||||||
|
ast->chip == AST2400 ||
|
||||||
|
ast->chip == AST2500) {
|
||||||
|
dev->mode_config.max_width = 1920;
|
||||||
|
dev->mode_config.max_height = 2048;
|
||||||
|
} else {
|
||||||
|
dev->mode_config.max_width = 1600;
|
||||||
|
dev->mode_config.max_height = 1200;
|
||||||
|
}
|
||||||
|
|
||||||
memset(&ast->primary_plane, 0, sizeof(ast->primary_plane));
|
memset(&ast->primary_plane, 0, sizeof(ast->primary_plane));
|
||||||
ret = drm_universal_plane_init(dev, &ast->primary_plane, 0x01,
|
ret = drm_universal_plane_init(dev, &ast->primary_plane, 0x01,
|
||||||
&ast_primary_plane_funcs,
|
&ast_primary_plane_funcs,
|
||||||
@ -1107,6 +1142,8 @@ int ast_mode_init(struct drm_device *dev)
|
|||||||
ast_encoder_init(dev);
|
ast_encoder_init(dev);
|
||||||
ast_connector_init(dev);
|
ast_connector_init(dev);
|
||||||
|
|
||||||
|
drm_mode_config_reset(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user