Port of OpenBSD ffb driver written by Jason L. Wright.

This commit is contained in:
petrov 2003-05-23 06:51:15 +00:00
parent 5d5afc14d8
commit 49f3f8ccaf
4 changed files with 930 additions and 0 deletions

513
sys/arch/sparc64/dev/ffb.c Normal file
View File

@ -0,0 +1,513 @@
/* $NetBSD: ffb.c,v 1.1 2003/05/23 06:51:15 petrov Exp $ */
/* $OpenBSD: creator.c,v 1.20 2002/07/30 19:48:15 jason 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 <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <machine/bus.h>
#include <machine/autoconf.h>
#include <machine/openfirm.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wscons_raster.h>
#include <dev/rasops/rasops.h>
#include <sparc64/dev/ffbreg.h>
#include <sparc64/dev/ffbvar.h>
struct wsscreen_descr ffb_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 *ffb_scrlist[] = {
&ffb_stdscreen,
/* XXX other formats? */
};
struct wsscreen_list ffb_screenlist = {
sizeof(ffb_scrlist) / sizeof(struct wsscreen_descr *),
ffb_scrlist
};
int ffb_ioctl(void *, u_long, caddr_t, int, struct proc *);
int ffb_alloc_screen(void *, const struct wsscreen_descr *, void **,
int *, int *, long *);
void ffb_free_screen(void *, void *);
int ffb_show_screen(void *, void *, int, void (*cb)(void *, int, int),
void *);
paddr_t ffb_mmap(void *, off_t, int);
static int a2int(char *, int);
void ffb_ras_fifo_wait(struct ffb_softc *, int);
void ffb_ras_wait(struct ffb_softc *);
void ffb_ras_init(struct ffb_softc *);
void ffb_ras_copyrows(void *, int, int, int);
void ffb_ras_erasecols(void *, int, int, int, long int);
void ffb_ras_eraserows(void *, int, int, long int);
void ffb_ras_do_cursor(struct rasops_info *);
void ffb_ras_fill(struct ffb_softc *);
void ffb_ras_setfg(struct ffb_softc *, int32_t);
struct wsdisplay_accessops ffb_accessops = {
ffb_ioctl,
ffb_mmap,
ffb_alloc_screen,
ffb_free_screen,
ffb_show_screen,
NULL, /* load font */
NULL, /* scrollback */
NULL, /* getchar */
NULL, /* burner */
};
void
ffb_attach(struct ffb_softc *sc)
{
struct wsemuldisplaydev_attach_args waa;
char *model;
int btype;
printf(":");
if (sc->sc_type == FFB_CREATOR) {
btype = PROM_getpropint(sc->sc_node, "board_type", 0);
if ((btype & 7) == 3)
printf(" Creator3D");
else
printf(" Creator");
} else
printf(" Elite3D");
model = PROM_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 = PROM_getpropint(sc->sc_node, "height", 0);
sc->sc_width = PROM_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(PROM_getpropstring(optionsnode, "screen-#rows"), 34),
a2int(PROM_getpropstring(optionsnode, "screen-#columns"), 80));
if ((sc->sc_dv.dv_cfdata->cf_flags & FFB_CFFLAG_NOACCEL) == 0) {
sc->sc_rasops.ri_hw = sc;
sc->sc_rasops.ri_ops.eraserows = ffb_ras_eraserows;
sc->sc_rasops.ri_ops.erasecols = ffb_ras_erasecols;
sc->sc_rasops.ri_ops.copyrows = ffb_ras_copyrows;
ffb_ras_init(sc);
}
ffb_stdscreen.nrows = sc->sc_rasops.ri_rows;
ffb_stdscreen.ncols = sc->sc_rasops.ri_cols;
ffb_stdscreen.textops = &sc->sc_rasops.ri_ops;
if (sc->sc_console) {
int *ccolp, *crowp;
long defattr;
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;
sc->sc_rasops.ri_ops.allocattr(&sc->sc_rasops,
0, 0, 0, &defattr);
wsdisplay_cnattach(&ffb_stdscreen, &sc->sc_rasops,
sc->sc_rasops.ri_ccol, sc->sc_rasops.ri_crow, defattr);
}
waa.console = sc->sc_console;
waa.scrdata = &ffb_screenlist;
waa.accessops = &ffb_accessops;
waa.accesscookie = sc;
config_found(&sc->sc_dv, &waa, wsemuldisplaydevprint);
}
int
ffb_ioctl(v, cmd, data, flags, p)
void *v;
u_long cmd;
caddr_t data;
int flags;
struct proc *p;
{
struct ffb_softc *sc = v;
struct wsdisplay_fbinfo *wdf;
printf("ffb_ioctl: %s cmd _IO%s%s('%c', %lu)\n",
sc->sc_dv.dv_xname,
(cmd & IOC_IN) ? "W" : "", (cmd & IOC_OUT) ? "R" : "",
(char)IOCGROUP(cmd), cmd & 0xff);
switch (cmd) {
case WSDISPLAYIO_GTYPE:
*(u_int *)data = WSDISPLAY_TYPE_SUN24;
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;
#ifdef WSDISPLAYIO_LINEBYTES
case WSDISPLAYIO_LINEBYTES:
*(u_int *)data = sc->sc_linebytes;
break;
#endif
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
ffb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
void *v;
const struct wsscreen_descr *type;
void **cookiep;
int *curxp, *curyp;
long *attrp;
{
struct ffb_softc *sc = v;
if (sc->sc_nscreens > 0)
return (ENOMEM);
*cookiep = &sc->sc_rasops;
*curyp = 0;
*curxp = 0;
sc->sc_rasops.ri_ops.allocattr(&sc->sc_rasops, 0, 0, 0, attrp);
sc->sc_nscreens++;
return (0);
}
void
ffb_free_screen(v, cookie)
void *v;
void *cookie;
{
struct ffb_softc *sc = v;
sc->sc_nscreens--;
}
int
ffb_show_screen(v, cookie, waitok, cb, cbarg)
void *v;
void *cookie;
int waitok;
void (*cb)(void *, int, int);
void *cbarg;
{
return (0);
}
paddr_t
ffb_mmap(vsc, off, prot)
void *vsc;
off_t off;
int prot;
{
struct ffb_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;
#ifdef WSDISPLAYIO_MODE_DUMBFB
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;
#endif
}
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);
}
void
ffb_ras_fifo_wait(sc, n)
struct ffb_softc *sc;
int n;
{
int32_t cache = sc->sc_fifo_cache;
if (cache < n) {
do {
cache = FBC_READ(sc, FFB_FBC_UCSR);
cache = (cache & FBC_UCSR_FIFO_MASK) - 8;
} while (cache < n);
}
sc->sc_fifo_cache = cache - n;
}
void
ffb_ras_wait(sc)
struct ffb_softc *sc;
{
u_int32_t ucsr, r;
while (1) {
ucsr = FBC_READ(sc, FFB_FBC_UCSR);
if ((ucsr & (FBC_UCSR_FB_BUSY|FBC_UCSR_RP_BUSY)) == 0)
break;
r = ucsr & (FBC_UCSR_READ_ERR | FBC_UCSR_FIFO_OVFL);
if (r != 0)
FBC_WRITE(sc, FFB_FBC_UCSR, r);
}
}
void
ffb_ras_init(sc)
struct ffb_softc *sc;
{
ffb_ras_fifo_wait(sc, 7);
FBC_WRITE(sc, FFB_FBC_PPC,
FBC_PPC_VCE_DIS | FBC_PPC_TBE_OPAQUE |
FBC_PPC_APE_DIS | FBC_PPC_CS_CONST);
FBC_WRITE(sc, FFB_FBC_FBC,
FFB_FBC_WB_A | FFB_FBC_RB_A | FFB_FBC_SB_BOTH |
FFB_FBC_XE_OFF | FFB_FBC_RGBE_MASK);
FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_NEW);
FBC_WRITE(sc, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE);
FBC_WRITE(sc, FFB_FBC_PMASK, 0xffffffff);
FBC_WRITE(sc, FFB_FBC_FONTINC, 0x10000);
sc->sc_fg_cache = 0;
FBC_WRITE(sc, FFB_FBC_FG, sc->sc_fg_cache);
ffb_ras_wait(sc);
}
void
ffb_ras_eraserows(cookie, row, n, attr)
void *cookie;
int row, n;
long int attr;
{
struct rasops_info *ri = cookie;
struct ffb_softc *sc = ri->ri_hw;
if (row < 0) {
n += row;
row = 0;
}
if (row + n > ri->ri_rows)
n = ri->ri_rows - row;
if (n <= 0)
return;
ffb_ras_fill(sc);
ffb_ras_setfg(sc, ri->ri_devcmap[(attr >> 16) & 0xf]);
ffb_ras_fifo_wait(sc, 4);
if ((n == ri->ri_rows) && (ri->ri_flg & RI_FULLCLEAR)) {
FBC_WRITE(sc, FFB_FBC_BY, 0);
FBC_WRITE(sc, FFB_FBC_BX, 0);
FBC_WRITE(sc, FFB_FBC_BH, ri->ri_height);
FBC_WRITE(sc, FFB_FBC_BW, ri->ri_width);
} else {
row *= ri->ri_font->fontheight;
FBC_WRITE(sc, FFB_FBC_BY, ri->ri_yorigin + row);
FBC_WRITE(sc, FFB_FBC_BX, ri->ri_xorigin);
FBC_WRITE(sc, FFB_FBC_BH, n * ri->ri_font->fontheight);
FBC_WRITE(sc, FFB_FBC_BW, ri->ri_emuwidth);
}
ffb_ras_wait(sc);
}
void
ffb_ras_erasecols(cookie, row, col, n, attr)
void *cookie;
int row, col, n;
long int attr;
{
struct rasops_info *ri = cookie;
struct ffb_softc *sc = ri->ri_hw;
if ((row < 0) || (row >= ri->ri_rows))
return;
if (col < 0) {
n += col;
col = 0;
}
if (col + n > ri->ri_cols)
n = ri->ri_cols - col;
if (n <= 0)
return;
n *= ri->ri_font->fontwidth;
col *= ri->ri_font->fontwidth;
row *= ri->ri_font->fontheight;
ffb_ras_fill(sc);
ffb_ras_setfg(sc, ri->ri_devcmap[(attr >> 16) & 0xf]);
ffb_ras_fifo_wait(sc, 4);
FBC_WRITE(sc, FFB_FBC_BY, ri->ri_yorigin + row);
FBC_WRITE(sc, FFB_FBC_BX, ri->ri_xorigin + col);
FBC_WRITE(sc, FFB_FBC_BH, ri->ri_font->fontheight);
FBC_WRITE(sc, FFB_FBC_BW, n - 1);
ffb_ras_wait(sc);
}
void
ffb_ras_fill(sc)
struct ffb_softc *sc;
{
ffb_ras_fifo_wait(sc, 2);
FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_NEW);
FBC_WRITE(sc, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE);
ffb_ras_wait(sc);
}
void
ffb_ras_copyrows(cookie, src, dst, n)
void *cookie;
int src, dst, n;
{
struct rasops_info *ri = cookie;
struct ffb_softc *sc = ri->ri_hw;
if (dst == src)
return;
if (src < 0) {
n += src;
src = 0;
}
if ((src + n) > ri->ri_rows)
n = ri->ri_rows - src;
if (dst < 0) {
n += dst;
dst = 0;
}
if ((dst + n) > ri->ri_rows)
n = ri->ri_rows - dst;
if (n <= 0)
return;
n *= ri->ri_font->fontheight;
src *= ri->ri_font->fontheight;
dst *= ri->ri_font->fontheight;
ffb_ras_fifo_wait(sc, 8);
FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_OLD | (FBC_ROP_OLD << 8));
FBC_WRITE(sc, FFB_FBC_DRAWOP, FBC_DRAWOP_VSCROLL);
FBC_WRITE(sc, FFB_FBC_BY, ri->ri_yorigin + src);
FBC_WRITE(sc, FFB_FBC_BX, ri->ri_xorigin);
FBC_WRITE(sc, FFB_FBC_DY, ri->ri_yorigin + dst);
FBC_WRITE(sc, FFB_FBC_DX, ri->ri_xorigin);
FBC_WRITE(sc, FFB_FBC_BH, n);
FBC_WRITE(sc, FFB_FBC_BW, ri->ri_emuwidth);
ffb_ras_wait(sc);
}
void
ffb_ras_setfg(sc, fg)
struct ffb_softc *sc;
int32_t fg;
{
ffb_ras_fifo_wait(sc, 1);
if (fg == sc->sc_fg_cache)
return;
sc->sc_fg_cache = fg;
FBC_WRITE(sc, FFB_FBC_FG, fg);
ffb_ras_wait(sc);
}

View File

@ -0,0 +1,133 @@
/* $NetBSD: ffb_mainbus.c,v 1.1 2003/05/23 06:51:16 petrov Exp $ */
/* $OpenBSD: creator_mainbus.c,v 1.4 2002/07/26 16:39:04 jason Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net),
* Federico G. Schwindt (fgsch@openbsd.org)
* 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 <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <machine/bus.h>
#include <machine/autoconf.h>
#include <machine/openfirm.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wscons_raster.h>
#include <dev/rasops/rasops.h>
#include <sparc64/dev/ffbreg.h>
#include <sparc64/dev/ffbvar.h>
int ffb_mainbus_match(struct device *, struct cfdata *, void *);
void ffb_mainbus_attach(struct device *, struct device *, void *);
CFATTACH_DECL(ffb_mainbus, sizeof(struct ffb_softc),
ffb_mainbus_match, ffb_mainbus_attach, NULL, NULL);
int
ffb_mainbus_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct mainbus_attach_args *ma = aux;
if (strcmp(ma->ma_name, "SUNW,ffb") == 0 ||
strcmp(ma->ma_name, "SUNW,afb") == 0)
return (1);
return (0);
}
void
ffb_mainbus_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct ffb_softc *sc = (struct ffb_softc *)self;
struct mainbus_attach_args *ma = aux;
extern int fbnode;
int i, nregs;
sc->sc_bt = ma->ma_bustag;
nregs = min(ma->ma_nreg, FFB_NREGS);
if (nregs < FFB_REG_DFB24) {
printf(": no dfb24 regs found\n");
goto fail1;
}
if (bus_space_map(sc->sc_bt, ma->ma_reg[FFB_REG_DFB24].ur_paddr,
ma->ma_reg[FFB_REG_DFB24].ur_len, BUS_SPACE_MAP_LINEAR,
&sc->sc_pixel_h)) {
printf(": failed to map dfb24\n");
goto fail1;
}
if (bus_space_map(sc->sc_bt, ma->ma_reg[FFB_REG_FBC].ur_paddr,
ma->ma_reg[FFB_REG_FBC].ur_len, 0, &sc->sc_fbc_h)) {
printf(": failed to map fbc\n");
goto fail;
}
for (i = 0; i < nregs; i++) {
sc->sc_addrs[i] = ma->ma_reg[i].ur_paddr;
sc->sc_sizes[i] = ma->ma_reg[i].ur_len;
}
sc->sc_nreg = nregs;
sc->sc_console = (fbnode == ma->ma_node);
sc->sc_node = ma->ma_node;
if (strcmp(ma->ma_name, "SUNW,afb") == 0)
sc->sc_type = FFB_AFB;
ffb_attach(sc);
return;
fail:
#if 0
if (sc->sc_fbc_h != 0)
bus_space_unmap(sc->sc_bt, sc->sc_fbc_h,
ma->ma_reg[FFB_REG_FBC].ur_len);
#endif
/* if (sc->sc_pixel_h != 0) */
bus_space_unmap(sc->sc_bt, sc->sc_pixel_h,
ma->ma_reg[FFB_REG_DFB24].ur_len);
fail1:
return;
}

View File

@ -0,0 +1,221 @@
/* $NetBSD: ffbreg.h,v 1.1 2003/05/23 06:51:16 petrov Exp $ */
/* $OpenBSD: creatorreg.h,v 1.5 2002/07/29 06:21:45 jason 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.
*/
/* Number of register sets */
#define FFB_NREGS 24
/* Register set numbers */
#define FFB_REG_PROM 0
#define FFB_REG_DAC 1
#define FFB_REG_FBC 2
#define FFB_REG_DFB8R 3
#define FFB_REG_DFB8G 4
#define FFB_REG_DFB8B 5
#define FFB_REG_DFB8X 6
#define FFB_REG_DFB24 7
#define FFB_REG_DFB32 8
#define FFB_REG_SFB8R 9
#define FFB_REG_SFB8G 10
#define FFB_REG_SFB8B 11
#define FFB_REG_SFB8X 12
#define FFB_REG_SFB32 13
#define FFB_REG_SFB64 14
#define FFB_REG_DFB422A 15
#define FFB_FBC_ALPHA 0x00c
#define FFB_FBC_RED 0x010
#define FFB_FBC_GREEN 0x014
#define FFB_FBC_BLUE 0x018
#define FFB_FBC_DEPTH 0x01c
#define FFB_FBC_Y 0x020
#define FFB_FBC_X 0x024
#define FFB_FBC_RYF 0x030
#define FFB_FBC_RXF 0x034
#define FFB_FBC_DMYF 0x040
#define FFB_FBC_DMXF 0x044
#define FFB_FBC_EBYI 0x050
#define FFB_FBC_EBXI 0x054
#define FFB_FBC_BY 0x060
#define FFB_FBC_BX 0x064
#define FFB_FBC_DY 0x068
#define FFB_FBC_DX 0x06c
#define FFB_FBC_BH 0x070
#define FFB_FBC_BW 0x074
#define FFB_FBC_SUVTX 0x100
#define FFB_FBC_PPC 0x200 /* pixel processor control */
#define FFB_FBC_WID 0x204
#define FFB_FBC_FG 0x208
#define FFB_FBC_BG 0x20c
#define FFB_FBC_CONSTY 0x210
#define FFB_FBC_CONSTZ 0x214
#define FFB_FBC_XCLIP 0x218
#define FFB_FBC_DCSS 0x21c
#define FFB_FBC_VCLIPMIN 0x220
#define FFB_FBC_VCLIPMAX 0x224
#define FFB_FBC_VCLIPZMIN 0x228
#define FFB_FBC_VCLIPZMAX 0x22c
#define FFB_FBC_DCSF 0x230
#define FFB_FBC_DCSB 0x234
#define FFB_FBC_DCZF 0x238
#define FFB_FBC_DCZB 0x23c
#define FFB_FBC_BLENDC 0x244
#define FFB_FBC_BLENDC1 0x248
#define FFB_FBC_BLENDC2 0x24c
#define FFB_FBC_FBRAMITC 0x250
#define FFB_FBC_FBC 0x254 /* Frame Buffer Control */
#define FFB_FBC_ROP 0x258 /* Raster OPeration */
#define FFB_FBC_CMP 0x25c /* Frame Buffer Compare */
#define FFB_FBC_MATCHAB 0x260 /* Buffer AB Match Mask */
#define FFB_FBC_MATCHC 0x264
#define FFB_FBC_MAGNAB 0x268 /* Buffer AB Magnitude Mask */
#define FFB_FBC_MAGNC 0x26c
#define FFB_FBC_FBCFG0 0x270
#define FFB_FBC_FBCFG1 0x274
#define FFB_FBC_FBCFG2 0x278
#define FFB_FBC_FBCFG3 0x27c
#define FFB_FBC_PPCFG 0x280
#define FFB_FBC_PICK 0x284
#define FFB_FBC_FILLMODE 0x288
#define FFB_FBC_FBRAMWAC 0x28c
#define FFB_FBC_PMASK 0x290 /* RGB Plane Mask */
#define FFB_FBC_XPMASK 0x294 /* X PlaneMask */
#define FFB_FBC_YPMASK 0x298
#define FFB_FBC_ZPMASK 0x29c
#define FFB_FBC_CLIP0MIN 0x2a0
#define FFB_FBC_CLIP0MAX 0x2a4
#define FFB_FBC_CLIP1MIN 0x2a8
#define FFB_FBC_CLIP1MAX 0x2ac
#define FFB_FBC_CLIP2MIN 0x2b0
#define FFB_FBC_CLIP2MAX 0x2b4
#define FFB_FBC_CLIP3MIN 0x2b8
#define FFB_FBC_CLIP3MAX 0x2bc
#define FFB_FBC_RAWBLEND2 0x2c0
#define FFB_FBC_RAWPREBLEND 0x2c4
#define FFB_FBC_RAWSTENCIL 0x2c8
#define FFB_FBC_RAWSTENCILCTL 0x2cc
#define FFB_FBC_THREEDRAM1 0x2d0
#define FFB_FBC_THREEDRAM2 0x2d4
#define FFB_FBC_PASSIN 0x2d8
#define FFB_FBC_RAWCLRDEPTH 0x2dc
#define FFB_FBC_RAWPMASK 0x2e0
#define FFB_FBC_RAWCSRC 0x2e4
#define FFB_FBC_RAWMATCH 0x2e8
#define FFB_FBC_RAWMAGN 0x2ec
#define FFB_FBC_RAWROPBLEND 0x2f0
#define FFB_FBC_RAWCMP 0x2f4
#define FFB_FBC_RAWWAC 0x2f8
#define FFB_FBC_FBRAMID 0x2fc
#define FFB_FBC_DRAWOP 0x300 /* Draw OPeration */
#define FFB_FBC_FONTLPAT 0x30c
#define FFB_FBC_FONTXY 0x314
#define FFB_FBC_FONTW 0x318 /* Font Width */
#define FFB_FBC_FONTINC 0x31c /* Font Increment */
#define FFB_FBC_FONT 0x320
#define FFB_FBC_BLEND2 0x330
#define FFB_FBC_PREBLEND 0x334
#define FFB_FBC_STENCIL 0x338
#define FFB_FBC_STENCILCTL 0x33c
#define FFB_FBC_DCSS1 0x350
#define FFB_FBC_DCSS2 0x354
#define FFB_FBC_DCSS3 0x358
#define FFB_FBC_WIDPMASK 0x35c
#define FFB_FBC_DCS2 0x360
#define FFB_FBC_DCS3 0x364
#define FFB_FBC_DCS4 0x368
#define FFB_FBC_DCD2 0x370
#define FFB_FBC_DCD3 0x374
#define FFB_FBC_DCD4 0x378
#define FFB_FBC_PATTERN 0x380
#define FFB_FBC_DEVID 0x800
#define FFB_FBC_UCSR 0x900 /* User Control & Status */
#define FFB_FBC_MER 0x980
#define FFB_FBC_WB_A 0x20000000
#define FFB_FBC_WM_COMBINED 0x00080000
#define FFB_FBC_RB_A 0x00004000
#define FFB_FBC_SB_BOTH 0x00003000
#define FFB_FBC_ZE_OFF 0x00000400
#define FFB_FBC_YE_OFF 0x00000100
#define FFB_FBC_XE_ON 0x00000080
#define FFB_FBC_XE_OFF 0x00000040
#define FFB_FBC_RGBE_ON 0x0000002a
#define FFB_FBC_RGBE_MASK 0x0000003f
#define FBC_PPC_FW_DIS 0x00800000 /* force wid disable */
#define FBC_PPC_FW_ENA 0x00c00000 /* force wid enable */
#define FBC_PPC_ACE_DIS 0x00040000 /* aux clip disable */
#define FBC_PPC_ACE_AUXSUB 0x00080000 /* aux clip add */
#define FBC_PPC_ACE_AUXADD 0x000c0000 /* aux clip subtract */
#define FBC_PPC_DCE_DIS 0x00020000 /* depth cue disable */
#define FBC_PPC_DCE_ENA 0x00020000 /* depth cue enable */
#define FBC_PPC_ABE_DIS 0x00008000 /* alpha blend disable */
#define FBC_PPC_ABE_ENA 0x0000c000 /* alpha blend enable */
#define FBC_PPC_VCE_DIS 0x00001000 /* view clip disable */
#define FBC_PPC_VCE_2D 0x00002000 /* view clip 2d */
#define FBC_PPC_VCE_3D 0x00003000 /* view clip 3d */
#define FBC_PPC_APE_DIS 0x00000800 /* area pattern disable */
#define FBC_PPC_APE_ENA 0x00000c00 /* area pattern enable */
#define FBC_PPC_TBE_OPAQUE 0x00000200 /* opaque background */
#define FBC_PPC_TBE_TRANSPAR 0x00000300 /* transparent background */
#define FBC_PPC_ZS_VAR 0x00000080 /* z source ??? */
#define FBC_PPC_ZS_CONST 0x000000c0 /* z source ??? */
#define FBC_PPC_YS_VAR 0x00000020 /* y source ??? */
#define FBC_PPC_YS_CONST 0x00000030 /* y source ??? */
#define FBC_PPC_XS_WID 0x00000004 /* x source ??? */
#define FBC_PPC_XS_VAR 0x00000008 /* x source ??? */
#define FBC_PPC_XS_CONST 0x0000000c /* x source ??? */
#define FBC_PPC_CS_VAR 0x00000002 /* color source ??? */
#define FBC_PPC_CS_CONST 0x00000003 /* color source ??? */
#define FBC_ROP_NEW 0x83
#define FBC_ROP_OLD 0x85
#define FBC_UCSR_FIFO_MASK 0x00000fff
#define FBC_UCSR_FB_BUSY 0x01000000
#define FBC_UCSR_RP_BUSY 0x02000000
#define FBC_UCSR_READ_ERR 0x40000000
#define FBC_UCSR_FIFO_OVFL 0x80000000
#define FBC_DRAWOP_DOT 0x00
#define FBC_DRAWOP_AADOT 0x01
#define FBC_DRAWOP_BRLINECAP 0x02
#define FBC_DRAWOP_BRLINEOPEN 0x03
#define FBC_DRAWOP_DDLINE 0x04
#define FBC_DRAWOP_AALINE 0x05
#define FBC_DRAWOP_TRIANGLE 0x06
#define FBC_DRAWOP_POLYGON 0x07
#define FBC_DRAWOP_RECTANGLE 0x08
#define FBC_DRAWOP_FASTFILL 0x09
#define FBC_DRAWOP_BCOPY 0x0a /* block copy: not implemented */
#define FBC_DRAWOP_VSCROLL 0x0b /* vertical scroll */

View File

@ -0,0 +1,63 @@
/* $NetBSD: ffbvar.h,v 1.1 2003/05/23 06:51:16 petrov Exp $ */
/* $OpenBSD: creatorvar.h,v 1.6 2002/07/30 19:48:15 jason Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net),
* Federico G. Schwindt (fgsch@openbsd.org)
* 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.
*/
#define FFB_CREATOR 0
#define FFB_AFB 1
#define FFB_CFFLAG_NOACCEL 0x1
struct ffb_softc {
struct device sc_dv;
bus_space_tag_t sc_bt;
bus_space_handle_t sc_pixel_h;
bus_space_handle_t sc_fbc_h;
bus_addr_t sc_addrs[FFB_NREGS];
bus_size_t sc_sizes[FFB_NREGS];
int sc_height, sc_width, sc_linebytes, sc_depth;
int sc_nscreens, sc_nreg;
int sc_console;
int sc_node;
int sc_type;
u_int sc_mode;
struct rasops_info sc_rasops;
int32_t sc_fifo_cache, sc_fg_cache;
};
#define FBC_WRITE(sc,r,v) \
bus_space_write_4((sc)->sc_bt, (sc)->sc_fbc_h, (r), (v))
#define FBC_READ(sc,r) \
bus_space_read_4((sc)->sc_bt, (sc)->sc_fbc_h, (r))
void ffb_attach(struct ffb_softc *);