green_saver.c revision 24673
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 * 2824673Sdufault * $Id: green_saver.c,v 1.8 1997/02/22 12:49:15 peter Exp $ 296628Ssos */ 306628Ssos 316628Ssos#include <sys/param.h> 326628Ssos#include <sys/systm.h> 336628Ssos#include <sys/conf.h> 346628Ssos#include <sys/exec.h> 356628Ssos#include <sys/sysent.h> 366628Ssos#include <sys/lkm.h> 376628Ssos#include <sys/errno.h> 386628Ssos#include <saver.h> 396628Ssos 4012276SbdeMOD_MISC(green_saver); 416628Ssos 4212276Sbdevoid (*current_saver)(int blank); 4312276Sbdevoid (*old_saver)(int blank); 446628Ssos 458871Srgrimesstatic void 466628Ssosgreen_saver(int blank) 476628Ssos{ 486628Ssos u_char val; 496628Ssos if (blank) { 506628Ssos scrn_blanked = 1; 518871Srgrimes outb(TSIDX, 0x01); val = inb(TSREG); 526628Ssos outb(TSIDX, 0x01); outb(TSREG, val | 0x20); 536628Ssos outb(crtc_addr, 0x17); val = inb(crtc_addr + 1); 546628Ssos outb(crtc_addr + 1, val & ~0x80); 556628Ssos } 566628Ssos else { 578871Srgrimes outb(TSIDX, 0x01); val = inb(TSREG); 586628Ssos outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); 596628Ssos outb(crtc_addr, 0x17); val = inb(crtc_addr + 1); 606628Ssos outb(crtc_addr + 1, val | 0x80); 616628Ssos scrn_blanked = 0; 626628Ssos } 636628Ssos} 646628Ssos 6512276Sbdestatic int 6611857Spetergreen_saver_load(struct lkm_table *lkmtp, int cmd) 676628Ssos{ 686628Ssos (*current_saver)(0); 696628Ssos old_saver = current_saver; 706628Ssos current_saver = green_saver; 716628Ssos return 0; 726628Ssos} 736628Ssos 7412276Sbdestatic int 7511857Spetergreen_saver_unload(struct lkm_table *lkmtp, int cmd) 766628Ssos{ 776628Ssos (*current_saver)(0); 786628Ssos current_saver = old_saver; 796628Ssos return 0; 806628Ssos} 816628Ssos 8212276Sbdeint 8311857Spetergreen_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) 846628Ssos{ 8524673Sdufault MOD_DISPATCH(green_saver, lkmtp, cmd, ver, 8624673Sdufault green_saver_load, green_saver_unload, lkm_nullcmd); 876628Ssos} 88