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