]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/video/modedb.c
[SCSI] sym2: fix section mismatch warning
[linux-2.6-omap-h63xx.git] / drivers / video / modedb.c
index f7f9c087ad70a96dd645089243fcce1683215e6e..8d81ef019c6c6f8de6a5eeb6013b061de650a649 100644 (file)
@@ -27,7 +27,7 @@
 #define DPRINTK(fmt, args...)
 #endif
 
-const char *global_mode_option;
+const char *fb_mode_option;
 
     /*
      *  Standard video mode definitions (taken from XFree86)
@@ -510,7 +510,9 @@ int fb_find_mode(struct fb_var_screeninfo *var,
        default_bpp = 8;
 
     /* Did the user specify a video mode? */
-    if (mode_option || (mode_option = global_mode_option)) {
+    if (!mode_option)
+       mode_option = fb_mode_option;
+    if (mode_option) {
        const char *name = mode_option;
        unsigned int namelen = strlen(name);
        int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
@@ -606,26 +608,43 @@ done:
        DPRINTK("Trying specified video mode%s %ix%i\n",
            refresh_specified ? "" : " (ignoring refresh rate)", xres, yres);
 
-       diff = refresh;
+       if (!refresh_specified) {
+               /*
+                * If the caller has provided a custom mode database and a
+                * valid monspecs structure, we look for the mode with the
+                * highest refresh rate.  Otherwise we play it safe it and
+                * try to find a mode with a refresh rate closest to the
+                * standard 60 Hz.
+                */
+               if (db != modedb &&
+                   info->monspecs.vfmin && info->monspecs.vfmax &&
+                   info->monspecs.hfmin && info->monspecs.hfmax &&
+                   info->monspecs.dclkmax) {
+                       refresh = 1000;
+               } else {
+                       refresh = 60;
+               }
+       }
+
+       diff = -1;
        best = -1;
        for (i = 0; i < dbsize; i++) {
-               if (name_matches(db[i], name, namelen) ||
-                   (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 ((name_matches(db[i], name, namelen) ||
+                   (res_specified && res_matches(db[i], xres, yres))) &&
+                   !fb_try_mode(var, info, &db[i], bpp)) {
+                       if (refresh_specified && db[i].refresh == refresh) {
+                               return 1;
+                       } else {
+                               if (abs(db[i].refresh - refresh) < diff) {
+                                       diff = abs(db[i].refresh - refresh);
+                                       best = i;
                                }
                        }
                }
        }
        if (best != -1) {
                fb_try_mode(var, info, &db[best], bpp);
-               return 2;
+               return (refresh_specified) ? 2 : 1;
        }
 
        diff = xres + yres;