fade_saver.c revision 39428
1258945Sroberto/*- 2258945Sroberto * Copyright (c) 1995-1998 S�ren Schmidt 3258945Sroberto * All rights reserved. 4258945Sroberto * 5258945Sroberto * Redistribution and use in source and binary forms, with or without 6258945Sroberto * modification, are permitted provided that the following conditions 7258945Sroberto * are met: 8258945Sroberto * 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: fade_saver.c,v 1.13 1998/09/15 18:16:39 sos Exp $ 29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/exec.h> 34#include <sys/sysent.h> 35#include <sys/lkm.h> 36 37#include <i386/isa/isa.h> 38 39#include <saver.h> 40 41MOD_MISC(fade_saver); 42 43static void 44fade_saver(int blank) 45{ 46 static int count = 0; 47 u_char pal[256*3]; 48 int i; 49 50 if (blank) { 51 scrn_blanked = 1; 52 cur_console->status |= SAVER_RUNNING; 53 switch (crtc_type) { 54 case KD_VGA: 55 if (count < 64) { 56 pal[0] = pal[1] = pal[2] = 0; 57 for (i = 3; i < 256*3; i++) { 58 if (palette[i] - count > 60) 59 pal[i] = palette[i] - count; 60 else 61 pal[i] = 60; 62 } 63 load_palette(cur_console, pal); 64 count++; 65 } 66 break; 67 case KD_EGA: 68 /* not yet done XXX */ 69 break; 70 case KD_CGA: 71 outb(crtc_addr + 4, 0x25); 72 break; 73 case KD_MONO: 74 case KD_HERCULES: 75 outb(crtc_addr + 4, 0x21); 76 break; 77 default: 78 break; 79 } 80 } 81 else { 82 switch (crtc_type) { 83 case KD_VGA: 84 load_palette(cur_console, palette); 85 count = 0; 86 break; 87 case KD_EGA: 88 /* not yet done XXX */ 89 break; 90 case KD_CGA: 91 outb(crtc_addr + 4, 0x2d); 92 break; 93 case KD_MONO: 94 case KD_HERCULES: 95 outb(crtc_addr + 4, 0x29); 96 break; 97 default: 98 break; 99 } 100 cur_console->status &= ~SAVER_RUNNING; 101 scrn_blanked = 0; 102 } 103} 104 105static int 106fade_saver_load(struct lkm_table *lkmtp, int cmd) 107{ 108 switch (crtc_type) { 109 case KD_MONO: 110 case KD_HERCULES: 111 case KD_CGA: 112 /* 113 * `fade' saver is not fully implemented for MDA and CGA. 114 * It simply blanks the display instead. 115 */ 116 case KD_VGA: 117 break; 118 case KD_EGA: 119 /* EGA is yet to be supported */ 120 default: 121 return ENODEV; 122 } 123 return add_scrn_saver(fade_saver); 124} 125 126static int 127fade_saver_unload(struct lkm_table *lkmtp, int cmd) 128{ 129 return remove_scrn_saver(fade_saver); 130} 131 132int 133fade_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) 134{ 135 MOD_DISPATCH(fade_saver, lkmtp, cmd, ver, 136 fade_saver_load, fade_saver_unload, lkm_nullcmd); 137} 138