Subject: patch for pm driver cursor bug
To: Thorsten Frueauf <frueauf@ira.uka.de>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: port-pmax
Date: 11/11/1997 20:44:40
Could somebody who's got a 3100 please try the following, both
with a raster-graphics console at boot and with X11?

I'll commit as soon as I can confirm that it works with both, and that
any bugs are (if necessary) fixed.  

It may be necessary to add a call to pmCursorOn() in pmPosCursor as
well, to keep the Xserver happy; otherwise the manual suggests these
are correct...

I can supply a test kernel if that would help.



*** pm.c.DIST	Mon Jul 21 04:19:35 1997
--- pm.c	Tue Nov 11 20:38:28 1997
***************
*** 106,118 ****
  void bt478CursorColor __P((struct fbinfo *fi, u_int *color));
  void bt478InitColorMap __P((struct fbinfo *fi));
  
  
  int pminit __P((struct fbinfo *fi, int unit, int cold_console_flag));
  int pmattach __P((struct fbinfo *fi, int unit, int cold_console_flag));
  
  static int pm_video_on __P ((struct fbinfo *));
  static int pm_video_off __P ((struct fbinfo *));
! 
  
  
  #define CMAP_BITS	(3 * 256)		/* 256 entries, 3 bytes per. */
--- 106,120 ----
  void bt478CursorColor __P((struct fbinfo *fi, u_int *color));
  void bt478InitColorMap __P((struct fbinfo *fi));
  
+ void pccCursorOn  __P((struct fbinfo *fi));
+ void pccCursorOff __P((struct fbinfo *fi));
  
  int pminit __P((struct fbinfo *fi, int unit, int cold_console_flag));
  int pmattach __P((struct fbinfo *fi, int unit, int cold_console_flag));
  
  static int pm_video_on __P ((struct fbinfo *));
  static int pm_video_off __P ((struct fbinfo *));
! #define UNTESTED_CURSOR		/* Cursor fixes -- untested */
  
  
  #define CMAP_BITS	(3 * 256)		/* 256 entries, 3 bytes per. */
***************
*** 258,268 ****
  	 */
  	pcc->cmdr = PCC_FOPB | PCC_VBHI;
  
! 	/*
! 	 * Initialize the cursor register.
! 	 */
! 	pcc->cmdr = curReg = PCC_ENPA | PCC_ENPB;
! 
  	/*
  	 * Initialize the color map, the screen, and the mouse.
  	 */
--- 260,272 ----
  	 */
  	pcc->cmdr = PCC_FOPB | PCC_VBHI;
  
! 	/* Initialize the cursor register on . */
! #ifdef UNTESTED_CURSOR
! 	/* Turn off the hardware cursor sprite for rcons text mode. */
! 	pccCursorOff(fi);	/*XXX*/
! #else
! 	pccCursorOn(fi);	/*XXX was inlined */
! #endif
  	/*
  	 * Initialize the color map, the screen, and the mouse.
  	 */
***************
*** 312,317 ****
--- 316,322 ----
   *
   * Side effects:
   *	The cursor is loaded into the hardware cursor.
+  *	Also, turn on the cursor in case it was disabled before.
   *
   * ----------------------------------------------------------------------------
   */
***************
*** 330,335 ****
--- 335,345 ----
  		wbflush();
  	}
  	curReg &= ~PCC_LODSA;
+ 
+ #ifdef	UNTESTED_CURSOR
+ 	/* turn on the cursor plane overlays in the PCC chip. */
+  	curReg |= (PCC_ENPA | PCC_ENPB);
+ #endif
  	pcc->cmdr = curReg;
  }
  
***************
*** 369,374 ****
--- 379,412 ----
  	pcc->ypos = PCC_Y_OFFSET + y;
  }
  
+ /*
+  * Turn hardware cursor on by turning on the enable for A and B
+  * overlay planes. video output under the cursor sprite is then
+  * determined by  the A and B plane contents.
+  */
+ void pccCursorOn(fi)
+ 	struct fbinfo *fi;
+ {
+ 	register PCCRegs *pcc = (PCCRegs *)fi -> fi_base;
+ 	pcc -> cmdr = curReg | (PCC_ENPA | PCC_ENPB);
+ 	wbflush();
+ }
+ 
+ /*
+  * Turn hardware cursor off by turning off the enable for A and B
+  * overlay planes. video output under the cursor sprite is then
+  * determined by the framebuffer contents.
+  */
+ void pccCursorOff(fi)
+ 	struct fbinfo *fi;
+ {
+ 	register PCCRegs *pcc = (PCCRegs *)fi -> fi_base;
+ 
+ 	pcc -> cmdr = curReg & ~(PCC_ENPA | PCC_ENPB);
+ 	wbflush();
+ }
+ 
+ 
  
  /*
   * Enable the video display.
***************
*** 388,395 ****
  	return 0;
  }
  
! /* disable the video display. */
! 
  static int pm_video_off (fi)
  	struct fbinfo *fi;
  {
--- 426,438 ----
  	return 0;
  }
  
! /*
!  *  Disable the video display.
!  *  Sets the FOPA and FOPB bits in the PCC chip to force the contents
!  *  of the A and B overlay planes to 1. Video output is then
!  *  determined  by  colourmap entry 12 (0x0c), which we set here to
!  *  black.
!  */
  static int pm_video_off (fi)
  	struct fbinfo *fi;
  {