Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sbus switch to 32bit colour in WSDISPLAYIO_MODE_MAPP...
details: https://anonhg.NetBSD.org/src/rev/d7eb81cf180a
branches: trunk
changeset: 343520:d7eb81cf180a
user: macallan <macallan%NetBSD.org@localhost>
date: Thu Feb 11 02:23:44 2016 +0000
description:
switch to 32bit colour in WSDISPLAYIO_MODE_MAPPED, now X with wsfb will work
Not optimal though - for some reason the framebuffer's endianness in 32bit
colour is wrong and I have no idea (yet) how to change that, so many apps
using xrender will crash.
diffstat:
sys/dev/sbus/files.sbus | 7 +-
sys/dev/sbus/mgx.c | 243 ++++++++++++++++++++++++++++++++++++-----------
sys/dev/sbus/mgxreg.h | 56 ++++------
3 files changed, 211 insertions(+), 95 deletions(-)
diffs (truncated from 523 to 300 lines):
diff -r da7758fc9f0d -r d7eb81cf180a sys/dev/sbus/files.sbus
--- a/sys/dev/sbus/files.sbus Wed Feb 10 17:10:47 2016 +0000
+++ b/sys/dev/sbus/files.sbus Thu Feb 11 02:23:44 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.sbus,v 1.41 2015/01/04 18:18:20 macallan Exp $
+# $NetBSD: files.sbus,v 1.42 2016/02/11 02:23:44 macallan Exp $
#
# Config file and device description for machine-independent SBUS code.
# Included by ports that need it.
@@ -156,7 +156,8 @@
file dev/sbus/cgtwelve.c cgtwelve
# SSB MGX
-defflag opt_mgx.h MGX_DEBUG
-device mgx: fb, rasops8, wsemuldisplaydev, vcons, glyphcache
+defflag opt_mgx.h MGX_DEBUG
+defparam opt_mgx.h MGX_DEPTH=8
+device mgx: fb, rasops8, rasops32, wsemuldisplaydev, vcons, glyphcache
attach mgx at sbus
file dev/sbus/mgx.c mgx
diff -r da7758fc9f0d -r d7eb81cf180a sys/dev/sbus/mgx.c
--- a/sys/dev/sbus/mgx.c Wed Feb 10 17:10:47 2016 +0000
+++ b/sys/dev/sbus/mgx.c Thu Feb 11 02:23:44 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mgx.c,v 1.4 2015/01/06 17:41:30 macallan Exp $ */
+/* $NetBSD: mgx.c,v 1.5 2016/02/11 02:23:44 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.4 2015/01/06 17:41:30 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.5 2016/02/11 02:23:44 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -58,7 +58,7 @@
#include <dev/sbus/mgxreg.h>
#include "opt_wsemul.h"
-
+#include "opt_mgx.h"
struct mgx_softc {
device_t sc_dev;
@@ -70,8 +70,10 @@
int sc_width;
int sc_height;
int sc_stride;
+ int sc_depth;
int sc_fbsize;
int sc_mode;
+ char sc_name[8];
uint32_t sc_dec;
u_char sc_cmap_red[256];
u_char sc_cmap_green[256];
@@ -98,6 +100,7 @@
static int mgx_putcmap(struct mgx_softc *, struct wsdisplay_cmap *);
static int mgx_getcmap(struct mgx_softc *, struct wsdisplay_cmap *);
static int mgx_wait_engine(struct mgx_softc *);
+static int mgx_wait_host(struct mgx_softc *);
static int mgx_wait_fifo(struct mgx_softc *, unsigned int);
static void mgx_bitblt(void *, int, int, int, int, int, int, int);
@@ -124,6 +127,36 @@
NULL, /* scroll */
};
+static inline void
+mgx_write_vga(struct mgx_softc *sc, uint32_t reg, uint8_t val)
+{
+ bus_space_write_1(sc->sc_tag, sc->sc_vgah, reg ^ 3, val);
+}
+
+static inline uint8_t
+mgx_read_vga(struct mgx_softc *sc, uint32_t reg)
+{
+ return bus_space_read_1(sc->sc_tag, sc->sc_vgah, reg ^ 3);
+}
+
+static inline void
+mgx_write_1(struct mgx_softc *sc, uint32_t reg, uint8_t val)
+{
+ bus_space_write_1(sc->sc_tag, sc->sc_blith, reg ^ 3, val);
+}
+
+static inline uint8_t
+mgx_read_1(struct mgx_softc *sc, uint32_t reg)
+{
+ return bus_space_read_1(sc->sc_tag, sc->sc_blith, reg ^ 3);
+}
+
+static inline void
+mgx_write_4(struct mgx_softc *sc, uint32_t reg, uint32_t val)
+{
+ bus_space_write_4(sc->sc_tag, sc->sc_blith, reg, val);
+}
+
static int
mgx_match(device_t parent, cfdata_t cf, void *aux)
{
@@ -159,8 +192,8 @@
/* read geometry information from the device tree */
sc->sc_width = prom_getpropint(sa->sa_node, "width", 1152);
sc->sc_height = prom_getpropint(sa->sa_node, "height", 900);
- sc->sc_stride = prom_getpropint(sa->sa_node, "linebytes", 900);
- sc->sc_fbsize = sc->sc_height * sc->sc_stride;
+ sc->sc_stride = prom_getpropint(sa->sa_node, "linebytes", 1152);
+ sc->sc_fbsize = prom_getpropint(sa->sa_node, "fb_size", 0x00400000);
sc->sc_fbaddr = NULL;
if (sc->sc_fbaddr == NULL) {
if (sbus_bus_map(sa->sa_bustag,
@@ -169,14 +202,12 @@
sc->sc_fbsize,
BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE,
&bh) != 0) {
- aprint_error_dev(self, "cannot map framebuffer\n");
+ aprint_error_dev(self, "couldn't map framebuffer\n");
return;
}
sc->sc_fbaddr = bus_space_vaddr(sa->sa_bustag, bh);
}
- aprint_normal_dev(self, "%d x %d\n", sc->sc_width, sc->sc_height);
-
if (sbus_bus_map(sa->sa_bustag,
sa->sa_slot,
sa->sa_reg[4].oa_base, 0x1000, 0,
@@ -195,7 +226,11 @@
return;
}
- mgx_setup(sc, 8);
+ mgx_setup(sc, MGX_DEPTH);
+
+ aprint_normal_dev(self, "[%s] %d MB framebuffer, %d x %d\n",
+ sc->sc_name, sc->sc_fbsize >> 20, sc->sc_width, sc->sc_height);
+
sc->sc_defaultscreen_descr = (struct wsscreen_descr) {
"default",
@@ -253,33 +288,21 @@
aa.accesscookie = &sc->vd;
config_found(self, &aa, wsemuldisplaydevprint);
-}
-static inline void
-mgx_write_vga(struct mgx_softc *sc, uint32_t reg, uint8_t val)
-{
- bus_space_write_1(sc->sc_tag, sc->sc_vgah, reg ^ 3, val);
-}
+#if 0
+ uint32_t *fb = sc->sc_fbaddr;
+ int i, j;
+ for (i = 0; i < 256; i += 16) {
+ printf("%04x:", i);
+ for (j = 0; j < 16; j += 4) {
+ printf(" %08x", fb[(i + j) >> 2]);
+ }
+ printf("\n");
+ }
+#endif
-static inline void
-mgx_write_1(struct mgx_softc *sc, uint32_t reg, uint8_t val)
-{
- bus_space_write_1(sc->sc_tag, sc->sc_blith, reg ^ 3, val);
}
-static inline uint8_t
-mgx_read_1(struct mgx_softc *sc, uint32_t reg)
-{
- return bus_space_read_1(sc->sc_tag, sc->sc_blith, reg ^ 3);
-}
-
-static inline void
-mgx_write_4(struct mgx_softc *sc, uint32_t reg, uint32_t val)
-{
- bus_space_write_4(sc->sc_tag, sc->sc_blith, reg, val);
-}
-
-
static void
mgx_write_dac(struct mgx_softc *sc, int idx, int r, int g, int b)
{
@@ -296,13 +319,20 @@
int i, j = 0;
uint8_t cmap[768];
- rasops_get_cmap(ri, cmap, sizeof(cmap));
- for (i = 0; i < 256; i++) {
- sc->sc_cmap_red[i] = cmap[j];
- sc->sc_cmap_green[i] = cmap[j + 1];
- sc->sc_cmap_blue[i] = cmap[j + 2];
- mgx_write_dac(sc, i, cmap[j], cmap[j + 1], cmap[j + 2]);
- j += 3;
+ if (sc->sc_depth == 8) {
+ rasops_get_cmap(ri, cmap, sizeof(cmap));
+ for (i = 0; i < 256; i++) {
+ sc->sc_cmap_red[i] = cmap[j];
+ sc->sc_cmap_green[i] = cmap[j + 1];
+ sc->sc_cmap_blue[i] = cmap[j + 2];
+ mgx_write_dac(sc, i, cmap[j], cmap[j + 1], cmap[j + 2]);
+ j += 3;
+ }
+ } else {
+ /* linear ramp for true colour modes */
+ for (i = 0; i < 256; i++) {
+ mgx_write_dac(sc, i, i, i, i);
+ }
}
}
@@ -382,6 +412,21 @@
return i;
}
+static inline int
+mgx_wait_host(struct mgx_softc *sc)
+{
+ unsigned int i;
+ uint8_t stat;
+
+ for (i = 10000; i != 0; i--) {
+ stat = mgx_read_1(sc, ATR_BLT_STATUS);
+ if ((stat & BLT_HOST_BUSY) == 0)
+ break;
+ }
+
+ return i;
+}
+
static int
mgx_wait_fifo(struct mgx_softc *sc, unsigned int nfifo)
{
@@ -402,31 +447,57 @@
static void
mgx_setup(struct mgx_softc *sc, int depth)
{
+ uint32_t stride;
+ int i;
+ uint8_t reg;
+
/* wait for everything to go idle */
if (mgx_wait_engine(sc) == 0)
return;
if (mgx_wait_fifo(sc, FIFO_AT24) == 0)
return;
- /*
- * Compute the invariant bits of the DEC register.
- */
+
+ /* read name from sequencer */
+ for (i = 0; i < 8; i++) {
+ mgx_write_vga(sc, SEQ_INDEX, i + 0x11);
+ sc->sc_name[i] = mgx_read_vga(sc, SEQ_DATA);
+ }
+ sc->sc_name[7] = 0;
+
+ reg = mgx_read_1(sc, ATR_PIXEL);
+ reg &= ~PIXEL_DEPTH_MASK;
switch (depth) {
case 8:
sc->sc_dec = DEC_DEPTH_8 << DEC_DEPTH_SHIFT;
+ reg |= PIXEL_8;
break;
case 15:
+ sc->sc_dec = DEC_DEPTH_16 << DEC_DEPTH_SHIFT;
+ reg |= PIXEL_15;
+ break;
case 16:
sc->sc_dec = DEC_DEPTH_16 << DEC_DEPTH_SHIFT;
+ reg |= PIXEL_16;
break;
case 32:
sc->sc_dec = DEC_DEPTH_32 << DEC_DEPTH_SHIFT;
+ reg |= PIXEL_32;
break;
default:
return; /* not supported */
}
- switch (sc->sc_stride) {
+ /* the chip wants stride in units of 8 bytes */
+ sc->sc_stride = sc->sc_width * (depth >> 3);
+ stride = sc->sc_stride >> 3;
+#ifdef MGX_DEBUG
+ sc->sc_height = 600;
+#endif
+
+ sc->sc_depth = depth;
+
+ switch (sc->sc_width) {
case 640:
sc->sc_dec |= DEC_WIDTH_640 << DEC_WIDTH_SHIFT;
break;
Home |
Main Index |
Thread Index |
Old Index