blob: c485f1ac4ac3088e8fa6a9360e24c8e248b070d1 [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
22 type Controller_Kind is (A, B, C);
23 type Controller_Type is private;
24 type Controller_Array is array (Controller_Kind) of Controller_Type;
25
26 type Pipe_Head is (Head_EDP, Head_A, Head_B, Head_C);
27 type Head_Type is private;
28 type Head_Array is array (Pipe_Head) of Head_Type;
29
30 procedure On
31 (Controller : Controller_Type;
32 Head : Head_Type;
33 Port_Cfg : Port_Config;
Nico Huber47ff0692016-11-04 14:29:39 +010034 Framebuffer : Framebuffer_Type)
35 with
36 Pre =>
37 Framebuffer.Width <= Pos32 (Port_Cfg.Mode.H_Visible) and
38 Framebuffer.Height <= Pos32 (Port_Cfg.Mode.V_Visible);
Nico Huber83693c82016-10-08 22:17:55 +020039
40 procedure Off
41 (Controller : Controller_Type;
42 Head : Head_Type);
43
44 procedure All_Off;
45
46 function Get_Pipe_Hint (Head : Head_Type) return Word32;
47
48 procedure Update_Offset
49 (Controller : Controller_Type;
50 Framebuffer : HW.GFX.Framebuffer_Type);
51
52 Controllers : constant Controller_Array;
53
54 Heads : constant Head_Array;
55
56 function Default_Pipe_Head (Kind : Controller_Kind) return Head_Type;
57
58private
59
60 subtype WM_Levels is Natural range 0 .. 7;
61 type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
62
63 type Controller_Type is
64 record
65 Kind : Controller_Kind;
66 PIPESRC : Registers.Registers_Index;
67 PIPEMISC : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010068 PF_CTRL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020069 PF_WIN_POS : Registers.Registers_Index;
70 PF_WIN_SZ : Registers.Registers_Index;
71 DSPCNTR : Registers.Registers_Index;
72 DSPLINOFF : Registers.Registers_Index;
73 DSPSTRIDE : Registers.Registers_Index;
74 DSPSURF : Registers.Registers_Index;
75 DSPTILEOFF : Registers.Registers_Index;
76 SPCNTR : Registers.Registers_Index;
77 TRANS_CLK_SEL : Registers.Registers_Index;
78 -- Skylake registers (partially aliased)
79 PLANE_CTL : Registers.Registers_Index;
80 PLANE_OFFSET : Registers.Registers_Index;
81 PLANE_POS : Registers.Registers_Index;
82 PLANE_SIZE : Registers.Registers_Index;
83 PLANE_STRIDE : Registers.Registers_Index;
84 PLANE_SURF : Registers.Registers_Index;
85 PS_CTRL_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010086 PS_WIN_POS_1 : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020087 PS_WIN_SZ_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010088 PS_CTRL_2 : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +020089 PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
90 WM_LINETIME : Registers.Registers_Index;
91 PLANE_BUF_CFG : Registers.Registers_Index;
92 PLANE_WM : PLANE_WM_Type;
93 end record;
94
95 type Head_Type is
96 record
97 Head : Pipe_Head;
98 HTOTAL : Registers.Registers_Index;
99 HBLANK : Registers.Registers_Index;
100 HSYNC : Registers.Registers_Index;
101 VTOTAL : Registers.Registers_Index;
102 VBLANK : Registers.Registers_Index;
103 VSYNC : Registers.Registers_Index;
104 PIPECONF : Registers.Registers_Index;
105 PIPE_DATA_M1 : Registers.Registers_Index;
106 PIPE_DATA_N1 : Registers.Registers_Index;
107 PIPE_LINK_M1 : Registers.Registers_Index;
108 PIPE_LINK_N1 : Registers.Registers_Index;
109 PIPE_DDI_FUNC_CTL : Registers.Registers_Index;
110 PIPE_MSA_MISC : Registers.Registers_Index;
111 end record;
112
113 Controllers : constant Controller_Array := Controller_Array'
114 (A => Controller_Type'
115 (Kind => A,
116 PIPESRC => Registers.PIPEASRC,
117 PIPEMISC => Registers.PIPEAMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100118 PF_CTRL => Registers.PFA_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200119 PF_WIN_POS => Registers.PFA_WIN_POS,
120 PF_WIN_SZ => Registers.PFA_WIN_SZ,
121 DSPCNTR => Registers.DSPACNTR,
122 DSPLINOFF => Registers.DSPALINOFF,
123 DSPSTRIDE => Registers.DSPASTRIDE,
124 DSPSURF => Registers.DSPASURF,
125 DSPTILEOFF => Registers.DSPATILEOFF,
126 SPCNTR => Registers.SPACNTR,
127 TRANS_CLK_SEL => Registers.TRANSA_CLK_SEL,
128 PLANE_CTL => Registers.DSPACNTR,
129 PLANE_OFFSET => Registers.DSPATILEOFF,
130 PLANE_POS => Registers.PLANE_POS_1_A,
131 PLANE_SIZE => Registers.PLANE_SIZE_1_A,
132 PLANE_STRIDE => Registers.DSPASTRIDE,
133 PLANE_SURF => Registers.DSPASURF,
134 PS_CTRL_1 => Registers.PS_CTRL_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100135 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_A,
Nico Huber83693c82016-10-08 22:17:55 +0200136 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100137 PS_CTRL_2 => Registers.PS_CTRL_2_A,
Nico Huber83693c82016-10-08 22:17:55 +0200138 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_A,
139 WM_LINETIME => Registers.WM_LINETIME_A,
140 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_A,
141 PLANE_WM => PLANE_WM_Type'(
142 Registers.PLANE_WM_1_A_0,
143 Registers.PLANE_WM_1_A_1,
144 Registers.PLANE_WM_1_A_2,
145 Registers.PLANE_WM_1_A_3,
146 Registers.PLANE_WM_1_A_4,
147 Registers.PLANE_WM_1_A_5,
148 Registers.PLANE_WM_1_A_6,
149 Registers.PLANE_WM_1_A_7)),
150 B => Controller_Type'
151 (Kind => B,
152 PIPESRC => Registers.PIPEBSRC,
153 PIPEMISC => Registers.PIPEBMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100154 PF_CTRL => Registers.PFB_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200155 PF_WIN_POS => Registers.PFB_WIN_POS,
156 PF_WIN_SZ => Registers.PFB_WIN_SZ,
157 DSPCNTR => Registers.DSPBCNTR,
158 DSPLINOFF => Registers.DSPBLINOFF,
159 DSPSTRIDE => Registers.DSPBSTRIDE,
160 DSPSURF => Registers.DSPBSURF,
161 DSPTILEOFF => Registers.DSPBTILEOFF,
162 SPCNTR => Registers.SPBCNTR,
163 TRANS_CLK_SEL => Registers.TRANSB_CLK_SEL,
164 PLANE_CTL => Registers.DSPBCNTR,
165 PLANE_OFFSET => Registers.DSPBTILEOFF,
166 PLANE_POS => Registers.PLANE_POS_1_B,
167 PLANE_SIZE => Registers.PLANE_SIZE_1_B,
168 PLANE_STRIDE => Registers.DSPBSTRIDE,
169 PLANE_SURF => Registers.DSPBSURF,
170 PS_CTRL_1 => Registers.PS_CTRL_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100171 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
Nico Huber83693c82016-10-08 22:17:55 +0200172 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100173 PS_CTRL_2 => Registers.PS_CTRL_2_B,
Nico Huber83693c82016-10-08 22:17:55 +0200174 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B,
175 WM_LINETIME => Registers.WM_LINETIME_B,
176 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B,
177 PLANE_WM => PLANE_WM_Type'(
178 Registers.PLANE_WM_1_B_0,
179 Registers.PLANE_WM_1_B_1,
180 Registers.PLANE_WM_1_B_2,
181 Registers.PLANE_WM_1_B_3,
182 Registers.PLANE_WM_1_B_4,
183 Registers.PLANE_WM_1_B_5,
184 Registers.PLANE_WM_1_B_6,
185 Registers.PLANE_WM_1_B_7)),
186 C => Controller_Type'
187 (Kind => C,
188 PIPESRC => Registers.PIPECSRC,
189 PIPEMISC => Registers.PIPECMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100190 PF_CTRL => Registers.PFC_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200191 PF_WIN_POS => Registers.PFC_WIN_POS,
192 PF_WIN_SZ => Registers.PFC_WIN_SZ,
193 DSPCNTR => Registers.DSPCCNTR,
194 DSPLINOFF => Registers.DSPCLINOFF,
195 DSPSTRIDE => Registers.DSPCSTRIDE,
196 DSPSURF => Registers.DSPCSURF,
197 DSPTILEOFF => Registers.DSPCTILEOFF,
198 SPCNTR => Registers.SPCCNTR,
199 TRANS_CLK_SEL => Registers.TRANSC_CLK_SEL,
200 PLANE_CTL => Registers.DSPCCNTR,
201 PLANE_OFFSET => Registers.DSPCTILEOFF,
202 PLANE_POS => Registers.PLANE_POS_1_C,
203 PLANE_SIZE => Registers.PLANE_SIZE_1_C,
204 PLANE_STRIDE => Registers.DSPCSTRIDE,
205 PLANE_SURF => Registers.DSPCSURF,
206 PS_CTRL_1 => Registers.PS_CTRL_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100207 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C,
Nico Huber83693c82016-10-08 22:17:55 +0200208 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100209 PS_CTRL_2 => Registers.Invalid_Register,
Nico Huber83693c82016-10-08 22:17:55 +0200210 PS_WIN_SZ_2 => Registers.Invalid_Register,
211 WM_LINETIME => Registers.WM_LINETIME_C,
212 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C,
213 PLANE_WM => PLANE_WM_Type'(
214 Registers.PLANE_WM_1_C_0,
215 Registers.PLANE_WM_1_C_1,
216 Registers.PLANE_WM_1_C_2,
217 Registers.PLANE_WM_1_C_3,
218 Registers.PLANE_WM_1_C_4,
219 Registers.PLANE_WM_1_C_5,
220 Registers.PLANE_WM_1_C_6,
221 Registers.PLANE_WM_1_C_7)));
222
223 Heads : constant Head_Array := Head_Array'
224 (Head_EDP => Head_Type'
225 (Head => Head_EDP,
226 HTOTAL => Registers.HTOTAL_EDP,
227 HBLANK => Registers.HBLANK_EDP,
228 HSYNC => Registers.HSYNC_EDP,
229 VTOTAL => Registers.VTOTAL_EDP,
230 VBLANK => Registers.VBLANK_EDP,
231 VSYNC => Registers.VSYNC_EDP,
232 PIPECONF => Registers.PIPE_EDP_CONF,
233 PIPE_DATA_M1 => Registers.PIPE_EDP_DATA_M1,
234 PIPE_DATA_N1 => Registers.PIPE_EDP_DATA_N1,
235 PIPE_LINK_M1 => Registers.PIPE_EDP_LINK_M1,
236 PIPE_LINK_N1 => Registers.PIPE_EDP_LINK_N1,
237 PIPE_DDI_FUNC_CTL => Registers.PIPE_EDP_DDI_FUNC_CTL,
238 PIPE_MSA_MISC => Registers.PIPE_EDP_MSA_MISC),
239 Head_A => Head_Type'
240 (Head => Head_A,
241 HTOTAL => Registers.HTOTAL_A,
242 HBLANK => Registers.HBLANK_A,
243 HSYNC => Registers.HSYNC_A,
244 VTOTAL => Registers.VTOTAL_A,
245 VBLANK => Registers.VBLANK_A,
246 VSYNC => Registers.VSYNC_A,
247 PIPECONF => Registers.PIPEACONF,
248 PIPE_DATA_M1 => Registers.PIPEA_DATA_M1,
249 PIPE_DATA_N1 => Registers.PIPEA_DATA_N1,
250 PIPE_LINK_M1 => Registers.PIPEA_LINK_M1,
251 PIPE_LINK_N1 => Registers.PIPEA_LINK_N1,
252 PIPE_DDI_FUNC_CTL => Registers.PIPEA_DDI_FUNC_CTL,
253 PIPE_MSA_MISC => Registers.PIPEA_MSA_MISC),
254 Head_B => Head_Type'
255 (Head => Head_B,
256 HTOTAL => Registers.HTOTAL_B,
257 HBLANK => Registers.HBLANK_B,
258 HSYNC => Registers.HSYNC_B,
259 VTOTAL => Registers.VTOTAL_B,
260 VBLANK => Registers.VBLANK_B,
261 VSYNC => Registers.VSYNC_B,
262 PIPECONF => Registers.PIPEBCONF,
263 PIPE_DATA_M1 => Registers.PIPEB_DATA_M1,
264 PIPE_DATA_N1 => Registers.PIPEB_DATA_N1,
265 PIPE_LINK_M1 => Registers.PIPEB_LINK_M1,
266 PIPE_LINK_N1 => Registers.PIPEB_LINK_N1,
267 PIPE_DDI_FUNC_CTL => Registers.PIPEB_DDI_FUNC_CTL,
268 PIPE_MSA_MISC => Registers.PIPEB_MSA_MISC),
269 Head_C => Head_Type'
270 (Head => Head_C,
271 HTOTAL => Registers.HTOTAL_C,
272 HBLANK => Registers.HBLANK_C,
273 HSYNC => Registers.HSYNC_C,
274 VTOTAL => Registers.VTOTAL_C,
275 VBLANK => Registers.VBLANK_C,
276 VSYNC => Registers.VSYNC_C,
277 PIPECONF => Registers.PIPECCONF,
278 PIPE_DATA_M1 => Registers.PIPEC_DATA_M1,
279 PIPE_DATA_N1 => Registers.PIPEC_DATA_N1,
280 PIPE_LINK_M1 => Registers.PIPEC_LINK_M1,
281 PIPE_LINK_N1 => Registers.PIPEC_LINK_N1,
282 PIPE_DDI_FUNC_CTL => Registers.PIPEC_DDI_FUNC_CTL,
283 PIPE_MSA_MISC => Registers.PIPEC_MSA_MISC));
284
285end HW.GFX.GMA.Pipe_Setup;