green_saver.c revision 27427
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
98871Srgrimes *    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 *
2827427Syokota *	$Id: green_saver.c,v 1.9 1997/04/06 10:49:13 dufault Exp $
296628Ssos */
306628Ssos
316628Ssos#include <sys/param.h>
326628Ssos#include <sys/systm.h>
336628Ssos#include <sys/exec.h>
346628Ssos#include <sys/sysent.h>
356628Ssos#include <sys/lkm.h>
3627427Syokota
3727427Syokota#include <i386/isa/isa.h>
3827427Syokota
396628Ssos#include <saver.h>
406628Ssos
4112276SbdeMOD_MISC(green_saver);
426628Ssos
438871Srgrimesstatic void
446628Ssosgreen_saver(int blank)
456628Ssos{
466628Ssos	u_char val;
476628Ssos	if (blank) {
486628Ssos		scrn_blanked = 1;
498871Srgrimes		outb(TSIDX, 0x01); val = inb(TSREG);
506628Ssos		outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
516628Ssos		outb(crtc_addr, 0x17); val = inb(crtc_addr + 1);
526628Ssos		outb(crtc_addr + 1, val & ~0x80);
536628Ssos	}
546628Ssos	else {
558871Srgrimes		outb(TSIDX, 0x01); val = inb(TSREG);
566628Ssos		outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
576628Ssos		outb(crtc_addr, 0x17); val = inb(crtc_addr + 1);
586628Ssos		outb(crtc_addr + 1, val | 0x80);
596628Ssos		scrn_blanked = 0;
606628Ssos	}
616628Ssos}
626628Ssos
6312276Sbdestatic int
6411857Spetergreen_saver_load(struct lkm_table *lkmtp, int cmd)
656628Ssos{
6627427Syokota	if (!crtc_vga)
6727427Syokota		return EINVAL;
6827427Syokota	return add_scrn_saver(green_saver);
696628Ssos}
706628Ssos
7112276Sbdestatic int
7211857Spetergreen_saver_unload(struct lkm_table *lkmtp, int cmd)
736628Ssos{
7427427Syokota	return remove_scrn_saver(green_saver);
756628Ssos}
766628Ssos
7712276Sbdeint
7811857Spetergreen_saver_mod(struct lkm_table *lkmtp, int cmd, int ver)
796628Ssos{
8024673Sdufault	MOD_DISPATCH(green_saver, lkmtp, cmd, ver,
8124673Sdufault		green_saver_load, green_saver_unload, lkm_nullcmd);
826628Ssos}
83