Commit 490cf56b authored by Antonino Daplas's avatar Antonino Daplas Committed by Linus Torvalds

[PATCH] More updates to rivafb driver

1.  pass info->monspecs.modedb and info->monspecs.modedb_len to
   fb_find_mode() instead of NULL, 0 since its contents are specific to the
   attached display.  Anyway, if info->monspecs.modedb == NULL,
   fb_find_mode() will use the default database.

2.  Added best fit algo to fb_find_mode().

3.  Use snprintf instead of sprintf.
Signed-off-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5a32c854
......@@ -1512,9 +1512,10 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
if (!info->fbops->fb_set_par)
return -EINVAL;
sprintf(mode, "%dx%d", var.xres, var.yres);
err = fb_find_mode(&var, info, mode, NULL, 0, NULL,
info->var.bits_per_pixel);
snprintf(mode, 40, "%ix%i", var.xres, var.yres);
err = fb_find_mode(&var, info, mode, info->monspecs.modedb,
info->monspecs.modedb_len, NULL,
info->var.bits_per_pixel);
if (!err || width > var.xres/fw || height > var.yres/fh)
return -EINVAL;
DPRINTK("resize now %ix%i\n", var.xres, var.yres);
......
......@@ -490,6 +490,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;
u32 best = -1, diff = -1;
for (i = namelen-1; i >= 0; i--) {
switch (name[i]) {
......@@ -529,8 +530,8 @@ int fb_find_mode(struct fb_var_screeninfo *var,
}
done:
for (i = refresh_specified; i >= 0; i--) {
DPRINTK("Trying specified video mode%s\n",
i ? "" : " (ignoring refresh rate)");
DPRINTK("Trying specified video mode%s %ix%i\n",
i ? "" : " (ignoring refresh rate)", xres, yres);
for (j = 0; j < dbsize; j++)
if ((name_matches(db[j], name, namelen) ||
(res_specified && res_matches(db[j], xres, yres))) &&
......@@ -538,6 +539,22 @@ int fb_find_mode(struct fb_var_screeninfo *var,
!fb_try_mode(var, info, &db[j], bpp))
return 2-i;
}
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;
}
}
}
}
if (best != -1) {
fb_try_mode(var, info, &db[best], bpp);
return 5;
}
}
DPRINTK("Trying default video mode\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment