gma edid: Check expected display type
Check that the EDID's digital-input bit matches the expected display
type (i.e. it should only be set for non-VGA displays).
Change-Id: I099112f190f866525e882d5e24a428092d4d8331
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/17085
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/common/hw-gfx-edid.adb b/common/hw-gfx-edid.adb
index 64b86a9..44d729f 100644
--- a/common/hw-gfx-edid.adb
+++ b/common/hw-gfx-edid.adb
@@ -68,6 +68,15 @@
----------------------------------------------------------------------------
+ function Compatible_Display
+ (Raw_EDID : Raw_EDID_Data;
+ Display : Display_Type)
+ return Boolean
+ is
+ begin
+ return (Display = VGA) = ((Raw_EDID (INPUT) and INPUT_DIGITAL) = 16#00#);
+ end Compatible_Display;
+
function Read_LE16
(Raw_EDID : Raw_EDID_Data;
Offset : Raw_EDID_Index)
diff --git a/common/hw-gfx-edid.ads b/common/hw-gfx-edid.ads
index efc3b36..cce1a40 100644
--- a/common/hw-gfx-edid.ads
+++ b/common/hw-gfx-edid.ads
@@ -32,6 +32,13 @@
with
Pre => Offset < Raw_EDID_Index'Last;
+ function Compatible_Display
+ (Raw_EDID : Raw_EDID_Data;
+ Display : Display_Type)
+ return Boolean
+ with
+ Pre => Valid (Raw_EDID);
+
function Has_Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Boolean
with
Pre => Valid (Raw_EDID),
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 416117b..cd202be 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -327,7 +327,10 @@
Connector_Info.Read_EDID (Raw_EDID, Port_Cfg, Success);
end if;
- if Success and then EDID.Has_Preferred_Mode (Raw_EDID) then
+ if Success and then
+ (EDID.Compatible_Display (Raw_EDID, Port_Cfg.Display) and
+ EDID.Has_Preferred_Mode (Raw_EDID))
+ then
Configs (Config_Idx).Mode := EDID.Preferred_Mode (Raw_EDID);
else
Configs (Config_Idx).Port := Disabled;
@@ -428,7 +431,10 @@
Success => Success);
end if;
- if Success and then EDID.Has_Preferred_Mode (Raw_EDID) then
+ if Success and then
+ (EDID.Compatible_Display (Raw_EDID, Port_Cfg.Display) and
+ EDID.Has_Preferred_Mode (Raw_EDID))
+ then
Configs (Config_Idx) := Config_Type'
(Port => Port,
Framebuffer => Configs (Config_Idx).Framebuffer,
diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads
index 3adf1f9..1e64cb4 100644
--- a/common/hw-gfx-gma.ads
+++ b/common/hw-gfx-gma.ads
@@ -109,10 +109,6 @@
subtype PCH_HDMI_Port is PCH_Port range PCH_HDMI_B .. PCH_HDMI_D;
subtype PCH_DP_Port is PCH_Port range PCH_DP_B .. PCH_DP_D;
- type Display_Type is (None, LVDS, DP, HDMI, VGA);
-
- subtype Internal_Type is Display_Type range None .. DP;
-
type Port_Config is
record
Port : GPU_Port;
diff --git a/common/hw-gfx.ads b/common/hw-gfx.ads
index b9d7225..051b326 100644
--- a/common/hw-gfx.ads
+++ b/common/hw-gfx.ads
@@ -94,6 +94,9 @@
Enhanced_Framing => False,
Opportunistic_Training => False);
+ type Display_Type is (None, LVDS, DP, HDMI, VGA);
+ subtype Internal_Type is Display_Type range None .. DP;
+
type Mode_Type is
record
Dotclock : Frequency_Type;