blob: 5970ea5466188472029780bea2279329e29cc004 [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
Arthur Heymans60d0e5f2018-03-28 17:08:27 +020063 (Pipe : in Pipe_Index;
64 Port_Cfg : in Port_Config;
Nico Huber83693c82016-10-08 22:17:55 +020065 PLL_Hint : in Word32;
66 Success : out Boolean)
67 is
68 begin
69 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
70
71 if Port_Cfg.Port = DIGI_A then
72 EDP.Pre_Training;
Nico Huber2bbd6e72020-01-07 18:22:59 +010073 Panel.On (Port_Cfg.Panel, Wait => True);
Nico Huber7892ff62016-11-21 23:26:00 +010074 EDP.Post_On (Port_Cfg.DP, Success);
Nico Huber83693c82016-10-08 22:17:55 +020075 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
76 declare
77 FDI_Port : constant PCH.FDI_Port_Type :=
78 FDI.PCH_FDIs (Port_Cfg.Port);
79 begin
80 FDI.Post_On (Port_Cfg, Success);
81
82 if Success then
83 PCH.Transcoder.On (Port_Cfg, FDI_Port, PLL_Hint);
84 if Port_Cfg.PCH_Port = PCH_DAC then
85 PCH.VGA.On (FDI_Port, Port_Cfg.Mode);
86 elsif Port_Cfg.PCH_Port = PCH_LVDS then
87 PCH.LVDS.On (Port_Cfg, FDI_Port);
88 elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then
89 PCH.HDMI.On (Port_Cfg, FDI_Port);
90 elsif Port_Cfg.PCH_Port in PCH_DP_Port then
Nico Huberf6a2d182019-10-01 10:37:49 +020091 PCH.DP.On (Port_Cfg, FDI_Port, Success);
Nico Huber83693c82016-10-08 22:17:55 +020092 end if;
93 end if;
94 end;
95 else
96 Success := False;
97 end if;
98
99 if Success and Is_Internal (Port_Cfg) then
Nico Huber2bbd6e72020-01-07 18:22:59 +0100100 Panel.On (Port_Cfg.Panel, Wait => False);
101 Panel.Backlight_On (Port_Cfg.Panel);
Nico Huber83693c82016-10-08 22:17:55 +0200102 end if;
103 end Post_On;
104
105 ----------------------------------------------------------------------------
106
107 procedure Pre_Off (Port_Cfg : Port_Config)
108 is
109 begin
110 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
111
112 if Is_Internal (Port_Cfg) then
Nico Huber2bbd6e72020-01-07 18:22:59 +0100113 Panel.Backlight_Off (Port_Cfg.Panel);
114 Panel.Off (Port_Cfg.Panel);
Nico Huber83693c82016-10-08 22:17:55 +0200115 end if;
116 end Pre_Off;
117
118 procedure Post_Off (Port_Cfg : Port_Config)
119 is
120 begin
121 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
122
123 if Port_Cfg.Port = DIGI_A then
124 EDP.Off (Port_Cfg.Port);
125 elsif Port_Cfg.Port in FDI.GPU_FDI_Port then
126 declare
127 FDI_Port : constant PCH.FDI_Port_Type :=
128 FDI.PCH_FDIs (Port_Cfg.Port);
129 begin
130 if Port_Cfg.PCH_Port in PCH_DP_Port then
131 PCH.DP.Off (Port_Cfg.PCH_Port);
132 end if;
133
134 FDI.Off (Port_Cfg.Port, FDI.Link_Off);
135
136 if Port_Cfg.PCH_Port = PCH_DAC then
137 PCH.VGA.Off;
138 elsif Port_Cfg.PCH_Port = PCH_LVDS then
139 PCH.LVDS.Off;
140 elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then
141 PCH.HDMI.Off (Port_Cfg.PCH_Port);
142 end if;
143 PCH.Transcoder.Off (FDI_Port);
144
145 FDI.Off (Port_Cfg.Port, FDI.Clock_Off);
146 end;
147 end if;
148 end Post_Off;
149
150 ----------------------------------------------------------------------------
151
152 procedure Pre_All_Off
153 is
154 begin
155 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
156
Nico Huber2bbd6e72020-01-07 18:22:59 +0100157 for P in Valid_Panels loop
158 Panel.Backlight_Off (P);
159 Panel.Off (P);
160 end loop;
Nico Huber83693c82016-10-08 22:17:55 +0200161 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;