1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/isa/vga_isa.c 198964 2009-11-05 22:58:50Z jkim $"); |
29 30#include "opt_vga.h" 31#include "opt_fb.h" 32#include "opt_syscons.h" /* should be removed in the future, XXX */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> --- 124 unchanged lines hidden (view full) --- 161} 162 163static int 164isavga_suspend(device_t dev) 165{ 166 vga_softc_t *sc; 167 int err, nbytes; 168 |
169 err = bus_generic_suspend(dev); 170 if (err) 171 return (err); 172 |
173 sc = device_get_softc(dev); 174 |
175 /* Save the video state across the suspend. */ |
176 if (sc->state_buf != NULL) 177 goto save_palette; |
178 nbytes = vidd_save_state(sc->adp, NULL, 0); 179 if (nbytes <= 0) |
180 goto save_palette; |
181 sc->state_buf = malloc(nbytes, M_TEMP, M_NOWAIT); |
182 if (sc->state_buf == NULL) 183 goto save_palette; 184 if (bootverbose) 185 device_printf(dev, "saving %d bytes of video state\n", nbytes); 186 if (vidd_save_state(sc->adp, sc->state_buf, nbytes) != 0) { 187 device_printf(dev, "failed to save state (nbytes=%d)\n", 188 nbytes); 189 free(sc->state_buf, M_TEMP); 190 sc->state_buf = NULL; |
191 } 192 |
193save_palette: |
194 /* Save the color palette across the suspend. */ 195 if (sc->pal_buf != NULL) |
196 return (0); |
197 sc->pal_buf = malloc(256 * 3, M_TEMP, M_NOWAIT); 198 if (sc->pal_buf != NULL) { 199 if (bootverbose) 200 device_printf(dev, "saving color palette\n"); 201 if (vidd_save_palette(sc->adp, sc->pal_buf) != 0) { 202 device_printf(dev, "failed to save palette\n"); 203 free(sc->pal_buf, M_TEMP); 204 sc->pal_buf = NULL; --- 4 unchanged lines hidden (view full) --- 209} 210 211static int 212isavga_resume(device_t dev) 213{ 214 vga_softc_t *sc; 215 216 sc = device_get_softc(dev); |
217 |
218 if (sc->state_buf != NULL) { 219 if (vidd_load_state(sc->adp, sc->state_buf) != 0) 220 device_printf(dev, "failed to reload state\n"); 221 free(sc->state_buf, M_TEMP); 222 sc->state_buf = NULL; 223 } 224 if (sc->pal_buf != NULL) { 225 if (vidd_load_palette(sc->adp, sc->pal_buf) != 0) 226 device_printf(dev, "failed to reload palette\n"); 227 free(sc->pal_buf, M_TEMP); 228 sc->pal_buf = NULL; 229 } 230 |
231 return (bus_generic_resume(dev)); |
232} 233 234#ifdef FB_INSTALL_CDEV 235 236static int 237isavga_open(struct cdev *dev, int flag, int mode, struct thread *td) 238{ 239 return vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td); --- 52 unchanged lines hidden --- |