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