aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/modedb.c
diff options
context:
space:
mode:
authorMichal Januszewski <spock@gentoo.org>2007-10-16 04:29:19 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:18 -0400
commit1c5dd170927b1aa8e3a01d43d611b840336cdaf2 (patch)
tree15db224cfc06d552cb667bde503cafd90631fa0b /drivers/video/modedb.c
parent10b98368a0a94b015c1a596b7a02eff447a65226 (diff)
fbdev: find mode with the highest/safest refresh rate in fb_find_mode()
Currently, if the refresh rate is not specified, fb_find_mode() returns the first known video mode with the requested resolution, which provides no guarantees wrt the refresh rate. Change this so that the mode with the highest refresh rate is returned when the driver provides a custom video mode database and the monitor limits, and a mode with the safe 60 Hz refresh rate otherwise. Signed-off-by: Michal Januszewski <spock@gentoo.org> Signed-off-by: Antonino Daplas <adaplas@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/modedb.c')
-rw-r--r--drivers/video/modedb.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c
index f7f9c087ad70..03b06aa2475f 100644
--- a/drivers/video/modedb.c
+++ b/drivers/video/modedb.c
@@ -606,26 +606,43 @@ done:
606 DPRINTK("Trying specified video mode%s %ix%i\n", 606 DPRINTK("Trying specified video mode%s %ix%i\n",
607 refresh_specified ? "" : " (ignoring refresh rate)", xres, yres); 607 refresh_specified ? "" : " (ignoring refresh rate)", xres, yres);
608 608
609 diff = refresh; 609 if (!refresh_specified) {
610 /*
611 * If the caller has provided a custom mode database and a
612 * valid monspecs structure, we look for the mode with the
613 * highest refresh rate. Otherwise we play it safe it and
614 * try to find a mode with a refresh rate closest to the
615 * standard 60 Hz.
616 */
617 if (db != modedb &&
618 info->monspecs.vfmin && info->monspecs.vfmax &&
619 info->monspecs.hfmin && info->monspecs.hfmax &&
620 info->monspecs.dclkmax) {
621 refresh = 1000;
622 } else {
623 refresh = 60;
624 }
625 }
626
627 diff = -1;
610 best = -1; 628 best = -1;
611 for (i = 0; i < dbsize; i++) { 629 for (i = 0; i < dbsize; i++) {
612 if (name_matches(db[i], name, namelen) || 630 if ((name_matches(db[i], name, namelen) ||
613 (res_specified && res_matches(db[i], xres, yres))) { 631 (res_specified && res_matches(db[i], xres, yres))) &&
614 if(!fb_try_mode(var, info, &db[i], bpp)) { 632 !fb_try_mode(var, info, &db[i], bpp)) {
615 if(!refresh_specified || db[i].refresh == refresh) 633 if (refresh_specified && db[i].refresh == refresh) {
616 return 1; 634 return 1;
617 else { 635 } else {
618 if(diff > abs(db[i].refresh - refresh)) { 636 if (abs(db[i].refresh - refresh) < diff) {
619 diff = abs(db[i].refresh - refresh); 637 diff = abs(db[i].refresh - refresh);
620 best = i; 638 best = i;
621 }
622 } 639 }
623 } 640 }
624 } 641 }
625 } 642 }
626 if (best != -1) { 643 if (best != -1) {
627 fb_try_mode(var, info, &db[best], bpp); 644 fb_try_mode(var, info, &db[best], bpp);
628 return 2; 645 return (refresh_specified) ? 2 : 1;
629 } 646 }
630 647
631 diff = xres + yres; 648 diff = xres + yres;