gma: Get rid of Port_Config in Read_EDID()
We usually don't have the full Port_Config available when we want to
read the EDID. Also move this procedure one level up into GMA.
Change-Id: Ibdce83c6024d796c645dae6786c67206b5343402
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/17752
Reviewed-by: Reto Buerki <reet@codelabs.ch>
diff --git a/common/hw-gfx-gma-connector_info.adb b/common/hw-gfx-gma-connector_info.adb
index 89e0425..eae083f 100644
--- a/common/hw-gfx-gma-connector_info.adb
+++ b/common/hw-gfx-gma-connector_info.adb
@@ -12,22 +12,20 @@
-- GNU General Public License for more details.
--
-with HW.GFX.I2C;
with HW.GFX.GMA.Config;
with HW.GFX.GMA.Panel;
-with HW.GFX.GMA.I2C;
with HW.GFX.GMA.DP_Info;
-with HW.GFX.GMA.DP_Aux_Ch;
with HW.Debug;
with GNAT.Source_Info;
package body HW.GFX.GMA.Connector_Info is
- function To_DP (Port_Cfg : Port_Config) return DP_Port
+ procedure Preferred_Link_Setting
+ (Port_Cfg : in out Port_Config;
+ Success : out Boolean)
is
- begin
- return
+ DP_Port : constant GMA.DP_Port :=
(if Port_Cfg.Port = DIGI_A then
DP_A
else
@@ -35,51 +33,7 @@
when PCH_DP_B => DP_B,
when PCH_DP_C => DP_C,
when PCH_DP_D => DP_D,
- when others => DP_Port'First));
- end To_DP;
-
- ----------------------------------------------------------------------------
-
- procedure Read_EDID
- (Raw_EDID : out EDID.Raw_EDID_Data;
- Port_Cfg : in Port_Config;
- Success : out Boolean)
- is
- Raw_EDID_Length : GFX.I2C.Transfer_Length := Raw_EDID'Length;
- begin
- pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
-
- for I in 1 .. 2 loop
- if Port_Cfg.Display = DP then
- DP_Aux_Ch.I2C_Read
- (Port => To_DP (Port_Cfg),
- Address => 16#50#,
- Length => Raw_EDID_Length,
- Data => Raw_EDID,
- Success => Success);
- else
- I2C.I2C_Read
- (Port => (if Port_Cfg.Display = VGA
- then Config.Analog_I2C_Port
- else Port_Cfg.PCH_Port),
- Address => 16#50#,
- Length => Raw_EDID_Length,
- Data => Raw_EDID,
- Success => Success);
- end if;
- exit when not Success; -- don't retry if reading itself failed
-
- pragma Debug (Debug.Put_Buffer ("EDID", Raw_EDID, Raw_EDID_Length));
- EDID.Sanitize (Raw_EDID, Success);
- exit when Success;
- end loop;
- end Read_EDID;
-
- ----------------------------------------------------------------------------
-
- procedure Preferred_Link_Setting
- (Port_Cfg : in out Port_Config;
- Success : out Boolean) is
+ when others => GMA.DP_Port'First));
begin
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
@@ -94,7 +48,7 @@
DP_Info.Read_Caps
(Link => Port_Cfg.DP,
- Port => To_DP (Port_Cfg),
+ Port => DP_Port,
Success => Success);
if Success then
DP_Info.Preferred_Link_Setting
diff --git a/common/hw-gfx-gma-connector_info.ads b/common/hw-gfx-gma-connector_info.ads
index 171b558..42dbe6e 100644
--- a/common/hw-gfx-gma-connector_info.ads
+++ b/common/hw-gfx-gma-connector_info.ads
@@ -16,13 +16,6 @@
private package HW.GFX.GMA.Connector_Info is
- procedure Read_EDID
- (Raw_EDID : out EDID.Raw_EDID_Data;
- Port_Cfg : in Port_Config;
- Success : out Boolean)
- with
- Post => (if Success then EDID.Valid (Raw_EDID));
-
procedure Preferred_Link_Setting
(Port_Cfg : in out Port_Config;
Success : out Boolean)
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index fbb5d98..e72bbed 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -12,8 +12,11 @@
-- GNU General Public License for more details.
--
+with HW.GFX.I2C;
with HW.GFX.EDID;
with HW.GFX.GMA.Config;
+with HW.GFX.GMA.I2C;
+with HW.GFX.GMA.DP_Aux_Ch;
with HW.GFX.GMA.DP_Info;
with HW.GFX.GMA.Registers;
with HW.GFX.GMA.Power_And_Clocks;
@@ -117,6 +120,7 @@
end To_GPU_Port;
function To_PCH_Port (Port : Active_Port_Type) return PCH_Port
+ with Pre => True
is
begin
return
@@ -342,6 +346,53 @@
Configs (Tertiary).Port = Port;
end Port_Configured;
+ procedure Read_EDID
+ (Raw_EDID : out EDID.Raw_EDID_Data;
+ Port : in Active_Port_Type;
+ Success : out Boolean)
+ with
+ Post => (if Success then EDID.Valid (Raw_EDID))
+ is
+ Raw_EDID_Length : GFX.I2C.Transfer_Length := Raw_EDID'Length;
+ begin
+ pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
+
+ for I in 1 .. 2 loop
+ if To_Display_Type (Port) = DP then
+ declare
+ DP_Port : constant GMA.DP_Port :=
+ (case Port is
+ when Internal => DP_A,
+ when DP1 => DP_B,
+ when DP2 => DP_C,
+ when DP3 => DP_D,
+ when others => GMA.DP_Port'First);
+ begin
+ DP_Aux_Ch.I2C_Read
+ (Port => DP_Port,
+ Address => 16#50#,
+ Length => Raw_EDID_Length,
+ Data => Raw_EDID,
+ Success => Success);
+ end;
+ else
+ I2C.I2C_Read
+ (Port => (if Port = Analog
+ then Config.Analog_I2C_Port
+ else To_PCH_Port (Port)),
+ Address => 16#50#,
+ Length => Raw_EDID_Length,
+ Data => Raw_EDID,
+ Success => Success);
+ end if;
+ exit when not Success; -- don't retry if reading itself failed
+
+ pragma Debug (Debug.Put_Buffer ("EDID", Raw_EDID, Raw_EDID_Length));
+ EDID.Sanitize (Raw_EDID, Success);
+ exit when Success;
+ end loop;
+ end Read_EDID;
+
procedure Scan_Ports
(Configs : out Pipe_Configs;
Ports : in Port_List;
@@ -372,7 +423,7 @@
Panel.On;
end if;
- Connector_Info.Read_EDID (Raw_EDID, Port_Cfg, Success);
+ Read_EDID (Raw_EDID, Ports (Port_Idx), Success);
end if;
if Success and then