edid: Sanitize bad EDID header patterns

Some devices fail to transmit the EDID header pattern correctly. To
compensate, we patch EDID header patterns when at least six out of
the eight bytes match. We then verify the checksum over all bytes
including the patched header.

Linux does it similar and gets more displays up that way, sigh.

Change-Id: Ic63880a05e64f40dfda165bd54e708cd981f08fb
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/17493
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/common/hw-gfx-edid.ads b/common/hw-gfx-edid.ads
index cce1a40..abbb2ee 100644
--- a/common/hw-gfx-edid.ads
+++ b/common/hw-gfx-edid.ads
@@ -22,6 +22,9 @@
    subtype Raw_EDID_Data is Buffer (Raw_EDID_Index);
 
    function Valid (Raw_EDID : Raw_EDID_Data) return Boolean;
+   procedure Sanitize (Raw_EDID : in out Raw_EDID_Data; Success : out Boolean)
+   with
+      Post => (if Success then Valid (Raw_EDID));
 
    DESCRIPTOR_1 : constant := 54;