mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/ast: Fix big-endian support
@ 2025-12-02 16:06 René Rebe
  2025-12-03  9:40 ` Thomas Zimmermann
  0 siblings, 1 reply; 23+ messages in thread
From: René Rebe @ 2025-12-02 16:06 UTC (permalink / raw)
  To: dri-devel, linux-kernel; +Cc: Dave Airlie, Thomas Zimmermann

The Aspeed ast drm driver has the frame-buffer RGBX swapped on
big-endian RISC systems. Fix by enabling byte swapping for any
__BIG_ENDIAN config.

Fixes: 12fec1405dd5 ("drm: Initial KMS driver for AST (ASpeed Technologies) 2000 series (v2)")
Signed-off-by: René Rebe <rene@exactco.de>
---
Tested on Oracle T4-1 running sparc64 T2/Linux.
---
 drivers/gpu/drm/ast/ast_mode.c | 14 ++++++++++++++
 drivers/gpu/drm/ast/ast_reg.h  |  6 ++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 30b011ed0a05..155ae35470d9 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -708,6 +708,20 @@ static void ast_crtc_helper_mode_set_nofb(struct drm_crtc *crtc)
 	ast_set_dclk_reg(ast, adjusted_mode, vmode);
 	ast_set_crtthd_reg(ast);
 	ast_set_sync_reg(ast, adjusted_mode, vmode);
+
+#ifdef __BIG_ENDIAN
+	/* Big-endian byte-swapping */
+	switch (ast_crtc_state->format->format) {
+	case DRM_FORMAT_RGB565:
+		ast_set_index_reg_mask(ast, AST_IO_VGACRI, AST_IO_VGACRA2, 0x3f, 0x40);
+		break;
+	case DRM_FORMAT_XRGB8888:
+		ast_set_index_reg_mask(ast, AST_IO_VGACRI, AST_IO_VGACRA2, 0x3f, 0x80);
+		break;
+	default:
+		break;
+	}
+#endif
 }
 
 static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/ast/ast_reg.h b/drivers/gpu/drm/ast/ast_reg.h
index 30578e3b07e4..5c8c0fd2e229 100644
--- a/drivers/gpu/drm/ast/ast_reg.h
+++ b/drivers/gpu/drm/ast/ast_reg.h
@@ -75,4 +75,10 @@
 #define AST_IO_VGAIR1_R			(0x5A)
 #define AST_IO_VGAIR1_VREFRESH		BIT(3)
 
+/*
+ * PCI Control
+ */
+
+#define AST_IO_VGACRA2			(0xA2) /* PCI control & big-endian */
+
 #endif
-- 
2.52.0


-- 
René Rebe, ExactCODE GmbH, Berlin, Germany
https://exactco.dehttps://t2linux.comhttps://patreon.com/renerebe

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2025-12-15  7:28 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-02 16:06 [PATCH] drm/ast: Fix big-endian support René Rebe
2025-12-03  9:40 ` Thomas Zimmermann
2025-12-03 10:14   ` René Rebe
2025-12-03 10:28     ` Thomas Zimmermann
2025-12-05 15:14   ` René Rebe
2025-12-05 18:31     ` Timothy Pearson
2025-12-05 19:46       ` Thomas Zimmermann
2025-12-05 19:50         ` René Rebe
2025-12-08  8:44           ` Thomas Zimmermann
2025-12-09 12:13             ` René Rebe
2025-12-10  8:55               ` Thomas Zimmermann
2025-12-10 15:33                 ` René Rebe
2025-12-10 15:41                   ` Thomas Zimmermann
2025-12-10 16:56                     ` René Rebe
2025-12-11  7:22                       ` Thomas Zimmermann
2025-12-11 12:43                         ` René Rebe
2025-12-11 14:03                           ` Thomas Zimmermann
2025-12-11 14:31                             ` René Rebe
2025-12-11 14:56                               ` Thomas Zimmermann
2025-12-12 15:14                                 ` Michel Dänzer
2025-12-12 17:54                                   ` René Rebe
2025-12-12 20:15                               ` René Rebe
2025-12-15  7:27                                 ` Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®