public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Antonino A. Daplas" <adaplas@gmail.com>
To: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>
Cc: Dave Jones <davej@redhat.com>, Jason <dravet@hotmail.com>,
	Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Linux Kernel Development <linux-kernel@vger.kernel.org>
Subject: [PATCH] vgacon: Workaround for resize bug in some chipsets
Date: Sun, 13 Nov 2005 06:20:53 +0800	[thread overview]
Message-ID: <43766AC5.9080406@gmail.com> (raw)

Reported from Redhat Bugzilla Bug 170450

"I updated to the development kernel and now during boot only the top of the
text is visable. For example the monitor screen the is the lines and I can
only  see text in the asterik area.
---------------------
| ****************  |
| *              *  |
| *              *  |
| ****************  |
|                   |
|                   |
|                   |
---------------------

I have a Silicon Graphics 1600sw LCD panel with a Number Nine Revolution 4
video card."

This bug seems to be a glitch in the VGA core of this chipset.  Resizing
the screen triggers the mentioned bug.

The workaround is to make vgacon avoid calling vgacon_doresize() if the
display parameters did not change. It also has a nice side effect of faster
console switches, but that will be barely noticeable.

Note that this bug may be triggered if the user changes the screen height
with stty, or using another font with different dimensions.

A definitive fix will need to be provided by someone who knows and has the
hardware.

This patch also converted hard-coded constants to a named constant
(VGACON_FONTWIDTH).

Signed-off-by: Antonino Daplas <adaplas@pol.net>
---
 vgacon.c |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)


diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 274f905..5ce8348 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -56,6 +56,8 @@
 static DEFINE_SPINLOCK(vga_lock);
 static int cursor_size_lastfrom;
 static int cursor_size_lastto;
+static u32 vgacon_xres;
+static u32 vgacon_yres;
 static struct vgastate state;
 
 #define BLANK 0x0020
@@ -69,7 +71,7 @@ static struct vgastate state;
  * appear.
  */
 #undef TRIDENT_GLITCH
-
+#define VGA_FONTWIDTH       8   /* VGA does not support fontwidths != 8 */
 /*
  *  Interface used by the world
  */
@@ -325,6 +327,10 @@ static const char __init *vgacon_startup
 		vga_scan_lines =
 		    vga_video_font_height * vga_video_num_lines;
 	}
+
+	vgacon_xres = ORIG_VIDEO_COLS * VGA_FONTWIDTH;
+	vgacon_yres = vga_scan_lines;
+
 	return display_desc;
 }
 
@@ -507,6 +513,8 @@ static int vgacon_doresize(struct vc_dat
 
 	spin_lock_irqsave(&vga_lock, flags);
 
+	vgacon_xres = width * VGA_FONTWIDTH;
+	vgacon_yres = height * c->vc_font.height;
 	outb_p(VGA_CRTC_MODE, vga_video_port_reg);
 	mode = inb_p(vga_video_port_val);
 
@@ -551,6 +559,10 @@ static int vgacon_doresize(struct vc_dat
 
 static int vgacon_switch(struct vc_data *c)
 {
+	int x = c->vc_cols * VGA_FONTWIDTH;
+	int y = c->vc_rows * c->vc_font.height;
+	int rows = ORIG_VIDEO_LINES * vga_default_font_height/
+		c->vc_font.height;
 	/*
 	 * We need to save screen size here as it's the only way
 	 * we can spot the screen has been resized and we need to
@@ -566,10 +578,11 @@ static int vgacon_switch(struct vc_data 
 		scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf,
 			    c->vc_screenbuf_size > vga_vram_size ?
 				vga_vram_size : c->vc_screenbuf_size);
-		if (!(vga_video_num_columns % 2) &&
-		    vga_video_num_columns <= ORIG_VIDEO_COLS &&
-		    vga_video_num_lines <= (ORIG_VIDEO_LINES *
-			vga_default_font_height) / c->vc_font.height)
+
+		if ((vgacon_xres != x || vgacon_yres != y) &&
+		    (!(vga_video_num_columns % 2) &&
+		     vga_video_num_columns <= ORIG_VIDEO_COLS &&
+		     vga_video_num_lines <= rows))
 			vgacon_doresize(c, c->vc_cols, c->vc_rows);
 	}
 
@@ -992,7 +1005,8 @@ static int vgacon_font_set(struct vc_dat
 	if (vga_video_type < VIDEO_TYPE_EGAM)
 		return -EINVAL;
 
-	if (font->width != 8 || (charcount != 256 && charcount != 512))
+	if (font->width != VGA_FONTWIDTH ||
+	    (charcount != 256 && charcount != 512))
 		return -EINVAL;
 
 	rc = vgacon_do_font_op(&state, font->data, 1, charcount == 512);
@@ -1009,7 +1023,7 @@ static int vgacon_font_get(struct vc_dat
 	if (vga_video_type < VIDEO_TYPE_EGAM)
 		return -EINVAL;
 
-	font->width = 8;
+	font->width = VGA_FONTWIDTH;
 	font->height = c->vc_font.height;
 	font->charcount = vga_512_chars ? 512 : 256;
 	if (!font->data)

             reply	other threads:[~2005-11-12 22:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-12 22:20 Antonino A. Daplas [this message]
2005-11-13 10:23 ` [PATCH] vgacon: Workaround for resize bug in some chipsets Martin Mares
2005-11-13 11:06 ` Samuel Thibault
2005-11-13 14:33   ` Antonino A. Daplas
2005-11-13 22:25     ` Samuel Thibault
2005-11-13 23:37       ` Antonino A. Daplas
     [not found] <58c2Z-8jG-23@gated-at.bofh.it>
2005-11-13 19:41 ` Bodo Eggert
2005-11-13 22:11   ` Antonino A. Daplas
2005-11-13 22:26     ` Mika Penttilä
2005-11-13 23:35       ` Antonino A. Daplas
2005-11-14  3:32         ` H. Peter Anvin
2005-11-13 22:24   ` Samuel Thibault
  -- strict thread matches above, loose matches on Subject: below --
2005-11-14  3:46 Jason Dravet
     [not found] <58DvZ-6en-1@gated-at.bofh.it>
2005-11-14  9:24 ` Bodo Eggert
2005-11-14 15:27   ` Jason Dravet
2005-11-14 16:32     ` Bodo Eggert
2005-11-16  0:05     ` Samuel Thibault
2005-11-16  1:50       ` Jason Dravet
2005-11-16  2:25         ` Samuel Thibault
2005-11-16 17:58 Jason Dravet
2005-11-16 23:52 ` Samuel Thibault
2005-11-17  1:37   ` Jason Dravet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43766AC5.9080406@gmail.com \
    --to=adaplas@gmail.com \
    --cc=akpm@osdl.org \
    --cc=davej@redhat.com \
    --cc=dravet@hotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox