| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 1 | -- |
| 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG |
| 3 | -- |
| 4 | -- This program is free software; you can redistribute it and/or modify |
| 5 | -- it under the terms of the GNU General Public License as published by |
| Nico Huber | 125a29e | 2016-10-18 00:23:54 +0200 | [diff] [blame] | 6 | -- the Free Software Foundation; either version 2 of the License, or |
| 7 | -- (at your option) any later version. |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 8 | -- |
| 9 | -- This program is distributed in the hope that it will be useful, |
| 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | -- GNU General Public License for more details. |
| 13 | -- |
| 14 | |
| 15 | with HW.GFX.GMA.Registers; |
| 16 | |
| Nico Huber | 47ff069 | 2016-11-04 14:29:39 +0100 | [diff] [blame] | 17 | use type HW.Int32; |
| 18 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 19 | private package HW.GFX.GMA.Pipe_Setup |
| 20 | is |
| 21 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 22 | procedure On |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 23 | (Pipe : Pipe_Index; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 24 | Port_Cfg : Port_Config; |
| Nico Huber | 47ff069 | 2016-11-04 14:29:39 +0100 | [diff] [blame] | 25 | Framebuffer : Framebuffer_Type) |
| 26 | with |
| 27 | Pre => |
| 28 | Framebuffer.Width <= Pos32 (Port_Cfg.Mode.H_Visible) and |
| 29 | Framebuffer.Height <= Pos32 (Port_Cfg.Mode.V_Visible); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 30 | |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 31 | procedure Off (Pipe : Pipe_Index; Port_Cfg : Port_Config); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 32 | |
| 33 | procedure All_Off; |
| 34 | |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 35 | function Get_Pipe_Hint (Pipe : Pipe_Index) return Word32; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 36 | |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 37 | procedure Update_Offset (Pipe : Pipe_Index; Framebuffer : Framebuffer_Type); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 38 | |
| 39 | private |
| 40 | |
| 41 | subtype WM_Levels is Natural range 0 .. 7; |
| 42 | type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index; |
| 43 | |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 44 | ---------------------------------------------------------------------------- |
| 45 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 46 | type Controller_Type is |
| 47 | record |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 48 | Pipe : Pipe_Index; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 49 | PIPESRC : Registers.Registers_Index; |
| 50 | PIPEMISC : Registers.Registers_Index; |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 51 | PF_CTRL : Registers.Registers_Index; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 52 | PF_WIN_POS : Registers.Registers_Index; |
| 53 | PF_WIN_SZ : Registers.Registers_Index; |
| 54 | DSPCNTR : Registers.Registers_Index; |
| 55 | DSPLINOFF : Registers.Registers_Index; |
| 56 | DSPSTRIDE : Registers.Registers_Index; |
| 57 | DSPSURF : Registers.Registers_Index; |
| 58 | DSPTILEOFF : Registers.Registers_Index; |
| 59 | SPCNTR : Registers.Registers_Index; |
| 60 | TRANS_CLK_SEL : Registers.Registers_Index; |
| 61 | -- Skylake registers (partially aliased) |
| 62 | PLANE_CTL : Registers.Registers_Index; |
| 63 | PLANE_OFFSET : Registers.Registers_Index; |
| 64 | PLANE_POS : Registers.Registers_Index; |
| 65 | PLANE_SIZE : Registers.Registers_Index; |
| 66 | PLANE_STRIDE : Registers.Registers_Index; |
| 67 | PLANE_SURF : Registers.Registers_Index; |
| 68 | PS_CTRL_1 : Registers.Registers_Index; |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 69 | PS_WIN_POS_1 : Registers.Registers_Index; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 70 | PS_WIN_SZ_1 : Registers.Registers_Index; |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 71 | PS_CTRL_2 : Registers.Registers_Invalid_Index; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 72 | PS_WIN_SZ_2 : Registers.Registers_Invalid_Index; |
| 73 | WM_LINETIME : Registers.Registers_Index; |
| 74 | PLANE_BUF_CFG : Registers.Registers_Index; |
| 75 | PLANE_WM : PLANE_WM_Type; |
| 76 | end record; |
| 77 | |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 78 | type Controller_Array is array (Pipe_Index) of Controller_Type; |
| 79 | |
| 80 | ---------------------------------------------------------------------------- |
| 81 | |
| 82 | type Pipe_Head is (Head_EDP, Head_A, Head_B, Head_C); |
| 83 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 84 | type Head_Type is |
| 85 | record |
| 86 | Head : Pipe_Head; |
| 87 | HTOTAL : Registers.Registers_Index; |
| 88 | HBLANK : Registers.Registers_Index; |
| 89 | HSYNC : Registers.Registers_Index; |
| 90 | VTOTAL : Registers.Registers_Index; |
| 91 | VBLANK : Registers.Registers_Index; |
| 92 | VSYNC : Registers.Registers_Index; |
| 93 | PIPECONF : Registers.Registers_Index; |
| 94 | PIPE_DATA_M1 : Registers.Registers_Index; |
| 95 | PIPE_DATA_N1 : Registers.Registers_Index; |
| 96 | PIPE_LINK_M1 : Registers.Registers_Index; |
| 97 | PIPE_LINK_N1 : Registers.Registers_Index; |
| 98 | PIPE_DDI_FUNC_CTL : Registers.Registers_Index; |
| 99 | PIPE_MSA_MISC : Registers.Registers_Index; |
| 100 | end record; |
| 101 | |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 102 | type Head_Array is array (Pipe_Head) of Head_Type; |
| 103 | |
| 104 | ---------------------------------------------------------------------------- |
| 105 | |
| 106 | Controllers : constant Controller_Array := |
| 107 | (Primary => Controller_Type' |
| 108 | (Pipe => Primary, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 109 | PIPESRC => Registers.PIPEASRC, |
| 110 | PIPEMISC => Registers.PIPEAMISC, |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 111 | PF_CTRL => Registers.PFA_CTL_1, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 112 | PF_WIN_POS => Registers.PFA_WIN_POS, |
| 113 | PF_WIN_SZ => Registers.PFA_WIN_SZ, |
| 114 | DSPCNTR => Registers.DSPACNTR, |
| 115 | DSPLINOFF => Registers.DSPALINOFF, |
| 116 | DSPSTRIDE => Registers.DSPASTRIDE, |
| 117 | DSPSURF => Registers.DSPASURF, |
| 118 | DSPTILEOFF => Registers.DSPATILEOFF, |
| 119 | SPCNTR => Registers.SPACNTR, |
| 120 | TRANS_CLK_SEL => Registers.TRANSA_CLK_SEL, |
| 121 | PLANE_CTL => Registers.DSPACNTR, |
| 122 | PLANE_OFFSET => Registers.DSPATILEOFF, |
| 123 | PLANE_POS => Registers.PLANE_POS_1_A, |
| 124 | PLANE_SIZE => Registers.PLANE_SIZE_1_A, |
| 125 | PLANE_STRIDE => Registers.DSPASTRIDE, |
| 126 | PLANE_SURF => Registers.DSPASURF, |
| 127 | PS_CTRL_1 => Registers.PS_CTRL_1_A, |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 128 | PS_WIN_POS_1 => Registers.PS_WIN_POS_1_A, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 129 | PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_A, |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 130 | PS_CTRL_2 => Registers.PS_CTRL_2_A, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 131 | PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_A, |
| 132 | WM_LINETIME => Registers.WM_LINETIME_A, |
| 133 | PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_A, |
| 134 | PLANE_WM => PLANE_WM_Type'( |
| 135 | Registers.PLANE_WM_1_A_0, |
| 136 | Registers.PLANE_WM_1_A_1, |
| 137 | Registers.PLANE_WM_1_A_2, |
| 138 | Registers.PLANE_WM_1_A_3, |
| 139 | Registers.PLANE_WM_1_A_4, |
| 140 | Registers.PLANE_WM_1_A_5, |
| 141 | Registers.PLANE_WM_1_A_6, |
| 142 | Registers.PLANE_WM_1_A_7)), |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 143 | Secondary => Controller_Type' |
| 144 | (Pipe => Secondary, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 145 | PIPESRC => Registers.PIPEBSRC, |
| 146 | PIPEMISC => Registers.PIPEBMISC, |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 147 | PF_CTRL => Registers.PFB_CTL_1, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 148 | PF_WIN_POS => Registers.PFB_WIN_POS, |
| 149 | PF_WIN_SZ => Registers.PFB_WIN_SZ, |
| 150 | DSPCNTR => Registers.DSPBCNTR, |
| 151 | DSPLINOFF => Registers.DSPBLINOFF, |
| 152 | DSPSTRIDE => Registers.DSPBSTRIDE, |
| 153 | DSPSURF => Registers.DSPBSURF, |
| 154 | DSPTILEOFF => Registers.DSPBTILEOFF, |
| 155 | SPCNTR => Registers.SPBCNTR, |
| 156 | TRANS_CLK_SEL => Registers.TRANSB_CLK_SEL, |
| 157 | PLANE_CTL => Registers.DSPBCNTR, |
| 158 | PLANE_OFFSET => Registers.DSPBTILEOFF, |
| 159 | PLANE_POS => Registers.PLANE_POS_1_B, |
| 160 | PLANE_SIZE => Registers.PLANE_SIZE_1_B, |
| 161 | PLANE_STRIDE => Registers.DSPBSTRIDE, |
| 162 | PLANE_SURF => Registers.DSPBSURF, |
| 163 | PS_CTRL_1 => Registers.PS_CTRL_1_B, |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 164 | PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 165 | PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B, |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 166 | PS_CTRL_2 => Registers.PS_CTRL_2_B, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 167 | PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B, |
| 168 | WM_LINETIME => Registers.WM_LINETIME_B, |
| 169 | PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B, |
| 170 | PLANE_WM => PLANE_WM_Type'( |
| 171 | Registers.PLANE_WM_1_B_0, |
| 172 | Registers.PLANE_WM_1_B_1, |
| 173 | Registers.PLANE_WM_1_B_2, |
| 174 | Registers.PLANE_WM_1_B_3, |
| 175 | Registers.PLANE_WM_1_B_4, |
| 176 | Registers.PLANE_WM_1_B_5, |
| 177 | Registers.PLANE_WM_1_B_6, |
| 178 | Registers.PLANE_WM_1_B_7)), |
| Nico Huber | f3e2366 | 2016-12-05 21:33:03 +0100 | [diff] [blame^] | 179 | Tertiary => Controller_Type' |
| 180 | (Pipe => Tertiary, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 181 | PIPESRC => Registers.PIPECSRC, |
| 182 | PIPEMISC => Registers.PIPECMISC, |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 183 | PF_CTRL => Registers.PFC_CTL_1, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 184 | PF_WIN_POS => Registers.PFC_WIN_POS, |
| 185 | PF_WIN_SZ => Registers.PFC_WIN_SZ, |
| 186 | DSPCNTR => Registers.DSPCCNTR, |
| 187 | DSPLINOFF => Registers.DSPCLINOFF, |
| 188 | DSPSTRIDE => Registers.DSPCSTRIDE, |
| 189 | DSPSURF => Registers.DSPCSURF, |
| 190 | DSPTILEOFF => Registers.DSPCTILEOFF, |
| 191 | SPCNTR => Registers.SPCCNTR, |
| 192 | TRANS_CLK_SEL => Registers.TRANSC_CLK_SEL, |
| 193 | PLANE_CTL => Registers.DSPCCNTR, |
| 194 | PLANE_OFFSET => Registers.DSPCTILEOFF, |
| 195 | PLANE_POS => Registers.PLANE_POS_1_C, |
| 196 | PLANE_SIZE => Registers.PLANE_SIZE_1_C, |
| 197 | PLANE_STRIDE => Registers.DSPCSTRIDE, |
| 198 | PLANE_SURF => Registers.DSPCSURF, |
| 199 | PS_CTRL_1 => Registers.PS_CTRL_1_C, |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 200 | PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 201 | PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C, |
| Nico Huber | 4916e34 | 2016-11-04 14:37:53 +0100 | [diff] [blame] | 202 | PS_CTRL_2 => Registers.Invalid_Register, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 203 | PS_WIN_SZ_2 => Registers.Invalid_Register, |
| 204 | WM_LINETIME => Registers.WM_LINETIME_C, |
| 205 | PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C, |
| 206 | PLANE_WM => PLANE_WM_Type'( |
| 207 | Registers.PLANE_WM_1_C_0, |
| 208 | Registers.PLANE_WM_1_C_1, |
| 209 | Registers.PLANE_WM_1_C_2, |
| 210 | Registers.PLANE_WM_1_C_3, |
| 211 | Registers.PLANE_WM_1_C_4, |
| 212 | Registers.PLANE_WM_1_C_5, |
| 213 | Registers.PLANE_WM_1_C_6, |
| 214 | Registers.PLANE_WM_1_C_7))); |
| 215 | |
| 216 | Heads : constant Head_Array := Head_Array' |
| 217 | (Head_EDP => Head_Type' |
| 218 | (Head => Head_EDP, |
| 219 | HTOTAL => Registers.HTOTAL_EDP, |
| 220 | HBLANK => Registers.HBLANK_EDP, |
| 221 | HSYNC => Registers.HSYNC_EDP, |
| 222 | VTOTAL => Registers.VTOTAL_EDP, |
| 223 | VBLANK => Registers.VBLANK_EDP, |
| 224 | VSYNC => Registers.VSYNC_EDP, |
| 225 | PIPECONF => Registers.PIPE_EDP_CONF, |
| 226 | PIPE_DATA_M1 => Registers.PIPE_EDP_DATA_M1, |
| 227 | PIPE_DATA_N1 => Registers.PIPE_EDP_DATA_N1, |
| 228 | PIPE_LINK_M1 => Registers.PIPE_EDP_LINK_M1, |
| 229 | PIPE_LINK_N1 => Registers.PIPE_EDP_LINK_N1, |
| 230 | PIPE_DDI_FUNC_CTL => Registers.PIPE_EDP_DDI_FUNC_CTL, |
| 231 | PIPE_MSA_MISC => Registers.PIPE_EDP_MSA_MISC), |
| 232 | Head_A => Head_Type' |
| 233 | (Head => Head_A, |
| 234 | HTOTAL => Registers.HTOTAL_A, |
| 235 | HBLANK => Registers.HBLANK_A, |
| 236 | HSYNC => Registers.HSYNC_A, |
| 237 | VTOTAL => Registers.VTOTAL_A, |
| 238 | VBLANK => Registers.VBLANK_A, |
| 239 | VSYNC => Registers.VSYNC_A, |
| 240 | PIPECONF => Registers.PIPEACONF, |
| 241 | PIPE_DATA_M1 => Registers.PIPEA_DATA_M1, |
| 242 | PIPE_DATA_N1 => Registers.PIPEA_DATA_N1, |
| 243 | PIPE_LINK_M1 => Registers.PIPEA_LINK_M1, |
| 244 | PIPE_LINK_N1 => Registers.PIPEA_LINK_N1, |
| 245 | PIPE_DDI_FUNC_CTL => Registers.PIPEA_DDI_FUNC_CTL, |
| 246 | PIPE_MSA_MISC => Registers.PIPEA_MSA_MISC), |
| 247 | Head_B => Head_Type' |
| 248 | (Head => Head_B, |
| 249 | HTOTAL => Registers.HTOTAL_B, |
| 250 | HBLANK => Registers.HBLANK_B, |
| 251 | HSYNC => Registers.HSYNC_B, |
| 252 | VTOTAL => Registers.VTOTAL_B, |
| 253 | VBLANK => Registers.VBLANK_B, |
| 254 | VSYNC => Registers.VSYNC_B, |
| 255 | PIPECONF => Registers.PIPEBCONF, |
| 256 | PIPE_DATA_M1 => Registers.PIPEB_DATA_M1, |
| 257 | PIPE_DATA_N1 => Registers.PIPEB_DATA_N1, |
| 258 | PIPE_LINK_M1 => Registers.PIPEB_LINK_M1, |
| 259 | PIPE_LINK_N1 => Registers.PIPEB_LINK_N1, |
| 260 | PIPE_DDI_FUNC_CTL => Registers.PIPEB_DDI_FUNC_CTL, |
| 261 | PIPE_MSA_MISC => Registers.PIPEB_MSA_MISC), |
| 262 | Head_C => Head_Type' |
| 263 | (Head => Head_C, |
| 264 | HTOTAL => Registers.HTOTAL_C, |
| 265 | HBLANK => Registers.HBLANK_C, |
| 266 | HSYNC => Registers.HSYNC_C, |
| 267 | VTOTAL => Registers.VTOTAL_C, |
| 268 | VBLANK => Registers.VBLANK_C, |
| 269 | VSYNC => Registers.VSYNC_C, |
| 270 | PIPECONF => Registers.PIPECCONF, |
| 271 | PIPE_DATA_M1 => Registers.PIPEC_DATA_M1, |
| 272 | PIPE_DATA_N1 => Registers.PIPEC_DATA_N1, |
| 273 | PIPE_LINK_M1 => Registers.PIPEC_LINK_M1, |
| 274 | PIPE_LINK_N1 => Registers.PIPEC_LINK_N1, |
| 275 | PIPE_DDI_FUNC_CTL => Registers.PIPEC_DDI_FUNC_CTL, |
| 276 | PIPE_MSA_MISC => Registers.PIPEC_MSA_MISC)); |
| 277 | |
| 278 | end HW.GFX.GMA.Pipe_Setup; |