- Rework copycols() with SFB ASIC calls.

This commit is contained in:
nisimura 1999-06-11 00:56:09 +00:00
parent 033ffd1215
commit f4be9af151
1 changed files with 190 additions and 103 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: sfb.c,v 1.15 1999/05/07 08:00:31 nisimura Exp $ */
/* $NetBSD: sfb.c,v 1.16 1999/06/11 00:56:09 nisimura Exp $ */
/*
* Copyright (c) 1998 Tohru Nishimura. All rights reserved.
* Copyright (c) 1998, 1999 Tohru Nishimura. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: sfb.c,v 1.15 1999/05/07 08:00:31 nisimura Exp $");
__KERNEL_RCSID(0, "$NetBSD: sfb.c,v 1.16 1999/06/11 00:56:09 nisimura Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -57,8 +57,6 @@ __KERNEL_RCSID(0, "$NetBSD: sfb.c,v 1.15 1999/05/07 08:00:31 nisimura Exp $");
#include <uvm/uvm_extern.h>
/* XXX BUS'IFYING XXX */
#if defined(pmax)
#define machine_btop(x) mips_btop(x)
#define MACHINE_KSEG0_TO_PHYS(x) MIPS_KSEG1_TO_PHYS(x)
@ -82,15 +80,26 @@ __KERNEL_RCSID(0, "$NetBSD: sfb.c,v 1.15 1999/05/07 08:00:31 nisimura Exp $");
* } bt_lo;
* ...
* Although HX has single Bt459, 32bit R/W can be done w/o any trouble.
* struct bt459reg {
* u_int32_t bt_lo;
* u_int32_t bt_hi;
* u_int32_t bt_reg;
* u_int32_t bt_cmap;
* };
*
*/
struct bt459reg {
u_int32_t bt_lo;
u_int32_t bt_hi;
u_int32_t bt_reg;
u_int32_t bt_cmap;
};
/* XXX XXX XXX */
#define bt_lo 0
#define bt_hi 1
#define bt_reg 2
#define bt_cmap 3
#define REG(base, index) *((u_int32_t *)(base) + (index))
#define SELECT(vdac, regno) do { \
REG(vdac, bt_lo) = ((regno) & 0x00ff); \
REG(vdac, bt_hi) = ((regno) & 0x0f00) >> 8; \
tc_wmb(); \
} while (0)
struct fb_devconfig {
vaddr_t dc_vaddr; /* memory space virtual base address */
@ -216,13 +225,6 @@ static int get_cursor __P((struct sfb_softc *, struct wsdisplay_cursor *));
static void set_curpos __P((struct sfb_softc *, struct wsdisplay_curpos *));
static void bt459_set_curpos __P((struct sfb_softc *));
/* XXX XXX XXX */
#define BT459_SELECT(vdac, regno) do { \
vdac->bt_lo = (regno) & 0x00ff; \
vdac->bt_hi = ((regno)& 0x0f00) >> 8; \
tc_wmb(); \
} while (0)
/* XXX XXX XXX */
/*
* Compose 2 bit/pixel cursor image. Bit order will be reversed.
@ -529,7 +531,7 @@ sfbintr(arg)
struct sfb_softc *sc = arg;
caddr_t sfbbase = (caddr_t)sc->sc_dc->dc_vaddr;
caddr_t sfbasic = sfbbase + SFB_ASIC_OFFSET;
struct bt459reg *vdac;
caddr_t vdac;
int v;
*(u_int32_t *)(sfbasic + SFB_ASIC_CLEAR_INTR) = 0;
@ -543,20 +545,20 @@ sfbintr(arg)
sc->sc_changed = 0;
if (v & DATA_ENB_CHANGED) {
BT459_SELECT(vdac, BT459_REG_CCR);
vdac->bt_reg = (sc->sc_curenb) ? 0xc0 : 0x00;
SELECT(vdac, BT459_REG_CCR);
REG(vdac, bt_reg) = (sc->sc_curenb) ? 0xc0 : 0x00;
}
if (v & DATA_CURCMAP_CHANGED) {
u_int8_t *cp = sc->sc_cursor.cc_color;
BT459_SELECT(vdac, BT459_REG_CCOLOR_2);
vdac->bt_reg = cp[1]; tc_wmb();
vdac->bt_reg = cp[3]; tc_wmb();
vdac->bt_reg = cp[5]; tc_wmb();
SELECT(vdac, BT459_REG_CCOLOR_2);
REG(vdac, bt_reg) = cp[1]; tc_wmb();
REG(vdac, bt_reg) = cp[3]; tc_wmb();
REG(vdac, bt_reg) = cp[5]; tc_wmb();
vdac->bt_reg = cp[0]; tc_wmb();
vdac->bt_reg = cp[2]; tc_wmb();
vdac->bt_reg = cp[4]; tc_wmb();
REG(vdac, bt_reg) = cp[0]; tc_wmb();
REG(vdac, bt_reg) = cp[2]; tc_wmb();
REG(vdac, bt_reg) = cp[4]; tc_wmb();
}
if (v & DATA_CURSHAPE_CHANGED) {
u_int8_t *ip, *mp, img, msk;
@ -567,29 +569,29 @@ sfbintr(arg)
mp = (u_int8_t *)(sc->sc_cursor.cc_image + CURSOR_MAX_SIZE);
bcnt = 0;
BT459_SELECT(vdac, BT459_REG_CRAM_BASE+0);
SELECT(vdac, BT459_REG_CRAM_BASE+0);
/* 64 pixel scan line is consisted with 16 byte cursor ram */
while (bcnt < sc->sc_cursor.cc_size.y * 16) {
/* pad right half 32 pixel when smaller than 33 */
if ((bcnt & 0x8) && sc->sc_cursor.cc_size.x < 33) {
vdac->bt_reg = 0; tc_wmb();
vdac->bt_reg = 0; tc_wmb();
REG(vdac, bt_reg) = 0; tc_wmb();
REG(vdac, bt_reg) = 0; tc_wmb();
}
else {
img = *ip++;
msk = *mp++;
img &= msk; /* cookie off image */
u = (msk & 0x0f) << 4 | (img & 0x0f);
vdac->bt_reg = shuffle[u]; tc_wmb();
REG(vdac, bt_reg) = shuffle[u]; tc_wmb();
u = (msk & 0xf0) | (img & 0xf0) >> 4;
vdac->bt_reg = shuffle[u]; tc_wmb();
REG(vdac, bt_reg) = shuffle[u]; tc_wmb();
}
bcnt += 2;
}
/* pad unoccupied scan lines */
while (bcnt < CURSOR_MAX_SIZE * 16) {
vdac->bt_reg = 0; tc_wmb();
vdac->bt_reg = 0; tc_wmb();
REG(vdac, bt_reg) = 0; tc_wmb();
REG(vdac, bt_reg) = 0; tc_wmb();
bcnt += 2;
}
}
@ -597,11 +599,11 @@ sfbintr(arg)
struct hwcmap256 *cm = &sc->sc_cmap;
int index;
BT459_SELECT(vdac, 0);
SELECT(vdac, 0);
for (index = 0; index < CMAP_SIZE; index++) {
vdac->bt_cmap = cm->r[index]; tc_wmb();
vdac->bt_cmap = cm->g[index]; tc_wmb();
vdac->bt_cmap = cm->b[index]; tc_wmb();
REG(vdac, bt_cmap) = cm->r[index]; tc_wmb();
REG(vdac, bt_cmap) = cm->g[index]; tc_wmb();
REG(vdac, bt_cmap) = cm->b[index]; tc_wmb();
}
}
return (1);
@ -612,7 +614,7 @@ sfbinit(dc)
struct fb_devconfig *dc;
{
caddr_t sfbasic = (caddr_t)(dc->dc_vaddr + SFB_ASIC_OFFSET);
struct bt459reg *vdac = (void *)(dc->dc_vaddr + SFB_RAMDAC_OFFSET);
caddr_t vdac = (void *)(dc->dc_vaddr + SFB_RAMDAC_OFFSET);
int i;
*(u_int32_t *)(sfbasic + SFB_ASIC_VIDEO_VALID) = 0;
@ -623,67 +625,67 @@ sfbinit(dc)
*(u_int32_t *)(sfbasic + 0x180000) = 0; /* Bt459 reset */
BT459_SELECT(vdac, BT459_REG_COMMAND_0);
vdac->bt_reg = 0x40; /* CMD0 */ tc_wmb();
vdac->bt_reg = 0x0; /* CMD1 */ tc_wmb();
vdac->bt_reg = 0xc0; /* CMD2 */ tc_wmb();
vdac->bt_reg = 0xff; /* PRM */ tc_wmb();
vdac->bt_reg = 0; /* 205 */ tc_wmb();
vdac->bt_reg = 0x0; /* PBM */ tc_wmb();
vdac->bt_reg = 0; /* 207 */ tc_wmb();
vdac->bt_reg = 0x0; /* ORM */ tc_wmb();
vdac->bt_reg = 0x0; /* OBM */ tc_wmb();
vdac->bt_reg = 0x0; /* ILV */ tc_wmb();
vdac->bt_reg = 0x0; /* TEST */ tc_wmb();
SELECT(vdac, BT459_REG_COMMAND_0);
REG(vdac, bt_reg) = 0x40; /* CMD0 */ tc_wmb();
REG(vdac, bt_reg) = 0x0; /* CMD1 */ tc_wmb();
REG(vdac, bt_reg) = 0xc0; /* CMD2 */ tc_wmb();
REG(vdac, bt_reg) = 0xff; /* PRM */ tc_wmb();
REG(vdac, bt_reg) = 0; /* 205 */ tc_wmb();
REG(vdac, bt_reg) = 0x0; /* PBM */ tc_wmb();
REG(vdac, bt_reg) = 0; /* 207 */ tc_wmb();
REG(vdac, bt_reg) = 0x0; /* ORM */ tc_wmb();
REG(vdac, bt_reg) = 0x0; /* OBM */ tc_wmb();
REG(vdac, bt_reg) = 0x0; /* ILV */ tc_wmb();
REG(vdac, bt_reg) = 0x0; /* TEST */ tc_wmb();
BT459_SELECT(vdac, BT459_REG_CCR);
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
vdac->bt_reg = 0x0; tc_wmb();
SELECT(vdac, BT459_REG_CCR);
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
REG(vdac, bt_reg) = 0x0; tc_wmb();
/* build sane colormap */
BT459_SELECT(vdac, 0);
vdac->bt_cmap = 0; tc_wmb();
vdac->bt_cmap = 0; tc_wmb();
vdac->bt_cmap = 0; tc_wmb();
SELECT(vdac, 0);
REG(vdac, bt_cmap) = 0; tc_wmb();
REG(vdac, bt_cmap) = 0; tc_wmb();
REG(vdac, bt_cmap) = 0; tc_wmb();
for (i = 1; i < CMAP_SIZE; i++) {
vdac->bt_cmap = 0xff; tc_wmb();
vdac->bt_cmap = 0xff; tc_wmb();
vdac->bt_cmap = 0xff; tc_wmb();
REG(vdac, bt_cmap) = 0xff; tc_wmb();
REG(vdac, bt_cmap) = 0xff; tc_wmb();
REG(vdac, bt_cmap) = 0xff; tc_wmb();
}
/* clear out cursor image */
BT459_SELECT(vdac, BT459_REG_CRAM_BASE);
SELECT(vdac, BT459_REG_CRAM_BASE);
for (i = 0; i < 1024; i++)
vdac->bt_reg = 0xff; tc_wmb();
REG(vdac, bt_reg) = 0xff; tc_wmb();
/*
* 2 bit/pixel cursor. Assign MSB for cursor mask and LSB for
* cursor image. CCOLOR_2 for mask color, while CCOLOR_3 for
* image color. CCOLOR_1 will be never used.
*/
BT459_SELECT(vdac, BT459_REG_CCOLOR_1);
vdac->bt_reg = 0xff; tc_wmb();
vdac->bt_reg = 0xff; tc_wmb();
vdac->bt_reg = 0xff; tc_wmb();
SELECT(vdac, BT459_REG_CCOLOR_1);
REG(vdac, bt_reg) = 0xff; tc_wmb();
REG(vdac, bt_reg) = 0xff; tc_wmb();
REG(vdac, bt_reg) = 0xff; tc_wmb();
vdac->bt_reg = 0; tc_wmb();
vdac->bt_reg = 0; tc_wmb();
vdac->bt_reg = 0; tc_wmb();
REG(vdac, bt_reg) = 0; tc_wmb();
REG(vdac, bt_reg) = 0; tc_wmb();
REG(vdac, bt_reg) = 0; tc_wmb();
vdac->bt_reg = 0xff; tc_wmb();
vdac->bt_reg = 0xff; tc_wmb();
vdac->bt_reg = 0xff; tc_wmb();
REG(vdac, bt_reg) = 0xff; tc_wmb();
REG(vdac, bt_reg) = 0xff; tc_wmb();
REG(vdac, bt_reg) = 0xff; tc_wmb();
}
static int
@ -824,7 +826,7 @@ bt459_set_curpos(sc)
struct sfb_softc *sc;
{
caddr_t sfbbase = (caddr_t)sc->sc_dc->dc_vaddr;
struct bt459reg *vdac = (void *)(sfbbase + SFB_RAMDAC_OFFSET);
caddr_t vdac = (void *)(sfbbase + SFB_RAMDAC_OFFSET);
int x, y, s;
x = sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x;
@ -835,11 +837,11 @@ bt459_set_curpos(sc)
s = spltty();
BT459_SELECT(vdac, BT459_REG_CURSOR_X_LOW);
vdac->bt_reg = x; tc_wmb();
vdac->bt_reg = x >> 8; tc_wmb();
vdac->bt_reg = y; tc_wmb();
vdac->bt_reg = y >> 8; tc_wmb();
SELECT(vdac, BT459_REG_CURSOR_X_LOW);
REG(vdac, bt_reg) = x; tc_wmb();
REG(vdac, bt_reg) = x >> 8; tc_wmb();
REG(vdac, bt_reg) = y; tc_wmb();
REG(vdac, bt_reg) = y >> 8; tc_wmb();
splx(s);
}
@ -935,7 +937,7 @@ sfb_putchar(id, row, col, uc, attr)
}
/*
* Copy columns (characters) in a row (line).
* Copy characters in a line.
*/
void
sfb_copycols(id, row, srccol, dstcol, ncols)
@ -943,20 +945,105 @@ sfb_copycols(id, row, srccol, dstcol, ncols)
int row, srccol, dstcol, ncols;
{
struct rcons *rc = id;
int y, srcx, dstx, nx;
struct raster *rap = rc->rc_sp;
caddr_t sp, dp, basex, sfb;
int scanspan, height, width, aligns, alignd, w, y;
u_int32_t lmasks, rmasks, lmaskd, rmaskd;
scanspan = rap->linelongs * 4;
y = rc->rc_yorigin + rc->rc_font->height * row;
srcx = rc->rc_xorigin + rc->rc_font->width * srccol;
dstx = rc->rc_xorigin + rc->rc_font->width * dstcol;
nx = rc->rc_font->width * ncols;
basex = (caddr_t)rap->pixels + y * scanspan + rc->rc_xorigin;
height = rc->rc_font->height;
w = rc->rc_font->width * ncols;
raster_op(rc->rc_sp, dstx, y,
nx, rc->rc_font->height, RAS_SRC,
rc->rc_sp, srcx, y);
dp = basex + rc->rc_font->width * dstcol;
alignd = (long)dp & SFBALIGNMASK;
dp -= alignd;
width = w + alignd;
lmaskd = SFBSTIPPLEALL1 << alignd;
rmaskd = SFBSTIPPLEALL1 >> (-width & SFBSTIPPLEBITMASK);
sp = basex + rc->rc_font->width * srccol;
aligns = (long)sp & SFBALIGNMASK;
sp -= aligns;
width = w + aligns;
lmasks = SFBSTIPPLEALL1 << aligns;
rmasks = SFBSTIPPLEALL1 >> (-width & SFBSTIPPLEBITMASK);
width += (-width & SFBSTIPPLEBITMASK);
sfb = rap->data;
*(u_int32_t *)(sfb + SFB_ASIC_MODE) = MODE_COPY;
*(u_int32_t *)(sfb + SFB_ASIC_PLANEMASK) = ~0;
*(u_int32_t *)(sfb + SFB_ASIC_PIXELSHIFT) = alignd - aligns;
if (width <= SFBSTIPPLEBITS) {
while (height > 0) {
*(u_int32_t *)sp = lmasks & rmasks;
*(u_int32_t *)dp = lmaskd & rmaskd;
sp += scanspan;
dp += scanspan;
height--;
}
}
/* copy forward (left-to-right) */
else if (dstcol > srccol || srccol + ncols >= dstcol) {
caddr_t sq = sp, dq = dp;
w = width;
while (height > 0) {
*(u_int32_t *)sp = lmasks;
*(u_int32_t *)dp = lmaskd;
width -= 2 * SFBSTIPPLEBITS;
while (width > 0) {
sp += SFBSTIPPLEBYTESDONE;
dp += SFBSTIPPLEBYTESDONE;
*(u_int32_t *)sp = SFBSTIPPLEALL1;
*(u_int32_t *)dp = SFBSTIPPLEALL1;
width -= SFBSTIPPLEBITS;
}
sp += SFBSTIPPLEBYTESDONE;
dp += SFBSTIPPLEBYTESDONE;
*(u_int32_t *)sp = rmasks;
*(u_int32_t *)dp = rmaskd;
sp = (sq += scanspan);
dp = (dq += scanspan);
width = w;
height--;
}
}
/* copy backward (right-to-left) */
else {
caddr_t sq = (sp += width), dq = (dp += width);
w = width;
while (height > 0) {
*(u_int32_t *)sp = rmasks;
*(u_int32_t *)dp = rmaskd;
width -= 2 * SFBSTIPPLEBITS;
while (width > 0) {
sp -= SFBSTIPPLEBYTESDONE;
dp -= SFBSTIPPLEBYTESDONE;
*(u_int32_t *)sp = SFBSTIPPLEALL1;
*(u_int32_t *)dp = SFBSTIPPLEALL1;
width -= SFBSTIPPLEBITS;
}
sp -= SFBSTIPPLEBYTESDONE;
dp -= SFBSTIPPLEBYTESDONE;
*(u_int32_t *)sp = lmasks;
*(u_int32_t *)dp = lmaskd;
sp = (sq += scanspan);
dp = (dq += scanspan);
width = w;
height--;
}
}
*(u_int32_t *)(sfb + SFB_ASIC_MODE) = MODE_SIMPLE;
}
/*
* Clear columns (characters) in a row (line).
* Clear characters in a line.
*/
void
sfb_erasecols(id, row, startcol, ncols, fillattr)
@ -1016,7 +1103,7 @@ sfb_erasecols(id, row, startcol, ncols, fillattr)
}
/*
* Copy rows (lines).
* Copy lines.
*/
void
sfb_copyrows(id, srcrow, dstrow, nrows)
@ -1077,7 +1164,7 @@ sfb_copyrows(id, srcrow, dstrow, nrows)
}
/*
* Erase rows (lines).
* Erase characters in a line.
*/
void
sfb_eraserows(id, startrow, nrows, fillattr)