intel-iommu: Fix boot inside 64bit virtualbox with io-apic disabled
[safe/jmp/linux-2.6] / drivers / video / modedb.c
index 42f5d76..b895aae 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/module.h>
 #include <linux/fb.h>
+#include <linux/kernel.h>
 
 #undef DEBUG
 
     ((v).xres == (x) && (v).yres == (y))
 
 #ifdef DEBUG
-#define DPRINTK(fmt, args...)  printk("modedb %s: " fmt, __FUNCTION__ , ## args)
+#define DPRINTK(fmt, args...)  printk("modedb %s: " fmt, __func__ , ## args)
 #else
 #define DPRINTK(fmt, args...)
 #endif
 
 const char *fb_mode_option;
+EXPORT_SYMBOL_GPL(fb_mode_option);
 
     /*
      *  Standard video mode definitions (taken from XFree86)
@@ -259,6 +261,18 @@ static const struct fb_videomode modedb[] = {
        /* 1366x768, 60 Hz, 47.403 kHz hsync, WXGA 16:9 aspect ratio */
        NULL, 60, 1366, 768, 13806, 120, 10, 14, 3, 32, 5,
        0, FB_VMODE_NONINTERLACED
+   }, {
+       /* 1280x800, 60 Hz, 47.403 kHz hsync, WXGA 16:10 aspect ratio */
+       NULL, 60, 1280, 800, 12048, 200, 64, 24, 1, 136, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 720x576i @ 50 Hz, 15.625 kHz hsync (PAL RGB) */
+       NULL, 50, 720, 576, 74074, 64, 16, 39, 5, 64, 5,
+       0, FB_VMODE_INTERLACED
+    }, {
+       /* 800x520i @ 50 Hz, 15.625 kHz hsync (PAL RGB) */
+       NULL, 50, 800, 520, 58823, 144, 64, 72, 28, 80, 5,
+       0, FB_VMODE_INTERLACED
     },
 };
 
@@ -324,7 +338,7 @@ const struct fb_videomode vesa_modes[] = {
          FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
          FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
        /* 17 1152x864-75 VESA */
-       { NULL, 75, 1153, 864, 9259, 256, 64, 32, 1, 128, 3,
+       { NULL, 75, 1152, 864, 9259, 256, 64, 32, 1, 128, 3,
          FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
          FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
        /* 18 1280x960-60 VESA */
@@ -389,21 +403,6 @@ const struct fb_videomode vesa_modes[] = {
 EXPORT_SYMBOL(vesa_modes);
 #endif /* CONFIG_FB_MODE_HELPERS */
 
-static int my_atoi(const char *name)
-{
-    int val = 0;
-
-    for (;; name++) {
-       switch (*name) {
-           case '0' ... '9':
-               val = 10*val+(*name-'0');
-               break;
-           default:
-               return val;
-       }
-    }
-}
-
 /**
  *     fb_try_mode - test a video mode
  *     @var: frame buffer user defined part of display
@@ -510,13 +509,15 @@ int fb_find_mode(struct fb_var_screeninfo *var,
        default_bpp = 8;
 
     /* Did the user specify a video mode? */
-    if (mode_option || (mode_option = fb_mode_option)) {
+    if (!mode_option)
+       mode_option = fb_mode_option;
+    if (mode_option) {
        const char *name = mode_option;
        unsigned int namelen = strlen(name);
        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]) {
@@ -524,7 +525,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
                    namelen = i;
                    if (!refresh_specified && !bpp_specified &&
                        !yres_specified) {
-                       refresh = my_atoi(&name[i+1]);
+                       refresh = simple_strtol(&name[i+1], NULL, 10);
                        refresh_specified = 1;
                        if (cvt || rb)
                            cvt = 0;
@@ -534,7 +535,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
                case '-':
                    namelen = i;
                    if (!bpp_specified && !yres_specified) {
-                       bpp = my_atoi(&name[i+1]);
+                       bpp = simple_strtol(&name[i+1], NULL, 10);
                        bpp_specified = 1;
                        if (cvt || rb)
                            cvt = 0;
@@ -543,7 +544,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
                    break;
                case 'x':
                    if (!yres_specified) {
-                       yres = my_atoi(&name[i+1]);
+                       yres = simple_strtol(&name[i+1], NULL, 10);
                        yres_specified = 1;
                    } else
                        goto done;
@@ -571,7 +572,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
            }
        }
        if (i < 0 && yres_specified) {
-           xres = my_atoi(name);
+           xres = simple_strtol(name, NULL, 10);
            res_specified = 1;
        }
 done:
@@ -584,6 +585,7 @@ done:
                    "", (margins) ? " with margins" : "", (interlace) ?
                    " interlaced" : "");
 
+           memset(&cvt_mode, 0, sizeof(cvt_mode));
            cvt_mode.xres = xres;
            cvt_mode.yres = yres;
            cvt_mode.refresh = (refresh) ? refresh : 60;
@@ -645,19 +647,27 @@ done:
                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);
@@ -883,7 +893,7 @@ const struct fb_videomode *fb_match_mode(const struct fb_var_screeninfo *var,
 }
 
 /**
- * fb_add_videomode: adds videomode entry to modelist
+ * fb_add_videomode - adds videomode entry to modelist
  * @mode: videomode to add
  * @head: struct list_head of modelist
  *
@@ -918,7 +928,7 @@ int fb_add_videomode(const struct fb_videomode *mode, struct list_head *head)
 }
 
 /**
- * fb_delete_videomode: removed videomode entry from modelist
+ * fb_delete_videomode - removed videomode entry from modelist
  * @mode: videomode to remove
  * @head: struct list_head of modelist
  *
@@ -943,7 +953,7 @@ void fb_delete_videomode(const struct fb_videomode *mode,
 }
 
 /**
- * fb_destroy_modelist: destroy modelist
+ * fb_destroy_modelist - destroy modelist
  * @head: struct list_head of modelist
  */
 void fb_destroy_modelist(struct list_head *head)
@@ -958,7 +968,7 @@ void fb_destroy_modelist(struct list_head *head)
 EXPORT_SYMBOL_GPL(fb_destroy_modelist);
 
 /**
- * fb_videomode_to_modelist: convert mode array to mode list
+ * fb_videomode_to_modelist - convert mode array to mode list
  * @modedb: array of struct fb_videomode
  * @num: number of entries in array
  * @head: struct list_head of modelist