blob: 3cf8c4ed6f01b34033198b18633086261090eddb [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;
69 Success := True;
70 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
71 declare
72 FDI_Port : constant PCH.FDI_Port_Type :=
73 FDI.PCH_FDIs (Port_Cfg.Port);
74 begin
75 FDI.Post_On (Port_Cfg, Success);
76
77 if Success then
78 PCH.Transcoder.On (Port_Cfg, FDI_Port, PLL_Hint);
79 if Port_Cfg.PCH_Port = PCH_DAC then
80 PCH.VGA.On (FDI_Port, Port_Cfg.Mode);
81 elsif Port_Cfg.PCH_Port = PCH_LVDS then
82 PCH.LVDS.On (Port_Cfg, FDI_Port);
83 elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then
84 PCH.HDMI.On (Port_Cfg, FDI_Port);
85 elsif Port_Cfg.PCH_Port in PCH_DP_Port then
86 PCH.DP.On (Port_Cfg, Success);
87 end if;
88 end if;
89 end;
90 else
91 Success := False;
92 end if;
93
94 if Success and Is_Internal (Port_Cfg) then
95 Panel.On;
96 end if;
97
98 if Port_Cfg.Port = DIGI_A then
99 EDP.Post_On (Port_Cfg.DP, Success);
100 end if;
101
102 if Success and Is_Internal (Port_Cfg) then
103 Panel.Backlight_On;
104 end if;
105 end Post_On;
106
107 ----------------------------------------------------------------------------
108
109 procedure Pre_Off (Port_Cfg : Port_Config)
110 is
111 begin
112 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
113
114 if Is_Internal (Port_Cfg) then
115 Panel.Backlight_Off;
116 Panel.Off;
117 end if;
118 end Pre_Off;
119
120 procedure Post_Off (Port_Cfg : Port_Config)
121 is
122 begin
123 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
124
125 if Port_Cfg.Port = DIGI_A then
126 EDP.Off (Port_Cfg.Port);
127 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
128 declare
129 FDI_Port : constant PCH.FDI_Port_Type :=
130 FDI.PCH_FDIs (Port_Cfg.Port);
131 begin
132 if Port_Cfg.PCH_Port in PCH_DP_Port then
133 PCH.DP.Off (Port_Cfg.PCH_Port);
134 end if;
135
136 FDI.Off (Port_Cfg.Port, FDI.Link_Off);
137
138 if Port_Cfg.PCH_Port = PCH_DAC then
139 PCH.VGA.Off;
140 elsif Port_Cfg.PCH_Port = PCH_LVDS then
141 PCH.LVDS.Off;
142 elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then
143 PCH.HDMI.Off (Port_Cfg.PCH_Port);
144 end if;
145 PCH.Transcoder.Off (FDI_Port);
146
147 FDI.Off (Port_Cfg.Port, FDI.Clock_Off);
148 end;
149 end if;
150 end Post_Off;
151
152 ----------------------------------------------------------------------------
153
154 procedure Pre_All_Off
155 is
156 begin
157 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
158
159 Panel.Backlight_Off;
160 Panel.Off;
161 end Pre_All_Off;
162
163 procedure Post_All_Off
164 is
165 begin
166 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
167
168 EDP.Off (DIGI_A);
169
170 for Port in FDI.GPU_FDI_Port loop
171 FDI.Off (Port, FDI.Link_Off);
172 end loop;
173 PCH.VGA.Off;
174 PCH.LVDS.Off;
175 PCH.HDMI.All_Off;
176 PCH.DP.All_Off;
177 for Port in PCH.FDI_Port_Type loop
178 PCH.Transcoder.Off (Port);
179 end loop;
180 for Port in FDI.GPU_FDI_Port loop
181 FDI.Off (Port, FDI.Clock_Off);
182 end loop;
183 end Post_All_Off;
184
185end HW.GFX.GMA.Connectors;