fade_saver.c revision 39287
1/*- 2 * Copyright (c) 1995-1998 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 * 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$ 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 int i; 48 49 if (blank) { 50 scrn_blanked = 1; 51 switch (crtc_type) { 52 case KD_VGA: 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 break; 70 case KD_EGA: 71 /* not yet done XXX */ 72 break; 73 case KD_CGA: 74 outb(crtc_addr + 4, 0x25); 75 break; 76 case KD_MONO: 77 case KD_HERCULES: 78 outb(crtc_addr + 4, 0x21); 79 break; 80 default: 81 break; 82 } 83 } 84 else { 85 switch (crtc_type) { 86 case KD_VGA: 87 load_palette(cur_console, palette); 88 count = 0; 89 break; 90 case KD_EGA: 91 /* not yet done XXX */ 92 break; 93 case KD_CGA: 94 outb(crtc_addr + 4, 0x2d); 95 break; 96 case KD_MONO: 97 case KD_HERCULES: 98 outb(crtc_addr + 4, 0x29); 99 break; 100 default: 101 break; 102 } 103 scrn_blanked = 0; 104 } 105} 106 107static int 108fade_saver_load(struct lkm_table *lkmtp, int cmd) 109{ 110 switch (crtc_type) { 111 case KD_MONO: 112 case KD_HERCULES: 113 case KD_CGA: 114 /* 115 * `fade' saver is not fully implemented for MDA and CGA. 116 * It simply blanks the display instead. 117 */ 118 case KD_VGA: 119 break; 120 case KD_EGA: 121 /* EGA is yet to be supported */ 122 default: 123 return ENODEV; 124 } 125 return add_scrn_saver(fade_saver); 126} 127 128static int 129fade_saver_unload(struct lkm_table *lkmtp, int cmd) 130{ 131 return remove_scrn_saver(fade_saver); 132} 133 134int 135fade_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) 136{ 137 MOD_DISPATCH(fade_saver, lkmtp, cmd, ver, 138 fade_saver_load, fade_saver_unload, lkm_nullcmd); 139} 140