From 418b7581212ec736eb1bcc985bd98158b8f67234 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 21 Apr 2021 13:12:48 +0200
Subject: [PATCH 10/11] drm/ast: Add support for 1152x864 mode
Patch-mainline: Never, temporary fixes until upstream resolution
References: bsc#1174416
A code snippet forward-ported from A-Speed downstream driver.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
drivers/gpu/drm/ast/ast_drv.h | 2 +-
drivers/gpu/drm/ast/ast_main.c | 16 ++++++++--------
drivers/gpu/drm/ast/ast_mode.c | 7 ++++++-
drivers/gpu/drm/ast/ast_tables.h | 7 +++++++
4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 883e72f1ef38..ed8f135c9b3c 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -126,7 +126,7 @@ struct ast_private {
struct drm_plane primary_plane;
struct drm_plane cursor_plane;
- bool support_wide_screen;
+ bool support_newvga_mode;
enum {
ast_use_p2a,
ast_use_dt,
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 62259166f0b5..b43e56f5b24e 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -194,29 +194,29 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
drm_info(dev, "AST 2000 detected\n");
}
- /* Check if we support wide screen */
+ /* Check if we newvga mode & support wide screen */
switch (ast->chip) {
case AIP200:
case AST2000:
- ast->support_wide_screen = false;
+ ast->support_newvga_mode = false;
break;
default:
jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
if (!(jreg & 0x80))
- ast->support_wide_screen = true;
+ ast->support_newvga_mode = true;
else if (jreg & 0x01)
- ast->support_wide_screen = true;
+ ast->support_newvga_mode = true;
else {
- ast->support_wide_screen = false;
+ ast->support_newvga_mode = false;
if (ast->chip == AST2300 &&
(scu_rev & 0x300) == 0x0) /* ast1300 */
- ast->support_wide_screen = true;
+ ast->support_newvga_mode = true;
if (ast->chip == AST2400 &&
(scu_rev & 0x300) == 0x100) /* ast1400 */
- ast->support_wide_screen = true;
+ ast->support_newvga_mode = true;
if (ast->chip == AST2500 &&
scu_rev == 0x100) /* ast2510 */
- ast->support_wide_screen = true;
+ ast->support_newvga_mode = true;
}
break;
}
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 4f6c01d48c2a..b2abd1ec85f7 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -114,6 +114,9 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format,
case 1024:
vbios_mode->enh_table = &res_1024x768[refresh_rate_index];
break;
+ case 1152:
+ vbios_mode->enh_table = &res_1152x864[refresh_rate_index];
+ break;
case 1280:
if (mode->crtc_vdisplay == 800)
vbios_mode->enh_table = &res_1280x800[refresh_rate_index];
@@ -966,7 +969,9 @@ static enum drm_mode_status ast_mode_valid(struct drm_connector *connector,
int flags = MODE_NOMODE;
uint32_t jtemp;
- if (ast->support_wide_screen) {
+ if (ast->support_newvga_mode) {
+ if ((mode->hdisplay == 1152) && (mode->vdisplay == 864))
+ return MODE_OK;
if ((mode->hdisplay == 1680) && (mode->vdisplay == 1050))
return MODE_OK;
if ((mode->hdisplay == 1280) && (mode->vdisplay == 800))
diff --git a/drivers/gpu/drm/ast/ast_tables.h b/drivers/gpu/drm/ast/ast_tables.h
index 91399e2a86bf..e878bf75eccf 100644
--- a/drivers/gpu/drm/ast/ast_tables.h
+++ b/drivers/gpu/drm/ast/ast_tables.h
@@ -272,6 +272,13 @@ static const struct ast_vbios_enhtable res_1600x1200[] = {
(SyncPP | Charx8Dot), 0xFF, 1, 0x33 },
};
+static const struct ast_vbios_enhtable res_1152x864[] = {
+ {1600, 1152, 64, 128, 900, 864, 1, 3, VCLK108, /* 75Hz */
+ (SyncPP | Charx8Dot | NewModeInfo), 75, 1, 0x3B },
+ {1600, 1152, 64, 128, 900, 864, 1, 3, VCLK108, /* end */
+ (SyncPP | Charx8Dot | NewModeInfo), 0xFF, 1, 0x3B },
+};
+
/* 16:9 */
static const struct ast_vbios_enhtable res_1360x768[] = {
{1792, 1360, 64, 112, 795, 768, 3, 6, VCLK85_5, /* 60Hz */
--
2.26.2