Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/dev PR/32552: Antonio Bravo: cgfourteen 24-bi...



details:   https://anonhg.NetBSD.org/src/rev/45dc6157a80e
branches:  trunk
changeset: 587258:45dc6157a80e
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jan 17 04:22:08 2006 +0000

description:
PR/32552: Antonio Bravo: cgfourteen 24-bit support
Original code from der Mouse, posted to the mailing lists by Jakob Menzi.

diffstat:

 sys/arch/sparc/dev/cgfourteen.c    |  492 +++++++++++++-----------------------
 sys/arch/sparc/dev/cgfourteenreg.h |    2 +-
 sys/arch/sparc/dev/cgfourteenvar.h |   25 +-
 3 files changed, 190 insertions(+), 329 deletions(-)

diffs (truncated from 816 to 300 lines):

diff -r 45cec9f29696 -r 45dc6157a80e sys/arch/sparc/dev/cgfourteen.c
--- a/sys/arch/sparc/dev/cgfourteen.c   Tue Jan 17 03:32:10 2006 +0000
+++ b/sys/arch/sparc/dev/cgfourteen.c   Tue Jan 17 04:22:08 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cgfourteen.c,v 1.41 2005/12/11 12:19:05 christos Exp $ */
+/*     $NetBSD: cgfourteen.c,v 1.42 2006/01/17 04:22:08 christos Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -66,19 +66,14 @@
  * enabled by allowing any user to map the control registers for the
  * cg14 into their space.
  */
-#undef CG14_MAP_REGS
+#define CG14_MAP_REGS
 
 /*
  * The following enables 24-bit operation: when opened, the framebuffer
  * will switch to 24-bit mode (actually 32-bit mode), and provide a
  * simple cg8 emulation.
- *
- * XXX Note that the code enabled by this define is currently untested/broken.
  */
-#undef CG14_CG8
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgfourteen.c,v 1.41 2005/12/11 12:19:05 christos Exp $");
+#define CG14_CG8
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -92,14 +87,13 @@
 
 #include <uvm/uvm_extern.h>
 
-#include <machine/bus.h>
+#include <dev/sun/fbio.h>
 #include <machine/autoconf.h>
-
+#include <machine/pmap.h>
+#include <dev/sun/fbvar.h>
+#include <machine/cpu.h>
 #include <dev/sbus/sbusvar.h>
 
-#include <dev/sun/fbio.h>
-#include <dev/sun/fbvar.h>
-
 #include <sparc/dev/cgfourteenreg.h>
 #include <sparc/dev/cgfourteenvar.h>
 
@@ -110,25 +104,28 @@
 
 CFATTACH_DECL(cgfourteen, sizeof(struct cgfourteen_softc),
     cgfourteenmatch, cgfourteenattach, NULL, NULL);
-
+        
 extern struct cfdriver cgfourteen_cd;
 
 dev_type_open(cgfourteenopen);
 dev_type_close(cgfourteenclose);
 dev_type_ioctl(cgfourteenioctl);
 dev_type_mmap(cgfourteenmmap);
+dev_type_poll(cgfourteenpoll);
 
 const struct cdevsw cgfourteen_cdevsw = {
-       cgfourteenopen, cgfourteenclose, noread, nowrite, cgfourteenioctl,
-       nostop, notty, nopoll, cgfourteenmmap, nokqfilter,
+        cgfourteenopen, cgfourteenclose, noread, nowrite, cgfourteenioctl,
+        nostop, notty, cgfourteenpoll, cgfourteenmmap, nokqfilter,
 };
 
 /* frame buffer generic driver */
 static struct fbdriver cgfourteenfbdriver = {
        cgfourteenunblank, cgfourteenopen, cgfourteenclose, cgfourteenioctl,
-       nopoll, cgfourteenmmap, nokqfilter
+       cgfourteenpoll, cgfourteenmmap, nokqfilter
 };
 
+extern struct tty *fbconstty;
+
 static void cg14_set_video(struct cgfourteen_softc *, int);
 static int  cg14_get_video(struct cgfourteen_softc *);
 static int  cg14_get_cmap(struct fbcmap *, union cg14cmap *, int);
@@ -136,24 +133,11 @@
 static void cg14_load_hwcmap(struct cgfourteen_softc *, int, int);
 static void cg14_init(struct cgfourteen_softc *);
 static void cg14_reset(struct cgfourteen_softc *);
-static void cg14_loadomap(struct cgfourteen_softc *);  /* cursor overlay */
-static void cg14_setcursor(struct cgfourteen_softc *); /* set position */
-static void cg14_loadcursor(struct cgfourteen_softc *);        /* set shape */
-
-/*
- * We map the display memory with an offset of 256K when emulating the cg3 or
- * cg8; the cg3 uses this offset for compatibility with the cg4, and both the
- * cg4 and cg8 have a mono overlay plane and an overlay enable plane in the
- * first 256K.  Mapping at an offset of 0x04000000 causes only the color
- * frame buffer to be mapped, without the overlay planes.
- */
-#define START          (128*1024 + 128*1024)
-#define NOOVERLAY      (0x04000000)
 
 /*
  * Match a cgfourteen.
  */
-static int
+int
 cgfourteenmatch(struct device *parent, struct cfdata *cf, void *aux)
 {
        union obio_attach_args *uoba = aux;
@@ -174,9 +158,27 @@
 }
 
 /*
+ * Set COLOUR_OFFSET to the offset of the video RAM.  This is to provide
+ *  space for faked overlay junk for the cg8 emulation.
+ *
+ * As it happens, this value is correct for both cg3 and cg8 emulation!
+ */
+#define COLOUR_OFFSET (256*1024)
+
+static void cg14_set_rcons_luts(struct cgfourteen_softc *sc)
+{
+       int i;
+
+       for (i=0;i<CG14_CLUT_SIZE;i++) sc->sc_xlut->xlut_lut[i] = 0x22;
+       for (i=0;i<CG14_CLUT_SIZE;i++) sc->sc_clut2->clut_lut[i] = 0x00ffffff;
+       sc->sc_clut2->clut_lut[0] = 0x00ffffff;
+       sc->sc_clut2->clut_lut[255] = 0;
+}
+
+/*
  * Attach a display.  We need to notice if it is the console, too.
  */
-static void
+void
 cgfourteenattach(struct device *parent, struct device *self, void *aux)
 {
        union obio_attach_args *uoba = aux;
@@ -204,29 +206,16 @@
 #ifdef CG14_CG8
        fb->fb_type.fb_type = FBTYPE_MEMCOLOR;
        fb->fb_type.fb_depth = 32;
+       fb_setsize_obp(fb, sc->sc_fb.fb_type.fb_depth, 1152, 900, node);
+       ramsize = roundup(fb->fb_type.fb_height * 1152 * 4, NBPG);
 #else
        fb->fb_type.fb_type = FBTYPE_SUN3COLOR;
        fb->fb_type.fb_depth = 8;
-#endif
        fb_setsize_obp(fb, sc->sc_fb.fb_type.fb_depth, 1152, 900, node);
-#ifdef CG14_CG8
-       /*
-        * fb_setsize_obp set fb->fb_linebytes based on the current
-        * depth reported by obp, but that defaults to 8 bits (as
-        * reported by getpropint().  Update the value to reflect
-        * the depth that will be used after open.
-        * The display memory size returned by the cg8 driver includes
-        * the space used by the overlay planes, but the size returned
-        * by the cg3 driver does not; emulate the other drivers.
-        */
-       fb->fb_linebytes = (fb->fb_type.fb_width * fb->fb_type.fb_depth) / 8;
-       ramsize = roundup(START + (fb->fb_type.fb_height * fb->fb_linebytes),
-                       PAGE_SIZE);
-#else
-       ramsize = roundup(fb->fb_type.fb_height * fb->fb_linebytes, PAGE_SIZE);
+       ramsize = roundup(fb->fb_type.fb_height * fb->fb_linebytes, NBPG);
 #endif
        fb->fb_type.fb_cmsize = CG14_CLUT_SIZE;
-       fb->fb_type.fb_size = ramsize;
+       fb->fb_type.fb_size = ramsize + COLOUR_OFFSET;
 
        if (sa->sa_nreg < 2) {
                printf("%s: only %d register sets\n",
@@ -234,7 +223,7 @@
                return;
        }
        bcopy(sa->sa_reg, sc->sc_physadr,
-             sa->sa_nreg * sizeof(struct openprom_addr));
+             sa->sa_nreg * sizeof(struct sbus_reg));
 
        /*
         * Now map in the 8 useful pages of registers
@@ -245,9 +234,11 @@
 #endif
                sa->sa_size = 0x10000;
        }
-       if (sbus_bus_map(sa->sa_bustag,
-                        sa->sa_slot, sa->sa_offset, sa->sa_size,
-                        BUS_SPACE_MAP_LINEAR, &bh) != 0) {
+       if (sbus_bus_map(sa->sa_bustag, sa->sa_slot,
+                        sa->sa_offset,
+                        sa->sa_size,
+                        BUS_SPACE_MAP_LINEAR,
+                        &bh) != 0) {
                printf("%s: cannot map control registers\n", self->dv_xname);
                return;
        }
@@ -272,7 +263,7 @@
                fb->fb_type.fb_width, fb->fb_type.fb_height);
 #endif
        /*
-        * Enable the video, but don't change the pixel depth.
+        * Enable the video.
         */
        cg14_set_video(sc, 1);
 
@@ -284,19 +275,32 @@
                sc->sc_cmap.cm_chip[i] = lut[i];
 
        /* See if we're the console */
-       isconsole = fb_is_console(node);
+        isconsole = fb_is_console(node);
 
        if (isconsole) {
                printf(" (console)\n");
-#ifdef notdef
-               /*
-                * We don't use the raster console since the cg14 is
-                * fast enough already.
-                */
 #ifdef RASTERCONSOLE
-               fbrcons_init(fb);
+               /* *sbus*_bus_map?  but that's how we map the regs... */
+               if (sbus_bus_map( sc->sc_bustag,
+                                 sc->sc_physadr[CG14_PXL_IDX].sbr_slot,
+                                 sc->sc_physadr[CG14_PXL_IDX].sbr_offset+0x03800000,
+                                 1152*900, BUS_SPACE_MAP_LINEAR,
+                                 &bh) != 0) {
+                       printf("%s: cannot map pixels\n",&sc->sc_dev.dv_xname[0]);
+               } else {
+                       sc->sc_rcfb = sc->sc_fb;
+                       sc->sc_rcfb.fb_type.fb_type = FBTYPE_SUN3COLOR;
+                       sc->sc_rcfb.fb_type.fb_depth = 8;
+                       sc->sc_rcfb.fb_linebytes = 1152;
+                       sc->sc_rcfb.fb_type.fb_size = roundup(1152*900,NBPG);
+                       sc->sc_rcfb.fb_pixels = (void *)bh;
+                       printf("vram at %p\n",(void *)bh);
+                       for (i=0;i<1152*900;i++) ((unsigned char *)bh)[i] = 0;
+                       fbrcons_init(&sc->sc_rcfb);
+                       cg14_set_rcons_luts(sc);
+                       sc->sc_ctl->ctl_mctl = CG14_MCTL_ENABLEVID | CG14_MCTL_PIXMODE_32 | CG14_MCTL_POWERCTL;
+               }
 #endif
-#endif /* notdef */
        } else
                printf("\n");
 
@@ -315,14 +319,16 @@
 int
 cgfourteenopen(dev_t dev, int flags, int mode, struct lwp *l)
 {
-       struct cgfourteen_softc *sc = cgfourteen_cd.cd_devs[minor(dev)];
-       int unit = minor(dev);
+       struct cgfourteen_softc *sc;
+       int unit;
        int s, oldopens;
 
-       if (unit >= cgfourteen_cd.cd_ndevs ||
-           cgfourteen_cd.cd_devs[unit] == NULL)
-               return (ENXIO);
-
+       unit = minor(dev);
+       if (unit >= cgfourteen_cd.cd_ndevs)
+               return(ENXIO);
+       sc = cgfourteen_cd.cd_devs[minor(dev)];
+       if (sc == NULL)
+               return(ENXIO);
        s = splhigh();
        oldopens = cg14_opens++;
        splx(s);
@@ -360,10 +366,7 @@
 {
        struct cgfourteen_softc *sc = cgfourteen_cd.cd_devs[minor(dev)];
        struct fbgattr *fba;
-       union cg14cursor_cmap tcm;
-       int v, error;
-       u_int count;
-       u_int eplane[32], cplane[32];
+       int error;
 
        switch (cmd) {
 
@@ -384,7 +387,7 @@
                break;
 
        case FBIOGETCMAP:
-               return (cg14_get_cmap((struct fbcmap *)data, &sc->sc_cmap,
+               return(cg14_get_cmap((struct fbcmap *)data, &sc->sc_cmap,
                                     CG14_CLUT_SIZE));
 
        case FBIOPUTCMAP:
@@ -410,112 +413,6 @@
                cg14_set_video(sc, *(int *)data);
                break;
 
-/* these are for both FBIOSCURSOR and FBIOGCURSOR */
-#define p ((struct fbcursor *)data)
-#define cc (&sc->sc_cursor)
-       case FBIOGCURSOR:
-               /* do not quite want everything here... */
-               p->set = FB_CUR_SETALL; /* close enough, anyway */



Home | Main Index | Thread Index | Old Index