From: "Antonino A. Daplas" <adaplas@hotpop.com>
To: David Eger <eger@havoc.gtf.org>
Cc: James Simmons <jsimmons@infradead.org>,
Andrew Morton <akpm@osdl.org>,
Linux Fbdev development list
<linux-fbdev-devel@lists.sourceforge.net>
Subject: Re: [PATCH][RIVAFB]: Updates to rivafb driver
Date: Wed, 16 Jun 2004 13:53:51 +0800 [thread overview]
Message-ID: <200406161353.51195.adaplas@hotpop.com> (raw)
In-Reply-To: <200406161044.45807.adaplas@hotpop.com>
On Wednesday 16 June 2004 10:44, Antonino A. Daplas wrote:
> On Wednesday 16 June 2004 06:17, David Eger wrote:
> > hey tony,
> >
> > your patch against drivers/video/riva/fbdev.c chokes on hunk 2 when
> > applied to 2.6.7-rc3-mm2. resend, and i'll test it on my TNT2 :)
>
> Ok. Patch against 2.6.7-rc3-mm2.
>
> Note I haven't added the hardware acceleration capability support yet,
> so scrolling is still slow.
>
> Secondly, stty seems not to work anymore, though I'm sure
> the driver can do mode setup independently if with DDC. I'll look into
> this later.
I believe I know why stty failed. It's because fbcon_resize() inf fbcon.c uses
fb_find_mode(). I have reservations with this method though.
1. Since it uses a mode database, this will completely ignore drivers/hardware
that can do scaling or can use the GTF.
2. Secondly, stty works in a weird manner. For example, fb is in 800x600. I want
to go to 1024x768. In order to do that I issue 'stty cols 128 rows 48'. This will fail
because it will be processed in 2 steps:
1. set at 1024x592 (128x37) <-- fails
2. set at 1024x768(128x48)
Of course, step 1 will fail since 1024x592 is not in the database.
I believe a proper way is to just add another method in info->fb_ops, something like
info->fb_ops->fb_find_mode(struct fb_var_screeninfo*, int xres, int yres) that will
be called by fbcon_resize().
Anyway, a workaround is to add a best-fit algorithm in fb_find_mode(). It will try to return
modes that are bigger but closest to the given mode. fb_find_mode will return 5 in this case.
Note that it currently ignores refresh rates. So, it will now work this way:
1. set at 1024x592(128x37)
fb_find_mode() return 1024x768
2. set at 1024x768(128x48)
fb_find_mode() return 1024x768 (success)
The algo is currently very simple, feel free to modify.
Tony
Signed-off-by: Antonino Daplas <adaplas@pol.net>
1. pass info->monspecs.modedb and info->monspecs.modedb_len to fb_find_mode()
instead of NULL, 0 since its contents are specific to the attached display. Anyway, if
info->monspecs.modedb == NULL, fb_find_mode() will use the default database.
2. Added best fit algo to fb_find_mode().
3. Use snprintf instead of sprintf.
diff -Naur linux-2.6.6-rc3-mm2-orig/drivers/video/console/fbcon.c linux-2.6.6-rc3-mm2-test/drivers/video/console/fbcon.c
--- linux-2.6.6-rc3-mm2-orig/drivers/video/console/fbcon.c 2004-06-16 01:18:35.000000000 +0000
+++ linux-2.6.6-rc3-mm2-test/drivers/video/console/fbcon.c 2004-06-16 05:31:06.594105304 +0000
@@ -1512,9 +1512,10 @@
if (!info->fbops->fb_set_par)
return -EINVAL;
- sprintf(mode, "%dx%d", var.xres, var.yres);
- err = fb_find_mode(&var, info, mode, NULL, 0, NULL,
- info->var.bits_per_pixel);
+ snprintf(mode, 40, "%ix%i", var.xres, var.yres);
+ err = fb_find_mode(&var, info, mode, info->monspecs.modedb,
+ info->monspecs.modedb_len, NULL,
+ info->var.bits_per_pixel);
if (!err || width > var.xres/fw || height > var.yres/fh)
return -EINVAL;
DPRINTK("resize now %ix%i\n", var.xres, var.yres);
diff -Naur linux-2.6.6-rc3-mm2-orig/drivers/video/modedb.c linux-2.6.6-rc3-mm2-test/drivers/video/modedb.c
--- linux-2.6.6-rc3-mm2-orig/drivers/video/modedb.c 2004-06-16 01:17:54.000000000 +0000
+++ linux-2.6.6-rc3-mm2-test/drivers/video/modedb.c 2004-06-16 05:30:55.409805576 +0000
@@ -490,7 +490,8 @@
int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0;
int yres_specified = 0;
-
+ u32 best = -1, diff = -1;
+
for (i = namelen-1; i >= 0; i--) {
switch (name[i]) {
case '@':
@@ -529,8 +530,8 @@
}
done:
for (i = refresh_specified; i >= 0; i--) {
- DPRINTK("Trying specified video mode%s\n",
- i ? "" : " (ignoring refresh rate)");
+ DPRINTK("Trying specified video mode%s %ix%i\n",
+ i ? "" : " (ignoring refresh rate)", xres, yres);
for (j = 0; j < dbsize; j++)
if ((name_matches(db[j], name, namelen) ||
(res_specified && res_matches(db[j], xres, yres))) &&
@@ -538,6 +539,22 @@
!fb_try_mode(var, info, &db[j], bpp))
return 2-i;
}
+ DPRINTK("Trying best-fit modes\n");
+ for (i = 0; i < dbsize; i++) {
+ if (xres <= db[i].xres && yres <= db[i].yres) {
+ DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres);
+ if (!fb_try_mode(var, info, &db[i], bpp)) {
+ if (diff > (db[i].xres - xres) + (db[i].yres - yres)) {
+ diff = (db[i].xres - xres) + (db[i].yres - yres);
+ best = i;
+ }
+ }
+ }
+ }
+ if (best != -1) {
+ fb_try_mode(var, info, &db[best], bpp);
+ return 5;
+ }
}
DPRINTK("Trying default video mode\n");
-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
next prev parent reply other threads:[~2004-06-16 5:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-15 20:06 [PATCH][RIVAFB]: Updates to rivafb driver Antonino A. Daplas
2004-06-15 22:17 ` David Eger
2004-06-15 22:18 ` jsimmons
2004-06-16 2:44 ` Antonino A. Daplas
2004-06-16 5:53 ` Antonino A. Daplas [this message]
2004-06-16 16:47 ` jsimmons
2004-06-16 20:23 ` Andrew Morton
2004-06-16 22:29 ` Antonino A. Daplas
2004-06-16 22:39 ` Andrew Morton
2004-06-17 18:24 ` [PATCH][RIVAFB] rivafb: fb accel capabilities David Eger
2004-06-16 17:34 ` [PATCH][RIVAFB]: Updates to rivafb driver David Eger
2004-06-16 22:29 ` Antonino A. Daplas
2004-06-17 0:16 ` David Eger
2004-06-17 16:34 ` Benjamin Herrenschmidt
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=200406161353.51195.adaplas@hotpop.com \
--to=adaplas@hotpop.com \
--cc=adaplas@pol.net \
--cc=akpm@osdl.org \
--cc=eger@havoc.gtf.org \
--cc=jsimmons@infradead.org \
--cc=linux-fbdev-devel@lists.sourceforge.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.