Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/sbus - some cosmetic fixes



details:   https://anonhg.NetBSD.org/src/rev/cbf0cb62e28c
branches:  trunk
changeset: 746737:cbf0cb62e28c
user:      macallan <macallan%NetBSD.org@localhost>
date:      Wed Aug 19 03:35:32 2009 +0000

description:
- some cosmetic fixes
- add support for screen blanking via /dev/fb*
- reimplement colour map ioctl()s for /dev/fb*
- implement mmap and ioctl for wscons, map 8 or 24bit framebuffer depending
  on hardware
With this X works with the wsfb driver in 24bit.
TODO:
- fix wsfb to use the right pixel format for S24
- implement wsdisplay colour map ioctl()s
- add hardware cursor support for wscons and /dev/fb*

diffstat:

 sys/dev/sbus/tcx.c |  239 ++++++++++++++++++----------------------------------
 1 files changed, 82 insertions(+), 157 deletions(-)

diffs (truncated from 419 to 300 lines):

diff -r 484ac071dc09 -r cbf0cb62e28c sys/dev/sbus/tcx.c
--- a/sys/dev/sbus/tcx.c        Wed Aug 19 01:38:39 2009 +0000
+++ b/sys/dev/sbus/tcx.c        Wed Aug 19 03:35:32 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcx.c,v 1.33 2009/08/18 20:45:42 macallan Exp $ */
+/*     $NetBSD: tcx.c,v 1.34 2009/08/19 03:35:32 macallan Exp $ */
 
 /*
  *  Copyright (c) 1996,1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.33 2009/08/18 20:45:42 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.34 2009/08/19 03:35:32 macallan Exp $");
 
 /*
  * define for cg8 emulation on S24 (24-bit version of tcx) for the SS5;
@@ -87,7 +87,7 @@
        struct sbusdev  sc_sd;          /* sbus device */
        struct fbdevice sc_fb;          /* frame buffer device */
        bus_space_tag_t sc_bustag;
-       struct openprom_addr sc_physadr[TCX_NREG];/* phys addr of h/w */
+       struct openprom_addr sc_physaddr[TCX_NREG];/* phys addr of h/w */
 
        bus_space_handle_t sc_bt;       /* Brooktree registers */
        bus_space_handle_t sc_thc;      /* THC registers */
@@ -251,11 +251,11 @@
        fb_setsize_obp(fb, fb->fb_type.fb_depth, 1152, 900, node);
 
        if (sc->sc_8bit) {
-               printf(" {8bit only TCX)");
+               printf(" (8bit only TCX)");
                ramsize = 1024 * 1024;
                /* XXX - fix THC and TEC offsets */
-               sc->sc_physadr[TCX_REG_TEC].oa_base += 0x1000;
-               sc->sc_physadr[TCX_REG_THC].oa_base += 0x1000;
+               sc->sc_physaddr[TCX_REG_TEC].oa_base += 0x1000;
+               sc->sc_physaddr[TCX_REG_THC].oa_base += 0x1000;
        } else {
                printf(" (S24)\n");
                ramsize = 4 * 1024 * 1024;
@@ -275,13 +275,13 @@
                        device_xname(self), sa->sa_nreg);
                return;
        }
-       memcpy(sc->sc_physadr, sa->sa_reg,
+       memcpy(sc->sc_physaddr, sa->sa_reg,
              sa->sa_nreg * sizeof(struct openprom_addr));
 
        /* Map the register banks we care about */
        if (sbus_bus_map(sa->sa_bustag,
-                        sc->sc_physadr[TCX_REG_THC].oa_space,
-                        sc->sc_physadr[TCX_REG_THC].oa_base,
+                        sc->sc_physaddr[TCX_REG_THC].oa_space,
+                        sc->sc_physaddr[TCX_REG_THC].oa_base,
                         0x1000,
                         BUS_SPACE_MAP_LINEAR, &sc->sc_thc) != 0) {
                printf("tcxattach: cannot map thc registers\n");
@@ -289,8 +289,8 @@
        }
 
        if (sbus_bus_map(sa->sa_bustag,
-                        sc->sc_physadr[TCX_REG_CMAP].oa_space,
-                        sc->sc_physadr[TCX_REG_CMAP].oa_base,
+                        sc->sc_physaddr[TCX_REG_CMAP].oa_space,
+                        sc->sc_physaddr[TCX_REG_CMAP].oa_base,
                         0x1000,
                         BUS_SPACE_MAP_LINEAR, &sc->sc_bt) != 0) {
                printf("tcxattach: cannot map bt registers\n");
@@ -299,8 +299,8 @@
 
        /* map the 8bit dumb FB for the console */
        if (sbus_bus_map(sa->sa_bustag,
-                sc->sc_physadr[TCX_REG_DFB8].oa_space,
-                sc->sc_physadr[TCX_REG_DFB8].oa_base,
+                sc->sc_physaddr[TCX_REG_DFB8].oa_space,
+                sc->sc_physaddr[TCX_REG_DFB8].oa_base,
                         1024 * 1024,
                         BUS_SPACE_MAP_LINEAR,
                         &bh) != 0) {
@@ -311,8 +311,8 @@
 
        /* RBLIT space */
        if (sbus_bus_map(sa->sa_bustag,
-                sc->sc_physadr[TCX_REG_RBLIT].oa_space,
-                sc->sc_physadr[TCX_REG_RBLIT].oa_base,
+                sc->sc_physaddr[TCX_REG_RBLIT].oa_space,
+                sc->sc_physaddr[TCX_REG_RBLIT].oa_base,
                         8 * 1024 * 1024,
                         BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE,
                         &bh) != 0) {
@@ -323,8 +323,8 @@
 
        /* RSTIP space */
        if (sbus_bus_map(sa->sa_bustag,
-                sc->sc_physadr[TCX_REG_RSTIP].oa_space,
-                sc->sc_physadr[TCX_REG_RSTIP].oa_base,
+                sc->sc_physaddr[TCX_REG_RSTIP].oa_space,
+                sc->sc_physaddr[TCX_REG_RSTIP].oa_base,
                         8 * 1024 * 1024,
                         BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE,
                         &bh) != 0) {
@@ -405,46 +405,9 @@
        tcx_loadcmap(sc, 0, 256);
 }
 
-#ifdef TCX_CG8
-/*
- * keep track of the number of opens, so we can switch to 24-bit mode
- * when the device is first opened, and return to 8-bit mode on the
- * last close.  (stolen from cgfourteen driver...)  There can only be
- * one TCX per system, so we only need one flag.
- */
-static int tcx_opens = 0;
-#endif
-
 int
 tcxopen(dev_t dev, int flags, int mode, struct lwp *l)
 {
-#ifdef TCX_CG8
-       int unit = minor(dev);
-       struct tcx_softc *sc;
-       int i, s, oldopens;
-       volatile ulong *cptr;
-       struct fbdevice *fb;
-
-       sc = device_lookup_private(&tcx_cd, unit);
-       if (!sc)
-               return (ENXIO);
-       if (!sc->sc_8bit) {
-               s = splhigh();
-               oldopens = tcx_opens++;
-               splx(s);
-               if (oldopens == 0) {
-                       /*
-                        * rewrite the control planes to select 24-bit mode
-                        * and clear the screen
-                        */
-                       fb = &sc->sc_fb;
-                       i = fb->fb_type.fb_height * fb->fb_type.fb_width;
-                       cptr = sc->sc_cplane;
-                       while (--i >= 0)
-                               *cptr++ = TCX_CTL_24_LEVEL;
-               }
-       }
-#endif
        return (0);
 }
 
@@ -452,34 +415,9 @@
 tcxclose(dev_t dev, int flags, int mode, struct lwp *l)
 {
        struct tcx_softc *sc = device_lookup_private(&tcx_cd, minor(dev));
-#ifdef TCX_CG8
-       int i, s, opens;
-       volatile ulong *cptr;
-       struct fbdevice *fb;
-#endif
 
        tcx_reset(sc);
-#ifdef TCX_CG8
-       if (!sc->sc_8bit) {
-               s = splhigh();
-               opens = --tcx_opens;
-               if (tcx_opens <= 0)
-                       opens = tcx_opens = 0;
-               splx(s);
-               if (opens == 0) {
-                       /*
-                        * rewrite the control planes to select 8-bit mode,
-                        * preserving the contents of the screen.
-                        * (or we could just bzero the whole thing...)
-                        */
-                       fb = &sc->sc_fb;
-                       i = fb->fb_type.fb_height * fb->fb_type.fb_width;
-                       cptr = sc->sc_cplane;
-                       while (--i >= 0)
-                               *cptr++ &= TCX_CTL_PIXELMASK;
-               }
-       }
-#endif
+       /* we may want to clear and redraw the console here */
        return (0);
 }
 
@@ -508,31 +446,31 @@
                fba->emu_types[2] = -1;
 #undef fba
                break;
-#if 0
+
        case FBIOGETCMAP:
 #define        p ((struct fbcmap *)data)
-               return (bt_getcmap(p, &sc->sc_cmap, 256, 1));
+               if (copyout(&sc->sc_cmap_red[p->index], p->red, p->count) != 0)
+                       return EINVAL;
+               if (copyout(&sc->sc_cmap_green[p->index], p->green, p->count)
+                   != 0)
+                       return EINVAL;
+               if (copyout(&sc->sc_cmap_blue[p->index], p->blue, p->count)
+                   != 0)
+                       return EINVAL;
+               return 0;
 
        case FBIOPUTCMAP:
                /* copy to software map */
-#ifdef TCX_CG8
-               if (!sc->sc_8bit) {
-                       /*
-                        * cg8 has extra bits in high-order byte of the index
-                        * that bt_putcmap doesn't recognize
-                        */
-                       p->index &= 0xffffff;
-               }
-#endif
-               error = bt_putcmap(p, &sc->sc_cmap, 256, 1);
-               if (error)
-                       return (error);
-               /* now blast them into the chip */
-               /* XXX should use retrace interrupt */
+               if (copyin(p->red, &sc->sc_cmap_red[p->index], p->count) != 0)
+                       return EINVAL;
+               if (copyin(p->green, &sc->sc_cmap_green[p->index], p->count)
+                   != 0)
+                       return EINVAL;
+               if (copyin(p->blue, &sc->sc_cmap_blue[p->index], p->count) != 0)
+                       return EINVAL;
                tcx_loadcmap(sc, p->index, p->count);
 #undef p
                break;
-#endif
        case FBIOGVIDEO:
                *(int *)data = sc->sc_blanked;
                break;
@@ -541,11 +479,16 @@
                if (*(int *)data)
                        tcx_unblank(sc->sc_dev);
                else if (!sc->sc_blanked) {
+                       uint32_t reg;
                        sc->sc_blanked = 1;
-                       //sc->sc_thc->thc_hcmisc &= ~THC_MISC_VIDEN;
+                       reg = bus_space_read_4(sc->sc_bustag, sc->sc_thc,
+                           THC_MISC);
+                       reg &= ~THC_MISC_VIDEN;
                        /* Put monitor in `power-saving mode' */
-                       //sc->sc_thc->thc_hcmisc |= THC_MISC_VSYNC_DISABLE;
-                       //sc->sc_thc->thc_hcmisc |= THC_MISC_HSYNC_DISABLE;
+                       reg |= THC_MISC_VSYNC_DISABLE;
+                       reg |= THC_MISC_HSYNC_DISABLE;
+                       bus_space_write_4(sc->sc_bustag, sc->sc_thc, THC_MISC,
+                           reg);
                }
                break;
 
@@ -566,10 +509,10 @@
 tcx_reset(struct tcx_softc *sc)
 {
 
-       /* Enable cursor in Brooktree DAC. */
-       /* TODO: bus_spacify */
-//     bt->bt_addr = 0x06 << 24;
-//     bt->bt_ctrl |= 0x03 << 24;
+       /* Disable cursor in Brooktree DAC. */
+       bus_space_write_4(sc->sc_bustag, sc->sc_bt, DAC_ADDRESS,
+           DAC_C1_CONTROL_0);
+       bus_space_write_4(sc->sc_bustag, sc->sc_bt, DAC_CONTROL_1, 0);
 }
 
 /*
@@ -599,11 +542,13 @@
        struct tcx_softc *sc = device_private(dev);
 
        if (sc->sc_blanked) {
-       
+               uint32_t reg;
                sc->sc_blanked = 0;
-               //sc->sc_thc->thc_hcmisc &= ~THC_MISC_VSYNC_DISABLE;
-               //sc->sc_thc->thc_hcmisc &= ~THC_MISC_HSYNC_DISABLE;
-               //sc->sc_thc->thc_hcmisc |= THC_MISC_VIDEN;
+               reg = bus_space_read_4(sc->sc_bustag, sc->sc_thc, THC_MISC);
+               reg &= ~THC_MISC_VSYNC_DISABLE;
+               reg &= ~THC_MISC_HSYNC_DISABLE;
+               reg |= THC_MISC_VIDEN;
+               bus_space_write_4(sc->sc_bustag, sc->sc_thc, THC_MISC, reg);
        }
 }
 
@@ -643,7 +588,7 @@
 tcxmmap(dev_t dev, off_t off, int prot)
 {
        struct tcx_softc *sc = device_lookup_private(&tcx_cd, minor(dev));
-       struct openprom_addr *rr = sc->sc_physadr;
+       struct openprom_addr *rr = sc->sc_physaddr;
        struct mmo *mo, *mo_end;
        u_int u, sz;
        static struct mmo mmo[] = {
@@ -664,20 +609,6 @@
                { TCX_USER_ROM, 65536, TCX_REG_ROM },
        };



Home | Main Index | Thread Index | Old Index