Merge Linus' tree.
[safe/jmp/linux-2.6] / drivers / video / fbmon.c
index 791bec3..fc7965b 100644 (file)
@@ -314,11 +314,13 @@ static int edid_is_monitor_block(unsigned char *block)
                return 0;
 }
 
-static void calc_mode_timings(int xres, int yres, int refresh, struct fb_videomode *mode)
+static void calc_mode_timings(int xres, int yres, int refresh,
+                             struct fb_videomode *mode)
 {
        struct fb_var_screeninfo var;
        struct fb_info info;
        
+       memset(&var, 0, sizeof(struct fb_var_screeninfo));
        var.xres = xres;
        var.yres = yres;
        fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 
@@ -536,25 +538,12 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize)
 
        *dbsize = 0;
 
-       DPRINTK("   Supported VESA Modes\n");
-       block = edid + ESTABLISHED_TIMING_1;
-       num += get_est_timing(block, &mode[num]);
-
-       DPRINTK("   Standard Timings\n");
-       block = edid + STD_TIMING_DESCRIPTIONS_START;
-       for (i = 0; i < STD_TIMING; i++, block += STD_TIMING_DESCRIPTION_SIZE) 
-               num += get_std_timing(block, &mode[num]);
-
        DPRINTK("   Detailed Timings\n");
        block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
        for (i = 0; i < 4; i++, block+= DETAILED_TIMING_DESCRIPTION_SIZE) {
                int first = 1;
 
-               if (block[0] == 0x00 && block[1] == 0x00) {
-                       if (block[3] == 0xfa) {
-                               num += get_dst_timing(block + 5, &mode[num]);
-                       }
-               } else  {
+               if (!(block[0] == 0x00 && block[1] == 0x00)) {
                        get_detailed_timing(block, &mode[num]);
                        if (first) {
                                mode[num].flag |= FB_MODE_IS_FIRST;
@@ -563,6 +552,21 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize)
                        num++;
                }
        }
+
+       DPRINTK("   Supported VESA Modes\n");
+       block = edid + ESTABLISHED_TIMING_1;
+       num += get_est_timing(block, &mode[num]);
+
+       DPRINTK("   Standard Timings\n");
+       block = edid + STD_TIMING_DESCRIPTIONS_START;
+       for (i = 0; i < STD_TIMING; i++, block += STD_TIMING_DESCRIPTION_SIZE)
+               num += get_std_timing(block, &mode[num]);
+
+       block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
+       for (i = 0; i < 4; i++, block+= DETAILED_TIMING_DESCRIPTION_SIZE) {
+               if (block[0] == 0x00 && block[1] == 0x00 && block[3] == 0xfa)
+                       num += get_dst_timing(block + 5, &mode[num]);
+       }
        
        /* Yikes, EDID data is totally useless */
        if (!num) {
@@ -825,7 +829,7 @@ int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var)
 void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
 {
        unsigned char *block;
-       int i;
+       int i, found = 0;
 
        if (edid == NULL)
                return;
@@ -867,6 +871,22 @@ void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
        get_monspecs(edid, specs);
 
        specs->modedb = fb_create_modedb(edid, &specs->modedb_len);
+
+       /*
+        * Workaround for buggy EDIDs that sets that the first
+        * detailed timing is preferred but has not detailed
+        * timing specified
+        */
+       for (i = 0; i < specs->modedb_len; i++) {
+               if (specs->modedb[i].flag & FB_MODE_IS_DETAILED) {
+                       found = 1;
+                       break;
+               }
+       }
+
+       if (!found)
+               specs->misc &= ~FB_MISC_1ST_DETAIL;
+
        DPRINTK("========================================\n");
 }