Skip to content

Commit e6949ff

Browse files
committed
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
1 parent 1728bf6 commit e6949ff

3 files changed

Lines changed: 41 additions & 37 deletions

File tree

‎drivers/gpu/drm/ast/ast_drv.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ struct ast_crtc_state {
286286

287287
#define to_ast_crtc_state(state) container_of(state, struct ast_crtc_state, base)
288288

289-
extern int ast_mode_init(struct drm_device *dev);
289+
int ast_mode_config_init(struct ast_private *ast);
290290

291291
#define AST_MM_ALIGN_SHIFT 4
292292
#define AST_MM_ALIGN_MASK ((1 << AST_MM_ALIGN_SHIFT) - 1)

‎drivers/gpu/drm/ast/ast_main.c‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <drm/drm_atomic_helper.h>
3232
#include <drm/drm_crtc_helper.h>
3333
#include <drm/drm_gem.h>
34-
#include <drm/drm_gem_framebuffer_helper.h>
3534
#include <drm/drm_gem_vram_helper.h>
3635

3736
#include "ast_drv.h"
@@ -379,13 +378,6 @@ static int ast_get_dram_info(struct drm_device *dev)
379378
return 0;
380379
}
381380

382-
static const struct drm_mode_config_funcs ast_mode_funcs = {
383-
.fb_create = drm_gem_fb_create,
384-
.mode_valid = drm_vram_helper_mode_valid,
385-
.atomic_check = drm_atomic_helper_check,
386-
.atomic_commit = drm_atomic_helper_commit,
387-
};
388-
389381
static u32 ast_get_vram_info(struct drm_device *dev)
390382
{
391383
struct ast_private *ast = to_ast_private(dev);
@@ -473,35 +465,10 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
473465
if (ret)
474466
goto out_free;
475467

476-
ret = drmm_mode_config_init(dev);
477-
if (ret)
478-
goto out_free;
479-
480-
dev->mode_config.funcs = (void *)&ast_mode_funcs;
481-
dev->mode_config.min_width = 0;
482-
dev->mode_config.min_height = 0;
483-
dev->mode_config.preferred_depth = 24;
484-
dev->mode_config.prefer_shadow = 1;
485-
dev->mode_config.fb_base = pci_resource_start(ast->dev->pdev, 0);
486-
487-
if (ast->chip == AST2100 ||
488-
ast->chip == AST2200 ||
489-
ast->chip == AST2300 ||
490-
ast->chip == AST2400 ||
491-
ast->chip == AST2500) {
492-
dev->mode_config.max_width = 1920;
493-
dev->mode_config.max_height = 2048;
494-
} else {
495-
dev->mode_config.max_width = 1600;
496-
dev->mode_config.max_height = 1200;
497-
}
498-
499-
ret = ast_mode_init(dev);
468+
ret = ast_mode_config_init(ast);
500469
if (ret)
501470
goto out_free;
502471

503-
drm_mode_config_reset(dev);
504-
505472
return 0;
506473
out_free:
507474
kfree(ast);

‎drivers/gpu/drm/ast/ast_mode.c‎

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <drm/drm_crtc.h>
3838
#include <drm/drm_crtc_helper.h>
3939
#include <drm/drm_fourcc.h>
40+
#include <drm/drm_gem_framebuffer_helper.h>
4041
#include <drm/drm_gem_vram_helper.h>
4142
#include <drm/drm_plane_helper.h>
4243
#include <drm/drm_probe_helper.h>
@@ -1069,15 +1070,49 @@ static int ast_connector_init(struct drm_device *dev)
10691070
return 0;
10701071
}
10711072

1072-
int ast_mode_init(struct drm_device *dev)
1073+
/*
1074+
* Mode config
1075+
*/
1076+
1077+
static const struct drm_mode_config_funcs ast_mode_config_funcs = {
1078+
.fb_create = drm_gem_fb_create,
1079+
.mode_valid = drm_vram_helper_mode_valid,
1080+
.atomic_check = drm_atomic_helper_check,
1081+
.atomic_commit = drm_atomic_helper_commit,
1082+
};
1083+
1084+
int ast_mode_config_init(struct ast_private *ast)
10731085
{
1074-
struct ast_private *ast = to_ast_private(dev);
1086+
struct drm_device *dev = ast->dev;
10751087
int ret;
10761088

10771089
ret = ast_cursor_init(ast);
10781090
if (ret)
10791091
return ret;
10801092

1093+
ret = drmm_mode_config_init(dev);
1094+
if (ret)
1095+
return ret;
1096+
1097+
dev->mode_config.funcs = &ast_mode_config_funcs;
1098+
dev->mode_config.min_width = 0;
1099+
dev->mode_config.min_height = 0;
1100+
dev->mode_config.preferred_depth = 24;
1101+
dev->mode_config.prefer_shadow = 1;
1102+
dev->mode_config.fb_base = pci_resource_start(ast->dev->pdev, 0);
1103+
1104+
if (ast->chip == AST2100 ||
1105+
ast->chip == AST2200 ||
1106+
ast->chip == AST2300 ||
1107+
ast->chip == AST2400 ||
1108+
ast->chip == AST2500) {
1109+
dev->mode_config.max_width = 1920;
1110+
dev->mode_config.max_height = 2048;
1111+
} else {
1112+
dev->mode_config.max_width = 1600;
1113+
dev->mode_config.max_height = 1200;
1114+
}
1115+
10811116
memset(&ast->primary_plane, 0, sizeof(ast->primary_plane));
10821117
ret = drm_universal_plane_init(dev, &ast->primary_plane, 0x01,
10831118
&ast_primary_plane_funcs,
@@ -1107,6 +1142,8 @@ int ast_mode_init(struct drm_device *dev)
11071142
ast_encoder_init(dev);
11081143
ast_connector_init(dev);
11091144

1145+
drm_mode_config_reset(dev);
1146+
11101147
return 0;
11111148
}
11121149

0 commit comments

Comments
 (0)