* Fwd: [PATCH 2.5.59] fix for fbcon.c
@ 2003-01-19 18:56 Alexander Kern
2003-01-20 8:45 ` Antonino Daplas
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Kern @ 2003-01-19 18:56 UTC (permalink / raw)
To: Linux-fbdev-devel
[-- Attachment #1: Type: text/plain, Size: 1317 bytes --]
---------- Weitergeleitete Nachricht ----------
Subject: [PATCH 2.5.59] fix for fbcon.c
Date: Sun, 19 Jan 2003 19:36:12 +0100
From: Alexander Kern <alex.kern@gmx.de>
To: fb-devel@lists.sourceforge.net
Hello,
hier is a fix needed by 1400x1050 resolution. fbcon_resize() without fis set
resolution to 1400x1040 and confusing LCD vertical stretching.
Regards
Alex
PS: I have retest both kernel versions, here is a result.
COMPAQ ARMADA E500, ATI (Mach64) Rage 3D Mobility P/M
15" with native 1400x1050 pixel
2.4.21-pre3 2.5.59
640x400 perfect(LOGO) perfect
640x480 perfect(LOGO) perfect
800x600 perfect perfect
1024x768 h. overlapping(LOGO) h. overlapping
1152x864 h. overlapping h. overlapping
1280x1024 h. overlapping h. overlapping
1400x1050 perfect perfect (with this
fix)
LOGO by 640x4?0 means strange blue pixels as mirror of pinguin
LOGO by 1024x768 means shift to top, pinguin head is unvisible
h. overlapping means mostly stretching issue.
-------------------------------------------------------
[-- Attachment #2: fbcon.diff --]
[-- Type: text/x-diff, Size: 997 bytes --]
--- linux-2.5.orig/drivers/video/console/fbcon.c 2003-01-17 16:13:53.000000000 +0100
+++ linux/drivers/video/console/fbcon.c 2003-01-19 19:17:23.000000000 +0100
@@ -1876,17 +1876,23 @@
struct display *p = &fb_display[vc->vc_num];
struct fb_info *info = p->fb_info;
struct fb_var_screeninfo var = info->var;
- int err;
+ int err; int x_diff, y_diff;
var.xres = width * vc->vc_font.width;
var.yres = height * vc->vc_font.height;
var.activate = FB_ACTIVATE_NOW;
-
+ x_diff = info->var.xres - var.xres;
+ y_diff = info->var.yres - var.yres;
+ if(x_diff < 0 || x_diff > vc->vc_font.width ||
+ (y_diff < 0 || y_diff > vc->vc_font.height)) {
+ DPRINTK("resize now %ix%i\n", var.xres, var.yres);
err = fb_set_var(&var, info);
return (err || var.xres != info->var.xres ||
- var.yres != info->var.yres) ?
- -EINVAL : 0;
-
+ var.yres != info->var.yres) ? -EINVAL : 0;
+ } else {
+ DPRINTK("prevent resize\n");
+ return 0;
+ }
}
static int fbcon_switch(struct vc_data *vc)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fwd: [PATCH 2.5.59] fix for fbcon.c
2003-01-19 18:56 Fwd: [PATCH 2.5.59] fix for fbcon.c Alexander Kern
@ 2003-01-20 8:45 ` Antonino Daplas
2003-01-22 17:45 ` Alexander Kern
2003-02-17 11:33 ` Antonino Daplas
0 siblings, 2 replies; 4+ messages in thread
From: Antonino Daplas @ 2003-01-20 8:45 UTC (permalink / raw)
To: Alexander Kern; +Cc: Linux Fbdev development list
On Mon, 2003-01-20 at 02:56, Alexander Kern wrote:
[...]
> --- linux-2.5.orig/drivers/video/console/fbcon.c 2003-01-17 16:13:53.000000000 +0100
> +++ linux/drivers/video/console/fbcon.c 2003-01-19 19:17:23.000000000 +0100
> @@ -1876,17 +1876,23 @@
> struct display *p = &fb_display[vc->vc_num];
> struct fb_info *info = p->fb_info;
> struct fb_var_screeninfo var = info->var;
> - int err;
> + int err; int x_diff, y_diff;
>
> var.xres = width * vc->vc_font.width;
> var.yres = height * vc->vc_font.height;
> var.activate = FB_ACTIVATE_NOW;
> -
> + x_diff = info->var.xres - var.xres;
> + y_diff = info->var.yres - var.yres;
> + if(x_diff < 0 || x_diff > vc->vc_font.width ||
> + (y_diff < 0 || y_diff > vc->vc_font.height)) {
> + DPRINTK("resize now %ix%i\n", var.xres, var.yres);
> err = fb_set_var(&var, info);
> return (err || var.xres != info->var.xres ||
> - var.yres != info->var.yres) ?
> - -EINVAL : 0;
> -
> + var.yres != info->var.yres) ? -EINVAL : 0;
> + } else {
> + DPRINTK("prevent resize\n");
> + return 0;
> + }
> }
>
> static int fbcon_switch(struct vc_data *vc)
Yes, that will work, only if all your console have the same window
size. If the size of one of your console is different, then these tests
(x_diff > vc->vc_font.width || y_diff > vc->vc_font.height) will become
true each time you switch consoles, so you'll be back with a yres of
1040 instead of 1050. The best solution is for the driver to round up
to 1050 if 1040 is not acceptable.
Still, its much better than the old one :-). If you don't mind, I'll
add a few things to your patch:
a. We do not need to activate the hardware immediately if there is a
chance of failure.
b. The xres/yres returned from fb_set_var() will be acceptable as long
as the value is within a fontwidth/fontheight. This should fix hardware
that only has a limited set of video modes.
BTW, I'm also attaching a diff to fix vc_resize() in vt.c. In
vc_resize(), if con_resize() exits with an error, the new console
dimensions are not reset to the original, and memory from kmalloc() is
not freed.
Tony
PATCH 1: fbcon_resize
<< begin >>
diff -Naur linux-2.5.59/drivers/video/console/fbcon.c linux/drivers/video/console/fbcon.c
--- linux-2.5.59/drivers/video/console/fbcon.c 2003-01-20 08:19:50.000000000 +0000
+++ linux/drivers/video/console/fbcon.c 2003-01-20 08:37:06.000000000 +0000
@@ -1870,23 +1870,35 @@
}
-static int fbcon_resize(struct vc_data *vc, unsigned int width,
- unsigned int height)
+ static int fbcon_resize(struct vc_data *vc, unsigned int width,
+ unsigned int height)
{
struct display *p = &fb_display[vc->vc_num];
struct fb_info *info = p->fb_info;
struct fb_var_screeninfo var = info->var;
- int err;
-
- var.xres = width * vc->vc_font.width;
- var.yres = height * vc->vc_font.height;
- var.activate = FB_ACTIVATE_NOW;
-
- err = fb_set_var(&var, info);
- return (err || var.xres != info->var.xres ||
- var.yres != info->var.yres) ?
- -EINVAL : 0;
-
+ int err; int x_diff, y_diff;
+ int fw = vc->vc_font.width;
+ int fh = vc->vc_font.height;
+
+ var.xres = width * fw;
+ var.yres = height * fh;
+ x_diff = info->var.xres - var.xres;
+ y_diff = info->var.yres - var.yres;
+ if (x_diff < 0 || x_diff > fw ||
+ (y_diff < 0 || y_diff > fh)) {
+ var.activate = FB_ACTIVATE_TEST;
+ err = fb_set_var(&var, info);
+ if (err || width != var.xres/fw ||
+ height != var.yres/fh)
+ return -EINVAL;
+ DPRINTK("resize now %ix%i\n", var.xres, var.yres);
+ var.activate = FB_ACTIVATE_NOW;
+ fb_set_var(&var, info);
+ p->vrows = info->var.yres_virtual/fh;
+ } else {
+ DPRINTK("prevent resize\n");
+ }
+ return 0;
}
static int fbcon_switch(struct vc_data *vc)
<< end >>
PATCH 2: vc_resize
<< begin >>
diff -Naur linux-2.5.59/drivers/char/vt.c linux/drivers/char/vt.c
--- linux-2.5.59/drivers/char/vt.c 2003-01-20 08:18:11.000000000 +0000
+++ linux/drivers/char/vt.c 2003-01-20 08:17:37.000000000 +0000
@@ -732,6 +732,10 @@
if (new_cols == video_num_columns && new_rows == video_num_lines)
return 0;
+ err = resize_screen(currcons, new_cols, new_rows);
+ if (err)
+ return err;
+
newscreen = (unsigned short *) kmalloc(new_screen_size, GFP_USER);
if (!newscreen)
return -ENOMEM;
@@ -746,9 +750,6 @@
video_size_row = new_row_size;
screenbuf_size = new_screen_size;
- err = resize_screen(currcons, new_cols, new_rows);
- if (err)
- return err;
rlth = min(old_row_size, new_row_size);
rrem = new_row_size - rlth;
<< end >>
-------------------------------------------------------
This SF.NET email is sponsored by: FREE SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fwd: [PATCH 2.5.59] fix for fbcon.c
2003-01-20 8:45 ` Antonino Daplas
@ 2003-01-22 17:45 ` Alexander Kern
2003-02-17 11:33 ` Antonino Daplas
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Kern @ 2003-01-22 17:45 UTC (permalink / raw)
To: Antonino Daplas; +Cc: fbdev
Hello,
thanks, it look good for me.
Regards
Alex Kern
Am Montag, 20. Januar 2003 09:45 schrieb Antonino Daplas:
> On Mon, 2003-01-20 at 02:56, Alexander Kern wrote:
> [...]
>
> > --- linux-2.5.orig/drivers/video/console/fbcon.c 2003-01-17
> > 16:13:53.000000000 +0100 +++
> > linux/drivers/video/console/fbcon.c 2003-01-19 19:17:23.000000000 +0100
> > @@ -1876,17 +1876,23 @@
> > struct display *p = &fb_display[vc->vc_num];
> > struct fb_info *info = p->fb_info;
> > struct fb_var_screeninfo var = info->var;
> > - int err;
> > + int err; int x_diff, y_diff;
> >
> > var.xres = width * vc->vc_font.width;
> > var.yres = height * vc->vc_font.height;
> > var.activate = FB_ACTIVATE_NOW;
> > -
> > + x_diff = info->var.xres - var.xres;
> > + y_diff = info->var.yres - var.yres;
> > + if(x_diff < 0 || x_diff > vc->vc_font.width ||
> > + (y_diff < 0 || y_diff > vc->vc_font.height)) {
> > + DPRINTK("resize now %ix%i\n", var.xres, var.yres);
> > err = fb_set_var(&var, info);
> > return (err || var.xres != info->var.xres ||
> > - var.yres != info->var.yres) ?
> > - -EINVAL : 0;
> > -
> > + var.yres != info->var.yres) ? -EINVAL : 0;
> > + } else {
> > + DPRINTK("prevent resize\n");
> > + return 0;
> > + }
> > }
> >
> > static int fbcon_switch(struct vc_data *vc)
>
> Yes, that will work, only if all your console have the same window
> size. If the size of one of your console is different, then these tests
> (x_diff > vc->vc_font.width || y_diff > vc->vc_font.height) will become
> true each time you switch consoles, so you'll be back with a yres of
> 1040 instead of 1050. The best solution is for the driver to round up
> to 1050 if 1040 is not acceptable.
>
> Still, its much better than the old one :-). If you don't mind, I'll
> add a few things to your patch:
>
> a. We do not need to activate the hardware immediately if there is a
> chance of failure.
>
> b. The xres/yres returned from fb_set_var() will be acceptable as long
> as the value is within a fontwidth/fontheight. This should fix hardware
> that only has a limited set of video modes.
>
> BTW, I'm also attaching a diff to fix vc_resize() in vt.c. In
> vc_resize(), if con_resize() exits with an error, the new console
> dimensions are not reset to the original, and memory from kmalloc() is
> not freed.
>
> Tony
>
> PATCH 1: fbcon_resize
> << begin >>
>
> diff -Naur linux-2.5.59/drivers/video/console/fbcon.c
> linux/drivers/video/console/fbcon.c ---
> linux-2.5.59/drivers/video/console/fbcon.c 2003-01-20 08:19:50.000000000
> +0000 +++ linux/drivers/video/console/fbcon.c 2003-01-20 08:37:06.000000000
> +0000 @@ -1870,23 +1870,35 @@
> }
>
>
> -static int fbcon_resize(struct vc_data *vc, unsigned int width,
> - unsigned int height)
> + static int fbcon_resize(struct vc_data *vc, unsigned int width,
> + unsigned int height)
> {
> struct display *p = &fb_display[vc->vc_num];
> struct fb_info *info = p->fb_info;
> struct fb_var_screeninfo var = info->var;
> - int err;
> -
> - var.xres = width * vc->vc_font.width;
> - var.yres = height * vc->vc_font.height;
> - var.activate = FB_ACTIVATE_NOW;
> -
> - err = fb_set_var(&var, info);
> - return (err || var.xres != info->var.xres ||
> - var.yres != info->var.yres) ?
> - -EINVAL : 0;
> -
> + int err; int x_diff, y_diff;
> + int fw = vc->vc_font.width;
> + int fh = vc->vc_font.height;
> +
> + var.xres = width * fw;
> + var.yres = height * fh;
> + x_diff = info->var.xres - var.xres;
> + y_diff = info->var.yres - var.yres;
> + if (x_diff < 0 || x_diff > fw ||
> + (y_diff < 0 || y_diff > fh)) {
> + var.activate = FB_ACTIVATE_TEST;
> + err = fb_set_var(&var, info);
> + if (err || width != var.xres/fw ||
> + height != var.yres/fh)
> + return -EINVAL;
> + DPRINTK("resize now %ix%i\n", var.xres, var.yres);
> + var.activate = FB_ACTIVATE_NOW;
> + fb_set_var(&var, info);
> + p->vrows = info->var.yres_virtual/fh;
> + } else {
> + DPRINTK("prevent resize\n");
> + }
> + return 0;
> }
>
> static int fbcon_switch(struct vc_data *vc)
> << end >>
>
> PATCH 2: vc_resize
>
> << begin >>
>
> diff -Naur linux-2.5.59/drivers/char/vt.c linux/drivers/char/vt.c
> --- linux-2.5.59/drivers/char/vt.c 2003-01-20 08:18:11.000000000 +0000
> +++ linux/drivers/char/vt.c 2003-01-20 08:17:37.000000000 +0000
> @@ -732,6 +732,10 @@
> if (new_cols == video_num_columns && new_rows == video_num_lines)
> return 0;
>
> + err = resize_screen(currcons, new_cols, new_rows);
> + if (err)
> + return err;
> +
> newscreen = (unsigned short *) kmalloc(new_screen_size, GFP_USER);
> if (!newscreen)
> return -ENOMEM;
> @@ -746,9 +750,6 @@
> video_size_row = new_row_size;
> screenbuf_size = new_screen_size;
>
> - err = resize_screen(currcons, new_cols, new_rows);
> - if (err)
> - return err;
>
> rlth = min(old_row_size, new_row_size);
> rrem = new_row_size - rlth;
> << end >>
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by: FREE SSL Guide from Thawte
> are you planning your Web Server Security? Click here to get a FREE
> Thawte SSL guide and find the answers to all your SSL security issues.
> http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
> _______________________________________________
> Linux-fbdev-devel mailing list
> Linux-fbdev-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fwd: [PATCH 2.5.59] fix for fbcon.c
2003-01-20 8:45 ` Antonino Daplas
2003-01-22 17:45 ` Alexander Kern
@ 2003-02-17 11:33 ` Antonino Daplas
1 sibling, 0 replies; 4+ messages in thread
From: Antonino Daplas @ 2003-02-17 11:33 UTC (permalink / raw)
To: Antonino Daplas; +Cc: Alexander Kern, Linux Fbdev development list
On Mon, 2003-01-20 at 16:45, Antonino Daplas wrote:
> On Mon, 2003-01-20 at 02:56, Alexander Kern wrote:
>
> Yes, that will work, only if all your console have the same window
> size. If the size of one of your console is different, then these tests
> (x_diff > vc->vc_font.width || y_diff > vc->vc_font.height) will become
> true each time you switch consoles, so you'll be back with a yres of
> 1040 instead of 1050. The best solution is for the driver to round up
> to 1050 if 1040 is not acceptable.
>
> Still, its much better than the old one :-). If you don't mind, I'll
> add a few things to your patch:
>
> a. We do not need to activate the hardware immediately if there is a
> chance of failure.
>
> b. The xres/yres returned from fb_set_var() will be acceptable as long
> as the value is within a fontwidth/fontheight. This should fix hardware
> that only has a limited set of video modes.
>
Here's an incremental patch (linux-2.5.61 + James' latest fbdev.diff)
1. adjust display->vrows unconditionally during fbcon_resize(). This
should prevent console corruption when var->yres_virtual was changed
behind the back of the console, ie using fbset.
2. call fbcon_resize() as early as possible during fbcon_switch().
Tony
diff -Naur linux-2.5.61-fbdev/drivers/video/console/fbcon.c linux-2.5.61/drivers/video/console/fbcon.c
--- linux-2.5.61-fbdev/drivers/video/console/fbcon.c 2003-02-16 21:01:01.000000000 +0000
+++ linux-2.5.61/drivers/video/console/fbcon.c 2003-02-16 22:20:31.000000000 +0000
@@ -1879,8 +1879,8 @@
DPRINTK("resize now %ix%i\n", var.xres, var.yres);
var.activate = FB_ACTIVATE_NOW;
fb_set_var(&var, info);
- p->vrows = info->var.yres_virtual/fh;
}
+ p->vrows = info->var.yres_virtual/fh;
return 0;
}
@@ -1915,6 +1915,9 @@
}
if (info)
info->var.yoffset = p->yscroll = 0;
+
+ fbcon_resize(vc, vc->vc_cols, vc->vc_rows);
+
switch (p->scrollmode & __SCROLL_YMASK) {
case __SCROLL_YWRAP:
scrollback_phys_max = p->vrows - vc->vc_rows;
@@ -1933,7 +1936,6 @@
info->currcon = unit;
- fbcon_resize(vc, vc->vc_cols, vc->vc_rows);
update_var(unit, info);
fbcon_set_palette(vc, color_table);
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-02-17 11:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-19 18:56 Fwd: [PATCH 2.5.59] fix for fbcon.c Alexander Kern
2003-01-20 8:45 ` Antonino Daplas
2003-01-22 17:45 ` Alexander Kern
2003-02-17 11:33 ` Antonino Daplas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).