| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 1 | -- |
| Nico Huber | 3d06de8 | 2018-05-29 01:35:04 +0200 | [diff] [blame] | 2 | -- Copyright (C) 2015-2018 secunet Security Networks AG |
| Nico Huber | 194e57e | 2017-07-15 21:15:46 +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 | 194e57e | 2017-07-15 21:15:46 +0200 | [diff] [blame] | 16 | with HW.Config; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 17 | with HW.Time; |
| Nico Huber | c5c66ec | 2019-09-28 23:59:45 +0200 | [diff] [blame^] | 18 | with HW.PCI; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 19 | with HW.Port_IO; |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 20 | with HW.GFX.Framebuffer_Filler; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 21 | |
| 22 | package HW.GFX.GMA |
| 23 | with |
| 24 | Abstract_State => |
| 25 | (State, |
| 26 | Init_State, |
| 27 | Config_State, |
| 28 | (Device_State with External)), |
| Nico Huber | 27088aa | 2018-06-10 13:28:05 +0200 | [diff] [blame] | 29 | Initializes => Init_State |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 30 | is |
| 31 | |
| Nico Huber | a02b2c6 | 2018-01-09 15:58:34 +0100 | [diff] [blame] | 32 | GTT_Page_Size : constant := 4096; |
| 33 | type GTT_Address_Type is mod 2 ** 39; |
| 34 | subtype GTT_Range is Natural range 0 .. 16#8_0000# - 1; |
| 35 | GTT_Rotation_Offset : constant GTT_Range := GTT_Range'Last / 2 + 1; |
| 36 | |
| Nico Huber | 6621a14 | 2018-06-07 23:56:54 +0200 | [diff] [blame] | 37 | type Generation is (G45, Ironlake, Haswell, Broxton, Skylake); |
| 38 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 39 | type CPU_Type is |
| Arthur Heymans | 73ea032 | 2018-03-28 17:17:07 +0200 | [diff] [blame] | 40 | (G45, |
| Nico Huber | 7f3e280 | 2019-09-28 20:40:55 +0200 | [diff] [blame] | 41 | GM45, |
| Arthur Heymans | 73ea032 | 2018-03-28 17:17:07 +0200 | [diff] [blame] | 42 | Ironlake, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 43 | Sandybridge, |
| 44 | Ivybridge, |
| 45 | Haswell, |
| 46 | Broadwell, |
| Nico Huber | 21da574 | 2017-01-20 14:00:53 +0100 | [diff] [blame] | 47 | Broxton, |
| Nico Huber | 88badbe | 2018-09-27 16:36:47 +0200 | [diff] [blame] | 48 | Skylake, |
| 49 | Kabylake); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 50 | |
| Nico Huber | 25fdb15 | 2019-02-17 15:54:39 +0100 | [diff] [blame] | 51 | type CPU_Variant is (Normal, ULT, ULX); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 52 | |
| 53 | type Port_Type is |
| 54 | (Disabled, |
| 55 | Internal, |
| 56 | DP1, |
| 57 | DP2, |
| 58 | DP3, |
| Nico Huber | 0d454cd | 2016-11-21 13:33:43 +0100 | [diff] [blame] | 59 | HDMI1, -- or DVI |
| 60 | HDMI2, -- or DVI |
| 61 | HDMI3, -- or DVI |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 62 | Analog); |
| Nico Huber | 040d9b6 | 2019-02-18 00:52:00 +0100 | [diff] [blame] | 63 | subtype Active_Port_Type is Port_Type |
| 64 | range Port_Type'Succ (Disabled) .. Port_Type'Last; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 65 | |
| Nico Huber | a02b2c6 | 2018-01-09 15:58:34 +0100 | [diff] [blame] | 66 | type Cursor_Mode is (No_Cursor, ARGB_Cursor); |
| 67 | type Cursor_Size is (Cursor_64x64, Cursor_128x128, Cursor_256x256); |
| 68 | Cursor_Width : constant array (Cursor_Size) of Width_Type := (64, 128, 256); |
| 69 | |
| 70 | subtype Cursor_Pos is Int32 range Int32'First / 2 .. Int32'Last / 2; |
| 71 | |
| 72 | type Cursor_Type is record |
| 73 | Mode : Cursor_Mode; |
| 74 | Size : Cursor_Size; |
| 75 | Center_X : Cursor_Pos; |
| 76 | Center_Y : Cursor_Pos; |
| 77 | GTT_Offset : GTT_Range; |
| 78 | end record; |
| 79 | Default_Cursor : constant Cursor_Type := |
| 80 | (Mode => No_Cursor, |
| 81 | Size => Cursor_Size'First, |
| 82 | Center_X => 0, |
| 83 | Center_Y => 0, |
| 84 | GTT_Offset => 0); |
| 85 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 86 | type Pipe_Config is record |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 87 | Port : Port_Type; |
| 88 | Framebuffer : Framebuffer_Type; |
| Nico Huber | a02b2c6 | 2018-01-09 15:58:34 +0100 | [diff] [blame] | 89 | Cursor : Cursor_Type; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 90 | Mode : Mode_Type; |
| 91 | end record; |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 92 | type Pipe_Index is (Primary, Secondary, Tertiary); |
| 93 | type Pipe_Configs is array (Pipe_Index) of Pipe_Config; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 94 | |
| Nico Huber | 3675db5 | 2016-11-04 16:27:29 +0100 | [diff] [blame] | 95 | -- Special framebuffer offset to indicate legacy VGA plane. |
| 96 | -- Only valid on primary pipe. |
| 97 | VGA_PLANE_FRAMEBUFFER_OFFSET : constant := 16#ffff_ffff#; |
| 98 | |
| Nico Huber | bebca13 | 2017-06-12 23:04:46 +0200 | [diff] [blame] | 99 | pragma Warnings (GNATprove, Off, "unused variable ""Write_Delay""", |
| 100 | Reason => "Write_Delay is used for debugging only"); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 101 | procedure Initialize |
| Nico Huber | 2b6f699 | 2017-07-09 18:11:34 +0200 | [diff] [blame] | 102 | (Write_Delay : in Word64 := 0; |
| Nico Huber | 793a8d4 | 2016-11-21 18:57:03 +0100 | [diff] [blame] | 103 | Clean_State : in Boolean := False; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 104 | Success : out Boolean) |
| 105 | with |
| 106 | Global => |
| Nico Huber | 27088aa | 2018-06-10 13:28:05 +0200 | [diff] [blame] | 107 | (In_Out => (Device_State, Port_IO.State), |
| 108 | Output => (State, Init_State, Config_State), |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 109 | Input => (Time.State)), |
| 110 | Post => Success = Is_Initialized; |
| 111 | function Is_Initialized return Boolean |
| 112 | with |
| 113 | Global => (Input => Init_State); |
| Nico Huber | bebca13 | 2017-06-12 23:04:46 +0200 | [diff] [blame] | 114 | pragma Warnings (GNATprove, On, "unused variable ""Write_Delay"""); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 115 | |
| Nico Huber | 42fb2d0 | 2017-09-01 17:01:51 +0200 | [diff] [blame] | 116 | procedure Power_Up_VGA |
| 117 | with |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 118 | Global => |
| Nico Huber | adfe11f | 2018-06-10 14:59:04 +0200 | [diff] [blame] | 119 | (Input => (State, Config_State, Time.State), |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 120 | In_Out => (Device_State), |
| 121 | Proof_In => (Init_State)), |
| Nico Huber | 42fb2d0 | 2017-09-01 17:01:51 +0200 | [diff] [blame] | 122 | Pre => Is_Initialized; |
| 123 | |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 124 | ---------------------------------------------------------------------------- |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 125 | |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 126 | procedure Update_Outputs (Configs : Pipe_Configs) |
| 127 | with |
| 128 | Global => |
| 129 | (Input => (Config_State, Time.State), |
| 130 | In_Out => (State, Device_State, Port_IO.State), |
| 131 | Proof_In => (Init_State)), |
| 132 | Pre => Is_Initialized; |
| 133 | |
| Nico Huber | 75a707f | 2018-06-18 16:28:33 +0200 | [diff] [blame] | 134 | pragma Warnings (GNATprove, Off, "no check message justified by this", |
| 135 | Reason => "see Annotate aspects."); |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 136 | procedure Update_Cursor (Pipe : Pipe_Index; Cursor : Cursor_Type) |
| 137 | with |
| 138 | Global => |
| Nico Huber | 75a707f | 2018-06-18 16:28:33 +0200 | [diff] [blame] | 139 | (Input => (Config_State), |
| 140 | In_Out => (State, Device_State), |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 141 | Proof_In => (Init_State)), |
| Nico Huber | 75a707f | 2018-06-18 16:28:33 +0200 | [diff] [blame] | 142 | Pre => Is_Initialized, |
| 143 | Annotate => |
| 144 | (GNATprove, Intentional, |
| 145 | "global input ""GMA.Config_State"" of ""Update_Cursor"" not read", |
| 146 | "Reading of Config_State depends on the platform configuration."); |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 147 | |
| Nico Huber | 15ffc4f | 2018-01-11 14:44:43 +0100 | [diff] [blame] | 148 | procedure Place_Cursor |
| 149 | (Pipe : Pipe_Index; |
| 150 | X : Cursor_Pos; |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 151 | Y : Cursor_Pos) |
| 152 | with |
| 153 | Global => |
| Nico Huber | 75a707f | 2018-06-18 16:28:33 +0200 | [diff] [blame] | 154 | (Input => (Config_State), |
| 155 | In_Out => (State, Device_State), |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 156 | Proof_In => (Init_State)), |
| Nico Huber | 75a707f | 2018-06-18 16:28:33 +0200 | [diff] [blame] | 157 | Pre => Is_Initialized, |
| 158 | Annotate => |
| 159 | (GNATprove, Intentional, |
| 160 | "global input ""GMA.Config_State"" of ""Place_Cursor"" not read", |
| 161 | "Reading of Config_State depends on the platform configuration."); |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 162 | |
| Nico Huber | 15ffc4f | 2018-01-11 14:44:43 +0100 | [diff] [blame] | 163 | procedure Move_Cursor |
| 164 | (Pipe : Pipe_Index; |
| 165 | X : Cursor_Pos; |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 166 | Y : Cursor_Pos) |
| 167 | with |
| 168 | Global => |
| Nico Huber | 75a707f | 2018-06-18 16:28:33 +0200 | [diff] [blame] | 169 | (Input => (Config_State), |
| 170 | In_Out => (State, Device_State), |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 171 | Proof_In => (Init_State)), |
| Nico Huber | 75a707f | 2018-06-18 16:28:33 +0200 | [diff] [blame] | 172 | Pre => Is_Initialized, |
| 173 | Annotate => |
| 174 | (GNATprove, Intentional, |
| 175 | "global input ""GMA.Config_State"" of ""Move_Cursor"" not read", |
| 176 | "Reading of Config_State depends on the platform configuration."); |
| Nico Huber | 15ffc4f | 2018-01-11 14:44:43 +0100 | [diff] [blame] | 177 | |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 178 | ---------------------------------------------------------------------------- |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 179 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 180 | procedure Write_GTT |
| 181 | (GTT_Page : GTT_Range; |
| 182 | Device_Address : GTT_Address_Type; |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 183 | Valid : Boolean) |
| 184 | with |
| Nico Huber | adfe11f | 2018-06-10 14:59:04 +0200 | [diff] [blame] | 185 | Global => |
| 186 | (Input => Config_State, |
| 187 | In_Out => Device_State, Proof_In => Init_State), |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 188 | Pre => Is_Initialized; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 189 | |
| Nico Huber | ceda17d | 2018-06-09 22:00:29 +0200 | [diff] [blame] | 190 | procedure Read_GTT |
| 191 | (Device_Address : out GTT_Address_Type; |
| 192 | Valid : out Boolean; |
| 193 | GTT_Page : in GTT_Range) |
| 194 | with |
| Nico Huber | adfe11f | 2018-06-10 14:59:04 +0200 | [diff] [blame] | 195 | Global => |
| 196 | (Input => Config_State, |
| 197 | In_Out => Device_State, Proof_In => Init_State), |
| Nico Huber | ceda17d | 2018-06-09 22:00:29 +0200 | [diff] [blame] | 198 | Pre => Is_Initialized; |
| 199 | |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 200 | procedure Setup_Default_FB |
| 201 | (FB : in Framebuffer_Type; |
| 202 | Clear : in Boolean := True; |
| 203 | Success : out Boolean) |
| Nico Huber | 194e57e | 2017-07-15 21:15:46 +0200 | [diff] [blame] | 204 | with |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 205 | Global => |
| Nico Huber | adfe11f | 2018-06-10 14:59:04 +0200 | [diff] [blame] | 206 | (Input => Config_State, |
| 207 | In_Out => |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 208 | (State, Device_State, |
| 209 | Framebuffer_Filler.State, Framebuffer_Filler.Base_Address), |
| 210 | Proof_In => (Init_State)), |
| Nico Huber | 5374c3a | 2017-07-15 21:48:06 +0200 | [diff] [blame] | 211 | Pre => Is_Initialized and HW.Config.Dynamic_MMIO; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 212 | |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 213 | procedure Map_Linear_FB (Linear_FB : out Word64; FB : in Framebuffer_Type) |
| 214 | with |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 215 | Global => |
| Nico Huber | adfe11f | 2018-06-10 14:59:04 +0200 | [diff] [blame] | 216 | (Input => Config_State, |
| 217 | In_Out => (State, Device_State), |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 218 | Proof_In => (Init_State)), |
| Nico Huber | adfe11f | 2018-06-10 14:59:04 +0200 | [diff] [blame] | 219 | Pre => Is_Initialized and HW.Config.Dynamic_MMIO, |
| 220 | Annotate => |
| 221 | (GNATprove, Intentional, |
| 222 | "global input ""GMA.Config_State"" of ""Map_Linear_FB"" not read", |
| 223 | "Reading of Config_State depends on the platform configuration."); |
| 224 | pragma Warnings (GNATprove, On, "no check message justified by this"); |
| Nico Huber | c3f66f6 | 2017-07-16 21:39:54 +0200 | [diff] [blame] | 225 | |
| Nico Huber | cf88f3d | 2018-06-05 13:27:34 +0200 | [diff] [blame] | 226 | ---------------------------------------------------------------------------- |
| 227 | |
| 228 | pragma Warnings (GNATprove, Off, "subprogram ""Dump_Configs"" has no effect", |
| 229 | Reason => "It's only used for debugging"); |
| 230 | procedure Dump_Configs (Configs : Pipe_Configs); |
| 231 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 232 | private |
| 233 | |
| Nico Huber | c5c66ec | 2019-09-28 23:59:45 +0200 | [diff] [blame^] | 234 | PCI_Usable : Boolean with Part_Of => State; |
| 235 | use type HW.PCI.Index; |
| 236 | procedure PCI_Read16 (Value : out Word16; Offset : HW.PCI.Index) |
| 237 | with |
| 238 | Pre => PCI_Usable and Offset mod 2 = 0; |
| 239 | |
| 240 | ---------------------------------------------------------------------------- |
| 241 | |
| Nico Huber | 3299ad5 | 2018-06-02 16:53:39 +0200 | [diff] [blame] | 242 | -- For the default framebuffer setup (see below) with 90 degree rotations, |
| 243 | -- we expect the offset which is used for the final scanout to be above |
| 244 | -- `GTT_Rotation_Offset`. So we can use `Offset - GTT_Rotation_Offset` for |
| 245 | -- the physical memory location and aperture mapping. |
| 246 | function Phys_Offset (FB : Framebuffer_Type) return Word32 is |
| 247 | (if Rotation_90 (FB) |
| 248 | then FB.Offset - Word32 (GTT_Rotation_Offset) * GTT_Page_Size |
| 249 | else FB.Offset); |
| 250 | |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 251 | ---------------------------------------------------------------------------- |
| 252 | -- State tracking for the currently configured pipes |
| 253 | |
| 254 | Cur_Configs : Pipe_Configs with Part_Of => State; |
| 255 | |
| Nico Huber | 3d06de8 | 2018-05-29 01:35:04 +0200 | [diff] [blame] | 256 | function Requires_Scaling (Pipe_Cfg : Pipe_Config) return Boolean is |
| 257 | (Requires_Scaling (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode)); |
| 258 | |
| Nico Huber | b217ece | 2018-06-02 16:56:35 +0200 | [diff] [blame] | 259 | function Scaling_Type (Pipe_Cfg : Pipe_Config) return Scaling_Aspect is |
| 260 | (Scaling_Type (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode)); |
| 261 | |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 262 | ---------------------------------------------------------------------------- |
| 263 | -- Internal representation of a single pipe's configuration |
| 264 | |
| Arthur Heymans | 5d08a93 | 2018-03-28 17:00:18 +0200 | [diff] [blame] | 265 | type GPU_Port is (DIGI_A, DIGI_B, DIGI_C, DIGI_D, DIGI_E, LVDS, VGA); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 266 | |
| 267 | subtype Digital_Port is GPU_Port range DIGI_A .. DIGI_E; |
| Arthur Heymans | 5d08a93 | 2018-03-28 17:00:18 +0200 | [diff] [blame] | 268 | subtype GMCH_DP_Port is GPU_Port range DIGI_B .. DIGI_D; |
| 269 | subtype GMCH_HDMI_Port is GPU_Port range DIGI_B .. DIGI_C; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 270 | |
| 271 | type PCH_Port is |
| 272 | (PCH_DAC, PCH_LVDS, |
| 273 | PCH_HDMI_B, PCH_HDMI_C, PCH_HDMI_D, |
| 274 | PCH_DP_B, PCH_DP_C, PCH_DP_D); |
| 275 | |
| 276 | subtype PCH_HDMI_Port is PCH_Port range PCH_HDMI_B .. PCH_HDMI_D; |
| 277 | subtype PCH_DP_Port is PCH_Port range PCH_DP_B .. PCH_DP_D; |
| 278 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 279 | type Port_Config is |
| 280 | record |
| 281 | Port : GPU_Port; |
| 282 | PCH_Port : GMA.PCH_Port; |
| 283 | Display : Display_Type; |
| 284 | Mode : Mode_Type; |
| 285 | Is_FDI : Boolean; |
| 286 | FDI : DP_Link; |
| 287 | DP : DP_Link; |
| 288 | end record; |
| 289 | |
| 290 | type FDI_Training_Type is (Simple_Training, Full_Training, Auto_Training); |
| 291 | |
| 292 | ---------------------------------------------------------------------------- |
| 293 | |
| 294 | type DP_Port is (DP_A, DP_B, DP_C, DP_D); |
| 295 | |
| Nico Huber | 247adf3 | 2017-06-12 14:39:11 +0200 | [diff] [blame] | 296 | ---------------------------------------------------------------------------- |
| 297 | |
| 298 | subtype DDI_HDMI_Buf_Trans_Range is Integer range 0 .. 11; |
| 299 | |
| Nico Huber | 0164b02 | 2017-08-24 15:12:51 +0200 | [diff] [blame] | 300 | ---------------------------------------------------------------------------- |
| 301 | |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 302 | Tile_Width : constant array (Tiling_Type) of Width_Type := |
| Nico Huber | 0164b02 | 2017-08-24 15:12:51 +0200 | [diff] [blame] | 303 | (Linear => 16, X_Tiled => 128, Y_Tiled => 32); |
| Nico Huber | c5c767a | 2018-06-03 01:09:04 +0200 | [diff] [blame] | 304 | Tile_Rows : constant array (Tiling_Type) of Height_Type := |
| Nico Huber | 9b47941 | 2017-08-27 11:55:56 +0200 | [diff] [blame] | 305 | (Linear => 1, X_Tiled => 8, Y_Tiled => 32); |
| Nico Huber | 0164b02 | 2017-08-24 15:12:51 +0200 | [diff] [blame] | 306 | |
| Nico Huber | 5ef4d60 | 2017-12-13 13:56:47 +0100 | [diff] [blame] | 307 | function FB_Pitch (Px : Pos_Pixel_Type; FB : Framebuffer_Type) return Natural |
| 308 | is (Natural (Div_Round_Up |
| 309 | (Pixel_To_Bytes (Px, FB), Tile_Width (FB.Tiling) * 4))); |
| Nico Huber | 0164b02 | 2017-08-24 15:12:51 +0200 | [diff] [blame] | 310 | |
| 311 | function Valid_Stride (FB : Framebuffer_Type) return Boolean is |
| Nico Huber | 5ef4d60 | 2017-12-13 13:56:47 +0100 | [diff] [blame] | 312 | (FB.Width + FB.Start_X <= FB.Stride and |
| Nico Huber | 9b47941 | 2017-08-27 11:55:56 +0200 | [diff] [blame] | 313 | Pixel_To_Bytes (FB.Stride, FB) mod (Tile_Width (FB.Tiling) * 4) = 0 and |
| Nico Huber | 5ef4d60 | 2017-12-13 13:56:47 +0100 | [diff] [blame] | 314 | FB.Height + FB.Start_Y <= FB.V_Stride and |
| Nico Huber | 9b47941 | 2017-08-27 11:55:56 +0200 | [diff] [blame] | 315 | FB.V_Stride mod Tile_Rows (FB.Tiling) = 0); |
| Nico Huber | 0164b02 | 2017-08-24 15:12:51 +0200 | [diff] [blame] | 316 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 317 | end HW.GFX.GMA; |