diff options
-rw-r--r-- | drivers/video/modedb.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c index 08d072552233..640351c9a9e1 100644 --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c | |||
@@ -522,7 +522,7 @@ int fb_find_mode(struct fb_var_screeninfo *var, | |||
522 | int res_specified = 0, bpp_specified = 0, refresh_specified = 0; | 522 | int res_specified = 0, bpp_specified = 0, refresh_specified = 0; |
523 | unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0; | 523 | unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0; |
524 | int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0; | 524 | int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0; |
525 | u32 best, diff; | 525 | u32 best, diff, tdiff; |
526 | 526 | ||
527 | for (i = namelen-1; i >= 0; i--) { | 527 | for (i = namelen-1; i >= 0; i--) { |
528 | switch (name[i]) { | 528 | switch (name[i]) { |
@@ -651,19 +651,27 @@ done: | |||
651 | return (refresh_specified) ? 2 : 1; | 651 | return (refresh_specified) ? 2 : 1; |
652 | } | 652 | } |
653 | 653 | ||
654 | diff = xres + yres; | 654 | diff = 2 * (xres + yres); |
655 | best = -1; | 655 | best = -1; |
656 | DPRINTK("Trying best-fit modes\n"); | 656 | DPRINTK("Trying best-fit modes\n"); |
657 | for (i = 0; i < dbsize; i++) { | 657 | for (i = 0; i < dbsize; i++) { |
658 | if (xres <= db[i].xres && yres <= db[i].yres) { | ||
659 | DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres); | 658 | DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres); |
660 | if (!fb_try_mode(var, info, &db[i], bpp)) { | 659 | if (!fb_try_mode(var, info, &db[i], bpp)) { |
661 | if (diff > (db[i].xres - xres) + (db[i].yres - yres)) { | 660 | tdiff = abs(db[i].xres - xres) + |
662 | diff = (db[i].xres - xres) + (db[i].yres - yres); | 661 | abs(db[i].yres - yres); |
663 | best = i; | 662 | |
664 | } | 663 | /* |
664 | * Penalize modes with resolutions smaller | ||
665 | * than requested. | ||
666 | */ | ||
667 | if (xres > db[i].xres || yres > db[i].yres) | ||
668 | tdiff += xres + yres; | ||
669 | |||
670 | if (diff > tdiff) { | ||
671 | diff = tdiff; | ||
672 | best = i; | ||
673 | } | ||
665 | } | 674 | } |
666 | } | ||
667 | } | 675 | } |
668 | if (best != -1) { | 676 | if (best != -1) { |
669 | fb_try_mode(var, info, &db[best], bpp); | 677 | fb_try_mode(var, info, &db[best], bpp); |