[PATCH] fbdev: Resurrect hooks to get EDID from firmware
[linux-3.10.git] / drivers / video / fbmon.c
index 978def0135879836f8cd711356c7ac6b1b3f6f1f..791bec3d672af47d999e798baf87760cc4b17188 100644 (file)
 #include <linux/tty.h>
 #include <linux/fb.h>
 #include <linux/module.h>
+#include <video/edid.h>
 #ifdef CONFIG_PPC_OF
 #include <linux/pci.h>
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
 #endif
-#include <video/edid.h>
 #include "edid.h"
 
 /* 
@@ -1242,6 +1242,8 @@ int fb_validate_mode(const struct fb_var_screeninfo *var, struct fb_info *info)
                vtotal *= 2;
 
        hfreq = pixclock/htotal;
+       hfreq = (hfreq + 500) / 1000 * 1000;
+
        vfreq = hfreq/vtotal;
 
        return (vfreq < vfmin || vfreq > vfmax || 
@@ -1250,9 +1252,41 @@ int fb_validate_mode(const struct fb_var_screeninfo *var, struct fb_info *info)
                -EINVAL : 0;
 }
 
+#if defined(__i386__)
+#include <linux/pci.h>
+
+/*
+ * We need to ensure that the EDID block is only returned for
+ * the primary graphics adapter.
+ */
+
+const unsigned char *fb_firmware_edid(struct device *device)
+{
+       struct pci_dev *dev = NULL;
+       struct resource *res = NULL;
+       unsigned char *edid = NULL;
+
+       if (device)
+               dev = to_pci_dev(device);
+
+       if (dev)
+               res = &dev->resource[PCI_ROM_RESOURCE];
+
+       if (res && res->flags & IORESOURCE_ROM_SHADOW)
+               edid = edid_info.dummy;
+
+       return edid;
+}
+#else
+const unsigned char *fb_firmware_edid(struct device *device)
+{
+       return NULL;
+}
+#endif /* _i386_ */
+
 EXPORT_SYMBOL(fb_parse_edid);
 EXPORT_SYMBOL(fb_edid_to_monspecs);
-
+EXPORT_SYMBOL(fb_firmware_edid);
 EXPORT_SYMBOL(fb_get_mode);
 EXPORT_SYMBOL(fb_validate_mode);
 EXPORT_SYMBOL(fb_destroy_modedb);