Save/restore VGA color palette while suspending and resuming.
This commit is contained in:
parent
1f45f0733b
commit
7ac3e951e3
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user