blob: 1d97adb87ecb7e599988a6da012d364d22a7875c [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;
24with HW.GFX.GMA.Power_And_Clocks;
25with HW.GFX.GMA.Panel;
26with HW.GFX.GMA.PLLs;
27with HW.GFX.GMA.Port_Detect;
28with HW.GFX.GMA.Connectors;
29with HW.GFX.GMA.Connector_Info;
30with HW.GFX.GMA.Pipe_Setup;
31
Nico Huber83693c82016-10-08 22:17:55 +020032with HW.Debug;
33with GNAT.Source_Info;
34
Nico Huber83693c82016-10-08 22:17:55 +020035use type HW.Int32;
36
37package body HW.GFX.GMA
38 with Refined_State =>
39 (State =>
Nico Huber2b6f6992017-07-09 18:11:34 +020040 (Dev.Address_State,
41 Registers.Address_State,
Nico Huber83693c82016-10-08 22:17:55 +020042 PLLs.State, Panel.Panel_State,
Nico Huber1a712d32017-01-09 15:11:04 +010043 Cur_Configs, Allocated_PLLs,
Nico Huberc3f66f62017-07-16 21:39:54 +020044 HPD_Delay, Wait_For_HPD,
45 Linear_FB_Base),
Nico Huber83693c82016-10-08 22:17:55 +020046 Init_State => Initialized,
Nico Huber30e84082018-06-10 13:28:05 +020047 Config_State => (Config.Variable),
Nico Huber83693c82016-10-08 22:17:55 +020048 Device_State =>
Nico Huber2b6f6992017-07-09 18:11:34 +020049 (Dev.PCI_State, Registers.Register_State, Registers.GTT_State))
Nico Huber83693c82016-10-08 22:17:55 +020050is
Nico Huber2b6f6992017-07-09 18:11:34 +020051 pragma Disable_Atomic_Synchronization;
Nico Huber83693c82016-10-08 22:17:55 +020052
53 subtype Port_Name is String (1 .. 8);
54 type Port_Name_Array is array (Port_Type) of Port_Name;
55 Port_Names : constant Port_Name_Array :=
56 (Disabled => "Disabled",
57 Internal => "Internal",
58 DP1 => "DP1 ",
59 DP2 => "DP2 ",
60 DP3 => "DP3 ",
Nico Huber0d454cd2016-11-21 13:33:43 +010061 HDMI1 => "HDMI1 ",
62 HDMI2 => "HDMI2 ",
63 HDMI3 => "HDMI3 ",
Nico Huber83693c82016-10-08 22:17:55 +020064 Analog => "Analog ");
65
Nico Huber2b6f6992017-07-09 18:11:34 +020066 package Dev is new HW.PCI.Dev (PCI.Address'(0, 2, 0));
67
Nico Huber83693c82016-10-08 22:17:55 +020068 package Display_Controller renames Pipe_Setup;
69
Nico Huber99f10f32016-11-20 00:34:05 +010070 type PLLs_Type is array (Pipe_Index) of PLLs.T;
Nico Huber83693c82016-10-08 22:17:55 +020071
Nico Huber83693c82016-10-08 22:17:55 +020072 type HPD_Type is array (Port_Type) of Boolean;
Nico Huber3be61d42017-01-09 13:58:18 +010073 type HPD_Delay_Type is array (Active_Port_Type) of Time.T;
Nico Huber83693c82016-10-08 22:17:55 +020074
Nico Huber83693c82016-10-08 22:17:55 +020075 Allocated_PLLs : PLLs_Type;
Nico Huber83693c82016-10-08 22:17:55 +020076 HPD_Delay : HPD_Delay_Type;
77 Wait_For_HPD : HPD_Type;
78 Initialized : Boolean := False;
79
Nico Huberc3f66f62017-07-16 21:39:54 +020080 Linear_FB_Base : Word64;
81
Nico Huber83693c82016-10-08 22:17:55 +020082 ----------------------------------------------------------------------------
83
Nico Huberf54d0962016-10-20 14:17:18 +020084 PCH_RAWCLK_FREQ_MASK : constant := 16#3ff# * 2 ** 0;
85
86 function PCH_RAWCLK_FREQ (Freq : Frequency_Type) return Word32
87 is
88 begin
89 return Word32 (Freq / 1_000_000);
90 end PCH_RAWCLK_FREQ;
91
92 ----------------------------------------------------------------------------
93
Nico Huber43370ba2017-01-09 15:26:19 +010094 procedure Enable_Output
95 (Pipe : in Pipe_Index;
96 Pipe_Cfg : in Pipe_Config;
97 Success : out Boolean)
Nico Huber8a5a3b52018-06-04 14:42:13 +020098 with
99 Pre => Pipe_Cfg.Port in Active_Port_Type
Nico Huber43370ba2017-01-09 15:26:19 +0100100 is
101 Port_Cfg : Port_Config;
Nico Huberf361ec82018-06-02 18:01:45 +0200102 Scaler_Available : Boolean;
Nico Huber43370ba2017-01-09 15:26:19 +0100103 begin
Nico Huber3be61d42017-01-09 13:58:18 +0100104 pragma Debug (Debug.New_Line);
105 pragma Debug (Debug.Put_Line
106 ("Trying to enable port " & Port_Names (Pipe_Cfg.Port)));
107
Nico Huber43370ba2017-01-09 15:26:19 +0100108 Config_Helpers.Fill_Port_Config
109 (Port_Cfg, Pipe, Pipe_Cfg.Port, Pipe_Cfg.Mode, Success);
110
111 if Success then
Nico Huberf361ec82018-06-02 18:01:45 +0200112 Display_Controller.Scaler_Available (Scaler_Available, Pipe);
Nico Huber43370ba2017-01-09 15:26:19 +0100113 Success := Config_Helpers.Validate_Config
Nico Huberf361ec82018-06-02 18:01:45 +0200114 (Pipe_Cfg.Framebuffer, Port_Cfg.Mode, Pipe, Scaler_Available);
Nico Huber43370ba2017-01-09 15:26:19 +0100115 end if;
116
Nico Huber43370ba2017-01-09 15:26:19 +0100117 if Success then
Nico Huber43370ba2017-01-09 15:26:19 +0100118 Connector_Info.Preferred_Link_Setting (Port_Cfg, Success);
119 end if;
120
121 -- loop over all possible DP-lane configurations
122 -- (non-DP ports use a single fake configuration)
123 while Success loop
124 pragma Loop_Invariant
125 (Pipe_Cfg.Port in Active_Port_Type and
126 Port_Cfg.Mode = Port_Cfg.Mode'Loop_Entry);
127
128 PLLs.Alloc
129 (Port_Cfg => Port_Cfg,
130 PLL => Allocated_PLLs (Pipe),
131 Success => Success);
132
133 if Success then
134 -- try each DP-lane configuration twice
135 for Try in 1 .. 2 loop
136 pragma Loop_Invariant
137 (Pipe_Cfg.Port in Active_Port_Type);
138
Nico Huber4798c662017-01-11 12:44:48 +0100139 -- Clear pending hot-plug events before every try
140 Port_Detect.Clear_Hotplug_Detect (Pipe_Cfg.Port);
141
Nico Huber43370ba2017-01-09 15:26:19 +0100142 Connectors.Pre_On
143 (Pipe => Pipe,
144 Port_Cfg => Port_Cfg,
145 PLL_Hint => PLLs.Register_Value (Allocated_PLLs (Pipe)),
146 Success => Success);
147
148 if Success then
149 Display_Controller.On
150 (Pipe => Pipe,
151 Port_Cfg => Port_Cfg,
Nico Huber4dc4c612018-01-10 15:55:09 +0100152 Framebuffer => Pipe_Cfg.Framebuffer,
153 Cursor => Pipe_Cfg.Cursor);
Nico Huber43370ba2017-01-09 15:26:19 +0100154
155 Connectors.Post_On
Arthur Heymans60d0e5f2018-03-28 17:08:27 +0200156 (Pipe => Pipe,
157 Port_Cfg => Port_Cfg,
Nico Huber43370ba2017-01-09 15:26:19 +0100158 PLL_Hint => PLLs.Register_Value (Allocated_PLLs (Pipe)),
159 Success => Success);
160
161 if not Success then
162 Display_Controller.Off (Pipe);
163 Connectors.Post_Off (Port_Cfg);
164 end if;
165 end if;
166
167 exit when Success;
168 end loop;
169 exit when Success; -- connection established => stop loop
170
171 -- connection failed
172 PLLs.Free (Allocated_PLLs (Pipe));
173 end if;
174
175 Connector_Info.Next_Link_Setting (Port_Cfg, Success);
176 end loop;
177
178 if Success then
179 pragma Debug (Debug.Put_Line
180 ("Enabled port " & Port_Names (Pipe_Cfg.Port)));
181 else
182 Wait_For_HPD (Pipe_Cfg.Port) := True;
183 if Pipe_Cfg.Port = Internal then
184 Panel.Off;
185 end if;
186 end if;
187 end Enable_Output;
188
Nico Huber3be61d42017-01-09 13:58:18 +0100189 procedure Disable_Output (Pipe : Pipe_Index; Pipe_Cfg : Pipe_Config)
190 is
191 Port_Cfg : Port_Config;
192 Success : Boolean;
193 begin
194 Config_Helpers.Fill_Port_Config
195 (Port_Cfg, Pipe, Pipe_Cfg.Port, Pipe_Cfg.Mode, Success);
196 if Success then
197 pragma Debug (Debug.New_Line);
198 pragma Debug (Debug.Put_Line
199 ("Disabling port " & Port_Names (Pipe_Cfg.Port)));
200 pragma Debug (Debug.New_Line);
201
202 Connectors.Pre_Off (Port_Cfg);
203 Display_Controller.Off (Pipe);
204 Connectors.Post_Off (Port_Cfg);
205
206 PLLs.Free (Allocated_PLLs (Pipe));
207 end if;
208 end Disable_Output;
209
Nico Huber99f10f32016-11-20 00:34:05 +0100210 procedure Update_Outputs (Configs : Pipe_Configs)
Nico Huber83693c82016-10-08 22:17:55 +0200211 is
Nico Huber3be61d42017-01-09 13:58:18 +0100212 procedure Check_HPD (Port : in Active_Port_Type; Detected : out Boolean)
213 is
214 HPD_Delay_Over : constant Boolean := Time.Timed_Out (HPD_Delay (Port));
215 begin
216 if HPD_Delay_Over then
217 Port_Detect.Hotplug_Detect (Port, Detected);
218 HPD_Delay (Port) := Time.MS_From_Now (333);
219 else
220 Detected := False;
221 end if;
222 end Check_HPD;
Nico Huberb56b9c52017-01-11 15:12:23 +0100223
Nico Huber564103f2017-01-11 15:33:07 +0100224 Power_Changed : Boolean := False;
Nico Huberb56b9c52017-01-11 15:12:23 +0100225 Old_Configs : Pipe_Configs;
Nico Huber564103f2017-01-11 15:33:07 +0100226
227 -- Only called when we actually tried to change something
228 -- so we don't congest the log with unnecessary messages.
229 procedure Update_Power
230 is
231 begin
232 if not Power_Changed then
233 Power_And_Clocks.Power_Up (Old_Configs, Configs);
234 Power_Changed := True;
235 end if;
236 end Update_Power;
Nico Huber3d06de82018-05-29 01:35:04 +0200237
238 function Full_Update (Cur_Config, New_Config : Pipe_Config) return Boolean
239 is
240 begin
241 return
Nico Huber958c5642018-06-02 16:59:31 +0200242 Cur_Config.Port /= New_Config.Port
243 or else
244 Cur_Config.Mode /= New_Config.Mode
245 or else
Nico Huber3d06de82018-05-29 01:35:04 +0200246 (Config.Use_PDW_For_EDP_Scaling and then
247 (Cur_Config.Port = Internal and
Nico Huber958c5642018-06-02 16:59:31 +0200248 Requires_Scaling (Cur_Config) /= Requires_Scaling (New_Config)))
249 or else
250 (Config.Has_GMCH_PFIT_CONTROL and then
251 (Requires_Scaling (Cur_Config) /= Requires_Scaling (New_Config) or
252 Scaling_Type (Cur_Config) /= Scaling_Type (New_Config)));
Nico Huber3d06de82018-05-29 01:35:04 +0200253 end Full_Update;
Nico Huber83693c82016-10-08 22:17:55 +0200254 begin
255 Old_Configs := Cur_Configs;
256
Nico Huberb56b9c52017-01-11 15:12:23 +0100257 -- disable all pipes that changed or had a hot-plug event
258 for Pipe in Pipe_Index loop
259 declare
260 Unplug_Detected : Boolean;
261 Cur_Config : Pipe_Config renames Cur_Configs (Pipe);
262 New_Config : Pipe_Config renames Configs (Pipe);
263 begin
264 if Cur_Config.Port /= Disabled then
265 Check_HPD (Cur_Config.Port, Unplug_Detected);
Nico Huber83693c82016-10-08 22:17:55 +0200266
Nico Huber3d06de82018-05-29 01:35:04 +0200267 if Full_Update (Cur_Config, New_Config) or Unplug_Detected then
Nico Huberb56b9c52017-01-11 15:12:23 +0100268 Disable_Output (Pipe, Cur_Config);
269 Cur_Config.Port := Disabled;
Nico Huber564103f2017-01-11 15:33:07 +0100270 Update_Power;
Nico Huberb56b9c52017-01-11 15:12:23 +0100271 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200272 end if;
Nico Huberb56b9c52017-01-11 15:12:23 +0100273 end;
274 end loop;
Nico Huber83693c82016-10-08 22:17:55 +0200275
Nico Huberb56b9c52017-01-11 15:12:23 +0100276 -- enable all pipes that changed and should be active
277 for Pipe in Pipe_Index loop
278 declare
279 Success : Boolean;
Nico Huberf361ec82018-06-02 18:01:45 +0200280 Scaler_Available : Boolean;
Nico Huberb56b9c52017-01-11 15:12:23 +0100281 Cur_Config : Pipe_Config renames Cur_Configs (Pipe);
282 New_Config : Pipe_Config renames Configs (Pipe);
283 begin
Nico Huber3d06de82018-05-29 01:35:04 +0200284 if New_Config.Port /= Disabled and
285 Full_Update (Cur_Config, New_Config)
Nico Huberb56b9c52017-01-11 15:12:23 +0100286 then
Nico Huber3be61d42017-01-09 13:58:18 +0100287 if Wait_For_HPD (New_Config.Port) then
288 Check_HPD (New_Config.Port, Success);
289 Wait_For_HPD (New_Config.Port) := not Success;
290 else
291 Success := True;
Nico Huber8c45bcf2016-11-20 17:30:57 +0100292 end if;
Nico Huberc7a4fee2016-11-03 18:18:03 +0100293
Nico Huber3be61d42017-01-09 13:58:18 +0100294 if Success then
Nico Huber564103f2017-01-11 15:33:07 +0100295 Update_Power;
Nico Huberb56b9c52017-01-11 15:12:23 +0100296 Enable_Output (Pipe, New_Config, Success);
Nico Huber3be61d42017-01-09 13:58:18 +0100297 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200298
299 if Success then
Nico Huberb56b9c52017-01-11 15:12:23 +0100300 Cur_Config := New_Config;
Nico Huber83693c82016-10-08 22:17:55 +0200301 end if;
Nico Huber3be61d42017-01-09 13:58:18 +0100302
Nico Huberb56b9c52017-01-11 15:12:23 +0100303 -- update framebuffer offset only
304 elsif New_Config.Port /= Disabled and
Nico Huberf361ec82018-06-02 18:01:45 +0200305 Cur_Config.Framebuffer /= New_Config.Framebuffer
Nico Huberb56b9c52017-01-11 15:12:23 +0100306 then
Nico Huberf361ec82018-06-02 18:01:45 +0200307 Display_Controller.Scaler_Available (Scaler_Available, Pipe);
308 if Config_Helpers.Validate_Config
309 (New_Config.Framebuffer, New_Config.Mode,
310 Pipe, Scaler_Available)
311 then
312 Display_Controller.Setup_FB
313 (Pipe, New_Config.Mode, New_Config.Framebuffer);
314 Display_Controller.Update_Cursor
315 (Pipe, New_Config.Framebuffer, New_Config.Cursor);
316 Cur_Config := New_Config;
317 end if;
Nico Huberb56b9c52017-01-11 15:12:23 +0100318 end if;
319 end;
Nico Huber83693c82016-10-08 22:17:55 +0200320 end loop;
321
Nico Huber564103f2017-01-11 15:33:07 +0100322 if Power_Changed then
Nico Huber83693c82016-10-08 22:17:55 +0200323 Power_And_Clocks.Power_Down (Old_Configs, Configs, Cur_Configs);
324 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200325 end Update_Outputs;
326
327 ----------------------------------------------------------------------------
328
Nico Huber15ffc4f2018-01-11 14:44:43 +0100329 procedure Update_Cursor (Pipe : Pipe_Index; Cursor : Cursor_Type)
330 is
331 begin
332 Cur_Configs (Pipe).Cursor := Cursor;
333 Display_Controller.Update_Cursor
334 (Pipe, Cur_Configs (Pipe).Framebuffer, Cur_Configs (Pipe).Cursor);
335 end Update_Cursor;
336
337 procedure Place_Cursor
338 (Pipe : Pipe_Index;
339 X : Cursor_Pos;
340 Y : Cursor_Pos)
341 is
342 begin
343 Cur_Configs (Pipe).Cursor.Center_X := X;
344 Cur_Configs (Pipe).Cursor.Center_Y := Y;
345 Display_Controller.Place_Cursor
346 (Pipe, Cur_Configs (Pipe).Framebuffer, Cur_Configs (Pipe).Cursor);
347 end Place_Cursor;
348
349 procedure Move_Cursor
350 (Pipe : Pipe_Index;
351 X : Cursor_Pos;
352 Y : Cursor_Pos)
353 is
354 function Cap_Add (A, B : Cursor_Pos) return Cursor_Pos is
355 (if A + B < 0
356 then Int32'Max (Cursor_Pos'First, A + B)
357 else Int32'Min (Cursor_Pos'Last, A + B));
358 begin
359 Place_Cursor
360 (Pipe => Pipe,
361 X => Cap_Add (Cur_Configs (Pipe).Cursor.Center_X, X),
362 Y => Cap_Add (Cur_Configs (Pipe).Cursor.Center_Y, Y));
363 end Move_Cursor;
364
365 ----------------------------------------------------------------------------
366
Nico Huber83693c82016-10-08 22:17:55 +0200367 procedure Initialize
Nico Huber2b6f6992017-07-09 18:11:34 +0200368 (Write_Delay : in Word64 := 0;
Nico Huber793a8d42016-11-21 18:57:03 +0100369 Clean_State : in Boolean := False;
Nico Huber83693c82016-10-08 22:17:55 +0200370 Success : out Boolean)
371 with
372 Refined_Global =>
Nico Huber27088aa2018-06-10 13:28:05 +0200373 (Input => (Time.State),
374 In_Out => (Dev.PCI_State, Registers.Register_State, Port_IO.State),
Nico Huber83693c82016-10-08 22:17:55 +0200375 Output =>
Nico Huber27088aa2018-06-10 13:28:05 +0200376 (Config.Variable,
377 Dev.Address_State,
Nico Huber2b6f6992017-07-09 18:11:34 +0200378 Registers.Address_State,
Nico Huber83693c82016-10-08 22:17:55 +0200379 PLLs.State, Panel.Panel_State,
Nico Huber1a712d32017-01-09 15:11:04 +0100380 Cur_Configs, Allocated_PLLs,
Nico Huberc3f66f62017-07-16 21:39:54 +0200381 HPD_Delay, Wait_For_HPD,
382 Linear_FB_Base, Initialized))
Nico Huber83693c82016-10-08 22:17:55 +0200383 is
384 use type HW.Word64;
385
Nico Huber0b2329a2018-06-09 21:14:27 +0200386 function MMIO_GTT_Offset return Natural is
387 (if Config.Has_64bit_GTT
388 then Registers.MMIO_GTT_64_Offset
389 else Registers.MMIO_GTT_32_Offset);
Nico Huber2b6f6992017-07-09 18:11:34 +0200390 PCI_MMIO_Base, PCI_GTT_Base : Word64;
391
Nico Huber83693c82016-10-08 22:17:55 +0200392 Now : constant Time.T := Time.Now;
393
394 procedure Check_Platform (Success : out Boolean)
395 is
396 Audio_VID_DID : Word32;
397 begin
Nico Huber6621a142018-06-07 23:56:54 +0200398 case Config.Gen is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200399 when G45 =>
400 Registers.Read (Registers.G4X_AUD_VID_DID, Audio_VID_DID);
Nico Huber6621a142018-06-07 23:56:54 +0200401 when Ironlake =>
402 Registers.Read (Registers.PCH_AUD_VID_DID, Audio_VID_DID);
Nico Huber83693c82016-10-08 22:17:55 +0200403 when Haswell .. Skylake =>
404 Registers.Read (Registers.AUD_VID_DID, Audio_VID_DID);
Nico Huber83693c82016-10-08 22:17:55 +0200405 end case;
406 Success :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200407 ((Config.Gen_Broxton and Audio_VID_DID = 16#8086_280a#) or
408 (Config.Gen_Skylake and Audio_VID_DID = 16#8086_2809#) or
409 (Config.CPU_Broadwell and Audio_VID_DID = 16#8086_2808#) or
410 (Config.CPU_Haswell and Audio_VID_DID = 16#8086_2807#) or
411 ((Config.CPU_Ivybridge or
412 Config.CPU_Sandybridge) and (Audio_VID_DID = 16#8086_2806# or
413 Audio_VID_DID = 16#8086_2805#)) or
414 (Config.CPU_Ironlake and Audio_VID_DID = 16#0000_0000#) or
415 (Config.Gen_G45 and (Audio_VID_DID = 16#8086_2801# or
416 Audio_VID_DID = 16#8086_2802# or
417 Audio_VID_DID = 16#8086_2803#)));
Nico Huber83693c82016-10-08 22:17:55 +0200418 end Check_Platform;
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200419
420 procedure Check_Platform_PCI (Success : out Boolean)
421 is
422 use type HW.Word16;
423 Vendor, Device : Word16;
424 begin
425 Dev.Read16 (Vendor, PCI.Vendor_Id);
426 Dev.Read16 (Device, PCI.Device_Id);
427
428 Success := Vendor = 16#8086# and Config.Compatible_GPU (Device);
429 end Check_Platform_PCI;
Nico Huber83693c82016-10-08 22:17:55 +0200430 begin
Nico Huber83693c82016-10-08 22:17:55 +0200431 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
432
433 pragma Debug (Debug.Set_Register_Write_Delay (Write_Delay));
434
Nico Huberc3f66f62017-07-16 21:39:54 +0200435 Linear_FB_Base := 0;
Nico Huber83693c82016-10-08 22:17:55 +0200436 Wait_For_HPD := HPD_Type'(others => False);
437 HPD_Delay := HPD_Delay_Type'(others => Now);
Nico Huber83693c82016-10-08 22:17:55 +0200438 Allocated_PLLs := (others => PLLs.Invalid);
Nico Huber99f10f32016-11-20 00:34:05 +0100439 Cur_Configs := Pipe_Configs'
440 (others => Pipe_Config'
Nico Huber83693c82016-10-08 22:17:55 +0200441 (Port => Disabled,
442 Framebuffer => HW.GFX.Default_FB,
Nico Hubera02b2c62018-01-09 15:58:34 +0100443 Cursor => Default_Cursor,
Nico Huber83693c82016-10-08 22:17:55 +0200444 Mode => HW.GFX.Invalid_Mode));
Nico Huber27088aa2018-06-10 13:28:05 +0200445 Config.Variable := Config.Initial_Settings;
Nico Huber83693c82016-10-08 22:17:55 +0200446 PLLs.Initialize;
447
Nico Huber2b6f6992017-07-09 18:11:34 +0200448 Dev.Initialize (Success);
449
450 if Success then
Nico Huber0b2329a2018-06-09 21:14:27 +0200451 Dev.Map (PCI_MMIO_Base, PCI.Res0, Length => MMIO_GTT_Offset);
452 Dev.Map (PCI_GTT_Base, PCI.Res0, Offset => MMIO_GTT_Offset);
Nico Huber2b6f6992017-07-09 18:11:34 +0200453 if PCI_MMIO_Base /= 0 and PCI_GTT_Base /= 0 then
454 Registers.Set_Register_Base (PCI_MMIO_Base, PCI_GTT_Base);
455 else
456 pragma Debug (Debug.Put_Line
457 ("ERROR: Couldn't map resoure0."));
458 Registers.Set_Register_Base (Config.Default_MMIO_Base);
459 Success := Config.Default_MMIO_Base_Set;
460 end if;
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200461
462 if Success then
463 Check_Platform_PCI (Success);
464 end if;
Nico Huber2b6f6992017-07-09 18:11:34 +0200465 else
466 pragma Debug (Debug.Put_Line
467 ("WARNING: Couldn't initialize PCI dev."));
468 Registers.Set_Register_Base (Config.Default_MMIO_Base);
469 Success := Config.Default_MMIO_Base_Set;
Nico Huber2b6f6992017-07-09 18:11:34 +0200470
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200471 if Success then
472 Check_Platform (Success);
473 end if;
Nico Huber2b6f6992017-07-09 18:11:34 +0200474 end if;
475
Nico Huber83693c82016-10-08 22:17:55 +0200476 if not Success then
477 pragma Debug (Debug.Put_Line ("ERROR: Incompatible CPU or PCH."));
478
479 Panel.Static_Init; -- for flow analysis
480
481 Initialized := False;
482 return;
483 end if;
484
485 Panel.Setup_PP_Sequencer;
486 Port_Detect.Initialize;
Nico Huber0923b792017-06-09 15:28:41 +0200487 Connectors.Initialize;
Nico Huber83693c82016-10-08 22:17:55 +0200488
Nico Huber793a8d42016-11-21 18:57:03 +0100489 if Clean_State then
490 Power_And_Clocks.Pre_All_Off;
491 Connectors.Pre_All_Off;
492 Display_Controller.All_Off;
493 Connectors.Post_All_Off;
494 PLLs.All_Off;
495 Power_And_Clocks.Post_All_Off;
Nico Huber17d64b62017-07-15 20:51:25 +0200496 Registers.Clear_Fences;
Nico Huber33912aa2016-12-06 20:36:23 +0100497 else
498 -- According to PRMs, VGA plane is the only thing
Nico Huber3a0e2a02017-07-19 14:41:46 +0200499 -- that's enabled by default after reset...
Nico Huber33912aa2016-12-06 20:36:23 +0100500 Display_Controller.Legacy_VGA_Off;
Nico Huber3a0e2a02017-07-19 14:41:46 +0200501 -- ... along with some DDI port bits since Skylake.
502 Connectors.Post_Reset_Off;
Nico Huber793a8d42016-11-21 18:57:03 +0100503 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200504
505 -------------------- Now restart from a clean state ---------------------
506 Power_And_Clocks.Initialize;
507
Nico Huber1c3b9282017-02-09 13:57:04 +0100508 if Config.Has_PCH then
509 Registers.Unset_And_Set_Mask
510 (Register => Registers.PCH_RAWCLK_FREQ,
511 Mask_Unset => PCH_RAWCLK_FREQ_MASK,
512 Mask_Set => PCH_RAWCLK_FREQ (Config.Default_RawClk_Freq));
513 end if;
Nico Huberf54d0962016-10-20 14:17:18 +0200514
Nico Huber83693c82016-10-08 22:17:55 +0200515 Initialized := True;
516
517 end Initialize;
518
519 function Is_Initialized return Boolean
520 with
521 Refined_Post => Is_Initialized'Result = Initialized
522 is
523 begin
524 return Initialized;
525 end Is_Initialized;
526
527 ----------------------------------------------------------------------------
528
Nico Hubercf88f3d2018-06-05 13:27:34 +0200529 pragma Warnings
530 (GNATprove, Off, """Registers.Register_State"" * is not modified*",
531 Reason => "Power_Up_VGA is only effective on certain generations.");
Nico Huber42fb2d02017-09-01 17:01:51 +0200532 procedure Power_Up_VGA
Nico Hubercf88f3d2018-06-05 13:27:34 +0200533 with
534 Refined_Global =>
535 (Input => (Cur_Configs, Time.State),
536 In_Out => (Registers.Register_State),
537 Proof_In => (Initialized))
Nico Huber42fb2d02017-09-01 17:01:51 +0200538 is
539 Fake_Config : constant Pipe_Configs :=
540 (Primary =>
541 (Port => Analog,
542 Framebuffer => HW.GFX.Default_FB,
Nico Hubera02b2c62018-01-09 15:58:34 +0100543 Cursor => Default_Cursor,
Nico Huber42fb2d02017-09-01 17:01:51 +0200544 Mode => HW.GFX.Invalid_Mode),
545 others =>
546 (Port => Disabled,
547 Framebuffer => HW.GFX.Default_FB,
Nico Hubera02b2c62018-01-09 15:58:34 +0100548 Cursor => Default_Cursor,
Nico Huber42fb2d02017-09-01 17:01:51 +0200549 Mode => HW.GFX.Invalid_Mode));
550 begin
551 Power_And_Clocks.Power_Up (Cur_Configs, Fake_Config);
552 end Power_Up_VGA;
Nico Hubercf88f3d2018-06-05 13:27:34 +0200553 pragma Warnings
554 (GNATprove, Off, "no check message justified*", Reason => "see below");
555 pragma Annotate
556 (GNATprove, Intentional, "unused global",
557 "Power_Up_VGA is only effective on certain generations.");
558 pragma Warnings (GNATprove, On, "no check message justified*");
559 pragma Warnings
560 (GNATprove, On, """Registers.Register_State"" * is not modified*");
Nico Huber42fb2d02017-09-01 17:01:51 +0200561
562 ----------------------------------------------------------------------------
563
Nico Huber5374c3a2017-07-15 21:48:06 +0200564 function FB_First_Page (FB : Framebuffer_Type) return Natural is
Nico Huber34be6542017-12-13 09:26:24 +0100565 (Natural (Phys_Offset (FB) / GTT_Page_Size));
Nico Huber5374c3a2017-07-15 21:48:06 +0200566 function FB_Pages (FB : Framebuffer_Type) return Natural is
567 (Natural (Div_Round_Up (FB_Size (FB), GTT_Page_Size)));
568 function FB_Last_Page (FB : Framebuffer_Type) return Natural is
569 (FB_First_Page (FB) + FB_Pages (FB) - 1);
570
Nico Huber34be6542017-12-13 09:26:24 +0100571 -- Check basics and that it fits in GTT. For 90 degree rotations,
572 -- the Offset should be above GTT_Rotation_Offset. The latter will
573 -- be subtracted for the aperture mapping.
Nico Huber5374c3a2017-07-15 21:48:06 +0200574 function Valid_FB (FB : Framebuffer_Type) return Boolean is
Nico Huber34be6542017-12-13 09:26:24 +0100575 (Valid_Stride (FB) and
576 FB_First_Page (FB) in GTT_Range and
577 FB_Last_Page (FB) in GTT_Range and
578 (not Rotation_90 (FB) or
579 (FB_Last_Page (FB) + GTT_Rotation_Offset in GTT_Range and
580 FB.Offset >= Word32 (GTT_Rotation_Offset) * GTT_Page_Size)));
Nico Huber5374c3a2017-07-15 21:48:06 +0200581
582 -- Also check that we don't overflow the GTT's 39-bit space
583 -- (always true with a 32-bit base)
584 function Valid_Phys_FB (FB : Framebuffer_Type; Phys_Base : Word32)
585 return Boolean is
586 (Valid_FB (FB) and
Nico Huber34be6542017-12-13 09:26:24 +0100587 Int64 (Phys_Base) + Int64 (Phys_Offset (FB)) + Int64 (FB_Size (FB)) <=
Nico Huber5374c3a2017-07-15 21:48:06 +0200588 Int64 (GTT_Address_Type'Last))
589 with
590 Ghost;
591
Nico Huber83693c82016-10-08 22:17:55 +0200592 procedure Write_GTT
593 (GTT_Page : GTT_Range;
594 Device_Address : GTT_Address_Type;
Nico Huber5374c3a2017-07-15 21:48:06 +0200595 Valid : Boolean)
596 is
Nico Huber83693c82016-10-08 22:17:55 +0200597 begin
598 Registers.Write_GTT (GTT_Page, Device_Address, Valid);
599 end Write_GTT;
600
Nico Huberceda17d2018-06-09 22:00:29 +0200601 procedure Read_GTT
602 (Device_Address : out GTT_Address_Type;
603 Valid : out Boolean;
604 GTT_Page : in GTT_Range)
605 is
606 begin
607 Registers.Read_GTT (Device_Address, Valid, GTT_Page);
608 end Read_GTT;
609
Nico Huber194e57e2017-07-15 21:15:46 +0200610 procedure Setup_Default_GTT (FB : Framebuffer_Type; Phys_Base : Word32)
Nico Huber5374c3a2017-07-15 21:48:06 +0200611 with
612 Pre => Is_Initialized and Valid_Phys_FB (FB, Phys_Base)
Nico Huber83693c82016-10-08 22:17:55 +0200613 is
Nico Huber194e57e2017-07-15 21:15:46 +0200614 Phys_Addr : GTT_Address_Type :=
Nico Huber34be6542017-12-13 09:26:24 +0100615 GTT_Address_Type (Phys_Base) + GTT_Address_Type (Phys_Offset (FB));
Nico Huber83693c82016-10-08 22:17:55 +0200616 begin
Nico Huber194e57e2017-07-15 21:15:46 +0200617 for Idx in FB_First_Page (FB) .. FB_Last_Page (FB) loop
Nico Huber83693c82016-10-08 22:17:55 +0200618 Registers.Write_GTT
619 (GTT_Page => Idx,
620 Device_Address => Phys_Addr,
621 Valid => True);
Nico Huber194e57e2017-07-15 21:15:46 +0200622 Phys_Addr := Phys_Addr + GTT_Page_Size;
Nico Huber83693c82016-10-08 22:17:55 +0200623 end loop;
Nico Huber9b479412017-08-27 11:55:56 +0200624
625 if Rotation_90 (FB) and FB.Tiling = Y_Tiled and FB.V_Stride >= 32 then
626 declare
627 V_Pages : constant Natural := Natural (FB.V_Stride) / 32;
628 Bytes_Per_Row : constant GTT_Address_Type :=
629 GTT_Address_Type (Pixel_To_Bytes (32 * FB.Stride, FB));
630 begin
631 Phys_Addr := GTT_Address_Type (Phys_Base) +
Nico Huber34be6542017-12-13 09:26:24 +0100632 GTT_Address_Type (Phys_Offset (FB)) +
Nico Huber9b479412017-08-27 11:55:56 +0200633 GTT_Address_Type (FB_Size (FB));
634 for Page in FB_First_Page (FB) .. FB_Last_Page (FB) loop
635 Phys_Addr := Phys_Addr - Bytes_Per_Row;
636 Registers.Write_GTT
637 (GTT_Page => GTT_Rotation_Offset + Page,
638 Device_Address => Phys_Addr,
639 Valid => True);
640
641 if (Page - FB_First_Page (FB) + 1) mod V_Pages = 0 then
642 Phys_Addr := Phys_Addr + GTT_Page_Size +
643 GTT_Address_Type (V_Pages) * Bytes_Per_Row;
644 end if;
645 end loop;
646 end;
647 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200648 end Setup_Default_GTT;
649
650 ----------------------------------------------------------------------------
651
Nico Hubereedde882017-07-16 02:54:39 +0200652 use type HW.Word16;
653 subtype Stolen_Size_Range is Int64 range 0 .. 2 ** 33;
654
655 function GGMS_Gen4 (GGC : Word16) return Natural is
656 (Natural (Shift_Right (GGC, 8) and 16#07#));
657 function GTT_Size_Gen4 (GGC : Word16) return Natural is
658 (if GGMS_Gen4 (GGC) in 1 .. 3 then
659 (GGMS_Gen4 (GGC) + 1) * 2 ** 19 else 0);
660
661 function GMS_Gen4 (GGC : Word16) return Natural is
662 (Natural (Shift_Right (GGC, 4) and 16#0f#));
663 Valid_Stolen_Size_Gen4 : constant
664 array (Natural range 1 .. 13) of Stolen_Size_Range :=
665 (1, 4, 8, 16, 32, 48, 64, 128, 256, 96, 160, 224, 352);
666 function Stolen_Size_Gen4 (GGC : Word16) return Stolen_Size_Range is
667 (if GMS_Gen4 (GGC) in Valid_Stolen_Size_Gen4'Range then
Arthur Heymans5fd9a312017-09-12 12:45:18 +0200668 Valid_Stolen_Size_Gen4 (GMS_Gen4 (GGC)) * 2 ** 20 else 0);
Nico Hubereedde882017-07-16 02:54:39 +0200669
670 function GTT_Size_Gen6 (GGC : Word16) return Natural is
671 (Natural (Shift_Right (GGC, 8) and 16#03#) * 2 ** 20);
672
673 function Stolen_Size_Gen6 (GGC : Word16) return Stolen_Size_Range is
674 (Stolen_Size_Range (Shift_Right (GGC, 3) and 16#1f#) * 32 * 2 ** 20);
675
676 function GTT_Size_Gen8 (GGC : Word16) return Natural is
677 (Natural (Shift_Right (GGC, 6) and 16#03#) * 2 ** 20);
678
679 function GMS_Gen8 (GGC : Word16) return Stolen_Size_Range is
680 (Stolen_Size_Range (Shift_Right (GGC, 8) and 16#ff#));
681 function Stolen_Size_Gen8 (GGC : Word16) return Stolen_Size_Range is
682 (GMS_Gen8 (GGC) * 32 * 2 ** 20);
683
684 function Stolen_Size_Gen9 (GGC : Word16) return Stolen_Size_Range is
685 (if GMS_Gen8 (GGC) < 16#f0# then
686 Stolen_Size_Gen8 (GGC)
687 else
688 (GMS_Gen8 (GGC) - 16#f0# + 1) * 4 * 2 ** 20);
689
690 procedure Decode_Stolen
691 (GTT_Size : out Natural;
692 Stolen_Size : out Stolen_Size_Range)
693 with
694 Pre => Is_Initialized
695 is
Nico Huber63ec8362018-06-09 17:42:19 +0200696 GGC_Reg : constant PCI.Index :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200697 (if Config.Gen_G45 or Config.CPU_Ironlake then 16#52# else 16#50#);
Nico Hubereedde882017-07-16 02:54:39 +0200698 GGC : Word16;
699 begin
700 Dev.Read16 (GGC, GGC_Reg);
Nico Huber998ee2b2018-06-12 23:02:17 +0200701 if Config.Gen_G45 or Config.CPU_Ironlake then
702 GTT_Size := GTT_Size_Gen4 (GGC);
703 Stolen_Size := Stolen_Size_Gen4 (GGC);
704 elsif Config.CPU_Sandybridge or Config.CPU_Ivybridge or Config.CPU_Haswell
705 then
706 GTT_Size := GTT_Size_Gen6 (GGC);
707 Stolen_Size := Stolen_Size_Gen6 (GGC);
708 elsif Config.CPU_Broadwell then
709 GTT_Size := GTT_Size_Gen8 (GGC);
710 Stolen_Size := Stolen_Size_Gen8 (GGC);
711 else
712 GTT_Size := GTT_Size_Gen8 (GGC);
713 Stolen_Size := Stolen_Size_Gen9 (GGC);
714 end if;
Nico Hubereedde882017-07-16 02:54:39 +0200715 end Decode_Stolen;
716
717 -- Additional runtime validation that FB fits stolen memory and aperture.
718 procedure Validate_FB (FB : Framebuffer_Type; Valid : out Boolean)
719 with
720 Pre => Is_Initialized,
721 Post => (if Valid then Valid_FB (FB))
722 is
723 GTT_Size, Aperture_Size : Natural;
724 Stolen_Size : Stolen_Size_Range;
725 begin
726 Valid := Valid_FB (FB);
727
728 if Valid then
729 Decode_Stolen (GTT_Size, Stolen_Size);
730 Dev.Resource_Size (Aperture_Size, PCI.Res2);
731 Valid :=
732 FB_Last_Page (FB) < GTT_Size / Config.GTT_PTE_Size and
733 FB_Last_Page (FB) < Natural (Stolen_Size / GTT_Page_Size) and
734 FB_Last_Page (FB) < Aperture_Size / GTT_Page_Size;
Nico Huber34be6542017-12-13 09:26:24 +0100735 pragma Debug (not Valid, Debug.Put_Line
Nico Hubereedde882017-07-16 02:54:39 +0200736 ("Stolen memory too small to hold framebuffer."));
737 end if;
738 end Validate_FB;
739
Nico Huber5374c3a2017-07-15 21:48:06 +0200740 procedure Setup_Default_FB
741 (FB : in Framebuffer_Type;
742 Clear : in Boolean := True;
743 Success : out Boolean)
744 is
745 GMA_Phys_Base : constant PCI.Index := 16#5c#;
746 GMA_Phys_Base_Mask : constant := 16#fff0_0000#;
747
748 Phys_Base : Word32;
749 begin
Nico Hubereedde882017-07-16 02:54:39 +0200750 Validate_FB (FB, Success);
Nico Huber5374c3a2017-07-15 21:48:06 +0200751
752 if Success then
753 Dev.Read32 (Phys_Base, GMA_Phys_Base);
754 Phys_Base := Phys_Base and GMA_Phys_Base_Mask;
755 Success := Phys_Base /= GMA_Phys_Base_Mask and Phys_Base /= 0;
756 pragma Debug (not Success, Debug.Put_Line
757 ("Failed to read stolen memory base."));
Nico Huber0164b022017-08-24 15:12:51 +0200758
759 if Success then
760 if FB.Tiling in XY_Tiling then
761 Registers.Add_Fence
762 (First_Page => FB_First_Page (FB),
763 Last_Page => FB_Last_Page (FB),
764 Tiling => FB.Tiling,
765 Pitch => FB_Pitch (FB.Stride, FB),
766 Success => Success);
767 end if;
768 pragma Debug (not Success, Debug.Put_Line
769 ("Tiled framebuffer but no fence regs available."));
770 end if;
771
Nico Huber5374c3a2017-07-15 21:48:06 +0200772 if Success then
773 Setup_Default_GTT (FB, Phys_Base);
774 end if;
775 end if;
776
777 if Success and then Clear then
778 declare
779 use type HW.Word64;
780 Linear_FB : Word64;
781 begin
Nico Huberc3f66f62017-07-16 21:39:54 +0200782 Map_Linear_FB (Linear_FB, FB);
Nico Huber5374c3a2017-07-15 21:48:06 +0200783 if Linear_FB /= 0 then
Nico Huberc3f66f62017-07-16 21:39:54 +0200784 Framebuffer_Filler.Fill (Linear_FB, FB);
Nico Huber5374c3a2017-07-15 21:48:06 +0200785 end if;
Nico Huber5374c3a2017-07-15 21:48:06 +0200786 end;
787 end if;
788 end Setup_Default_FB;
789
Nico Huberc3f66f62017-07-16 21:39:54 +0200790 procedure Map_Linear_FB (Linear_FB : out Word64; FB : in Framebuffer_Type)
791 is
792 use type HW.Word64;
793
794 Valid : Boolean;
795 begin
796 Linear_FB := 0;
797
798 if Linear_FB_Base = 0 then
799 Dev.Map (Linear_FB_Base, PCI.Res2);
800 pragma Debug
801 (Linear_FB_Base = 0, Debug.Put_Line ("Failed to map resource2."));
802 end if;
803
804 if Linear_FB_Base /= 0 then
805 Validate_FB (FB, Valid);
806 if Valid then
Nico Huber34be6542017-12-13 09:26:24 +0100807 Linear_FB := Linear_FB_Base + Word64 (Phys_Offset (FB));
Nico Huberc3f66f62017-07-16 21:39:54 +0200808 end if;
809 end if;
810 end Map_Linear_FB;
811
Nico Huber5374c3a2017-07-15 21:48:06 +0200812 ----------------------------------------------------------------------------
813
Nico Huber99f10f32016-11-20 00:34:05 +0100814 procedure Dump_Configs (Configs : Pipe_Configs)
Nico Huber83693c82016-10-08 22:17:55 +0200815 is
816 subtype Pipe_Name is String (1 .. 9);
Nico Huber99f10f32016-11-20 00:34:05 +0100817 type Pipe_Name_Array is array (Pipe_Index) of Pipe_Name;
Nico Huber83693c82016-10-08 22:17:55 +0200818 Pipe_Names : constant Pipe_Name_Array :=
819 (Primary => "Primary ",
820 Secondary => "Secondary",
821 Tertiary => "Tertiary ");
Nico Huber5ef4d602017-12-13 13:56:47 +0100822
823 subtype Tiling_Name is String (1 .. 7);
824 type Tiling_Name_Array is array (Tiling_Type) of Tiling_Name;
825 Tilings : constant Tiling_Name_Array :=
826 (Linear => "Linear ",
827 X_Tiled => "X_Tiled",
828 Y_Tiled => "Y_Tiled");
829
830 subtype Rotation_Name is String (1 .. 11);
831 type Rotation_Name_Array is array (Rotation_Type) of Rotation_Name;
832 Rotations : constant Rotation_Name_Array :=
833 (No_Rotation => "No_Rotation",
834 Rotated_90 => "Rotated_90 ",
835 Rotated_180 => "Rotated_180",
836 Rotated_270 => "Rotated_270");
Nico Huber83693c82016-10-08 22:17:55 +0200837 begin
838 Debug.New_Line;
Paul Menzelb83107c2017-05-04 09:02:33 +0200839 Debug.Put_Line ("CONFIG =>");
Nico Huber99f10f32016-11-20 00:34:05 +0100840 for Pipe in Pipe_Index loop
841 if Pipe = Pipe_Index'First then
Nico Huber83693c82016-10-08 22:17:55 +0200842 Debug.Put (" (");
843 else
844 Debug.Put (" ");
845 end if;
846 Debug.Put_Line (Pipe_Names (Pipe) & " =>");
847 Debug.Put_Line
848 (" (Port => " & Port_Names (Configs (Pipe).Port) & ",");
849 Debug.Put_Line (" Framebuffer =>");
Nico Huber5ef4d602017-12-13 13:56:47 +0100850 Debug.Put (" (Width => ");
Nico Huber83693c82016-10-08 22:17:55 +0200851 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Width);
852 Debug.Put_Line (",");
Nico Huber5ef4d602017-12-13 13:56:47 +0100853 Debug.Put (" Height => ");
Nico Huber83693c82016-10-08 22:17:55 +0200854 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Height);
855 Debug.Put_Line (",");
Nico Huber5ef4d602017-12-13 13:56:47 +0100856 Debug.Put (" Start_X => ");
857 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Start_X);
858 Debug.Put_Line (",");
859 Debug.Put (" Start_Y => ");
860 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Start_Y);
861 Debug.Put_Line (",");
862 Debug.Put (" Stride => ");
Nico Huber83693c82016-10-08 22:17:55 +0200863 Debug.Put_Int32 (Configs (Pipe).Framebuffer.Stride);
864 Debug.Put_Line (",");
Nico Huber5ef4d602017-12-13 13:56:47 +0100865 Debug.Put (" V_Stride => ");
866 Debug.Put_Int32 (Configs (Pipe).Framebuffer.V_Stride);
867 Debug.Put_Line (",");
868 Debug.Put (" Tiling => ");
869 Debug.Put_Line (Tilings (Configs (Pipe).Framebuffer.Tiling) & ",");
870 Debug.Put (" Rotation => ");
871 Debug.Put_Line (Rotations (Configs (Pipe).Framebuffer.Rotation) & ",");
Nico Huber83693c82016-10-08 22:17:55 +0200872 Debug.Put (" Offset => ");
873 Debug.Put_Word32 (Configs (Pipe).Framebuffer.Offset);
874 Debug.Put_Line (",");
875 Debug.Put (" BPC => ");
876 Debug.Put_Int64 (Configs (Pipe).Framebuffer.BPC);
877 Debug.Put_Line ("),");
878 Debug.Put_Line (" Mode =>");
879 Debug.Put (" (Dotclock => ");
880 Debug.Put_Int64 (Configs (Pipe).Mode.Dotclock);
881 Debug.Put_Line (",");
882 Debug.Put (" H_Visible => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200883 Debug.Put_Int32 (Configs (Pipe).Mode.H_Visible);
Nico Huber83693c82016-10-08 22:17:55 +0200884 Debug.Put_Line (",");
885 Debug.Put (" H_Sync_Begin => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200886 Debug.Put_Int32 (Configs (Pipe).Mode.H_Sync_Begin);
Nico Huber83693c82016-10-08 22:17:55 +0200887 Debug.Put_Line (",");
888 Debug.Put (" H_Sync_End => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200889 Debug.Put_Int32 (Configs (Pipe).Mode.H_Sync_End);
Nico Huber83693c82016-10-08 22:17:55 +0200890 Debug.Put_Line (",");
891 Debug.Put (" H_Total => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200892 Debug.Put_Int32 (Configs (Pipe).Mode.H_Total);
Nico Huber83693c82016-10-08 22:17:55 +0200893 Debug.Put_Line (",");
894 Debug.Put (" V_Visible => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200895 Debug.Put_Int32 (Configs (Pipe).Mode.V_Visible);
Nico Huber83693c82016-10-08 22:17:55 +0200896 Debug.Put_Line (",");
897 Debug.Put (" V_Sync_Begin => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200898 Debug.Put_Int32 (Configs (Pipe).Mode.V_Sync_Begin);
Nico Huber83693c82016-10-08 22:17:55 +0200899 Debug.Put_Line (",");
900 Debug.Put (" V_Sync_End => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200901 Debug.Put_Int32 (Configs (Pipe).Mode.V_Sync_End);
Nico Huber83693c82016-10-08 22:17:55 +0200902 Debug.Put_Line (",");
903 Debug.Put (" V_Total => ");
Nico Huberc5c767a2018-06-03 01:09:04 +0200904 Debug.Put_Int32 (Configs (Pipe).Mode.V_Total);
Nico Huber83693c82016-10-08 22:17:55 +0200905 Debug.Put_Line (",");
906 Debug.Put_Line (" H_Sync_Active_High => " &
907 (if Configs (Pipe).Mode.H_Sync_Active_High
908 then "True,"
909 else "False,"));
910 Debug.Put_Line (" V_Sync_Active_High => " &
911 (if Configs (Pipe).Mode.V_Sync_Active_High
912 then "True,"
913 else "False,"));
914 Debug.Put (" BPC => ");
915 Debug.Put_Int64 (Configs (Pipe).Mode.BPC);
Nico Huber99f10f32016-11-20 00:34:05 +0100916 if Pipe /= Pipe_Index'Last then
Nico Huber83693c82016-10-08 22:17:55 +0200917 Debug.Put_Line (")),");
918 else
919 Debug.Put_Line (")));");
920 end if;
921 end loop;
922 end Dump_Configs;
923
924end HW.GFX.GMA;