blob: dbdee5c9f2374f7f12ef0ae7469585252e8eef6c [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
Nico Huber3d06de82018-05-29 01:35:04 +02002-- Copyright (C) 2014-2018 secunet Security Networks AG
Nico Huber2b6f6992017-07-09 18:11:34 +02003-- Copyright (C) 2017 Nico Huber <nico.h@gmx.de>
Nico Huber83693c82016-10-08 22:17:55 +02004--
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
Nico Huber2b6f6992017-07-09 18:11:34 +020016with HW.MMIO_Range;
17pragma Elaborate_All (HW.MMIO_Range);
18with HW.PCI.Dev;
19pragma Elaborate_All (HW.PCI.Dev);
20
Nico Huber83693c82016-10-08 22:17:55 +020021with HW.GFX.GMA.Config;
Nico Huber8c45bcf2016-11-20 17:30:57 +010022with HW.GFX.GMA.Config_Helpers;
Nico Huber83693c82016-10-08 22:17:55 +020023with HW.GFX.GMA.Registers;
Nico Huber312433c2019-09-28 03:15:48 +020024with HW.GFX.GMA.PCode;
Nico Huber83693c82016-10-08 22:17:55 +020025with HW.GFX.GMA.Power_And_Clocks;
26with HW.GFX.GMA.Panel;
27with HW.GFX.GMA.PLLs;
28with HW.GFX.GMA.Port_Detect;
29with HW.GFX.GMA.Connectors;
30with HW.GFX.GMA.Connector_Info;
31with HW.GFX.GMA.Pipe_Setup;
32
Nico Huber83693c82016-10-08 22:17:55 +020033with HW.Debug;
34with GNAT.Source_Info;
35
Nico Huber83693c82016-10-08 22:17:55 +020036use type HW.Int32;
37
38package body HW.GFX.GMA
39 with Refined_State =>
40 (State =>
Nico Huber2b6f6992017-07-09 18:11:34 +020041 (Dev.Address_State,
42 Registers.Address_State,
Nico Huber312433c2019-09-28 03:15:48 +020043 PCode.Mailbox_Ready,
Nico Huber83693c82016-10-08 22:17:55 +020044 PLLs.State, Panel.Panel_State,
Nico Huber1a712d32017-01-09 15:11:04 +010045 Cur_Configs, Allocated_PLLs,
Nico Huberc3f66f62017-07-16 21:39:54 +020046 HPD_Delay, Wait_For_HPD,
47 Linear_FB_Base),
Nico Huber83693c82016-10-08 22:17:55 +020048 Init_State => Initialized,
Nico Huber30e84082018-06-10 13:28:05 +020049 Config_State => (Config.Variable),
Nico Huber83693c82016-10-08 22:17:55 +020050 Device_State =>
Nico Huber2b6f6992017-07-09 18:11:34 +020051 (Dev.PCI_State, Registers.Register_State, Registers.GTT_State))
Nico Huber83693c82016-10-08 22:17:55 +020052is
Nico Huber2b6f6992017-07-09 18:11:34 +020053 pragma Disable_Atomic_Synchronization;
Nico Huber83693c82016-10-08 22:17:55 +020054
55 subtype Port_Name is String (1 .. 8);
56 type Port_Name_Array is array (Port_Type) of Port_Name;
57 Port_Names : constant Port_Name_Array :=
58 (Disabled => "Disabled",
59 Internal => "Internal",
60 DP1 => "DP1 ",
61 DP2 => "DP2 ",
62 DP3 => "DP3 ",
Nico Huber0d454cd2016-11-21 13:33:43 +010063 HDMI1 => "HDMI1 ",
64 HDMI2 => "HDMI2 ",
65 HDMI3 => "HDMI3 ",
Nico Huber83693c82016-10-08 22:17:55 +020066 Analog => "Analog ");
67
Nico Huber2b6f6992017-07-09 18:11:34 +020068 package Dev is new HW.PCI.Dev (PCI.Address'(0, 2, 0));
69
Nico Huber83693c82016-10-08 22:17:55 +020070 package Display_Controller renames Pipe_Setup;
71
Nico Huber99f10f32016-11-20 00:34:05 +010072 type PLLs_Type is array (Pipe_Index) of PLLs.T;
Nico Huber83693c82016-10-08 22:17:55 +020073
Nico Huber83693c82016-10-08 22:17:55 +020074 type HPD_Type is array (Port_Type) of Boolean;
Nico Huber3be61d42017-01-09 13:58:18 +010075 type HPD_Delay_Type is array (Active_Port_Type) of Time.T;
Nico Huber83693c82016-10-08 22:17:55 +020076
Nico Huber83693c82016-10-08 22:17:55 +020077 Allocated_PLLs : PLLs_Type;
Nico Huber83693c82016-10-08 22:17:55 +020078 HPD_Delay : HPD_Delay_Type;
79 Wait_For_HPD : HPD_Type;
80 Initialized : Boolean := False;
81
Nico Huberc3f66f62017-07-16 21:39:54 +020082 Linear_FB_Base : Word64;
83
Nico Huber83693c82016-10-08 22:17:55 +020084 ----------------------------------------------------------------------------
85
Nico Huberf54d0962016-10-20 14:17:18 +020086 PCH_RAWCLK_FREQ_MASK : constant := 16#3ff# * 2 ** 0;
87
88 function PCH_RAWCLK_FREQ (Freq : Frequency_Type) return Word32
89 is
90 begin
91 return Word32 (Freq / 1_000_000);
92 end PCH_RAWCLK_FREQ;
93
94 ----------------------------------------------------------------------------
95
Nico Huber43370ba2017-01-09 15:26:19 +010096 procedure Enable_Output
97 (Pipe : in Pipe_Index;
98 Pipe_Cfg : in Pipe_Config;
99 Success : out Boolean)
Nico Huber8a5a3b52018-06-04 14:42:13 +0200100 with
101 Pre => Pipe_Cfg.Port in Active_Port_Type
Nico Huber43370ba2017-01-09 15:26:19 +0100102 is
103 Port_Cfg : Port_Config;
Nico Huberf361ec82018-06-02 18:01:45 +0200104 Scaler_Available : Boolean;
Nico Huber43370ba2017-01-09 15:26:19 +0100105 begin
Nico Huber3be61d42017-01-09 13:58:18 +0100106 pragma Debug (Debug.New_Line);
107 pragma Debug (Debug.Put_Line
108 ("Trying to enable port " & Port_Names (Pipe_Cfg.Port)));
109
Nico Huber43370ba2017-01-09 15:26:19 +0100110 Config_Helpers.Fill_Port_Config
111 (Port_Cfg, Pipe, Pipe_Cfg.Port, Pipe_Cfg.Mode, Success);
112
113 if Success then
Nico Huberf361ec82018-06-02 18:01:45 +0200114 Display_Controller.Scaler_Available (Scaler_Available, Pipe);
Nico Huber43370ba2017-01-09 15:26:19 +0100115 Success := Config_Helpers.Validate_Config
Nico Huberf361ec82018-06-02 18:01:45 +0200116 (Pipe_Cfg.Framebuffer, Port_Cfg.Mode, Pipe, Scaler_Available);
Nico Huber43370ba2017-01-09 15:26:19 +0100117 end if;
118
Nico Huber43370ba2017-01-09 15:26:19 +0100119 if Success then
Nico Huber43370ba2017-01-09 15:26:19 +0100120 Connector_Info.Preferred_Link_Setting (Port_Cfg, Success);
121 end if;
122
123 -- loop over all possible DP-lane configurations
124 -- (non-DP ports use a single fake configuration)
125 while Success loop
126 pragma Loop_Invariant
127 (Pipe_Cfg.Port in Active_Port_Type and
128 Port_Cfg.Mode = Port_Cfg.Mode'Loop_Entry);
129
130 PLLs.Alloc
131 (Port_Cfg => Port_Cfg,
132 PLL => Allocated_PLLs (Pipe),
133 Success => Success);
134
135 if Success then
136 -- try each DP-lane configuration twice
137 for Try in 1 .. 2 loop
138 pragma Loop_Invariant
139 (Pipe_Cfg.Port in Active_Port_Type);
140
Nico Huber4798c662017-01-11 12:44:48 +0100141 -- Clear pending hot-plug events before every try
142 Port_Detect.Clear_Hotplug_Detect (Pipe_Cfg.Port);
143
Nico Huber43370ba2017-01-09 15:26:19 +0100144 Connectors.Pre_On
145 (Pipe => Pipe,
146 Port_Cfg => Port_Cfg,
147 PLL_Hint => PLLs.Register_Value (Allocated_PLLs (Pipe)),
148 Success => Success);
149
150 if Success then
151 Display_Controller.On
152 (Pipe => Pipe,
153 Port_Cfg => Port_Cfg,
Nico Huber4dc4c612018-01-10 15:55:09 +0100154 Framebuffer => Pipe_Cfg.Framebuffer,
155 Cursor => Pipe_Cfg.Cursor);
Nico Huber43370ba2017-01-09 15:26:19 +0100156
157 Connectors.Post_On
Arthur Heymans60d0e5f2018-03-28 17:08:27 +0200158 (Pipe => Pipe,
159 Port_Cfg => Port_Cfg,
Nico Huber43370ba2017-01-09 15:26:19 +0100160 PLL_Hint => PLLs.Register_Value (Allocated_PLLs (Pipe)),
161 Success => Success);
162
163 if not Success then
164 Display_Controller.Off (Pipe);
165 Connectors.Post_Off (Port_Cfg);
166 end if;
167 end if;
168
169 exit when Success;
170 end loop;
171 exit when Success; -- connection established => stop loop
172
173 -- connection failed
174 PLLs.Free (Allocated_PLLs (Pipe));
175 end if;
176
177 Connector_Info.Next_Link_Setting (Port_Cfg, Success);
178 end loop;
179
180 if Success then
181 pragma Debug (Debug.Put_Line
182 ("Enabled port " & Port_Names (Pipe_Cfg.Port)));
183 else
184 Wait_For_HPD (Pipe_Cfg.Port) := True;
185 if Pipe_Cfg.Port = Internal then
186 Panel.Off;
187 end if;
188 end if;
189 end Enable_Output;
190
Nico Huber3be61d42017-01-09 13:58:18 +0100191 procedure Disable_Output (Pipe : Pipe_Index; Pipe_Cfg : Pipe_Config)
192 is
193 Port_Cfg : Port_Config;
194 Success : Boolean;
195 begin
196 Config_Helpers.Fill_Port_Config
197 (Port_Cfg, Pipe, Pipe_Cfg.Port, Pipe_Cfg.Mode, Success);
198 if Success then
199 pragma Debug (Debug.New_Line);
200 pragma Debug (Debug.Put_Line
201 ("Disabling port " & Port_Names (Pipe_Cfg.Port)));
202 pragma Debug (Debug.New_Line);
203
204 Connectors.Pre_Off (Port_Cfg);
205 Display_Controller.Off (Pipe);
206 Connectors.Post_Off (Port_Cfg);
207
208 PLLs.Free (Allocated_PLLs (Pipe));
209 end if;
210 end Disable_Output;
211
Nico Huber99f10f32016-11-20 00:34:05 +0100212 procedure Update_Outputs (Configs : Pipe_Configs)
Nico Huber83693c82016-10-08 22:17:55 +0200213 is
Nico Huber3be61d42017-01-09 13:58:18 +0100214 procedure Check_HPD (Port : in Active_Port_Type; Detected : out Boolean)
215 is
216 HPD_Delay_Over : constant Boolean := Time.Timed_Out (HPD_Delay (Port));
217 begin
218 if HPD_Delay_Over then
219 Port_Detect.Hotplug_Detect (Port, Detected);
220 HPD_Delay (Port) := Time.MS_From_Now (333);
221 else
222 Detected := False;
223 end if;
224 end Check_HPD;
Nico Huberb56b9c52017-01-11 15:12:23 +0100225
Nico Huber564103f2017-01-11 15:33:07 +0100226 Power_Changed : Boolean := False;
Nico Huberb56b9c52017-01-11 15:12:23 +0100227 Old_Configs : Pipe_Configs;
Nico Huber564103f2017-01-11 15:33:07 +0100228
229 -- Only called when we actually tried to change something
230 -- so we don't congest the log with unnecessary messages.
231 procedure Update_Power
232 is
233 begin
234 if not Power_Changed then
235 Power_And_Clocks.Power_Up (Old_Configs, Configs);
236 Power_Changed := True;
237 end if;
238 end Update_Power;
Nico Huber3d06de82018-05-29 01:35:04 +0200239
240 function Full_Update (Cur_Config, New_Config : Pipe_Config) return Boolean
241 is
242 begin
243 return
Nico Huber958c5642018-06-02 16:59:31 +0200244 Cur_Config.Port /= New_Config.Port
245 or else
246 Cur_Config.Mode /= New_Config.Mode
247 or else
Nico Huber3d06de82018-05-29 01:35:04 +0200248 (Config.Use_PDW_For_EDP_Scaling and then
249 (Cur_Config.Port = Internal and
Nico Huber958c5642018-06-02 16:59:31 +0200250 Requires_Scaling (Cur_Config) /= Requires_Scaling (New_Config)))
251 or else
252 (Config.Has_GMCH_PFIT_CONTROL and then
253 (Requires_Scaling (Cur_Config) /= Requires_Scaling (New_Config) or
254 Scaling_Type (Cur_Config) /= Scaling_Type (New_Config)));
Nico Huber3d06de82018-05-29 01:35:04 +0200255 end Full_Update;
Nico Huber83693c82016-10-08 22:17:55 +0200256 begin
257 Old_Configs := Cur_Configs;
258
Nico Huberb56b9c52017-01-11 15:12:23 +0100259 -- disable all pipes that changed or had a hot-plug event
260 for Pipe in Pipe_Index loop
261 declare
262 Unplug_Detected : Boolean;
263 Cur_Config : Pipe_Config renames Cur_Configs (Pipe);
264 New_Config : Pipe_Config renames Configs (Pipe);
265 begin
266 if Cur_Config.Port /= Disabled then
267 Check_HPD (Cur_Config.Port, Unplug_Detected);
Nico Huber83693c82016-10-08 22:17:55 +0200268
Nico Huber3d06de82018-05-29 01:35:04 +0200269 if Full_Update (Cur_Config, New_Config) or Unplug_Detected then
Nico Huberb56b9c52017-01-11 15:12:23 +0100270 Disable_Output (Pipe, Cur_Config);
271 Cur_Config.Port := Disabled;
Nico Huber564103f2017-01-11 15:33:07 +0100272 Update_Power;
Nico Huberb56b9c52017-01-11 15:12:23 +0100273 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200274 end if;
Nico Huberb56b9c52017-01-11 15:12:23 +0100275 end;
276 end loop;
Nico Huber83693c82016-10-08 22:17:55 +0200277
Nico Huberb56b9c52017-01-11 15:12:23 +0100278 -- enable all pipes that changed and should be active
279 for Pipe in Pipe_Index loop
280 declare
281 Success : Boolean;
Nico Huberf361ec82018-06-02 18:01:45 +0200282 Scaler_Available : Boolean;
Nico Huberb56b9c52017-01-11 15:12:23 +0100283 Cur_Config : Pipe_Config renames Cur_Configs (Pipe);
284 New_Config : Pipe_Config renames Configs (Pipe);
285 begin
Nico Huber3d06de82018-05-29 01:35:04 +0200286 if New_Config.Port /= Disabled and
287 Full_Update (Cur_Config, New_Config)
Nico Huberb56b9c52017-01-11 15:12:23 +0100288 then
Nico Huber3be61d42017-01-09 13:58:18 +0100289 if Wait_For_HPD (New_Config.Port) then
290 Check_HPD (New_Config.Port, Success);
291 Wait_For_HPD (New_Config.Port) := not Success;
292 else
293 Success := True;
Nico Huber8c45bcf2016-11-20 17:30:57 +0100294 end if;
Nico Huberc7a4fee2016-11-03 18:18:03 +0100295
Nico Huber3be61d42017-01-09 13:58:18 +0100296 if Success then
Nico Huber564103f2017-01-11 15:33:07 +0100297 Update_Power;
Nico Huberb56b9c52017-01-11 15:12:23 +0100298 Enable_Output (Pipe, New_Config, Success);
Nico Huber3be61d42017-01-09 13:58:18 +0100299 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200300
301 if Success then
Nico Huberb56b9c52017-01-11 15:12:23 +0100302 Cur_Config := New_Config;
Nico Huber83693c82016-10-08 22:17:55 +0200303 end if;
Nico Huber3be61d42017-01-09 13:58:18 +0100304
Nico Huberb56b9c52017-01-11 15:12:23 +0100305 -- update framebuffer offset only
306 elsif New_Config.Port /= Disabled and
Nico Huberf361ec82018-06-02 18:01:45 +0200307 Cur_Config.Framebuffer /= New_Config.Framebuffer
Nico Huberb56b9c52017-01-11 15:12:23 +0100308 then
Nico Huberf361ec82018-06-02 18:01:45 +0200309 Display_Controller.Scaler_Available (Scaler_Available, Pipe);
310 if Config_Helpers.Validate_Config
311 (New_Config.Framebuffer, New_Config.Mode,
312 Pipe, Scaler_Available)
313 then
314 Display_Controller.Setup_FB
315 (Pipe, New_Config.Mode, New_Config.Framebuffer);
316 Display_Controller.Update_Cursor
317 (Pipe, New_Config.Framebuffer, New_Config.Cursor);
318 Cur_Config := New_Config;
319 end if;
Nico Huberb56b9c52017-01-11 15:12:23 +0100320 end if;
321 end;
Nico Huber83693c82016-10-08 22:17:55 +0200322 end loop;
323
Nico Huber564103f2017-01-11 15:33:07 +0100324 if Power_Changed then
Nico Huber83693c82016-10-08 22:17:55 +0200325 Power_And_Clocks.Power_Down (Old_Configs, Configs, Cur_Configs);
326 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200327 end Update_Outputs;
328
329 ----------------------------------------------------------------------------
330
Nico Huber15ffc4f2018-01-11 14:44:43 +0100331 procedure Update_Cursor (Pipe : Pipe_Index; Cursor : Cursor_Type)
332 is
333 begin
334 Cur_Configs (Pipe).Cursor := Cursor;
335 Display_Controller.Update_Cursor
336 (Pipe, Cur_Configs (Pipe).Framebuffer, Cur_Configs (Pipe).Cursor);
337 end Update_Cursor;
338
339 procedure Place_Cursor
340 (Pipe : Pipe_Index;
341 X : Cursor_Pos;
342 Y : Cursor_Pos)
343 is
344 begin
345 Cur_Configs (Pipe).Cursor.Center_X := X;
346 Cur_Configs (Pipe).Cursor.Center_Y := Y;
347 Display_Controller.Place_Cursor
348 (Pipe, Cur_Configs (Pipe).Framebuffer, Cur_Configs (Pipe).Cursor);
349 end Place_Cursor;
350
351 procedure Move_Cursor
352 (Pipe : Pipe_Index;
353 X : Cursor_Pos;
354 Y : Cursor_Pos)
355 is
356 function Cap_Add (A, B : Cursor_Pos) return Cursor_Pos is
357 (if A + B < 0
358 then Int32'Max (Cursor_Pos'First, A + B)
359 else Int32'Min (Cursor_Pos'Last, A + B));
360 begin
361 Place_Cursor
362 (Pipe => Pipe,
363 X => Cap_Add (Cur_Configs (Pipe).Cursor.Center_X, X),
364 Y => Cap_Add (Cur_Configs (Pipe).Cursor.Center_Y, Y));
365 end Move_Cursor;
366
367 ----------------------------------------------------------------------------
368
Nico Huber83693c82016-10-08 22:17:55 +0200369 procedure Initialize
Nico Huber2b6f6992017-07-09 18:11:34 +0200370 (Write_Delay : in Word64 := 0;
Nico Huber793a8d42016-11-21 18:57:03 +0100371 Clean_State : in Boolean := False;
Nico Huber83693c82016-10-08 22:17:55 +0200372 Success : out Boolean)
373 with
374 Refined_Global =>
Nico Huber27088aa2018-06-10 13:28:05 +0200375 (Input => (Time.State),
376 In_Out => (Dev.PCI_State, Registers.Register_State, Port_IO.State),
Nico Huber83693c82016-10-08 22:17:55 +0200377 Output =>
Nico Huber27088aa2018-06-10 13:28:05 +0200378 (Config.Variable,
379 Dev.Address_State,
Nico Huber2b6f6992017-07-09 18:11:34 +0200380 Registers.Address_State,
Nico Huber312433c2019-09-28 03:15:48 +0200381 PCode.Mailbox_Ready,
Nico Huber83693c82016-10-08 22:17:55 +0200382 PLLs.State, Panel.Panel_State,
Nico Huber1a712d32017-01-09 15:11:04 +0100383 Cur_Configs, Allocated_PLLs,
Nico Huberc3f66f62017-07-16 21:39:54 +0200384 HPD_Delay, Wait_For_HPD,
385 Linear_FB_Base, Initialized))
Nico Huber83693c82016-10-08 22:17:55 +0200386 is
387 use type HW.Word64;
388
Nico Huber0b2329a2018-06-09 21:14:27 +0200389 function MMIO_GTT_Offset return Natural is
390 (if Config.Has_64bit_GTT
391 then Registers.MMIO_GTT_64_Offset
392 else Registers.MMIO_GTT_32_Offset);
Nico Huber2b6f6992017-07-09 18:11:34 +0200393 PCI_MMIO_Base, PCI_GTT_Base : Word64;
394
Nico Huber83693c82016-10-08 22:17:55 +0200395 Now : constant Time.T := Time.Now;
396
397 procedure Check_Platform (Success : out Boolean)
398 is
399 Audio_VID_DID : Word32;
400 begin
Nico Huber6621a142018-06-07 23:56:54 +0200401 case Config.Gen is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200402 when G45 =>
403 Registers.Read (Registers.G4X_AUD_VID_DID, Audio_VID_DID);
Nico Huber6621a142018-06-07 23:56:54 +0200404 when Ironlake =>
405 Registers.Read (Registers.PCH_AUD_VID_DID, Audio_VID_DID);
Nico Huber83693c82016-10-08 22:17:55 +0200406 when Haswell .. Skylake =>
407 Registers.Read (Registers.AUD_VID_DID, Audio_VID_DID);
Nico Huber83693c82016-10-08 22:17:55 +0200408 end case;
409 Success :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200410 ((Config.Gen_Broxton and Audio_VID_DID = 16#8086_280a#) or
Nico Huber88badbe2018-09-27 16:36:47 +0200411 (Config.CPU_Kabylake and Audio_VID_DID = 16#8086_280b#) or
412 (Config.CPU_Skylake and Audio_VID_DID = 16#8086_2809#) or
Nico Huber998ee2b2018-06-12 23:02:17 +0200413 (Config.CPU_Broadwell and Audio_VID_DID = 16#8086_2808#) or
414 (Config.CPU_Haswell and Audio_VID_DID = 16#8086_2807#) or
415 ((Config.CPU_Ivybridge or
416 Config.CPU_Sandybridge) and (Audio_VID_DID = 16#8086_2806# or
417 Audio_VID_DID = 16#8086_2805#)) or
418 (Config.CPU_Ironlake and Audio_VID_DID = 16#0000_0000#) or
419 (Config.Gen_G45 and (Audio_VID_DID = 16#8086_2801# or
420 Audio_VID_DID = 16#8086_2802# or
421 Audio_VID_DID = 16#8086_2803#)));
Nico Huber83693c82016-10-08 22:17:55 +0200422 end Check_Platform;
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200423
424 procedure Check_Platform_PCI (Success : out Boolean)
425 is
426 use type HW.Word16;
427 Vendor, Device : Word16;
428 begin
429 Dev.Read16 (Vendor, PCI.Vendor_Id);
430 Dev.Read16 (Device, PCI.Device_Id);
431
Nico Huber6a996dc2018-06-17 16:30:33 +0200432 Config.Detect_CPU (Device);
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200433 Success := Vendor = 16#8086# and Config.Compatible_GPU (Device);
434 end Check_Platform_PCI;
Nico Huber83693c82016-10-08 22:17:55 +0200435 begin
Nico Huber83693c82016-10-08 22:17:55 +0200436 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
437
438 pragma Debug (Debug.Set_Register_Write_Delay (Write_Delay));
439
Nico Huberc3f66f62017-07-16 21:39:54 +0200440 Linear_FB_Base := 0;
Nico Huber312433c2019-09-28 03:15:48 +0200441 PCode.Mailbox_Ready := False;
Nico Huber83693c82016-10-08 22:17:55 +0200442 Wait_For_HPD := HPD_Type'(others => False);
443 HPD_Delay := HPD_Delay_Type'(others => Now);
Nico Huber83693c82016-10-08 22:17:55 +0200444 Allocated_PLLs := (others => PLLs.Invalid);
Nico Huber99f10f32016-11-20 00:34:05 +0100445 Cur_Configs := Pipe_Configs'
446 (others => Pipe_Config'
Nico Huber83693c82016-10-08 22:17:55 +0200447 (Port => Disabled,
448 Framebuffer => HW.GFX.Default_FB,
Nico Hubera02b2c62018-01-09 15:58:34 +0100449 Cursor => Default_Cursor,
Nico Huber83693c82016-10-08 22:17:55 +0200450 Mode => HW.GFX.Invalid_Mode));
Nico Huber27088aa2018-06-10 13:28:05 +0200451 Config.Variable := Config.Initial_Settings;
Nico Huber6a996dc2018-06-17 16:30:33 +0200452 Registers.Set_Register_Base (Config.Default_MMIO_Base);
Nico Huber83693c82016-10-08 22:17:55 +0200453 PLLs.Initialize;
454
Nico Huber2b6f6992017-07-09 18:11:34 +0200455 Dev.Initialize (Success);
456
457 if Success then
Nico Huber6a996dc2018-06-17 16:30:33 +0200458 Check_Platform_PCI (Success);
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200459 if Success then
Nico Huber6a996dc2018-06-17 16:30:33 +0200460 Dev.Map (PCI_MMIO_Base, PCI.Res0, Length => MMIO_GTT_Offset);
461 Dev.Map (PCI_GTT_Base, PCI.Res0, Offset => MMIO_GTT_Offset);
462 if PCI_MMIO_Base /= 0 and PCI_GTT_Base /= 0 then
463 Registers.Set_Register_Base (PCI_MMIO_Base, PCI_GTT_Base);
464 else
465 pragma Debug (Debug.Put_Line
466 ("ERROR: Couldn't map resoure0."));
467 Success := Config.Default_MMIO_Base_Set;
468 end if;
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200469 end if;
Nico Huber2b6f6992017-07-09 18:11:34 +0200470 else
471 pragma Debug (Debug.Put_Line
472 ("WARNING: Couldn't initialize PCI dev."));
Nico Huber2b6f6992017-07-09 18:11:34 +0200473 Success := Config.Default_MMIO_Base_Set;
Nico Huber2b6f6992017-07-09 18:11:34 +0200474
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200475 if Success then
476 Check_Platform (Success);
477 end if;
Nico Huber2b6f6992017-07-09 18:11:34 +0200478 end if;
479
Nico Huber83693c82016-10-08 22:17:55 +0200480 if not Success then
481 pragma Debug (Debug.Put_Line ("ERROR: Incompatible CPU or PCH."));
482
483 Panel.Static_Init; -- for flow analysis
484
485 Initialized := False;
486 return;
487 end if;
488
489 Panel.Setup_PP_Sequencer;
490 Port_Detect.Initialize;
Nico Huber0923b792017-06-09 15:28:41 +0200491 Connectors.Initialize;
Nico Huber83693c82016-10-08 22:17:55 +0200492
Nico Huber793a8d42016-11-21 18:57:03 +0100493 if Clean_State then
494 Power_And_Clocks.Pre_All_Off;
495 Connectors.Pre_All_Off;
496 Display_Controller.All_Off;
497 Connectors.Post_All_Off;
498 PLLs.All_Off;
499 Power_And_Clocks.Post_All_Off;
Nico Huber17d64b62017-07-15 20:51:25 +0200500 Registers.Clear_Fences;
Nico Huber33912aa2016-12-06 20:36:23 +0100501 else
502 -- According to PRMs, VGA plane is the only thing
Nico Huber3a0e2a02017-07-19 14:41:46 +0200503 -- that's enabled by default after reset...
Nico Huber33912aa2016-12-06 20:36:23 +0100504 Display_Controller.Legacy_VGA_Off;
Nico Huber3a0e2a02017-07-19 14:41:46 +0200505 -- ... along with some DDI port bits since Skylake.
506 Connectors.Post_Reset_Off;
Nico Huber793a8d42016-11-21 18:57:03 +0100507 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200508
509 -------------------- Now restart from a clean state ---------------------
510 Power_And_Clocks.Initialize;
511
Nico Huber1c3b9282017-02-09 13:57:04 +0100512 if Config.Has_PCH then
513 Registers.Unset_And_Set_Mask
514 (Register => Registers.PCH_RAWCLK_FREQ,
515 Mask_Unset => PCH_RAWCLK_FREQ_MASK,
516 Mask_Set => PCH_RAWCLK_FREQ (Config.Default_RawClk_Freq));
517 end if;
Nico Huberf54d0962016-10-20 14:17:18 +0200518
Nico Huber83693c82016-10-08 22:17:55 +0200519 Initialized := True;
520
521 end Initialize;
522
523 function Is_Initialized return Boolean
524 with
525 Refined_Post => Is_Initialized'Result = Initialized
526 is
527 begin
528 return Initialized;
529 end Is_Initialized;
530
531 ----------------------------------------------------------------------------
532
Nico Hubercf88f3d2018-06-05 13:27:34 +0200533 pragma Warnings
534 (GNATprove, Off, """Registers.Register_State"" * is not modified*",
Nico Huberadfe11f2018-06-10 14:59:04 +0200535 Reason => "Power_Up_VGA is only effective in certain configurations.");
Nico Huber42fb2d02017-09-01 17:01:51 +0200536 procedure Power_Up_VGA
Nico Hubercf88f3d2018-06-05 13:27:34 +0200537 with
538 Refined_Global =>
Nico Huberadfe11f2018-06-10 14:59:04 +0200539 (Input => (Cur_Configs, Config.Variable, Time.State),
Nico Hubercf88f3d2018-06-05 13:27:34 +0200540 In_Out => (Registers.Register_State),
541 Proof_In => (Initialized))
Nico Huber42fb2d02017-09-01 17:01:51 +0200542 is
543 Fake_Config : constant Pipe_Configs :=
544 (Primary =>
545 (Port => Analog,
546 Framebuffer => HW.GFX.Default_FB,
Nico Hubera02b2c62018-01-09 15:58:34 +0100547 Cursor => Default_Cursor,
Nico Huber42fb2d02017-09-01 17:01:51 +0200548 Mode => HW.GFX.Invalid_Mode),
549 others =>
550 (Port => Disabled,
551 Framebuffer => HW.GFX.Default_FB,
Nico Hubera02b2c62018-01-09 15:58:34 +0100552 Cursor => Default_Cursor,
Nico Huber42fb2d02017-09-01 17:01:51 +0200553 Mode => HW.GFX.Invalid_Mode));
554 begin
555 Power_And_Clocks.Power_Up (Cur_Configs, Fake_Config);
556 end Power_Up_VGA;
Nico Hubercf88f3d2018-06-05 13:27:34 +0200557 pragma Warnings
558 (GNATprove, Off, "no check message justified*", Reason => "see below");
559 pragma Annotate
560 (GNATprove, Intentional, "unused global",
Nico Huberadfe11f2018-06-10 14:59:04 +0200561 "Power_Up_VGA is only effective in certain configurations.");
Nico Hubercf88f3d2018-06-05 13:27:34 +0200562 pragma Warnings (GNATprove, On, "no check message justified*");
563 pragma Warnings
564 (GNATprove, On, """Registers.Register_State"" * is not modified*");
Nico Huber42fb2d02017-09-01 17:01:51 +0200565
566 ----------------------------------------------------------------------------
567
Nico Huber5374c3a2017-07-15 21:48:06 +0200568 function FB_First_Page (FB : Framebuffer_Type) return Natural is
Nico Huber34be6542017-12-13 09:26:24 +0100569 (Natural (Phys_Offset (FB) / GTT_Page_Size));
Nico Huber5374c3a2017-07-15 21:48:06 +0200570 function FB_Pages (FB : Framebuffer_Type) return Natural is
571 (Natural (Div_Round_Up (FB_Size (FB), GTT_Page_Size)));
572 function FB_Last_Page (FB : Framebuffer_Type) return Natural is
573 (FB_First_Page (FB) + FB_Pages (FB) - 1);
574
Nico Huber34be6542017-12-13 09:26:24 +0100575 -- Check basics and that it fits in GTT. For 90 degree rotations,
576 -- the Offset should be above GTT_Rotation_Offset. The latter will
577 -- be subtracted for the aperture mapping.
Nico Huber5374c3a2017-07-15 21:48:06 +0200578 function Valid_FB (FB : Framebuffer_Type) return Boolean is
Nico Huber34be6542017-12-13 09:26:24 +0100579 (Valid_Stride (FB) and
580 FB_First_Page (FB) in GTT_Range and
581 FB_Last_Page (FB) in GTT_Range and
582 (not Rotation_90 (FB) or
583 (FB_Last_Page (FB) + GTT_Rotation_Offset in GTT_Range and
584 FB.Offset >= Word32 (GTT_Rotation_Offset) * GTT_Page_Size)));
Nico Huber5374c3a2017-07-15 21:48:06 +0200585
586 -- Also check that we don't overflow the GTT's 39-bit space
587 -- (always true with a 32-bit base)
588 function Valid_Phys_FB (FB : Framebuffer_Type; Phys_Base : Word32)
589 return Boolean is
590 (Valid_FB (FB) and
Nico Huber34be6542017-12-13 09:26:24 +0100591 Int64 (Phys_Base) + Int64 (Phys_Offset (FB)) + Int64 (FB_Size (FB)) <=
Nico Huber5374c3a2017-07-15 21:48:06 +0200592 Int64 (GTT_Address_Type'Last))
593 with
594 Ghost;
595
Nico Huber83693c82016-10-08 22:17:55 +0200596 procedure Write_GTT
597 (GTT_Page : GTT_Range;
598 Device_Address : GTT_Address_Type;
Nico Huber5374c3a2017-07-15 21:48:06 +0200599 Valid : Boolean)
600 is
Nico Huber83693c82016-10-08 22:17:55 +0200601 begin
602 Registers.Write_GTT (GTT_Page, Device_Address, Valid);
603 end Write_GTT;
604
Nico Huberceda17d2018-06-09 22:00:29 +0200605 procedure Read_GTT
606 (Device_Address : out GTT_Address_Type;
607 Valid : out Boolean;
608 GTT_Page : in GTT_Range)
609 is
610 begin
611 Registers.Read_GTT (Device_Address, Valid, GTT_Page);
612 end Read_GTT;
613
Nico Huber194e57e2017-07-15 21:15:46 +0200614 procedure Setup_Default_GTT (FB : Framebuffer_Type; Phys_Base : Word32)
Nico Huber5374c3a2017-07-15 21:48:06 +0200615 with
616 Pre => Is_Initialized and Valid_Phys_FB (FB, Phys_Base)
Nico Huber83693c82016-10-08 22:17:55 +0200617 is
Nico Huber194e57e2017-07-15 21:15:46 +0200618 Phys_Addr : GTT_Address_Type :=
Nico Huber34be6542017-12-13 09:26:24 +0100619 GTT_Address_Type (Phys_Base) + GTT_Address_Type (Phys_Offset (FB));
Nico Huber83693c82016-10-08 22:17:55 +0200620 begin
Nico Huber194e57e2017-07-15 21:15:46 +0200621 for Idx in FB_First_Page (FB) .. FB_Last_Page (FB) loop
Nico Huber83693c82016-10-08 22:17:55 +0200622 Registers.Write_GTT
623 (GTT_Page => Idx,
624 Device_Address => Phys_Addr,
625 Valid => True);
Nico Huber194e57e2017-07-15 21:15:46 +0200626 Phys_Addr := Phys_Addr + GTT_Page_Size;
Nico Huber83693c82016-10-08 22:17:55 +0200627 end loop;
Nico Huber9b479412017-08-27 11:55:56 +0200628
629 if Rotation_90 (FB) and FB.Tiling = Y_Tiled and FB.V_Stride >= 32 then
630 declare
631 V_Pages : constant Natural := Natural (FB.V_Stride) / 32;
632 Bytes_Per_Row : constant GTT_Address_Type :=
633 GTT_Address_Type (Pixel_To_Bytes (32 * FB.Stride, FB));
634 begin
635 Phys_Addr := GTT_Address_Type (Phys_Base) +
Nico Huber34be6542017-12-13 09:26:24 +0100636 GTT_Address_Type (Phys_Offset (FB)) +
Nico Huber9b479412017-08-27 11:55:56 +0200637 GTT_Address_Type (FB_Size (FB));
638 for Page in FB_First_Page (FB) .. FB_Last_Page (FB) loop
639 Phys_Addr := Phys_Addr - Bytes_Per_Row;
640 Registers.Write_GTT
641 (GTT_Page => GTT_Rotation_Offset + Page,
642 Device_Address => Phys_Addr,
643 Valid => True);
644
645 if (Page - FB_First_Page (FB) + 1) mod V_Pages = 0 then
646 Phys_Addr := Phys_Addr + GTT_Page_Size +
647 GTT_Address_Type (V_Pages) * Bytes_Per_Row;
648 end if;
649 end loop;
650 end;
651 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200652 end Setup_Default_GTT;
653
654 ----------------------------------------------------------------------------
655
Nico Hubereedde882017-07-16 02:54:39 +0200656 use type HW.Word16;
657 subtype Stolen_Size_Range is Int64 range 0 .. 2 ** 33;
658
659 function GGMS_Gen4 (GGC : Word16) return Natural is
660 (Natural (Shift_Right (GGC, 8) and 16#07#));
661 function GTT_Size_Gen4 (GGC : Word16) return Natural is
662 (if GGMS_Gen4 (GGC) in 1 .. 3 then
663 (GGMS_Gen4 (GGC) + 1) * 2 ** 19 else 0);
664
665 function GMS_Gen4 (GGC : Word16) return Natural is
666 (Natural (Shift_Right (GGC, 4) and 16#0f#));
667 Valid_Stolen_Size_Gen4 : constant
668 array (Natural range 1 .. 13) of Stolen_Size_Range :=
669 (1, 4, 8, 16, 32, 48, 64, 128, 256, 96, 160, 224, 352);
670 function Stolen_Size_Gen4 (GGC : Word16) return Stolen_Size_Range is
671 (if GMS_Gen4 (GGC) in Valid_Stolen_Size_Gen4'Range then
Arthur Heymans5fd9a312017-09-12 12:45:18 +0200672 Valid_Stolen_Size_Gen4 (GMS_Gen4 (GGC)) * 2 ** 20 else 0);
Nico Hubereedde882017-07-16 02:54:39 +0200673
674 function GTT_Size_Gen6 (GGC : Word16) return Natural is
675 (Natural (Shift_Right (GGC, 8) and 16#03#) * 2 ** 20);
676
677 function Stolen_Size_Gen6 (GGC : Word16) return Stolen_Size_Range is
678 (Stolen_Size_Range (Shift_Right (GGC, 3) and 16#1f#) * 32 * 2 ** 20);
679
680 function GTT_Size_Gen8 (GGC : Word16) return Natural is
681 (Natural (Shift_Right (GGC, 6) and 16#03#) * 2 ** 20);
682
683 function GMS_Gen8 (GGC : Word16) return Stolen_Size_Range is
684 (Stolen_Size_Range (Shift_Right (GGC, 8) and 16#ff#));
685 function Stolen_Size_Gen8 (GGC : Word16) return Stolen_Size_Range is
686 (GMS_Gen8 (GGC) * 32 * 2 ** 20);
687
688 function Stolen_Size_Gen9 (GGC : Word16) return Stolen_Size_Range is
689 (if GMS_Gen8 (GGC) < 16#f0# then
690 Stolen_Size_Gen8 (GGC)
691 else
692 (GMS_Gen8 (GGC) - 16#f0# + 1) * 4 * 2 ** 20);
693
694 procedure Decode_Stolen
695 (GTT_Size : out Natural;
696 Stolen_Size : out Stolen_Size_Range)
697 with
698 Pre => Is_Initialized
699 is
Nico Huber63ec8362018-06-09 17:42:19 +0200700 GGC_Reg : constant PCI.Index :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200701 (if Config.Gen_G45 or Config.CPU_Ironlake then 16#52# else 16#50#);
Nico Hubereedde882017-07-16 02:54:39 +0200702 GGC : Word16;
703 begin
704 Dev.Read16 (GGC, GGC_Reg);
Nico Huber998ee2b2018-06-12 23:02:17 +0200705 if Config.Gen_G45 or Config.CPU_Ironlake then
706 GTT_Size := GTT_Size_Gen4 (GGC);
707 Stolen_Size := Stolen_Size_Gen4 (GGC);
708 elsif Config.CPU_Sandybridge or Config.CPU_Ivybridge or Config.CPU_Haswell
709 then
710 GTT_Size := GTT_Size_Gen6 (GGC);
711 Stolen_Size := Stolen_Size_Gen6 (GGC);
712 elsif Config.CPU_Broadwell then
713 GTT_Size := GTT_Size_Gen8 (GGC);
714 Stolen_Size := Stolen_Size_Gen8 (GGC);
715 else
716 GTT_Size := GTT_Size_Gen8 (GGC);
717 Stolen_Size := Stolen_Size_Gen9 (GGC);
718 end if;
Nico Hubereedde882017-07-16 02:54:39 +0200719 end Decode_Stolen;
720
721 -- Additional runtime validation that FB fits stolen memory and aperture.
722 procedure Validate_FB (FB : Framebuffer_Type; Valid : out Boolean)
723 with
724 Pre => Is_Initialized,
725 Post => (if Valid then Valid_FB (FB))
726 is
727 GTT_Size, Aperture_Size : Natural;
728 Stolen_Size : Stolen_Size_Range;
729 begin
730 Valid := Valid_FB (FB);
731
732 if Valid then
733 Decode_Stolen (GTT_Size, Stolen_Size);
734 Dev.Resource_Size (Aperture_Size, PCI.Res2);
735 Valid :=
736 FB_Last_Page (FB) < GTT_Size / Config.GTT_PTE_Size and
737 FB_Last_Page (FB) < Natural (Stolen_Size / GTT_Page_Size) and
738 FB_Last_Page (FB) < Aperture_Size / GTT_Page_Size;
Nico Huber34be6542017-12-13 09:26:24 +0100739 pragma Debug (not Valid, Debug.Put_Line
Nico Hubereedde882017-07-16 02:54:39 +0200740 ("Stolen memory too small to hold framebuffer."));
741 end if;
742 end Validate_FB;
743
Nico Huber5374c3a2017-07-15 21:48:06 +0200744 procedure Setup_Default_FB
745 (FB : in Framebuffer_Type;
746 Clear : in Boolean := True;
747 Success : out Boolean)
748 is
749 GMA_Phys_Base : constant PCI.Index := 16#5c#;
750 GMA_Phys_Base_Mask : constant := 16#fff0_0000#;
751
752 Phys_Base : Word32;
753 begin
Nico Hubereedde882017-07-16 02:54:39 +0200754 Validate_FB (FB, Success);
Nico Huber5374c3a2017-07-15 21:48:06 +0200755
756 if Success then
757 Dev.Read32 (Phys_Base, GMA_Phys_Base);
758 Phys_Base := Phys_Base and GMA_Phys_Base_Mask;
759 Success := Phys_Base /= GMA_Phys_Base_Mask and Phys_Base /= 0;
760 pragma Debug (not Success, Debug.Put_Line
761 ("Failed to read stolen memory base."));
Nico Huber0164b022017-08-24 15:12:51 +0200762
763 if Success then
764 if FB.Tiling in XY_Tiling then
765 Registers.Add_Fence
766 (First_Page => FB_First_Page (FB),
767 Last_Page => FB_Last_Page (FB),
768 Tiling => FB.Tiling,
769 Pitch => FB_Pitch (FB.Stride, FB),
770 Success => Success);
771 end if;
772 pragma Debug (not Success, Debug.Put_Line
773 ("Tiled framebuffer but no fence regs available."));
774 end if;
775
Nico Huber5374c3a2017-07-15 21:48:06 +0200776 if Success then
777 Setup_Default_GTT (FB, Phys_Base);
778 end if;
779 end if;
780
781 if Success and then Clear then
782 declare
783 use type HW.Word64;
784 Linear_FB : Word64;
785 begin
Nico Huberc3f66f62017-07-16 21:39:54 +0200786 Map_Linear_FB (Linear_FB, FB);
Nico Huber5374c3a2017-07-15 21:48:06 +0200787 if Linear_FB /= 0 then
Nico Huberc3f66f62017-07-16 21:39:54 +0200788 Framebuffer_Filler.Fill (Linear_FB, FB);
Nico Huber5374c3a2017-07-15 21:48:06 +0200789 end if;
Nico Huber5374c3a2017-07-15 21:48:06 +0200790 end;
791 end if;
792 end Setup_Default_FB;
793
Nico Huberc3f66f62017-07-16 21:39:54 +0200794 procedure Map_Linear_FB (Linear_FB : out Word64; FB : in Framebuffer_Type)
795 is
796 use type HW.Word64;
797
798 Valid : Boolean;
799 begin
800 Linear_FB := 0;
801
802 if Linear_FB_Base = 0 then
803 Dev.Map (Linear_FB_Base, PCI.Res2);
804 pragma Debug
805 (Linear_FB_Base = 0, Debug.Put_Line ("Failed to map resource2."));
806 end if;
807
808 if Linear_FB_Base /= 0 then
809 Validate_FB (FB, Valid);
810 if Valid then
Nico Huber34be6542017-12-13 09:26:24 +0100811 Linear_FB := Linear_FB_Base + Word64 (Phys_Offset (FB));
Nico Huberc3f66f62017-07-16 21:39:54 +0200812 end if;
813 end if;
814 end Map_Linear_FB;
815
Nico Huber5374c3a2017-07-15 21:48:06 +0200816 ----------------------------------------------------------------------------
817
Nico Huber99f10f32016-11-20 00:34:05 +0100818 procedure Dump_Configs (Configs : Pipe_Configs)
Nico Huber83693c82016-10-08 22:17:55 +0200819 is
820 subtype Pipe_Name is String (1 .. 9);
Nico Huber99f10f32016-11-20 00:34:05 +0100821 type Pipe_Name_Array is array (Pipe_Index) of Pipe_Name;
Nico Huber83693c82016-10-08 22:17:55 +0200822 Pipe_Names : constant Pipe_Name_Array :=
823 (Primary => "Primary ",
824 Secondary => "Secondary",
825 Tertiary => "Tertiary ");
Nico Huber5ef4d602017-12-13 13:56:47 +0100826
827 subtype Tiling_Name is String (1 .. 7);
828 type Tiling_Name_Array is array (Tiling_Type) of Tiling_Name;
829 Tilings : constant Tiling_Name_Array :=
830 (Linear => "Linear ",
831 X_Tiled => "X_Tiled",
832 Y_Tiled => "Y_Tiled");
833
834 subtype Rotation_Name is String (1 .. 11);
835 type Rotation_Name_Array is array (Rotation_Type) of Rotation_Name;
836 Rotations : constant Rotation_Name_Array :=
837 (No_Rotation => "No_Rotation",
838 Rotated_90 => "Rotated_90 ",
839 Rotated_180 => "Rotated_180",
840 Rotated_270 => "Rotated_270");
Nico Huber83693c82016-10-08 22:17:55 +0200841 begin
842 Debug.New_Line;
Paul Menzelb83107c2017-05-04 09:02:33 +0200843 Debug.Put_Line ("CONFIG =>");
Nico Huber99f10f32016-11-20 00:34:05 +0100844 for Pipe in Pipe_Index loop
845 if Pipe = Pipe_Index'First then
Nico Huber83693c82016-10-08 22:17:55 +0200846 Debug.Put (" (");
847 else
848 Debug.Put (" ");
849 end if;
850 Debug.Put_Line (Pipe_Names (Pipe) & " =>");
851 Debug.Put_Line
852 (" (Port => " & Port_Names (Configs (Pipe).Port) & ",");
853 Debug.Put_Line (" Framebuffer =>");
Nico Huber5ef4d602017-12-13 13:56:47 +0100854 Debug.Put (" (Width => ");
Nico Huber83693c82016-10-08 22:17:55 +0200855 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Width);
856 Debug.Put_Line (",");
Nico Huber5ef4d602017-12-13 13:56:47 +0100857 Debug.Put (" Height => ");
Nico Huber83693c82016-10-08 22:17:55 +0200858 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Height);
859 Debug.Put_Line (",");
Nico Huber5ef4d602017-12-13 13:56:47 +0100860 Debug.Put (" Start_X => ");
861 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Start_X);
862 Debug.Put_Line (",");
863 Debug.Put (" Start_Y => ");
864 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Start_Y);
865 Debug.Put_Line (",");
866 Debug.Put (" Stride => ");
Nico Huber83693c82016-10-08 22:17:55 +0200867 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Stride);
868 Debug.Put_Line (",");
Nico Huber5ef4d602017-12-13 13:56:47 +0100869 Debug.Put (" V_Stride => ");
870 Debug.Put_Int32 (Configs (Pipe).Framebuffer.V_Stride);
871 Debug.Put_Line (",");
872 Debug.Put (" Tiling => ");
873 Debug.Put_Line (Tilings (Configs (Pipe).Framebuffer.Tiling) & ",");
874 Debug.Put (" Rotation => ");
875 Debug.Put_Line (Rotations (Configs (Pipe).Framebuffer.Rotation) & ",");
Nico Huber83693c82016-10-08 22:17:55 +0200876 Debug.Put (" Offset => ");
877 Debug.Put_Word32 (Configs (Pipe).Framebuffer.Offset);
878 Debug.Put_Line (",");
879 Debug.Put (" BPC => ");
880 Debug.Put_Int64 (Configs (Pipe).Framebuffer.BPC);
881 Debug.Put_Line ("),");
882 Debug.Put_Line (" Mode =>");
883 Debug.Put (" (Dotclock => ");
884 Debug.Put_Int64 (Configs (Pipe).Mode.Dotclock);
885 Debug.Put_Line (",");
886 Debug.Put (" H_Visible => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200887 Debug.Put_Int32 (Configs (Pipe).Mode.H_Visible);
Nico Huber83693c82016-10-08 22:17:55 +0200888 Debug.Put_Line (",");
889 Debug.Put (" H_Sync_Begin => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200890 Debug.Put_Int32 (Configs (Pipe).Mode.H_Sync_Begin);
Nico Huber83693c82016-10-08 22:17:55 +0200891 Debug.Put_Line (",");
892 Debug.Put (" H_Sync_End => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200893 Debug.Put_Int32 (Configs (Pipe).Mode.H_Sync_End);
Nico Huber83693c82016-10-08 22:17:55 +0200894 Debug.Put_Line (",");
895 Debug.Put (" H_Total => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200896 Debug.Put_Int32 (Configs (Pipe).Mode.H_Total);
Nico Huber83693c82016-10-08 22:17:55 +0200897 Debug.Put_Line (",");
898 Debug.Put (" V_Visible => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200899 Debug.Put_Int32 (Configs (Pipe).Mode.V_Visible);
Nico Huber83693c82016-10-08 22:17:55 +0200900 Debug.Put_Line (",");
901 Debug.Put (" V_Sync_Begin => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200902 Debug.Put_Int32 (Configs (Pipe).Mode.V_Sync_Begin);
Nico Huber83693c82016-10-08 22:17:55 +0200903 Debug.Put_Line (",");
904 Debug.Put (" V_Sync_End => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200905 Debug.Put_Int32 (Configs (Pipe).Mode.V_Sync_End);
Nico Huber83693c82016-10-08 22:17:55 +0200906 Debug.Put_Line (",");
907 Debug.Put (" V_Total => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200908 Debug.Put_Int32 (Configs (Pipe).Mode.V_Total);
Nico Huber83693c82016-10-08 22:17:55 +0200909 Debug.Put_Line (",");
910 Debug.Put_Line (" H_Sync_Active_High => " &
911 (if Configs (Pipe).Mode.H_Sync_Active_High
912 then "True,"
913 else "False,"));
914 Debug.Put_Line (" V_Sync_Active_High => " &
915 (if Configs (Pipe).Mode.V_Sync_Active_High
916 then "True,"
917 else "False,"));
918 Debug.Put (" BPC => ");
919 Debug.Put_Int64 (Configs (Pipe).Mode.BPC);
Nico Huber99f10f32016-11-20 00:34:05 +0100920 if Pipe /= Pipe_Index'Last then
Nico Huber83693c82016-10-08 22:17:55 +0200921 Debug.Put_Line (")),");
922 else
923 Debug.Put_Line (")));");
924 end if;
925 end loop;
926 end Dump_Configs;
927
928end HW.GFX.GMA;