2005-11-12 22:21:05

by Antonino A. Daplas

[permalink] [raw]
Subject: [PATCH] vgacon: Workaround for resize bug in some chipsets

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 <[email protected]>
---
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)


2005-11-13 10:23:28

by Martin Mares

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Hello!

> 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.

This patch really deserves a comment in the code that such a broken hardware
exists.

Also, I don't see much reasons for introducing VGA_FONTWIDTH, it seems to only
complicate the code.

Have a nice fortnight
--
Martin `MJ' Mares <[email protected]> http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
For every complex problem, there's a solution that is simple, neat and wrong.

2005-11-13 11:06:22

by Samuel Thibault

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Antonino A. Daplas, le Sun 13 Nov 2005 06:20:53 +0800, a ?crit :
> "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.
> ---------------------
> | **************** |
> | * * |
> | * * |
> | **************** |
> | |
> | |
> | |
> ---------------------

Are you missing some left and right part too? What are the dimensions of
the text screen at bootup? What bootloader are you using? (It could be a
bug in the boot up text screen dimension discovery).

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

Does vgacon.c properly discovers that it is a VGA board?

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

Do vga-only games (like old DOS-mode games) work with it?

> The workaround is to make vgacon avoid calling vgacon_doresize() if the
> display parameters did not change.

I.e. never call it, actually.

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

I'm not sure it is hardware-specific. Maybe you have a combination of
vga bios/bootloader/vga=ask/... that prevents vgacon.c from properly
discovering the dimensions of the text screen.


Well, else it looks like a "safe side" patch: people now hit by such bug
won't be hit any more unless using stty or such.

Regards,
Samuel

2005-11-13 14:33:36

by Antonino A. Daplas

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Samuel Thibault wrote:
> Antonino A. Daplas, le Sun 13 Nov 2005 06:20:53 +0800, a ?crit :
>> "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.
>> ---------------------
>> | **************** |
>> | * * |
>> | * * |
>> | **************** |
>> | |
>> | |
>> | |
>> ---------------------
>
> Are you missing some left and right part too? What are the dimensions of
> the text screen at bootup? What bootloader are you using? (It could be a
> bug in the boot up text screen dimension discovery).

It was just the height. All numbers (done with printk's) look okay from
bootup. He gets 80 and 25 for ORIG_VIDEO_NUM_COLS and ORIG_VIDEO_NUM_LINES
respectively.

>
>> I have a Silicon Graphics 1600sw LCD panel with a Number Nine Revolution 4
>> video card."
>
> Does vgacon.c properly discovers that it is a VGA board?

Yes.

>
>> This bug seems to be a glitch in the VGA core of this chipset. Resizing
>> the screen triggers the mentioned bug.
>
> Do vga-only games (like old DOS-mode games) work with it?
>
>> The workaround is to make vgacon avoid calling vgacon_doresize() if the
>> display parameters did not change.
>
> I.e. never call it, actually.
>
>> A definitive fix will need to be provided by someone who knows and has the
>> hardware.
>
> I'm not sure it is hardware-specific. Maybe you have a combination of
> vga bios/bootloader/vga=ask/... that prevents vgacon.c from properly
> discovering the dimensions of the text screen.

His console worked before linux-2.6.14-rc2.

Tony

2005-11-13 19:40:50

by Bodo Eggert

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Antonino A. Daplas <[email protected]> wrote:

> +++ b/drivers/video/console/vgacon.c
> +#define VGA_FONTWIDTH 8 /* VGA does not support fontwidths != 8 */

This is not true, VGA cards do support fontwidth=9, but the ninth column
can only be blank or (optionally and only in the range of the IBM block
chars) copied from the eighth column, cloning the behaviour of the MDA
graphics card. If you disable this feature, you'll get 90x25 text resolution
within standard VGA timings.

BTW while looking at this file:

1) I see ORIG_VIDEO_EGA_BX (defined to (screen_info.orig_video_ega_bx)
being checked to be 0x10, but I don't find a place where the associated
variable is set to this value. Nor do I get the meaning of this variable
by reading it's name.

2) If the videomode is 7, the card is asumed not to be a VGA card.
VGA does support videomode 7, so this test is wrong. However, I don't
asume this mode to be used on normal systems as nobody complained.

I asume from the fragments I read that the correct fix would be to read
the Display Combination Code for VGA (detects additional CGA and MDA
adapters), then detect EGA (if it is, don't forget to check to check bit
3 of 0x487) and use the return code and finally to use the CRTC address
from the BIOS (The video mode may be set to 5 or 6 in order to make a
mouse driver work in Hercules graphics). In case of EGA, we'll
have to detect additional adapters manually. (Unfortunaly I threw away my
EGA-compatible monitor, so I don't know if I can test it.)

3) Having a text mode is tested by a blacklist of graphic modes. I don't
think this is good, but I've not yet read everything in this file.
--
Ich danke GMX daf?r, die Verwendung meiner Adressen mittels per SPF
verbreiteten L?gen zu sabotieren.

2005-11-13 22:11:57

by Antonino A. Daplas

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Bodo Eggert wrote:
> Antonino A. Daplas <[email protected]> wrote:
>
>> +++ b/drivers/video/console/vgacon.c
>> +#define VGA_FONTWIDTH 8 /* VGA does not support fontwidths != 8 */
>
> This is not true, VGA cards do support fontwidth=9, but the ninth column

Yes. What it should mean is that vgacon does not support fontwidths != 8.

> can only be blank or (optionally and only in the range of the IBM block
> chars) copied from the eighth column, cloning the behaviour of the MDA
> graphics card. If you disable this feature, you'll get 90x25 text resolution
> within standard VGA timings.
>
> BTW while looking at this file:
>
> 1) I see ORIG_VIDEO_EGA_BX (defined to (screen_info.orig_video_ega_bx)
> being checked to be 0x10, but I don't find a place where the associated
> variable is set to this value. Nor do I get the meaning of this variable
> by reading it's name.

Set at arch/i386/boot/video.S. It contains the contents of register bx
after calling int 0x10 ah=0x12 bl=0x10.

Tony

2005-11-13 22:25:39

by Samuel Thibault

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Antonino A. Daplas, le Sun 13 Nov 2005 22:33:18 +0800, a ?crit :
> Samuel Thibault wrote:
> > Antonino A. Daplas, le Sun 13 Nov 2005 06:20:53 +0800, a ?crit :
> >> "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.
> >> ---------------------
> >> | **************** |
> >> | * * |
> >> | * * |
> >> | **************** |
> >> | |
> >> | |
> >> | |
> >> ---------------------
> >
> > Are you missing some left and right part too? What are the dimensions of
> > the text screen at bootup? What bootloader are you using? (It could be a
> > bug in the boot up text screen dimension discovery).
>
> It was just the height. All numbers (done with printk's) look okay from
> bootup. He gets 80 and 25 for ORIG_VIDEO_NUM_COLS and ORIG_VIDEO_NUM_LINES
> respectively.

And you got less than 25 lines? How many exactly?

Regards,
Samuel

2005-11-13 22:24:54

by Samuel Thibault

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Bodo Eggert, le Sun 13 Nov 2005 20:41:04 +0100, a ?crit :
> 2) If the videomode is 7, the card is asumed not to be a VGA card.
> VGA does support videomode 7, so this test is wrong.

But IIRC, in that case, the VGA board just emulates a MDA adapter, so
using it as an MDA adapter makes sense.

Regards,
Samuel

2005-11-13 22:26:50

by Mika Penttilä

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Antonino A. Daplas wrote:

>Bodo Eggert wrote:
>
>
>>Antonino A. Daplas <[email protected]> wrote:
>>
>>
>>
>>>+++ b/drivers/video/console/vgacon.c
>>>+#define VGA_FONTWIDTH 8 /* VGA does not support fontwidths != 8 */
>>>
>>>
>>This is not true, VGA cards do support fontwidth=9, but the ninth column
>>
>>
>
>Yes. What it should mean is that vgacon does not support fontwidths != 8.
>
>
>
I think vgacon doesn't touch the 8/9 pixel setting, so the fonts are hw
extended to 9 pixels by VGA in many modes.

--Mika

2005-11-13 23:36:12

by Antonino A. Daplas

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Mika Penttil? wrote:
> Antonino A. Daplas wrote:
>
>> Bodo Eggert wrote:
>>
>>
>>> Antonino A. Daplas <[email protected]> wrote:
>>>
>>>
>>>> +++ b/drivers/video/console/vgacon.c
>>>> +#define VGA_FONTWIDTH 8 /* VGA does not support fontwidths
>>>> != 8 */
>>>>
>>> This is not true, VGA cards do support fontwidth=9, but the ninth column
>>>
>>
>> Yes. What it should mean is that vgacon does not support fontwidths
>> != 8.
>>
>>
>>
> I think vgacon doesn't touch the 8/9 pixel setting, so the fonts are hw
> extended to 9 pixels by VGA in many modes.
>

It's not a hardware limitation, but vgacon is hardcoded to accept fonts that are
only 8 pixels wide. You can try it by doing a setfont.

Tony

2005-11-13 23:37:35

by Antonino A. Daplas

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Samuel Thibault wrote:
> Antonino A. Daplas, le Sun 13 Nov 2005 22:33:18 +0800, a ?crit :
>> Samuel Thibault wrote:
>>> Antonino A. Daplas, le Sun 13 Nov 2005 06:20:53 +0800, a ?crit :
>>>> "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.
>>>> ---------------------
>>>> | **************** |
>>>> | * * |
>>>> | * * |
>>>> | **************** |
>>>> | |
>>>> | |
>>>> | |
>>>> ---------------------
>>> Are you missing some left and right part too? What are the dimensions of
>>> the text screen at bootup? What bootloader are you using? (It could be a
>>> bug in the boot up text screen dimension discovery).
>> It was just the height. All numbers (done with printk's) look okay from
>> bootup. He gets 80 and 25 for ORIG_VIDEO_NUM_COLS and ORIG_VIDEO_NUM_LINES
>> respectively.
>
> And you got less than 25 lines? How many exactly?

If the original size was at 80x25, and vgacon_doresize() was called, the
the resulting screen is only 80x12.5. The 13th line has its bottom half
chopped off, and the rest of the lines (14-25) is invisible.

If he sets it at < 25, he gets a window much smaller than 12.5, but he did
not specify. So my guess is his chipset programs the screen height by 1/2
of the value of the requested rows.

Tony

2005-11-14 03:32:31

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Followup to: <[email protected]>
By author: "Antonino A. Daplas" <[email protected]>
In newsgroup: linux.dev.kernel
> >>
> >>
> > I think vgacon doesn't touch the 8/9 pixel setting, so the fonts are hw
> > extended to 9 pixels by VGA in many modes.
> >
>
> It's not a hardware limitation, but vgacon is hardcoded to accept fonts that are
> only 8 pixels wide. You can try it by doing a setfont.
>

The *font* is always 8 pixels wide. Whether or not you display it in
8- or 9-pixel mode is irrelevant to the formatting of the font.

In general, for vgacon, it should use the 9-pixel mode, at least by default.

-hpa

2005-11-14 03:46:46

by Jason Dravet

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

>From: "Antonino A. Daplas" <[email protected]>
>To: Samuel Thibault <[email protected]>
>CC: Linus Torvalds <[email protected]>, Andrew Morton <[email protected]>,
>Dave Jones <[email protected]>, Jason <[email protected]>, Linux Kernel
>Development <[email protected]>
>Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets
>Date: Mon, 14 Nov 2005 07:37:17 +0800
>
>Samuel Thibault wrote:
> > Antonino A. Daplas, le Sun 13 Nov 2005 22:33:18 +0800, a ?crit :
> >> Samuel Thibault wrote:
> >>> Antonino A. Daplas, le Sun 13 Nov 2005 06:20:53 +0800, a ?crit :
> >>>> "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.
> >>>> ---------------------
> >>>> | **************** |
> >>>> | * * |
> >>>> | * * |
> >>>> | **************** |
> >>>> | |
> >>>> | |
> >>>> | |
> >>>> ---------------------
> >>> Are you missing some left and right part too? What are the dimensions
>of
> >>> the text screen at bootup? What bootloader are you using? (It could be
>a
> >>> bug in the boot up text screen dimension discovery).
> >> It was just the height. All numbers (done with printk's) look okay
>from
> >> bootup. He gets 80 and 25 for ORIG_VIDEO_NUM_COLS and
>ORIG_VIDEO_NUM_LINES
> >> respectively.
> >
> > And you got less than 25 lines? How many exactly?
>
>If the original size was at 80x25, and vgacon_doresize() was called, the
>the resulting screen is only 80x12.5. The 13th line has its bottom half
>chopped off, and the rest of the lines (14-25) is invisible.
>
>If he sets it at < 25, he gets a window much smaller than 12.5, but he did
>not specify. So my guess is his chipset programs the screen height by 1/2
>of the value of the requested rows.
>
>Tony

When I run stty rows 20 I get a screen of 80x20. I can see the top 10 rows
and the bottom 10 rows are invisible.

Thanks,
Jason Dravet


2005-11-14 09:23:34

by Bodo Eggert

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Jason Dravet <[email protected]> wrote:

> When I run stty rows 20 I get a screen of 80x20. I can see the top 10 rows
> and the bottom 10 rows are invisible.

I asume your VGA indicates that it'll divide it's scanline counter by 2.
Please add a printk("vgacon: mode=%2.2x\n", mode) before line 512 and report
the value. A real fix will depend on this value. In the meantime, removing
the lines 512 and 513 from the original file should be a temporary fix.

--
Ich danke GMX daf?r, die Verwendung meiner Adressen mittels per SPF
verbreiteten L?gen zu sabotieren.

2005-11-14 15:27:53

by Jason Dravet

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

>From: Bodo Eggert <[email protected]>
>Reply-To: [email protected]
>To: Jason Dravet <[email protected]>, [email protected],
>[email protected], [email protected], [email protected],
>[email protected], [email protected]
>Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets
>Date: Mon, 14 Nov 2005 10:24:02 +0100
>
>Jason Dravet <[email protected]> wrote:
>
> > When I run stty rows 20 I get a screen of 80x20. I can see the top 10
>rows
> > and the bottom 10 rows are invisible.
>
>I asume your VGA indicates that it'll divide it's scanline counter by 2.
>Please add a printk("vgacon: mode=%2.2x\n", mode) before line 512 and
>report
>the value. A real fix will depend on this value. In the meantime, removing
>the lines 512 and 513 from the original file should be a temporary fix.
>
>--
>Ich danke GMX daf?r, die Verwendung meiner Adressen mittels per SPF
>verbreiteten L?gen zu sabotieren.

Here is the result from the printk you requested:
vgacon: mode=a3

I commented out lines 512 and 513 and the problem remains.

Thanks,
Jason


2005-11-14 16:31:24

by Bodo Eggert

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

On Mon, 14 Nov 2005, Jason Dravet wrote:
> >From: Bodo Eggert <[email protected]>

> >I asume your VGA indicates that it'll divide it's scanline counter by 2.
> >Please add a printk("vgacon: mode=%2.2x\n", mode) before line 512 and
> >report
> >the value. A real fix will depend on this value. In the meantime, removing
> >the lines 512 and 513 from the original file should be a temporary fix.
>
> Here is the result from the printk you requested:
> vgacon: mode=a3
>
> I commented out lines 512 and 513 and the problem remains.

It seems I was wrong. I will have to think about it later. In the
meantime, you might also want to use the no-scroll (IIRC) kernel
parameter. (Disclaimer: I just started rading this file.)

--
Funny quotes:
1. Save the whales. Collect the whole set.

2005-11-16 00:06:12

by Samuel Thibault

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Hi,

Jason Dravet, le Mon 14 Nov 2005 09:27:51 -0600, a ?crit :
> >Jason Dravet <[email protected]> wrote:
> >
> >> When I run stty rows 20 I get a screen of 80x20. I can see the top 10
> >rows
> >> and the bottom 10 rows are invisible.
> >
> >I asume your VGA indicates that it'll divide it's scanline counter by 2.
> >Please add a printk("vgacon: mode=%2.2x\n", mode) before line 512 and
> >report
> >the value. A real fix will depend on this value. In the meantime, removing
> >the lines 512 and 513 from the original file should be a temporary fix.
>
> Here is the result from the printk you requested:
> vgacon: mode=a3
>
> I commented out lines 512 and 513 and the problem remains.

Really strange...

At that same line, could you try adding this:

printk("vgacon: y=%d fonth=%d deffh=%d vidfh=%d scanl=%d\n", height, c->vc_font.height, vga_default_font_height, vga_video_font_height, vga_scan_lines);
outb_p(VGA_CRTC_OVERFLOW, vga_video_port_reg);
printk("vgacon: overflow %02x\n",inb_p(vga_video_port_val));
outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg);
printk("vgacon: vsync_end %02x\n",inb_p(vga_video_port_val));
outb_p(VGA_CRTC_V_DISP_END, vga_video_port_reg);
printk("vgacon: vdisp_end %02x\n",inb_p(vga_video_port_val));

Regards,
Samuel

2005-11-16 01:50:40

by Jason Dravet

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

>From: Samuel Thibault <[email protected]>
>To: Jason Dravet <[email protected]>
>CC: [email protected], [email protected], [email protected],
>[email protected],[email protected], [email protected]
>Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets
>Date: Wed, 16 Nov 2005 01:05:49 +0100
>
>Hi,
>
>Jason Dravet, le Mon 14 Nov 2005 09:27:51 -0600, a ?crit :
> > >Jason Dravet <[email protected]> wrote:
> > >
> > >> When I run stty rows 20 I get a screen of 80x20. I can see the top
>10
> > >rows
> > >> and the bottom 10 rows are invisible.
> > >
> > >I asume your VGA indicates that it'll divide it's scanline counter by
>2.
> > >Please add a printk("vgacon: mode=%2.2x\n", mode) before line 512 and
> > >report
> > >the value. A real fix will depend on this value. In the meantime,
>removing
> > >the lines 512 and 513 from the original file should be a temporary fix.
> >
> > Here is the result from the printk you requested:
> > vgacon: mode=a3
> >
> > I commented out lines 512 and 513 and the problem remains.
>
>Really strange...
>
>At that same line, could you try adding this:
>
>printk("vgacon: y=%d fonth=%d deffh=%d vidfh=%d scanl=%d\n", height,
>c->vc_font.height, vga_default_font_height, vga_video_font_height,
>vga_scan_lines);
>outb_p(VGA_CRTC_OVERFLOW, vga_video_port_reg);
>printk("vgacon: overflow %02x\n",inb_p(vga_video_port_val));
>outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg);
>printk("vgacon: vsync_end %02x\n",inb_p(vga_video_port_val));
>outb_p(VGA_CRTC_V_DISP_END, vga_video_port_reg);
>printk("vgacon: vdisp_end %02x\n",inb_p(vga_video_port_val));
>
>Regards,
>Samuel

Here are the results:
y=25 fonth=16 deffh=16 vidfh=16 scanl=400
overflow=ff
vsync_end=8f
vdisp_end=1f

Thanks,
Jason


2005-11-16 02:25:21

by Samuel Thibault

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Hi,

Jason Dravet, le Tue 15 Nov 2005 19:50:39 -0600, a ?crit :
> Here are the results:
> y=25 fonth=16 deffh=16 vidfh=16 scanl=400
> overflow=ff
> vsync_end=8f
> vdisp_end=1f

Ah, this is odd indeed: your hardware uses 800 scanlines
(overflow:(512+256)+vdisp_end:0x1f), while the actual needed lines
should be y:25*fonth:16 ... Maybe it is actually using a 32 lines font.

Just to make sure about every VGA bits, could you install the
svgatextmode package, which holds a getVGAreg command, and run twice

for i in `seq 0 24` ; do getVGAreg CRTC $i ; done

The first time while having a correct full text screen rendering, and
the second time after vgacon_doresize() has blanked the bottom half of
the screen.

Regards,
Samuel

2005-11-16 17:58:47

by Jason Dravet

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

>From: Samuel Thibault <[email protected]>
>To: Jason Dravet <[email protected]>
>CC: [email protected], [email protected], [email protected],
>[email protected],[email protected], [email protected]
>Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets
>Date: Wed, 16 Nov 2005 03:25:08 +0100
>
>Hi,
>
>Jason Dravet, le Tue 15 Nov 2005 19:50:39 -0600, a ?crit :
> > Here are the results:
> > y=25 fonth=16 deffh=16 vidfh=16 scanl=400
> > overflow=ff
> > vsync_end=8f
> > vdisp_end=1f
>
>Ah, this is odd indeed: your hardware uses 800 scanlines
>(overflow:(512+256)+vdisp_end:0x1f), while the actual needed lines
>should be y:25*fonth:16 ... Maybe it is actually using a 32 lines font.
>
>Just to make sure about every VGA bits, could you install the
>svgatextmode package, which holds a getVGAreg command, and run twice
>
>for i in `seq 0 24` ; do getVGAreg CRTC $i ; done
>
>The first time while having a correct full text screen rendering, and
>the second time after vgacon_doresize() has blanked the bottom half of
>the screen.
>
>Regards,
>Samuel

For some reason my custom 2.6.14 kernels no longer boot. While I look into
this here are the results when only half the screen works:

VGA 'CRTC' register, index 0 (=0x0) contains 89 (=0x59 =b01011001)
VGA 'CRTC' register, index 1 (=0x1) contains 79 (=0x4f =b01001111)
VGA 'CRTC' register, index 2 (=0x2) contains 79 (=0x4f =b01001111)
VGA 'CRTC' register, index 3 (=0x3) contains 157 (=0x9d =b10011101)
VGA 'CRTC' register, index 4 (=0x4) contains 84 (=0x54 =b01010100)
VGA 'CRTC' register, index 5 (=0x5) contains 27 (=0x1b =b00011011)
VGA 'CRTC' register, index 6 (=0x6) contains 255 (=0xff =b11111111)
VGA 'CRTC' register, index 7 (=0x7) contains 191 (=0xbf =b10111111)
VGA 'CRTC' register, index 8 (=0x8) contains 0 (=0x00 =b00000000)
VGA 'CRTC' register, index 9 (=0x9) contains 239 (=0xef =b11101111)
VGA 'CRTC' register, index 10 (=0xa) contains 13 (=0x0d =b00001101)
VGA 'CRTC' register, index 11 (=0xb) contains 14 (=0x0e =b00001110)
VGA 'CRTC' register, index 12 (=0xc) contains 40 (=0x28 =b00101000)
VGA 'CRTC' register, index 13 (=0xd) contains 240 (=0xf0 =b11110000)
VGA 'CRTC' register, index 14 (=0xe) contains 42 (=0x2a =b00101010)
VGA 'CRTC' register, index 15 (=0xf) contains 32 (=0x20 =b00100000)
VGA 'CRTC' register, index 16 (=0x10) contains 125 (=0x7d =b01111101)
VGA 'CRTC' register, index 17 (=0x11) contains 143 (=0x8f =b10001111)
VGA 'CRTC' register, index 18 (=0x12) contains 143 (=0x8f =b10001111)
VGA 'CRTC' register, index 19 (=0x13) contains 40 (=0x28 =b00101000)
VGA 'CRTC' register, index 20 (=0x14) contains 31 (=0x1f =b00011111)
VGA 'CRTC' register, index 21 (=0x15) contains 30 (=0x1e =b00011110)
VGA 'CRTC' register, index 22 (=0x16) contains 0 (=0x00 =b00000000)
VGA 'CRTC' register, index 23 (=0x17) contains 163 (=0xa3 =b10100011)
VGA 'CRTC' register, index 24 (=0x18) contains 255 (=0xff =b11111111)

I will send the whole screen results when I find and fix the problem. I am
running the fedora core development system with all but todays updates.

Thanks,
Jason


2005-11-16 23:52:35

by Samuel Thibault

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

Hi,

The following patch should correct the issue:

When doublescan mode is in use, scanlines must be doubled.

Signed-off-by: Samuel Thibault <[email protected]>

--- drivers/video/console/vgacon.c.orig 2005-11-17 00:40:02.000000000 +0100
+++ drivers/video/console/vgacon.c 2005-11-17 00:42:27.000000000 +0100
@@ -502,10 +502,16 @@
{
unsigned long flags;
unsigned int scanlines = height * c->vc_font.height;
- u8 scanlines_lo, r7, vsync_end, mode;
+ u8 scanlines_lo, r7, vsync_end, mode, max_scan;

spin_lock_irqsave(&vga_lock, flags);

+ outb_p(VGA_CRTC_MAX_SCAN, vga_video_port_reg);
+ max_scan = inb_p(vga_video_port_val);
+
+ if (max_scan & 0x80)
+ scanlines <<= 1;
+
outb_p(VGA_CRTC_MODE, vga_video_port_reg);
mode = inb_p(vga_video_port_val);

2005-11-17 01:37:04

by Jason Dravet

[permalink] [raw]
Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets

>From: Samuel Thibault <[email protected]>
>To: Jason Dravet <[email protected]>
>CC: [email protected], [email protected], [email protected],
>[email protected],[email protected], [email protected]
>Subject: Re: [PATCH] vgacon: Workaround for resize bug in some chipsets
>Date: Thu, 17 Nov 2005 00:52:16 +0100
>
>Hi,
>
>The following patch should correct the issue:
>
>When doublescan mode is in use, scanlines must be doubled.
>
>Signed-off-by: Samuel Thibault <[email protected]>
>
>--- drivers/video/console/vgacon.c.orig 2005-11-17 00:40:02.000000000 +0100
>+++ drivers/video/console/vgacon.c 2005-11-17 00:42:27.000000000 +0100
>@@ -502,10 +502,16 @@
> {
> unsigned long flags;
> unsigned int scanlines = height * c->vc_font.height;
>- u8 scanlines_lo, r7, vsync_end, mode;
>+ u8 scanlines_lo, r7, vsync_end, mode, max_scan;
>
> spin_lock_irqsave(&vga_lock, flags);
>
>+ outb_p(VGA_CRTC_MAX_SCAN, vga_video_port_reg);
>+ max_scan = inb_p(vga_video_port_val);
>+
>+ if (max_scan & 0x80)
>+ scanlines <<= 1;
>+
> outb_p(VGA_CRTC_MODE, vga_video_port_reg);
> mode = inb_p(vga_video_port_val);
>

The patch does fix my problem. Thank you Samuel. I really appreciate the
work you and Antonino have done on this issue. I look forward to seeing
this patch in the mainline.

Thanks again,
Jason Dravet