Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Nov 2009 00:58:20 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r198866 - in head/sys: dev/fb isa
Message-ID:  <200911040058.nA40wKZp011756@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Wed Nov  4 00:58:20 2009
New Revision: 198866
URL: http://svn.freebsd.org/changeset/base/198866

Log:
  Save/restore VGA color palette while suspending and resuming.

Modified:
  head/sys/dev/fb/vgareg.h
  head/sys/isa/vga_isa.c

Modified: head/sys/dev/fb/vgareg.h
==============================================================================
--- head/sys/dev/fb/vgareg.h	Tue Nov  3 23:26:58 2009	(r198865)
+++ head/sys/dev/fb/vgareg.h	Wed Nov  4 00:58:20 2009	(r198866)
@@ -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

Modified: head/sys/isa/vga_isa.c
==============================================================================
--- head/sys/isa/vga_isa.c	Tue Nov  3 23:26:58 2009	(r198865)
+++ head/sys/isa/vga_isa.c	Wed Nov  4 00:58:20 2009	(r198866)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911040058.nA40wKZp011756>