Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Xorg for amiga via wsfb. Currently available on CV6...



details:   https://anonhg.NetBSD.org/src/rev/ff8c6fa77d5d
branches:  trunk
changeset: 811717:ff8c6fa77d5d
user:      phx <phx%NetBSD.org@localhost>
date:      Thu Nov 12 12:01:53 2015 +0000

description:
Xorg for amiga via wsfb. Currently available on CV64 and CV64/3D. More
graphics cards will follow, when adding wscons support to them.

I didn't manage to make the "wskbd" protocol the default in the X server,
so you have to provide a small xorg.conf with Option "Protocol" "wskbd".
The standard protocol will not work as the Amiga wskbd cannot be switched
into raw mode and has no AT-scancode translation in the kernel.

On the positive side, wskbd also works with national keymaps under X.

The graphics modes can still be defined via grfconfig(8). Xorg's wsfb
driver uses the current grf video mode, which is usually mode #1.
All resolutions and depths seem to work (tested on CV64).

diffstat:

 sys/arch/amiga/amiga/bus.c        |   9 +--
 sys/arch/amiga/dev/grf.c          |  39 ++++++---------
 sys/arch/amiga/dev/grf_cv.c       |  95 ++++++++++++++++++++++++++++++++++++--
 sys/arch/amiga/dev/grf_cv3d.c     |  95 ++++++++++++++++++++++++++++++++++++--
 sys/arch/amiga/include/param.h    |   5 +-
 sys/arch/amigappc/include/param.h |   5 +-
 6 files changed, 204 insertions(+), 44 deletions(-)

diffs (truncated from 429 to 300 lines):

diff -r affddb9d5015 -r ff8c6fa77d5d sys/arch/amiga/amiga/bus.c
--- a/sys/arch/amiga/amiga/bus.c        Thu Nov 12 11:35:42 2015 +0000
+++ b/sys/arch/amiga/amiga/bus.c        Thu Nov 12 12:01:53 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.c,v 1.1 2011/08/04 17:48:50 rkujawa Exp $ */
+/*     $NetBSD: bus.c,v 1.2 2015/11/12 12:01:53 phx Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -48,11 +48,7 @@
 bus_space_mmap(bus_space_tag_t t, bus_addr_t addr, off_t off, int prot,
        int flags)
 {
-#if defined(__m68k__)
-       return m68k_btop(addr + off);
-#else
-       return -1; /* FIXME */
-#endif
+       return MD_BTOP(addr + off);
 }
 
 void *
@@ -63,4 +59,3 @@
 
        return va;
 }
-
diff -r affddb9d5015 -r ff8c6fa77d5d sys/arch/amiga/dev/grf.c
--- a/sys/arch/amiga/dev/grf.c  Thu Nov 12 11:35:42 2015 +0000
+++ b/sys/arch/amiga/dev/grf.c  Thu Nov 12 12:01:53 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: grf.c,v 1.63 2015/11/07 14:29:10 phx Exp $ */
+/*     $NetBSD: grf.c,v 1.64 2015/11/12 12:01:53 phx Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: grf.c,v 1.63 2015/11/07 14:29:10 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf.c,v 1.64 2015/11/12 12:01:53 phx Exp $");
 
 /*
  * Graphics display driver for the Amiga
@@ -140,7 +140,6 @@
 static void grf_init_screen(void *, struct vcons_screen *, int, long *);
 static struct rasops_info *grf_setup_rasops(struct grf_softc *,
     struct vcons_screen *);
-static paddr_t grf_wsmmap_md(off_t off);
 
 cons_decl(grf);
 #endif
@@ -369,14 +368,14 @@
         * control registers
         */
        if (off >= 0 && off < gi->gd_regsize)
-               return(((paddr_t)gi->gd_regaddr + off) >> PGSHIFT);
+               return MD_BTOP((paddr_t)gi->gd_regaddr + off);
 
        /*
         * frame buffer
         */
        if (off >= gi->gd_regsize && off < gi->gd_regsize+gi->gd_fbsize) {
                off -= gi->gd_regsize;
-               return(((paddr_t)gi->gd_fbaddr + off) >> PGSHIFT);
+               return MD_BTOP((paddr_t)gi->gd_fbaddr + off);
        }
        /* bogus */
        return(-1);
@@ -613,8 +612,12 @@
 
        /* Normal fb mapping */
        if (off < gi->gd_fbsize)
-               return grf_wsmmap_md(((bus_addr_t)gp->g_fbkva) + off);
+               return MD_BTOP(((paddr_t)gi->gd_fbaddr) + off);
 
+       /*
+        * restrict all other mappings to processes with superuser privileges
+        * or the kernel itself
+        */
        if (kauth_authorize_machdep(kauth_cred_get(), KAUTH_MACHDEP_UNMANAGEDMEM,
            NULL, NULL, NULL, NULL) != 0) {
                aprint_normal("%s: permission to mmap denied.\n",
@@ -622,28 +625,18 @@
                return -1;
        }
 
-       if ((off >= (bus_addr_t)gp->g_fbkva ) &&
-           (off < ( (bus_addr_t)gp->g_fbkva + (size_t)gi->gd_fbsize)))
-               return grf_wsmmap_md(off);
+       /* Handle register mapping */
+       if ((off >= (paddr_t)gi->gd_regaddr) &&
+           (off < ((paddr_t)gi->gd_regaddr + (size_t)gi->gd_regsize)))
+               return MD_BTOP(off);
 
-       /* Handle register mapping */
-       if ((off >= (bus_addr_t)gi->gd_regaddr) &&
-           (off < ((bus_addr_t)gi->gd_regaddr + (size_t)gi->gd_regsize)))
-               return grf_wsmmap_md(off);
+       if ((off >= (paddr_t)gi->gd_fbaddr) &&
+           (off < ((paddr_t)gi->gd_fbaddr + (size_t)gi->gd_fbsize)))
+               return MD_BTOP(off);
 
        return -1;
 }
 
-static paddr_t
-grf_wsmmap_md(off_t off) 
-{
-#if defined(__m68k__)
-       return (paddr_t) m68k_btop(off);
-#else
-       return -1; /* FIXME */
-#endif
-}
-
 #endif  /* NWSDISPLAY > 0 */
 
 #endif /* NGRF > 0 */
diff -r affddb9d5015 -r ff8c6fa77d5d sys/arch/amiga/dev/grf_cv.c
--- a/sys/arch/amiga/dev/grf_cv.c       Thu Nov 12 11:35:42 2015 +0000
+++ b/sys/arch/amiga/dev/grf_cv.c       Thu Nov 12 12:01:53 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: grf_cv.c,v 1.57 2015/11/07 14:29:10 phx Exp $ */
+/*     $NetBSD: grf_cv.c,v 1.58 2015/11/12 12:01:53 phx Exp $ */
 
 /*
  * Copyright (c) 1995 Michael Teske
@@ -33,7 +33,7 @@
 #include "opt_amigacons.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: grf_cv.c,v 1.57 2015/11/07 14:29:10 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf_cv.c,v 1.58 2015/11/12 12:01:53 phx Exp $");
 
 #include "grfcv.h"
 #include "ite.h"
@@ -271,6 +271,7 @@
 #if NWSDISPLAY > 0
 /* wsdisplay acessops, emulops */
 static int     cv_wsioctl(void *, void *, u_long, void *, int, struct lwp *);
+static int     cv_get_fbinfo(struct grf_softc *, struct wsdisplayio_fbinfo *);
 
 static void    cv_wscursor(void *, int, int, int);
 static void    cv_wsputchar(void *, int, int, u_int, long);
@@ -440,7 +441,7 @@
 }
 
 int
-grfcvmatch(device_t paren, cfdata_t cf, void *aux)
+grfcvmatch(device_t parent, cfdata_t cf, void *aux)
 {
 #ifdef CV64CONSOLE
        static int cvcons_unit = -1;
@@ -2485,12 +2486,94 @@
 
        case WSDISPLAYIO_SVIDEO:
                return cv_blank(gp, *(u_int *)data == WSDISPLAYIO_VIDEO_OFF);
+
+       case WSDISPLAYIO_SMODE:
+               if ((*(int *)data) != gp->g_wsmode) {
+                       if (*(int *)data == WSDISPLAYIO_MODE_EMUL) {
+                               /* load console text mode, redraw screen */
+                               (void)cv_load_mon(gp, &cvconsole_mode);
+                               if (vd->active != NULL)
+                                       vcons_redraw_screen(vd->active);
+                       } else {
+                               /* switch to current graphics mode */
+                               if (!cv_load_mon(gp,
+                                   (struct grfcvtext_mode *)monitor_current))
+                                       return EINVAL;
+                       }
+                       gp->g_wsmode = *(int *)data;
+               } 
+               return 0;
+
+       case WSDISPLAYIO_GET_FBINFO:
+               return cv_get_fbinfo(gp, data);
        }
 
        /* handle this command hw-independant in grf(4) */
        return grf_wsioctl(v, vs, cmd, data, flag, l);
 }
 
-#endif  /* NWSDISPLAY > 0 */
-
-#endif  /* NGRFCV */
+/*
+ * Fill the wsdisplayio_fbinfo structure with information from the current
+ * graphics mode. Even when text mode is active.
+ */
+static int
+cv_get_fbinfo(struct grf_softc *gp, struct wsdisplayio_fbinfo *fbi)
+{
+       struct grfvideo_mode *md;
+       uint32_t rbits, gbits, bbits, abits;
+
+       md = monitor_current;
+       abits = 0;
+
+       fbi->fbi_width = md->disp_width;
+       fbi->fbi_height = md->disp_height;
+       fbi->fbi_bitsperpixel = md->depth;
+
+       switch (md->depth) {
+       case 8:
+               fbi->fbi_stride = md->disp_width;
+               rbits = gbits = bbits = 6;  /* keep gcc happy */
+               break;
+       case 15:
+               fbi->fbi_stride = md->disp_width * 2;
+               rbits = gbits = bbits = 5;
+               break;
+       case 16:
+               fbi->fbi_stride = md->disp_width * 2;
+               rbits = bbits = 5;
+               gbits = 6;
+               break;
+       case 32:
+               abits = 8;
+       case 24:
+               fbi->fbi_stride = md->disp_width * 4;
+               rbits = gbits = bbits = 8;
+               break;
+       default:
+               return EINVAL;
+       }
+
+       if (md->depth > 8) {
+               fbi->fbi_pixeltype = WSFB_RGB;
+               fbi->fbi_subtype.fbi_rgbmasks.red_offset = bbits + gbits;
+               fbi->fbi_subtype.fbi_rgbmasks.red_size = rbits;
+               fbi->fbi_subtype.fbi_rgbmasks.green_offset = bbits;
+               fbi->fbi_subtype.fbi_rgbmasks.green_size = gbits;
+               fbi->fbi_subtype.fbi_rgbmasks.blue_offset = 0;
+               fbi->fbi_subtype.fbi_rgbmasks.blue_size = bbits;
+               fbi->fbi_subtype.fbi_rgbmasks.alpha_offset =
+                   bbits + gbits + rbits;
+               fbi->fbi_subtype.fbi_rgbmasks.alpha_size = abits;
+       } else {
+               fbi->fbi_pixeltype = WSFB_CI;
+               fbi->fbi_subtype.fbi_cmapinfo.cmap_entries = 1 << md->depth;
+       }
+
+       fbi->fbi_flags = 0;
+       fbi->fbi_fbsize = fbi->fbi_stride * fbi->fbi_height;
+       fbi->fbi_fboffset = 0;
+       return 0;
+}
+#endif /* NWSDISPLAY > 0 */
+
+#endif /* NGRFCV */
diff -r affddb9d5015 -r ff8c6fa77d5d sys/arch/amiga/dev/grf_cv3d.c
--- a/sys/arch/amiga/dev/grf_cv3d.c     Thu Nov 12 11:35:42 2015 +0000
+++ b/sys/arch/amiga/dev/grf_cv3d.c     Thu Nov 12 12:01:53 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: grf_cv3d.c,v 1.31 2015/11/07 14:29:10 phx Exp $ */
+/*     $NetBSD: grf_cv3d.c,v 1.32 2015/11/12 12:01:53 phx Exp $ */
 
 /*
  * Copyright (c) 1995 Michael Teske
@@ -33,7 +33,7 @@
 #include "opt_amigacons.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: grf_cv3d.c,v 1.31 2015/11/07 14:29:10 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf_cv3d.c,v 1.32 2015/11/12 12:01:53 phx Exp $");
 
 #include "ite.h"
 #include "wsdisplay.h"
@@ -46,7 +46,7 @@
  * Modified for CV64/3D from Michael Teske's CV driver by Tobias Abt 10/97.
  * Bugfixes by Bernd Ernesti 10/97.
  * Many thanks to Richard Hartmann who gave us his board so we could make
- * driver.
+ * the driver.
  *
  * TODO:
  *     - ZorroII support
@@ -73,7 +73,7 @@
         +0xc0e0000      PCI Cfg Base start
         +0xc0e0fff      PCI Cfg Base end
 
-Note: IO Regbase is needed fo wakeup of the board otherwise use
+Note: IO Regbase is needed for wakeup of the board otherwise use
       MMIO Regbase
 */
 
@@ -291,6 +291,7 @@
 #if NWSDISPLAY > 0 
 /* wsdisplay accessops, emulops */
 static int     cv3d_wsioctl(void *, void *, u_long, void *, int, struct lwp *);
+static int     cv3d_get_fbinfo(struct grf_softc *, struct wsdisplayio_fbinfo *);
 
 static void    cv3d_wscursor(void *, int, int, int);
 static void    cv3d_wsputchar(void *, int, int, u_int, long);
@@ -2340,12 +2341,94 @@
 
        case WSDISPLAYIO_SVIDEO:



Home | Main Index | Thread Index | Old Index