fade_saver.c revision 6628
16628Ssos/*-
26628Ssos * Copyright (c) 1995 S�ren Schmidt
36628Ssos * All rights reserved.
46628Ssos *
56628Ssos * Redistribution and use in source and binary forms, with or without
66628Ssos * modification, are permitted provided that the following conditions
76628Ssos * are met:
86628Ssos * 1. Redistributions of source code must retain the above copyright
96628Ssos *    notice, this list of conditions and the following disclaimer
106628Ssos *    in this position and unchanged.
116628Ssos * 2. Redistributions in binary form must reproduce the above copyright
126628Ssos *    notice, this list of conditions and the following disclaimer in the
136628Ssos *    documentation and/or other materials provided with the distribution.
146628Ssos * 3. The name of the author may not be used to endorse or promote products
156628Ssos *    derived from this software withough specific prior written permission
166628Ssos *
176628Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
186628Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
196628Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
206628Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
216628Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
226628Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236628Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246628Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256628Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
266628Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276628Ssos *
286628Ssos *	$Id$
296628Ssos */
306628Ssos
316628Ssos#include <sys/param.h>
326628Ssos#include <sys/systm.h>
336628Ssos#include <sys/conf.h>
346628Ssos#include <sys/exec.h>
356628Ssos#include <sys/sysent.h>
366628Ssos#include <sys/lkm.h>
376628Ssos#include <sys/errno.h>
386628Ssos#include <saver.h>
396628Ssos
406628SsosMOD_MISC("fade_saver")
416628Ssos
426628Ssosvoid (*current_saver)();
436628Ssosvoid (*old_saver)();
446628Ssos
456628Ssosstatic void
466628Ssosfade_saver(int blank)
476628Ssos{
486628Ssos	static int count = 0;
496628Ssos	int i;
506628Ssos
516628Ssos	if (blank) {
526628Ssos		scrn_blanked = 1;
536628Ssos		if (count < 64) {
546628Ssos			outb(PIXMASK, 0xFF);		/* no pixelmask */
556628Ssos			outb(PALWADR, 0x00);
566628Ssos			outb(PALDATA, 0);
576628Ssos			outb(PALDATA, 0);
586628Ssos			outb(PALDATA, 0);
596628Ssos			for (i = 3; i < 768; i++) {
606628Ssos				if (palette[i] - count > 15)
616628Ssos					outb(PALDATA, palette[i]-count);
626628Ssos				else
636628Ssos					outb(PALDATA, 15);
646628Ssos			}
656628Ssos			inb(crtc_addr+6);		/* reset flip/flop */
666628Ssos			outb(ATC, 0x20);		/* enable palette */
676628Ssos			count++;
686628Ssos		}
696628Ssos	}
706628Ssos	else {
716628Ssos		load_palette();
726628Ssos		count = scrn_blanked = 0;
736628Ssos	}
746628Ssos}
756628Ssos
766628Ssossaver_load(struct lkm_table *lkmtp, int cmd)
776628Ssos{
786628Ssos	(*current_saver)(0);
796628Ssos	old_saver = current_saver;
806628Ssos	current_saver = fade_saver;
816628Ssos	uprintf("fade screen saver installed\n");
826628Ssos	return 0;
836628Ssos}
846628Ssos
856628Ssossaver_unload(struct lkm_table *lkmtp, int cmd)
866628Ssos{
876628Ssos	(*current_saver)(0);
886628Ssos	current_saver = old_saver;
896628Ssos	uprintf("fade screen saver removed\n");
906628Ssos	return 0;
916628Ssos}
926628Ssos
936628Ssossaver_init(struct lkm_table *lkmtp, int cmd, int ver)
946628Ssos{
956628Ssos	DISPATCH(lkmtp, cmd, ver, saver_load, saver_unload, nosys);
966628Ssos}
97