Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/macppc Use dev/rasops instead of dev/rcons.



details:   https://anonhg.NetBSD.org/src/rev/d0a7c8ce1a31
branches:  trunk
changeset: 481925:d0a7c8ce1a31
user:      tsubai <tsubai%NetBSD.org@localhost>
date:      Wed Feb 09 13:08:35 2000 +0000

description:
Use dev/rasops instead of dev/rcons.

diffstat:

 sys/arch/macppc/conf/files.macppc |    6 +-
 sys/arch/macppc/dev/ofb.c         |  230 ++++++++++++++++++++-----------------
 sys/arch/macppc/dev/ofbvar.h      |   11 +-
 3 files changed, 129 insertions(+), 118 deletions(-)

diffs (truncated from 449 to 300 lines):

diff -r 08be8f088c47 -r d0a7c8ce1a31 sys/arch/macppc/conf/files.macppc
--- a/sys/arch/macppc/conf/files.macppc Wed Feb 09 13:07:45 2000 +0000
+++ b/sys/arch/macppc/conf/files.macppc Wed Feb 09 13:08:35 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.macppc,v 1.27 2000/02/03 19:27:44 tsubai Exp $
+#      $NetBSD: files.macppc,v 1.28 2000/02/09 13:08:35 tsubai Exp $
 #
 # macppc-specific configuration info
 
@@ -79,8 +79,10 @@
 include "dev/mii/files.mii"
 
 include "dev/wscons/files.wscons"
+include "dev/wsfont/files.wsfont"
+include "dev/rasops/files.rasops"
 
-device ofb: wsemuldisplaydev, wsrasteremulops
+device ofb: wsemuldisplaydev, rasops8
 attach ofb at pci
 file arch/macppc/dev/ofb.c                     ofb needs-flag
 
diff -r 08be8f088c47 -r d0a7c8ce1a31 sys/arch/macppc/dev/ofb.c
--- a/sys/arch/macppc/dev/ofb.c Wed Feb 09 13:07:45 2000 +0000
+++ b/sys/arch/macppc/dev/ofb.c Wed Feb 09 13:08:35 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofb.c,v 1.10 1999/12/06 19:25:58 drochner Exp $        */
+/*     $NetBSD: ofb.c,v 1.11 2000/02/09 13:08:36 tsubai Exp $  */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -36,14 +36,15 @@
 #include <sys/malloc.h>
 #include <sys/systm.h>
 
+#include <vm/vm.h>
+
 #include <dev/pci/pcidevs.h>
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
-#include <dev/rcons/raster.h>
 #include <dev/wscons/wsconsio.h>
-#include <dev/wscons/wscons_raster.h>
 #include <dev/wscons/wsdisplayvar.h>
+#include <dev/rasops/rasops.h>
 
 #include <machine/bus.h>
 #include <machine/grfioctl.h>
@@ -60,21 +61,10 @@
 
 struct ofb_devconfig ofb_console_dc;
 
-struct wsdisplay_emulops ofb_emulops = {
-       rcons_cursor,                   /* could use hardware cursor; punt */
-       rcons_mapchar,
-       rcons_putchar,
-       rcons_copycols,
-       rcons_erasecols,
-       rcons_copyrows,
-       rcons_eraserows,
-       rcons_alloc_attr
-};
-
 struct wsscreen_descr ofb_stdscreen = {
        "std",
        0, 0,   /* will be filled in -- XXX shouldn't, it's global */
-       &ofb_emulops,
+       0,
        0, 0,
        WSSCREEN_REVERSE
 };
@@ -105,7 +95,11 @@
        0 /* load_font */
 };
 
+static struct wsdisplay_font openfirm6x11;
+
 static void ofb_common_init __P((int, struct ofb_devconfig *));
+static int ofb_getcmap __P((struct ofb_softc *, struct wsdisplay_cmap *));
+static int ofb_putcmap __P((struct ofb_softc *, struct wsdisplay_cmap *));
 
 int
 ofbmatch(parent, match, aux)
@@ -115,9 +109,8 @@
 {
        struct pci_attach_args *pa = aux;
 
-       /* /chaos/control */
        if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE &&
-           PCI_PRODUCT(pa->pa_id) == 3)
+           PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_CONTROL)
                return 1;
 
        if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY)
@@ -155,12 +148,9 @@
                }
                ofb_common_init(node, dc);
 
-               /* Set colormap to black on white. */
-               OF_call_method_1("color!", dc->dc_ih, 4, 0, 0, 0, 0xff);
-               OF_call_method_1("color!", dc->dc_ih, 4, 255, 255, 255, 0);
-               screenbytes = dc->dc_height * dc->dc_linebytes;
+               screenbytes = dc->dc_ri.ri_stride * dc->dc_ri.ri_height;
                for (i = 0; i < screenbytes; i += sizeof(u_int32_t))
-                       *(u_int32_t *)(dc->dc_paddr + i) = 0;
+                       *(u_int32_t *)(dc->dc_paddr + i) = 0xffffffff;
        }
        sc->sc_dc = dc;
 
@@ -172,7 +162,12 @@
        pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
        printf(": %s\n", devinfo);
        printf("%s: %d x %d, %dbpp\n", self->dv_xname,
-           dc->dc_raster.width, dc->dc_raster.height, dc->dc_raster.depth);
+              dc->dc_ri.ri_width, dc->dc_ri.ri_height, dc->dc_ri.ri_depth);
+
+       sc->sc_cmap_red[0] = sc->sc_cmap_green[0] = sc->sc_cmap_blue[0] = 0;
+       sc->sc_cmap_red[15] = sc->sc_cmap_red[255] = 0xff;
+       sc->sc_cmap_green[15] = sc->sc_cmap_green[255] = 0xff;
+       sc->sc_cmap_blue[15] = sc->sc_cmap_blue[255] = 0xff;
 
        a.console = console;
        a.scrdata = &ofb_screenlist;
@@ -187,10 +182,8 @@
        int node;
        struct ofb_devconfig *dc;
 {
-       struct raster *rap;
-       struct rcons *rcp;
-       int i;
-       int addr, width, height, linebytes, depth;
+       struct rasops_info *ri = &dc->dc_ri;
+       int32_t addr, width, height, linebytes, depth;
 
        if (dc->dc_ih == 0) {
                char name[64];
@@ -202,49 +195,59 @@
 
        /* XXX /chaos/control doesn't have "width", "height", ... */
        width = height = -1;
-       if (OF_getprop(node, "width", &width, sizeof(width)) != 4)
+       if (OF_getprop(node, "width", &width, 4) != 4)
                OF_interpret("screen-width", 1, &width);
-       if (OF_getprop(node, "height", &height, sizeof(height)) != 4)
+       if (OF_getprop(node, "height", &height, 4) != 4)
                OF_interpret("screen-height", 1, &height);
-       if (OF_getprop(node, "linebytes", &linebytes, sizeof(linebytes)) != 4)
+       if (OF_getprop(node, "linebytes", &linebytes, 4) != 4)
                linebytes = width;                      /* XXX */
-       if (OF_getprop(node, "depth", &depth, sizeof(depth)) != 4)
+       if (OF_getprop(node, "depth", &depth, 4) != 4)
                depth = 8;                              /* XXX */
-       if (width == -1 || height == -1)
+       if (OF_getprop(node, "address", &addr, 4) != 4)
+               OF_interpret("frame-buffer-adr", 1, &addr);
+
+       if (width == -1 || height == -1 || addr == 0 || addr == -1)
                return;
 
-       OF_interpret("frame-buffer-adr", 1, &addr);
-       if (addr == 0 || addr == -1)
-               return;
-       dc->dc_paddr = addr;    /* PA of the frame buffer */
+       dc->dc_paddr = addr;            /* PA of the frame buffer */
+
+       /* change 0xff/0xff/0xff to white */
+       OF_call_method_1("color!", dc->dc_ih, 4, 255, 255, 255, 255);
 
-       /* initialize the raster */
-       rap = &dc->dc_raster;
-       rap->width = width;
-       rap->height = height;
-       rap->depth = depth;
-       rap->linelongs = linebytes / sizeof(u_int32_t);
-       rap->pixels = (u_int32_t *)addr;
-
-       /* initialize the raster console blitter */
-       rcp = &dc->dc_rcons;
-       rcp->rc_sp = rap;
-       rcp->rc_crow = rcp->rc_ccol = -1;
-       rcp->rc_crowp = &rcp->rc_crow;
-       rcp->rc_ccolp = &rcp->rc_ccol;
-       rcons_init(rcp, 128, 128);
+       /* initialize rasops */
+       ri->ri_width = width;
+       ri->ri_height = height;
+       ri->ri_depth = depth;
+       ri->ri_stride = linebytes;
+       ri->ri_bits = (char *)addr;
+       ri->ri_flg = RI_FORCEMONO | RI_FULLCLEAR | RI_CENTER;
 
        /* If screen is smaller than 1024x768, use small font. */
        if ((width < 1024 || height < 768) && copy_rom_font() == 0) {
-               rcp->rc_xorigin = 2;
-               rcp->rc_yorigin = 4;
+               int cols, rows;
+
+               OF_interpret("#lines", 1, &rows);
+               OF_interpret("#columns", 1, &cols);
+
+               ri->ri_font = &openfirm6x11;
+               ri->ri_wsfcookie = -1;          /* not using wsfont */
+               rasops_init(ri, rows, cols);
 
-               OF_interpret("#lines", 1, &dc->dc_rcons.rc_maxrow);
-               OF_interpret("#columns", 1, &dc->dc_rcons.rc_maxcol);
-       }
+               ri->ri_xorigin = 2;
+               ri->ri_yorigin = 3;
+               ri->ri_bits = (char *)addr + ri->ri_xorigin +
+                             ri->ri_stride * ri->ri_yorigin;
+       } else
+               rasops_init(ri, height/22, (width/12) & ~7);    /* XXX 12x22 */
 
-       ofb_stdscreen.nrows = dc->dc_rcons.rc_maxrow;
-       ofb_stdscreen.ncols = dc->dc_rcons.rc_maxcol;
+       /* black on white */
+       ri->ri_devcmap[0] = 0xffffffff;                 /* bg */
+       ri->ri_devcmap[1] = 0;                          /* fg */
+
+       ofb_stdscreen.nrows = ri->ri_rows;
+       ofb_stdscreen.ncols = ri->ri_cols;
+       ofb_stdscreen.textops = &ri->ri_ops;
+       ofb_stdscreen.capabilities = ri->ri_caps;
 }
 
 int
@@ -283,21 +286,24 @@
 
        case WSDISPLAYIO_GINFO:
                wdf = (void *)data;
-               wdf->height = sc->sc_dc->dc_raster.height;
-               wdf->width = sc->sc_dc->dc_raster.width;
-               wdf->depth = sc->sc_dc->dc_raster.depth;
+               wdf->height = dc->dc_ri.ri_height;
+               wdf->width = dc->dc_ri.ri_width;
+               wdf->depth = dc->dc_ri.ri_depth;
                wdf->cmsize = 256;
                return 0;
 
+       case WSDISPLAYIO_GETCMAP:
+               return ofb_getcmap(sc, (struct wsdisplay_cmap *)data);
+
        case WSDISPLAYIO_PUTCMAP:
-               return putcmap(sc, data);
+               return ofb_putcmap(sc, (struct wsdisplay_cmap *)data);
 
        /* XXX There are no way to know framebuffer pa from a user program. */
        case GRFIOCGINFO:
                gm = (void *)data;
                bzero(gm, sizeof(struct grfinfo));
-               gm->gd_fbaddr = (caddr_t)sc->sc_dc->dc_paddr;
-               gm->gd_fbrowbytes = sc->sc_dc->dc_linebytes;
+               gm->gd_fbaddr = (caddr_t)dc->dc_paddr;
+               gm->gd_fbrowbytes = dc->dc_ri.ri_stride;
                return 0;
        }
        return -1;
@@ -311,8 +317,9 @@
 {
        struct ofb_softc *sc = v;
        struct ofb_devconfig *dc = sc->sc_dc;
+       struct rasops_info *ri = &dc->dc_ri;
 
-       if (offset >= (dc->dc_linebytes * dc->dc_height) || offset < 0)
+       if (offset >= (ri->ri_stride * ri->ri_height) || offset < 0)
                return -1;
 
        return dc->dc_paddr + offset;
@@ -327,15 +334,16 @@
        long *attrp;
 {
        struct ofb_softc *sc = v;
+       struct rasops_info *ri = &sc->sc_dc->dc_ri;
        long defattr;
 
        if (sc->nscreens > 0)
                return (ENOMEM);
 
-       *cookiep = &sc->sc_dc->dc_rcons; /* one and only for now */
+       *cookiep = ri;                  /* one and only for now */
        *curxp = 0;
        *curyp = 0;
-       rcons_alloc_attr(&sc->sc_dc->dc_rcons, 0, 0, 0, &defattr);
+       (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr);
        *attrp = defattr;
        sc->nscreens++;
        return 0;
@@ -370,41 +378,34 @@
 ofb_cnattach()
 {
        struct ofb_devconfig *dc = &ofb_console_dc;
+       struct rasops_info *ri = &dc->dc_ri;
        long defattr;
-       int crow = 0, i, screenbytes;
+       int crow = 0;
        int chosen, stdout, node;
-       char cmd[32];
 
        chosen = OF_finddevice("/chosen");



Home | Main Index | Thread Index | Old Index