示例#1
0
static int
fade_saver(video_adapter_t *adp, int blank)
{
	static int count = 0;
	u_char pal[256*3];
	int i;

	if (blank) {
		if (ISPALAVAIL(adp->va_flags)) {
			if (count <= 0)
				vidd_save_palette(adp, palette);
			if (count < 256) {
				pal[0] = pal[1] = pal[2] = 0;
				for (i = 3; i < 256*3; i++) {
					if (palette[i] - count > 60)
						pal[i] = palette[i] - count;
					else
						pal[i] = 60;
				}
				vidd_load_palette(adp, pal);
				count++;
			}
		} else {
	    		vidd_blank_display(adp, V_DISPLAY_BLANK);
		}
	} else {
		if (ISPALAVAIL(adp->va_flags)) {
			vidd_load_palette(adp, palette);
			count = 0;
		} else {
	    		vidd_blank_display(adp, V_DISPLAY_ON);
		}
	}
	return 0;
}
static int
bmp_splash(video_adapter_t *adp, int on)
{
    static u_char	pal[256*3];
    static long		time_stamp;
    u_char		tpal[256*3];
    static int		fading = TRUE, brightness = FADE_LEVELS;
    struct timeval	tv;
    int			i;

    if (on) {
	if (!splash_on) {
	    /* set up the video mode and draw something */
	    if (vidd_set_mode(adp, splash_mode))
		return 1;
	    if (bmp_Draw(adp))
		return 1;
	    vidd_save_palette(adp, pal);
	    time_stamp = 0;
	    splash_on = TRUE;
	}
	/*
	 * This is a kludge to fade the image away.  This section of the 
	 * code takes effect only after the system is completely up.
	 * FADE_TIMEOUT should be configurable.
	 */
	if (!cold) {
	    getmicrotime(&tv);
	    if (time_stamp == 0)
		time_stamp = tv.tv_sec;
	    if (tv.tv_sec > time_stamp + FADE_TIMEOUT) {
		if (fading)
		    if (brightness == 0) {
			fading = FALSE;
			brightness++;
		    }
		    else brightness--;
		else
		    if (brightness == FADE_LEVELS) {
			fading = TRUE;
			brightness--;
		    }
		    else brightness++;
		for (i = 0; i < sizeof(pal); ++i) {
		    tpal[i] = pal[i] * brightness / FADE_LEVELS;
		}
		vidd_load_palette(adp, tpal);
		time_stamp = tv.tv_sec;
	    }
	}
	return 0;
    } else {
	/* the video mode will be restored by the caller */
	splash_on = FALSE;
	return 0;
    }
}
示例#3
0
static void
vga_suspend(device_t dev)
{
	vga_softc_t *sc;
	int nbytes;

	sc = device_get_softc(dev);

	/* Save the video state across the suspend. */
	if (sc->state_buf != NULL)
		goto save_palette;
	nbytes = vidd_save_state(sc->adp, NULL, 0);
	if (nbytes <= 0)
		goto save_palette;
	sc->state_buf = malloc(nbytes, M_TEMP, M_NOWAIT);
	if (sc->state_buf == NULL)
		goto save_palette;
	if (bootverbose)
		device_printf(dev, "saving %d bytes of video state\n", nbytes);
	if (vidd_save_state(sc->adp, sc->state_buf, nbytes) != 0) {
		device_printf(dev, "failed to save state (nbytes=%d)\n",
		    nbytes);
		free(sc->state_buf, M_TEMP);
		sc->state_buf = NULL;
	}

save_palette:
	/* Save the color palette across the suspend. */
	if (sc->pal_buf != NULL)
		return;
	sc->pal_buf = malloc(256 * 3, M_TEMP, M_NOWAIT);
	if (sc->pal_buf == NULL)
		return;
	if (bootverbose)
		device_printf(dev, "saving color palette\n");
	if (vidd_save_palette(sc->adp, sc->pal_buf) != 0) {
		device_printf(dev, "failed to save palette\n");
		free(sc->pal_buf, M_TEMP);
		sc->pal_buf = NULL;
	}
}