1228445Seadler/*- 2228445Seadler * Copyright (c) 1999 Michael Smith <msmith@freebsd.org> 3228445Seadler * Copyright (c) 1999 Kazutaka YOKOTA <yokota@freebsd.org> 4228445Seadler * Copyright (c) 2005 Antony Mawer <antony@mawer.org> 5228445Seadler * All rights reserved. 6228445Seadler * 7228445Seadler * Redistribution and use in source and binary forms, with or without 8228445Seadler * modification, are permitted provided that the following conditions 9228445Seadler * are met: 10228445Seadler * 1. Redistributions of source code must retain the above copyright 11228445Seadler * notice, this list of conditions and the following disclaimer. 12228445Seadler * 2. Redistributions in binary form must reproduce the above copyright 13228445Seadler * notice, this list of conditions and the following disclaimer in the 14228445Seadler * documentation and/or other materials provided with the distribution. 15228445Seadler * 16228445Seadler * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 17228445Seadler * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18228445Seadler * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19228445Seadler * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 20228445Seadler * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21228445Seadler * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22228445Seadler * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23228445Seadler * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24228445Seadler * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25228445Seadler * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26228445Seadler * SUCH DAMAGE. 27228445Seadler * 28228445Seadler * $FreeBSD$ 29228445Seadler */ 30228445Seadler 31228445Seadler#include <sys/param.h> 32228445Seadler#include <sys/systm.h> 33228445Seadler#include <sys/module.h> 34228445Seadler#include <sys/kernel.h> 35228445Seadler#include <sys/consio.h> 36228445Seadler#include <sys/fbio.h> 37228445Seadler 38228445Seadler#include <machine/pc/display.h> 39228445Seadler 40228445Seadler#include <dev/fb/fbreg.h> 41228445Seadler#include <dev/fb/splashreg.h> 42228445Seadler#include <dev/syscons/syscons.h> 43228445Seadler 44228445Seadlerstatic int splash_on = FALSE; 45228445Seadler 46228445Seadlerstatic int txt_init(video_adapter_t *adp); 47228445Seadlerstatic int txt_end(video_adapter_t *adp); 48228445Seadlerstatic int txt_splash(video_adapter_t * adp, const int on); 49228445Seadler 50228445Seadler/* These are rows by columns of the text-mode display device. */ 51228445Seadler#define BIN_IMAGE_WIDTH 80 52228445Seadler#define BIN_IMAGE_HEIGHT 25 53228445Seadler 54228445Seadlerstatic splash_decoder_t txt_decoder = { 55228445Seadler .name = "splash_txt", 56228445Seadler .init = txt_init, 57228445Seadler .term = txt_end, 58228445Seadler .splash = txt_splash, 59228445Seadler .data_type = SPLASH_IMAGE, 60228445Seadler}; 61228445Seadler 62228445SeadlerSPLASH_DECODER(splash_txt, txt_decoder); 63228445Seadler 64228445Seadlerstatic void 65228445Seadlerdraw_text_splash(sc_softc_t *sc) 66228445Seadler{ 67228445Seadler u_int x, y; 68228445Seadler u_char ch, attr; 69228445Seadler u_char *pdata = txt_decoder.data; 70228445Seadler 71228445Seadler /* Init failed. */ 72228445Seadler if (txt_decoder.data == NULL) 73228445Seadler return; 74228445Seadler for (y = 0; y < BIN_IMAGE_HEIGHT; y++) { 75228445Seadler for (x = 0; x < BIN_IMAGE_WIDTH; x++) { 76228445Seadler ch = *pdata++; 77228445Seadler attr = *pdata++; 78228445Seadler sc_vtb_putc(&sc->cur_scp->scr, 79228445Seadler (y * sc->cur_scp->xsize) + x, 80228445Seadler sc->scr_map[ch], (int)attr << 8); 81228445Seadler } 82228445Seadler } 83228445Seadler} 84228445Seadler 85228445Seadlerstatic int 86228445Seadlertxt_init(video_adapter_t *adp) 87228445Seadler{ 88228445Seadler 89228445Seadler /* Ensure that the image data exists. */ 90228445Seadler if (txt_decoder.data == NULL || txt_decoder.data_size <= 0) { 91228445Seadler printf("splash_txt: No ASCII bitmap file found\n"); 92228445Seadler return (ENODEV); 93228445Seadler } 94228445Seadler return (0); 95228445Seadler} 96228445Seadler 97228445Seadlerstatic int 98228445Seadlertxt_end(video_adapter_t *adp) 99228445Seadler{ 100228445Seadler 101228445Seadler return (0); 102228445Seadler} 103228445Seadler 104228445Seadlerstatic int 105228445Seadlertxt_splash(video_adapter_t *adp, const int on) 106228445Seadler{ 107228445Seadler sc_softc_t *sc; 108228445Seadler scr_stat *scp; 109228445Seadler 110228445Seadler sc = sc_find_softc(adp, NULL); 111228445Seadler if (sc == NULL) 112228445Seadler return (EAGAIN); 113228445Seadler scp = sc->cur_scp; 114228445Seadler if (on) { 115228445Seadler if (!splash_on) { 116228445Seadler if (adp->va_info.vi_flags & V_INFO_GRAPHICS) 117228445Seadler return EAGAIN; 118228445Seadler /* Clear screen and set border colour. */ 119228445Seadler sc_vtb_clear(&scp->scr, sc->scr_map[0x20], 120228445Seadler (FG_LIGHTGREY | BG_BLACK) << 8); 121228445Seadler (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1); 122228445Seadler sc_set_border(scp, 0); 123228445Seadler splash_on = TRUE; 124228445Seadler /* Display the splash screen. */ 125228445Seadler draw_text_splash(sc); 126228445Seadler } 127228445Seadler return (0); 128228445Seadler } else { 129228445Seadler /* The video mode will be restored by the caller. */ 130228445Seadler splash_on = FALSE; 131228445Seadler return (0); 132228445Seadler } 133228445Seadler} 134228445Seadler 135228445Seadler 136