151851Snsayer/*- 251851Snsayer * Copyright (c) 1999 Nick Sayer (who stole shamelessly from blank_saver) 351851Snsayer * All rights reserved. 451851Snsayer * 551851Snsayer * Redistribution and use in source and binary forms, with or without 651851Snsayer * modification, are permitted provided that the following conditions 751851Snsayer * are met: 851851Snsayer * 1. Redistributions of source code must retain the above copyright 951851Snsayer * notice, this list of conditions and the following disclaimer, 1051851Snsayer * without modification, immediately at the beginning of the file. 1151851Snsayer * 2. Redistributions in binary form must reproduce the above copyright 1251851Snsayer * notice, this list of conditions and the following disclaimer in the 1351851Snsayer * documentation and/or other materials provided with the distribution. 1451851Snsayer * 3. The name of the author may not be used to endorse or promote products 1551851Snsayer * derived from this software without specific prior written permission. 1651851Snsayer * 1751851Snsayer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1851851Snsayer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1951851Snsayer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2051851Snsayer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2151851Snsayer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2251851Snsayer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2351851Snsayer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2451851Snsayer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2551851Snsayer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2651851Snsayer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2751851Snsayer * 2851851Snsayer * $FreeBSD$ 2951851Snsayer */ 3051851Snsayer 3151851Snsayer#include <sys/param.h> 3251851Snsayer#include <sys/systm.h> 33158922Simp#include <sys/condvar.h> 3451851Snsayer#include <sys/kernel.h> 35158922Simp#include <sys/kthread.h> 36158922Simp#include <sys/lock.h> 3751851Snsayer#include <sys/module.h> 38158922Simp#include <sys/mutex.h> 3951851Snsayer#include <sys/consio.h> 4051851Snsayer#include <sys/fbio.h> 4151851Snsayer 4251851Snsayer#include <dev/fb/fbreg.h> 4351851Snsayer#include <dev/fb/splashreg.h> 4451851Snsayer#include <dev/syscons/syscons.h> 4551851Snsayer 4670834Swollman#include <sys/selinfo.h> 4751851Snsayer#include <machine/apm_bios.h> 4851851Snsayer#include <machine/pc/bios.h> 4971619Snyan#include <machine/bus.h> 50112551Smdodd#include <i386/bios/apm.h> 5151851Snsayer 5292762Salfredextern int apm_display(int newstate); 5351851Snsayer 5451851Snsayerextern struct apm_softc apm_softc; 5551851Snsayer 5651851Snsayerstatic int blanked=0; 5751851Snsayer 5851851Snsayerstatic int 5951851Snsayerapm_saver(video_adapter_t *adp, int blank) 6051851Snsayer{ 6168103Snsayer if (!apm_softc.initialized || !apm_softc.active) 6251851Snsayer return 0; 6351851Snsayer 6451851Snsayer if (blank==blanked) 6551851Snsayer return 0; 6651851Snsayer 6751851Snsayer blanked=blank; 6851851Snsayer 6951851Snsayer apm_display(!blanked); 7051851Snsayer 7151851Snsayer return 0; 7251851Snsayer} 7351851Snsayer 7451851Snsayerstatic int 7551851Snsayerapm_init(video_adapter_t *adp) 7651851Snsayer{ 7768103Snsayer if (!apm_softc.initialized || !apm_softc.active) 7851851Snsayer printf("WARNING: apm_saver module requires apm enabled\n"); 7951851Snsayer return 0; 8051851Snsayer} 8151851Snsayer 8251851Snsayerstatic int 8351851Snsayerapm_term(video_adapter_t *adp) 8451851Snsayer{ 8551851Snsayer return 0; 8651851Snsayer} 8751851Snsayer 8851851Snsayerstatic scrn_saver_t apm_module = { 8951851Snsayer "apm_saver", apm_init, apm_term, apm_saver, NULL, 9051851Snsayer}; 9151851Snsayer 9251851SnsayerSAVER_MODULE(apm_saver, apm_module); 93110960SruMODULE_DEPEND(apm_saver, apm, 1, 1, 1); 94