blob: db8e6d0a05a538905ce8419601efc4de478ab386 [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
2-- Copyright (C) 2015-2016 secunet Security Networks AG
3-- Copyright (C) 2016 Nico Huber <nico.h@gmx.de>
4--
5-- This program is free software; you can redistribute it and/or modify
6-- it under the terms of the GNU General Public License as published by
Nico Huber125a29e2016-10-18 00:23:54 +02007-- the Free Software Foundation; either version 2 of the License, or
8-- (at your option) any later version.
Nico Huber83693c82016-10-08 22:17:55 +02009--
10-- This program is distributed in the hope that it will be useful,
11-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-- GNU General Public License for more details.
14--
15
16with HW.GFX.GMA.Config;
17with HW.GFX.GMA.Panel;
18with HW.GFX.GMA.Connectors.EDP;
19with HW.GFX.GMA.Connectors.FDI;
20with HW.GFX.GMA.PCH.VGA;
21with HW.GFX.GMA.PCH.LVDS;
22with HW.GFX.GMA.PCH.HDMI;
23with HW.GFX.GMA.PCH.DP;
24with HW.GFX.GMA.PCH.Transcoder;
25
26with HW.Debug;
27with GNAT.Source_Info;
28
29package body HW.GFX.GMA.Connectors
30is
31
Nico Huber3a0e2a02017-07-19 14:41:46 +020032 procedure Post_Reset_Off is null;
33 procedure Initialize is null;
Nico Huber0923b792017-06-09 15:28:41 +020034
Nico Hubera8254482024-07-03 12:23:00 +020035 ----------------------------------------------------------------------------
36
37 procedure Prepare
38 (Port : in Active_Port_Type;
39 Port_Cfg : in out Port_Config;
40 Success : out Boolean)
41 is
42 begin
43 Success := True;
44 end Prepare;
45
46 ----------------------------------------------------------------------------
47
Nico Huber83693c82016-10-08 22:17:55 +020048 function Is_Internal (Port_Cfg : Port_Config) return Boolean
49 is
50 begin
51 return
52 Port_Cfg.Port = DIGI_A or
53 (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS);
54 end Is_Internal;
55
56 ----------------------------------------------------------------------------
57
58 procedure Pre_On
Nico Huber6e327c92016-12-21 14:45:45 +010059 (Pipe : in Pipe_Index;
60 Port_Cfg : in Port_Config;
Nico Huber83693c82016-10-08 22:17:55 +020061 PLL_Hint : in Word32;
Nico Huber83693c82016-10-08 22:17:55 +020062 Success : out Boolean)
63 is
64 begin
65 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
66
67 if Port_Cfg.Port = DIGI_A then
Nico Huber6e327c92016-12-21 14:45:45 +010068 EDP.Pre_On (Pipe, Port_Cfg);
Nico Huber83693c82016-10-08 22:17:55 +020069 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
70 FDI.Pre_On (Port_Cfg);
71 end if;
72 Success := True;
73 end Pre_On;
74
75 procedure Post_On
Arthur Heymans60d0e5f2018-03-28 17:08:27 +020076 (Pipe : in Pipe_Index;
77 Port_Cfg : in Port_Config;
Nico Huber83693c82016-10-08 22:17:55 +020078 PLL_Hint : in Word32;
79 Success : out Boolean)
80 is
81 begin
82 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
83
84 if Port_Cfg.Port = DIGI_A then
85 EDP.Pre_Training;
Nico Huber2bbd6e72020-01-07 18:22:59 +010086 Panel.On (Port_Cfg.Panel, Wait => True);
Nico Huber7892ff62016-11-21 23:26:00 +010087 EDP.Post_On (Port_Cfg.DP, Success);
Nico Huber83693c82016-10-08 22:17:55 +020088 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
89 declare
90 FDI_Port : constant PCH.FDI_Port_Type :=
91 FDI.PCH_FDIs (Port_Cfg.Port);
92 begin
93 FDI.Post_On (Port_Cfg, Success);
94
95 if Success then
96 PCH.Transcoder.On (Port_Cfg, FDI_Port, PLL_Hint);
97 if Port_Cfg.PCH_Port = PCH_DAC then
98 PCH.VGA.On (FDI_Port, Port_Cfg.Mode);
99 elsif Port_Cfg.PCH_Port = PCH_LVDS then
100 PCH.LVDS.On (Port_Cfg, FDI_Port);
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600101 elsif Port_Cfg.PCH_Port in PCH.HDMI.IRL_PCH_HDMI_Port then
Nico Huber83693c82016-10-08 22:17:55 +0200102 PCH.HDMI.On (Port_Cfg, FDI_Port);
103 elsif Port_Cfg.PCH_Port in PCH_DP_Port then
Nico Huberf6a2d182019-10-01 10:37:49 +0200104 PCH.DP.On (Port_Cfg, FDI_Port, Success);
Nico Huber83693c82016-10-08 22:17:55 +0200105 end if;
106 end if;
107 end;
108 else
109 Success := False;
110 end if;
111
112 if Success and Is_Internal (Port_Cfg) then
Nico Huber2bbd6e72020-01-07 18:22:59 +0100113 Panel.On (Port_Cfg.Panel, Wait => False);
114 Panel.Backlight_On (Port_Cfg.Panel);
Nico Huber83693c82016-10-08 22:17:55 +0200115 end if;
116 end Post_On;
117
118 ----------------------------------------------------------------------------
119
120 procedure Pre_Off (Port_Cfg : Port_Config)
121 is
122 begin
123 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
124
125 if Is_Internal (Port_Cfg) then
Nico Huber2bbd6e72020-01-07 18:22:59 +0100126 Panel.Backlight_Off (Port_Cfg.Panel);
127 Panel.Off (Port_Cfg.Panel);
Nico Huber83693c82016-10-08 22:17:55 +0200128 end if;
129 end Pre_Off;
130
131 procedure Post_Off (Port_Cfg : Port_Config)
132 is
133 begin
134 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
135
136 if Port_Cfg.Port = DIGI_A then
137 EDP.Off (Port_Cfg.Port);
138 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
139 declare
140 FDI_Port : constant PCH.FDI_Port_Type :=
141 FDI.PCH_FDIs (Port_Cfg.Port);
142 begin
143 if Port_Cfg.PCH_Port in PCH_DP_Port then
144 PCH.DP.Off (Port_Cfg.PCH_Port);
145 end if;
146
147 FDI.Off (Port_Cfg.Port, FDI.Link_Off);
148
149 if Port_Cfg.PCH_Port = PCH_DAC then
150 PCH.VGA.Off;
151 elsif Port_Cfg.PCH_Port = PCH_LVDS then
152 PCH.LVDS.Off;
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600153 elsif Port_Cfg.PCH_Port in PCH.HDMI.IRL_PCH_HDMI_Port then
Nico Huber83693c82016-10-08 22:17:55 +0200154 PCH.HDMI.Off (Port_Cfg.PCH_Port);
155 end if;
156 PCH.Transcoder.Off (FDI_Port);
157
158 FDI.Off (Port_Cfg.Port, FDI.Clock_Off);
159 end;
160 end if;
161 end Post_Off;
162
163 ----------------------------------------------------------------------------
164
165 procedure Pre_All_Off
166 is
167 begin
168 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
169
Nico Huber2bbd6e72020-01-07 18:22:59 +0100170 for P in Valid_Panels loop
171 Panel.Backlight_Off (P);
172 Panel.Off (P);
173 end loop;
Nico Huber83693c82016-10-08 22:17:55 +0200174 end Pre_All_Off;
175
176 procedure Post_All_Off
177 is
178 begin
179 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
180
181 EDP.Off (DIGI_A);
182
183 for Port in FDI.GPU_FDI_Port loop
184 FDI.Off (Port, FDI.Link_Off);
185 end loop;
186 PCH.VGA.Off;
187 PCH.LVDS.Off;
188 PCH.HDMI.All_Off;
189 PCH.DP.All_Off;
190 for Port in PCH.FDI_Port_Type loop
191 PCH.Transcoder.Off (Port);
192 end loop;
193 for Port in FDI.GPU_FDI_Port loop
194 FDI.Off (Port, FDI.Clock_Off);
195 end loop;
196 end Post_All_Off;
197
198end HW.GFX.GMA.Connectors;