Deleted Added
full compact
vga_isa.c (198866) vga_isa.c (198964)
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>
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 198866 2009-11-04 00:58:20Z jkim $");
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
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 sc = device_get_softc(dev);
170 err = bus_generic_suspend(dev);
171 if (err)
172 return (err);
173
169 err = bus_generic_suspend(dev);
170 if (err)
171 return (err);
172
173 sc = device_get_softc(dev);
174
174 /* Save the video state across the suspend. */
175 /* Save the video state across the suspend. */
175 if (sc->state_buf != NULL) {
176 free(sc->state_buf, M_TEMP);
177 sc->state_buf = NULL;
178 }
176 if (sc->state_buf != NULL)
177 goto save_palette;
179 nbytes = vidd_save_state(sc->adp, NULL, 0);
180 if (nbytes <= 0)
178 nbytes = vidd_save_state(sc->adp, NULL, 0);
179 if (nbytes <= 0)
181 return (0);
180 goto save_palette;
182 sc->state_buf = malloc(nbytes, M_TEMP, M_NOWAIT);
181 sc->state_buf = malloc(nbytes, M_TEMP, M_NOWAIT);
183 if (sc->state_buf != NULL) {
184 if (bootverbose)
185 device_printf(dev, "saving %d bytes of video state\n",
186 nbytes);
187 if (vidd_save_state(sc->adp, sc->state_buf, nbytes) != 0) {
188 device_printf(dev, "failed to save state (nbytes=%d)\n",
189 nbytes);
190 free(sc->state_buf, M_TEMP);
191 sc->state_buf = NULL;
192 }
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;
193 }
194
191 }
192
193save_palette:
195 /* Save the color palette across the suspend. */
196 if (sc->pal_buf != NULL)
194 /* Save the color palette across the suspend. */
195 if (sc->pal_buf != NULL)
197 free(sc->pal_buf, M_TEMP);
196 return (0);
198 sc->pal_buf = malloc(256 * 3, M_TEMP, M_NOWAIT);
199 if (sc->pal_buf != NULL) {
200 if (bootverbose)
201 device_printf(dev, "saving color palette\n");
202 if (vidd_save_palette(sc->adp, sc->pal_buf) != 0) {
203 device_printf(dev, "failed to save palette\n");
204 free(sc->pal_buf, M_TEMP);
205 sc->pal_buf = NULL;

--- 4 unchanged lines hidden (view full) ---

210}
211
212static int
213isavga_resume(device_t dev)
214{
215 vga_softc_t *sc;
216
217 sc = device_get_softc(dev);
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
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 bus_generic_resume(dev);
232 return 0;
231 return (bus_generic_resume(dev));
233}
234
235#ifdef FB_INSTALL_CDEV
236
237static int
238isavga_open(struct cdev *dev, int flag, int mode, struct thread *td)
239{
240 return vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td);

--- 52 unchanged lines hidden ---
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 ---