diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-05-08 22:28:44 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-05-08 22:28:44 +0000 |
commit | fda42b5add85625d515849886a87228d10924814 (patch) | |
tree | 7849de50a9531e5b8133cd38385c4b9e5bde782e /sys/dev | |
parent | 02e0d54c66a867c4789380666e0ac55a8b780f8a (diff) |
inplement screen burner in screenblank(1) style (no program though).
disabled by default, also supports vsync blanking, disabled by default.
aaron@ looked at it a while back and i fixed problems he had indicated.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/vga.c | 53 | ||||
-rw-r--r-- | sys/dev/wscons/wsconsio.h | 24 | ||||
-rw-r--r-- | sys/dev/wscons/wsdisplay.c | 156 | ||||
-rw-r--r-- | sys/dev/wscons/wsdisplayvar.h | 13 | ||||
-rw-r--r-- | sys/dev/wscons/wskbd.c | 4 | ||||
-rw-r--r-- | sys/dev/wscons/wsmouse.c | 4 |
6 files changed, 202 insertions, 52 deletions
diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c index 4c3febb03e0..baccb16eb48 100644 --- a/sys/dev/ic/vga.c +++ b/sys/dev/ic/vga.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vga.c,v 1.24 2001/05/08 16:16:10 mickey Exp $ */ +/* $OpenBSD: vga.c,v 1.25 2001/05/08 22:28:43 mickey Exp $ */ /* $NetBSD: vga.c,v 1.28.2.1 2000/06/30 16:27:47 simonb Exp $ */ /* @@ -87,17 +87,15 @@ struct vgascreen { int vga_rollover; }; -static int vgaconsole, vga_console_type, vga_console_attached; -static struct vgascreen vga_console_screen; -static struct vga_config vga_console_vc; +int vgaconsole, vga_console_type, vga_console_attached; +struct vgascreen vga_console_screen; +struct vga_config vga_console_vc; int vga_selectfont __P((struct vga_config *, struct vgascreen *, - const char *, const char *)); -void vga_init_screen __P((struct vga_config *, struct vgascreen *, - const struct wsscreen_descr *, - int, long *)); -void vga_init __P((struct vga_config *, bus_space_tag_t, - bus_space_tag_t)); + const char *, const char *)); +void vga_init_screen __P((struct vga_config *, struct vgascreen *, + const struct wsscreen_descr *, int, long *)); +void vga_init __P((struct vga_config *, bus_space_tag_t, bus_space_tag_t)); void vga_setfont __P((struct vga_config *, struct vgascreen *)); int vga_mapchar __P((void *, int, unsigned int *)); @@ -105,7 +103,7 @@ void vga_putchar __P((void *, int, int, u_int, long)); int vga_alloc_attr __P((void *, int, int, int, long *)); void vga_copyrows __P((void *, int, int, int)); -const struct wsdisplay_emulops vga_emulops = { +static const struct wsdisplay_emulops vga_emulops = { pcdisplay_cursor, vga_mapchar, vga_putchar, @@ -223,6 +221,7 @@ int vga_show_screen __P((void *, void *, int, void (*) (void *, int, int), void *)); int vga_load_font __P((void *, void *, struct wsdisplay_font *)); void vga_scrollback __P((void *, void *, int)); +void vga_burner __P((void *v, u_int on, u_int flags)); u_int16_t vga_getchar __P((void *, int, int)); void vga_doswitch __P((struct vga_config *)); @@ -235,7 +234,8 @@ const struct wsdisplay_accessops vga_accessops = { vga_show_screen, vga_load_font, vga_scrollback, - vga_getchar + vga_getchar, + vga_burner }; /* @@ -1239,6 +1239,35 @@ vga_putchar(c, row, col, uc, attr) pcdisplay_putchar(c, row, col, uc, attr); } +void +vga_burner(v, on, flags) + void *v; + u_int on, flags; +{ + struct vga_config *vc = v; + struct vga_handle *vh = &vc->hdl; + u_int8_t r; + int s; + + s = splhigh(); + vga_ts_write(vh, syncreset, 0x01); + if (on) { + vga_ts_write(vh, mode, (vga_ts_read(vh, mode) & ~0x20)); + r = vga_6845_read(vh, mode) | 0x80; + DELAY(10000); + vga_6845_write(vh, mode, r); + } else { + vga_ts_write(vh, mode, (vga_ts_read(vh, mode) | 0x20)); + if (flags & WSDISPLAY_BURN_VBLANK) { + r = vga_6845_read(vh, mode) & ~0x80; + DELAY(10000); + vga_6845_write(vh, mode, r); + } + } + vga_ts_write(vh, syncreset, 0x03); + splx(s); +} + u_int16_t vga_getchar(c, row, col) void *c; diff --git a/sys/dev/wscons/wsconsio.h b/sys/dev/wscons/wsconsio.h index 534946886cf..abaea787766 100644 --- a/sys/dev/wscons/wsconsio.h +++ b/sys/dev/wscons/wsconsio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsio.h,v 1.9 2001/04/14 04:44:01 aaron Exp $ */ +/* $OpenBSD: wsconsio.h,v 1.10 2001/05/08 22:28:43 mickey Exp $ */ /* $NetBSD: wsconsio.h,v 1.31.2.1 2000/07/07 09:49:17 hannken Exp $ */ /* @@ -304,11 +304,6 @@ struct wsdisplay_cursor { #define WSDISPLAYIO_MODE_EMUL 0 /* emulation (text) mode */ #define WSDISPLAYIO_MODE_MAPPED 1 /* mapped (graphics) mode */ -/* - * XXX WARNING - * XXX The following definitions are very preliminary and are likely - * XXX to be changed without care about backwards compatibility! - */ struct wsdisplay_font { char name[WSFONT_NAME_SIZE]; int index; @@ -332,6 +327,23 @@ struct wsdisplay_font { #define WSDISPLAYIO_DELFONT _IOW ('W', 79, struct wsdisplay_font) #define WSDISPLAYIO_USEFONT _IOW ('W', 80, struct wsdisplay_font) +struct wsdisplay_burner { + u_int off; + u_int on; + u_int flags; +#define WSDISPLAY_BURN_VBLANK 0x0001 +#define WSDISPLAY_BURN_KBD 0x0002 +#define WSDISPLAY_BURN_MOUSE 0x0004 +#define WSDISPLAY_BURN_OUTPUT 0x0008 +}; +#define WSDISPLAYIO_SBURNER _IOW('W', 81, struct wsdisplay_burner) +#define WSDISPLAYIO_GBURNER _IOR('W', 82, struct wsdisplay_burner) + +/* + * XXX WARNING + * XXX The following definitions are very preliminary and are likely + * XXX to be changed without care about backwards compatibility! + */ struct wsdisplay_addscreendata { int idx; /* screen index */ char screentype[WSSCREEN_NAME_SIZE]; diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c index 93efa045707..d931bb8580e 100644 --- a/sys/dev/wscons/wsdisplay.c +++ b/sys/dev/wscons/wsdisplay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsdisplay.c,v 1.25 2001/05/01 02:23:22 aaron Exp $ */ +/* $OpenBSD: wsdisplay.c,v 1.26 2001/05/08 22:28:43 mickey Exp $ */ /* $NetBSD: wsdisplay.c,v 1.37.4.1 2000/06/30 16:27:53 simonb Exp $ */ /* @@ -128,16 +128,14 @@ struct wsscreen { }; struct wsscreen *wsscreen_attach __P((struct wsdisplay_softc *, int, - const char *, - const struct wsscreen_descr *, void *, - int, int, long)); + const char *, const struct wsscreen_descr *, void *, int, int, long)); void wsscreen_detach __P((struct wsscreen *)); -int wsdisplay_addscreen __P((struct wsdisplay_softc *, int, const char *, - const char *)); +int wsdisplay_addscreen __P((struct wsdisplay_softc *, int, const char *, const char *)); void wsdisplay_shutdownhook __P((void *)); void wsdisplay_addscreen_print __P((struct wsdisplay_softc *, int, int)); void wsdisplay_closescreen __P((struct wsdisplay_softc *, struct wsscreen *)); int wsdisplay_delscreen __P((struct wsdisplay_softc *, int, int)); +void wsdisplay_burner __P((void *v)); #define WSDISPLAY_MAXSCREEN 12 #define WSDISPLAY_MAXFONT 8 @@ -154,6 +152,13 @@ struct wsdisplay_softc { int sc_focusidx; /* available only if sc_focus isn't null */ struct wsscreen *sc_focus; + struct timeout sc_burner; + int sc_burnoutintvl; + int sc_burninintvl; + int sc_burnout; + int sc_burnman; + int sc_burnflags; + struct wsdisplay_font sc_fonts[WSDISPLAY_MAXFONT]; int sc_isconsole; @@ -221,17 +226,17 @@ void wsdisplay_common_attach __P((struct wsdisplay_softc *sc, int console, int wsdisplay_update_rawkbd __P((struct wsdisplay_softc *, struct wsscreen *)); #endif -static int wsdisplay_console_initted; -static struct wsdisplay_softc *wsdisplay_console_device; -static struct wsscreen_internal wsdisplay_console_conf; +int wsdisplay_console_initted; +struct wsdisplay_softc *wsdisplay_console_device; +struct wsscreen_internal wsdisplay_console_conf; int wsdisplay_getc_dummy __P((dev_t)); void wsdisplay_pollc __P((dev_t, int)); -static int wsdisplay_cons_pollmode; +int wsdisplay_cons_pollmode; void (*wsdisplay_cons_kbd_pollc) __P((dev_t, int)); -static struct consdev wsdisplay_cons = { +struct consdev wsdisplay_cons = { NULL, NULL, wsdisplay_getc_dummy, wsdisplay_cnputc, wsdisplay_pollc, NULL, NODEV, CN_NORMAL }; @@ -681,6 +686,13 @@ wsdisplay_common_attach(sc, console, scrdata, accessops, accesscookie) if (i > start) wsdisplay_addscreen_print(sc, start, i-start); + sc->sc_burnoutintvl = (hz * WSDISPLAY_DEFBURNOUT) / 1000; + sc->sc_burninintvl = (hz * WSDISPLAY_DEFBURNIN ) / 1000; + sc->sc_burnflags = 0; /* off by default */ + timeout_set(&sc->sc_burner, wsdisplay_burner, sc); + sc->sc_burnout = sc->sc_burnoutintvl; + wsdisplay_burn(sc, sc->sc_burnflags); + if (hookset == 0) shutdownhook_establish(wsdisplay_shutdownhook, NULL); hookset = 1; @@ -994,32 +1006,30 @@ wsdisplay_internal_ioctl(sc, scr, cmd, data, flag, p) #if NWSKBD > 0 #ifdef WSDISPLAY_COMPAT_RAWKBD - switch (cmd) { - case WSKBDIO_SETMODE: - scr->scr_rawkbd = (*(int *)data == WSKBD_RAW); - return (wsdisplay_update_rawkbd(sc, scr)); - case WSKBDIO_GETMODE: - *(int *)data = (scr->scr_rawkbd ? - WSKBD_RAW : WSKBD_TRANSLATED); - return (0); - } + switch (cmd) { + case WSKBDIO_SETMODE: + scr->scr_rawkbd = (*(int *)data == WSKBD_RAW); + return (wsdisplay_update_rawkbd(sc, scr)); + case WSKBDIO_GETMODE: + *(int *)data = (scr->scr_rawkbd ? + WSKBD_RAW : WSKBD_TRANSLATED); + return (0); + } #endif error = wsmux_displayioctl(&sc->sc_muxdv->sc_dv, cmd, data, flag, p); - if (error >= 0) + if (error >= 0) return (error); #endif /* NWSKBD > 0 */ switch (cmd) { case WSDISPLAYIO_GMODE: *(u_int *)data = (scr->scr_flags & SCR_GRAPHICS ? - WSDISPLAYIO_MODE_MAPPED : - WSDISPLAYIO_MODE_EMUL); + WSDISPLAYIO_MODE_MAPPED : WSDISPLAYIO_MODE_EMUL); return (0); case WSDISPLAYIO_SMODE: #define d (*(int *)data) - if (d != WSDISPLAYIO_MODE_EMUL && - d != WSDISPLAYIO_MODE_MAPPED) + if (d != WSDISPLAYIO_MODE_EMUL && d != WSDISPLAYIO_MODE_MAPPED) return (EINVAL); if (WSSCREEN_HAS_EMULATOR(scr)) { @@ -1041,10 +1051,55 @@ wsdisplay_internal_ioctl(sc, scr, cmd, data, flag, p) return (EINVAL); d->data = 0; error = (*sc->sc_accessops->load_font)(sc->sc_accesscookie, - scr->scr_dconf->emulcookie, d); + scr->scr_dconf->emulcookie, d); if (!error && WSSCREEN_HAS_EMULATOR(scr)) (*scr->scr_dconf->wsemul->reset) - (scr->scr_dconf->wsemulcookie, WSEMUL_SYNCFONT); + (scr->scr_dconf->wsemulcookie, WSEMUL_SYNCFONT); + return (error); +#undef d + case WSDISPLAYIO_GVIDEO: + *(u_int *)data = !sc->sc_burnman; + break; + + case WSDISPLAYIO_SVIDEO: + if (*(u_int *)data != WSDISPLAYIO_VIDEO_OFF && + *(u_int *)data != WSDISPLAYIO_VIDEO_ON) + return (EINVAL); + if (sc->sc_accessops->burn_screen == NULL) + return (EOPNOTSUPP); + (*sc->sc_accessops->burn_screen)(sc->sc_accesscookie, + *(u_int *)data, sc->sc_burnflags); + break; + + case WSDISPLAYIO_GBURNER: +#define d ((struct wsdisplay_burner *)data) + d->on = sc->sc_burninintvl * 1000 / hz; + d->off = sc->sc_burnoutintvl * 1000 / hz; + d->flags = sc->sc_burnflags; + return (0); + + case WSDISPLAYIO_SBURNER: + error = EINVAL; + if (d->flags & (WSDISPLAY_BURN_VBLANK | WSDISPLAY_BURN_KBD | + WSDISPLAY_BURN_MOUSE | WSDISPLAY_BURN_OUTPUT)) { + error = 0; + sc->sc_burnflags = d->flags; + } + if (d->on) { + error = 0; + sc->sc_burninintvl = hz * d->on / 1000; + if (sc->sc_burnman) + sc->sc_burnout = sc->sc_burninintvl; + } + if (d->off) { + error = 0; + sc->sc_burnoutintvl = hz * d->off / 1000; + if (!sc->sc_burnman) { + sc->sc_burnout = sc->sc_burnoutintvl; + /* reinit timeout if changed */ + wsdisplay_burn(sc, sc->sc_burnflags); + } + } return (error); #undef d } @@ -1100,9 +1155,9 @@ wsdisplay_cfg_ioctl(sc, cmd, data, flag, p) d->data = buf; error = (*sc->sc_accessops->load_font)(sc->sc_accesscookie, 0, d); - if (error || d->index < 0) + if (error) free(buf, M_DEVBUF); - else + else if (d->index >= 0 || d->index < WSDISPLAY_MAXFONT) sc->sc_fonts[d->index] = *d; return (error); @@ -1265,6 +1320,7 @@ wsdisplaystart(tp) if (!(scr->scr_flags & SCR_GRAPHICS)) { KASSERT(WSSCREEN_HAS_EMULATOR(scr)); + wsdisplay_burn(sc, WSDISPLAY_BURN_OUTPUT); if (scr == sc->sc_focus) { if (IS_SEL_EXISTS(sc->sc_focus)) /* hide a potential selection */ @@ -1282,6 +1338,7 @@ wsdisplaystart(tp) if (!(scr->scr_flags & SCR_GRAPHICS)) { KASSERT(WSSCREEN_HAS_EMULATOR(scr)); + wsdisplay_burn(sc, WSDISPLAY_BURN_OUTPUT); (*scr->scr_dconf->wsemul->output) (scr->scr_dconf->wsemulcookie, buf, n, 0); } @@ -1373,7 +1430,7 @@ wsdisplay_emulinput(v, data, count) tp = scr->scr_tty; while (count-- > 0) (*linesw[tp->t_line].l_rint)(*data++, tp); -}; +} /* * Calls from the keyboard interface. @@ -1837,6 +1894,7 @@ wsdisplay_cnputc(dev, i) return; dc = &wsdisplay_console_conf; + /*wsdisplay_burn(wsdisplay_console_device, WSDISPLAY_BURN_OUTPUT);*/ (*dc->wsemul->output)(dc->wsemulcookie, &c, 1, 1); } @@ -1928,6 +1986,44 @@ wsscrollback(arg, op) } } +void +wsdisplay_burn(v, flags) + void *v; + u_int flags; +{ + struct wsdisplay_softc *sc = v; + + if ((flags & sc->sc_burnflags & (WSDISPLAY_BURN_OUTPUT | + WSDISPLAY_BURN_KBD | WSDISPLAY_BURN_MOUSE)) && + sc->sc_accessops->burn_screen) { + if (sc->sc_burnout) + timeout_add(&sc->sc_burner, sc->sc_burnout); + if (sc->sc_burnman) + sc->sc_burnout = 0; + } +} + +void +wsdisplay_burner(v) + void *v; +{ + struct wsdisplay_softc *sc = v; + int s; + + if (sc->sc_accessops->burn_screen) { + (*sc->sc_accessops->burn_screen)(sc->sc_accesscookie, + sc->sc_burnman, sc->sc_burnflags); + s = spltty(); + if (sc->sc_burnman) { + sc->sc_burnout = sc->sc_burnoutintvl; + timeout_add(&sc->sc_burner, sc->sc_burnout); + } else + sc->sc_burnout = sc->sc_burninintvl; + sc->sc_burnman = !sc->sc_burnman; + splx(s); + } +} + /* * Switch the console at shutdown. */ diff --git a/sys/dev/wscons/wsdisplayvar.h b/sys/dev/wscons/wsdisplayvar.h index 1674f53d6d6..edf941e647c 100644 --- a/sys/dev/wscons/wsdisplayvar.h +++ b/sys/dev/wscons/wsdisplayvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsdisplayvar.h,v 1.9 2001/04/14 04:44:02 aaron Exp $ */ +/* $OpenBSD: wsdisplayvar.h,v 1.10 2001/05/08 22:28:43 mickey Exp $ */ /* $NetBSD: wsdisplayvar.h,v 1.14.4.1 2000/06/30 16:27:53 simonb Exp $ */ /* @@ -115,6 +115,7 @@ struct wsdisplay_accessops { int (*load_font) __P((void *, void *, struct wsdisplay_font *)); void (*scrollback) __P((void *, void *, int)); u_int16_t (*getchar) __P((void *, int, int)); + void (*burn_screen) __P((void *, u_int, u_int)); void (*pollc) __P((void *, int)); }; @@ -210,8 +211,16 @@ const struct wsscreen_descr * /* * for use by wskbd */ -void wsscrollback __P((void *, int op)); +void wsdisplay_burn __P((void *v, u_int flags)); +void wsscrollback __P((void *v, int op)); #define WSDISPLAY_SCROLL_BACKWARD 0 #define WSDISPLAY_SCROLL_FORWARD 1 #define WSDISPLAY_SCROLL_RESET 2 + +/* + * screen burner + */ +#define WSDISPLAY_DEFBURNOUT 600000 /* ms */ +#define WSDISPLAY_DEFBURNIN 250 /* ms */ + diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c index 72a19224af1..5532b9d9faa 100644 --- a/sys/dev/wscons/wskbd.c +++ b/sys/dev/wscons/wskbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wskbd.c,v 1.15 2001/04/18 02:26:58 aaron Exp $ */ +/* $OpenBSD: wskbd.c,v 1.16 2001/05/08 22:28:43 mickey Exp $ */ /* $NetBSD: wskbd.c,v 1.38 2000/03/23 07:01:47 thorpej Exp $ */ /* @@ -589,6 +589,8 @@ wskbd_input(dev, type, value) * send upstream. */ if (sc->sc_translating) { + if (type == WSCONS_EVENT_KEY_DOWN && sc->sc_displaydv != NULL) + wsdisplay_burn(sc->sc_displaydv, WSDISPLAY_BURN_KBD); num = wskbd_translate(sc->id, type, value); if (num > 0) { if (sc->sc_displaydv != NULL) { diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c index ba02e11fd54..650925a1e84 100644 --- a/sys/dev/wscons/wsmouse.c +++ b/sys/dev/wscons/wsmouse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmouse.c,v 1.5 2001/03/30 16:38:14 aaron Exp $ */ +/* $OpenBSD: wsmouse.c,v 1.6 2001/05/08 22:28:43 mickey Exp $ */ /* $NetBSD: wsmouse.c,v 1.12 2000/05/01 07:36:58 takemura Exp $ */ /* @@ -97,6 +97,7 @@ #include <dev/wscons/wsconsio.h> #include <dev/wscons/wsmousevar.h> #include <dev/wscons/wseventvar.h> +#include <dev/wscons/wsdisplayvar.h> #include "wsmouse.h" #include "wsmux.h" @@ -436,6 +437,7 @@ out: sc->sc_ub = ub; evar->put = put; WSEVENT_WAKEUP(evar); + /* wsdisplay_burn(sc->sc_displaydv, WSDISPLAY_BURN_MOUSE); */ } } |