Resent-Date: Fri, 23 Oct 1998 10:27:21 +0200 (MET DST)
To: Geert Uytterhoeven <Geert.Uytterhoeven@cs.kuleuven.ac.be>
Cc: linux-m68k@lists.linux-m68k.org, linux-m68k@phil.uni-sb.de
Subject: Re: Fbcon display bug
References: <Pine.LNX.4.03.9810211141330.16940-100000@mercator.cs.kuleuven.ac.be>
X-Yow: Darling, my ELBOW is FLYING over FRANKFURT, Germany..
From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Date: 23 Oct 1998 10:27:47 +0200
Resent-From: linux-m68k@phil.uni-sb.de

Here is the patch to implement clear_margins for the iplain2p? and mfb
drivers.  It fixes also another bug in the mfb driver: fbcon_mfb_clear
should use the reverse attribute from the erase character, not from the
current attributes.

Andreas.

--- drivers/video/fbcon-iplan2p2.c.~2~	Tue Oct 20 20:40:48 1998
+++ drivers/video/fbcon-iplan2p2.c	Thu Oct 22 19:51:48 1998
@@ -405,6 +405,30 @@
     }
 }
 
+void fbcon_iplan2p2_clear_margins(struct vc_data *conp, struct display *p,
+				  int bottom_only)
+{
+    u32 offset;
+    int bytes;
+    int lines;
+    u32 cval;
+
+/* No need to handle right margin, cannot occur with fontwidth == 8 */
+
+    bytes = p->next_line;
+    if (fontheightlog(p)) {
+	lines = p->var.yres - (conp->vc_rows << fontheightlog(p));
+	offset = ((p->yscroll + conp->vc_rows) * bytes) << fontheightlog(p);
+    } else {
+	lines = p->var.yres - conp->vc_rows * fontheight(p);
+	offset = (p->yscroll + conp->vc_rows) * bytes * fontheight(p);
+    }
+    if (lines) {
+	cval = expand2l(COLOR_2P(attr_bgcol_ec(p,conp)));
+	memset_even_2p(p->screen_base+offset, lines * bytes, cval);
+    }
+}
+
 
     /*
      *  `switch' for the low level operations
@@ -413,7 +437,7 @@
 struct display_switch fbcon_iplan2p2 = {
     fbcon_iplan2p2_setup, fbcon_iplan2p2_bmove, fbcon_iplan2p2_clear,
     fbcon_iplan2p2_putc, fbcon_iplan2p2_putcs, fbcon_iplan2p2_revc, NULL,
-    NULL, NULL, FONTWIDTH(8)
+    NULL, fbcon_iplan2p2_clear_margins, FONTWIDTH(8)
 };
 
 
@@ -439,3 +463,4 @@
 EXPORT_SYMBOL(fbcon_iplan2p2_putc);
 EXPORT_SYMBOL(fbcon_iplan2p2_putcs);
 EXPORT_SYMBOL(fbcon_iplan2p2_revc);
+EXPORT_SYMBOL(fbcon_iplan2p2_clear_margins);
--- drivers/video/fbcon-iplan2p4.c.~2~	Tue Oct 20 20:40:57 1998
+++ drivers/video/fbcon-iplan2p4.c	Thu Oct 22 19:52:13 1998
@@ -425,6 +425,30 @@
     }
 }
 
+void fbcon_iplan2p4_clear_margins(struct vc_data *conp, struct display *p,
+				  int bottom_only)
+{
+    u32 offset;
+    int bytes;
+    int lines;
+    u32 cval1, cval2;
+
+/* No need to handle right margin, cannot occur with fontwidth == 8 */
+
+    bytes = p->next_line;
+    if (fontheightlog(p)) {
+	lines = p->var.yres - (conp->vc_rows << fontheightlog(p));
+	offset = ((p->yscroll + conp->vc_rows) * bytes) << fontheightlog(p);
+    } else {
+	lines = p->var.yres - conp->vc_rows * fontheight(p);
+	offset = (p->yscroll + conp->vc_rows) * bytes * fontheight(p);
+    }
+    if (lines) {
+	expand4dl(attr_bgcol_ec(p,conp), &cval1, &cval2);
+	memset_even_4p(p->screen_base+offset, lines * bytes, cval1, cval2);
+    }
+}
+
 
     /*
      *  `switch' for the low level operations
@@ -433,7 +457,7 @@
 struct display_switch fbcon_iplan2p4 = {
     fbcon_iplan2p4_setup, fbcon_iplan2p4_bmove, fbcon_iplan2p4_clear,
     fbcon_iplan2p4_putc, fbcon_iplan2p4_putcs, fbcon_iplan2p4_revc, NULL,
-    NULL, NULL, FONTWIDTH(8)
+    NULL, fbcon_iplan2p4_clear_margins, FONTWIDTH(8)
 };
 
 
@@ -459,3 +483,4 @@
 EXPORT_SYMBOL(fbcon_iplan2p4_putc);
 EXPORT_SYMBOL(fbcon_iplan2p4_putcs);
 EXPORT_SYMBOL(fbcon_iplan2p4_revc);
+EXPORT_SYMBOL(fbcon_iplan2p4_clear_margins);
--- drivers/video/fbcon-iplan2p8.c.~2~	Tue Oct 20 20:40:51 1998
+++ drivers/video/fbcon-iplan2p8.c	Thu Oct 22 19:52:37 1998
@@ -461,6 +461,31 @@
     }
 }
 
+void fbcon_iplan2p8_clear_margins(struct vc_data *conp, struct display *p,
+				  int bottom_only)
+{
+    u32 offset;
+    int bytes;
+    int lines;
+    u32 cval1, cval2, cval3, cval4;
+
+/* No need to handle right margin, cannot occur with fontwidth == 8 */
+
+    bytes = p->next_line;
+    if (fontheightlog(p)) {
+	lines = p->var.yres - (conp->vc_rows << fontheightlog(p));
+	offset = ((p->yscroll + conp->vc_rows) * bytes) << fontheightlog(p);
+    } else {
+	lines = p->var.yres - conp->vc_rows * fontheight(p);
+	offset = (p->yscroll + conp->vc_rows) * bytes * fontheight(p);
+    }
+    if (lines) {
+	expand8ql(attr_bgcol_ec(p,conp), &cval1, &cval2, &cval3, &cval4);
+	memset_even_8p(p->screen_base+offset, lines * bytes,
+		       cval1, cval2, cval3, cval4);
+    }
+}
+
 
     /*
      *  `switch' for the low level operations
@@ -469,7 +494,7 @@
 struct display_switch fbcon_iplan2p8 = {
     fbcon_iplan2p8_setup, fbcon_iplan2p8_bmove, fbcon_iplan2p8_clear,
     fbcon_iplan2p8_putc, fbcon_iplan2p8_putcs, fbcon_iplan2p8_revc, NULL,
-    NULL, NULL, FONTWIDTH(8)
+    NULL, fbcon_iplan2p8_clear_margins, FONTWIDTH(8)
 };
 
 
@@ -495,3 +520,4 @@
 EXPORT_SYMBOL(fbcon_iplan2p8_putc);
 EXPORT_SYMBOL(fbcon_iplan2p8_putcs);
 EXPORT_SYMBOL(fbcon_iplan2p8_revc);
+EXPORT_SYMBOL(fbcon_iplan2p8_clear_margins);
--- drivers/video/fbcon-mfb.c.~1~	Tue Sep  1 18:06:42 1998
+++ drivers/video/fbcon-mfb.c	Thu Oct 22 20:48:50 1998
@@ -66,7 +66,7 @@
 {
     u8 *dest;
     u_int rows;
-    int inverse = conp ? attr_reverse(p,conp->vc_attr) : 0;
+    int inverse = conp ? attr_reverse(p,conp->vc_video_erase_char) : 0;
 
     dest = p->screen_base+sy*fontheight(p)*p->next_line+sx;
 
@@ -148,6 +148,28 @@
 	*dest = ~*dest;
 }
 
+void fbcon_mfb_clear_margins(struct vc_data *conp, struct display *p,
+			     int bottom_only)
+{
+    u8 *dest;
+    int height, bottom;
+    int inverse = conp ? attr_reverse(p,conp->vc_video_erase_char) : 0;
+
+    /* XXX Need to handle right margin? */
+
+    height = p->var.yres - conp->vc_rows * fontheight(p);
+    if (!height)
+	return;
+    bottom = conp->vc_rows + p->yscroll;
+    if (bottom >= p->vrows)
+	bottom -= p->vrows;
+    dest = p->screen_base + bottom * fontheight(p) * p->next_line;
+    if (inverse)
+	mymemset(dest, height * p->next_line);
+    else
+	mymemclear(dest, height * p->next_line);
+}
+
 
     /*
      *  `switch' for the low level operations
@@ -155,7 +177,8 @@
 
 struct display_switch fbcon_mfb = {
     fbcon_mfb_setup, fbcon_mfb_bmove, fbcon_mfb_clear, fbcon_mfb_putc,
-    fbcon_mfb_putcs, fbcon_mfb_revc, NULL, NULL, NULL, FONTWIDTH(8)
+    fbcon_mfb_putcs, fbcon_mfb_revc, NULL, NULL, fbcon_mfb_clear_margins,
+    FONTWIDTH(8)
 };
 
 
@@ -181,3 +204,4 @@
 EXPORT_SYMBOL(fbcon_mfb_putc);
 EXPORT_SYMBOL(fbcon_mfb_putcs);
 EXPORT_SYMBOL(fbcon_mfb_revc);
+EXPORT_SYMBOL(fbcon_mfb_clear_margins);

-- 
Andreas Schwab                                      "And now for something
schwab@issan.cs.uni-dortmund.de                      completely different"
schwab@gnu.org

