blank_saver.c revision 42504
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: blank_saver.c,v 1.14 1998/11/04 03:49:38 peter 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 <dev/fb/vgareg.h>
37
38#include <i386/isa/isa.h>
39
40#include <saver.h>
41
42static int
43blank_saver(video_adapter_t *adp, int blank)
44{
45	u_char val;
46	if (blank) {
47		switch (adp->va_type) {
48		case KD_VGA:
49			outb(TSIDX, 0x01); val = inb(TSREG);
50			outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
51			break;
52		case KD_EGA:
53			/* not yet done XXX */
54			break;
55		case KD_CGA:
56			outb(adp->va_crtc_addr + 4, 0x25);
57			break;
58		case KD_MONO:
59		case KD_HERCULES:
60			outb(adp->va_crtc_addr + 4, 0x21);
61			break;
62		default:
63			break;
64		}
65	}
66	else {
67		switch (adp->va_type) {
68		case KD_VGA:
69			outb(TSIDX, 0x01); val = inb(TSREG);
70			outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
71			break;
72		case KD_EGA:
73			/* not yet done XXX */
74			break;
75		case KD_CGA:
76			outb(adp->va_crtc_addr + 4, 0x2d);
77			break;
78		case KD_MONO:
79		case KD_HERCULES:
80			outb(adp->va_crtc_addr + 4, 0x29);
81			break;
82		default:
83			break;
84		}
85	}
86	return 0;
87}
88
89static int
90blank_init(video_adapter_t *adp)
91{
92	switch (adp->va_type) {
93	case KD_MONO:
94	case KD_HERCULES:
95	case KD_CGA:
96	case KD_VGA:
97		break;
98	case KD_EGA:
99		/* EGA is yet to be supported */
100	default:
101		return ENODEV;
102	}
103	return 0;
104}
105
106static int
107blank_term(video_adapter_t *adp)
108{
109	return 0;
110}
111
112static scrn_saver_t blank_module = {
113	"blank_saver", blank_init, blank_term, blank_saver, NULL,
114};
115
116SAVER_MODULE(blank_saver, blank_module);
117