Date: Tue, 8 Apr 1997 15:20:53 +0200 (MET DST)
From: Jesper Skov <jskov@cs.auc.dk>
To: linux-m68k@phil.uni-sb.de
Subject: L68K: copcon patches
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: linux-m68k@phil.uni-sb.de


A few cleanups to my previous copcon release. This version also allows
screen blanking.

Michael Goodwin has problems with copcon on his OCS Amiga. Anyone else
with experiences from OCS/ECS machines? I'd love to hear from you
(good and bad experiences).

-- Jesper

--- amifb.c	Mon Apr  7 20:42:33 1997
+++ /pack/kernel/linux/arch/m68k/amiga/amifb.c	Mon Apr  7 20:44:16 1997
@@ -57,7 +57,7 @@
 #include <asm/amigaints.h>
 #include <linux/fb.h>
 
-#ifdef CONFIG_COPCON
+#if defined(CONFIG_COPCON)
 #define MAXCOPCONROWS 128
 extern u_char *line_ptrs[MAXCOPCONROWS];
 extern short line_ptrs_used;
@@ -1985,7 +1985,6 @@
 	/*
 	 * Update the `var' structure (called by amicon.c)
 	 */
-
 static int amifbcon_updatevar(int con)
 {
 	ami_pan_var(&disp[con].var);
@@ -3569,8 +3568,6 @@
 			(copl++)->l = CMOVE2(loww(p), bplpt[i]);
 		}
 		
-		(copl++)->l = CMOVE(DMAF_RASTER | DMAF_SETCLR, dmacon);
-		
 		for(j = 1; j < line_ptrs_used; j++){
 			line += par->yoffset << par->line_shift;
 			p = (u_long) line_ptrs[j] + (mod2(line) ? par->next_line : 0);
@@ -3661,7 +3658,6 @@
 				(cops++)->l = CMOVE(highw(p), bplpt[i]);
 				(cops++)->l = CMOVE2(loww(p), bplpt[i]);
 			}
-			(cops++)->l = CMOVE(DMAF_RASTER | DMAF_SETCLR, dmacon);
 			
 			for(j = 1; j < line_ptrs_used; j++){
 				line += par->yoffset << par->line_shift;
--- copcon.c	Mon Apr  7 20:41:02 1997
+++ /pack/kernel/linux/arch/m68k/console/copcon.c	Mon Apr  7 20:34:57 1997
@@ -29,10 +29,23 @@
  *
  */
 
+/* 
+ * TO DO:
+ *
+ * Presently the lines_lock variable is used to prevent scrolling while
+ * switching virtual consoles. This should be handled in some other way as
+ * the display is sure to be fucked up by such a cancelled scroll operation.
+ * A solution would be to cli/sti the routine that cleans up the display when
+ * changing consoles, but it is a pretty slow thing... Ideas are welcome.
+ *
+ * If scrolling out more than half the number of lines, the top and bottom
+ * line ptrs can simply be exchanged. Don't know if the gain is worth the
+ * hassle though.
+ *
+ */
+
 #include <linux/sched.h>
-#include <linux/tty.h>
 #include <linux/console.h>
-#include <linux/string.h>
 
 #include <asm/setup.h>
 #include <asm/irq.h>
@@ -42,8 +55,6 @@
 #include <asm/font.h>
 #include <asm/machdep.h>
 
-#include <asm/system.h>
-
 #include "../../../drivers/char/vt_kern.h"   /* vt_cons and vc_resize_con() */
 
 
@@ -58,7 +69,7 @@
 u_char *line_ptrs[MAXCOPCONROWS];
 u_char *line_ptrs_roll[MAXCOPCONROWS];
 short line_ptrs_used;
-u_char lines_lock;
+u_char lines_lock;		/* Lock array from access during update */
 
 static int cursor_drawn = 0;
 
@@ -227,10 +238,7 @@
 		panic("copcon_setup: No support for fontwidth != 8");
 
 	conp->vc_cols = p->var.xres / p->fontwidth;
-	line_ptrs_used = conp->vc_rows = p->var.yres / p->fontheight;
-	
-	if(line_ptrs_used > MAXCOPCONROWS)
-		panic("copcon_setup: Too many rows for current line_ptrs[]");
+ 	conp->vc_rows = p->var.yres / p->fontheight;
 	
 	/* fbcon needs to know fontheight for copper update */
 	p->var.yoffset = p->fontheight;
@@ -251,7 +259,15 @@
 	}
 
 
-	if(!once_in++){
+	if(!once_in){
+		/* We won't init this array more than once */
+		once_in++;
+
+
+		line_ptrs_used = conp->vc_rows;
+		if(line_ptrs_used > MAXCOPCONROWS)
+			panic("copcon_setup: Too many rows for current line_ptrs[]");
+	
 
 		/* Initialize line_ptrs array */
 		bpl_ptr = p->screen_base;
@@ -259,6 +275,7 @@
 			line_ptrs[i] = bpl_ptr;
 			bpl_ptr += p->next_line * p->fontheight;
 		}
+
 		lines_lock = 0;
 	}
 
@@ -646,10 +663,9 @@
 {
 	int unit = conp->vc_num;
 	struct display *p = &disp[unit];
-	int i, j = 0, k = 0;
+	int i;
 	int bi = b, bj = b;
 	int ti = t, tj = t;
-	u_char *tmp;
 	unsigned long flags;
 
 
@@ -664,19 +680,20 @@
 		if (count > conp->vc_rows) /* Maximum realistic size */
 			count = conp->vc_rows;
 		
+		/* XXX Only scroll if we're not changing console */
 		if(!lines_lock){
 
 			save_flags(flags);
 			cli();
 
 			for(i = 0; i < count; i++)
-				line_ptrs_roll[j++] = line_ptrs[ti++];
+				line_ptrs_roll[i] = line_ptrs[ti++];
 			
 			while(ti < b)
 				line_ptrs[tj++] = line_ptrs[ti++];
 
-			while(j)
-				line_ptrs[tj++] = line_ptrs_roll[--j];
+			while(i)
+				line_ptrs[tj++] = line_ptrs_roll[--i];
 
 			restore_flags(flags);
 
@@ -690,19 +707,20 @@
 		if (count > conp->vc_rows) /* Maximum realistic size */
 			count = conp->vc_rows;
 		
+		/* XXX Only scroll if we're not changing console */
 		if(!lines_lock){
 
 			save_flags(flags);
 			cli();
 
 			for(i = 0; i < count; i++)
-				line_ptrs_roll[j++] = line_ptrs[--bi];
+				line_ptrs_roll[i] = line_ptrs[--bi];
 			
 			while(bi > t)
 				line_ptrs[--bj] = line_ptrs[--bi];
 
-			while(j)
-				line_ptrs[--bj] = line_ptrs_roll[--j];
+			while(i)
+				line_ptrs[--bj] = line_ptrs_roll[--i];
 		
 			restore_flags(flags);
 
@@ -789,11 +807,11 @@
 	int i, line, size;
 	u_char *src, *dest, *bpl_ptr;
 
-	if(lines_lock++)
-		__asm__ __volatile__ ("movew #0xf0f,0x80dff180\n\t");
+	lines_lock++;
 
 	size = (p->var.xres/p->fontwidth) * p->fontheight;
 
+	/* Reshuffle lines to correct bitmap order */
 	bpl_ptr = p->screen_base;
 	for(line = 0; line < line_ptrs_used; line++){
 		src = line_ptrs[line];
@@ -896,9 +914,6 @@
 
 	c &= 0xff;
 
-	if(lines_lock++)
-		__asm__ __volatile__ ("movew #0x880,0x80dff180\n\t");
-
 	dest0 = line_ptrs[y]+x;
 	cdat0 = p->fontdata+c*p->fontheight;
 	fg = attr_fgcol(p,conp);
@@ -923,8 +938,6 @@
 		bg >>= 1;
 		fg >>= 1;
 	}
-
-	lines_lock--;
 }
 
 
@@ -944,9 +957,6 @@
 	u_long d;
 	int fg0, bg0, fg, bg;
 
-	if(lines_lock++)
-		__asm__ __volatile__ ("movew #0x880,0x80dff180\n\t");
-
 	dest0 = line_ptrs[y]+x;
 	fg0 = attr_fgcol(p,conp);
 	bg0 = attr_bgcol(p,conp);
@@ -1023,8 +1033,6 @@
 			count -= 3;
 		}
 	}
-
-	lines_lock--;
 }
 
 
@@ -1034,9 +1042,6 @@
 	u_int rows, i;
 	int mask;
 
-	if(lines_lock++)
-		__asm__ __volatile__ ("movew #0x880,0x80dff180\n\t");
- 
 	dest0 = line_ptrs[y]+x;
 	mask = p->fgcol ^ p->bgcol;
 
@@ -1055,9 +1060,6 @@
 		}
 		mask >>= 1;
 	}
-	
-	lines_lock--;
- 
 }
 
 /* ====================================================================== */
