blob: e94ae2eed65669f906daf2aa90043313add1d940 [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
32 function Is_Internal (Port_Cfg : Port_Config) return Boolean
33 is
34 begin
35 return
36 Port_Cfg.Port = DIGI_A or
37 (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS);
38 end Is_Internal;
39
40 ----------------------------------------------------------------------------
41
42 procedure Pre_On
43 (Port_Cfg : in Port_Config;
44 PLL_Hint : in Word32;
45 Pipe_Hint : in Word32;
46 Success : out Boolean)
47 is
48 begin
49 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
50
51 if Port_Cfg.Port = DIGI_A then
52 EDP.Pre_On (Port_Cfg, Pipe_Hint);
53 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
54 FDI.Pre_On (Port_Cfg);
55 end if;
56 Success := True;
57 end Pre_On;
58
59 procedure Post_On
60 (Port_Cfg : in Port_Config;
61 PLL_Hint : in Word32;
62 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
68 EDP.Pre_Training;
Nico Huber7892ff62016-11-21 23:26:00 +010069 Panel.On (Wait => True);
70 EDP.Post_On (Port_Cfg.DP, Success);
Nico Huber83693c82016-10-08 22:17:55 +020071 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
72 declare
73 FDI_Port : constant PCH.FDI_Port_Type :=
74 FDI.PCH_FDIs (Port_Cfg.Port);
75 begin
76 FDI.Post_On (Port_Cfg, Success);
77
78 if Success then
79 PCH.Transcoder.On (Port_Cfg, FDI_Port, PLL_Hint);
80 if Port_Cfg.PCH_Port = PCH_DAC then
81 PCH.VGA.On (FDI_Port, Port_Cfg.Mode);
82 elsif Port_Cfg.PCH_Port = PCH_LVDS then
83 PCH.LVDS.On (Port_Cfg, FDI_Port);
84 elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then
85 PCH.HDMI.On (Port_Cfg, FDI_Port);
86 elsif Port_Cfg.PCH_Port in PCH_DP_Port then
87 PCH.DP.On (Port_Cfg, Success);
88 end if;
89 end if;
90 end;
91 else
92 Success := False;
93 end if;
94
95 if Success and Is_Internal (Port_Cfg) then
Nico Huber7892ff62016-11-21 23:26:00 +010096 Panel.On (Wait => False);
Nico Huber83693c82016-10-08 22:17:55 +020097 Panel.Backlight_On;
98 end if;
99 end Post_On;
100
101 ----------------------------------------------------------------------------
102
103 procedure Pre_Off (Port_Cfg : Port_Config)
104 is
105 begin
106 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
107
108 if Is_Internal (Port_Cfg) then
109 Panel.Backlight_Off;
110 Panel.Off;
111 end if;
112 end Pre_Off;
113
114 procedure Post_Off (Port_Cfg : Port_Config)
115 is
116 begin
117 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
118
119 if Port_Cfg.Port = DIGI_A then
120 EDP.Off (Port_Cfg.Port);
121 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
122 declare
123 FDI_Port : constant PCH.FDI_Port_Type :=
124 FDI.PCH_FDIs (Port_Cfg.Port);
125 begin
126 if Port_Cfg.PCH_Port in PCH_DP_Port then
127 PCH.DP.Off (Port_Cfg.PCH_Port);
128 end if;
129
130 FDI.Off (Port_Cfg.Port, FDI.Link_Off);
131
132 if Port_Cfg.PCH_Port = PCH_DAC then
133 PCH.VGA.Off;
134 elsif Port_Cfg.PCH_Port = PCH_LVDS then
135 PCH.LVDS.Off;
136 elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then
137 PCH.HDMI.Off (Port_Cfg.PCH_Port);
138 end if;
139 PCH.Transcoder.Off (FDI_Port);
140
141 FDI.Off (Port_Cfg.Port, FDI.Clock_Off);
142 end;
143 end if;
144 end Post_Off;
145
146 ----------------------------------------------------------------------------
147
148 procedure Pre_All_Off
149 is
150 begin
151 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
152
153 Panel.Backlight_Off;
154 Panel.Off;
155 end Pre_All_Off;
156
157 procedure Post_All_Off
158 is
159 begin
160 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
161
162 EDP.Off (DIGI_A);
163
164 for Port in FDI.GPU_FDI_Port loop
165 FDI.Off (Port, FDI.Link_Off);
166 end loop;
167 PCH.VGA.Off;
168 PCH.LVDS.Off;
169 PCH.HDMI.All_Off;
170 PCH.DP.All_Off;
171 for Port in PCH.FDI_Port_Type loop
172 PCH.Transcoder.Off (Port);
173 end loop;
174 for Port in FDI.GPU_FDI_Port loop
175 FDI.Off (Port, FDI.Clock_Off);
176 end loop;
177 end Post_All_Off;
178
179end HW.GFX.GMA.Connectors;