NetBSD Problem Report #10170

Received: (qmail 22519 invoked from network); 22 May 2000 02:34:30 -0000
Message-Id: <200005220234.TAA00514@quartz.clock.org>
Date: Sun, 21 May 2000 19:34:24 -0700 (PDT)
From: "Erik E. Fair" <fair@quartz.clock.org>
Reply-To: fair@quartz.clock.org
To: gnats-bugs@gnats.netbsd.org
Subject: cgfourteen (SX) does not support more than 8bpp (cg3)
X-Send-Pr-Version: 3.95

>Number:         10170
>Category:       port-sparc
>Synopsis:       cgfourteen (SX) does not support more than 8bpp (cg3)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-sparc-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 22 02:35:01 +0000 2000
>Closed-Date:    Wed Apr 03 16:34:48 +0000 2002
>Last-Modified:  Wed Apr 03 16:34:48 +0000 2002
>Originator:     Erik E. Fair
>Release:        1.4.2
>Organization:
International Organization of Internet Clock Watchers
>Environment:

System: NetBSD quartz.clock.org 1.4.2A NetBSD 1.4.2A (QUARTZ) #1: Sun May 21 18:51:56 PDT 2000 fair@quartz.clock.org:/usr/obj/sys/arch/sparc/compile/QUARTZ sparc

cgfourteen0 at obio0 slot 2 offset 0x0 level 8: cgeight emulated at 1280x1024x24bpp (console)
cgfourteen0: attached to /dev/fb

Sun GDM-20E10 multisync monitor in 1280x1024 mode, with 8MB VSIMM.

>Description:
	The SPARCstation 20 has a 24bpp capable graphics subsystem
	called the cgfourteen, or the SX. It is enabled if there
	is a 4MB or 8MB VSIMM installed in the system. Unfortunately,
	the NetBSD cgfourteen driver only correctly supports a
	cgthree (8bpp) emulation.

	An attempt to use the support for a cgeight (24bpp) emulation
	found in the cgfourteen driver (labelled "untested/broken")
	failed - Xsun24 found the device, tried to drive it, and
	exited without any particular error message.

	Alas, this sort of stuff is beyond my experience; however,
	since I have the hardware, I'll happily test whatever
	patches someone qualified can come up with.

	Cursory examination of the OpenBSD cgfourteen shows only
	superficial changes, so they're no better off than we are.
	I tried to read the Debian Linux for SPARC cgfourteen
	driver, and it didn't look like it was supporting 24bpp
	either, though it was difficult to tell.

>How-To-Repeat:
	change the CG14_CG8 define to "1" in sparc/dev/cgfourteen.c
	compile a new kernel, install, reboot,
	and attempt to startx with "-fbinfo" arg.

	The console text screen shrinks to a very small size, and
	four copies of it are seen at the top of the monitor, with
	the rest of the monitor filled alternately with black or
	white horizontal rectangular bars in an alternating pattern.

	After a time, Xsun24 restores the text console and reports:

	/dev/fb is really a MEMCOLOR   (cg8)

	and exits - X clients die off when server connection is broken.

>Fix:
>Release-Note:
>Audit-Trail:

From: "Erik E. Fair" <fair@clock.org>
To: NetBSD GNATS Problem Report Tracking System <gnats-bugs@gnats.netbsd.org>
Cc:  
Subject: Re: port-sparc/10170
Date: Thu, 22 Mar 2001 09:08:53 -0600

 As discussed in port-sparc@netbsd.org, there is now a bounty of $100 
 (and possibly more) for getting this bug fixed. Who wants to try 
 their hand?

 	Erik <fair@clock.org>

From: Charles Carvalho <carvalho@employees.org>
To: gnats-bugs@netbsd.org
Cc: carvalho@employees.org, fair@quartz.clock.org
Subject: Re: port-sparc/10170
Date: Tue, 19 Feb 2002 01:18:08 -0800 (PST)

 Problem 1: when the CG8 emulation is enabled in the CG14 driver
 (arch/sparc/dev/cgfourteen.c), the X server gets a segmentation
 violation while trying to clear the screen at startup.

 Problem 2: after fixing problem 1, the X server starts successfully,
 but the colors are wrong.

 Problem 3: when trying to use the CG14 as the console, the console is
 initialized while the framebuffer is still in 8-bit mode.  Any console
 output after the device has been opened (which causes it to switch to
 24-bit mode) is unreadable and leaves the framebuffer in a strange
 state; it appears to be necessary to kill the X server in order to
 recover from this.

 Analysis:
 problem 1 occurs because the X server is using the fb_size value
 ("total size in bytes") it obtained from the driver to mmap the
 display buffer into memory.  This value is calculated by the driver as
 fb_height * fb_linebytes, but the value of fb_linebytes is also wrong;
 it was calculated using the initial depth (8 bits) rather than the
 depth (32 bits) that takes effect once the device is opened.  The CG8
 support in the X server is expecting this value to include not only
 the full size of the color display buffer (1152*900*4) but to include
 the space used by the CG8's mono plane and enable plane (128K bytes
 each) as well, as is done by the cgeight driver. Modifying the
 cgfourteen driver to include the full size of the display buffer, plus
 the offset, in fb_size, causes the entire display buffer to be mapped,
 eliminating the segmentation violation.

 problem 2 occurs because the X server (Xsun24) thinks the CG8 supports
 24-bit DirectColor as well as 24-bit TrueColor; this may be true for a
 real CG8, but the only reference document I found (Solaris Handbook
 for Sun Frame Buffers) doesn't include 24-bit DirectColor in the list
 of supported visuals for the CG14.  The server creates both
 DirectColor and TrueColor visuals for the CG8, and allocates color map
 entries for blackPixel and whitePixel; but the CG14 isn't using the
 color table, so the colors are wrong.  Changing the definition of
 LARGE_VISUALS in xsrc/xc/programs/Xserver/cfb/cfbcmap.c to exclude
 DirectColorMask and rebuilding Xsun24 fixed this, but this is a shared
 file, so committing this change would break any framebuffers that did
 support 24-bit DirectColor.  The correct solution is probably to have
 the driver not claim to be a CG8, and add code to the X server to
 support it directly.

 problem 3 occurs because the framebuffer is left in 8-bit mode until
 the first open, and is returned to 8-bit mode after the last close;
 the comments in the driver say that this important for screenblank,
 but the console handler apparently isn't being informed of the depth
 change.  I don't have a fix for this, but the problem can be avoided
 by using a serial console, or minimized by keeping a console window
 (xterm -C, xconsole, or equivalent) open while the X server is running.

 Proposed changes to sys/arch/sparc/dev/cgfourteen.c to fix problem 1:
 Combine CG3START and CG8START into START, since they represent the
 same thing: space for the overlay planes (the cgthree driver also uses
 START for this value).

 In cgfourteenattach(), for CG8 emulation, override the value of
 fb_linebytes set by fb_setsize_obp, and include the overlay space as
 well as the color display space in fb_size to match the cgeight
 driver. For cg3 emulation, continue to exclude the overlay space, to
 match the cgthree driver.

 In cgfourteenmmap(), don't scale fb_size by the display depth, since
 it is already in bytes, not pixels; for CG8 emulation, adjust for the
 inclusion of the overlay planes in fb_size.

 These changes have been verified under 1.5.2 for CG3 and CG8 emulation,
 with a screen size of 1152x900; CG3 emulation is still the default.

 --- arch/sparc/dev/cgfourteen.c.save	Mon Jan 28 01:34:58 2002
 +++ arch/sparc/dev/cgfourteen.c	Mon Feb 18 02:29:55 2002
 @@ -131,6 +131,16 @@
  static void cg14_loadcursor __P((struct cgfourteen_softc *));/* set shape */

  /*
 + * We map the display memory with an offset of 256K when emulating the cg3 or
 + * cg8; the cg3 uses this offset for compatibility with the cg4, and both the
 + * cg4 and cg8 have a mono overlay plane and an overlay enable plane in the
 + * first 256K.  Mapping at an offset of 0x04000000 causes only the color
 + * frame buffer to be mapped, without the overlay planes.
 + */
 +#define START		(128*1024 + 128*1024)
 +#define NOOVERLAY	(0x04000000)
 +
 +/*
   * Match a cgfourteen.
   */
  int
 @@ -194,8 +204,22 @@
  	fb->fb_type.fb_depth = 8;
  #endif
  	fb_setsize_obp(fb, sc->sc_fb.fb_type.fb_depth, 1152, 900, node);
 -
 +#ifdef CG14_CG8
 +	/*
 +	 * fb_setsize_obp set fb->fb_linebytes based on the current
 +	 * depth reported by obp, but that defaults to 8 bits (as
 +	 * reported by getpropint().  Update the value to reflect
 +	 * the depth that will be used after open.
 +	 * The display memory size returned by the cg8 driver includes
 +	 * the space used by the overlay planes, but the size returned
 +	 * by the cg3 driver does not; emulate the other drivers.
 +	 */
 +	fb->fb_linebytes = (fb->fb_type.fb_width * fb->fb_type.fb_depth) / 8;
 +	ramsize = roundup(START + (fb->fb_type.fb_height * fb->fb_linebytes),
 +			NBPG);
 +#else
  	ramsize = roundup(fb->fb_type.fb_height * fb->fb_linebytes, NBPG);
 +#endif
  	fb->fb_type.fb_cmsize = CG14_CLUT_SIZE;
  	fb->fb_type.fb_size = ramsize;

 @@ -540,10 +564,6 @@
  	struct cgfourteen_softc *sc = cgfourteen_cd.cd_devs[minor(dev)];
  	bus_space_handle_t bh;

 -#define CG3START	(128*1024 + 128*1024)
 -#define CG8START	(256*1024)
 -#define NOOVERLAY	(0x04000000)
 -
  	if (off & PGOFSET)
  		panic("cgfourteenmmap");

 @@ -569,19 +589,20 @@

  	if ((u_int)off >= NOOVERLAY)
  		off -= NOOVERLAY;
 -#ifdef CG14_CG8
 -	else if ((u_int)off >= CG8START) {
 -		off -= CG8START;
 -	}
 -#else
 -	else if ((u_int)off >= CG3START)
 -		off -= CG3START;
 -#endif
 +	else if ((u_int)off >= START)
 +		off -= START;
  	else
  		off = 0;

 -	if (off >= sc->sc_fb.fb_type.fb_size *
 -		sc->sc_fb.fb_type.fb_depth/8) {
 +	/*
 +	 * fb_size includes the overlay space only for the CG8.
 +	 */
 +#ifdef CG14_CG8
 +	if (off >= sc->sc_fb.fb_type.fb_size - START)
 +#else
 +	if (off >= sc->sc_fb.fb_type.fb_size)
 +#endif
 +	{
  #ifdef DEBUG
  		printf("\nmmap request out of bounds: request 0x%x, "
  		    "bound 0x%x\n", (unsigned) off,
 [end of patch]
State-Changed-From-To: open->closed 
State-Changed-By: darrenr 
State-Changed-When: Wed Apr 3 08:34:15 PST 2002 
State-Changed-Why:  
patch applied to -current to resolve this problem. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.