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