blob: 8ae47fdecc6838016aaae8042d669e7ecc3679f2 [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 Huber0923b792017-06-09 15:28:41 +020032 procedure Initialize
33 is
34 begin
35 null;
36 end Initialize;
37
Nico Huber83693c82016-10-08 22:17:55 +020038 function Is_Internal (Port_Cfg : Port_Config) return Boolean
39 is
40 begin
41 return
42 Port_Cfg.Port = DIGI_A or
43 (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS);
44 end Is_Internal;
45
46 ----------------------------------------------------------------------------
47
48 procedure Pre_On
Nico Huber6e327c92016-12-21 14:45:45 +010049 (Pipe : in Pipe_Index;
50 Port_Cfg : in Port_Config;
Nico Huber83693c82016-10-08 22:17:55 +020051 PLL_Hint : in Word32;
Nico Huber83693c82016-10-08 22:17:55 +020052 Success : out Boolean)
53 is
54 begin
55 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
56
57 if Port_Cfg.Port = DIGI_A then
Nico Huber6e327c92016-12-21 14:45:45 +010058 EDP.Pre_On (Pipe, Port_Cfg);
Nico Huber83693c82016-10-08 22:17:55 +020059 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
60 FDI.Pre_On (Port_Cfg);
61 end if;
62 Success := True;
63 end Pre_On;
64
65 procedure Post_On
66 (Port_Cfg : in Port_Config;
67 PLL_Hint : in Word32;
68 Success : out Boolean)
69 is
70 begin
71 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
72
73 if Port_Cfg.Port = DIGI_A then
74 EDP.Pre_Training;
Nico Huber7892ff62016-11-21 23:26:00 +010075 Panel.On (Wait => True);
76 EDP.Post_On (Port_Cfg.DP, Success);
Nico Huber83693c82016-10-08 22:17:55 +020077 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
78 declare
79 FDI_Port : constant PCH.FDI_Port_Type :=
80 FDI.PCH_FDIs (Port_Cfg.Port);
81 begin
82 FDI.Post_On (Port_Cfg, Success);
83
84 if Success then
85 PCH.Transcoder.On (Port_Cfg, FDI_Port, PLL_Hint);
86 if Port_Cfg.PCH_Port = PCH_DAC then
87 PCH.VGA.On (FDI_Port, Port_Cfg.Mode);
88 elsif Port_Cfg.PCH_Port = PCH_LVDS then
89 PCH.LVDS.On (Port_Cfg, FDI_Port);
90 elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then
91 PCH.HDMI.On (Port_Cfg, FDI_Port);
92 elsif Port_Cfg.PCH_Port in PCH_DP_Port then
93 PCH.DP.On (Port_Cfg, Success);
94 end if;
95 end if;
96 end;
97 else
98 Success := False;
99 end if;
100
101 if Success and Is_Internal (Port_Cfg) then
Nico Huber7892ff62016-11-21 23:26:00 +0100102 Panel.On (Wait => False);
Nico Huber83693c82016-10-08 22:17:55 +0200103 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;