Module Name: src
Committed By: macallan
Date: Thu Nov 11 19:37:30 UTC 2021
Modified Files:
src/sys/dev/sbus: mgx.c mgxreg.h
Log Message:
provide an endian-flipped view of the framebuffer via mmap() if we know how
for now this is sparc64 only
To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sbus/mgx.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sbus/mgxreg.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/sbus/mgx.c
diff -u src/sys/dev/sbus/mgx.c:1.19 src/sys/dev/sbus/mgx.c:1.20
--- src/sys/dev/sbus/mgx.c:1.19 Sun Oct 31 05:31:12 2021
+++ src/sys/dev/sbus/mgx.c Thu Nov 11 19:37:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: mgx.c,v 1.19 2021/10/31 05:31:12 macallan Exp $ */
+/* $NetBSD: mgx.c,v 1.20 2021/11/11 19:37:30 macallan Exp $ */
/*-
* Copyright (c) 2014 Michael Lorenz
@@ -29,7 +29,7 @@
/* a console driver for the SSB 4096V-MGX graphics card */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.19 2021/10/31 05:31:12 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.20 2021/11/11 19:37:30 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1112,11 +1112,19 @@ mgx_mmap(void *v, void *vs, off_t offset
{
struct vcons_data *vd = v;
struct mgx_softc *sc = vd->cookie;
+ uint32_t flags = BUS_SPACE_MAP_LINEAR;
+
+#ifdef BUS_SPACE_MAP_LITTLE
+ if (offset & MGX_FLIPOFFSET) {
+ offset &= ~MGX_FLIPOFFSET;
+ flags |= BUS_SPACE_MAP_LITTLE;
+ }
+#endif
/* regular fb mapping at 0 */
if ((offset >= 0) && (offset < sc->sc_fbsize)) {
return bus_space_mmap(sc->sc_tag, sc->sc_paddr,
- offset, prot, BUS_SPACE_MAP_LINEAR);
+ offset, prot, flags);
}
/*
@@ -1262,11 +1270,19 @@ paddr_t
mgxmmap(dev_t dev, off_t offset, int prot)
{
struct mgx_softc *sc = device_lookup_private(&mgx_cd, minor(dev));
+ uint32_t flags = BUS_SPACE_MAP_LINEAR;
+
+#ifdef BUS_SPACE_MAP_LITTLE
+ if (offset & MGX_FLIPOFFSET) {
+ offset &= ~MGX_FLIPOFFSET;
+ flags |= BUS_SPACE_MAP_LITTLE;
+ }
+#endif
/* regular fb mapping at 0 */
if ((offset >= 0) && (offset < sc->sc_fbsize)) {
return bus_space_mmap(sc->sc_tag, sc->sc_paddr,
- offset, prot, BUS_SPACE_MAP_LINEAR);
+ offset, prot, flags);
}
/*
Index: src/sys/dev/sbus/mgxreg.h
diff -u src/sys/dev/sbus/mgxreg.h:1.6 src/sys/dev/sbus/mgxreg.h:1.7
--- src/sys/dev/sbus/mgxreg.h:1.6 Sat Oct 30 05:37:39 2021
+++ src/sys/dev/sbus/mgxreg.h Thu Nov 11 19:37:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: mgxreg.h,v 1.6 2021/10/30 05:37:39 macallan Exp $ */
+/* $NetBSD: mgxreg.h,v 1.7 2021/11/11 19:37:30 macallan Exp $ */
/* register definitions based on OpenBSD's atxxreg.h: */
@@ -30,8 +30,9 @@
#ifndef MGX_REG_H
#define MGX_REG_H
-#define MGX_FBOFFSET 0x00000000
-#define MGX_BLTOFFSET 0x00800000
+#define MGX_FBOFFSET 0x00000000
+#define MGX_BLTOFFSET 0x00800000
+#define MGX_FLIPOFFSET 0x01000000
#define VGA_BASE 0x3c0
#define CRTC_INDEX 0x3d4