| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 1 | -- |
| 2 | -- Copyright (C) 2014-2016 secunet Security Networks AG |
| 3 | -- |
| 4 | -- This program is free software; you can redistribute it and/or modify |
| 5 | -- it under the terms of the GNU General Public License as published by |
| Nico Huber | 125a29e | 2016-10-18 00:23:54 +0200 | [diff] [blame] | 6 | -- the Free Software Foundation; either version 2 of the License, or |
| 7 | -- (at your option) any later version. |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 8 | -- |
| 9 | -- This program is distributed in the hope that it will be useful, |
| 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | -- GNU General Public License for more details. |
| 13 | -- |
| 14 | |
| Nico Huber | 995436b | 2016-11-20 02:21:51 +0100 | [diff] [blame] | 15 | with HW.GFX.I2C; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 16 | with HW.GFX.EDID; |
| 17 | with HW.GFX.GMA.Config; |
| Nico Huber | 995436b | 2016-11-20 02:21:51 +0100 | [diff] [blame] | 18 | with HW.GFX.GMA.I2C; |
| 19 | with HW.GFX.GMA.DP_Aux_Ch; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 20 | with HW.GFX.GMA.DP_Info; |
| 21 | with HW.GFX.GMA.Registers; |
| 22 | with HW.GFX.GMA.Power_And_Clocks; |
| 23 | with HW.GFX.GMA.Panel; |
| 24 | with HW.GFX.GMA.PLLs; |
| 25 | with HW.GFX.GMA.Port_Detect; |
| 26 | with HW.GFX.GMA.Connectors; |
| 27 | with HW.GFX.GMA.Connector_Info; |
| 28 | with HW.GFX.GMA.Pipe_Setup; |
| 29 | |
| 30 | with System; |
| 31 | |
| 32 | with HW.Debug; |
| 33 | with GNAT.Source_Info; |
| 34 | |
| 35 | use type HW.Word8; |
| 36 | use type HW.Int32; |
| 37 | |
| 38 | package body HW.GFX.GMA |
| 39 | with Refined_State => |
| 40 | (State => |
| 41 | (Registers.Address_State, |
| 42 | PLLs.State, Panel.Panel_State, |
| 43 | Cur_Configs, Allocated_PLLs, DP_Links, |
| 44 | HPD_Delay, Wait_For_HPD), |
| 45 | Init_State => Initialized, |
| 46 | Config_State => Config.Valid_Port_GPU, |
| 47 | Device_State => |
| 48 | (Registers.Register_State, Registers.GTT_State)) |
| 49 | is |
| 50 | |
| 51 | subtype Port_Name is String (1 .. 8); |
| 52 | type Port_Name_Array is array (Port_Type) of Port_Name; |
| 53 | Port_Names : constant Port_Name_Array := |
| 54 | (Disabled => "Disabled", |
| 55 | Internal => "Internal", |
| 56 | DP1 => "DP1 ", |
| 57 | DP2 => "DP2 ", |
| 58 | DP3 => "DP3 ", |
| Nico Huber | 0d454cd | 2016-11-21 13:33:43 +0100 | [diff] [blame] | 59 | HDMI1 => "HDMI1 ", |
| 60 | HDMI2 => "HDMI2 ", |
| 61 | HDMI3 => "HDMI3 ", |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 62 | Analog => "Analog "); |
| 63 | |
| 64 | package Display_Controller renames Pipe_Setup; |
| 65 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 66 | type PLLs_Type is array (Pipe_Index) of PLLs.T; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 67 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 68 | type Links_Type is array (Pipe_Index) of DP_Link; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 69 | |
| 70 | type HPD_Type is array (Port_Type) of Boolean; |
| 71 | type HPD_Delay_Type is array (Port_Type) of Time.T; |
| 72 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 73 | Cur_Configs : Pipe_Configs; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 74 | Allocated_PLLs : PLLs_Type; |
| 75 | DP_Links : Links_Type; |
| 76 | HPD_Delay : HPD_Delay_Type; |
| 77 | Wait_For_HPD : HPD_Type; |
| 78 | Initialized : Boolean := False; |
| 79 | |
| 80 | subtype Active_Port_Type is Port_Type range Port_Type'Succ (Disabled) .. Port_Type'Last; |
| 81 | |
| 82 | ---------------------------------------------------------------------------- |
| 83 | |
| Nico Huber | f54d096 | 2016-10-20 14:17:18 +0200 | [diff] [blame] | 84 | 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 94 | function To_GPU_Port |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 95 | (Configs : Pipe_Configs; |
| 96 | Idx : Pipe_Index) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 97 | return GPU_Port |
| 98 | is |
| 99 | begin |
| 100 | return |
| 101 | (case Config.CPU is |
| 102 | when Ironlake .. Ivybridge => -- everything but eDP through FDI/PCH |
| 103 | (if Config.Internal_Is_EDP and then Configs (Idx).Port = Internal |
| 104 | then |
| 105 | DIGI_A |
| 106 | else |
| 107 | (case Idx is |
| 108 | -- FDIs are fixed to the CPU pipe |
| 109 | when Primary => DIGI_B, |
| 110 | when Secondary => DIGI_C, |
| 111 | when Tertiary => DIGI_D)), |
| 112 | when Haswell .. Skylake => -- everything but VGA directly on CPU |
| 113 | (case Configs (Idx).Port is |
| Nico Huber | 0d454cd | 2016-11-21 13:33:43 +0100 | [diff] [blame] | 114 | when Disabled => GPU_Port'First, |
| 115 | when Internal => DIGI_A, -- LVDS not available |
| 116 | when HDMI1 | DP1 => DIGI_B, |
| 117 | when HDMI2 | DP2 => DIGI_C, |
| 118 | when HDMI3 | DP3 => DIGI_D, |
| 119 | when Analog => DIGI_E)); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 120 | end To_GPU_Port; |
| 121 | |
| 122 | function To_PCH_Port (Port : Active_Port_Type) return PCH_Port |
| Nico Huber | 995436b | 2016-11-20 02:21:51 +0100 | [diff] [blame] | 123 | with Pre => True |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 124 | is |
| 125 | begin |
| 126 | return |
| 127 | (case Port is |
| 128 | when Internal => PCH_LVDS, -- will be ignored if Internal is DP |
| 129 | when Analog => PCH_DAC, |
| Nico Huber | 0d454cd | 2016-11-21 13:33:43 +0100 | [diff] [blame] | 130 | when HDMI1 => PCH_HDMI_B, |
| 131 | when HDMI2 => PCH_HDMI_C, |
| 132 | when HDMI3 => PCH_HDMI_D, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 133 | when DP1 => PCH_DP_B, |
| 134 | when DP2 => PCH_DP_C, |
| 135 | when DP3 => PCH_DP_D); |
| 136 | end To_PCH_Port; |
| 137 | |
| 138 | function To_Display_Type (Port : Active_Port_Type) return Display_Type |
| 139 | with Pre => True |
| 140 | is |
| 141 | begin |
| 142 | return |
| 143 | (case Port is |
| 144 | when Internal => Config.Internal_Display, |
| 145 | when Analog => VGA, |
| Nico Huber | 0d454cd | 2016-11-21 13:33:43 +0100 | [diff] [blame] | 146 | when HDMI1 | |
| 147 | HDMI2 | |
| 148 | HDMI3 => HDMI, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 149 | when DP1 | |
| 150 | DP2 | |
| 151 | DP3 => DP); |
| 152 | end To_Display_Type; |
| 153 | |
| 154 | procedure Configure_FDI_Link |
| 155 | (Port_Cfg : in out Port_Config; |
| 156 | Success : out Boolean) |
| Nico Huber | 47ff069 | 2016-11-04 14:29:39 +0100 | [diff] [blame] | 157 | with |
| 158 | Post => Port_Cfg.Mode = Port_Cfg.Mode'Old |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 159 | is |
| 160 | procedure Limit_Lane_Count |
| 161 | is |
| 162 | FDI_TX_CTL_FDI_TX_ENABLE : constant := 1 * 2 ** 31; |
| 163 | Enabled : Boolean; |
| 164 | begin |
| 165 | -- if DIGI_D enabled: (FDI names are off by one) |
| 166 | Registers.Is_Set_Mask |
| 167 | (Register => Registers.FDI_TX_CTL_C, |
| 168 | Mask => FDI_TX_CTL_FDI_TX_ENABLE, |
| 169 | Result => Enabled); |
| 170 | if Enabled then |
| 171 | Port_Cfg.FDI.Receiver_Caps.Max_Lane_Count := DP_Lane_Count_2; |
| 172 | end if; |
| 173 | end Limit_Lane_Count; |
| 174 | begin |
| 175 | Port_Cfg.FDI.Receiver_Caps.Max_Link_Rate := DP_Bandwidth_2_7; |
| 176 | Port_Cfg.FDI.Receiver_Caps.Max_Lane_Count := |
| 177 | Config.FDI_Lane_Count (Port_Cfg.Port); |
| 178 | Port_Cfg.FDI.Receiver_Caps.Enhanced_Framing := True; |
| 179 | if Config.Has_FDI_C and then Port_Cfg.Port = DIGI_C then |
| 180 | Limit_Lane_Count; |
| 181 | end if; |
| 182 | DP_Info.Preferred_Link_Setting (Port_Cfg.FDI, Port_Cfg.Mode, Success); |
| 183 | end Configure_FDI_Link; |
| 184 | |
| Nico Huber | c7a4fee | 2016-11-03 18:18:03 +0100 | [diff] [blame] | 185 | function Validate_Config |
| 186 | (Framebuffer : Framebuffer_Type; |
| Nico Huber | dcd274b | 2016-11-03 20:15:39 +0100 | [diff] [blame] | 187 | Port_Cfg : Port_Config; |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 188 | I : Pipe_Index) |
| Nico Huber | c7a4fee | 2016-11-03 18:18:03 +0100 | [diff] [blame] | 189 | return Boolean |
| Nico Huber | 47ff069 | 2016-11-04 14:29:39 +0100 | [diff] [blame] | 190 | with |
| 191 | Post => |
| 192 | (if Validate_Config'Result then |
| 193 | Framebuffer.Width <= Pos32 (Port_Cfg.Mode.H_Visible) and |
| 194 | Framebuffer.Height <= Pos32 (Port_Cfg.Mode.V_Visible)) |
| Nico Huber | c7a4fee | 2016-11-03 18:18:03 +0100 | [diff] [blame] | 195 | is |
| 196 | begin |
| 197 | -- No downscaling |
| Nico Huber | dcd274b | 2016-11-03 20:15:39 +0100 | [diff] [blame] | 198 | -- Respect maximum scalable width |
| Nico Huber | 3675db5 | 2016-11-04 16:27:29 +0100 | [diff] [blame] | 199 | -- VGA plane is only allowed on the primary pipe |
| 200 | -- Only 32bpp RGB (ignored for VGA plane) |
| 201 | -- Stride must be a multiple of 64 (ignored for VGA plane) |
| Nico Huber | c7a4fee | 2016-11-03 18:18:03 +0100 | [diff] [blame] | 202 | return |
| Nico Huber | dcd274b | 2016-11-03 20:15:39 +0100 | [diff] [blame] | 203 | ((Framebuffer.Width = Pos32 (Port_Cfg.Mode.H_Visible) and |
| 204 | Framebuffer.Height = Pos32 (Port_Cfg.Mode.V_Visible)) or |
| 205 | (Framebuffer.Width <= Config.Maximum_Scalable_Width (I) and |
| 206 | Framebuffer.Width <= Pos32 (Port_Cfg.Mode.H_Visible) and |
| 207 | Framebuffer.Height <= Pos32 (Port_Cfg.Mode.V_Visible))) and |
| Nico Huber | 3675db5 | 2016-11-04 16:27:29 +0100 | [diff] [blame] | 208 | (Framebuffer.Offset /= VGA_PLANE_FRAMEBUFFER_OFFSET or I = Primary) and |
| 209 | (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or |
| 210 | (Framebuffer.BPC = 8 and |
| 211 | Framebuffer.Stride mod 64 = 0)); |
| Nico Huber | c7a4fee | 2016-11-03 18:18:03 +0100 | [diff] [blame] | 212 | end Validate_Config; |
| 213 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 214 | procedure Fill_Port_Config |
| 215 | (Port_Cfg : out Port_Config; |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 216 | Configs : in Pipe_Configs; |
| 217 | Idx : in Pipe_Index; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 218 | Success : out Boolean) |
| 219 | with Pre => True |
| 220 | is |
| 221 | begin |
| 222 | Success := |
| 223 | Config.Supported_Pipe (Idx) and then |
| 224 | Config.Valid_Port (Configs (Idx).Port) and then |
| 225 | Configs (Idx).Port /= Disabled; |
| 226 | |
| 227 | if Success then |
| 228 | declare |
| 229 | Port : constant Port_Type := Configs (Idx).Port; |
| 230 | Mode : constant Mode_Type := Configs (Idx).Mode; |
| 231 | Link : constant DP_Link := DP_Links (Idx); |
| 232 | begin |
| 233 | Port_Cfg := Port_Config' |
| 234 | (Port => To_GPU_Port (Configs, Idx), |
| 235 | PCH_Port => To_PCH_Port (Port), |
| 236 | Display => To_Display_Type (Port), |
| 237 | Mode => Mode, |
| 238 | Is_FDI => Config.FDI_Port (To_GPU_Port (Configs, Idx)), |
| 239 | FDI => Default_DP, |
| 240 | DP => Link); |
| 241 | if Port_Cfg.Mode.BPC = Auto_BPC then |
| 242 | Port_Cfg.Mode.BPC := Connector_Info.Default_BPC (Port_Cfg); |
| 243 | end if; |
| Nico Huber | 74ec962 | 2016-11-19 03:00:43 +0100 | [diff] [blame] | 244 | if Port_Cfg.Display = HDMI then |
| 245 | declare |
| 246 | pragma Assert (Config.HDMI_Max_Clock_24bpp * 8 |
| 247 | / Port_Cfg.Mode.BPC >= Frequency_Type'First); |
| 248 | Max_Dotclock : constant Frequency_Type := |
| 249 | Config.HDMI_Max_Clock_24bpp * 8 / Port_Cfg.Mode.BPC; |
| 250 | begin |
| 251 | if Port_Cfg.Mode.Dotclock > Max_Dotclock then |
| 252 | pragma Debug (Debug.Put ("Dotclock ")); |
| 253 | pragma Debug (Debug.Put_Int64 (Port_Cfg.Mode.Dotclock)); |
| 254 | pragma Debug (Debug.Put (" too high, limiting to ")); |
| 255 | pragma Debug (Debug.Put_Int64 (Max_Dotclock)); |
| 256 | pragma Debug (Debug.Put_Line (".")); |
| 257 | Port_Cfg.Mode.Dotclock := Max_Dotclock; |
| 258 | end if; |
| 259 | end; |
| 260 | end if; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 261 | end; |
| 262 | else |
| 263 | Port_Cfg := Port_Config' |
| 264 | (Port => GPU_Port'First, |
| 265 | PCH_Port => PCH_Port'First, |
| 266 | Display => Display_Type'First, |
| 267 | Mode => Invalid_Mode, |
| 268 | Is_FDI => False, |
| 269 | FDI => Default_DP, |
| 270 | DP => Default_DP); |
| 271 | end if; |
| 272 | end Fill_Port_Config; |
| 273 | |
| 274 | ---------------------------------------------------------------------------- |
| 275 | |
| 276 | function To_Controller |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 277 | (Dsp_Config : Pipe_Index) return Display_Controller.Controller_Type |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 278 | is |
| 279 | Result : Display_Controller.Controller_Type; |
| 280 | begin |
| 281 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 282 | |
| 283 | case Dsp_Config is |
| 284 | when Primary => |
| 285 | Result := Display_Controller.Controllers (Display_Controller.A); |
| 286 | when Secondary => |
| 287 | Result := Display_Controller.Controllers (Display_Controller.B); |
| 288 | when Tertiary => |
| 289 | Result := Display_Controller.Controllers (Display_Controller.C); |
| 290 | end case; |
| 291 | return Result; |
| 292 | end To_Controller; |
| 293 | |
| 294 | ---------------------------------------------------------------------------- |
| 295 | |
| 296 | function To_Head |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 297 | (N_Config : Pipe_Index; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 298 | Port : Active_Port_Type) |
| 299 | return Display_Controller.Head_Type |
| 300 | is |
| 301 | Result : Display_Controller.Head_Type; |
| 302 | begin |
| 303 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 304 | |
| 305 | if Config.Has_EDP_Pipe and then Port = Internal then |
| 306 | Result := Display_Controller.Heads (Display_Controller.Head_EDP); |
| 307 | else |
| 308 | case N_Config is |
| 309 | when Primary => |
| 310 | Result := Display_Controller.Heads (Display_Controller.Head_A); |
| 311 | when Secondary => |
| 312 | Result := Display_Controller.Heads (Display_Controller.Head_B); |
| 313 | when Tertiary => |
| 314 | Result := Display_Controller.Heads (Display_Controller.Head_C); |
| 315 | end case; |
| 316 | end if; |
| 317 | return Result; |
| 318 | end To_Head; |
| 319 | |
| 320 | ---------------------------------------------------------------------------- |
| 321 | |
| 322 | procedure Legacy_VGA_Off |
| 323 | is |
| 324 | Reg8 : Word8; |
| 325 | begin |
| 326 | -- disable legacy VGA plane, taking over control now |
| 327 | Port_IO.OutB (VGA_SR_INDEX, VGA_SR01); |
| 328 | Port_IO.InB (Reg8, VGA_SR_DATA); |
| 329 | Port_IO.OutB (VGA_SR_DATA, Reg8 or 1 * 2 ** 5); |
| 330 | Time.U_Delay (100); -- PRM says 100us, Linux does 300 |
| 331 | Registers.Set_Mask (Registers.VGACNTRL, 1 * 2 ** 31); |
| 332 | end Legacy_VGA_Off; |
| 333 | |
| 334 | ---------------------------------------------------------------------------- |
| 335 | |
| 336 | function Port_Configured |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 337 | (Configs : Pipe_Configs; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 338 | Port : Port_Type) |
| 339 | return Boolean |
| 340 | with |
| 341 | Global => null |
| 342 | is |
| 343 | begin |
| 344 | return Configs (Primary).Port = Port or |
| 345 | Configs (Secondary).Port = Port or |
| 346 | Configs (Tertiary).Port = Port; |
| 347 | end Port_Configured; |
| 348 | |
| Nico Huber | 845de36 | 2016-11-21 14:00:06 +0100 | [diff] [blame] | 349 | -- DP and HDMI share physical pins. |
| 350 | function Sibling_Port (Port : Port_Type) return Port_Type |
| 351 | is |
| 352 | begin |
| 353 | return |
| 354 | (case Port is |
| 355 | when HDMI1 => DP1, |
| 356 | when HDMI2 => DP2, |
| 357 | when HDMI3 => DP3, |
| 358 | when DP1 => HDMI1, |
| 359 | when DP2 => HDMI2, |
| 360 | when DP3 => HDMI3, |
| 361 | when others => Disabled); |
| 362 | end Sibling_Port; |
| 363 | |
| 364 | function Has_Sibling_Port (Port : Port_Type) return Boolean |
| 365 | is |
| 366 | begin |
| 367 | return Sibling_Port (Port) /= Disabled; |
| 368 | end Has_Sibling_Port; |
| 369 | |
| Nico Huber | 995436b | 2016-11-20 02:21:51 +0100 | [diff] [blame] | 370 | procedure Read_EDID |
| 371 | (Raw_EDID : out EDID.Raw_EDID_Data; |
| 372 | Port : in Active_Port_Type; |
| 373 | Success : out Boolean) |
| 374 | with |
| 375 | Post => (if Success then EDID.Valid (Raw_EDID)) |
| 376 | is |
| 377 | Raw_EDID_Length : GFX.I2C.Transfer_Length := Raw_EDID'Length; |
| 378 | begin |
| 379 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 380 | |
| 381 | for I in 1 .. 2 loop |
| 382 | if To_Display_Type (Port) = DP then |
| Nico Huber | 1b2c9a3 | 2016-11-20 03:42:08 +0100 | [diff] [blame] | 383 | -- May need power to read edid |
| 384 | declare |
| 385 | Temp_Configs : Pipe_Configs := Cur_Configs; |
| 386 | begin |
| 387 | Temp_Configs (Primary).Port := Port; |
| 388 | Power_And_Clocks.Power_Up (Cur_Configs, Temp_Configs); |
| 389 | end; |
| 390 | |
| Nico Huber | 995436b | 2016-11-20 02:21:51 +0100 | [diff] [blame] | 391 | declare |
| 392 | DP_Port : constant GMA.DP_Port := |
| 393 | (case Port is |
| 394 | when Internal => DP_A, |
| 395 | when DP1 => DP_B, |
| 396 | when DP2 => DP_C, |
| 397 | when DP3 => DP_D, |
| 398 | when others => GMA.DP_Port'First); |
| 399 | begin |
| 400 | DP_Aux_Ch.I2C_Read |
| 401 | (Port => DP_Port, |
| 402 | Address => 16#50#, |
| 403 | Length => Raw_EDID_Length, |
| 404 | Data => Raw_EDID, |
| 405 | Success => Success); |
| 406 | end; |
| 407 | else |
| 408 | I2C.I2C_Read |
| 409 | (Port => (if Port = Analog |
| 410 | then Config.Analog_I2C_Port |
| 411 | else To_PCH_Port (Port)), |
| 412 | Address => 16#50#, |
| 413 | Length => Raw_EDID_Length, |
| 414 | Data => Raw_EDID, |
| 415 | Success => Success); |
| 416 | end if; |
| 417 | exit when not Success; -- don't retry if reading itself failed |
| 418 | |
| 419 | pragma Debug (Debug.Put_Buffer ("EDID", Raw_EDID, Raw_EDID_Length)); |
| 420 | EDID.Sanitize (Raw_EDID, Success); |
| 421 | exit when Success; |
| 422 | end loop; |
| 423 | end Read_EDID; |
| 424 | |
| Nico Huber | 1b2c9a3 | 2016-11-20 03:42:08 +0100 | [diff] [blame] | 425 | procedure Probe_Port |
| 426 | (Pipe_Cfg : in out Pipe_Config; |
| 427 | Port : in Active_Port_Type; |
| 428 | Success : out Boolean) |
| Nico Huber | 6b7a40b | 2016-11-21 14:14:02 +0100 | [diff] [blame^] | 429 | with Pre => True |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 430 | is |
| 431 | Raw_EDID : EDID.Raw_EDID_Data := (others => 16#00#); |
| Nico Huber | 1b2c9a3 | 2016-11-20 03:42:08 +0100 | [diff] [blame] | 432 | begin |
| 433 | Success := Config.Valid_Port (Port); |
| 434 | |
| 435 | if Success then |
| 436 | if Port = Internal then |
| 437 | Panel.On; |
| 438 | end if; |
| 439 | Read_EDID (Raw_EDID, Port, Success); |
| 440 | end if; |
| 441 | |
| 442 | if Success and then |
| 443 | (EDID.Compatible_Display (Raw_EDID, To_Display_Type (Port)) and |
| 444 | EDID.Has_Preferred_Mode (Raw_EDID)) |
| 445 | then |
| 446 | Pipe_Cfg.Port := Port; |
| 447 | Pipe_Cfg.Mode := EDID.Preferred_Mode (Raw_EDID); |
| Nico Huber | 6b7a40b | 2016-11-21 14:14:02 +0100 | [diff] [blame^] | 448 | |
| 449 | pragma Warnings (GNATprove, Off, "unused assignment to ""Raw_EDID""", |
| 450 | Reason => "We just want to check if it's readable."); |
| 451 | if Has_Sibling_Port (Port) then |
| 452 | -- Probe sibling port too and bail out if something is detected. |
| 453 | -- This is a precaution for adapters that expose the pins of a |
| 454 | -- port for both HDMI/DVI and DP (like some ThinkPad docks). A |
| 455 | -- user might have attached both by accident and there are ru- |
| 456 | -- mors of displays that got fried by applying the wrong signal. |
| 457 | declare |
| 458 | Have_Sibling_EDID : Boolean; |
| 459 | begin |
| 460 | Read_EDID (Raw_EDID, Sibling_Port (Port), Have_Sibling_EDID); |
| 461 | if Have_Sibling_EDID then |
| 462 | Pipe_Cfg.Port := Disabled; |
| 463 | Success := False; |
| 464 | end if; |
| 465 | end; |
| 466 | end if; |
| 467 | pragma Warnings (GNATprove, On, "unused assignment to ""Raw_EDID"""); |
| Nico Huber | 1b2c9a3 | 2016-11-20 03:42:08 +0100 | [diff] [blame] | 468 | else |
| 469 | Success := False; |
| 470 | if Port = Internal then |
| 471 | Panel.Off; |
| 472 | end if; |
| 473 | end if; |
| 474 | end Probe_Port; |
| 475 | |
| 476 | procedure Scan_Ports |
| 477 | (Configs : out Pipe_Configs; |
| 478 | Ports : in Port_List; |
| 479 | Max_Pipe : in Pipe_Index := Pipe_Index'Last) |
| 480 | is |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 481 | Port_Idx : Port_List_Range := Port_List_Range'First; |
| Nico Huber | 1b2c9a3 | 2016-11-20 03:42:08 +0100 | [diff] [blame] | 482 | Success : Boolean; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 483 | begin |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 484 | Configs := (Pipe_Index => |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 485 | (Port => Disabled, |
| 486 | Mode => Invalid_Mode, |
| 487 | Framebuffer => Default_FB)); |
| 488 | |
| Nico Huber | 1b2c9a3 | 2016-11-20 03:42:08 +0100 | [diff] [blame] | 489 | for Pipe in Pipe_Index range |
| 490 | Pipe_Index'First .. Pipe_Index'Min (Max_Pipe, Config.Max_Pipe) |
| 491 | loop |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 492 | while Ports (Port_Idx) /= Disabled loop |
| Nico Huber | 845de36 | 2016-11-21 14:00:06 +0100 | [diff] [blame] | 493 | if not Port_Configured (Configs, Ports (Port_Idx)) and |
| 494 | (not Has_Sibling_Port (Ports (Port_Idx)) or |
| 495 | not Port_Configured (Configs, Sibling_Port (Ports (Port_Idx)))) |
| 496 | then |
| Nico Huber | 1b2c9a3 | 2016-11-20 03:42:08 +0100 | [diff] [blame] | 497 | Probe_Port (Configs (Pipe), Ports (Port_Idx), Success); |
| 498 | else |
| 499 | Success := False; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 500 | end if; |
| 501 | |
| 502 | exit when Port_Idx = Port_List_Range'Last; |
| 503 | Port_Idx := Port_List_Range'Succ (Port_Idx); |
| 504 | |
| 505 | exit when Success; |
| 506 | end loop; |
| 507 | end loop; |
| 508 | |
| Nico Huber | 1b2c9a3 | 2016-11-20 03:42:08 +0100 | [diff] [blame] | 509 | -- Restore power settings |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 510 | Power_And_Clocks.Power_Set_To (Cur_Configs); |
| 511 | end Scan_Ports; |
| 512 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 513 | ---------------------------------------------------------------------------- |
| 514 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 515 | procedure Update_Outputs (Configs : Pipe_Configs) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 516 | is |
| 517 | Did_Power_Up : Boolean := False; |
| 518 | |
| 519 | HPD, HPD_Delay_Over, Success : Boolean; |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 520 | Old_Config, New_Config : Pipe_Config; |
| 521 | Old_Configs : Pipe_Configs; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 522 | Port_Cfg : Port_Config; |
| 523 | |
| 524 | procedure Check_HPD |
| 525 | (Port_Cfg : in Port_Config; |
| 526 | Port : in Port_Type; |
| 527 | Detected : out Boolean) |
| 528 | is |
| 529 | begin |
| 530 | HPD_Delay_Over := Time.Timed_Out (HPD_Delay (Port)); |
| 531 | if HPD_Delay_Over then |
| 532 | Port_Detect.Hotplug_Detect (Port_Cfg, Detected); |
| 533 | HPD_Delay (Port) := Time.MS_From_Now (333); |
| 534 | else |
| 535 | Detected := False; |
| 536 | end if; |
| 537 | end Check_HPD; |
| 538 | begin |
| 539 | Old_Configs := Cur_Configs; |
| 540 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 541 | for I in Pipe_Index loop |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 542 | HPD := False; |
| 543 | |
| 544 | Old_Config := Cur_Configs (I); |
| 545 | New_Config := Configs (I); |
| 546 | |
| 547 | Fill_Port_Config (Port_Cfg, Old_Configs, I, Success); |
| 548 | if Success then |
| 549 | Check_HPD (Port_Cfg, Old_Config.Port, HPD); |
| 550 | end if; |
| 551 | |
| 552 | -- Connector changed? |
| 553 | if (Success and then HPD) or |
| 554 | Old_Config.Port /= New_Config.Port or |
| 555 | Old_Config.Mode /= New_Config.Mode |
| 556 | then |
| 557 | if Old_Config.Port /= Disabled then |
| 558 | if Success then |
| 559 | pragma Debug (Debug.New_Line); |
| 560 | pragma Debug (Debug.Put_Line |
| 561 | ("Disabling port " & Port_Names (Old_Config.Port))); |
| 562 | |
| 563 | Connectors.Pre_Off (Port_Cfg); |
| 564 | |
| 565 | Display_Controller.Off |
| 566 | (To_Controller (I), To_Head (I, Old_Config.Port)); |
| 567 | |
| 568 | Connectors.Post_Off (Port_Cfg); |
| 569 | end if; |
| 570 | |
| 571 | -- Free PLL |
| 572 | PLLs.Free (Allocated_PLLs (I)); |
| 573 | |
| 574 | Cur_Configs (I).Port := Disabled; |
| 575 | end if; |
| 576 | |
| 577 | if New_Config.Port /= Disabled then |
| 578 | Fill_Port_Config (Port_Cfg, Configs, I, Success); |
| 579 | |
| Nico Huber | c7a4fee | 2016-11-03 18:18:03 +0100 | [diff] [blame] | 580 | Success := Success and then |
| Nico Huber | dcd274b | 2016-11-03 20:15:39 +0100 | [diff] [blame] | 581 | Validate_Config (New_Config.Framebuffer, Port_Cfg, I); |
| Nico Huber | c7a4fee | 2016-11-03 18:18:03 +0100 | [diff] [blame] | 582 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 583 | if Success and then Wait_For_HPD (New_Config.Port) then |
| 584 | Check_HPD (Port_Cfg, New_Config.Port, Success); |
| 585 | Wait_For_HPD (New_Config.Port) := not Success; |
| 586 | end if; |
| 587 | |
| 588 | if Success then |
| 589 | pragma Debug (Debug.New_Line); |
| 590 | pragma Debug (Debug.Put_Line |
| 591 | ("Trying to enable port " & Port_Names (New_Config.Port))); |
| 592 | |
| 593 | if not Did_Power_Up then |
| 594 | Power_And_Clocks.Power_Up (Old_Configs, Configs); |
| 595 | Did_Power_Up := True; |
| 596 | end if; |
| 597 | |
| 598 | if Port_Cfg.Is_FDI then |
| 599 | Configure_FDI_Link (Port_Cfg, Success); |
| 600 | end if; |
| 601 | end if; |
| 602 | |
| 603 | if Success then |
| 604 | Connector_Info.Preferred_Link_Setting |
| 605 | (Port_Cfg => Port_Cfg, |
| 606 | Success => Success); |
| 607 | end if; |
| 608 | |
| 609 | while Success loop |
| Nico Huber | 47ff069 | 2016-11-04 14:29:39 +0100 | [diff] [blame] | 610 | pragma Loop_Invariant |
| 611 | (New_Config.Port in Active_Port_Type and |
| 612 | Port_Cfg.Mode = Port_Cfg.Mode'Loop_Entry); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 613 | |
| 614 | PLLs.Alloc |
| 615 | (Port_Cfg => Port_Cfg, |
| 616 | PLL => Allocated_PLLs (I), |
| 617 | Success => Success); |
| 618 | |
| 619 | if Success then |
| 620 | for Try in 1 .. 2 loop |
| 621 | pragma Loop_Invariant |
| 622 | (New_Config.Port in Active_Port_Type); |
| 623 | |
| 624 | Connectors.Pre_On |
| 625 | (Port_Cfg => Port_Cfg, |
| 626 | PLL_Hint => PLLs.Register_Value |
| 627 | (Allocated_PLLs (I)), |
| 628 | Pipe_Hint => Display_Controller.Get_Pipe_Hint |
| 629 | (To_Head (I, New_Config.Port)), |
| 630 | Success => Success); |
| 631 | |
| 632 | if Success then |
| 633 | Display_Controller.On |
| 634 | (Controller => To_Controller (I), |
| 635 | Head => To_Head (I, New_Config.Port), |
| 636 | Port_Cfg => Port_Cfg, |
| 637 | Framebuffer => New_Config.Framebuffer); |
| 638 | |
| 639 | Connectors.Post_On |
| 640 | (Port_Cfg => Port_Cfg, |
| 641 | PLL_Hint => PLLs.Register_Value |
| 642 | (Allocated_PLLs (I)), |
| 643 | Success => Success); |
| 644 | |
| 645 | if not Success then |
| 646 | Display_Controller.Off |
| 647 | (To_Controller (I), |
| 648 | To_Head (I, New_Config.Port)); |
| 649 | Connectors.Post_Off (Port_Cfg); |
| 650 | end if; |
| 651 | end if; |
| 652 | |
| 653 | exit when Success; |
| 654 | end loop; |
| 655 | exit when Success; -- connection established => stop loop |
| 656 | |
| 657 | -- connection failed |
| 658 | PLLs.Free (Allocated_PLLs (I)); |
| 659 | end if; |
| 660 | |
| 661 | Connector_Info.Next_Link_Setting |
| 662 | (Port_Cfg => Port_Cfg, |
| 663 | Success => Success); |
| 664 | end loop; |
| 665 | |
| 666 | if Success then |
| 667 | pragma Debug (Debug.Put_Line |
| 668 | ("Enabled port " & Port_Names (New_Config.Port))); |
| 669 | Cur_Configs (I) := New_Config; |
| 670 | DP_Links (I) := Port_Cfg.DP; |
| 671 | else |
| 672 | Wait_For_HPD (New_Config.Port) := True; |
| 673 | if New_Config.Port = Internal then |
| 674 | Panel.Off; |
| 675 | end if; |
| 676 | end if; |
| 677 | else |
| 678 | Cur_Configs (I) := New_Config; |
| 679 | end if; |
| 680 | elsif Old_Config.Framebuffer /= New_Config.Framebuffer and |
| 681 | Old_Config.Port /= Disabled |
| 682 | then |
| 683 | Display_Controller.Update_Offset |
| 684 | (Controller => To_Controller (I), |
| 685 | Framebuffer => New_Config.Framebuffer); |
| 686 | Cur_Configs (I) := New_Config; |
| 687 | end if; |
| 688 | end loop; |
| 689 | |
| 690 | if Did_Power_Up then |
| 691 | Power_And_Clocks.Power_Down (Old_Configs, Configs, Cur_Configs); |
| 692 | end if; |
| 693 | |
| 694 | end Update_Outputs; |
| 695 | |
| 696 | ---------------------------------------------------------------------------- |
| 697 | |
| 698 | procedure Initialize |
| 699 | (MMIO_Base : in Word64 := 0; |
| 700 | Write_Delay : in Word64 := 0; |
| 701 | Success : out Boolean) |
| 702 | with |
| 703 | Refined_Global => |
| 704 | (In_Out => |
| 705 | (Config.Valid_Port_GPU, |
| 706 | Registers.Register_State, Port_IO.State), |
| 707 | Input => |
| 708 | (Time.State), |
| 709 | Output => |
| 710 | (Registers.Address_State, |
| 711 | PLLs.State, Panel.Panel_State, |
| 712 | Cur_Configs, Allocated_PLLs, DP_Links, |
| 713 | HPD_Delay, Wait_For_HPD, Initialized)) |
| 714 | is |
| 715 | use type HW.Word64; |
| 716 | |
| 717 | Now : constant Time.T := Time.Now; |
| 718 | |
| 719 | procedure Check_Platform (Success : out Boolean) |
| 720 | is |
| 721 | Audio_VID_DID : Word32; |
| 722 | begin |
| 723 | case Config.CPU is |
| 724 | when Haswell .. Skylake => |
| 725 | Registers.Read (Registers.AUD_VID_DID, Audio_VID_DID); |
| 726 | when Ironlake .. Ivybridge => |
| 727 | Registers.Read (Registers.PCH_AUD_VID_DID, Audio_VID_DID); |
| 728 | end case; |
| 729 | Success := |
| 730 | (case Config.CPU is |
| 731 | when Skylake => Audio_VID_DID = 16#8086_2809#, |
| 732 | when Broadwell => Audio_VID_DID = 16#8086_2808#, |
| 733 | when Haswell => Audio_VID_DID = 16#8086_2807#, |
| 734 | when Ivybridge | |
| 735 | Sandybridge => Audio_VID_DID = 16#8086_2806# or |
| 736 | Audio_VID_DID = 16#8086_2805#, |
| Nico Huber | eeb5a39 | 2016-10-09 19:28:30 +0200 | [diff] [blame] | 737 | when Ironlake => Audio_VID_DID = 16#0000_0000#); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 738 | end Check_Platform; |
| 739 | begin |
| 740 | pragma Warnings (GNATprove, Off, "unused variable ""Write_Delay""", |
| 741 | Reason => "Write_Delay is used for debugging only"); |
| 742 | |
| 743 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 744 | |
| 745 | pragma Debug (Debug.Set_Register_Write_Delay (Write_Delay)); |
| 746 | |
| 747 | Wait_For_HPD := HPD_Type'(others => False); |
| 748 | HPD_Delay := HPD_Delay_Type'(others => Now); |
| 749 | DP_Links := Links_Type'(others => HW.GFX.Default_DP); |
| 750 | Allocated_PLLs := (others => PLLs.Invalid); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 751 | Cur_Configs := Pipe_Configs' |
| 752 | (others => Pipe_Config' |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 753 | (Port => Disabled, |
| 754 | Framebuffer => HW.GFX.Default_FB, |
| 755 | Mode => HW.GFX.Invalid_Mode)); |
| 756 | Registers.Set_Register_Base |
| 757 | (if MMIO_Base /= 0 then |
| 758 | MMIO_Base |
| 759 | else |
| 760 | Config.Default_MMIO_Base); |
| 761 | PLLs.Initialize; |
| 762 | |
| 763 | Check_Platform (Success); |
| 764 | if not Success then |
| 765 | pragma Debug (Debug.Put_Line ("ERROR: Incompatible CPU or PCH.")); |
| 766 | |
| 767 | Panel.Static_Init; -- for flow analysis |
| 768 | |
| 769 | Initialized := False; |
| 770 | return; |
| 771 | end if; |
| 772 | |
| 773 | Panel.Setup_PP_Sequencer; |
| 774 | Port_Detect.Initialize; |
| 775 | |
| 776 | Power_And_Clocks.Pre_All_Off; |
| 777 | |
| 778 | Legacy_VGA_Off; |
| 779 | |
| 780 | Connectors.Pre_All_Off; |
| 781 | Display_Controller.All_Off; |
| 782 | Connectors.Post_All_Off; |
| 783 | PLLs.All_Off; |
| 784 | |
| 785 | Power_And_Clocks.Post_All_Off; |
| 786 | |
| 787 | -------------------- Now restart from a clean state --------------------- |
| 788 | Power_And_Clocks.Initialize; |
| 789 | |
| Nico Huber | f54d096 | 2016-10-20 14:17:18 +0200 | [diff] [blame] | 790 | Registers.Unset_And_Set_Mask |
| 791 | (Register => Registers.PCH_RAWCLK_FREQ, |
| 792 | Mask_Unset => PCH_RAWCLK_FREQ_MASK, |
| 793 | Mask_Set => PCH_RAWCLK_FREQ (Config.Default_RawClk_Freq)); |
| 794 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 795 | Initialized := True; |
| 796 | |
| 797 | end Initialize; |
| 798 | |
| 799 | function Is_Initialized return Boolean |
| 800 | with |
| 801 | Refined_Post => Is_Initialized'Result = Initialized |
| 802 | is |
| 803 | begin |
| 804 | return Initialized; |
| 805 | end Is_Initialized; |
| 806 | |
| 807 | ---------------------------------------------------------------------------- |
| 808 | |
| 809 | procedure Write_GTT |
| 810 | (GTT_Page : GTT_Range; |
| 811 | Device_Address : GTT_Address_Type; |
| 812 | Valid : Boolean) is |
| 813 | begin |
| 814 | Registers.Write_GTT (GTT_Page, Device_Address, Valid); |
| 815 | end Write_GTT; |
| 816 | |
| 817 | procedure Setup_Default_GTT (FB : Framebuffer_Type; Phys_FB : Word32) |
| 818 | is |
| 819 | FB_Size : constant Pos32 := |
| 820 | FB.Stride * FB.Height * Pos32 (((FB.BPC * 4) / 8)); |
| 821 | Phys_Addr : GTT_Address_Type := GTT_Address_Type (Phys_FB); |
| 822 | begin |
| 823 | for Idx in GTT_Range range 0 .. GTT_Range (((FB_Size + 4095) / 4096) - 1) |
| 824 | loop |
| 825 | Registers.Write_GTT |
| 826 | (GTT_Page => Idx, |
| 827 | Device_Address => Phys_Addr, |
| 828 | Valid => True); |
| 829 | Phys_Addr := Phys_Addr + 4096; |
| 830 | end loop; |
| 831 | end Setup_Default_GTT; |
| 832 | |
| 833 | ---------------------------------------------------------------------------- |
| 834 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 835 | procedure Dump_Configs (Configs : Pipe_Configs) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 836 | is |
| 837 | subtype Pipe_Name is String (1 .. 9); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 838 | type Pipe_Name_Array is array (Pipe_Index) of Pipe_Name; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 839 | Pipe_Names : constant Pipe_Name_Array := |
| 840 | (Primary => "Primary ", |
| 841 | Secondary => "Secondary", |
| 842 | Tertiary => "Tertiary "); |
| 843 | begin |
| 844 | Debug.New_Line; |
| 845 | Debug.Put_Line ("CONFIG => "); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 846 | for Pipe in Pipe_Index loop |
| 847 | if Pipe = Pipe_Index'First then |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 848 | Debug.Put (" ("); |
| 849 | else |
| 850 | Debug.Put (" "); |
| 851 | end if; |
| 852 | Debug.Put_Line (Pipe_Names (Pipe) & " =>"); |
| 853 | Debug.Put_Line |
| 854 | (" (Port => " & Port_Names (Configs (Pipe).Port) & ","); |
| 855 | Debug.Put_Line (" Framebuffer =>"); |
| 856 | Debug.Put (" (Width => "); |
| 857 | Debug.Put_Int32 (Configs (Pipe).Framebuffer.Width); |
| 858 | Debug.Put_Line (","); |
| 859 | Debug.Put (" Height => "); |
| 860 | Debug.Put_Int32 (Configs (Pipe).Framebuffer.Height); |
| 861 | Debug.Put_Line (","); |
| 862 | Debug.Put (" Stride => "); |
| 863 | Debug.Put_Int32 (Configs (Pipe).Framebuffer.Stride); |
| 864 | Debug.Put_Line (","); |
| 865 | Debug.Put (" Offset => "); |
| 866 | Debug.Put_Word32 (Configs (Pipe).Framebuffer.Offset); |
| 867 | Debug.Put_Line (","); |
| 868 | Debug.Put (" BPC => "); |
| 869 | Debug.Put_Int64 (Configs (Pipe).Framebuffer.BPC); |
| 870 | Debug.Put_Line ("),"); |
| 871 | Debug.Put_Line (" Mode =>"); |
| 872 | Debug.Put (" (Dotclock => "); |
| 873 | Debug.Put_Int64 (Configs (Pipe).Mode.Dotclock); |
| 874 | Debug.Put_Line (","); |
| 875 | Debug.Put (" H_Visible => "); |
| 876 | Debug.Put_Int16 (Configs (Pipe).Mode.H_Visible); |
| 877 | Debug.Put_Line (","); |
| 878 | Debug.Put (" H_Sync_Begin => "); |
| 879 | Debug.Put_Int16 (Configs (Pipe).Mode.H_Sync_Begin); |
| 880 | Debug.Put_Line (","); |
| 881 | Debug.Put (" H_Sync_End => "); |
| 882 | Debug.Put_Int16 (Configs (Pipe).Mode.H_Sync_End); |
| 883 | Debug.Put_Line (","); |
| 884 | Debug.Put (" H_Total => "); |
| 885 | Debug.Put_Int16 (Configs (Pipe).Mode.H_Total); |
| 886 | Debug.Put_Line (","); |
| 887 | Debug.Put (" V_Visible => "); |
| 888 | Debug.Put_Int16 (Configs (Pipe).Mode.V_Visible); |
| 889 | Debug.Put_Line (","); |
| 890 | Debug.Put (" V_Sync_Begin => "); |
| 891 | Debug.Put_Int16 (Configs (Pipe).Mode.V_Sync_Begin); |
| 892 | Debug.Put_Line (","); |
| 893 | Debug.Put (" V_Sync_End => "); |
| 894 | Debug.Put_Int16 (Configs (Pipe).Mode.V_Sync_End); |
| 895 | Debug.Put_Line (","); |
| 896 | Debug.Put (" V_Total => "); |
| 897 | Debug.Put_Int16 (Configs (Pipe).Mode.V_Total); |
| 898 | Debug.Put_Line (","); |
| 899 | Debug.Put_Line (" H_Sync_Active_High => " & |
| 900 | (if Configs (Pipe).Mode.H_Sync_Active_High |
| 901 | then "True," |
| 902 | else "False,")); |
| 903 | Debug.Put_Line (" V_Sync_Active_High => " & |
| 904 | (if Configs (Pipe).Mode.V_Sync_Active_High |
| 905 | then "True," |
| 906 | else "False,")); |
| 907 | Debug.Put (" BPC => "); |
| 908 | Debug.Put_Int64 (Configs (Pipe).Mode.BPC); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 909 | if Pipe /= Pipe_Index'Last then |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 910 | Debug.Put_Line (")),"); |
| 911 | else |
| 912 | Debug.Put_Line (")));"); |
| 913 | end if; |
| 914 | end loop; |
| 915 | end Dump_Configs; |
| 916 | |
| 917 | end HW.GFX.GMA; |