Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add genfb(4) driver for mac68k grfbus.



details:   https://anonhg.NetBSD.org/src/rev/2b3f79dd09b0
branches:  trunk
changeset: 452884:2b3f79dd09b0
user:      rin <rin%NetBSD.org@localhost>
date:      Fri Jul 26 10:48:44 2019 +0000

description:
Add genfb(4) driver for mac68k grfbus.
1, 2, 4, 8, 15, and 32 color-depths are supported.

ANSI colors on console are functional for depth >= 4.

Graphic applications based on wsfb API should work, provided
they can correctly handle fbi_fboffset and your color depth.

wsfb driver of Xorg 1.20 and mlterm-fb (framebuffer version of
x11/mlterm) work fine for depth == 1 || depth >= 8.

For depth == 8 (256 colors), graphic applications require
colormap callback, which is currently supported for some
internal graphic adapters, and only Civic (found on Quadra
AV series) was tested. Register definition and its usage are
taken from Linux. You can easily support other adapters if
Linux supports that.

Have fun, and any problem reports are welcomed!

diffstat:

 share/man/man4/genfb.4             |   10 +-
 sys/arch/mac68k/conf/WSFB          |    6 +
 sys/arch/mac68k/conf/WSFB.common   |   27 +++
 sys/arch/mac68k/conf/WSFBSBC       |    6 +
 sys/arch/mac68k/conf/files.mac68k  |    7 +-
 sys/arch/mac68k/dev/genfb_grfbus.c |  257 +++++++++++++++++++++++++++++++++++++
 sys/arch/mac68k/dev/grf_subr.c     |    6 +-
 sys/arch/mac68k/dev/grfvar.h       |   17 ++-
 sys/arch/mac68k/dev/maccons.c      |   26 +++-
 sys/arch/mac68k/mac68k/conf.c      |   12 +-
 sys/arch/mac68k/mac68k/machdep.c   |    7 +-
 sys/arch/mac68k/obio/grf_obio.c    |  166 ++++++++++++++++++++++-
 sys/arch/mac68k/obio/grf_obioreg.h |  106 +++++++++++++++
 sys/dev/rasops/rasops.c            |   75 ++++++++++-
 sys/dev/wsfb/files.wsfb            |    4 +-
 15 files changed, 694 insertions(+), 38 deletions(-)

diffs (truncated from 1087 to 300 lines):

diff -r b2a2b08d4ea3 -r 2b3f79dd09b0 share/man/man4/genfb.4
--- a/share/man/man4/genfb.4    Fri Jul 26 10:47:29 2019 +0000
+++ b/share/man/man4/genfb.4    Fri Jul 26 10:48:44 2019 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: genfb.4,v 1.3 2009/08/24 02:25:18 jmcneill Exp $
+.\"    $NetBSD: genfb.4,v 1.4 2019/07/26 10:48:44 rin Exp $
 .\"
 .\" Copyright (c) 2007 Michael Lorenz
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 23, 2009
+.Dd July 26, 2019
 .Dt GENFB 4
 .Os
 .Sh NAME
@@ -35,6 +35,8 @@
 .Sh SYNOPSIS
 .Cd "genfb* at pci?"
 .Cd "genfb* at sbus?"
+.Cd "genfb* at intvid?" Pq mac68k
+.Cd "genfb* at macvid?" Pq mac68k
 .Cd "wsdisplay* at genfb?"
 .Sh DESCRIPTION
 The
@@ -65,9 +67,13 @@
 When attaching to
 .Xr sbus 4
 all those parameters are retrieved from the firmware.
+.Ss mac68k
+All those parameters are configured with Mac OS,
+and retrieved from the boot loader.
 .Sh SEE ALSO
 .Xr pci 4 ,
 .Xr sbus 4 ,
+.Xr mac68k/intro 4 ,
 .Xr wscons 4 ,
 .Xr wsdisplay 4
 .Sh BUGS
diff -r b2a2b08d4ea3 -r 2b3f79dd09b0 sys/arch/mac68k/conf/WSFB
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mac68k/conf/WSFB Fri Jul 26 10:48:44 2019 +0000
@@ -0,0 +1,6 @@
+# $NetBSD: WSFB,v 1.1 2019/07/26 10:48:44 rin Exp $
+#
+# GENERIC with wsfb raster console driver enabled
+
+include "arch/mac68k/conf/GENERIC"
+include "arch/mac68k/conf/WSFB.common"
diff -r b2a2b08d4ea3 -r 2b3f79dd09b0 sys/arch/mac68k/conf/WSFB.common
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mac68k/conf/WSFB.common  Fri Jul 26 10:48:44 2019 +0000
@@ -0,0 +1,27 @@
+# $NetBSD: WSFB.common,v 1.1 2019/07/26 10:48:44 rin Exp $
+
+genfb* at intvid?
+genfb* at macvid?
+wsdisplay* at wsemuldisplaydev?
+
+options RASOPS_APPLE_PALETTE
+
+options WSDISPLAY_DEFAULTSCREENS=1
+options WS_KERNEL_FG=WSCOL_GREEN
+#options WS_KERNEL_BG=WSCOL_BLACK
+
+pseudo-device wsfont
+pseudo-device wsmux
+
+no options WSDISPLAY_COMPAT_ITEFONT
+no options RCONS_2BPP
+no options RCONS_4BPP
+no options RCONS_16BPP
+no options GRF_COMPAT
+
+no macfb* at intvid?
+no macfb* at macvid?
+no wsdisplay* at macfb?
+
+no pseudo-device grf
+no pseudo-device ite
diff -r b2a2b08d4ea3 -r 2b3f79dd09b0 sys/arch/mac68k/conf/WSFBSBC
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mac68k/conf/WSFBSBC      Fri Jul 26 10:48:44 2019 +0000
@@ -0,0 +1,6 @@
+# $NetBSD: WSFBSBC,v 1.1 2019/07/26 10:48:44 rin Exp $
+#
+# GENERICSBC with wsfb raster console driver enabled
+
+include "arch/mac68k/conf/GENERICSBC"
+include "arch/mac68k/conf/WSFB.common"
diff -r b2a2b08d4ea3 -r 2b3f79dd09b0 sys/arch/mac68k/conf/files.mac68k
--- a/sys/arch/mac68k/conf/files.mac68k Fri Jul 26 10:47:29 2019 +0000
+++ b/sys/arch/mac68k/conf/files.mac68k Fri Jul 26 10:48:44 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.mac68k,v 1.128 2019/02/18 01:12:23 thorpej Exp $
+#      $NetBSD: files.mac68k,v 1.129 2019/07/26 10:48:44 rin Exp $
 
 # mac68k-specific configuration info
 
@@ -64,7 +64,10 @@
 attach macfb at grfbus
 file   arch/mac68k/dev/macfb.c         macfb needs-flag
 
-file   arch/mac68k/dev/maccons.c       akbd & macfb
+attach genfb at grfbus with genfb_grfbus
+file   arch/mac68k/dev/genfb_grfbus.c  genfb_grfbus
+
+file   arch/mac68k/dev/maccons.c       akbd & (macfb | genfb_grfbus)
 
 #device        ite: wsemuldisplaydev
 #attach        ite at wsdisplay
diff -r b2a2b08d4ea3 -r 2b3f79dd09b0 sys/arch/mac68k/dev/genfb_grfbus.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mac68k/dev/genfb_grfbus.c        Fri Jul 26 10:48:44 2019 +0000
@@ -0,0 +1,257 @@
+/* $NetBSD: genfb_grfbus.c,v 1.1 2019/07/26 10:48:44 rin Exp $ */
+
+/* NetBSD: simplefb.c,v 1.7 2019/01/30 00:55:04 jmcneill Exp */
+/*-
+ * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* NetBSD: macfb.c,v 1.20 2012/10/27 17:17:59 chs Exp */
+/*
+ * Copyright (c) 1998 Matt DeBergalis
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Matt DeBergalis
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opt_wsdisplay_compat.h"
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: genfb_grfbus.c,v 1.1 2019/07/26 10:48:44 rin Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+
+#include <machine/cpu.h>
+#include <machine/bus.h>
+
+#include <machine/video.h>
+#include <machine/grfioctl.h>
+#include <mac68k/nubus/nubus.h>
+#include <mac68k/dev/grfvar.h>
+
+#include <dev/wsfb/genfbvar.h>
+
+struct genfb_grfbus_softc {
+       struct genfb_softc sc_gen;
+
+       uint32_t sc_width;
+       uint32_t sc_height;
+       uint8_t  sc_depth;
+       uint16_t sc_stride;
+
+       paddr_t sc_paddr;
+       vaddr_t sc_vaddr;
+
+       void (*sc_set_mapreg)(void *, int, int, int, int);
+       struct grfbus_softc *sc_parent;
+};
+
+static int genfb_grfbus_ioctl(void *, void *, u_long, void *, int, lwp_t *);
+static paddr_t genfb_grfbus_mmap(void *, void *, off_t, int);
+
+static struct genfb_ops gfb_ops = {
+       .genfb_ioctl = genfb_grfbus_ioctl,
+       .genfb_mmap = genfb_grfbus_mmap,
+};
+
+static struct genfb_colormap_callback gfb_cmcb;
+
+static int __unused
+genfb_grfbus_is_console(paddr_t addr)
+{
+
+       if (addr != mac68k_video.mv_phys &&
+           (addr >= 0xf9000000 && addr <= 0xfeffffff)) {
+               /*
+                * This is in the NuBus standard slot space range, so we
+                * may well have to look at 0xFssxxxxx, too.  Mask off the
+                * slot number and duplicate it in bits 20-23, per IM:V
+                * pp 459, 463, and IM:VI ch 30 p 17.
+                * Note:  this is an ugly hack and I wish I knew what
+                * to do about it.  -- sr
+                */
+               addr = (paddr_t)(((u_long)addr & 0xff0fffff) |
+                   (((u_long)addr & 0x0f000000) >> 4));
+       }
+       return ((mac68k_machine.serial_console & 0x03) == 0
+           && (addr == mac68k_video.mv_phys));
+}
+
+static int
+genfb_grfbus_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l)
+{
+       struct genfb_grfbus_softc * const sc = v;
+#if 0
+       struct wsdisplayio_bus_id *busid;
+#endif
+       struct wsdisplayio_fbinfo *fbi;
+       struct rasops_info *ri;
+       int error;
+
+       switch (cmd) {
+       case WSDISPLAYIO_GTYPE:
+               *(u_int *)data = WSDISPLAY_TYPE_GENFB;
+               return 0;
+#if 0
+       case WSDISPLAYIO_GET_BUSID:
+               busid = data;
+               busid->bus_type = WSDISPLAYIO_BUS_GRFBUS;
+               return 0;
+#endif
+       case WSDISPLAYIO_GET_FBINFO:
+               fbi = data;
+               ri = &sc->sc_gen.vd.active->scr_ri;
+               error = wsdisplayio_get_fbinfo(ri, fbi);
+               if (error == 0) {
+                       /*
+                        * XXX
+                        * if the fb isn't page aligned, tell wsfb to skip the
+                        * unaligned part
+                        */
+                       fbi->fbi_fboffset = m68k_page_offset(sc->sc_paddr);
+                       fbi->fbi_flags |= WSFB_VRAM_IS_RAM;
+               }
+               return error;
+       default:
+               return EPASSTHROUGH;
+       }
+}
+
+static paddr_t
+genfb_grfbus_mmap(void *v, void *vs, off_t off, int prot)
+{
+       struct genfb_grfbus_softc * const sc = v;
+
+       if (off < 0 || off >= m68k_page_offset(sc->sc_paddr) +
+           sc->sc_gen.sc_fbsize)
+               return -1;
+
+       return m68k_btop(m68k_trunc_page(sc->sc_paddr) + off);
+}
+
+static int
+genfb_grfbus_attach_genfb(struct genfb_grfbus_softc *sc)
+{
+       device_t dev = sc->sc_gen.sc_dev;
+       prop_dictionary_t dict = device_properties(dev);



Home | Main Index | Thread Index | Old Index