Subject: port-playstation2/32730: [gsfb] setting WS_DEFAULT_[FB]G does not change colours entirely
To: None <port-playstation2-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: None <ed@fxq.nl>
List: netbsd-bugs
Date: 02/04/2006 14:50:00
>Number:         32730
>Category:       port-playstation2
>Synopsis:       [gsfb] setting WS_DEFAULT_[FB]G does not change colours entirely
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-playstation2-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 04 14:50:00 +0000 2006
>Originator:     Ed Schouten
>Release:        NetBSD 3.99.15
>Organization:
n/a
>Environment:
System: NetBSD sony.fxq.nl 3.99.15 NetBSD 3.99.15 (SONY) #4: Sat Feb  4 15:35:54 CET 2006  root@compy.fxq.nl:/usr/obj/sys/arch/playstation2/compile/SONY playstation2
Architecture: mipsel
Machine: playstation2
>Description:
The gsfb driver hardcodes WSCOL_WHITE and WSCOL_BLACK on certain places,
which means that setting WS_DEFAULT_FG and WS_DEFAULT_BG in your kernel
config wouldn't entirely change the framebuffer's colours.

>How-To-Repeat:
Build a kernel with WS_DEFAULT_[FB]G set in the kernel config. Boot your
machine. You'll notice two things:

1. The framebuffer is initialised black. After some scrolling, it will
   be the same as WS_DEFAULT_BG, but not after initialisation.
2. Applications that use the default colour of the console will print
   messages in black and white.

>Fix:
Below is a patch that changes some colours to the 'WS_DEFAULT[FB]G'
definitions and some code that changes the initialisation command to
paint the screen to WS_DEFAULT_BG instead of 0x80000000 (black):

%%%
--- gsfb.c	2005-12-25 00:24:01.000000000 +0100
+++ gsfb.c	2006-02-04 15:38:41.000000000 +0100
@@ -316,13 +316,16 @@
 gsfbcninit(struct consdev *cndev)
 {
 	paddr_t paddr = MIPS_KSEG0_TO_PHYS(gsfb_init_cmd_640x480);
-	long defattr =  ATTR_BG_SET(WSCOL_BLACK) | ATTR_FG_SET(WSCOL_WHITE);
+	u_int32_t *buf = (void *)MIPS_PHYS_TO_KSEG1(paddr);
+	long defattr =  ATTR_BG_SET(WS_DEFAULT_BG) | ATTR_FG_SET(WS_DEFAULT_FG);
 
 	gsfb.is_console = 1;
 
 	gsfb_hwinit();
 	gsfb_swinit();
 
+	/* Set the screen to the default background color at boot */
+	buf[28] = gsfb_ansi_psmct32[ATTR_BG_GET(defattr)];
 	gsfb_dma_kick(paddr, sizeof gsfb_init_cmd_640x480);
 #ifdef GSFB_DEBUG_MONITOR
 	{
@@ -511,8 +514,8 @@
 		return (EINVAL);
 
 	if ((flags & WSATTR_WSCOLORS) == 0) {
-		fg = WSCOL_WHITE;
-		bg = WSCOL_BLACK;
+		fg = WS_DEFAULT_FG;
+		bg = WS_DEFAULT_BG;
 	}
 
 	if ((flags & WSATTR_HILIT) != 0)
@@ -545,7 +548,7 @@
     int *curxp, int *curyp, long *attrp)
 {
 
-	*attrp = ATTR_BG_SET(WSCOL_BLACK) | ATTR_FG_SET(WSCOL_WHITE);
+	*attrp = ATTR_BG_SET(WS_DEFAULT_BG) | ATTR_FG_SET(WS_DEFAULT_FG);
 
 	return (0);
 }
%%%