* [PATCH modedb.c] change the find_mode behaviour
@ 2004-11-10 18:29 Alexander Kern
0 siblings, 0 replies; only message in thread
From: Alexander Kern @ 2004-11-10 18:29 UTC (permalink / raw)
To: Antonino A. Daplas; +Cc: fbdev
[-- Attachment #1: Type: text/plain, Size: 97 bytes --]
let find_mode search for nearest refresh rate
Signed-off-by: Alexander Kern <alex.kern@gmx.de>
[-- Attachment #2: modedb_search_refresh_closest_to.patch --]
[-- Type: text/x-diff, Size: 2237 bytes --]
--- linux-2.6.head/drivers/video/modedb.c.orig 2004-11-09 19:06:54.000000000 +0100
+++ linux-2.6.head/drivers/video/modedb.c 2004-11-10 16:40:10.994799088 +0100
@@ -24,7 +24,7 @@
((v).xres == (x) && (v).yres == (y))
#ifdef DEBUG
-#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
+#define DPRINTK(fmt, args...) printk("modedb %s: " fmt, __FUNCTION__ , ## args)
#else
#define DPRINTK(fmt, args...)
#endif
@@ -474,7 +474,7 @@
const struct fb_videomode *default_mode,
unsigned int default_bpp)
{
- int i, j;
+ int i;
/* Set up defaults */
if (!db) {
@@ -493,7 +493,7 @@
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;
+ u32 best, diff;
for (i = namelen-1; i >= 0; i--) {
switch (name[i]) {
@@ -532,16 +532,35 @@
res_specified = 1;
}
done:
- for (i = refresh_specified; i >= 0; i--) {
- 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))) &&
- (!i || db[j].refresh == refresh) &&
- !fb_try_mode(var, info, &db[j], bpp))
- return 2-i;
+ DPRINTK("Trying specified video mode%s %ix%i\n",
+ refresh_specified ? "" : " (ignoring refresh rate)", xres, yres);
+
+ diff = refresh;
+ best = -1;
+ for (i = 0; i < dbsize; i++) {
+ if ((name_matches(db[i], name, namelen) &&
+ !fb_try_mode(var, info, &db[i], bpp)))
+ return 1;
+ if (res_specified && res_matches(db[i], xres, yres)) {
+ if(!fb_try_mode(var, info, &db[i], bpp)) {
+ if(!refresh_specified || db[i].refresh == refresh)
+ return 1;
+ else {
+ if(diff > abs(db[i].refresh - refresh)) {
+ diff = abs(db[i].refresh - refresh);
+ best = i;
+ }
+ }
+ }
+ }
+ }
+ if (best != -1) {
+ fb_try_mode(var, info, &db[best], bpp);
+ return 2;
}
+
+ diff = xres + yres;
+ best = -1;
DPRINTK("Trying best-fit modes\n");
for (i = 0; i < dbsize; i++) {
if (xres <= db[i].xres && yres <= db[i].yres) {
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-11-10 18:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-10 18:29 [PATCH modedb.c] change the find_mode behaviour Alexander Kern
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).