Subject: Fixed DECstation [23]100 monochrome driver...
To: None <port-pmax@NetBSD.ORG>
From: Ted Lemon <mellon@fugue.com>
List: port-pmax
Date: 11/25/1995 02:53:03
It turns out that there were two problems: the brooktree DAC was being
initialized incorrectly, and the rasterop code was behaving
incorrectly.   The patch below fixes both problems (the change to
bt478.c is already checked into -current).

I would appreciate it if somebody who has a working cfb or sfb
configuration (i.e., 8 bits per pixel) would try out these changes and
see how badly they break things - I know they work on the pmax
monochrome frame buffer, but I don't want to send them to pk until
they also work on pmax color frame buffers.

			       _MelloN_

diff -c -r1.2 sys/dev/rcons/raster_op.c
*** sys/dev/rcons/raster_op.c	1995/11/24 23:50:54	1.2
--- sys/dev/rcons/raster_op.c	1995/11/25 10:49:26
***************
*** 446,451 ****
--- 446,454 ----
      0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
      0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
      0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff };
+ 
+ #define LSOP <<
+ #define RSOP >>
  #endif /*MSBYTE_FIRST*/
  
  #else /*MSBIT_FIRST*/
***************
*** 479,484 ****
--- 482,489 ----
      0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00,
      0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0,
      0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe };
+ #define LSOP >>
+ #define RSOP <<
  #endif /*not MSBYTE_FIRST*/
  
  #endif /*MSBIT_FIRST*/
***************
*** 1171,1177 ****
  		    ROP_SRCDST(
  		    /*op*/  op,
  		    /*pre*/ dl = *dstlin;,
! 		    /*s*/   *srclin << prevleftshift,
  		    /*d*/   dl,
  		    /*pst*/ *dstlin = ( *dstlin & lm ) | ( dl & nlm ); )
  
--- 1176,1182 ----
  		    ROP_SRCDST(
  		    /*op*/  op,
  		    /*pre*/ dl = *dstlin;,
! 		    /*s*/   *srclin LSOP prevleftshift,
  		    /*d*/   dl,
  		    /*pst*/ *dstlin = ( *dstlin & lm ) | ( dl & nlm ); )
  
***************
*** 1186,1192 ****
  		    ROP_SRCDST(
  		    /*op*/  op,
  		    /*pre*/ dl = *dstlin;,
! 		    /*s*/   *srclin >> currrightshift,
  		    /*d*/   dl,
  		    /*pst*/ *dstlin = ( *dstlin & lm ) | ( dl & nlm ); )
  
--- 1191,1197 ----
  		    ROP_SRCDST(
  		    /*op*/  op,
  		    /*pre*/ dl = *dstlin;,
! 		    /*s*/   *srclin RSOP currrightshift,
  		    /*d*/   dl,
  		    /*pst*/ *dstlin = ( *dstlin & lm ) | ( dl & nlm ); )
  
***************
*** 1211,1217 ****
  		    dstlong = dstlin;
  		    dstlong2 = dstlong + dstlongs;
  		    if ( srcleftignore > dstleftignore )
! 			prevsl = *srclong++ << prevleftshift;
  		    else
  			prevsl = 0;
  		    if ( dstrightignore != 0 )
--- 1216,1222 ----
  		    dstlong = dstlin;
  		    dstlong2 = dstlong + dstlongs;
  		    if ( srcleftignore > dstleftignore )
! 			prevsl = *srclong++ LSOP prevleftshift;
  		    else
  			prevsl = 0;
  		    if ( dstrightignore != 0 )
***************
*** 1224,1230 ****
  			/*op*/  op,
  			/*pre*/ sl = *srclong;
  				dl = *dstlong;,
! 			/*s*/   prevsl | ( sl >> currrightshift ),
  			/*d*/   dl,
  			/*pst*/ *dstlong = ( *dstlong & lm ) | ( dl & nlm ); )
  			prevsl = sl << prevleftshift;
--- 1229,1235 ----
  			/*op*/  op,
  			/*pre*/ sl = *srclong;
  				dl = *dstlong;,
! 			/*s*/   prevsl | ( sl RSOP currrightshift ),
  			/*d*/   dl,
  			/*pst*/ *dstlong = ( *dstlong & lm ) | ( dl & nlm ); )
  			prevsl = sl << prevleftshift;
***************
*** 1238,1246 ****
  		    /*pre*/ while ( dstlong != dstlong2 )
  				{
  				sl = *srclong;,
! 		    /*s*/       prevsl | ( sl >> currrightshift ),
  		    /*d*/       *dstlong,
! 		    /*pst*/     prevsl = sl << prevleftshift;
  				++srclong;
  				++dstlong;
  				} )
--- 1243,1251 ----
  		    /*pre*/ while ( dstlong != dstlong2 )
  				{
  				sl = *srclong;,
! 		    /*s*/       prevsl | ( sl RSOP currrightshift ),
  		    /*d*/       *dstlong,
! 		    /*pst*/     prevsl = sl LSOP prevleftshift;
  				++srclong;
  				++dstlong;
  				} )
***************
*** 1251,1257 ****
  			ROP_SRCDST(
  			/*op*/  op,
  			/*pre*/ dl = *dstlong;,
! 			/*s*/   prevsl | ( *srclong >> currrightshift ),
  			/*d*/   dl,
  			/*pst*/ *dstlong = ( dl & nrm ) | ( *dstlong & rm ); )
  			}
--- 1256,1262 ----
  			ROP_SRCDST(
  			/*op*/  op,
  			/*pre*/ dl = *dstlong;,
! 			/*s*/   prevsl | ( *srclong RSOP currrightshift ),
  			/*d*/   dl,
  			/*pst*/ *dstlong = ( dl & nrm ) | ( *dstlong & rm ); )
  			}
***************
*** 1269,1275 ****
  		    dstlong = dstlin;
  		    dstlong2 = dstlong - dstlongs;
  		    if ( srcrightignore > dstrightignore )
! 			prevsl = *srclong-- >> currrightshift;
  		    else
  			prevsl = 0;
  		    if ( dstleftignore != 0 )
--- 1274,1280 ----
  		    dstlong = dstlin;
  		    dstlong2 = dstlong - dstlongs;
  		    if ( srcrightignore > dstrightignore )
! 			prevsl = *srclong-- RSOP currrightshift;
  		    else
  			prevsl = 0;
  		    if ( dstleftignore != 0 )
***************
*** 1282,1291 ****
  			/*op*/  op,
  			/*pre*/ sl = *srclong;
  				dl = *dstlong;,
! 			/*s*/   prevsl | ( sl << prevleftshift ),
  			/*d*/   dl,
  			/*pst*/ *dstlong = ( dl & nrm ) | ( *dstlong & rm ); )
! 			prevsl = sl >> currrightshift;
  			--srclong;
  			--dstlong;
  			}
--- 1287,1296 ----
  			/*op*/  op,
  			/*pre*/ sl = *srclong;
  				dl = *dstlong;,
! 			/*s*/   prevsl | ( sl LSOP prevleftshift ),
  			/*d*/   dl,
  			/*pst*/ *dstlong = ( dl & nrm ) | ( *dstlong & rm ); )
! 			prevsl = sl RSOP currrightshift;
  			--srclong;
  			--dstlong;
  			}
***************
*** 1296,1304 ****
  		    /*pre*/ while ( dstlong != dstlong2 )
  				{
  				sl = *srclong;,
! 		    /*s*/       prevsl | ( sl << prevleftshift ),
  		    /*d*/       *dstlong,
! 		    /*pst*/     prevsl = sl >> currrightshift;
  				--srclong;
  				--dstlong;
  				} )
--- 1301,1309 ----
  		    /*pre*/ while ( dstlong != dstlong2 )
  				{
  				sl = *srclong;,
! 		    /*s*/       prevsl | ( sl LSOP prevleftshift ),
  		    /*d*/       *dstlong,
! 		    /*pst*/     prevsl = sl RSOP currrightshift;
  				--srclong;
  				--dstlong;
  				} )
***************
*** 1309,1315 ****
  			ROP_SRCDST(
  			/*op*/  op,
  			/*pre*/ dl = *dstlong;,
! 			/*s*/   prevsl | ( *srclong << prevleftshift ),
  			/*d*/   dl,
  			/*pst*/ *dstlong = ( *dstlong & lm ) | ( dl & nlm ); )
  			}
--- 1314,1320 ----
  			ROP_SRCDST(
  			/*op*/  op,
  			/*pre*/ dl = *dstlong;,
! 			/*s*/   prevsl | ( *srclong LSOP prevleftshift ),
  			/*d*/   dl,
  			/*pst*/ *dstlong = ( *dstlong & lm ) | ( dl & nlm ); )
  			}
diff -c -r1.1 -r1.2 sys/arch/pmax/dev/bt478.c
*** sys/arch/pmax/dev/bt478.c	1995/09/11 08:11:22	1.1
--- sys/arch/pmax/dev/bt478.c	1995/11/25 10:38:42	1.2
***************
*** 1,4 ****
! /*	$NetBSD: bt478.c,v 1.1 1995/09/11 08:11:22 jonathan Exp $	*/
  
  /*-
   * Copyright (c) 1992, 1993
--- 1,4 ----
! /*	$NetBSD: bt478.c,v 1.2 1995/11/25 10:38:42 mellon Exp $	*/
  
  /*-
   * Copyright (c) 1992, 1993
***************
*** 121,127 ****
  	 * Initialize the color map and the screen.
  	 */
  	bt478InitColorMap(fi);
- 	bt478RestoreCursorColor (fi);
  	return (1);
  }
  
--- 121,126 ----
***************
*** 211,224 ****
  	if (fi -> fi_type.fb_depth == 1) {
  		vdac->mapWA = 0; MachEmptyWriteBuffer();
  		for (i = 0; i < 256; i++) {
! 			((u_char *)(fi -> fi_cmap_bits)) [i * 3]
! 				= vdac->map = (i < 128) ? 0x00 : 0xff;
! 			MachEmptyWriteBuffer();
  			((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 1]
! 				= vdac->map = (i < 128) ? 0x00 : 0xff;
  			MachEmptyWriteBuffer();
! 			((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 2]
! 				= vdac->map = (i < 128) ? 0x00 : 0xff;
  			MachEmptyWriteBuffer();
  		}
  	} else {
--- 210,224 ----
  	if (fi -> fi_type.fb_depth == 1) {
  		vdac->mapWA = 0; MachEmptyWriteBuffer();
  		for (i = 0; i < 256; i++) {
! 			((u_char *)(fi -> fi_cmap_bits)) [i * 3] = 0;
  			((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 1]
! 				= (i < 128) ? 0x00 : 0xff;
! 			((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 2] = 0;
! 			vdac->map = 0;
! 			MachEmptyWriteBuffer();
! 			vdac->map = (i < 128) ? 0x00 : 0xff;
  			MachEmptyWriteBuffer();
! 			vdac->map = 0;
  			MachEmptyWriteBuffer();
  		}
  	} else {
***************
*** 244,251 ****
  			vdac->map = 0xff;
  			MachEmptyWriteBuffer();
  		}
- #if 0
- #endif
  	}
  
  	for (i = 0; i < 3; i++) {
--- 244,249 ----