green_saver.c revision 40885
1/*-
2 * Copyright (c) 1995-1998 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer,
10 *    without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 *    derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 *	$Id: green_saver.c,v 1.13 1998/09/17 19:40:30 sos Exp $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/kernel.h>
34#include <sys/module.h>
35
36#include <i386/isa/isa.h>
37
38#include <saver.h>
39
40static void
41green_saver(int blank)
42{
43	u_char val;
44	if (blank) {
45		scrn_blanked = 1;
46		cur_console->status |= SAVER_RUNNING;
47		switch (crtc_type) {
48		case KD_VGA:
49			outb(TSIDX, 0x01); val = inb(TSREG);
50			outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
51			outb(crtc_addr, 0x17); val = inb(crtc_addr + 1);
52			outb(crtc_addr + 1, val & ~0x80);
53			break;
54		case KD_EGA:
55			/* not yet done XXX */
56			break;
57		case KD_CGA:
58			outb(crtc_addr + 4, 0x25);
59			break;
60		case KD_MONO:
61		case KD_HERCULES:
62			outb(crtc_addr + 4, 0x21);
63			break;
64		default:
65			break;
66		}
67	}
68	else {
69		switch (crtc_type) {
70		case KD_VGA:
71			outb(TSIDX, 0x01); val = inb(TSREG);
72			outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
73			outb(crtc_addr, 0x17); val = inb(crtc_addr + 1);
74			outb(crtc_addr + 1, val | 0x80);
75			break;
76		case KD_EGA:
77			/* not yet done XXX */
78			break;
79		case KD_CGA:
80			outb(crtc_addr + 4, 0x2d);
81			break;
82		case KD_MONO:
83		case KD_HERCULES:
84			outb(crtc_addr + 4, 0x29);
85			break;
86		default:
87			break;
88		}
89		cur_console->status &= ~SAVER_RUNNING;
90		scrn_blanked = 0;
91	}
92}
93
94static int
95green_saver_load(void)
96{
97	switch (crtc_type) {
98	case KD_MONO:
99	case KD_HERCULES:
100	case KD_CGA:
101		/*
102		 * `green' saver is not fully implemented for MDA and CGA.
103		 * It simply blanks the display instead.
104		 */
105	case KD_VGA:
106		break;
107	case KD_EGA:
108		/* EGA is yet to be supported */
109	default:
110		return ENODEV;
111	}
112	return add_scrn_saver(green_saver);
113}
114
115static int
116green_saver_unload(void)
117{
118	return remove_scrn_saver(green_saver);
119}
120
121SAVER_MODULE(green_saver);
122