blob: 250ab5a45a25dc74398d54931077e2c7f480f7bd [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
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 Huber125a29e2016-10-18 00:23:54 +02006-- the Free Software Foundation; either version 2 of the License, or
7-- (at your option) any later version.
Nico Huber83693c82016-10-08 22:17:55 +02008--
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
15with HW.GFX.GMA.Registers;
16
Nico Huber47ff0692016-11-04 14:29:39 +010017use type HW.Int32;
18
Nico Huber83693c82016-10-08 22:17:55 +020019private package HW.GFX.GMA.Pipe_Setup
20is
21
Nico Huber83693c82016-10-08 22:17:55 +020022 procedure On
Nico Huberf3e23662016-12-05 21:33:03 +010023 (Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020024 Port_Cfg : Port_Config;
Nico Huber47ff0692016-11-04 14:29:39 +010025 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 Huber83693c82016-10-08 22:17:55 +020030
Nico Huberf3e23662016-12-05 21:33:03 +010031 procedure Off (Pipe : Pipe_Index; Port_Cfg : Port_Config);
Nico Huber83693c82016-10-08 22:17:55 +020032
Nico Huber33912aa2016-12-06 20:36:23 +010033 procedure Legacy_VGA_Off;
34
Nico Huber83693c82016-10-08 22:17:55 +020035 procedure All_Off;
36
Nico Huberf3e23662016-12-05 21:33:03 +010037 function Get_Pipe_Hint (Pipe : Pipe_Index) return Word32;
Nico Huber83693c82016-10-08 22:17:55 +020038
Nico Huberf3e23662016-12-05 21:33:03 +010039 procedure Update_Offset (Pipe : Pipe_Index; Framebuffer : Framebuffer_Type);
Nico Huber83693c82016-10-08 22:17:55 +020040
41private
42
43 subtype WM_Levels is Natural range 0 .. 7;
44 type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
45
Nico Huberf3e23662016-12-05 21:33:03 +010046 ----------------------------------------------------------------------------
47
Nico Huber83693c82016-10-08 22:17:55 +020048 type Controller_Type is
49 record
Nico Huberf3e23662016-12-05 21:33:03 +010050 Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020051 PIPESRC : Registers.Registers_Index;
52 PIPEMISC : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010053 PF_CTRL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020054 PF_WIN_POS : Registers.Registers_Index;
55 PF_WIN_SZ : Registers.Registers_Index;
56 DSPCNTR : Registers.Registers_Index;
57 DSPLINOFF : Registers.Registers_Index;
58 DSPSTRIDE : Registers.Registers_Index;
59 DSPSURF : Registers.Registers_Index;
60 DSPTILEOFF : Registers.Registers_Index;
61 SPCNTR : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020062 -- Skylake registers (partially aliased)
63 PLANE_CTL : Registers.Registers_Index;
64 PLANE_OFFSET : Registers.Registers_Index;
65 PLANE_POS : Registers.Registers_Index;
66 PLANE_SIZE : Registers.Registers_Index;
67 PLANE_STRIDE : Registers.Registers_Index;
68 PLANE_SURF : Registers.Registers_Index;
69 PS_CTRL_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010070 PS_WIN_POS_1 : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020071 PS_WIN_SZ_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010072 PS_CTRL_2 : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +020073 PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
74 WM_LINETIME : Registers.Registers_Index;
75 PLANE_BUF_CFG : Registers.Registers_Index;
76 PLANE_WM : PLANE_WM_Type;
77 end record;
78
Nico Huberf3e23662016-12-05 21:33:03 +010079 type Controller_Array is array (Pipe_Index) of Controller_Type;
80
81 ----------------------------------------------------------------------------
82
83 type Pipe_Head is (Head_EDP, Head_A, Head_B, Head_C);
84
Nico Huber83693c82016-10-08 22:17:55 +020085 type Head_Type is
86 record
87 Head : Pipe_Head;
88 HTOTAL : Registers.Registers_Index;
89 HBLANK : Registers.Registers_Index;
90 HSYNC : Registers.Registers_Index;
91 VTOTAL : Registers.Registers_Index;
92 VBLANK : Registers.Registers_Index;
93 VSYNC : Registers.Registers_Index;
94 PIPECONF : Registers.Registers_Index;
95 PIPE_DATA_M1 : Registers.Registers_Index;
96 PIPE_DATA_N1 : Registers.Registers_Index;
97 PIPE_LINK_M1 : Registers.Registers_Index;
98 PIPE_LINK_N1 : Registers.Registers_Index;
99 PIPE_DDI_FUNC_CTL : Registers.Registers_Index;
100 PIPE_MSA_MISC : Registers.Registers_Index;
Nico Huber113a14b2016-12-06 21:59:15 +0100101 TRANS_CLK_SEL : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +0200102 end record;
103
Nico Huberf3e23662016-12-05 21:33:03 +0100104 type Head_Array is array (Pipe_Head) of Head_Type;
105
106 ----------------------------------------------------------------------------
107
108 Controllers : constant Controller_Array :=
109 (Primary => Controller_Type'
110 (Pipe => Primary,
Nico Huber83693c82016-10-08 22:17:55 +0200111 PIPESRC => Registers.PIPEASRC,
112 PIPEMISC => Registers.PIPEAMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100113 PF_CTRL => Registers.PFA_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200114 PF_WIN_POS => Registers.PFA_WIN_POS,
115 PF_WIN_SZ => Registers.PFA_WIN_SZ,
116 DSPCNTR => Registers.DSPACNTR,
117 DSPLINOFF => Registers.DSPALINOFF,
118 DSPSTRIDE => Registers.DSPASTRIDE,
119 DSPSURF => Registers.DSPASURF,
120 DSPTILEOFF => Registers.DSPATILEOFF,
121 SPCNTR => Registers.SPACNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200122 PLANE_CTL => Registers.DSPACNTR,
123 PLANE_OFFSET => Registers.DSPATILEOFF,
124 PLANE_POS => Registers.PLANE_POS_1_A,
125 PLANE_SIZE => Registers.PLANE_SIZE_1_A,
126 PLANE_STRIDE => Registers.DSPASTRIDE,
127 PLANE_SURF => Registers.DSPASURF,
128 PS_CTRL_1 => Registers.PS_CTRL_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100129 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_A,
Nico Huber83693c82016-10-08 22:17:55 +0200130 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100131 PS_CTRL_2 => Registers.PS_CTRL_2_A,
Nico Huber83693c82016-10-08 22:17:55 +0200132 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_A,
133 WM_LINETIME => Registers.WM_LINETIME_A,
134 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_A,
135 PLANE_WM => PLANE_WM_Type'(
136 Registers.PLANE_WM_1_A_0,
137 Registers.PLANE_WM_1_A_1,
138 Registers.PLANE_WM_1_A_2,
139 Registers.PLANE_WM_1_A_3,
140 Registers.PLANE_WM_1_A_4,
141 Registers.PLANE_WM_1_A_5,
142 Registers.PLANE_WM_1_A_6,
143 Registers.PLANE_WM_1_A_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100144 Secondary => Controller_Type'
145 (Pipe => Secondary,
Nico Huber83693c82016-10-08 22:17:55 +0200146 PIPESRC => Registers.PIPEBSRC,
147 PIPEMISC => Registers.PIPEBMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100148 PF_CTRL => Registers.PFB_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200149 PF_WIN_POS => Registers.PFB_WIN_POS,
150 PF_WIN_SZ => Registers.PFB_WIN_SZ,
151 DSPCNTR => Registers.DSPBCNTR,
152 DSPLINOFF => Registers.DSPBLINOFF,
153 DSPSTRIDE => Registers.DSPBSTRIDE,
154 DSPSURF => Registers.DSPBSURF,
155 DSPTILEOFF => Registers.DSPBTILEOFF,
156 SPCNTR => Registers.SPBCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200157 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 Huber4916e342016-11-04 14:37:53 +0100164 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
Nico Huber83693c82016-10-08 22:17:55 +0200165 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100166 PS_CTRL_2 => Registers.PS_CTRL_2_B,
Nico Huber83693c82016-10-08 22:17:55 +0200167 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 Huberf3e23662016-12-05 21:33:03 +0100179 Tertiary => Controller_Type'
180 (Pipe => Tertiary,
Nico Huber83693c82016-10-08 22:17:55 +0200181 PIPESRC => Registers.PIPECSRC,
182 PIPEMISC => Registers.PIPECMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100183 PF_CTRL => Registers.PFC_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200184 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,
Nico Huber83693c82016-10-08 22:17:55 +0200192 PLANE_CTL => Registers.DSPCCNTR,
193 PLANE_OFFSET => Registers.DSPCTILEOFF,
194 PLANE_POS => Registers.PLANE_POS_1_C,
195 PLANE_SIZE => Registers.PLANE_SIZE_1_C,
196 PLANE_STRIDE => Registers.DSPCSTRIDE,
197 PLANE_SURF => Registers.DSPCSURF,
198 PS_CTRL_1 => Registers.PS_CTRL_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100199 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C,
Nico Huber83693c82016-10-08 22:17:55 +0200200 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100201 PS_CTRL_2 => Registers.Invalid_Register,
Nico Huber83693c82016-10-08 22:17:55 +0200202 PS_WIN_SZ_2 => Registers.Invalid_Register,
203 WM_LINETIME => Registers.WM_LINETIME_C,
204 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C,
205 PLANE_WM => PLANE_WM_Type'(
206 Registers.PLANE_WM_1_C_0,
207 Registers.PLANE_WM_1_C_1,
208 Registers.PLANE_WM_1_C_2,
209 Registers.PLANE_WM_1_C_3,
210 Registers.PLANE_WM_1_C_4,
211 Registers.PLANE_WM_1_C_5,
212 Registers.PLANE_WM_1_C_6,
213 Registers.PLANE_WM_1_C_7)));
214
215 Heads : constant Head_Array := Head_Array'
216 (Head_EDP => Head_Type'
217 (Head => Head_EDP,
218 HTOTAL => Registers.HTOTAL_EDP,
219 HBLANK => Registers.HBLANK_EDP,
220 HSYNC => Registers.HSYNC_EDP,
221 VTOTAL => Registers.VTOTAL_EDP,
222 VBLANK => Registers.VBLANK_EDP,
223 VSYNC => Registers.VSYNC_EDP,
224 PIPECONF => Registers.PIPE_EDP_CONF,
225 PIPE_DATA_M1 => Registers.PIPE_EDP_DATA_M1,
226 PIPE_DATA_N1 => Registers.PIPE_EDP_DATA_N1,
227 PIPE_LINK_M1 => Registers.PIPE_EDP_LINK_M1,
228 PIPE_LINK_N1 => Registers.PIPE_EDP_LINK_N1,
229 PIPE_DDI_FUNC_CTL => Registers.PIPE_EDP_DDI_FUNC_CTL,
Nico Huber113a14b2016-12-06 21:59:15 +0100230 PIPE_MSA_MISC => Registers.PIPE_EDP_MSA_MISC,
231 TRANS_CLK_SEL => Registers.Invalid_Register),
Nico Huber83693c82016-10-08 22:17:55 +0200232 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,
Nico Huber113a14b2016-12-06 21:59:15 +0100246 PIPE_MSA_MISC => Registers.PIPEA_MSA_MISC,
247 TRANS_CLK_SEL => Registers.TRANSA_CLK_SEL),
Nico Huber83693c82016-10-08 22:17:55 +0200248 Head_B => Head_Type'
249 (Head => Head_B,
250 HTOTAL => Registers.HTOTAL_B,
251 HBLANK => Registers.HBLANK_B,
252 HSYNC => Registers.HSYNC_B,
253 VTOTAL => Registers.VTOTAL_B,
254 VBLANK => Registers.VBLANK_B,
255 VSYNC => Registers.VSYNC_B,
256 PIPECONF => Registers.PIPEBCONF,
257 PIPE_DATA_M1 => Registers.PIPEB_DATA_M1,
258 PIPE_DATA_N1 => Registers.PIPEB_DATA_N1,
259 PIPE_LINK_M1 => Registers.PIPEB_LINK_M1,
260 PIPE_LINK_N1 => Registers.PIPEB_LINK_N1,
261 PIPE_DDI_FUNC_CTL => Registers.PIPEB_DDI_FUNC_CTL,
Nico Huber113a14b2016-12-06 21:59:15 +0100262 PIPE_MSA_MISC => Registers.PIPEB_MSA_MISC,
263 TRANS_CLK_SEL => Registers.TRANSB_CLK_SEL),
Nico Huber83693c82016-10-08 22:17:55 +0200264 Head_C => Head_Type'
265 (Head => Head_C,
266 HTOTAL => Registers.HTOTAL_C,
267 HBLANK => Registers.HBLANK_C,
268 HSYNC => Registers.HSYNC_C,
269 VTOTAL => Registers.VTOTAL_C,
270 VBLANK => Registers.VBLANK_C,
271 VSYNC => Registers.VSYNC_C,
272 PIPECONF => Registers.PIPECCONF,
273 PIPE_DATA_M1 => Registers.PIPEC_DATA_M1,
274 PIPE_DATA_N1 => Registers.PIPEC_DATA_N1,
275 PIPE_LINK_M1 => Registers.PIPEC_LINK_M1,
276 PIPE_LINK_N1 => Registers.PIPEC_LINK_N1,
277 PIPE_DDI_FUNC_CTL => Registers.PIPEC_DDI_FUNC_CTL,
Nico Huber113a14b2016-12-06 21:59:15 +0100278 PIPE_MSA_MISC => Registers.PIPEC_MSA_MISC,
279 TRANS_CLK_SEL => Registers.TRANSC_CLK_SEL));
Nico Huber83693c82016-10-08 22:17:55 +0200280
281end HW.GFX.GMA.Pipe_Setup;