aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/modedb.c
diff options
context:
space:
mode:
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;