Nico Huber has uploaded this change for review.

View Change

[WIP] gma panel: Introduce `Panel_Control` type

Change-Id: I83864bc86b48f65d9ba43e083b805ca09497cbb0
Signed-off-by: Nico Huber <nico.huber@secunet.com>
---
M common/g45/hw-gfx-gma-connectors.adb
M common/haswell_shared/hw-gfx-gma-connectors.adb
M common/hw-gfx-gma-config.ads.template
M common/hw-gfx-gma-config_helpers.adb
M common/hw-gfx-gma-config_helpers.ads
M common/hw-gfx-gma-connector_info.adb
M common/hw-gfx-gma-display_probing.adb
M common/hw-gfx-gma-panel.adb
M common/hw-gfx-gma-panel.ads
M common/hw-gfx-gma.adb
M common/hw-gfx-gma.ads
M common/ironlake/hw-gfx-gma-connectors.adb
12 files changed, 120 insertions(+), 77 deletions(-)

git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/43/38243/1
diff --git a/common/g45/hw-gfx-gma-connectors.adb b/common/g45/hw-gfx-gma-connectors.adb
index 5ca7c9b..7486fcc 100644
--- a/common/g45/hw-gfx-gma-connectors.adb
+++ b/common/g45/hw-gfx-gma-connectors.adb
@@ -29,12 +29,6 @@
procedure Post_Reset_Off is null;
procedure Initialize is null;

- function Is_Internal (Port_Cfg : Port_Config) return Boolean
- is
- begin
- return Port_Cfg.Port = LVDS;
- end Is_Internal;
-
----------------------------------------------------------------------------

procedure Pre_On
@@ -69,10 +63,8 @@
end if;
end if;

- if Is_Internal (Port_Cfg) then
- Panel.On (Wait => False);
- Panel.Backlight_On;
- end if;
+ Panel.On (Port_Cfg.Panel, Wait => False);
+ Panel.Backlight_On (Port_Cfg.Panel);
end Post_On;

----------------------------------------------------------------------------
@@ -82,10 +74,8 @@
begin
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

- if Is_Internal (Port_Cfg) then
- Panel.Backlight_Off;
- Panel.Off;
- end if;
+ Panel.Backlight_Off (Port_Cfg.Panel);
+ Panel.Off (Port_Cfg.Panel);
end Pre_Off;

procedure Post_Off (Port_Cfg : Port_Config)
@@ -110,8 +100,10 @@
begin
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

- Panel.Backlight_Off;
- Panel.Off;
+ for P in Active_Panel loop
+ Panel.Backlight_Off (P);
+ Panel.Off (P);
+ end loop;
end Pre_All_Off;

procedure Post_All_Off
diff --git a/common/haswell_shared/hw-gfx-gma-connectors.adb b/common/haswell_shared/hw-gfx-gma-connectors.adb
index e4980f1..c1b04ed 100644
--- a/common/haswell_shared/hw-gfx-gma-connectors.adb
+++ b/common/haswell_shared/hw-gfx-gma-connectors.adb
@@ -60,9 +60,7 @@
if Port_Cfg.Port in Digital_Port then
DDI.Post_On (Port_Cfg);

- if Port_Cfg.Port = DIGI_A then
- Panel.Backlight_On;
- end if;
+ Panel.Backlight_On (Port_Cfg.Panel);
Success := True;
else
Success := False; -- Should not happen
@@ -76,10 +74,8 @@
begin
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

- if Port_Cfg.Port = DIGI_A then
- Panel.Backlight_Off;
- Panel.Off;
- end if;
+ Panel.Backlight_Off (Port_Cfg.Panel);
+ Panel.Off (Port_Cfg.Panel);
end Pre_Off;

procedure Post_Off (Port_Cfg : Port_Config)
@@ -96,8 +92,10 @@
procedure Pre_All_Off
is
begin
- Panel.Backlight_Off;
- Panel.Off;
+ for P in Active_Panel loop
+ Panel.Backlight_Off (P);
+ Panel.Off (P);
+ end loop;
end Pre_All_Off;

procedure Post_All_Off
diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index 2467440..c6a5d44 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -43,7 +43,8 @@

CPU_Var : constant Gen_CPU_Variant := <<CPU_VARIANT>>;

- Panel_1_Port : constant Port_Type := <<PANEL_1_PORT>>;
+ Panel_Ports : constant array (Active_Panel) of Port_Type :=
+ (Panel_1 => <<PANEL_1_PORT>>);

Analog_I2C_Port : constant PCH_Port := <<ANALOG_I2C_PORT>>;

diff --git a/common/hw-gfx-gma-config_helpers.adb b/common/hw-gfx-gma-config_helpers.adb
index 07fa087..74279dc 100644
--- a/common/hw-gfx-gma-config_helpers.adb
+++ b/common/hw-gfx-gma-config_helpers.adb
@@ -12,7 +12,6 @@
-- GNU General Public License for more details.
--

-with HW.GFX.GMA.Config;
with HW.GFX.GMA.Connector_Info;
with HW.GFX.GMA.DP_Info;
with HW.GFX.GMA.Registers;
@@ -84,6 +83,17 @@
when DP1 .. DP3 => DP);
end To_Display_Type;

+ function To_Panel (Port : Active_Port_Type) return Panel_Control
+ is
+ begin
+ for P in Active_Panel loop
+ if Port = Config.Panel_Ports (P) then
+ return P;
+ end if;
+ end loop;
+ return No_Panel;
+ end To_Panel;
+
function Highest_Dotclock (Configs : Pipe_Configs) return Frequency_Type
is
Max : Frequency_Type := Frequency_Type'First;
@@ -171,6 +181,7 @@
(Port => To_GPU_Port (Pipe, Port),
PCH_Port => To_PCH_Port (Port),
Display => To_Display_Type (Port),
+ Panel => To_Panel (Port),
Mode => Mode,
Is_FDI => Config.Is_FDI_Port (Port),
FDI => Default_DP,
@@ -206,6 +217,7 @@
(Port => GPU_Port'First,
PCH_Port => PCH_Port'First,
Display => Display_Type'First,
+ Panel => No_Panel,
Mode => Invalid_Mode,
Is_FDI => False,
FDI => Default_DP,
diff --git a/common/hw-gfx-gma-config_helpers.ads b/common/hw-gfx-gma-config_helpers.ads
index 9d689c7..b9f1d70 100644
--- a/common/hw-gfx-gma-config_helpers.ads
+++ b/common/hw-gfx-gma-config_helpers.ads
@@ -13,6 +13,7 @@
--

with HW;
+with HW.GFX.GMA.Config;

private package HW.GFX.GMA.Config_Helpers
is
@@ -26,6 +27,8 @@

function To_Display_Type (Port : Active_Port_Type) return Display_Type;

+ function To_Panel (Port : Active_Port_Type) return Panel_Control;
+
procedure Fill_Port_Config
(Port_Cfg : out Port_Config;
Pipe : in Pipe_Index;
diff --git a/common/hw-gfx-gma-connector_info.adb b/common/hw-gfx-gma-connector_info.adb
index 3ce807e..dcbed2e 100644
--- a/common/hw-gfx-gma-connector_info.adb
+++ b/common/hw-gfx-gma-connector_info.adb
@@ -38,12 +38,10 @@
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

if Port_Cfg.Display = DP then
- if Port_Cfg.Port = DIGI_A then
- if GMA.Config.Use_PP_VDD_Override then
- Panel.VDD_Override;
- else
- Panel.On;
- end if;
+ if GMA.Config.Use_PP_VDD_Override then
+ Panel.VDD_Override (Port_Cfg.Panel);
+ else
+ Panel.On (Port_Cfg.Panel);
end if;

DP_Info.Read_Caps
diff --git a/common/hw-gfx-gma-display_probing.adb b/common/hw-gfx-gma-display_probing.adb
index df88492..5aed2e6 100644
--- a/common/hw-gfx-gma-display_probing.adb
+++ b/common/hw-gfx-gma-display_probing.adb
@@ -118,10 +118,7 @@
Success := Config.Valid_Port (Port);

if Success then
- if Port in Internal_Port_Type then
- Panel.Wait_On;
- end if;
- Read_EDID (Raw_EDID, Port, Success);
+ Panel.Wait_On (Config_Helpers.To_Panel (Port));
end if;

if Success and then
@@ -162,7 +159,7 @@
Max_Pipe : in Pipe_Index := Pipe_Index'Last;
Keep_Power : in Boolean := False)
is
- Probe_Internal : Boolean := False;
+ Probed_Panels : array (Active_Panel) of Boolean := (others => False);

Port_Idx : Port_List_Range := Port_List_Range'First;
Success : Boolean;
@@ -176,11 +173,14 @@
-- Turn panel on early to probe other ports during the power on delay.
for Idx in Port_List_Range loop
exit when Ports (Idx) = Disabled;
- if Ports (Idx) in Internal_Port_Type then
- Panel.On (Wait => False);
- Probe_Internal := True;
- exit;
- end if;
+ declare
+ P : constant Panel_Control := Config_Helpers.To_Panel (Ports (Idx));
+ begin
+ if P /= No_Panel then
+ Panel.On (P, Wait => False);
+ Probed_Panels (P) := True;
+ end if;
+ end;
end loop;

for Pipe in Pipe_Index range
@@ -211,11 +211,13 @@
end if;

-- Turn panel power off if probing failed.
- if Probe_Internal and not
- (Port_Configured (Configs, eDP) or Port_Configured (Configs, LVDS))
- then
- Panel.Off;
- end if;
+ for P in Active_Panel loop
+ if Probed_Panels (P) and not
+ Port_Configured (Configs, Config.Panel_Ports (P))
+ then
+ Panel.Off (P);
+ end if;
+ end loop;
end Scan_Ports;

procedure Hotplug_Events (Ports : out Port_List)
diff --git a/common/hw-gfx-gma-panel.adb b/common/hw-gfx-gma-panel.adb
index b40689b..398c4d7 100644
--- a/common/hw-gfx-gma-panel.adb
+++ b/common/hw-gfx-gma-panel.adb
@@ -218,7 +218,7 @@
if Override_Delays then
if Config.Has_PP_Port_Select then
Port_Select :=
- (case Config.Panel_1_Port is
+ (case Config.Panel_Ports (Panel_1) is
when LVDS => PCH_PP_ON_DELAYS_PORT_SELECT_LVDS,
when eDP => PCH_PP_ON_DELAYS_PORT_SELECT_DP_A,
when DP2 | HDMI2 => PCH_PP_ON_DELAYS_PORT_SELECT_DP_C,
@@ -269,21 +269,29 @@

----------------------------------------------------------------------------

- procedure VDD_Override is
+ procedure VDD_Override (Panel : Panel_Control) is
begin
+ if Panel = No_Panel then
+ return;
+ end if;
+
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

-- Yeah, We could do, what we are supposed to do here. But OTOH, we
-- are should wait for the full Power Up Delay, which we would have
-- to do later again. And just powering on the display seems to work
-- too. Also this function vanished on newer hardware.
- On;
+ On (Panel);
end VDD_Override;

- procedure On (Wait : Boolean := True)
+ procedure On (Panel : Panel_Control; Wait : Boolean := True)
is
Was_On : Boolean;
begin
+ if Panel = No_Panel then
+ return;
+ end if;
+
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

Registers.Is_Set_Mask (Panel_PP_Regs.CONTROL, PCH_PP_CONTROL_TARGET_ON, Was_On);
@@ -296,12 +304,16 @@
Power_Up_Timer := Time.US_From_Now (Delays_US (Power_Up_Delay));
end if;
if Wait then
- Wait_On;
+ Wait_On (Panel);
end if;
end On;

- procedure Wait_On is
+ procedure Wait_On (Panel : Panel_Control) is
begin
+ if Panel = No_Panel then
+ return;
+ end if;
+
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

Time.Delay_Until (Power_Up_Timer);
@@ -313,10 +325,14 @@
Registers.Unset_Mask (Panel_PP_Regs.CONTROL, PCH_PP_CONTROL_VDD_OVERRIDE);
end Wait_On;

- procedure Off
+ procedure Off (Panel : Panel_Control)
is
Was_On : Boolean;
begin
+ if Panel = No_Panel then
+ return;
+ end if;
+
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

Registers.Is_Set_Mask (Panel_PP_Regs.CONTROL, PCH_PP_CONTROL_TARGET_ON, Was_On);
@@ -338,8 +354,12 @@

----------------------------------------------------------------------------

- procedure Backlight_On is
+ procedure Backlight_On (Panel : Panel_Control) is
begin
+ if Panel = No_Panel then
+ return;
+ end if;
+
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

Registers.Set_Mask
@@ -347,8 +367,12 @@
Mask => PCH_PP_CONTROL_BACKLIGHT_ENABLE);
end Backlight_On;

- procedure Backlight_Off is
+ procedure Backlight_Off (Panel : Panel_Control) is
begin
+ if Panel = No_Panel then
+ return;
+ end if;
+
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

Registers.Unset_Mask
@@ -356,8 +380,12 @@
Mask => PCH_PP_CONTROL_BACKLIGHT_ENABLE);
end Backlight_Off;

- procedure Set_Backlight (Level : Word16) is
+ procedure Set_Backlight (Panel : Panel_Control; Level : Word16) is
begin
+ if Panel = No_Panel then
+ return;
+ end if;
+
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

Registers.Unset_And_Set_Mask
@@ -366,10 +394,15 @@
Mask_Set => Word32 (Level));
end Set_Backlight;

- procedure Get_Max_Backlight (Level : out Word16)
+ procedure Get_Max_Backlight (Panel : Panel_Control; Level : out Word16)
is
Reg : Word32;
begin
+ if Panel = No_Panel then
+ Level := 0;
+ return;
+ end if;
+
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

Registers.Read (Registers.BLC_PWM_PCH_CTL2, Reg);
diff --git a/common/hw-gfx-gma-panel.ads b/common/hw-gfx-gma-panel.ads
index b968e29..baf47f7 100644
--- a/common/hw-gfx-gma-panel.ads
+++ b/common/hw-gfx-gma-panel.ads
@@ -40,22 +40,22 @@

----------------------------------------------------------------------------

- procedure VDD_Override;
+ procedure VDD_Override (Panel : Panel_Control);

- procedure On (Wait : Boolean := True);
+ procedure On (Panel : Panel_Control; Wait : Boolean := True);

- procedure Wait_On;
+ procedure Wait_On (Panel : Panel_Control);

- procedure Off;
+ procedure Off (Panel : Panel_Control);

----------------------------------------------------------------------------

- procedure Backlight_On;
+ procedure Backlight_On (Panel : Panel_Control);

- procedure Backlight_Off;
+ procedure Backlight_Off (Panel : Panel_Control);

- procedure Set_Backlight (Level : Word16);
+ procedure Set_Backlight (Panel : Panel_Control; Level : Word16);

- procedure Get_Max_Backlight (Level : out Word16);
+ procedure Get_Max_Backlight (Panel : Panel_Control; Level : out Word16);

end HW.GFX.GMA.Panel;
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index d0f296e..04caa61 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -179,9 +179,7 @@
("Enabled port " & Port_Names (Pipe_Cfg.Port)));
else
Wait_For_HPD (Pipe_Cfg.Port) := True;
- if Pipe_Cfg.Port in Internal_Port_Type then
- Panel.Off;
- end if;
+ Panel.Off (Config_Helpers.To_Panel (Pipe_Cfg.Port));
end if;
end Enable_Output;

diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads
index fcd8804..d5ab68a 100644
--- a/common/hw-gfx-gma.ads
+++ b/common/hw-gfx-gma.ads
@@ -253,11 +253,15 @@
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 Panel_Control is (No_Panel, Panel_1);
+ subtype Active_Panel is Panel_Control range Panel_1 .. Panel_1;
+
type Port_Config is
record
Port : GPU_Port;
PCH_Port : GMA.PCH_Port;
Display : Display_Type;
+ Panel : Panel_Control;
Mode : Mode_Type;
Is_FDI : Boolean;
FDI : DP_Link;
diff --git a/common/ironlake/hw-gfx-gma-connectors.adb b/common/ironlake/hw-gfx-gma-connectors.adb
index 21eca97..fd774ff 100644
--- a/common/ironlake/hw-gfx-gma-connectors.adb
+++ b/common/ironlake/hw-gfx-gma-connectors.adb
@@ -70,7 +70,7 @@

if Port_Cfg.Port = DIGI_A then
EDP.Pre_Training;
- Panel.On (Wait => True);
+ Panel.On (Port_Cfg.Panel, Wait => True);
EDP.Post_On (Port_Cfg.DP, Success);
elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
declare
@@ -97,8 +97,8 @@
end if;

if Success and Is_Internal (Port_Cfg) then
- Panel.On (Wait => False);
- Panel.Backlight_On;
+ Panel.On (Port_Cfg.Panel, Wait => False);
+ Panel.Backlight_On (Port_Cfg.Panel);
end if;
end Post_On;

@@ -110,8 +110,8 @@
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

if Is_Internal (Port_Cfg) then
- Panel.Backlight_Off;
- Panel.Off;
+ Panel.Backlight_Off (Port_Cfg.Panel);
+ Panel.Off (Port_Cfg.Panel);
end if;
end Pre_Off;

@@ -154,8 +154,10 @@
begin
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

- Panel.Backlight_Off;
- Panel.Off;
+ for P in Active_Panel loop
+ Panel.Backlight_Off (P);
+ Panel.Off (P);
+ end loop;
end Pre_All_Off;

procedure Post_All_Off

To view, visit change 38243. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: I83864bc86b48f65d9ba43e083b805ca09497cbb0
Gerrit-Change-Number: 38243
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-MessageType: newchange