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: fade_saver.c,v 1.14 1998/09/17 19:40:30 sos Exp $ 29 */ 30 31 #include <sys/param.h> 32 #include <sys/systm.h> 33 #include <sys/kernel.h> 34 #include <sys/module.h> 35 36 #include <i386/isa/isa.h> 37 38 #include <saver.h> 39 40 static void 41 fade_saver(int blank) 42 { 43 static int count = 0; 44 u_char pal[256*3]; 45 int i; 46 47 if (blank) { 48 scrn_blanked = 1; 49 cur_console->status |= SAVER_RUNNING; 50 switch (crtc_type) { 51 case KD_VGA: 52 if (count < 64) { 53 pal[0] = pal[1] = pal[2] = 0; 54 for (i = 3; i < 256*3; i++) { 55 if (palette[i] - count > 60) 56 pal[i] = palette[i] - count; 57 else 58 pal[i] = 60; 59 } 60 load_palette(cur_console, pal); 61 count++; 62 } 63 break; 64 case KD_EGA: 65 /* not yet done XXX */ 66 break; 67 case KD_CGA: 68 outb(crtc_addr + 4, 0x25); 69 break; 70 case KD_MONO: 71 case KD_HERCULES: 72 outb(crtc_addr + 4, 0x21); 73 break; 74 default: 75 break; 76 } 77 } 78 else { 79 switch (crtc_type) { 80 case KD_VGA: 81 load_palette(cur_console, palette); 82 count = 0; 83 break; 84 case KD_EGA: 85 /* not yet done XXX */ 86 break; 87 case KD_CGA: 88 outb(crtc_addr + 4, 0x2d); 89 break; 90 case KD_MONO: 91 case KD_HERCULES: 92 outb(crtc_addr + 4, 0x29); 93 break; 94 default: 95 break; 96 } 97 cur_console->status &= ~SAVER_RUNNING; 98 scrn_blanked = 0; 99 } 100 } 101 102 static int 103 fade_saver_load(void) 104 { 105 switch (crtc_type) { 106 case KD_MONO: 107 case KD_HERCULES: 108 case KD_CGA: 109 /* 110 * `fade' saver is not fully implemented for MDA and CGA. 111 * It simply blanks the display instead. 112 */ 113 case KD_VGA: 114 break; 115 case KD_EGA: 116 /* EGA is yet to be supported */ 117 default: 118 return ENODEV; 119 } 120 return add_scrn_saver(fade_saver); 121 } 122 123 static int 124 fade_saver_unload(void) 125 { 126 return remove_scrn_saver(fade_saver); 127 } 128 129 SAVER_MODULE(fade_saver); 130