/* $OpenBSD: creator.c,v 1.12 2002/06/11 06:53:03 fgsch Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Jason L. Wright * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct wsscreen_descr creator_stdscreen = { "std", 0, 0, /* will be filled in -- XXX shouldn't, it's global. */ 0, 0, 0, WSSCREEN_REVERSE | WSSCREEN_WSCOLORS }; const struct wsscreen_descr *creator_scrlist[] = { &creator_stdscreen, /* XXX other formats? */ }; struct wsscreen_list creator_screenlist = { sizeof(creator_scrlist) / sizeof(struct wsscreen_descr *), creator_scrlist }; int creator_ioctl(void *, u_long, caddr_t, int, struct proc *); int creator_alloc_screen(void *, const struct wsscreen_descr *, void **, int *, int *, long *); void creator_free_screen(void *, void *); int creator_show_screen(void *, void *, int, void (*cb)(void *, int, int), void *); paddr_t creator_mmap(void *, off_t, int); static int a2int(char *, int); struct wsdisplay_accessops creator_accessops = { creator_ioctl, creator_mmap, creator_alloc_screen, creator_free_screen, creator_show_screen, NULL, /* load font */ NULL, /* scrollback */ NULL, /* getchar */ NULL, /* burner */ }; struct cfdriver creator_cd = { NULL, "creator", DV_DULL }; void creator_attach(struct creator_softc *sc) { struct wsemuldisplaydev_attach_args waa; long defattr; char *model; int btype; printf(":"); if (sc->sc_type == FFB_CREATOR) { btype = getpropint(sc->sc_node, "board_type", 0); if ((btype & 7) == 3) printf(" Creator3D"); else printf(" Creator"); } else printf(" Elite3D"); model = getpropstring(sc->sc_node, "model"); if (model == NULL || strlen(model) == 0) model = "unknown"; printf(", model %s\n", model); sc->sc_depth = 24; sc->sc_linebytes = 8192; sc->sc_height = getpropint(sc->sc_node, "height", 0); sc->sc_width = getpropint(sc->sc_node, "width", 0); sc->sc_rasops.ri_depth = 32; sc->sc_rasops.ri_stride = sc->sc_linebytes; sc->sc_rasops.ri_flg = RI_CENTER; sc->sc_rasops.ri_bits = (void *)bus_space_vaddr(sc->sc_bt, sc->sc_pixel_h); 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)); creator_stdscreen.nrows = sc->sc_rasops.ri_rows; creator_stdscreen.ncols = sc->sc_rasops.ri_cols; creator_stdscreen.textops = &sc->sc_rasops.ri_ops; sc->sc_rasops.ri_ops.alloc_attr(&sc->sc_rasops, 0, 0, 0, &defattr); if (sc->sc_console) { int *ccolp, *crowp; if (romgetcursoraddr(&crowp, &ccolp)) ccolp = crowp = NULL; if (ccolp != NULL) sc->sc_rasops.ri_ccol = *ccolp; if (crowp != NULL) sc->sc_rasops.ri_crow = *crowp; wsdisplay_cnattach(&creator_stdscreen, &sc->sc_rasops, sc->sc_rasops.ri_ccol, sc->sc_rasops.ri_crow, defattr); } waa.console = sc->sc_console; waa.scrdata = &creator_screenlist; waa.accessops = &creator_accessops; waa.accesscookie = sc; config_found(&sc->sc_dv, &waa, wsemuldisplaydevprint); } int creator_ioctl(v, cmd, data, flags, p) void *v; u_long cmd; caddr_t data; int flags; struct proc *p; { struct creator_softc *sc = v; struct wsdisplay_fbinfo *wdf; switch (cmd) { case WSDISPLAYIO_GTYPE: *(u_int *)data = WSDISPLAY_TYPE_SUNFFB; break; case WSDISPLAYIO_SMODE: sc->sc_mode = *(u_int *)data; break; case WSDISPLAYIO_GINFO: wdf = (void *)data; wdf->height = sc->sc_height; wdf->width = sc->sc_width; wdf->depth = 32; wdf->cmsize = 256; /* XXX */ break; case WSDISPLAYIO_LINEBYTES: *(u_int *)data = sc->sc_linebytes; break; case WSDISPLAYIO_GETCMAP: break;/* XXX */ case WSDISPLAYIO_PUTCMAP: break;/* XXX */ case WSDISPLAYIO_SVIDEO: case WSDISPLAYIO_GVIDEO: case WSDISPLAYIO_GCURPOS: case WSDISPLAYIO_SCURPOS: case WSDISPLAYIO_GCURMAX: case WSDISPLAYIO_GCURSOR: case WSDISPLAYIO_SCURSOR: default: return -1; /* not supported yet */ } return (0); } int creator_alloc_screen(v, type, cookiep, curxp, curyp, attrp) void *v; const struct wsscreen_descr *type; void **cookiep; int *curxp, *curyp; long *attrp; { struct creator_softc *sc = v; if (sc->sc_nscreens > 0) return (ENOMEM); *cookiep = &sc->sc_rasops; *curyp = 0; *curxp = 0; sc->sc_rasops.ri_ops.alloc_attr(&sc->sc_rasops, 0, 0, 0, attrp); sc->sc_nscreens++; return (0); } void creator_free_screen(v, cookie) void *v; void *cookie; { struct creator_softc *sc = v; sc->sc_nscreens--; } int creator_show_screen(v, cookie, waitok, cb, cbarg) void *v; void *cookie; int waitok; void (*cb)(void *, int, int); void *cbarg; { return (0); } paddr_t creator_mmap(vsc, off, prot) void *vsc; off_t off; int prot; { struct creator_softc *sc = vsc; int i; switch (sc->sc_mode) { case WSDISPLAYIO_MODE_MAPPED: for (i = 0; i < sc->sc_nreg; i++) { /* Before this set? */ if (off < sc->sc_addrs[i]) continue; /* After this set? */ if (off >= (sc->sc_addrs[i] + sc->sc_sizes[i])) continue; return (bus_space_mmap(sc->sc_bt, sc->sc_addrs[i], off - sc->sc_addrs[i], prot, BUS_SPACE_MAP_LINEAR)); } break; case WSDISPLAYIO_MODE_DUMBFB: if (sc->sc_nreg < FFB_REG_DFB24) break; if (off >= 0 && off < sc->sc_sizes[FFB_REG_DFB24]) return (bus_space_mmap(sc->sc_bt, sc->sc_addrs[FFB_REG_DFB24], off, prot, BUS_SPACE_MAP_LINEAR)); break; } 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); }