Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 94135
b: refs/heads/master
c: 6b745b6
h: refs/heads/master
i:
  94133: e90a760
  94131: 1396db7
  94127: e25320e
v: v3
  • Loading branch information
Michal Januszewski authored and Linus Torvalds committed Apr 28, 2008
1 parent 227a17f commit 5ec9894
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 169b6a7a6e91e1ea32136681b475cbaf2074bf35
refs/heads/master: 6b745b6fd02213f4b2fef2f2635985929fc5b8cc
24 changes: 16 additions & 8 deletions trunk/drivers/video/modedb.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
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, cvt = 0, rb = 0, interlace = 0, margins = 0;
u32 best, diff;
u32 best, diff, tdiff;

for (i = namelen-1; i >= 0; i--) {
switch (name[i]) {
Expand Down Expand Up @@ -651,19 +651,27 @@ int fb_find_mode(struct fb_var_screeninfo *var,
return (refresh_specified) ? 2 : 1;
}

diff = xres + yres;
diff = 2 * (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) {
DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres);
if (!fb_try_mode(var, info, &db[i], bpp)) {
if (diff > (db[i].xres - xres) + (db[i].yres - yres)) {
diff = (db[i].xres - xres) + (db[i].yres - yres);
best = i;
}
tdiff = abs(db[i].xres - xres) +
abs(db[i].yres - yres);

/*
* Penalize modes with resolutions smaller
* than requested.
*/
if (xres > db[i].xres || yres > db[i].yres)
tdiff += xres + yres;

if (diff > tdiff) {
diff = tdiff;
best = i;
}
}
}
}
if (best != -1) {
fb_try_mode(var, info, &db[best], bpp);
Expand Down

0 comments on commit 5ec9894

Please sign in to comment.