diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2003-06-18 17:35:31 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2003-06-18 17:35:31 +0000 |
commit | e248e4b35db806a4bf11728158f8100b1dcb7783 (patch) | |
tree | 9dbb54966fa9fa877782adcb6af4859d3885513b /sys/dev/sbus | |
parent | b16e59b21066b91a99919f2765eaca6a1bbda219 (diff) |
Switch to fbxxx() API.
cgsix tested and ok jason@, the rest tested by me.
Diffstat (limited to 'sys/dev/sbus')
-rw-r--r-- | sys/dev/sbus/bwtwo.c | 119 | ||||
-rw-r--r-- | sys/dev/sbus/cgsix.c | 134 | ||||
-rw-r--r-- | sys/dev/sbus/cgsixreg.h | 7 | ||||
-rw-r--r-- | sys/dev/sbus/cgthree.c | 118 |
4 files changed, 106 insertions, 272 deletions
diff --git a/sys/dev/sbus/bwtwo.c b/sys/dev/sbus/bwtwo.c index d19b2b09bcd..cd9fee69d8d 100644 --- a/sys/dev/sbus/bwtwo.c +++ b/sys/dev/sbus/bwtwo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwtwo.c,v 1.8 2003/06/02 18:32:41 jason Exp $ */ +/* $OpenBSD: bwtwo.c,v 1.9 2003/06/18 17:35:30 miod Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -49,38 +49,19 @@ #include <dev/wscons/wsdisplayvar.h> #include <dev/wscons/wscons_raster.h> #include <dev/rasops/rasops.h> +#include <machine/fbvar.h> #define BWTWO_CTRL_OFFSET 0x400000 #define BWTWO_CTRL_SIZE (sizeof(u_int32_t) * 8) #define BWTWO_VID_OFFSET 0x800000 #define BWTWO_VID_SIZE (1024 * 1024) -union bt_cmap { - u_int8_t cm_map[256][3]; /* 256 r/b/g entries */ - u_int32_t cm_chip[256 * 3 / 4]; /* the way the chip is loaded */ -}; - -#define BT_ADDR 0x00 /* map address register */ -#define BT_CMAP 0x04 /* colormap data register */ -#define BT_CTRL 0x08 /* control register */ -#define BT_OMAP 0x0c /* overlay (cursor) map register */ #define FBC_CTRL 0x10 /* control */ #define FBC_STAT 0x11 /* status */ #define FBC_START 0x12 /* cursor start */ #define FBC_END 0x13 /* cursor end */ #define FBC_VCTRL 0x14 /* 12 bytes of timing goo */ -#define BT_WRITE(sc, reg, val) \ - bus_space_write_4((sc)->sc_bustag, (sc)->sc_ctrl_regs, (reg), (val)) -#define BT_READ(sc, reg) \ - bus_space_read_4((sc)->sc_bustag, (sc)->sc_ctrl_regs, (reg)) -#define BT_BARRIER(sc,reg,flags) \ - bus_space_barrier((sc)->sc_bustag, (sc)->sc_ctrl_regs, (reg), \ - sizeof(u_int32_t), (flags)) - -#define BT_D4M3(x) ((((x) >> 2) << 1) + ((x) >> 2)) /* (x / 4) * 3 */ -#define BT_D4M4(x) ((x) & ~3) /* (x / 4) * 4 */ - #define FBC_CTRL_IENAB 0x80 /* interrupt enable */ #define FBC_CTRL_VENAB 0x40 /* video enable */ #define FBC_CTRL_TIME 0x20 /* timing enable */ @@ -115,25 +96,17 @@ union bt_cmap { bus_space_write_1((sc)->sc_bustag, (sc)->sc_ctrl_regs, (reg), (val)) struct bwtwo_softc { - struct device sc_dev; + struct sunfb sc_sunfb; struct sbusdev sc_sd; bus_space_tag_t sc_bustag; bus_addr_t sc_paddr; bus_space_handle_t sc_ctrl_regs; bus_space_handle_t sc_vid_regs; int sc_nscreens; - int sc_width, sc_height, sc_depth, sc_linebytes; - union bt_cmap sc_cmap; - struct rasops_info sc_rasops; - int *sc_crowp, *sc_ccolp; }; struct wsscreen_descr bwtwo_stdscreen = { "std", - 0, 0, /* will be filled in -- XXX shouldn't, it's global. */ - 0, - 0, 0, - WSSCREEN_UNDERLINE | WSSCREEN_REVERSE }; const struct wsscreen_descr *bwtwo_scrlist[] = { @@ -155,7 +128,6 @@ paddr_t bwtwo_mmap(void *, off_t, int); int bwtwo_is_console(int); void bwtwo_burner(void *, u_int, u_int); void bwtwo_updatecursor(struct rasops_info *); -static int a2int(char *, int); struct wsdisplay_accessops bwtwo_accessops = { bwtwo_ioctl, @@ -200,15 +172,11 @@ bwtwoattach(parent, self, aux) struct sbus_attach_args *sa = aux; struct wsemuldisplaydev_attach_args waa; int console; - long defattr; sc->sc_bustag = sa->sa_bustag; sc->sc_paddr = sbus_bus_addr(sa->sa_bustag, sa->sa_slot, sa->sa_offset); - sc->sc_depth = getpropint(sa->sa_node, "depth", 1); - sc->sc_linebytes = getpropint(sa->sa_node, "linebytes", 1152); - sc->sc_height = getpropint(sa->sa_node, "height", 900); - sc->sc_width = getpropint(sa->sa_node, "width", 1152); + fb_setsize(&sc->sc_sunfb, 1, 1152, 900, sa->sa_node, 0); if (sa->sa_nreg != 1) { printf(": expected %d registers, got %d\n", 1, sa->sa_nreg); @@ -228,7 +196,7 @@ bwtwoattach(parent, self, aux) if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot, sa->sa_reg[0].sbr_offset + BWTWO_VID_OFFSET, - sc->sc_linebytes * sc->sc_height, BUS_SPACE_MAP_LINEAR, + sc->sc_sunfb.sf_fbsize, BUS_SPACE_MAP_LINEAR, 0, &sc->sc_vid_regs) != 0) { printf(": cannot map vid registers\n"); goto fail_vid; @@ -236,42 +204,26 @@ bwtwoattach(parent, self, aux) console = bwtwo_is_console(sa->sa_node); - sbus_establish(&sc->sc_sd, &sc->sc_dev); + sbus_establish(&sc->sc_sd, &sc->sc_sunfb.sf_dev); bwtwo_burner(sc, 1, 0); - sc->sc_rasops.ri_depth = sc->sc_depth; - sc->sc_rasops.ri_stride = sc->sc_linebytes; - sc->sc_rasops.ri_flg = RI_CENTER | - (console ? 0 : RI_CLEAR); - sc->sc_rasops.ri_bits = (void *)bus_space_vaddr(sc->sc_bustag, + printf("\n"); + + sc->sc_sunfb.sf_ro.ri_bits = (void *)bus_space_vaddr(sc->sc_bustag, sc->sc_vid_regs); - sc->sc_rasops.ri_width = sc->sc_width; - sc->sc_rasops.ri_height = sc->sc_height; - sc->sc_rasops.ri_hw = sc; + sc->sc_sunfb.sf_ro.ri_hw = sc; + fbwscons_init(&sc->sc_sunfb, console ? 0 : RI_CLEAR); - rasops_init(&sc->sc_rasops, - a2int(getpropstring(optionsnode, "screen-#rows"), 34), - a2int(getpropstring(optionsnode, "screen-#columns"), 80)); - - bwtwo_stdscreen.nrows = sc->sc_rasops.ri_rows; - bwtwo_stdscreen.ncols = sc->sc_rasops.ri_cols; - bwtwo_stdscreen.textops = &sc->sc_rasops.ri_ops; - sc->sc_rasops.ri_ops.alloc_attr(&sc->sc_rasops, 0, 0, 0, &defattr); - - printf("\n"); + bwtwo_stdscreen.capabilities = sc->sc_sunfb.sf_ro.ri_caps; + bwtwo_stdscreen.nrows = sc->sc_sunfb.sf_ro.ri_rows; + bwtwo_stdscreen.ncols = sc->sc_sunfb.sf_ro.ri_cols; + bwtwo_stdscreen.textops = &sc->sc_sunfb.sf_ro.ri_ops; if (console) { - if (romgetcursoraddr(&sc->sc_crowp, &sc->sc_ccolp)) - sc->sc_ccolp = sc->sc_crowp = NULL; - if (sc->sc_ccolp != NULL) - sc->sc_rasops.ri_ccol = *sc->sc_ccolp; - if (sc->sc_crowp != NULL) - sc->sc_rasops.ri_crow = *sc->sc_crowp; - sc->sc_rasops.ri_updatecursor = bwtwo_updatecursor; - - wsdisplay_cnattach(&bwtwo_stdscreen, &sc->sc_rasops, - sc->sc_rasops.ri_ccol, sc->sc_rasops.ri_crow, defattr); + sc->sc_sunfb.sf_ro.ri_updatecursor = bwtwo_updatecursor; + fbwscons_console_init(&sc->sc_sunfb, &bwtwo_stdscreen, -1, + bwtwo_burner); } waa.console = console; @@ -306,13 +258,13 @@ bwtwo_ioctl(v, cmd, data, flags, p) break; case WSDISPLAYIO_GINFO: wdf = (void *)data; - wdf->height = sc->sc_height; - wdf->width = sc->sc_width; - wdf->depth = sc->sc_depth; + wdf->height = sc->sc_sunfb.sf_height; + wdf->width = sc->sc_sunfb.sf_width; + wdf->depth = sc->sc_sunfb.sf_depth; wdf->cmsize = 0; break; case WSDISPLAYIO_LINEBYTES: - *(u_int *)data = sc->sc_linebytes; + *(u_int *)data = sc->sc_sunfb.sf_linebytes; break; case WSDISPLAYIO_GETCMAP: @@ -346,10 +298,11 @@ bwtwo_alloc_screen(v, type, cookiep, curxp, curyp, attrp) if (sc->sc_nscreens > 0) return (ENOMEM); - *cookiep = &sc->sc_rasops; + *cookiep = &sc->sc_sunfb.sf_ro; *curyp = 0; *curxp = 0; - sc->sc_rasops.ri_ops.alloc_attr(&sc->sc_rasops, 0, 0, 0, attrp); + sc->sc_sunfb.sf_ro.ri_ops.alloc_attr(&sc->sc_sunfb.sf_ro, + 0, 0, 0, attrp); sc->sc_nscreens++; return (0); } @@ -389,25 +342,13 @@ bwtwo_mmap(v, offset, prot) if (offset & PGOFSET) return (-1); - if (offset >= 0 && offset < (sc->sc_linebytes * sc->sc_height)) + if (offset >= 0 && offset < sc->sc_sunfb.sf_fbsize) return (bus_space_mmap(sc->sc_bustag, sc->sc_paddr, BWTWO_VID_OFFSET + offset, prot, BUS_SPACE_MAP_LINEAR)); return (-1); } -static int -a2int(char *cp, int deflt) -{ - int i = 0; - - if (*cp == '\0') - return (deflt); - while (*cp != '\0') - i = i * 10 + *cp++ - '0'; - return (i); -} - int bwtwo_is_console(node) int node; @@ -445,8 +386,8 @@ bwtwo_updatecursor(ri) { struct bwtwo_softc *sc = ri->ri_hw; - if (sc->sc_crowp != NULL) - *sc->sc_crowp = ri->ri_crow; - if (sc->sc_ccolp != NULL) - *sc->sc_ccolp = ri->ri_ccol; + if (sc->sc_sunfb.sf_crowp != NULL) + *sc->sc_sunfb.sf_crowp = ri->ri_crow; + if (sc->sc_sunfb.sf_ccolp != NULL) + *sc->sc_sunfb.sf_ccolp = ri->ri_ccol; } diff --git a/sys/dev/sbus/cgsix.c b/sys/dev/sbus/cgsix.c index 418593b4ae2..d737489d7c2 100644 --- a/sys/dev/sbus/cgsix.c +++ b/sys/dev/sbus/cgsix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgsix.c,v 1.41 2003/06/02 18:32:41 jason Exp $ */ +/* $OpenBSD: cgsix.c,v 1.42 2003/06/18 17:35:30 miod Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -49,16 +49,12 @@ #include <dev/wscons/wsdisplayvar.h> #include <dev/wscons/wscons_raster.h> #include <dev/rasops/rasops.h> +#include <machine/fbvar.h> #include <dev/sbus/cgsixreg.h> #include <dev/ic/bt458reg.h> struct wsscreen_descr cgsix_stdscreen = { "std", - 0, 0, /* will be filled in -- XXX shouldn't, it's global. */ - 0, - 0, 0, - WSSCREEN_UNDERLINE | WSSCREEN_HILIT | - WSSCREEN_REVERSE | WSSCREEN_WSCOLORS }; const struct wsscreen_descr *cgsix_scrlist[] = { @@ -82,13 +78,11 @@ int cg6_bt_getcmap(union bt_cmap *, struct wsdisplay_cmap *); int cg6_bt_putcmap(union bt_cmap *, struct wsdisplay_cmap *); void cgsix_loadcmap_immediate(struct cgsix_softc *, u_int, u_int); void cgsix_loadcmap_deferred(struct cgsix_softc *, u_int, u_int); -void cgsix_setcolor(struct cgsix_softc *, u_int, - u_int8_t, u_int8_t, u_int8_t); +void cgsix_setcolor(void *, u_int, u_int8_t, u_int8_t, u_int8_t); void cgsix_reset(struct cgsix_softc *, u_int32_t); void cgsix_hardreset(struct cgsix_softc *); void cgsix_burner(void *, u_int, u_int); int cgsix_intr(void *); -static int a2int(char *, int); void cgsix_ras_init(struct cgsix_softc *); void cgsix_ras_copyrows(void *, int, int, int); void cgsix_ras_copycols(void *, int, int, int, int); @@ -142,7 +136,6 @@ cgsixattach(parent, self, aux) struct sbus_attach_args *sa = aux; struct wsemuldisplaydev_attach_args waa; int console, i; - long defattr; u_int32_t fhc, rev; sc->sc_bustag = sa->sa_bustag; @@ -153,10 +146,7 @@ cgsixattach(parent, self, aux) goto fail; } - sc->sc_depth = getpropint(sa->sa_node, "depth", 8); - sc->sc_linebytes = getpropint(sa->sa_node, "linebytes", 1152); - sc->sc_height = getpropint(sa->sa_node, "height", 900); - sc->sc_width = getpropint(sa->sa_node, "width", 1152); + fb_setsize(&sc->sc_sunfb, 8, 1152, 900, sa->sa_node, 0); /* * Map just BT, FHC, FBC, THC, and video RAM. @@ -184,7 +174,7 @@ cgsixattach(parent, self, aux) if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot, sa->sa_reg[0].sbr_offset + CGSIX_VID_OFFSET, - sc->sc_linebytes * sc->sc_height, BUS_SPACE_MAP_LINEAR, + sc->sc_sunfb.sf_fbsize, BUS_SPACE_MAP_LINEAR, 0, &sc->sc_vid_regs) != 0) { printf(": cannot map vid registers\n"); goto fail_vid; @@ -232,20 +222,10 @@ cgsixattach(parent, self, aux) sbus_establish(&sc->sc_sd, self); - sc->sc_rasops.ri_depth = sc->sc_depth; - sc->sc_rasops.ri_stride = sc->sc_linebytes; - sc->sc_rasops.ri_flg = RI_CENTER | - (console ? 0 : RI_CLEAR); - sc->sc_rasops.ri_bits = (void *)bus_space_vaddr(sc->sc_bustag, + sc->sc_sunfb.sf_ro.ri_bits = (void *)bus_space_vaddr(sc->sc_bustag, sc->sc_vid_regs); - sc->sc_rasops.ri_width = sc->sc_width; - sc->sc_rasops.ri_height = sc->sc_height; - sc->sc_rasops.ri_hw = sc; - - rasops_init(&sc->sc_rasops, - a2int(getpropstring(optionsnode, "screen-#rows"), 34), - a2int(getpropstring(optionsnode, "screen-#columns"), 80)); - sc->sc_rasops.ri_hw = sc; + sc->sc_sunfb.sf_ro.ri_hw = sc; + fbwscons_init(&sc->sc_sunfb, console ? 0 : RI_CLEAR); /* * Old rev. cg6 cards do not like the current acceleration code. @@ -254,48 +234,31 @@ cgsixattach(parent, self, aux) * will be investigated later. */ if (rev < 5) - sc->sc_dev.dv_cfdata->cf_flags |= CG6_CFFLAG_NOACCEL; - - if ((sc->sc_dev.dv_cfdata->cf_flags & CG6_CFFLAG_NOACCEL) == 0) { - sc->sc_rasops.ri_ops.copyrows = cgsix_ras_copyrows; - sc->sc_rasops.ri_ops.copycols = cgsix_ras_copycols; - sc->sc_rasops.ri_ops.eraserows = cgsix_ras_eraserows; - sc->sc_rasops.ri_ops.erasecols = cgsix_ras_erasecols; - sc->sc_rasops.ri_do_cursor = cgsix_ras_do_cursor; + sc->sc_sunfb.sf_dev.dv_cfdata->cf_flags |= CG6_CFFLAG_NOACCEL; + + if ((sc->sc_sunfb.sf_dev.dv_cfdata->cf_flags & CG6_CFFLAG_NOACCEL) + == 0) { + sc->sc_sunfb.sf_ro.ri_ops.copyrows = cgsix_ras_copyrows; + sc->sc_sunfb.sf_ro.ri_ops.copycols = cgsix_ras_copycols; + sc->sc_sunfb.sf_ro.ri_ops.eraserows = cgsix_ras_eraserows; + sc->sc_sunfb.sf_ro.ri_ops.erasecols = cgsix_ras_erasecols; + sc->sc_sunfb.sf_ro.ri_do_cursor = cgsix_ras_do_cursor; cgsix_ras_init(sc); } - cgsix_stdscreen.nrows = sc->sc_rasops.ri_rows; - cgsix_stdscreen.ncols = sc->sc_rasops.ri_cols; - cgsix_stdscreen.textops = &sc->sc_rasops.ri_ops; - sc->sc_rasops.ri_ops.alloc_attr(&sc->sc_rasops, - WSCOL_BLACK, WSCOL_WHITE, WSATTR_WSCOLORS, &defattr); + cgsix_stdscreen.capabilities = sc->sc_sunfb.sf_ro.ri_caps; + cgsix_stdscreen.nrows = sc->sc_sunfb.sf_ro.ri_rows; + cgsix_stdscreen.ncols = sc->sc_sunfb.sf_ro.ri_cols; + cgsix_stdscreen.textops = &sc->sc_sunfb.sf_ro.ri_ops; printf("\n"); - cgsix_setcolor(sc, WSCOL_BLACK, 0, 0, 0); - cgsix_setcolor(sc, WSCOL_RED, 255, 0, 0); - cgsix_setcolor(sc, WSCOL_GREEN, 0, 255, 0); - cgsix_setcolor(sc, WSCOL_BROWN, 154, 85, 46); - cgsix_setcolor(sc, WSCOL_BLUE, 0, 0, 255); - cgsix_setcolor(sc, WSCOL_MAGENTA, 255, 255, 0); - cgsix_setcolor(sc, WSCOL_CYAN, 0, 255, 255); - cgsix_setcolor(sc, WSCOL_WHITE, 255, 255, 255); - /* for cursor inversion */ - cgsix_setcolor(sc, (~WSCOL_WHITE) & 0xff, 0, 0, 0); - cgsix_setcolor(sc, (~WSCOL_BLACK) & 0xff, 255, 255, 255); + fbwscons_setcolormap(&sc->sc_sunfb, cgsix_setcolor); if (console) { - if (romgetcursoraddr(&sc->sc_crowp, &sc->sc_ccolp)) - sc->sc_crowp = sc->sc_ccolp = NULL; - if (sc->sc_ccolp != NULL) - sc->sc_rasops.ri_ccol = *sc->sc_ccolp; - if (sc->sc_crowp != NULL) - sc->sc_rasops.ri_crow = *sc->sc_crowp; - sc->sc_rasops.ri_updatecursor = cgsix_ras_updatecursor; - - wsdisplay_cnattach(&cgsix_stdscreen, &sc->sc_rasops, - sc->sc_rasops.ri_ccol, sc->sc_rasops.ri_crow, defattr); + sc->sc_sunfb.sf_ro.ri_updatecursor = cgsix_ras_updatecursor; + fbwscons_console_init(&sc->sc_sunfb, &cgsix_stdscreen, -1, + cgsix_burner); } waa.console = console; @@ -346,8 +309,8 @@ cgsix_ioctl(v, cmd, data, flags, p) break; case WSDISPLAYIO_SMODE: mode = *(u_int *)data; - if ((sc->sc_dev.dv_cfdata->cf_flags & CG6_CFFLAG_NOACCEL) - == 0) { + if ((sc->sc_sunfb.sf_dev.dv_cfdata->cf_flags & + CG6_CFFLAG_NOACCEL) == 0) { if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL && mode == WSDISPLAYIO_MODE_EMUL) cgsix_ras_init(sc); @@ -356,13 +319,13 @@ cgsix_ioctl(v, cmd, data, flags, p) break; case WSDISPLAYIO_GINFO: wdf = (void *)data; - wdf->height = sc->sc_height; - wdf->width = sc->sc_width; - wdf->depth = sc->sc_depth; + wdf->height = sc->sc_sunfb.sf_height; + wdf->width = sc->sc_sunfb.sf_width; + wdf->depth = sc->sc_sunfb.sf_depth; wdf->cmsize = 256; break; case WSDISPLAYIO_LINEBYTES: - *(u_int *)data = sc->sc_linebytes; + *(u_int *)data = sc->sc_sunfb.sf_linebytes; break; case WSDISPLAYIO_GETCMAP: cm = (struct wsdisplay_cmap *)data; @@ -585,10 +548,10 @@ cgsix_alloc_screen(v, type, cookiep, curxp, curyp, attrp) if (sc->sc_nscreens > 0) return (ENOMEM); - *cookiep = &sc->sc_rasops; + *cookiep = &sc->sc_sunfb.sf_ro; *curyp = 0; *curxp = 0; - sc->sc_rasops.ri_ops.alloc_attr(&sc->sc_rasops, + sc->sc_sunfb.sf_ro.ri_ops.alloc_attr(&sc->sc_sunfb.sf_ro, WSCOL_BLACK, WSCOL_WHITE, WSATTR_WSCOLORS, attrp); sc->sc_nscreens++; return (0); @@ -655,8 +618,7 @@ cgsix_mmap(v, off, prot) if (off < mo->mo_uaddr) continue; u = off - mo->mo_uaddr; - sz = mo->mo_size ? mo->mo_size : - sc->sc_linebytes * sc->sc_height; + sz = mo->mo_size ? mo->mo_size : sc->sc_sunfb.sf_fbsize; if (u < sz) { return (bus_space_mmap(sc->sc_bustag, sc->sc_paddr, u + mo->mo_physoff, @@ -667,7 +629,7 @@ cgsix_mmap(v, off, prot) case WSDISPLAYIO_MODE_DUMBFB: /* Allow mapping as a dumb framebuffer from offset 0 */ - if (off >= 0 && off < (sc->sc_linebytes * sc->sc_height)) + if (off >= 0 && off < sc->sc_sunfb.sf_fbsize) return (bus_space_mmap(sc->sc_bustag, sc->sc_paddr, off + CGSIX_VID_OFFSET, prot, BUS_SPACE_MAP_LINEAR)); @@ -677,18 +639,6 @@ cgsix_mmap(v, off, prot) return (-1); } -static int -a2int(char *cp, int deflt) -{ - int i = 0; - - if (*cp == '\0') - return (deflt); - while (*cp != '\0') - i = i * 10 + *cp++ - '0'; - return (i); -} - int cgsix_is_console(node) int node; @@ -782,11 +732,9 @@ cgsix_loadcmap_immediate(sc, start, ncolors) } void -cgsix_setcolor(sc, index, r, g, b) - struct cgsix_softc *sc; - u_int index; - u_int8_t r, g, b; +cgsix_setcolor(void *v, u_int index, u_int8_t r, u_int8_t g, u_int8_t b) { + struct cgsix_softc *sc = v; union bt_cmap *bcm = &sc->sc_cmap; bcm->cm_map[index][0] = r; @@ -1174,8 +1122,8 @@ cgsix_ras_updatecursor(ri) { struct cgsix_softc *sc = ri->ri_hw; - if (sc->sc_crowp != NULL) - *sc->sc_crowp = ri->ri_crow; - if (sc->sc_ccolp != NULL) - *sc->sc_ccolp = ri->ri_ccol; + if (sc->sc_sunfb.sf_crowp != NULL) + *sc->sc_sunfb.sf_crowp = ri->ri_crow; + if (sc->sc_sunfb.sf_ccolp != NULL) + *sc->sc_sunfb.sf_ccolp = ri->ri_ccol; } diff --git a/sys/dev/sbus/cgsixreg.h b/sys/dev/sbus/cgsixreg.h index acba294940c..06d81c410ba 100644 --- a/sys/dev/sbus/cgsixreg.h +++ b/sys/dev/sbus/cgsixreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cgsixreg.h,v 1.7 2003/06/02 18:32:41 jason Exp $ */ +/* $OpenBSD: cgsixreg.h,v 1.8 2003/06/18 17:35:30 miod Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -264,7 +264,7 @@ union bt_cmap { #define THC_MISC_CYCLS 0x0000000f /* cycles before transfer */ struct cgsix_softc { - struct device sc_dev; + struct sunfb sc_sunfb; struct sbusdev sc_sd; bus_space_tag_t sc_bustag; bus_addr_t sc_paddr; @@ -274,13 +274,10 @@ struct cgsix_softc { bus_space_handle_t sc_tec_regs; bus_space_handle_t sc_vid_regs; bus_space_handle_t sc_fbc_regs; - struct rasops_info sc_rasops; int sc_nscreens; - int sc_width, sc_height, sc_depth, sc_linebytes; union bt_cmap sc_cmap; void *sc_ih; u_int sc_mode; - int *sc_crowp, *sc_ccolp; u_int sc_curs_enabled, sc_curs_fg, sc_curs_bg; struct wsdisplay_curpos sc_curs_pos, sc_curs_hot, sc_curs_size; u_char sc_curs_image[128], sc_curs_mask[128]; diff --git a/sys/dev/sbus/cgthree.c b/sys/dev/sbus/cgthree.c index 5613ecb4eac..862ce4008af 100644 --- a/sys/dev/sbus/cgthree.c +++ b/sys/dev/sbus/cgthree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgthree.c,v 1.31 2003/06/17 19:47:45 miod Exp $ */ +/* $OpenBSD: cgthree.c,v 1.32 2003/06/18 17:35:30 miod Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -49,6 +49,8 @@ #include <dev/wscons/wsdisplayvar.h> #include <dev/wscons/wscons_raster.h> #include <dev/rasops/rasops.h> +#include <machine/fbvar.h> + #include <dev/ic/bt458reg.h> #define CGTHREE_CTRL_OFFSET 0x400000 @@ -116,27 +118,19 @@ union bt_cmap { bus_space_write_1((sc)->sc_bustag, (sc)->sc_ctrl_regs, (reg), (val)) struct cgthree_softc { - struct device sc_dev; + struct sunfb sc_sunfb; struct sbusdev sc_sd; bus_space_tag_t sc_bustag; bus_addr_t sc_paddr; bus_space_handle_t sc_ctrl_regs; bus_space_handle_t sc_vid_regs; int sc_nscreens; - int sc_width, sc_height, sc_depth, sc_linebytes; union bt_cmap sc_cmap; - struct rasops_info sc_rasops; u_int sc_mode; - int *sc_crowp, *sc_ccolp; }; struct wsscreen_descr cgthree_stdscreen = { "std", - 0, 0, /* will be filled in -- XXX shouldn't, it's global. */ - 0, - 0, 0, - WSSCREEN_UNDERLINE | WSSCREEN_HILIT | - WSSCREEN_REVERSE | WSSCREEN_WSCOLORS }; const struct wsscreen_descr *cgthree_scrlist[] = { @@ -159,12 +153,10 @@ int cgthree_is_console(int); void cgthree_loadcmap(struct cgthree_softc *, u_int, u_int); int cg3_bt_putcmap(union bt_cmap *, struct wsdisplay_cmap *); int cg3_bt_getcmap(union bt_cmap *, struct wsdisplay_cmap *); -void cgthree_setcolor(struct cgthree_softc *, u_int, - u_int8_t, u_int8_t, u_int8_t); +void cgthree_setcolor(void *, u_int, u_int8_t, u_int8_t, u_int8_t); void cgthree_burner(void *, u_int, u_int); void cgthree_reset(struct cgthree_softc *); void cgthree_updatecursor(struct rasops_info *); -static int a2int(char *, int); struct wsdisplay_accessops cgthree_accessops = { cgthree_ioctl, @@ -238,15 +230,11 @@ cgthreeattach(parent, self, aux) struct sbus_attach_args *sa = aux; struct wsemuldisplaydev_attach_args waa; int console, i; - long defattr; sc->sc_bustag = sa->sa_bustag; sc->sc_paddr = sbus_bus_addr(sa->sa_bustag, sa->sa_slot, sa->sa_offset); - sc->sc_depth = getpropint(sa->sa_node, "depth", 8); - sc->sc_linebytes = getpropint(sa->sa_node, "linebytes", 1152); - sc->sc_height = getpropint(sa->sa_node, "height", 900); - sc->sc_width = getpropint(sa->sa_node, "width", 1152); + fb_setsize(&sc->sc_sunfb, 8, 1152, 900, sa->sa_node, 0); if (sa->sa_nreg != 1) { printf(": expected %d registers, got %d\n", 1, sa->sa_nreg); @@ -266,7 +254,7 @@ cgthreeattach(parent, self, aux) if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot, sa->sa_reg[0].sbr_offset + CGTHREE_VID_OFFSET, - sc->sc_linebytes * sc->sc_height, BUS_SPACE_MAP_LINEAR, + sc->sc_sunfb.sf_fbsize, BUS_SPACE_MAP_LINEAR, 0, &sc->sc_vid_regs) != 0) { printf(": cannot map vid registers\n"); goto fail_vid; @@ -274,7 +262,7 @@ cgthreeattach(parent, self, aux) console = cgthree_is_console(sa->sa_node); - sbus_establish(&sc->sc_sd, &sc->sc_dev); + sbus_establish(&sc->sc_sd, &sc->sc_sunfb.sf_dev); cgthree_reset(sc); @@ -284,50 +272,24 @@ cgthreeattach(parent, self, aux) cgthree_burner(sc, 1, 0); - sc->sc_rasops.ri_depth = sc->sc_depth; - sc->sc_rasops.ri_stride = sc->sc_linebytes; - sc->sc_rasops.ri_flg = RI_CENTER | - (console ? 0 : RI_CLEAR); - sc->sc_rasops.ri_bits = (void *)bus_space_vaddr(sc->sc_bustag, + sc->sc_sunfb.sf_ro.ri_bits = (void *)bus_space_vaddr(sc->sc_bustag, sc->sc_vid_regs); - sc->sc_rasops.ri_width = sc->sc_width; - sc->sc_rasops.ri_height = sc->sc_height; - sc->sc_rasops.ri_hw = sc; - - rasops_init(&sc->sc_rasops, - a2int(getpropstring(optionsnode, "screen-#rows"), 34), - a2int(getpropstring(optionsnode, "screen-#columns"), 80)); + sc->sc_sunfb.sf_ro.ri_hw = sc; + fbwscons_init(&sc->sc_sunfb, console ? 0 : RI_CLEAR); - cgthree_stdscreen.nrows = sc->sc_rasops.ri_rows; - cgthree_stdscreen.ncols = sc->sc_rasops.ri_cols; - cgthree_stdscreen.textops = &sc->sc_rasops.ri_ops; - sc->sc_rasops.ri_ops.alloc_attr(&sc->sc_rasops, - WSCOL_BLACK, WSCOL_WHITE, WSATTR_WSCOLORS, &defattr); - sc->sc_rasops.ri_hw = sc; + cgthree_stdscreen.capabilities = sc->sc_sunfb.sf_ro.ri_caps; + cgthree_stdscreen.nrows = sc->sc_sunfb.sf_ro.ri_rows; + cgthree_stdscreen.ncols = sc->sc_sunfb.sf_ro.ri_cols; + cgthree_stdscreen.textops = &sc->sc_sunfb.sf_ro.ri_ops; printf("\n"); - cgthree_setcolor(sc, WSCOL_BLACK, 0, 0, 0); - cgthree_setcolor(sc, 255, 0, 0, 0); - cgthree_setcolor(sc, WSCOL_RED, 255, 0, 0); - cgthree_setcolor(sc, WSCOL_GREEN, 0, 255, 0); - cgthree_setcolor(sc, WSCOL_BROWN, 154, 85, 46); - cgthree_setcolor(sc, WSCOL_BLUE, 0, 0, 255); - cgthree_setcolor(sc, WSCOL_MAGENTA, 255, 255, 0); - cgthree_setcolor(sc, WSCOL_CYAN, 0, 255, 255); - cgthree_setcolor(sc, WSCOL_WHITE, 255, 255, 255); + fbwscons_setcolormap(&sc->sc_sunfb, cgthree_setcolor); if (console) { - if (romgetcursoraddr(&sc->sc_crowp, &sc->sc_ccolp)) - sc->sc_ccolp = sc->sc_crowp = NULL; - if (sc->sc_ccolp != NULL) - sc->sc_rasops.ri_ccol = *sc->sc_ccolp; - if (sc->sc_crowp != NULL) - sc->sc_rasops.ri_crow = *sc->sc_crowp; - sc->sc_rasops.ri_updatecursor = cgthree_updatecursor; - - wsdisplay_cnattach(&cgthree_stdscreen, &sc->sc_rasops, - sc->sc_rasops.ri_ccol, sc->sc_rasops.ri_crow, defattr); + sc->sc_sunfb.sf_ro.ri_updatecursor = cgthree_updatecursor; + fbwscons_console_init(&sc->sc_sunfb, &cgthree_stdscreen, -1, + cgthree_burner); } waa.console = console; @@ -367,13 +329,13 @@ cgthree_ioctl(v, cmd, data, flags, p) break; case WSDISPLAYIO_GINFO: wdf = (void *)data; - wdf->height = sc->sc_height; - wdf->width = sc->sc_width; - wdf->depth = sc->sc_depth; + wdf->height = sc->sc_sunfb.sf_height; + wdf->width = sc->sc_sunfb.sf_width; + wdf->depth = sc->sc_sunfb.sf_depth; wdf->cmsize = 256; break; case WSDISPLAYIO_LINEBYTES: - *(u_int *)data = sc->sc_linebytes; + *(u_int *)data = sc->sc_sunfb.sf_linebytes; break; case WSDISPLAYIO_GETCMAP: @@ -418,10 +380,10 @@ cgthree_alloc_screen(v, type, cookiep, curxp, curyp, attrp) if (sc->sc_nscreens > 0) return (ENOMEM); - *cookiep = &sc->sc_rasops; + *cookiep = &sc->sc_sunfb.sf_ro; *curyp = 0; *curxp = 0; - sc->sc_rasops.ri_ops.alloc_attr(&sc->sc_rasops, + sc->sc_sunfb.sf_ro.ri_ops.alloc_attr(&sc->sc_sunfb.sf_ro, WSCOL_BLACK, WSCOL_WHITE, WSATTR_WSCOLORS, attrp); sc->sc_nscreens++; return (0); @@ -470,12 +432,12 @@ cgthree_mmap(v, offset, prot) offset -= START; else offset = 0; - if (offset >= sc->sc_linebytes * sc->sc_height) + if (offset >= sc->sc_sunfb.sf_fbsize) return (-1); return (bus_space_mmap(sc->sc_bustag, sc->sc_paddr, CGTHREE_VID_OFFSET + offset, prot, BUS_SPACE_MAP_LINEAR)); case WSDISPLAYIO_MODE_DUMBFB: - if (offset < (sc->sc_linebytes * sc->sc_height)) + if (offset < sc->sc_sunfb.sf_fbsize) return (bus_space_mmap(sc->sc_bustag, sc->sc_paddr, CGTHREE_VID_OFFSET + offset, prot, BUS_SPACE_MAP_LINEAR)); @@ -484,18 +446,6 @@ cgthree_mmap(v, offset, prot) return (-1); } -static int -a2int(char *cp, int deflt) -{ - int i = 0; - - if (*cp == '\0') - return (deflt); - while (*cp != '\0') - i = i * 10 + *cp++ - '0'; - return (i); -} - int cgthree_is_console(node) int node; @@ -506,11 +456,9 @@ cgthree_is_console(node) } void -cgthree_setcolor(sc, index, r, g, b) - struct cgthree_softc *sc; - u_int index; - u_int8_t r, g, b; +cgthree_setcolor(void *v, u_int index, u_int8_t r, u_int8_t g, u_int8_t b) { + struct cgthree_softc *sc = v; union bt_cmap *bcm = &sc->sc_cmap; bcm->cm_map[index][0] = r; @@ -671,8 +619,8 @@ cgthree_updatecursor(ri) { struct cgthree_softc *sc = ri->ri_hw; - if (sc->sc_crowp != NULL) - *sc->sc_crowp = ri->ri_crow; - if (sc->sc_ccolp != NULL) - *sc->sc_ccolp = ri->ri_ccol; + if (sc->sc_sunfb.sf_crowp != NULL) + *sc->sc_sunfb.sf_crowp = ri->ri_crow; + if (sc->sc_sunfb.sf_ccolp != NULL) + *sc->sc_sunfb.sf_ccolp = ri->ri_ccol; } |