- virtual TEXT vram implimentation.

- optimize scroll.
- hardware accelerator hooking mechanism (initianly, maybe change..)
- multiscreen (some bugs, so currently disabled)
- if you want disable above codes, #define HPCFB_DISABLE.
This commit is contained in:
sato 2000-04-03 03:35:37 +00:00
parent 7f7027bb59
commit 1e2f627e0b
4 changed files with 688 additions and 25 deletions

View File

@ -1,8 +1,10 @@
/* $NetBSD: hpcfb.c,v 1.2 2000/03/20 10:47:34 takemura Exp $ */ /* $NetBSD: hpcfb.c,v 1.3 2000/04/03 03:35:37 sato Exp $ */
/*- /*-
* Copyright (c) 1999 * Copyright (c) 1999
* Shin Takemura and PocketBSD Project. All rights reserved. * Shin Takemura and PocketBSD Project. All rights reserved.
* Copyright (c) 2000
* SATO Kazumi. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -33,12 +35,17 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
*/ */
/*
* multiscreen, virtual text vram and hpcfb_emulops functions
* written by SATO Kazumi.
*/
#define FBDEBUG #define FBDEBUG
static const char _copyright[] __attribute__ ((unused)) = static const char _copyright[] __attribute__ ((unused)) =
"Copyright (c) 1999 Shin Takemura. All rights reserved."; "Copyright (c) 1999 Shin Takemura. All rights reserved.";
static const char _rcsid[] __attribute__ ((unused)) = static const char _rcsid[] __attribute__ ((unused)) =
"$Id: hpcfb.c,v 1.2 2000/03/20 10:47:34 takemura Exp $"; "$Id: hpcfb.c,v 1.3 2000/04/03 03:35:37 sato Exp $";
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -75,20 +82,63 @@ int hpcfb_debug = 0;
#define DPRINTF(arg) #define DPRINTF(arg)
#endif #endif
#ifndef HPCFB_DISABLE
#define HPCFB_HOOK
#define HPCFB_TVRAM
#define HPCFB_REDRAW
/*
#define HPCFB_MULTI
#define HPCFB_BSTORE
*/
#if defined(HPCFB_MULTI) || defined(HPCFB_REDRAW)
#define HPCFB_TVRAM
#endif
#if defined(HPCFB_MULTI) || defined(HPCFB_REDRAW) || defined(HPCFB_TVRAM)
#define HPCFB_HOOK
#endif
#endif /* HPCFBRASOPS_DISABLE */
#ifdef HPCFB_TVRAM
struct hpcfb_vchar {
u_int c;
long attr;
};
#endif /* HPCFB_TVRAM */
struct hpcfb_devconfig { struct hpcfb_devconfig {
struct rasops_info dc_rinfo; /* rasops infomation */ struct rasops_info dc_rinfo; /* rasops infomation */
int dc_blanked; /* currently had video disabled */ int dc_blanked; /* currently had video disabled */
#ifdef HPCFB_TVRAM
struct hpcfb_softc *dc_sc;
int dc_rows;
int dc_cols;
struct hpcfb_vchar *dc_tvram;
int dc_curx;
int dc_cury;
int dc_state;
#define HPCFB_DC_DRAWING 0x01
#define HPCFB_DC_SCROLLPENDING 0x02
#ifdef HPCFB_MULTI
int dc_scrno;
u_char *dc_bstore;
int dc_memsize;
#endif /* HPCFB_MULTI */
#endif /* HPCFB_TVRAM */
}; };
#define HPCFB_MAX_SCREEN 5
struct hpcfb_softc { struct hpcfb_softc {
struct device sc_dev; struct device sc_dev;
struct hpcfb_devconfig *sc_dc; /* device configuration */ struct hpcfb_devconfig *sc_dc; /* device configuration */
#ifdef HPCFB_MULTI
struct hpcfb_devconfig *screens[HPCFB_MAX_SCREEN];
#endif /* HPCFB_MULTI */
const struct hpcfb_accessops *sc_accessops; const struct hpcfb_accessops *sc_accessops;
void *sc_accessctx; void *sc_accessctx;
int nscreens; int nscreens;
}; };
/* /*
* function prototypes * function prototypes
*/ */
@ -108,6 +158,33 @@ static int hpcfb_show_screen __P((void *, void *, int,
static int pow __P((int, int)); static int pow __P((int, int));
#ifdef HPCFB_HOOK
void hpcfb_cursor __P((void *c, int on, int row, int col));
int hpcfb_mapchar __P((void *, int, unsigned int *));
void hpcfb_putchar __P((void *c, int row, int col, u_int uc, long attr));
void hpcfb_copycols __P((void *c, int row, int srccol,
int dstcol, int ncols));
void hpcfb_erasecols __P((void *c, int row, int startcol,
int ncols, long attr));
void hpcfb_redraw __P((void *c, int row, int nrows));
void hpcfb_copyrows __P((void *c, int srcrow, int dstrow, int nrows));
void hpcfb_eraserows __P((void *c, int row, int nrows, long attr));
int hpcfb_alloc_attr __P((void *c, int fg, int bg, int flags, long *attr));
#endif /* HPCFB_HOOK */
#ifdef HPCFB_HOOK
struct wsdisplay_emulops hpcfb_emulops = {
hpcfb_cursor,
hpcfb_mapchar,
hpcfb_putchar,
hpcfb_copycols,
hpcfb_erasecols,
hpcfb_copyrows,
hpcfb_eraserows,
hpcfb_alloc_attr
};
#endif /* HPCFB_HOOK */
/* /*
* static variables * static variables
*/ */
@ -118,7 +195,11 @@ struct cfattach hpcfb_ca = {
struct wsscreen_descr hpcfb_stdscreen = { struct wsscreen_descr hpcfb_stdscreen = {
"std", "std",
0, 0, /* will be filled in -- XXX shouldn't, it's global */ 0, 0, /* will be filled in -- XXX shouldn't, it's global */
#ifdef HPCFB_HOOK
&hpcfb_emulops, /* XXX */
#else /* HPCFB_HOOK */
0, 0,
#endif /* HPCFB_HOOK */
0, 0, 0, 0,
WSSCREEN_REVERSE WSSCREEN_REVERSE
}; };
@ -142,9 +223,25 @@ struct wsdisplay_accessops hpcfb_accessops = {
0 /* load_font */ 0 /* load_font */
}; };
#ifdef HPCFB_TVRAM
void hpcfb_tv_putchar __P((struct hpcfb_devconfig *, int, int, u_int, long));
void hpcfb_tv_copycols __P((struct hpcfb_devconfig *, int, int, int, int));
void hpcfb_tv_erasecols __P((struct hpcfb_devconfig *, int, int, int, long));
void hpcfb_tv_copyrows __P((struct hpcfb_devconfig *, int, int, int));
void hpcfb_tv_eraserows __P((struct hpcfb_devconfig *, int, int, long));
#endif /* HPCFB_TVRAM */
#ifdef HPCFB_HOOK
struct wsdisplay_emulops rasops_emul;
#endif /* HPCFB_HOOK */
static int hpcfbconsole, hpcfb_console_type; static int hpcfbconsole, hpcfb_console_type;
struct hpcfb_devconfig hpcfb_console_dc; struct hpcfb_devconfig hpcfb_console_dc;
struct wsscreen_descr hpcfb_console_screen; struct wsscreen_descr hpcfb_console_wsscreen;
#ifdef HPCFB_TVRAM
struct hpcfb_vchar hpcfb_console_tvram[200*200];
#endif /* HPCFB_TVRAM */
/* /*
* function bodies * function bodies
@ -185,27 +282,66 @@ hpcfbattach(parent, self, aux)
sc->sc_accessctx = ha->ha_accessctx; sc->sc_accessctx = ha->ha_accessctx;
if (hpcfbconsole) { if (hpcfbconsole) {
#ifdef HPCFB_MULTI
sc->screens[0] =
#endif /* HPCFB_MULTI */
sc->sc_dc = &hpcfb_console_dc; sc->sc_dc = &hpcfb_console_dc;
sc->nscreens = 1; sc->nscreens = 1;
#ifdef HPCFB_TVRAM
hpcfb_console_dc.dc_sc = sc;
#endif /* HPCFB_TVRAM */
} else { } else {
#ifdef HPCFB_MULTI
sc->screens[0] =
#endif /* HPCFB_MULTI */
sc->sc_dc = (struct hpcfb_devconfig *) sc->sc_dc = (struct hpcfb_devconfig *)
malloc(sizeof(struct hpcfb_devconfig), M_DEVBUF, M_WAITOK); malloc(sizeof(struct hpcfb_devconfig), M_DEVBUF, M_WAITOK);
bzero(sc->sc_dc, sizeof(struct hpcfb_devconfig)); bzero(sc->sc_dc, sizeof(struct hpcfb_devconfig));
if (hpcfb_init(&ha->ha_fbconflist[0], sc->sc_dc) != 0) { if (hpcfb_init(&ha->ha_fbconflist[0], sc->sc_dc) != 0) {
return; return;
} }
#ifdef HPCFB_TVRAM
sc->sc_dc->dc_sc = sc;
#endif /* HPCFB_TVRAM */
} }
#ifdef HPCFB_TVRAM
hpcfb_stdscreen.textops = &sc->sc_dc->dc_rinfo.ri_ops; hpcfb_stdscreen.nrows = sc->sc_dc->dc_rows;
hpcfb_stdscreen.ncols = sc->sc_dc->dc_cols;
#else /* HPCFB_TVRAM */
hpcfb_stdscreen.nrows = sc->sc_dc->dc_rinfo.ri_rows; hpcfb_stdscreen.nrows = sc->sc_dc->dc_rinfo.ri_rows;
hpcfb_stdscreen.ncols = sc->sc_dc->dc_rinfo.ri_cols; hpcfb_stdscreen.ncols = sc->sc_dc->dc_rinfo.ri_cols;
#endif /* HPCFB_TVRAM */
hpcfb_stdscreen.capabilities = sc->sc_dc->dc_rinfo.ri_caps; hpcfb_stdscreen.capabilities = sc->sc_dc->dc_rinfo.ri_caps;
#ifndef HPCFB_HOOK
hpcfb_stdscreen.textops = &sc->sc_dc->dc_rinfo.ri_ops;
#endif /* HPCFB_HOOK */
#ifdef HPCFB_HOOK
printf(": hpcrasops %dx%d pixels, %d colors, %dx%d chars:",
sc->sc_dc->dc_rinfo.ri_width,
sc->sc_dc->dc_rinfo.ri_height,
pow(2, sc->sc_dc->dc_rinfo.ri_depth),
sc->sc_dc->dc_rinfo.ri_cols,
sc->sc_dc->dc_rinfo.ri_rows);
#else /* HPCFB_HOOK */
printf(": rasops %dx%d pixels, %d colors, %dx%d chars", printf(": rasops %dx%d pixels, %d colors, %dx%d chars",
sc->sc_dc->dc_rinfo.ri_width, sc->sc_dc->dc_rinfo.ri_width,
sc->sc_dc->dc_rinfo.ri_height, sc->sc_dc->dc_rinfo.ri_height,
pow(2, sc->sc_dc->dc_rinfo.ri_depth), pow(2, sc->sc_dc->dc_rinfo.ri_depth),
sc->sc_dc->dc_rinfo.ri_cols, sc->sc_dc->dc_rinfo.ri_cols,
sc->sc_dc->dc_rinfo.ri_rows); sc->sc_dc->dc_rinfo.ri_rows);
#endif /* HPCFB_HOOK */
#ifdef HPCFB_TVRAM
printf(" tvram");
#endif /* HPCFB_TVRAM */
#ifdef HPCFB_REDRAW
printf(" redraw");
#endif /* HPCFB_REDRAW */
#ifdef HPCFB_MULTI
printf(" multi");
#endif /* HPCFB_MULTI */
#ifdef HPCFB_BSTORE
printf(" bstore");
#endif /* HPCFB_BSTORE */
printf("\n"); printf("\n");
wa.console = hpcfbconsole; wa.console = hpcfbconsole;
@ -254,15 +390,28 @@ hpcfb_cnattach(iot, iobase, type, check)
return (ENXIO); return (ENXIO);
} }
hpcfb_console_screen = hpcfb_stdscreen; hpcfb_console_wsscreen = hpcfb_stdscreen;
hpcfb_console_screen.textops = &hpcfb_console_dc.dc_rinfo.ri_ops; #ifdef HPCFB_TVRAM
hpcfb_console_screen.nrows = hpcfb_console_dc.dc_rinfo.ri_rows; hpcfb_console_wsscreen.nrows = hpcfb_console_dc.dc_rows;
hpcfb_console_screen.ncols = hpcfb_console_dc.dc_rinfo.ri_cols; hpcfb_console_wsscreen.ncols = hpcfb_console_dc.dc_cols;
hpcfb_console_screen.capabilities = hpcfb_console_dc.dc_rinfo.ri_caps; #else /* HPCFB_TVRAM */
hpcfb_console_wsscreen.nrows = hpcfb_console_dc.dc_rinfo.ri_rows;
hpcfb_console_wsscreen.ncols = hpcfb_console_dc.dc_rinfo.ri_cols;
#endif /* HPCFB_TVRAM */
hpcfb_console_wsscreen.capabilities = hpcfb_console_dc.dc_rinfo.ri_caps;
#ifndef HPCFB_HOOK
hpcfb_console_wsscreen.textops = &hpcfb_console_dc.dc_rinfo.ri_ops;
#endif /* HPCFB_HOOK */
#ifdef HPCFB_TVRAM
hpcfb_alloc_attr(&hpcfb_console_dc, 7, 0, 0, &defattr);
wsdisplay_cnattach(&hpcfb_console_wsscreen, &hpcfb_console_dc,
0, 0, defattr);
#else /* HPCFB_TVRAM */
hpcfb_console_dc.dc_rinfo.ri_ops.alloc_attr(&hpcfb_console_dc.dc_rinfo, hpcfb_console_dc.dc_rinfo.ri_ops.alloc_attr(&hpcfb_console_dc.dc_rinfo,
7, 0, 0, &defattr); 7, 0, 0, &defattr);
wsdisplay_cnattach(&hpcfb_console_screen, &hpcfb_console_dc.dc_rinfo, wsdisplay_cnattach(&hpcfb_console_wsscreen, &hpcfb_console_dc.dc_rinfo,
0, 0, defattr); 0, 0, defattr);
#endif /* HPCFB_TVRAM */
hpcfbconsole = 1; hpcfbconsole = 1;
hpcfb_console_type = type; hpcfb_console_type = type;
@ -303,6 +452,7 @@ hpcfb_init(fbconf, dc)
*(u_int32_t *)(fbaddr + i) = bg; *(u_int32_t *)(fbaddr + i) = bg;
} }
/* init rasops */
ri = &dc->dc_rinfo; ri = &dc->dc_rinfo;
bzero(ri, sizeof(struct rasops_info)); bzero(ri, sizeof(struct rasops_info));
ri->ri_depth = fbconf->hf_pixel_width; ri->ri_depth = fbconf->hf_pixel_width;
@ -314,6 +464,23 @@ hpcfb_init(fbconf, dc)
if (rasops_init(ri, 200, 200)) { if (rasops_init(ri, 200, 200)) {
panic("%s(%d): rasops_init() failed!", __FILE__, __LINE__); panic("%s(%d): rasops_init() failed!", __FILE__, __LINE__);
} }
#ifdef HPCFB_TVRAM
dc->dc_curx = -1;
dc->dc_cury = -1;
dc->dc_rows = dc->dc_rinfo.ri_rows;
dc->dc_cols = dc->dc_rinfo.ri_cols;
dc->dc_tvram = hpcfb_console_tvram;
#endif /* HPCFB_TVRAM */
#ifdef HPCFB_MULTI
dc->dc_scrno = 0;
dc->dc_bstore = NULL;
dc->dc_memsize = ri->ri_stride * ri->ri_height;
#endif /* HPCFB_MULTI */
#ifdef HPCFB_HOOK
/* hook rasops in hpcfb_ops */
rasops_emul = ri->ri_ops; /* struct copy */
ri->ri_ops = hpcfb_emulops; /* struct copy */
#endif /* HPCFB_HOOK */
/* /*
* setup color map * setup color map
@ -389,7 +556,7 @@ hpcfb_mmap(v, offset, prot)
return (*sc->sc_accessops->mmap)(sc->sc_accessctx, offset, prot); return (*sc->sc_accessops->mmap)(sc->sc_accessctx, offset, prot);
} }
int static int
hpcfb_alloc_screen(v, type, cookiep, curxp, curyp, attrp) hpcfb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
void *v; void *v;
const struct wsscreen_descr *type; const struct wsscreen_descr *type;
@ -398,35 +565,88 @@ hpcfb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
long *attrp; long *attrp;
{ {
struct hpcfb_softc *sc = v; struct hpcfb_softc *sc = v;
#ifdef HPCFB_MULTI
struct hpcfb_devconfig *dc;
#endif /* HPCFB_MULTI */
DPRINTF(("%s(%d): hpcfb_alloc_screen()\n", __FILE__, __LINE__)); DPRINTF(("%s(%d): hpcfb_alloc_screen()\n", __FILE__, __LINE__));
if (sc->nscreens > 0) #ifdef HPCFB_MULTI
if (sc->nscreens > HPCFB_MAX_SCREEN)
return (ENOMEM); return (ENOMEM);
/* second screen is allocated, alloc first one */
#ifdef HPCFB_BSTORE
if (sc->nscreens == 1
&& sc->screens[0]->dc_bstore == NULL) {
sc->screens[0]->dc_bstore =
malloc(sc->screens[0]->dc_memsize, M_DEVBUF, M_WAITOK);
}
#endif /* HPCFB_BSTORE */
if (sc->screens[sc->nscreens] == NULL)
sc->screens[sc->nscreens] =
malloc(sizeof(struct hpcfb_devconfig), M_DEVBUF, M_WAITOK);
dc = sc->screens[sc->nscreens];
dc->dc_sc = sc;
dc->dc_rinfo = sc->sc_dc->dc_rinfo;
dc->dc_scrno = sc->nscreens;
dc->dc_curx = -1;
dc->dc_cury = -1;
dc->dc_rows = sc->sc_dc->dc_rinfo.ri_rows;
dc->dc_cols = sc->sc_dc->dc_rinfo.ri_cols;
dc->dc_memsize = sc->sc_dc->dc_memsize;
#ifdef HPCFB_BSTORE
if (dc->dc_bstore == NULL) {
dc->dc_bstore =
malloc(dc->dc_memsize, M_DEVBUF, M_WAITOK);
}
#endif /* HPCFB_BSTORE */
dc->dc_rinfo.ri_bits = dc->dc_bstore;
if (dc->dc_tvram == NULL)
dc->dc_tvram =
malloc(sizeof(struct hpcfb_vchar)
* dc->dc_rows
* dc->dc_cols , M_DEVBUF, M_WAITOK);
*curxp = 0; *curxp = 0;
*curyp = 0; *curyp = 0;
*cookiep = &sc->sc_dc->dc_rinfo;
sc->sc_dc->dc_rinfo.ri_ops.alloc_attr(&sc->sc_dc->dc_rinfo,
7, 0, 0, attrp);
sc->nscreens++; sc->nscreens++;
*cookiep = dc;
hpcfb_alloc_attr(*cookiep, 7, 0, 0, attrp);
hpcfb_eraserows(*cookiep, 0, dc->dc_rows, *attrp);
#else /* HPCFB_MULTI */
if (sc->nscreens > 0)
return (ENOMEM);
*curxp = 0;
*curyp = 0;
sc->nscreens++;
*cookiep = &sc->sc_dc->dc_rinfo;
sc->sc_dc->dc_rinfo.ri_ops.alloc_attr(*cookiep,
7, 0, 0, attrp);
#endif /* HPCFB_MULTI */
return (0); return (0);
} }
void static void
hpcfb_free_screen(v, cookie) hpcfb_free_screen(v, cookie)
void *v; void *v;
void *cookie; void *cookie;
{ {
struct hpcfb_softc *sc = v; struct hpcfb_softc *sc = v;
#ifdef HPCFB_MULTI
if (sc->nscreens == 1 && sc->sc_dc == &hpcfb_console_dc)
panic("hpcfb_free_screen: console");
sc->nscreens--;
#else /* HPCFB_MULTI */
if (sc->sc_dc == &hpcfb_console_dc) if (sc->sc_dc == &hpcfb_console_dc)
panic("hpcfb_free_screen: console"); panic("hpcfb_free_screen: console");
sc->nscreens--; sc->nscreens--;
#endif /* HPCFB_MULTI */
} }
int static int
hpcfb_show_screen(v, cookie, waitok, cb, cbarg) hpcfb_show_screen(v, cookie, waitok, cb, cbarg)
void *v; void *v;
void *cookie; void *cookie;
@ -434,6 +654,436 @@ hpcfb_show_screen(v, cookie, waitok, cb, cbarg)
void (*cb) __P((void *, int, int)); void (*cb) __P((void *, int, int));
void *cbarg; void *cbarg;
{ {
#ifdef HPCFB_MULTI
struct hpcfb_softc *sc = v;
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
#endif /* HPCFB_MULTI */
DPRINTF(("%s(%d): hpcfb_show_screen()\n", __FILE__, __LINE__)); DPRINTF(("%s(%d): hpcfb_show_screen()\n", __FILE__, __LINE__));
#ifdef HPCFB_MULTI
dc->dc_rinfo.ri_bits = sc->sc_dc->dc_rinfo.ri_bits;
/* save current screen image */
#ifdef HPCFB_BSTORE
if (sc->sc_dc->dc_bstore) {
bcopy(sc->sc_dc->dc_rinfo.ri_bits, sc->sc_dc->dc_bstore,
sc->sc_dc->dc_memsize);
}
#endif /* HPCFB_BSTORE */
sc->sc_dc->dc_rinfo.ri_bits = sc->sc_dc->dc_bstore;
/* switch screen image */
sc->sc_dc = dc;
if (dc->dc_bstore) {
bcopy(dc->dc_bstore, dc->dc_rinfo.ri_bits, dc->dc_memsize);
} else {
hpcfb_redraw(dc, 0, dc->dc_rows);
if (dc->dc_curx > 0 && dc->dc_cury > 0)
hpcfb_cursor(dc, 1, dc->dc_cury, dc->dc_curx);
}
#endif /* HPCFB_MULTI */
return (0); return (0);
} }
#ifdef HPCFB_HOOK
/*
* cursor
*/
void
hpcfb_cursor(cookie, on, row, col)
void *cookie;
int on, row, col;
{
#ifdef HPCFB_TVRAM
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
struct hpcfb_softc *sc = dc->dc_sc;
struct rasops_info *ri = &dc->dc_rinfo;
int curwidth, curheight;
int xoff, yoff;
if (ri->ri_bits == NULL)
return;
if (on) {
dc->dc_curx = col;
dc->dc_cury = row;
} else {
dc->dc_curx = -1;
dc->dc_cury = -1;
}
#else /* HPCFB_TVRAM */
struct rasops_info *ri = (struct rasops_info *)cookie;
#endif /* HPCFB_TVRAM */
#ifdef HPCFB_TVRAM
if (sc && sc->sc_accessops->cursor) {
xoff = col * ri->ri_xscale;
yoff = row * ri->ri_yscale;
curheight = ri->ri_font->fontheight;
curwidth = ri->ri_xscale;
(*sc->sc_accessops->cursor)(sc->sc_accessctx,
on, xoff, yoff, curwidth, curheight);
} else
#endif /* HPCFB_TVRAM */
rasops_emul.cursor(ri, on, row, col);
}
/*
* mapchar
*/
int
hpcfb_mapchar(cookie, c, cp)
void *cookie;
int c;
unsigned int *cp;
{
#ifdef HPCFB_TVRAM
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
struct rasops_info *ri = &dc->dc_rinfo;
#else /* HPCFB_TVRAM */
struct rasops_info *ri = (struct rasops_info *)cookie;
#endif /* HPCFB_TVRAM */
return rasops_emul.mapchar(ri, c, cp);
}
/*
* putchar
*/
#ifdef HPCFB_TVRAM
void
hpcfb_tv_putchar(dc, row, col, uc, attr)
struct hpcfb_devconfig *dc;
int row, col;
u_int uc;
long attr;
{
struct hpcfb_vchar *vscn = dc->dc_tvram;
struct hpcfb_vchar *vc =
(vscn + row * dc->dc_cols + col);
if (vscn == 0)
return;
vc->c = uc;
vc->attr = attr;
}
#endif /* HPCFB_TVRAM */
void
hpcfb_putchar(cookie, row, col, uc, attr)
void *cookie;
int row, col;
u_int uc;
long attr;
{
#ifdef HPCFB_TVRAM
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
struct hpcfb_softc *sc = dc->dc_sc;
struct rasops_info *ri = &dc->dc_rinfo;
int xoff;
int yoff;
int fclr, uclr;
struct wsdisplay_font *font;
hpcfb_tv_putchar(dc, row, col, uc, attr);
if (ri->ri_bits == NULL)
return;
#else /* HPCFB_TVRAM */
struct rasops_info *ri = (struct rasops_info *)cookie;
#endif /* HPCFB_TVRAM */
#ifdef HPCFB_TVRAM
if (sc && sc->sc_accessops->putchar) {
yoff = row * ri->ri_yscale;
xoff = col * ri->ri_xscale;
fclr = ri->ri_devcmap[((u_int)attr >> 24) & 15];
uclr = ri->ri_devcmap[((u_int)attr >> 16) & 15];
(*sc->sc_accessops->putchar)(sc->sc_accessctx,
xoff, yoff, font, fclr, uclr, uc, attr);
} else
#endif /* HPCFB_TVRAM */
rasops_emul.putchar(ri, row, col, uc, attr);
}
/*
* copycols
*/
#ifdef HPCFB_TVRAM
void
hpcfb_tv_copycols(dc, row, srccol, dstcol, ncols)
struct hpcfb_devconfig *dc;
int row, srccol, dstcol, ncols;
{
struct hpcfb_vchar *vscn = dc->dc_tvram;
struct hpcfb_vchar *svc =
(vscn + row * dc->dc_cols + srccol);
struct hpcfb_vchar *dvc =
(vscn + row * dc->dc_cols + dstcol);
if (vscn == 0)
return;
bcopy(svc, dvc, ncols*sizeof(struct hpcfb_vchar));
}
#endif /* HPCFB_TVRAM */
void
hpcfb_copycols(cookie, row, srccol, dstcol, ncols)
void *cookie;
int row, srccol, dstcol, ncols;
{
#ifdef HPCFB_TVRAM
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
struct hpcfb_softc *sc = dc->dc_sc;
struct rasops_info *ri = &dc->dc_rinfo;
int srcxoff,dstxoff;
int srcyoff,dstyoff;
int height, width;
hpcfb_tv_copycols(dc, row, srccol, dstcol, ncols);
if (ri->ri_bits == NULL)
return;
#else /* HPCFB_TVRAM */
struct rasops_info *ri = (struct rasops_info *)cookie;
#endif /* HPCFB_TVRAM */
#ifdef HPCFB_TVRAM
if (sc && sc->sc_accessops->bitblit) {
srcxoff = srccol * ri->ri_xscale;
srcyoff = row * ri->ri_yscale;
dstxoff = dstcol * ri->ri_xscale;
dstyoff = row * ri->ri_yscale;
width = ncols * ri->ri_xscale;
height = ri->ri_yscale;
(*sc->sc_accessops->bitblit)(sc->sc_accessctx,
srcxoff, srcyoff, dstxoff, dstyoff, height, width);
} else
#endif /* HPCFB_TVRAM */
rasops_emul.copycols(ri, row, srccol, dstcol, ncols);
}
/*
* erasecols
*/
#ifdef HPCFB_TVRAM
void
hpcfb_tv_erasecols(dc, row, startcol, ncols, attr)
struct hpcfb_devconfig *dc;
int row, startcol, ncols;
long attr;
{
int cols = dc->dc_cols;
struct hpcfb_vchar *vscn = dc->dc_tvram;
struct hpcfb_vchar *svc = vscn + row * cols + startcol;
int i;
if (vscn == 0)
return;
for (i = 0; i < ncols; i++) {
svc->c = ' ';
svc->attr = attr;
svc++;
}
}
#endif /* HPCFB_TVRAM */
void
hpcfb_erasecols(cookie, row, startcol, ncols, attr)
void *cookie;
int row, startcol, ncols;
long attr;
{
#ifdef HPCFB_TVRAM
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
struct hpcfb_softc *sc = dc->dc_sc;
struct rasops_info *ri = &dc->dc_rinfo;
int xoff, yoff;
int width, height;
hpcfb_tv_erasecols(dc, row, startcol, ncols, attr);
if (ri->ri_bits == NULL)
return;
#else /* HPCFB_TVRAM */
struct rasops_info *ri = (struct rasops_info *)cookie;
#endif /* HPCFB_TVRAM */
#ifdef HPCFB_TVRAM
if (sc && sc->sc_accessops->erase) {
xoff = startcol * ri->ri_xscale;
yoff = row * ri->ri_yscale;
width = ncols * ri->ri_xscale;
height = ri->ri_yscale;
(*sc->sc_accessops->erase)(sc->sc_accessctx,
xoff, yoff, height, width, attr);
} else
#endif /* HPCFB_TVRAM */
rasops_emul.erasecols(ri, row, startcol, ncols, attr);
}
/*
* Copy rows.
*/
#ifdef HPCFB_TVRAM
void
hpcfb_tv_copyrows(dc, src, dst, num)
struct hpcfb_devconfig *dc;
int src, dst, num;
{
struct hpcfb_vchar *vscn = dc->dc_tvram;
int cols = dc->dc_cols;
struct hpcfb_vchar *svc = vscn + src * cols;
struct hpcfb_vchar *dvc = vscn + dst * cols;
if (vscn == 0)
return;
bcopy(svc, dvc, num*cols*sizeof(struct hpcfb_vchar));
}
#endif /* HPCFB_TVRAM */
#ifdef HPCFB_TVRAM
void
hpcfb_redraw(cookie, row, num)
void *cookie;
int row, num;
{
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
struct rasops_info *ri = &dc->dc_rinfo;
int cols = dc->dc_cols;
struct hpcfb_vchar *vscn = dc->dc_tvram;
struct hpcfb_vchar *svc;
int i, j;
if (vscn == 0)
return;
if (ri->ri_bits == NULL)
return;
for (i = 0; i < num; i++) {
for (j = 0; j < cols; j++) {
svc = vscn + (row+i) * cols + j;
rasops_emul.putchar(ri, row + i, j, svc->c, svc->attr);
}
}
}
#endif /* HPCFB_TVRAM */
void
hpcfb_copyrows(cookie, src, dst, num)
void *cookie;
int src, dst, num;
{
#ifdef HPCFB_TVRAM
#ifdef HPCFB_REDRAW
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
struct rasops_info *ri = &dc->dc_rinfo;
struct hpcfb_softc *sc = dc->dc_sc;
int srcyoff, dstyoff;
int width, height;
#endif /* HPCFB_REDRAW */
hpcfb_tv_copyrows(cookie, src, dst, num);
if (ri->ri_bits == NULL)
return;
#endif /* HPCFB_TVRAM */
#if defined(HPCFB_TVRAM) && defined(HPCFB_REDRAW)
if (sc && sc->sc_accessops->bitblit) {
srcyoff = src * ri->ri_yscale;
dstyoff = dst * ri->ri_yscale;
width = ri->ri_stride;
height = num * ri->ri_yscale;
(*sc->sc_accessops->bitblit)(sc->sc_accessctx,
0, srcyoff, 0, dstyoff, height, width);
} else
hpcfb_redraw(cookie, dst, num);
#else /* defined(HPCFB_TVRAM) && defined(HPCFB_REDRAW) */
rasops_emul.copyrows(ri, src, dst, num);
#endif /* defined(HPCFB_TVRAM) && defined(HPCFB_REDRAW) */
}
/*
* eraserows
*/
#ifdef HPCFB_TVRAM
void
hpcfb_tv_eraserows(dc, row, nrow, attr)
struct hpcfb_devconfig *dc;
int row, nrow;
long attr;
{
struct hpcfb_vchar *vscn = dc->dc_tvram;
struct hpcfb_vchar *svc = vscn + row * dc->dc_cols;
int i;
int j;
if (vscn == 0)
return;
for (i = 0; i < nrow; i++) {
for (j = 0; j < dc->dc_cols; j++) {
svc->c = ' ';
svc->attr = attr;
svc++;
}
}
}
#endif /* HPCFB_TVRAM */
void
hpcfb_eraserows(cookie, row, nrow, attr)
void *cookie;
int row, nrow;
long attr;
{
#ifdef HPCFB_TVRAM
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
struct hpcfb_softc *sc = dc->dc_sc;
struct rasops_info *ri = &dc->dc_rinfo;
int yoff;
int width;
int height;
hpcfb_tv_eraserows(dc, row, nrow, attr);
if (ri->ri_bits == NULL)
return;
#else /* HPCFB_TVRAM */
struct rasops_info *ri = (struct rasops_info *)cookie;
#endif /* HPCFB_TVRAM */
#ifdef HPCFB_TVRAM
if (sc && sc->sc_accessops->erase) {
yoff = row * ri->ri_yscale;
width = ri->ri_stride;
height = nrow * ri->ri_yscale;
(*sc->sc_accessops->erase)(sc->sc_accessctx,
0, yoff, height, width, attr);
} else
#endif /* HPCFB_TVRAM */
rasops_emul.eraserows(ri, row, nrow, attr);
}
/*
* alloc_attr
*/
int
hpcfb_alloc_attr(cookie, fg, bg, flags, attrp)
void *cookie;
int fg, bg, flags;
long *attrp;
{
#ifdef HPCFB_TVRAM
struct hpcfb_devconfig *dc = (struct hpcfb_devconfig *)cookie;
struct rasops_info *ri = &dc->dc_rinfo;
#else /* HPCFB_TVRAM */
struct rasops_info *ri = (struct rasops_info *)cookie;
#endif /* HPCFB_TVRAM */
return rasops_emul.alloc_attr(ri, fg, bg, flags, attrp);
}
#endif /* HPCFB_HOOK */

View File

@ -1,8 +1,10 @@
/* $NetBSD: hpcfbvar.h,v 1.1 2000/03/12 05:04:46 takemura Exp $ */ /* $NetBSD: hpcfbvar.h,v 1.2 2000/04/03 03:35:37 sato Exp $ */
/*- /*-
* Copyright (c) 1999 * Copyright (c) 1999
* Shin Takemura and PocketBSD Project. All rights reserved. * Shin Takemura and PocketBSD Project. All rights reserved.
* Copyright (c) 2000
* SATO Kazumi. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -35,12 +37,21 @@
*/ */
/* /*
* video access functions (must be provided by all keyboards). * video access functions (must be provided by all video).
*/ */
struct hpcfb_accessops { struct hpcfb_accessops {
int (*ioctl) __P((void *v, u_long cmd, caddr_t data, int flag, int (*ioctl) __P((void *v, u_long cmd, caddr_t data, int flag,
struct proc *p)); struct proc *p));
int (*mmap) __P((void *v, off_t off, int prot)); int (*mmap) __P((void *v, off_t off, int prot));
void (*cursor) __P((void *v, int on, int xoff, int yoff, \
int curwidth, int curheiht));
void (*bitblit) __P((void *v, int srcxoff, int srcyoff, \
int dstxoff, int dstyoff, int height, int width));
void (*erase) __P((void *v, int xoff, int yoff, \
int height, int width, int attr));
void (*putchar) __P((void *v, int xoff, int yoff, \
struct wsdisplay_font *font, int fclr, int uclr, \
u_int uc, int attr));
}; };
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: plumvideo.c,v 1.5 2000/03/25 15:08:26 uch Exp $ */ /* $NetBSD: plumvideo.c,v 1.6 2000/04/03 03:35:37 sato Exp $ */
/* /*
* Copyright (c) 1999, 2000, by UCHIYAMA Yasushi * Copyright (c) 1999, 2000, by UCHIYAMA Yasushi
@ -46,6 +46,7 @@
#include <machine/bootinfo.h> #include <machine/bootinfo.h>
#if NHPCFB > 0 #if NHPCFB > 0
#include <dev/wscons/wsconsio.h>
#include <arch/hpcmips/dev/hpcfbvar.h> #include <arch/hpcmips/dev/hpcfbvar.h>
#include <arch/hpcmips/dev/hpcfbio.h> #include <arch/hpcmips/dev/hpcfbio.h>
#include <arch/hpcmips/dev/bivideovar.h> #include <arch/hpcmips/dev/bivideovar.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx3912video.c,v 1.8 2000/03/13 18:49:17 uch Exp $ */ /* $NetBSD: tx3912video.c,v 1.9 2000/04/03 03:35:38 sato Exp $ */
/* /*
* Copyright (c) 1999, 2000, by UCHIYAMA Yasushi * Copyright (c) 1999, 2000, by UCHIYAMA Yasushi
@ -41,6 +41,7 @@
#include <hpcmips/tx/tx3912videoreg.h> #include <hpcmips/tx/tx3912videoreg.h>
#if NHPCFB > 0 #if NHPCFB > 0
#include <dev/wscons/wsconsio.h>
#include <arch/hpcmips/dev/hpcfbvar.h> #include <arch/hpcmips/dev/hpcfbvar.h>
#include <arch/hpcmips/dev/hpcfbio.h> #include <arch/hpcmips/dev/hpcfbio.h>
#include <arch/hpcmips/dev/bivideovar.h> #include <arch/hpcmips/dev/bivideovar.h>