From ab813af85f3d4dd2b25a8d283dd239ab98050c60 Mon Sep 17 00:00:00 2001 From: jkim Date: Wed, 4 Nov 2009 00:58:20 +0000 Subject: Save/restore VGA color palette while suspending and resuming. --- sys/dev/fb/vgareg.h | 1 + sys/isa/vga_isa.c | 42 ++++++++++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/sys/dev/fb/vgareg.h b/sys/dev/fb/vgareg.h index 0a73fbd..fa9d44e 100644 --- a/sys/dev/fb/vgareg.h +++ b/sys/dev/fb/vgareg.h @@ -70,6 +70,7 @@ struct video_adapter; typedef struct vga_softc { struct video_adapter *adp; void *state_buf; + void *pal_buf; #ifdef FB_INSTALL_CDEV genfb_softc_t gensc; #endif diff --git a/sys/isa/vga_isa.c b/sys/isa/vga_isa.c index 3d7cd3a..d31df7e 100644 --- a/sys/isa/vga_isa.c +++ b/sys/isa/vga_isa.c @@ -179,17 +179,33 @@ isavga_suspend(device_t dev) nbytes = vidd_save_state(sc->adp, NULL, 0); if (nbytes <= 0) return (0); - sc->state_buf = malloc(nbytes, M_TEMP, M_NOWAIT | M_ZERO); - if (sc->state_buf == NULL) - return (0); - 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; + sc->state_buf = malloc(nbytes, M_TEMP, M_NOWAIT); + if (sc->state_buf != NULL) { + 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 the color palette across the suspend. */ + if (sc->pal_buf != NULL) + free(sc->pal_buf, M_TEMP); + sc->pal_buf = malloc(256 * 3, M_TEMP, M_NOWAIT); + if (sc->pal_buf != NULL) { + 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; + } + } + return (0); } @@ -205,6 +221,12 @@ isavga_resume(device_t dev) free(sc->state_buf, M_TEMP); sc->state_buf = NULL; } + if (sc->pal_buf != NULL) { + if (vidd_load_palette(sc->adp, sc->pal_buf) != 0) + device_printf(dev, "failed to reload palette\n"); + free(sc->pal_buf, M_TEMP); + sc->pal_buf = NULL; + } bus_generic_resume(dev); return 0; -- cgit v1.1