Module Name:    src
Committed By:   macallan
Date:           Tue Jul 22 04:55:51 UTC 2014

Modified Files:
        src/sys/dev/sbus: tcx.c

Log Message:
restore the right colour map when X exits


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/sbus/tcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sbus/tcx.c
diff -u src/sys/dev/sbus/tcx.c:1.54 src/sys/dev/sbus/tcx.c:1.55
--- src/sys/dev/sbus/tcx.c:1.54	Wed Jul 16 17:58:35 2014
+++ src/sys/dev/sbus/tcx.c	Tue Jul 22 04:55:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcx.c,v 1.54 2014/07/16 17:58:35 macallan Exp $ */
+/*	$NetBSD: tcx.c,v 1.55 2014/07/22 04:55:51 macallan Exp $ */
 
 /*
  *  Copyright (c) 1996, 1998, 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.54 2014/07/16 17:58:35 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.55 2014/07/22 04:55:51 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -163,6 +163,7 @@ static void tcx_loadcmap(struct tcx_soft
 static int	tcx_ioctl(void *, void *, u_long, void *, int, struct lwp *);
 static paddr_t	tcx_mmap(void *, void *, off_t, int);
 
+static void	tcx_init_cmap(struct tcx_softc *);
 static void	tcx_init_screen(void *, struct vcons_screen *, int, long *);
 static void	tcx_clearscreen(struct tcx_softc *, int);
 static void	tcx_copyrows(void *, int, int, int);
@@ -212,7 +213,7 @@ tcxattach(device_t parent, device_t self
 	int node;
 	struct fbdevice *fb = &sc->sc_fb;
 	bus_space_handle_t bh;
-	int isconsole, i, j;
+	int isconsole;
 	uint32_t confreg;
 
 	sc->sc_dev = self;
@@ -377,17 +378,6 @@ tcxattach(device_t parent, device_t self
 	/* reset cursor & frame buffer controls */
 	tcx_reset(sc);
 
-	/* Initialize the default color map. */
-	j = 0;
-	for (i = 0; i < 256; i++) {
-
-		sc->sc_cmap_red[i] = rasops_cmap[j];
-		sc->sc_cmap_green[i] = rasops_cmap[j + 1];
-		sc->sc_cmap_blue[i] = rasops_cmap[j + 2];
-		j += 3;
-	}
-	tcx_loadcmap(sc, 0, 256);
-
 	if (!sc->sc_8bit)
 	    tcx_set_cursor(sc);
 
@@ -415,6 +405,7 @@ tcxattach(device_t parent, device_t self
 
 	sc->sc_bg = ri->ri_devcmap[(defattr >> 16) & 0xff];
 	tcx_clearscreen(sc, 0);
+	tcx_init_cmap(sc);
 
 	tcx_defscreendesc.nrows = ri->ri_rows;
 	tcx_defscreendesc.ncols = ri->ri_cols;
@@ -536,6 +527,23 @@ tcx_reset(struct tcx_softc *sc)
 }
 
 static void
+tcx_init_cmap(struct tcx_softc *sc)
+{
+	int i, j;
+
+	/* Initialize the default color map. */
+	j = 0;
+	for (i = 0; i < 256; i++) {
+
+		sc->sc_cmap_red[i] = rasops_cmap[j];
+		sc->sc_cmap_green[i] = rasops_cmap[j + 1];
+		sc->sc_cmap_blue[i] = rasops_cmap[j + 2];
+		j += 3;
+	}
+	tcx_loadcmap(sc, 0, 256);
+}
+
+static void
 tcx_loadcmap(struct tcx_softc *sc, int start, int ncolors)
 {
 	int i;
@@ -760,7 +768,7 @@ tcx_ioctl(void *v, void *vs, u_long cmd,
 					sc->sc_mode = new_mode;
 					if (new_mode == WSDISPLAYIO_MODE_EMUL)
 					{
-						tcx_loadcmap(sc, 0, 256);
+						tcx_init_cmap(sc);
 						tcx_clearscreen(sc, 0);
 						vcons_redraw_screen(ms);
 					} else if (!sc->sc_8bit)

Reply via email to