linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Kern <alex.kern@gmx.de>
To: "Antonino A. Daplas" <adaplas@hotpop.com>
Cc: fbdev <linux-fbdev-devel@lists.sourceforge.net>
Subject: [PATCH modedb.c] change the find_mode behaviour
Date: Wed, 10 Nov 2004 19:29:33 +0100	[thread overview]
Message-ID: <200411101929.33195.alex.kern@gmx.de> (raw)

[-- 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) {

                 reply	other threads:[~2004-11-10 18:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200411101929.33195.alex.kern@gmx.de \
    --to=alex.kern@gmx.de \
    --cc=adaplas@hotpop.com \
    --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 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).