| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 1 | -- |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 2 | -- Copyright (C) 2014-2019 secunet Security Networks AG |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 3 | -- Copyright (C) 2017 Nico Huber <nico.h@gmx.de> |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 4 | -- |
| 5 | -- This program is free software; you can redistribute it and/or modify |
| 6 | -- it under the terms of the GNU General Public License as published by |
| Nico Huber | 125a29e | 2016-10-18 00:23:54 +0200 | [diff] [blame] | 7 | -- the Free Software Foundation; either version 2 of the License, or |
| 8 | -- (at your option) any later version. |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 9 | -- |
| 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 Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 16 | with HW.MMIO_Range; |
| 17 | pragma Elaborate_All (HW.MMIO_Range); |
| 18 | with HW.PCI.Dev; |
| 19 | pragma Elaborate_All (HW.PCI.Dev); |
| 20 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 21 | with HW.GFX.GMA.Config; |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 22 | with HW.GFX.GMA.Config_Helpers; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 23 | with HW.GFX.GMA.Registers; |
| Nico Huber | 312433c | 2019-09-28 03:15:48 +0200 | [diff] [blame] | 24 | with HW.GFX.GMA.PCode; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 25 | with HW.GFX.GMA.Power_And_Clocks; |
| 26 | with HW.GFX.GMA.Panel; |
| 27 | with HW.GFX.GMA.PLLs; |
| 28 | with HW.GFX.GMA.Port_Detect; |
| 29 | with HW.GFX.GMA.Connectors; |
| 30 | with HW.GFX.GMA.Connector_Info; |
| 31 | with HW.GFX.GMA.Pipe_Setup; |
| 32 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 33 | with HW.Debug; |
| 34 | with GNAT.Source_Info; |
| 35 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 36 | use type HW.Int32; |
| 37 | |
| 38 | package body HW.GFX.GMA |
| 39 | with Refined_State => |
| 40 | (State => |
| Nico Huber | e317e9c | 2019-09-29 03:03:18 +0200 | [diff] [blame] | 41 | (Config.Variable, |
| 42 | PCI_Usable, |
| Nico Huber | c5c66ec | 2019-09-28 23:59:45 +0200 | [diff] [blame] | 43 | Dev.Address_State, |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 44 | Registers.Address_State, |
| Nico Huber | 312433c | 2019-09-28 03:15:48 +0200 | [diff] [blame] | 45 | PCode.Mailbox_Ready, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 46 | PLLs.State, Panel.Panel_State, |
| Nico Huber | 1a712d3 | 2017-01-09 15:11:04 +0100 | [diff] [blame] | 47 | Cur_Configs, Allocated_PLLs, |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 48 | HPD_Delay, Wait_For_HPD, |
| 49 | Linear_FB_Base), |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 50 | Init_State => Initialized, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 51 | Device_State => |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 52 | (Dev.PCI_State, Registers.Register_State, Registers.GTT_State)) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 53 | is |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 54 | pragma Disable_Atomic_Synchronization; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 55 | |
| 56 | subtype Port_Name is String (1 .. 8); |
| 57 | type Port_Name_Array is array (Port_Type) of Port_Name; |
| 58 | Port_Names : constant Port_Name_Array := |
| 59 | (Disabled => "Disabled", |
| Nico Huber | 8beafd7 | 2020-01-07 14:59:44 +0100 | [diff] [blame] | 60 | LVDS => "LVDS ", |
| 61 | eDP => "eDP ", |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 62 | DP1 => "DP1 ", |
| 63 | DP2 => "DP2 ", |
| 64 | DP3 => "DP3 ", |
| Nico Huber | 0d454cd | 2016-11-21 13:33:43 +0100 | [diff] [blame] | 65 | HDMI1 => "HDMI1 ", |
| 66 | HDMI2 => "HDMI2 ", |
| 67 | HDMI3 => "HDMI3 ", |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 68 | Analog => "Analog "); |
| 69 | |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 70 | package Dev is new HW.PCI.Dev (PCI.Address'(0, 2, 0)); |
| 71 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 72 | package Display_Controller renames Pipe_Setup; |
| 73 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 74 | type PLLs_Type is array (Pipe_Index) of PLLs.T; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 75 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 76 | type HPD_Type is array (Port_Type) of Boolean; |
| Nico Huber | 3be61d4 | 2017-01-09 13:58:18 +0100 | [diff] [blame] | 77 | type HPD_Delay_Type is array (Active_Port_Type) of Time.T; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 78 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 79 | Allocated_PLLs : PLLs_Type; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 80 | HPD_Delay : HPD_Delay_Type; |
| 81 | Wait_For_HPD : HPD_Type; |
| 82 | Initialized : Boolean := False; |
| 83 | |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 84 | Linear_FB_Base : Word64; |
| 85 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 86 | ---------------------------------------------------------------------------- |
| 87 | |
| Nico Huber | f54d096 | 2016-10-20 14:17:18 +0200 | [diff] [blame] | 88 | PCH_RAWCLK_FREQ_MASK : constant := 16#3ff# * 2 ** 0; |
| 89 | |
| 90 | function PCH_RAWCLK_FREQ (Freq : Frequency_Type) return Word32 |
| 91 | is |
| 92 | begin |
| 93 | return Word32 (Freq / 1_000_000); |
| 94 | end PCH_RAWCLK_FREQ; |
| 95 | |
| 96 | ---------------------------------------------------------------------------- |
| 97 | |
| Nico Huber | 43370ba | 2017-01-09 15:26:19 +0100 | [diff] [blame] | 98 | procedure Enable_Output |
| 99 | (Pipe : in Pipe_Index; |
| 100 | Pipe_Cfg : in Pipe_Config; |
| 101 | Success : out Boolean) |
| Nico Huber | 8a5a3b5 | 2018-06-04 14:42:13 +0200 | [diff] [blame] | 102 | with |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 103 | Pre => |
| 104 | Pipe_Cfg.Port in Active_Port_Type and |
| 105 | Config_Helpers.Valid_FB (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode) |
| Nico Huber | 43370ba | 2017-01-09 15:26:19 +0100 | [diff] [blame] | 106 | is |
| 107 | Port_Cfg : Port_Config; |
| 108 | begin |
| Nico Huber | 3be61d4 | 2017-01-09 13:58:18 +0100 | [diff] [blame] | 109 | pragma Debug (Debug.New_Line); |
| 110 | pragma Debug (Debug.Put_Line |
| 111 | ("Trying to enable port " & Port_Names (Pipe_Cfg.Port))); |
| 112 | |
| Nico Huber | 43370ba | 2017-01-09 15:26:19 +0100 | [diff] [blame] | 113 | Config_Helpers.Fill_Port_Config |
| 114 | (Port_Cfg, Pipe, Pipe_Cfg.Port, Pipe_Cfg.Mode, Success); |
| 115 | |
| 116 | if Success then |
| Nico Huber | 43370ba | 2017-01-09 15:26:19 +0100 | [diff] [blame] | 117 | Connector_Info.Preferred_Link_Setting (Port_Cfg, Success); |
| 118 | end if; |
| 119 | |
| 120 | -- loop over all possible DP-lane configurations |
| 121 | -- (non-DP ports use a single fake configuration) |
| 122 | while Success loop |
| 123 | pragma Loop_Invariant |
| 124 | (Pipe_Cfg.Port in Active_Port_Type and |
| 125 | Port_Cfg.Mode = Port_Cfg.Mode'Loop_Entry); |
| 126 | |
| 127 | PLLs.Alloc |
| 128 | (Port_Cfg => Port_Cfg, |
| 129 | PLL => Allocated_PLLs (Pipe), |
| 130 | Success => Success); |
| 131 | |
| 132 | if Success then |
| 133 | -- try each DP-lane configuration twice |
| 134 | for Try in 1 .. 2 loop |
| 135 | pragma Loop_Invariant |
| 136 | (Pipe_Cfg.Port in Active_Port_Type); |
| 137 | |
| Nico Huber | 4798c66 | 2017-01-11 12:44:48 +0100 | [diff] [blame] | 138 | -- Clear pending hot-plug events before every try |
| 139 | Port_Detect.Clear_Hotplug_Detect (Pipe_Cfg.Port); |
| 140 | |
| Nico Huber | 43370ba | 2017-01-09 15:26:19 +0100 | [diff] [blame] | 141 | Connectors.Pre_On |
| 142 | (Pipe => Pipe, |
| 143 | Port_Cfg => Port_Cfg, |
| 144 | PLL_Hint => PLLs.Register_Value (Allocated_PLLs (Pipe)), |
| 145 | Success => Success); |
| 146 | |
| 147 | if Success then |
| 148 | Display_Controller.On |
| 149 | (Pipe => Pipe, |
| 150 | Port_Cfg => Port_Cfg, |
| Nico Huber | 4dc4c61 | 2018-01-10 15:55:09 +0100 | [diff] [blame] | 151 | Framebuffer => Pipe_Cfg.Framebuffer, |
| 152 | Cursor => Pipe_Cfg.Cursor); |
| Nico Huber | 43370ba | 2017-01-09 15:26:19 +0100 | [diff] [blame] | 153 | |
| 154 | Connectors.Post_On |
| Arthur Heymans | 60d0e5f | 2018-03-28 17:08:27 +0200 | [diff] [blame] | 155 | (Pipe => Pipe, |
| 156 | Port_Cfg => Port_Cfg, |
| Nico Huber | 43370ba | 2017-01-09 15:26:19 +0100 | [diff] [blame] | 157 | PLL_Hint => PLLs.Register_Value (Allocated_PLLs (Pipe)), |
| 158 | Success => Success); |
| 159 | |
| 160 | if not Success then |
| 161 | Display_Controller.Off (Pipe); |
| 162 | Connectors.Post_Off (Port_Cfg); |
| 163 | end if; |
| 164 | end if; |
| 165 | |
| 166 | exit when Success; |
| 167 | end loop; |
| 168 | exit when Success; -- connection established => stop loop |
| 169 | |
| 170 | -- connection failed |
| 171 | PLLs.Free (Allocated_PLLs (Pipe)); |
| 172 | end if; |
| 173 | |
| 174 | Connector_Info.Next_Link_Setting (Port_Cfg, Success); |
| 175 | end loop; |
| 176 | |
| 177 | if Success then |
| 178 | pragma Debug (Debug.Put_Line |
| 179 | ("Enabled port " & Port_Names (Pipe_Cfg.Port))); |
| 180 | else |
| 181 | Wait_For_HPD (Pipe_Cfg.Port) := True; |
| Nico Huber | 8beafd7 | 2020-01-07 14:59:44 +0100 | [diff] [blame] | 182 | if Pipe_Cfg.Port in Internal_Port_Type then |
| Nico Huber | 43370ba | 2017-01-09 15:26:19 +0100 | [diff] [blame] | 183 | Panel.Off; |
| 184 | end if; |
| 185 | end if; |
| 186 | end Enable_Output; |
| 187 | |
| Nico Huber | 3be61d4 | 2017-01-09 13:58:18 +0100 | [diff] [blame] | 188 | procedure Disable_Output (Pipe : Pipe_Index; Pipe_Cfg : Pipe_Config) |
| 189 | is |
| 190 | Port_Cfg : Port_Config; |
| 191 | Success : Boolean; |
| 192 | begin |
| 193 | Config_Helpers.Fill_Port_Config |
| 194 | (Port_Cfg, Pipe, Pipe_Cfg.Port, Pipe_Cfg.Mode, Success); |
| 195 | if Success then |
| 196 | pragma Debug (Debug.New_Line); |
| 197 | pragma Debug (Debug.Put_Line |
| 198 | ("Disabling port " & Port_Names (Pipe_Cfg.Port))); |
| 199 | pragma Debug (Debug.New_Line); |
| 200 | |
| 201 | Connectors.Pre_Off (Port_Cfg); |
| 202 | Display_Controller.Off (Pipe); |
| 203 | Connectors.Post_Off (Port_Cfg); |
| 204 | |
| 205 | PLLs.Free (Allocated_PLLs (Pipe)); |
| 206 | end if; |
| 207 | end Disable_Output; |
| 208 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 209 | procedure Update_Outputs (Configs : Pipe_Configs) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 210 | is |
| Nico Huber | 3be61d4 | 2017-01-09 13:58:18 +0100 | [diff] [blame] | 211 | procedure Check_HPD (Port : in Active_Port_Type; Detected : out Boolean) |
| 212 | is |
| 213 | HPD_Delay_Over : constant Boolean := Time.Timed_Out (HPD_Delay (Port)); |
| 214 | begin |
| 215 | if HPD_Delay_Over then |
| 216 | Port_Detect.Hotplug_Detect (Port, Detected); |
| 217 | HPD_Delay (Port) := Time.MS_From_Now (333); |
| 218 | else |
| 219 | Detected := False; |
| 220 | end if; |
| 221 | end Check_HPD; |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 222 | |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 223 | Scaler_Reservation : Display_Controller.Scaler_Reservation := |
| 224 | Display_Controller.Null_Scaler_Reservation; |
| Nico Huber | 564103f | 2017-01-11 15:33:07 +0100 | [diff] [blame] | 225 | |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 226 | Update_Power : Boolean := False; |
| Nico Huber | b0bbdbc | 2019-09-27 22:32:21 +0200 | [diff] [blame] | 227 | Update_CDClk : Boolean; |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 228 | Old_Configs, |
| 229 | New_Configs : Pipe_Configs; |
| Nico Huber | 3d06de8 | 2018-05-29 01:35:04 +0200 | [diff] [blame] | 230 | |
| 231 | function Full_Update (Cur_Config, New_Config : Pipe_Config) return Boolean |
| 232 | is |
| 233 | begin |
| 234 | return |
| Nico Huber | 958c564 | 2018-06-02 16:59:31 +0200 | [diff] [blame] | 235 | Cur_Config.Port /= New_Config.Port |
| 236 | or else |
| 237 | Cur_Config.Mode /= New_Config.Mode |
| 238 | or else |
| Nico Huber | 3d06de8 | 2018-05-29 01:35:04 +0200 | [diff] [blame] | 239 | (Config.Use_PDW_For_EDP_Scaling and then |
| Nico Huber | 8beafd7 | 2020-01-07 14:59:44 +0100 | [diff] [blame] | 240 | (Cur_Config.Port = eDP and |
| Nico Huber | 958c564 | 2018-06-02 16:59:31 +0200 | [diff] [blame] | 241 | Requires_Scaling (Cur_Config) /= Requires_Scaling (New_Config))) |
| 242 | or else |
| 243 | (Config.Has_GMCH_PFIT_CONTROL and then |
| 244 | (Requires_Scaling (Cur_Config) /= Requires_Scaling (New_Config) or |
| 245 | Scaling_Type (Cur_Config) /= Scaling_Type (New_Config))); |
| Nico Huber | 3d06de8 | 2018-05-29 01:35:04 +0200 | [diff] [blame] | 246 | end Full_Update; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 247 | begin |
| 248 | Old_Configs := Cur_Configs; |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 249 | New_Configs := Configs; |
| 250 | |
| 251 | -- validate new configs, filter invalid configs and those waiting for HPD |
| 252 | for Pipe in Pipe_Index loop |
| 253 | declare |
| 254 | Success : Boolean := True; |
| 255 | Cur_Config : Pipe_Config renames Cur_Configs (Pipe); |
| 256 | New_Config : Pipe_Config renames New_Configs (Pipe); |
| 257 | begin |
| 258 | if New_Config.Port /= Disabled then |
| 259 | if Wait_For_HPD (New_Config.Port) then |
| 260 | Check_HPD (New_Config.Port, Success); |
| 261 | Wait_For_HPD (New_Config.Port) := not Success; |
| 262 | end if; |
| 263 | |
| 264 | Success := Success and then |
| 265 | Config_Helpers.Validate_Config |
| 266 | (New_Config.Framebuffer, New_Config.Mode, Pipe); |
| 267 | |
| 268 | if Success and then Requires_Scaling (New_Config) then |
| 269 | Display_Controller.Reserve_Scaler |
| 270 | (Success, Scaler_Reservation, Pipe); |
| 271 | end if; |
| 272 | |
| 273 | if not Success then |
| 274 | New_Config.Port := Disabled; |
| 275 | end if; |
| 276 | end if; |
| 277 | end; |
| 278 | pragma Loop_Invariant |
| 279 | (for all P in Pipe_Index'First .. Pipe => |
| 280 | New_Configs (P).Port = Disabled or |
| 281 | Config_Helpers.Valid_FB |
| 282 | (New_Configs (P).Framebuffer, New_Configs (P).Mode)); |
| 283 | end loop; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 284 | |
| Nico Huber | b0bbdbc | 2019-09-27 22:32:21 +0200 | [diff] [blame] | 285 | -- limit dotclocks to maximum CDClk, if we are about |
| 286 | -- to switch CDClk, all pipes have to be disabled |
| 287 | Power_And_Clocks.Limit_Dotclocks (New_Configs, Update_CDClk); |
| 288 | |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 289 | -- disable all pipes that changed or had a hot-plug event |
| 290 | for Pipe in Pipe_Index loop |
| 291 | declare |
| 292 | Unplug_Detected : Boolean; |
| 293 | Cur_Config : Pipe_Config renames Cur_Configs (Pipe); |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 294 | New_Config : Pipe_Config renames New_Configs (Pipe); |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 295 | begin |
| 296 | if Cur_Config.Port /= Disabled then |
| 297 | Check_HPD (Cur_Config.Port, Unplug_Detected); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 298 | |
| Nico Huber | b0bbdbc | 2019-09-27 22:32:21 +0200 | [diff] [blame] | 299 | if Update_CDClk or |
| 300 | Unplug_Detected or |
| 301 | Full_Update (Cur_Config, New_Config) |
| 302 | then |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 303 | Disable_Output (Pipe, Cur_Config); |
| 304 | Cur_Config.Port := Disabled; |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 305 | Update_Power := True; |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 306 | end if; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 307 | end if; |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 308 | end; |
| 309 | end loop; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 310 | |
| Nico Huber | b0bbdbc | 2019-09-27 22:32:21 +0200 | [diff] [blame] | 311 | -- switch CDClk if necessary and possible, limit dotclocks accordingly |
| 312 | if Update_CDClk then |
| 313 | Power_And_Clocks.Update_CDClk (New_Configs); |
| 314 | end if; |
| 315 | |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 316 | -- enable all pipes that changed and should be active |
| 317 | for Pipe in Pipe_Index loop |
| 318 | declare |
| 319 | Success : Boolean; |
| 320 | Cur_Config : Pipe_Config renames Cur_Configs (Pipe); |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 321 | New_Config : Pipe_Config renames New_Configs (Pipe); |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 322 | begin |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 323 | -- full update |
| Nico Huber | 3d06de8 | 2018-05-29 01:35:04 +0200 | [diff] [blame] | 324 | if New_Config.Port /= Disabled and |
| 325 | Full_Update (Cur_Config, New_Config) |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 326 | then |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 327 | Power_And_Clocks.Power_Up (Old_Configs, New_Configs); |
| 328 | Update_Power := True; |
| Nico Huber | c7a4fee | 2016-11-03 18:18:03 +0100 | [diff] [blame] | 329 | |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 330 | Enable_Output (Pipe, New_Config, Success); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 331 | if Success then |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 332 | Cur_Config := New_Config; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 333 | end if; |
| Nico Huber | 3be61d4 | 2017-01-09 13:58:18 +0100 | [diff] [blame] | 334 | |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 335 | -- update framebuffer offset only |
| 336 | elsif New_Config.Port /= Disabled and |
| Nico Huber | f361ec8 | 2018-06-02 18:01:45 +0200 | [diff] [blame] | 337 | Cur_Config.Framebuffer /= New_Config.Framebuffer |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 338 | then |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 339 | Display_Controller.Setup_FB |
| 340 | (Pipe, New_Config.Mode, New_Config.Framebuffer); |
| 341 | Display_Controller.Update_Cursor |
| 342 | (Pipe, New_Config.Framebuffer, New_Config.Cursor); |
| 343 | Cur_Config := New_Config; |
| Nico Huber | b56b9c5 | 2017-01-11 15:12:23 +0100 | [diff] [blame] | 344 | end if; |
| 345 | end; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 346 | end loop; |
| 347 | |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 348 | if Update_Power then |
| 349 | Power_And_Clocks.Power_Down (Old_Configs, New_Configs, Cur_Configs); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 350 | end if; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 351 | end Update_Outputs; |
| 352 | |
| 353 | ---------------------------------------------------------------------------- |
| 354 | |
| Nico Huber | 15ffc4f | 2018-01-11 14:44:43 +0100 | [diff] [blame] | 355 | procedure Update_Cursor (Pipe : Pipe_Index; Cursor : Cursor_Type) |
| 356 | is |
| 357 | begin |
| 358 | Cur_Configs (Pipe).Cursor := Cursor; |
| 359 | Display_Controller.Update_Cursor |
| 360 | (Pipe, Cur_Configs (Pipe).Framebuffer, Cur_Configs (Pipe).Cursor); |
| 361 | end Update_Cursor; |
| 362 | |
| 363 | procedure Place_Cursor |
| 364 | (Pipe : Pipe_Index; |
| 365 | X : Cursor_Pos; |
| 366 | Y : Cursor_Pos) |
| 367 | is |
| 368 | begin |
| 369 | Cur_Configs (Pipe).Cursor.Center_X := X; |
| 370 | Cur_Configs (Pipe).Cursor.Center_Y := Y; |
| 371 | Display_Controller.Place_Cursor |
| 372 | (Pipe, Cur_Configs (Pipe).Framebuffer, Cur_Configs (Pipe).Cursor); |
| 373 | end Place_Cursor; |
| 374 | |
| 375 | procedure Move_Cursor |
| 376 | (Pipe : Pipe_Index; |
| 377 | X : Cursor_Pos; |
| 378 | Y : Cursor_Pos) |
| 379 | is |
| 380 | function Cap_Add (A, B : Cursor_Pos) return Cursor_Pos is |
| 381 | (if A + B < 0 |
| 382 | then Int32'Max (Cursor_Pos'First, A + B) |
| 383 | else Int32'Min (Cursor_Pos'Last, A + B)); |
| 384 | begin |
| 385 | Place_Cursor |
| 386 | (Pipe => Pipe, |
| 387 | X => Cap_Add (Cur_Configs (Pipe).Cursor.Center_X, X), |
| 388 | Y => Cap_Add (Cur_Configs (Pipe).Cursor.Center_Y, Y)); |
| 389 | end Move_Cursor; |
| 390 | |
| 391 | ---------------------------------------------------------------------------- |
| 392 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 393 | procedure Initialize |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 394 | (Write_Delay : in Word64 := 0; |
| Nico Huber | 793a8d4 | 2016-11-21 18:57:03 +0100 | [diff] [blame] | 395 | Clean_State : in Boolean := False; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 396 | Success : out Boolean) |
| 397 | with |
| 398 | Refined_Global => |
| Nico Huber | 27088aa | 2018-06-10 13:28:05 +0200 | [diff] [blame] | 399 | (Input => (Time.State), |
| 400 | In_Out => (Dev.PCI_State, Registers.Register_State, Port_IO.State), |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 401 | Output => |
| Nico Huber | c5c66ec | 2019-09-28 23:59:45 +0200 | [diff] [blame] | 402 | (PCI_Usable, |
| 403 | Config.Variable, |
| Nico Huber | 27088aa | 2018-06-10 13:28:05 +0200 | [diff] [blame] | 404 | Dev.Address_State, |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 405 | Registers.Address_State, |
| Nico Huber | 312433c | 2019-09-28 03:15:48 +0200 | [diff] [blame] | 406 | PCode.Mailbox_Ready, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 407 | PLLs.State, Panel.Panel_State, |
| Nico Huber | 1a712d3 | 2017-01-09 15:11:04 +0100 | [diff] [blame] | 408 | Cur_Configs, Allocated_PLLs, |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 409 | HPD_Delay, Wait_For_HPD, |
| 410 | Linear_FB_Base, Initialized)) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 411 | is |
| 412 | use type HW.Word64; |
| 413 | |
| Nico Huber | 0b2329a | 2018-06-09 21:14:27 +0200 | [diff] [blame] | 414 | function MMIO_GTT_Offset return Natural is |
| 415 | (if Config.Has_64bit_GTT |
| 416 | then Registers.MMIO_GTT_64_Offset |
| 417 | else Registers.MMIO_GTT_32_Offset); |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 418 | PCI_MMIO_Base, PCI_GTT_Base : Word64; |
| 419 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 420 | Now : constant Time.T := Time.Now; |
| 421 | |
| 422 | procedure Check_Platform (Success : out Boolean) |
| 423 | is |
| 424 | Audio_VID_DID : Word32; |
| 425 | begin |
| Nico Huber | 6621a14 | 2018-06-07 23:56:54 +0200 | [diff] [blame] | 426 | case Config.Gen is |
| Arthur Heymans | 73ea032 | 2018-03-28 17:17:07 +0200 | [diff] [blame] | 427 | when G45 => |
| 428 | Registers.Read (Registers.G4X_AUD_VID_DID, Audio_VID_DID); |
| Nico Huber | 6621a14 | 2018-06-07 23:56:54 +0200 | [diff] [blame] | 429 | when Ironlake => |
| 430 | Registers.Read (Registers.PCH_AUD_VID_DID, Audio_VID_DID); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 431 | when Haswell .. Skylake => |
| 432 | Registers.Read (Registers.AUD_VID_DID, Audio_VID_DID); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 433 | end case; |
| 434 | Success := |
| Nico Huber | 998ee2b | 2018-06-12 23:02:17 +0200 | [diff] [blame] | 435 | ((Config.Gen_Broxton and Audio_VID_DID = 16#8086_280a#) or |
| Nico Huber | 88badbe | 2018-09-27 16:36:47 +0200 | [diff] [blame] | 436 | (Config.CPU_Kabylake and Audio_VID_DID = 16#8086_280b#) or |
| 437 | (Config.CPU_Skylake and Audio_VID_DID = 16#8086_2809#) or |
| Nico Huber | 998ee2b | 2018-06-12 23:02:17 +0200 | [diff] [blame] | 438 | (Config.CPU_Broadwell and Audio_VID_DID = 16#8086_2808#) or |
| 439 | (Config.CPU_Haswell and Audio_VID_DID = 16#8086_2807#) or |
| 440 | ((Config.CPU_Ivybridge or |
| 441 | Config.CPU_Sandybridge) and (Audio_VID_DID = 16#8086_2806# or |
| 442 | Audio_VID_DID = 16#8086_2805#)) or |
| 443 | (Config.CPU_Ironlake and Audio_VID_DID = 16#0000_0000#) or |
| 444 | (Config.Gen_G45 and (Audio_VID_DID = 16#8086_2801# or |
| 445 | Audio_VID_DID = 16#8086_2802# or |
| 446 | Audio_VID_DID = 16#8086_2803#))); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 447 | end Check_Platform; |
| Nico Huber | e7ac6eb | 2017-09-04 23:54:13 +0200 | [diff] [blame] | 448 | |
| 449 | procedure Check_Platform_PCI (Success : out Boolean) |
| 450 | is |
| 451 | use type HW.Word16; |
| 452 | Vendor, Device : Word16; |
| 453 | begin |
| 454 | Dev.Read16 (Vendor, PCI.Vendor_Id); |
| 455 | Dev.Read16 (Device, PCI.Device_Id); |
| 456 | |
| Nico Huber | 6a996dc | 2018-06-17 16:30:33 +0200 | [diff] [blame] | 457 | Config.Detect_CPU (Device); |
| Nico Huber | e7ac6eb | 2017-09-04 23:54:13 +0200 | [diff] [blame] | 458 | Success := Vendor = 16#8086# and Config.Compatible_GPU (Device); |
| 459 | end Check_Platform_PCI; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 460 | begin |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 461 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 462 | |
| 463 | pragma Debug (Debug.Set_Register_Write_Delay (Write_Delay)); |
| 464 | |
| Nico Huber | c5c66ec | 2019-09-28 23:59:45 +0200 | [diff] [blame] | 465 | PCI_Usable := False; |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 466 | Linear_FB_Base := 0; |
| Nico Huber | 312433c | 2019-09-28 03:15:48 +0200 | [diff] [blame] | 467 | PCode.Mailbox_Ready := False; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 468 | Wait_For_HPD := HPD_Type'(others => False); |
| 469 | HPD_Delay := HPD_Delay_Type'(others => Now); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 470 | Allocated_PLLs := (others => PLLs.Invalid); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 471 | Cur_Configs := Pipe_Configs' |
| 472 | (others => Pipe_Config' |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 473 | (Port => Disabled, |
| 474 | Framebuffer => HW.GFX.Default_FB, |
| Nico Huber | a02b2c6 | 2018-01-09 15:58:34 +0100 | [diff] [blame] | 475 | Cursor => Default_Cursor, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 476 | Mode => HW.GFX.Invalid_Mode)); |
| Nico Huber | 27088aa | 2018-06-10 13:28:05 +0200 | [diff] [blame] | 477 | Config.Variable := Config.Initial_Settings; |
| Nico Huber | 6a996dc | 2018-06-17 16:30:33 +0200 | [diff] [blame] | 478 | Registers.Set_Register_Base (Config.Default_MMIO_Base); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 479 | PLLs.Initialize; |
| 480 | |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 481 | Dev.Initialize (Success); |
| 482 | |
| 483 | if Success then |
| Nico Huber | 6a996dc | 2018-06-17 16:30:33 +0200 | [diff] [blame] | 484 | Check_Platform_PCI (Success); |
| Nico Huber | e7ac6eb | 2017-09-04 23:54:13 +0200 | [diff] [blame] | 485 | if Success then |
| Nico Huber | 6a996dc | 2018-06-17 16:30:33 +0200 | [diff] [blame] | 486 | Dev.Map (PCI_MMIO_Base, PCI.Res0, Length => MMIO_GTT_Offset); |
| 487 | Dev.Map (PCI_GTT_Base, PCI.Res0, Offset => MMIO_GTT_Offset); |
| 488 | if PCI_MMIO_Base /= 0 and PCI_GTT_Base /= 0 then |
| 489 | Registers.Set_Register_Base (PCI_MMIO_Base, PCI_GTT_Base); |
| Nico Huber | c5c66ec | 2019-09-28 23:59:45 +0200 | [diff] [blame] | 490 | PCI_Usable := True; |
| Nico Huber | 6a996dc | 2018-06-17 16:30:33 +0200 | [diff] [blame] | 491 | else |
| 492 | pragma Debug (Debug.Put_Line |
| 493 | ("ERROR: Couldn't map resoure0.")); |
| 494 | Success := Config.Default_MMIO_Base_Set; |
| 495 | end if; |
| Nico Huber | e7ac6eb | 2017-09-04 23:54:13 +0200 | [diff] [blame] | 496 | end if; |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 497 | else |
| 498 | pragma Debug (Debug.Put_Line |
| 499 | ("WARNING: Couldn't initialize PCI dev.")); |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 500 | Success := Config.Default_MMIO_Base_Set; |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 501 | |
| Nico Huber | e7ac6eb | 2017-09-04 23:54:13 +0200 | [diff] [blame] | 502 | if Success then |
| 503 | Check_Platform (Success); |
| 504 | end if; |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 505 | end if; |
| 506 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 507 | if not Success then |
| 508 | pragma Debug (Debug.Put_Line ("ERROR: Incompatible CPU or PCH.")); |
| 509 | |
| 510 | Panel.Static_Init; -- for flow analysis |
| 511 | |
| 512 | Initialized := False; |
| 513 | return; |
| 514 | end if; |
| 515 | |
| 516 | Panel.Setup_PP_Sequencer; |
| 517 | Port_Detect.Initialize; |
| Nico Huber | 0923b79 | 2017-06-09 15:28:41 +0200 | [diff] [blame] | 518 | Connectors.Initialize; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 519 | |
| Nico Huber | 793a8d4 | 2016-11-21 18:57:03 +0100 | [diff] [blame] | 520 | if Clean_State then |
| 521 | Power_And_Clocks.Pre_All_Off; |
| 522 | Connectors.Pre_All_Off; |
| 523 | Display_Controller.All_Off; |
| 524 | Connectors.Post_All_Off; |
| 525 | PLLs.All_Off; |
| 526 | Power_And_Clocks.Post_All_Off; |
| Nico Huber | 17d64b6 | 2017-07-15 20:51:25 +0200 | [diff] [blame] | 527 | Registers.Clear_Fences; |
| Nico Huber | 33912aa | 2016-12-06 20:36:23 +0100 | [diff] [blame] | 528 | else |
| 529 | -- According to PRMs, VGA plane is the only thing |
| Nico Huber | 3a0e2a0 | 2017-07-19 14:41:46 +0200 | [diff] [blame] | 530 | -- that's enabled by default after reset... |
| Nico Huber | 33912aa | 2016-12-06 20:36:23 +0100 | [diff] [blame] | 531 | Display_Controller.Legacy_VGA_Off; |
| Nico Huber | 3a0e2a0 | 2017-07-19 14:41:46 +0200 | [diff] [blame] | 532 | -- ... along with some DDI port bits since Skylake. |
| 533 | Connectors.Post_Reset_Off; |
| Nico Huber | 793a8d4 | 2016-11-21 18:57:03 +0100 | [diff] [blame] | 534 | end if; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 535 | |
| 536 | -------------------- Now restart from a clean state --------------------- |
| 537 | Power_And_Clocks.Initialize; |
| 538 | |
| Nico Huber | 1c3b928 | 2017-02-09 13:57:04 +0100 | [diff] [blame] | 539 | if Config.Has_PCH then |
| 540 | Registers.Unset_And_Set_Mask |
| 541 | (Register => Registers.PCH_RAWCLK_FREQ, |
| 542 | Mask_Unset => PCH_RAWCLK_FREQ_MASK, |
| 543 | Mask_Set => PCH_RAWCLK_FREQ (Config.Default_RawClk_Freq)); |
| 544 | end if; |
| Nico Huber | f54d096 | 2016-10-20 14:17:18 +0200 | [diff] [blame] | 545 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 546 | Initialized := True; |
| 547 | |
| 548 | end Initialize; |
| 549 | |
| 550 | function Is_Initialized return Boolean |
| 551 | with |
| 552 | Refined_Post => Is_Initialized'Result = Initialized |
| 553 | is |
| 554 | begin |
| 555 | return Initialized; |
| 556 | end Is_Initialized; |
| 557 | |
| 558 | ---------------------------------------------------------------------------- |
| 559 | |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 560 | pragma Warnings |
| 561 | (GNATprove, Off, """Registers.Register_State"" * is not modified*", |
| Nico Huber | adfe11f | 2018-06-10 14:59:04 +0200 | [diff] [blame] | 562 | Reason => "Power_Up_VGA is only effective in certain configurations."); |
| Nico Huber | 42fb2d0 | 2017-09-01 17:01:51 +0200 | [diff] [blame] | 563 | procedure Power_Up_VGA |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 564 | with |
| 565 | Refined_Global => |
| Nico Huber | adfe11f | 2018-06-10 14:59:04 +0200 | [diff] [blame] | 566 | (Input => (Cur_Configs, Config.Variable, Time.State), |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 567 | In_Out => (Registers.Register_State), |
| 568 | Proof_In => (Initialized)) |
| Nico Huber | 42fb2d0 | 2017-09-01 17:01:51 +0200 | [diff] [blame] | 569 | is |
| 570 | Fake_Config : constant Pipe_Configs := |
| 571 | (Primary => |
| 572 | (Port => Analog, |
| 573 | Framebuffer => HW.GFX.Default_FB, |
| Nico Huber | a02b2c6 | 2018-01-09 15:58:34 +0100 | [diff] [blame] | 574 | Cursor => Default_Cursor, |
| Nico Huber | 42fb2d0 | 2017-09-01 17:01:51 +0200 | [diff] [blame] | 575 | Mode => HW.GFX.Invalid_Mode), |
| 576 | others => |
| 577 | (Port => Disabled, |
| 578 | Framebuffer => HW.GFX.Default_FB, |
| Nico Huber | a02b2c6 | 2018-01-09 15:58:34 +0100 | [diff] [blame] | 579 | Cursor => Default_Cursor, |
| Nico Huber | 42fb2d0 | 2017-09-01 17:01:51 +0200 | [diff] [blame] | 580 | Mode => HW.GFX.Invalid_Mode)); |
| 581 | begin |
| 582 | Power_And_Clocks.Power_Up (Cur_Configs, Fake_Config); |
| 583 | end Power_Up_VGA; |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 584 | pragma Warnings |
| 585 | (GNATprove, Off, "no check message justified*", Reason => "see below"); |
| 586 | pragma Annotate |
| 587 | (GNATprove, Intentional, "unused global", |
| Nico Huber | adfe11f | 2018-06-10 14:59:04 +0200 | [diff] [blame] | 588 | "Power_Up_VGA is only effective in certain configurations."); |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 589 | pragma Warnings (GNATprove, On, "no check message justified*"); |
| 590 | pragma Warnings |
| 591 | (GNATprove, On, """Registers.Register_State"" * is not modified*"); |
| Nico Huber | 42fb2d0 | 2017-09-01 17:01:51 +0200 | [diff] [blame] | 592 | |
| 593 | ---------------------------------------------------------------------------- |
| 594 | |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 595 | function FB_First_Page (FB : Framebuffer_Type) return Natural is |
| Nico Huber | 34be654 | 2017-12-13 09:26:24 +0100 | [diff] [blame] | 596 | (Natural (Phys_Offset (FB) / GTT_Page_Size)); |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 597 | function FB_Pages (FB : Framebuffer_Type) return Natural is |
| 598 | (Natural (Div_Round_Up (FB_Size (FB), GTT_Page_Size))); |
| 599 | function FB_Last_Page (FB : Framebuffer_Type) return Natural is |
| 600 | (FB_First_Page (FB) + FB_Pages (FB) - 1); |
| 601 | |
| Nico Huber | 34be654 | 2017-12-13 09:26:24 +0100 | [diff] [blame] | 602 | -- Check basics and that it fits in GTT. For 90 degree rotations, |
| 603 | -- the Offset should be above GTT_Rotation_Offset. The latter will |
| 604 | -- be subtracted for the aperture mapping. |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 605 | function Valid_FB (FB : Framebuffer_Type) return Boolean is |
| Nico Huber | 34be654 | 2017-12-13 09:26:24 +0100 | [diff] [blame] | 606 | (Valid_Stride (FB) and |
| 607 | FB_First_Page (FB) in GTT_Range and |
| 608 | FB_Last_Page (FB) in GTT_Range and |
| 609 | (not Rotation_90 (FB) or |
| 610 | (FB_Last_Page (FB) + GTT_Rotation_Offset in GTT_Range and |
| 611 | FB.Offset >= Word32 (GTT_Rotation_Offset) * GTT_Page_Size))); |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 612 | |
| 613 | -- Also check that we don't overflow the GTT's 39-bit space |
| 614 | -- (always true with a 32-bit base) |
| 615 | function Valid_Phys_FB (FB : Framebuffer_Type; Phys_Base : Word32) |
| 616 | return Boolean is |
| 617 | (Valid_FB (FB) and |
| Nico Huber | 34be654 | 2017-12-13 09:26:24 +0100 | [diff] [blame] | 618 | Int64 (Phys_Base) + Int64 (Phys_Offset (FB)) + Int64 (FB_Size (FB)) <= |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 619 | Int64 (GTT_Address_Type'Last)) |
| 620 | with |
| 621 | Ghost; |
| 622 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 623 | procedure Write_GTT |
| 624 | (GTT_Page : GTT_Range; |
| 625 | Device_Address : GTT_Address_Type; |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 626 | Valid : Boolean) |
| 627 | is |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 628 | begin |
| 629 | Registers.Write_GTT (GTT_Page, Device_Address, Valid); |
| 630 | end Write_GTT; |
| 631 | |
| Nico Huber | ceda17d | 2018-06-09 22:00:29 +0200 | [diff] [blame] | 632 | procedure Read_GTT |
| 633 | (Device_Address : out GTT_Address_Type; |
| 634 | Valid : out Boolean; |
| 635 | GTT_Page : in GTT_Range) |
| 636 | is |
| 637 | begin |
| 638 | Registers.Read_GTT (Device_Address, Valid, GTT_Page); |
| 639 | end Read_GTT; |
| 640 | |
| Nico Huber | 194e57e | 2017-07-15 21:15:46 +0200 | [diff] [blame] | 641 | procedure Setup_Default_GTT (FB : Framebuffer_Type; Phys_Base : Word32) |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 642 | with |
| 643 | Pre => Is_Initialized and Valid_Phys_FB (FB, Phys_Base) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 644 | is |
| Nico Huber | 194e57e | 2017-07-15 21:15:46 +0200 | [diff] [blame] | 645 | Phys_Addr : GTT_Address_Type := |
| Nico Huber | 34be654 | 2017-12-13 09:26:24 +0100 | [diff] [blame] | 646 | GTT_Address_Type (Phys_Base) + GTT_Address_Type (Phys_Offset (FB)); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 647 | begin |
| Nico Huber | 194e57e | 2017-07-15 21:15:46 +0200 | [diff] [blame] | 648 | for Idx in FB_First_Page (FB) .. FB_Last_Page (FB) loop |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 649 | Registers.Write_GTT |
| 650 | (GTT_Page => Idx, |
| 651 | Device_Address => Phys_Addr, |
| 652 | Valid => True); |
| Nico Huber | 194e57e | 2017-07-15 21:15:46 +0200 | [diff] [blame] | 653 | Phys_Addr := Phys_Addr + GTT_Page_Size; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 654 | end loop; |
| Nico Huber | 9b47941 | 2017-08-27 11:55:56 +0200 | [diff] [blame] | 655 | |
| 656 | if Rotation_90 (FB) and FB.Tiling = Y_Tiled and FB.V_Stride >= 32 then |
| 657 | declare |
| 658 | V_Pages : constant Natural := Natural (FB.V_Stride) / 32; |
| 659 | Bytes_Per_Row : constant GTT_Address_Type := |
| 660 | GTT_Address_Type (Pixel_To_Bytes (32 * FB.Stride, FB)); |
| 661 | begin |
| 662 | Phys_Addr := GTT_Address_Type (Phys_Base) + |
| Nico Huber | 34be654 | 2017-12-13 09:26:24 +0100 | [diff] [blame] | 663 | GTT_Address_Type (Phys_Offset (FB)) + |
| Nico Huber | 9b47941 | 2017-08-27 11:55:56 +0200 | [diff] [blame] | 664 | GTT_Address_Type (FB_Size (FB)); |
| 665 | for Page in FB_First_Page (FB) .. FB_Last_Page (FB) loop |
| 666 | Phys_Addr := Phys_Addr - Bytes_Per_Row; |
| 667 | Registers.Write_GTT |
| 668 | (GTT_Page => GTT_Rotation_Offset + Page, |
| 669 | Device_Address => Phys_Addr, |
| 670 | Valid => True); |
| 671 | |
| 672 | if (Page - FB_First_Page (FB) + 1) mod V_Pages = 0 then |
| 673 | Phys_Addr := Phys_Addr + GTT_Page_Size + |
| 674 | GTT_Address_Type (V_Pages) * Bytes_Per_Row; |
| 675 | end if; |
| 676 | end loop; |
| 677 | end; |
| 678 | end if; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 679 | end Setup_Default_GTT; |
| 680 | |
| 681 | ---------------------------------------------------------------------------- |
| 682 | |
| Nico Huber | eedde88 | 2017-07-16 02:54:39 +0200 | [diff] [blame] | 683 | use type HW.Word16; |
| 684 | subtype Stolen_Size_Range is Int64 range 0 .. 2 ** 33; |
| 685 | |
| 686 | function GGMS_Gen4 (GGC : Word16) return Natural is |
| 687 | (Natural (Shift_Right (GGC, 8) and 16#07#)); |
| 688 | function GTT_Size_Gen4 (GGC : Word16) return Natural is |
| 689 | (if GGMS_Gen4 (GGC) in 1 .. 3 then |
| 690 | (GGMS_Gen4 (GGC) + 1) * 2 ** 19 else 0); |
| 691 | |
| 692 | function GMS_Gen4 (GGC : Word16) return Natural is |
| 693 | (Natural (Shift_Right (GGC, 4) and 16#0f#)); |
| 694 | Valid_Stolen_Size_Gen4 : constant |
| 695 | array (Natural range 1 .. 13) of Stolen_Size_Range := |
| 696 | (1, 4, 8, 16, 32, 48, 64, 128, 256, 96, 160, 224, 352); |
| 697 | function Stolen_Size_Gen4 (GGC : Word16) return Stolen_Size_Range is |
| 698 | (if GMS_Gen4 (GGC) in Valid_Stolen_Size_Gen4'Range then |
| Arthur Heymans | 5fd9a31 | 2017-09-12 12:45:18 +0200 | [diff] [blame] | 699 | Valid_Stolen_Size_Gen4 (GMS_Gen4 (GGC)) * 2 ** 20 else 0); |
| Nico Huber | eedde88 | 2017-07-16 02:54:39 +0200 | [diff] [blame] | 700 | |
| 701 | function GTT_Size_Gen6 (GGC : Word16) return Natural is |
| 702 | (Natural (Shift_Right (GGC, 8) and 16#03#) * 2 ** 20); |
| 703 | |
| 704 | function Stolen_Size_Gen6 (GGC : Word16) return Stolen_Size_Range is |
| 705 | (Stolen_Size_Range (Shift_Right (GGC, 3) and 16#1f#) * 32 * 2 ** 20); |
| 706 | |
| Nico Huber | fe7985f | 2019-10-12 22:19:24 +0200 | [diff] [blame] | 707 | function GGMS_Gen8 (GGC : Word16) return Natural is |
| 708 | (Natural (Shift_Right (GGC, 6) and 16#03#)); |
| Nico Huber | eedde88 | 2017-07-16 02:54:39 +0200 | [diff] [blame] | 709 | function GTT_Size_Gen8 (GGC : Word16) return Natural is |
| Nico Huber | fe7985f | 2019-10-12 22:19:24 +0200 | [diff] [blame] | 710 | (if GGMS_Gen8 (GGC) /= 0 then |
| 711 | Natural (Shift_Left (Word32'(1), 20 + GGMS_Gen8 (GGC))) else 0); |
| Nico Huber | eedde88 | 2017-07-16 02:54:39 +0200 | [diff] [blame] | 712 | |
| 713 | function GMS_Gen8 (GGC : Word16) return Stolen_Size_Range is |
| 714 | (Stolen_Size_Range (Shift_Right (GGC, 8) and 16#ff#)); |
| 715 | function Stolen_Size_Gen8 (GGC : Word16) return Stolen_Size_Range is |
| 716 | (GMS_Gen8 (GGC) * 32 * 2 ** 20); |
| 717 | |
| 718 | function Stolen_Size_Gen9 (GGC : Word16) return Stolen_Size_Range is |
| 719 | (if GMS_Gen8 (GGC) < 16#f0# then |
| 720 | Stolen_Size_Gen8 (GGC) |
| 721 | else |
| 722 | (GMS_Gen8 (GGC) - 16#f0# + 1) * 4 * 2 ** 20); |
| 723 | |
| 724 | procedure Decode_Stolen |
| 725 | (GTT_Size : out Natural; |
| 726 | Stolen_Size : out Stolen_Size_Range) |
| 727 | with |
| 728 | Pre => Is_Initialized |
| 729 | is |
| Nico Huber | 63ec836 | 2018-06-09 17:42:19 +0200 | [diff] [blame] | 730 | GGC_Reg : constant PCI.Index := |
| Nico Huber | 998ee2b | 2018-06-12 23:02:17 +0200 | [diff] [blame] | 731 | (if Config.Gen_G45 or Config.CPU_Ironlake then 16#52# else 16#50#); |
| Nico Huber | eedde88 | 2017-07-16 02:54:39 +0200 | [diff] [blame] | 732 | GGC : Word16; |
| 733 | begin |
| 734 | Dev.Read16 (GGC, GGC_Reg); |
| Nico Huber | 998ee2b | 2018-06-12 23:02:17 +0200 | [diff] [blame] | 735 | if Config.Gen_G45 or Config.CPU_Ironlake then |
| 736 | GTT_Size := GTT_Size_Gen4 (GGC); |
| 737 | Stolen_Size := Stolen_Size_Gen4 (GGC); |
| 738 | elsif Config.CPU_Sandybridge or Config.CPU_Ivybridge or Config.CPU_Haswell |
| 739 | then |
| 740 | GTT_Size := GTT_Size_Gen6 (GGC); |
| 741 | Stolen_Size := Stolen_Size_Gen6 (GGC); |
| 742 | elsif Config.CPU_Broadwell then |
| 743 | GTT_Size := GTT_Size_Gen8 (GGC); |
| 744 | Stolen_Size := Stolen_Size_Gen8 (GGC); |
| 745 | else |
| 746 | GTT_Size := GTT_Size_Gen8 (GGC); |
| 747 | Stolen_Size := Stolen_Size_Gen9 (GGC); |
| 748 | end if; |
| Nico Huber | eedde88 | 2017-07-16 02:54:39 +0200 | [diff] [blame] | 749 | end Decode_Stolen; |
| 750 | |
| 751 | -- Additional runtime validation that FB fits stolen memory and aperture. |
| 752 | procedure Validate_FB (FB : Framebuffer_Type; Valid : out Boolean) |
| 753 | with |
| 754 | Pre => Is_Initialized, |
| 755 | Post => (if Valid then Valid_FB (FB)) |
| 756 | is |
| 757 | GTT_Size, Aperture_Size : Natural; |
| 758 | Stolen_Size : Stolen_Size_Range; |
| 759 | begin |
| 760 | Valid := Valid_FB (FB); |
| 761 | |
| 762 | if Valid then |
| 763 | Decode_Stolen (GTT_Size, Stolen_Size); |
| 764 | Dev.Resource_Size (Aperture_Size, PCI.Res2); |
| 765 | Valid := |
| 766 | FB_Last_Page (FB) < GTT_Size / Config.GTT_PTE_Size and |
| 767 | FB_Last_Page (FB) < Natural (Stolen_Size / GTT_Page_Size) and |
| 768 | FB_Last_Page (FB) < Aperture_Size / GTT_Page_Size; |
| Nico Huber | 34be654 | 2017-12-13 09:26:24 +0100 | [diff] [blame] | 769 | pragma Debug (not Valid, Debug.Put_Line |
| Nico Huber | eedde88 | 2017-07-16 02:54:39 +0200 | [diff] [blame] | 770 | ("Stolen memory too small to hold framebuffer.")); |
| 771 | end if; |
| 772 | end Validate_FB; |
| 773 | |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 774 | procedure Setup_Default_FB |
| 775 | (FB : in Framebuffer_Type; |
| 776 | Clear : in Boolean := True; |
| 777 | Success : out Boolean) |
| 778 | is |
| 779 | GMA_Phys_Base : constant PCI.Index := 16#5c#; |
| 780 | GMA_Phys_Base_Mask : constant := 16#fff0_0000#; |
| 781 | |
| 782 | Phys_Base : Word32; |
| 783 | begin |
| Nico Huber | eedde88 | 2017-07-16 02:54:39 +0200 | [diff] [blame] | 784 | Validate_FB (FB, Success); |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 785 | |
| 786 | if Success then |
| 787 | Dev.Read32 (Phys_Base, GMA_Phys_Base); |
| 788 | Phys_Base := Phys_Base and GMA_Phys_Base_Mask; |
| 789 | Success := Phys_Base /= GMA_Phys_Base_Mask and Phys_Base /= 0; |
| 790 | pragma Debug (not Success, Debug.Put_Line |
| 791 | ("Failed to read stolen memory base.")); |
| Nico Huber | 0164b02 | 2017-08-24 15:12:51 +0200 | [diff] [blame] | 792 | |
| 793 | if Success then |
| 794 | if FB.Tiling in XY_Tiling then |
| 795 | Registers.Add_Fence |
| 796 | (First_Page => FB_First_Page (FB), |
| 797 | Last_Page => FB_Last_Page (FB), |
| 798 | Tiling => FB.Tiling, |
| 799 | Pitch => FB_Pitch (FB.Stride, FB), |
| 800 | Success => Success); |
| 801 | end if; |
| 802 | pragma Debug (not Success, Debug.Put_Line |
| 803 | ("Tiled framebuffer but no fence regs available.")); |
| 804 | end if; |
| 805 | |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 806 | if Success then |
| 807 | Setup_Default_GTT (FB, Phys_Base); |
| 808 | end if; |
| 809 | end if; |
| 810 | |
| 811 | if Success and then Clear then |
| 812 | declare |
| 813 | use type HW.Word64; |
| 814 | Linear_FB : Word64; |
| 815 | begin |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 816 | Map_Linear_FB (Linear_FB, FB); |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 817 | if Linear_FB /= 0 then |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 818 | Framebuffer_Filler.Fill (Linear_FB, FB); |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 819 | end if; |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 820 | end; |
| 821 | end if; |
| 822 | end Setup_Default_FB; |
| 823 | |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 824 | procedure Map_Linear_FB (Linear_FB : out Word64; FB : in Framebuffer_Type) |
| 825 | is |
| 826 | use type HW.Word64; |
| 827 | |
| 828 | Valid : Boolean; |
| 829 | begin |
| 830 | Linear_FB := 0; |
| 831 | |
| 832 | if Linear_FB_Base = 0 then |
| 833 | Dev.Map (Linear_FB_Base, PCI.Res2); |
| 834 | pragma Debug |
| 835 | (Linear_FB_Base = 0, Debug.Put_Line ("Failed to map resource2.")); |
| 836 | end if; |
| 837 | |
| 838 | if Linear_FB_Base /= 0 then |
| 839 | Validate_FB (FB, Valid); |
| 840 | if Valid then |
| Nico Huber | 34be654 | 2017-12-13 09:26:24 +0100 | [diff] [blame] | 841 | Linear_FB := Linear_FB_Base + Word64 (Phys_Offset (FB)); |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 842 | end if; |
| 843 | end if; |
| 844 | end Map_Linear_FB; |
| 845 | |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 846 | ---------------------------------------------------------------------------- |
| 847 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 848 | procedure Dump_Configs (Configs : Pipe_Configs) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 849 | is |
| 850 | subtype Pipe_Name is String (1 .. 9); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 851 | type Pipe_Name_Array is array (Pipe_Index) of Pipe_Name; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 852 | Pipe_Names : constant Pipe_Name_Array := |
| 853 | (Primary => "Primary ", |
| 854 | Secondary => "Secondary", |
| 855 | Tertiary => "Tertiary "); |
| Nico Huber | 5ef4d60 | 2017-12-13 13:56:47 +0100 | [diff] [blame] | 856 | |
| 857 | subtype Tiling_Name is String (1 .. 7); |
| 858 | type Tiling_Name_Array is array (Tiling_Type) of Tiling_Name; |
| 859 | Tilings : constant Tiling_Name_Array := |
| 860 | (Linear => "Linear ", |
| 861 | X_Tiled => "X_Tiled", |
| 862 | Y_Tiled => "Y_Tiled"); |
| 863 | |
| 864 | subtype Rotation_Name is String (1 .. 11); |
| 865 | type Rotation_Name_Array is array (Rotation_Type) of Rotation_Name; |
| 866 | Rotations : constant Rotation_Name_Array := |
| 867 | (No_Rotation => "No_Rotation", |
| 868 | Rotated_90 => "Rotated_90 ", |
| 869 | Rotated_180 => "Rotated_180", |
| 870 | Rotated_270 => "Rotated_270"); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 871 | begin |
| 872 | Debug.New_Line; |
| Paul Menzel | b83107c | 2017-05-04 09:02:33 +0200 | [diff] [blame] | 873 | Debug.Put_Line ("CONFIG =>"); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 874 | for Pipe in Pipe_Index loop |
| 875 | if Pipe = Pipe_Index'First then |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 876 | Debug.Put (" ("); |
| 877 | else |
| 878 | Debug.Put (" "); |
| 879 | end if; |
| 880 | Debug.Put_Line (Pipe_Names (Pipe) & " =>"); |
| 881 | Debug.Put_Line |
| 882 | (" (Port => " & Port_Names (Configs (Pipe).Port) & ","); |
| 883 | Debug.Put_Line (" Framebuffer =>"); |
| Nico Huber | 5ef4d60 | 2017-12-13 13:56:47 +0100 | [diff] [blame] | 884 | Debug.Put (" (Width => "); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 885 | Debug.Put_Int32 (Configs (Pipe).Framebuffer.Width); |
| 886 | Debug.Put_Line (","); |
| Nico Huber | 5ef4d60 | 2017-12-13 13:56:47 +0100 | [diff] [blame] | 887 | Debug.Put (" Height => "); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 888 | Debug.Put_Int32 (Configs (Pipe).Framebuffer.Height); |
| 889 | Debug.Put_Line (","); |
| Nico Huber | 5ef4d60 | 2017-12-13 13:56:47 +0100 | [diff] [blame] | 890 | Debug.Put (" Start_X => "); |
| 891 | Debug.Put_Int32 (Configs (Pipe).Framebuffer.Start_X); |
| 892 | Debug.Put_Line (","); |
| 893 | Debug.Put (" Start_Y => "); |
| 894 | Debug.Put_Int32 (Configs (Pipe).Framebuffer.Start_Y); |
| 895 | Debug.Put_Line (","); |
| 896 | Debug.Put (" Stride => "); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 897 | Debug.Put_Int32 (Configs (Pipe).Framebuffer.Stride); |
| 898 | Debug.Put_Line (","); |
| Nico Huber | 5ef4d60 | 2017-12-13 13:56:47 +0100 | [diff] [blame] | 899 | Debug.Put (" V_Stride => "); |
| 900 | Debug.Put_Int32 (Configs (Pipe).Framebuffer.V_Stride); |
| 901 | Debug.Put_Line (","); |
| 902 | Debug.Put (" Tiling => "); |
| 903 | Debug.Put_Line (Tilings (Configs (Pipe).Framebuffer.Tiling) & ","); |
| 904 | Debug.Put (" Rotation => "); |
| 905 | Debug.Put_Line (Rotations (Configs (Pipe).Framebuffer.Rotation) & ","); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 906 | Debug.Put (" Offset => "); |
| 907 | Debug.Put_Word32 (Configs (Pipe).Framebuffer.Offset); |
| 908 | Debug.Put_Line (","); |
| 909 | Debug.Put (" BPC => "); |
| 910 | Debug.Put_Int64 (Configs (Pipe).Framebuffer.BPC); |
| 911 | Debug.Put_Line ("),"); |
| 912 | Debug.Put_Line (" Mode =>"); |
| 913 | Debug.Put (" (Dotclock => "); |
| 914 | Debug.Put_Int64 (Configs (Pipe).Mode.Dotclock); |
| 915 | Debug.Put_Line (","); |
| 916 | Debug.Put (" H_Visible => "); |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 917 | Debug.Put_Int32 (Configs (Pipe).Mode.H_Visible); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 918 | Debug.Put_Line (","); |
| 919 | Debug.Put (" H_Sync_Begin => "); |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 920 | Debug.Put_Int32 (Configs (Pipe).Mode.H_Sync_Begin); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 921 | Debug.Put_Line (","); |
| 922 | Debug.Put (" H_Sync_End => "); |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 923 | Debug.Put_Int32 (Configs (Pipe).Mode.H_Sync_End); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 924 | Debug.Put_Line (","); |
| 925 | Debug.Put (" H_Total => "); |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 926 | Debug.Put_Int32 (Configs (Pipe).Mode.H_Total); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 927 | Debug.Put_Line (","); |
| 928 | Debug.Put (" V_Visible => "); |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 929 | Debug.Put_Int32 (Configs (Pipe).Mode.V_Visible); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 930 | Debug.Put_Line (","); |
| 931 | Debug.Put (" V_Sync_Begin => "); |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 932 | Debug.Put_Int32 (Configs (Pipe).Mode.V_Sync_Begin); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 933 | Debug.Put_Line (","); |
| 934 | Debug.Put (" V_Sync_End => "); |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 935 | Debug.Put_Int32 (Configs (Pipe).Mode.V_Sync_End); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 936 | Debug.Put_Line (","); |
| 937 | Debug.Put (" V_Total => "); |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 938 | Debug.Put_Int32 (Configs (Pipe).Mode.V_Total); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 939 | Debug.Put_Line (","); |
| 940 | Debug.Put_Line (" H_Sync_Active_High => " & |
| 941 | (if Configs (Pipe).Mode.H_Sync_Active_High |
| 942 | then "True," |
| 943 | else "False,")); |
| 944 | Debug.Put_Line (" V_Sync_Active_High => " & |
| 945 | (if Configs (Pipe).Mode.V_Sync_Active_High |
| 946 | then "True," |
| 947 | else "False,")); |
| 948 | Debug.Put (" BPC => "); |
| 949 | Debug.Put_Int64 (Configs (Pipe).Mode.BPC); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 950 | if Pipe /= Pipe_Index'Last then |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 951 | Debug.Put_Line (")),"); |
| 952 | else |
| 953 | Debug.Put_Line (")));"); |
| 954 | end if; |
| 955 | end loop; |
| 956 | end Dump_Configs; |
| 957 | |
| Nico Huber | c5c66ec | 2019-09-28 23:59:45 +0200 | [diff] [blame] | 958 | ---------------------------------------------------------------------------- |
| 959 | |
| 960 | procedure PCI_Read16 (Value : out Word16; Offset : HW.PCI.Index) is |
| 961 | begin |
| 962 | Dev.Read16 (Value, Offset); |
| 963 | end PCI_Read16; |
| 964 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 965 | end HW.GFX.GMA; |