fade_saver.c revision 21731
1/*-
2 * Copyright (c) 1995-1997 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 *    in this position and unchanged.
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 withough 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 *	$FreeBSD: head/sys/dev/syscons/fade/fade_saver.c 21731 1997-01-15 18:16:32Z sos $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/conf.h>
34#include <sys/exec.h>
35#include <sys/sysent.h>
36#include <sys/lkm.h>
37#include <sys/errno.h>
38#include <saver.h>
39
40MOD_MISC(fade_saver);
41
42void (*current_saver)(int blank);
43void (*old_saver)(int blank);
44
45static void
46fade_saver(int blank)
47{
48	static int count = 0;
49	int i;
50
51	if (blank) {
52		scrn_blanked = 1;
53		if (count < 64) {
54			outb(PIXMASK, 0xFF);		/* no pixelmask */
55			outb(PALWADR, 0x00);
56			outb(PALDATA, 0);
57			outb(PALDATA, 0);
58			outb(PALDATA, 0);
59			for (i = 3; i < 768; i++) {
60				if (palette[i] - count > 15)
61					outb(PALDATA, palette[i]-count);
62				else
63					outb(PALDATA, 15);
64			}
65			inb(crtc_addr+6);		/* reset flip/flop */
66			outb(ATC, 0x20);		/* enable palette */
67			count++;
68		}
69	}
70	else {
71		load_palette(palette);
72		count = scrn_blanked = 0;
73	}
74}
75
76static int
77fade_saver_load(struct lkm_table *lkmtp, int cmd)
78{
79	(*current_saver)(0);
80	old_saver = current_saver;
81	current_saver = fade_saver;
82	return 0;
83}
84
85static int
86fade_saver_unload(struct lkm_table *lkmtp, int cmd)
87{
88	(*current_saver)(0);
89	current_saver = old_saver;
90	return 0;
91}
92
93int
94fade_saver_mod(struct lkm_table *lkmtp, int cmd, int ver)
95{
96	DISPATCH(lkmtp, cmd, ver, fade_saver_load, fade_saver_unload,
97		 lkm_nullcmd);
98}
99