heads/patches/linux-6.6.16-openpower/0003-drm-ast-Add-option-to-initialize-palette-on-driver-l.patch
Thierry Laurion d7ff890c78
WiP: talos-2: kernel version bump to 6.6.16
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2024-11-29 12:38:05 -05:00

139 lines
4.7 KiB
Diff

From 39017ede41e6286e232c18cdf8b6b600dd751696 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <tpearson@raptorengineering.com>
Date: Fri, 9 Feb 2024 16:22:29 -0600
Subject: [PATCH] drm/ast: Add option to initialize palette on driver load
Non-x86 systems, such as OpenPOWER and ARM machines, do not execute the ASPEED-
provided option ROM on system start. As a result, the VGA palette registers
remain uninitialized, leading to odd colors and generally hard to read output
on the VGA port.
Add a new module option, ast_resetpalette, to enable loading a linear greyscale
palette into the VGA RAMDAC. This option is intended for use by the first Linux
kernel to load after initial power on, such as the skiroot kernel on OpenPOWER
systems.
Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
---
drivers/gpu/drm/ast/ast_drv.c | 4 ++++
drivers/gpu/drm/ast/ast_drv.h | 14 ++++++++++++++
drivers/gpu/drm/ast/ast_main.c | 8 ++++++++
drivers/gpu/drm/ast/ast_mode.c | 14 --------------
4 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index e1224ef4ad83..d46dc88ccbe9 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Red Hat Inc.
+ * Copyright 2024 Raptor Engineering, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -40,9 +41,12 @@
#include "ast_drv.h"
static int ast_modeset = -1;
+int ast_resetpalette = -1;
MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
+MODULE_PARM_DESC(resetpalette, "Disable/Enable palette reset on load");
module_param_named(modeset, ast_modeset, int, 0400);
+module_param_named(resetpalette, ast_resetpalette, int, 0400);
/*
* DRM driver
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index f7053f2972bb..61b6ae0dfbf3 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -340,6 +340,20 @@ static inline void ast_set_index_reg_mask(struct ast_device *ast, u32 base, u8 i
ast_set_index_reg(ast, base, index, tmp);
}
+static inline void ast_load_palette_index(struct ast_device *ast,
+ u8 index, u8 red, u8 green,
+ u8 blue)
+{
+ ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index);
+ ast_io_read8(ast, AST_IO_SEQ_PORT);
+ ast_io_write8(ast, AST_IO_DAC_DATA, red);
+ ast_io_read8(ast, AST_IO_SEQ_PORT);
+ ast_io_write8(ast, AST_IO_DAC_DATA, green);
+ ast_io_read8(ast, AST_IO_SEQ_PORT);
+ ast_io_write8(ast, AST_IO_DAC_DATA, blue);
+ ast_io_read8(ast, AST_IO_SEQ_PORT);
+}
+
#define AST_VIDMEM_SIZE_8M 0x00800000
#define AST_VIDMEM_SIZE_16M 0x01000000
#define AST_VIDMEM_SIZE_32M 0x02000000
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index dae365ed3969..ada259761b0e 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Red Hat Inc.
+ * Copyright 2024 Raptor Engineering, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -35,6 +36,8 @@
#include "ast_drv.h"
+extern int ast_resetpalette;
+
static bool ast_is_vga_enabled(struct drm_device *dev)
{
struct ast_device *ast = to_ast_device(dev);
@@ -432,6 +435,7 @@ struct ast_device *ast_device_create(const struct drm_driver *drv,
struct ast_device *ast;
bool need_post = false;
int ret = 0;
+ int index = 0;
ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base);
if (IS_ERR(ast))
@@ -517,5 +521,9 @@ struct ast_device *ast_device_create(const struct drm_driver *drv,
if (ret)
return ERR_PTR(ret);
+ if (ast_resetpalette == 1)
+ for (index = 0x00; index < 0x100; index++)
+ ast_load_palette_index(ast, index, index, index, index);
+
return ast;
}
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 3de0f457fff6..81bed5eeb87b 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -51,20 +51,6 @@
#define AST_LUT_SIZE 256
-static inline void ast_load_palette_index(struct ast_device *ast,
- u8 index, u8 red, u8 green,
- u8 blue)
-{
- ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index);
- ast_io_read8(ast, AST_IO_SEQ_PORT);
- ast_io_write8(ast, AST_IO_DAC_DATA, red);
- ast_io_read8(ast, AST_IO_SEQ_PORT);
- ast_io_write8(ast, AST_IO_DAC_DATA, green);
- ast_io_read8(ast, AST_IO_SEQ_PORT);
- ast_io_write8(ast, AST_IO_DAC_DATA, blue);
- ast_io_read8(ast, AST_IO_SEQ_PORT);
-}
-
static void ast_crtc_set_gamma_linear(struct ast_device *ast,
const struct drm_format_info *format)
{
--
2.39.2