summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2009-11-04 00:58:20 +0000
committerjkim <jkim@FreeBSD.org>2009-11-04 00:58:20 +0000
commitab813af85f3d4dd2b25a8d283dd239ab98050c60 (patch)
treecaed7b7e44cd27743dccaa80fc899e845a4d6aa2 /sys
parent6652e0b58106a0e0a38f926fd26993c8dd4ce178 (diff)
downloadFreeBSD-src-ab813af85f3d4dd2b25a8d283dd239ab98050c60.zip
FreeBSD-src-ab813af85f3d4dd2b25a8d283dd239ab98050c60.tar.gz
Save/restore VGA color palette while suspending and resuming.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/fb/vgareg.h1
-rw-r--r--sys/isa/vga_isa.c42
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;
OpenPOWER on IntegriCloud