fade_saver.c revision 39287
16628Ssos/*- 239287Ssos * Copyright (c) 1995-1998 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 939287Ssos * notice, this list of conditions and the following disclaimer, 1039287Ssos * without modification, immediately at the beginning of the file. 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 1539287Ssos * derived from this software without 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 * 2839287Ssos * $Id$ 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(fade_saver); 426628Ssos 438871Srgrimesstatic void 446628Ssosfade_saver(int blank) 456628Ssos{ 466628Ssos static int count = 0; 476628Ssos int i; 486628Ssos 496628Ssos if (blank) { 506628Ssos scrn_blanked = 1; 5130095Syokota switch (crtc_type) { 5230095Syokota case KD_VGA: 5330095Syokota if (count < 64) { 5430095Syokota outb(PIXMASK, 0xFF); /* no pixelmask */ 5530095Syokota outb(PALWADR, 0x00); 5630095Syokota outb(PALDATA, 0); 5730095Syokota outb(PALDATA, 0); 5830095Syokota outb(PALDATA, 0); 5930095Syokota for (i = 3; i < 768; i++) { 6030095Syokota if (palette[i] - count > 15) 6130095Syokota outb(PALDATA, palette[i]-count); 6230095Syokota else 6330095Syokota outb(PALDATA, 15); 6430095Syokota } 6530095Syokota inb(crtc_addr+6); /* reset flip/flop */ 6630095Syokota outb(ATC, 0x20); /* enable palette */ 6730095Syokota count++; 686628Ssos } 6930095Syokota break; 7030095Syokota case KD_EGA: 7130095Syokota /* not yet done XXX */ 7230095Syokota break; 7330095Syokota case KD_CGA: 7430095Syokota outb(crtc_addr + 4, 0x25); 7530095Syokota break; 7630095Syokota case KD_MONO: 7730095Syokota case KD_HERCULES: 7830095Syokota outb(crtc_addr + 4, 0x21); 7930095Syokota break; 8030095Syokota default: 8130095Syokota break; 826628Ssos } 836628Ssos } 846628Ssos else { 8530095Syokota switch (crtc_type) { 8630095Syokota case KD_VGA: 8739287Ssos load_palette(cur_console, palette); 8830095Syokota count = 0; 8930095Syokota break; 9030095Syokota case KD_EGA: 9130095Syokota /* not yet done XXX */ 9230095Syokota break; 9330095Syokota case KD_CGA: 9430095Syokota outb(crtc_addr + 4, 0x2d); 9530095Syokota break; 9630095Syokota case KD_MONO: 9730095Syokota case KD_HERCULES: 9830095Syokota outb(crtc_addr + 4, 0x29); 9930095Syokota break; 10030095Syokota default: 10130095Syokota break; 10230095Syokota } 10330095Syokota scrn_blanked = 0; 1046628Ssos } 1056628Ssos} 1066628Ssos 10712276Sbdestatic int 10811857Speterfade_saver_load(struct lkm_table *lkmtp, int cmd) 1096628Ssos{ 11030095Syokota switch (crtc_type) { 11130095Syokota case KD_MONO: 11230095Syokota case KD_HERCULES: 11330095Syokota case KD_CGA: 11430095Syokota /* 11530095Syokota * `fade' saver is not fully implemented for MDA and CGA. 11630095Syokota * It simply blanks the display instead. 11730095Syokota */ 11830095Syokota case KD_VGA: 11930095Syokota break; 12030095Syokota case KD_EGA: 12130095Syokota /* EGA is yet to be supported */ 12230095Syokota default: 12330095Syokota return ENODEV; 12430095Syokota } 12527427Syokota return add_scrn_saver(fade_saver); 1266628Ssos} 1276628Ssos 12812276Sbdestatic int 12911857Speterfade_saver_unload(struct lkm_table *lkmtp, int cmd) 1306628Ssos{ 13127427Syokota return remove_scrn_saver(fade_saver); 1326628Ssos} 1336628Ssos 13412276Sbdeint 13511857Speterfade_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) 1366628Ssos{ 13724673Sdufault MOD_DISPATCH(fade_saver, lkmtp, cmd, ver, 13824673Sdufault fade_saver_load, fade_saver_unload, lkm_nullcmd); 1396628Ssos} 140