16628Ssos/*- 2230132Suqs * Copyright (c) 1995-1998 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 939287Ssos * notice, this list of conditions and the following disclaimer, 1039287Ssos * without modification, immediately at the beginning of the file. 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 1539287Ssos * derived from this software without 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 * 2850477Speter * $FreeBSD: releng/10.3/sys/dev/syscons/fade/fade_saver.c 230132 2012-01-15 13:23:18Z uqs $ 296628Ssos */ 306628Ssos 316628Ssos#include <sys/param.h> 326628Ssos#include <sys/systm.h> 3340885Speter#include <sys/kernel.h> 3440885Speter#include <sys/module.h> 3548104Syokota#include <sys/consio.h> 3648104Syokota#include <sys/fbio.h> 3727427Syokota 3848104Syokota#include <dev/fb/fbreg.h> 3948104Syokota#include <dev/fb/splashreg.h> 4048104Syokota#include <dev/syscons/syscons.h> 4127427Syokota 4242504Syokotastatic u_char palette[256*3]; 4342504Syokota 4442504Syokotastatic int 4542504Syokotafade_saver(video_adapter_t *adp, int blank) 466628Ssos{ 476628Ssos static int count = 0; 4839428Ssos u_char pal[256*3]; 496628Ssos int i; 506628Ssos 516628Ssos if (blank) { 5248104Syokota if (ISPALAVAIL(adp->va_flags)) { 5342504Syokota if (count <= 0) 54174985Swkoszek vidd_save_palette(adp, palette); 5548104Syokota if (count < 256) { 5639428Ssos pal[0] = pal[1] = pal[2] = 0; 5739428Ssos for (i = 3; i < 256*3; i++) { 5839428Ssos if (palette[i] - count > 60) 5939428Ssos pal[i] = palette[i] - count; 6030095Syokota else 6139428Ssos pal[i] = 60; 6230095Syokota } 63174985Swkoszek vidd_load_palette(adp, pal); 6430095Syokota count++; 656628Ssos } 6648104Syokota } else { 67174985Swkoszek vidd_blank_display(adp, V_DISPLAY_BLANK); 686628Ssos } 6948104Syokota } else { 7048104Syokota if (ISPALAVAIL(adp->va_flags)) { 71174985Swkoszek vidd_load_palette(adp, palette); 7230095Syokota count = 0; 7348104Syokota } else { 74174985Swkoszek vidd_blank_display(adp, V_DISPLAY_ON); 7530095Syokota } 766628Ssos } 7742504Syokota return 0; 786628Ssos} 796628Ssos 8012276Sbdestatic int 8142504Syokotafade_init(video_adapter_t *adp) 826628Ssos{ 83174985Swkoszek if (!ISPALAVAIL(adp->va_flags) && 84174985Swkoszek vidd_blank_display(adp, V_DISPLAY_ON) != 0) 8530095Syokota return ENODEV; 8642504Syokota return 0; 876628Ssos} 886628Ssos 8912276Sbdestatic int 9042504Syokotafade_term(video_adapter_t *adp) 916628Ssos{ 9242504Syokota return 0; 936628Ssos} 946628Ssos 9542504Syokotastatic scrn_saver_t fade_module = { 9642504Syokota "fade_saver", fade_init, fade_term, fade_saver, NULL, 9742504Syokota}; 9842504Syokota 9942504SyokotaSAVER_MODULE(fade_saver, fade_module); 100