From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: [PATCH] radeonfb: Fix mode setting on CRT monitors
Date: Mon, 28 Mar 2005 10:24:56 +1000 [thread overview]
Message-ID: <1111969496.5409.40.camel@gaston> (raw)
Hi !
Current radeonfb is a bit "anal" about accepting CRT modes, it basically only
accepts modes that have the exact resolution, which tends to break with fbcon
on console switches as it provides "approximate" modes. This patch fixes it
by having the driver chose the closest possible mode instead of looking for
an exact match.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
--- linux-work.orig/drivers/video/aty/radeon_monitor.c 2005-03-11 16:54:25.000000000 +1100
+++ linux-work/drivers/video/aty/radeon_monitor.c 2005-03-11 16:58:04.000000000 +1100
@@ -903,7 +903,7 @@
*/
/*
- * This is used when looking for modes. We assign a "goodness" value
+ * This is used when looking for modes. We assign a "distance" value
* to a mode in the modedb depending how "close" it is from what we
* are looking for.
* Currently, we don't compare that much, we could do better but
@@ -912,13 +912,11 @@
static int radeon_compare_modes(const struct fb_var_screeninfo *var,
const struct fb_videomode *mode)
{
- int goodness = 0;
+ int distance = 0;
- if (var->yres == mode->yres)
- goodness += 10;
- if (var->xres == mode->xres)
- goodness += 9;
- return goodness;
+ distance = mode->yres - var->yres;
+ distance += (mode->xres - var->xres)/2;
+ return distance;
}
/*
@@ -940,7 +938,7 @@
const struct fb_videomode *db = vesa_modes;
int i, dbsize = 34;
int has_rmx, native_db = 0;
- int goodness = 0;
+ int distance = INT_MAX;
const struct fb_videomode *candidate = NULL;
/* Start with a copy of the requested mode */
@@ -976,19 +974,19 @@
/* Now look for a mode in the database */
while (db) {
for (i = 0; i < dbsize; i++) {
- int g;
+ int d;
if (db[i].yres < src->yres)
continue;
if (db[i].xres < src->xres)
continue;
- g = radeon_compare_modes(src, &db[i]);
+ d = radeon_compare_modes(src, &db[i]);
/* If the new mode is at least as good as the previous one,
* then it's our new candidate
*/
- if (g >= goodness) {
+ if (d < distance) {
candidate = &db[i];
- goodness = g;
+ distance = d;
}
}
db = NULL;
--
Benjamin Herrenschmidt <benh@kernel.crashing.org>
next reply other threads:[~2005-03-28 0:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-28 0:24 Benjamin Herrenschmidt [this message]
2005-03-28 12:03 ` [PATCH] radeonfb: Fix mode setting on CRT monitors Brice Goglin
2005-03-28 22:37 ` 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=1111969496.5409.40.camel@gaston \
--to=benh@kernel.crashing.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.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