blob: 7270cb267f02e358845e2e2071edc92a0753dd85 [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
Nico Huber75a707f2018-06-18 16:28:33 +020015with HW.GFX.GMA.Config;
Nico Huber9e96a452019-09-22 20:25:17 +020016with HW.GFX.GMA.Config_Helpers;
Nico Huber83693c82016-10-08 22:17:55 +020017with HW.GFX.GMA.Registers;
18
Nico Huber47ff0692016-11-04 14:29:39 +010019
Nico Huber83693c82016-10-08 22:17:55 +020020private package HW.GFX.GMA.Pipe_Setup
21is
22
Nico Huber83693c82016-10-08 22:17:55 +020023 procedure On
Nico Huberf3e23662016-12-05 21:33:03 +010024 (Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020025 Port_Cfg : Port_Config;
Nico Huber4dc4c612018-01-10 15:55:09 +010026 Framebuffer : Framebuffer_Type;
27 Cursor : Cursor_Type)
Nico Huber47ff0692016-11-04 14:29:39 +010028 with
Nico Huber9e96a452019-09-22 20:25:17 +020029 Pre => Config_Helpers.Valid_FB (Framebuffer, Port_Cfg.Mode);
Nico Huber83693c82016-10-08 22:17:55 +020030
Nico Huber7ad2d652016-12-07 15:19:32 +010031 procedure Off (Pipe : Pipe_Index);
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 Huberf7f537e2018-01-02 14:15:43 +010037 procedure Setup_FB
38 (Pipe : Pipe_Index;
39 Mode : Mode_Type;
40 Framebuffer : Framebuffer_Type)
41 with
Nico Huber9e96a452019-09-22 20:25:17 +020042 Pre => Config_Helpers.Valid_FB (Framebuffer, Mode);
Nico Huber83693c82016-10-08 22:17:55 +020043
Nico Huber4dc4c612018-01-10 15:55:09 +010044 procedure Update_Cursor
45 (Pipe : Pipe_Index;
46 FB : Framebuffer_Type;
47 Cursor : Cursor_Type);
48 procedure Place_Cursor
49 (Pipe : Pipe_Index;
50 FB : Framebuffer_Type;
51 Cursor : Cursor_Type);
52
Nico Huber9a4c4c32019-09-16 22:05:11 +020053 type Scaler_Reservation is private;
54 Null_Scaler_Reservation : constant Scaler_Reservation;
55 procedure Reserve_Scaler
56 (Success : out Boolean;
57 Reservation : in out Scaler_Reservation;
58 Pipe : in Pipe_Index);
Nico Huberf361ec82018-06-02 18:01:45 +020059
Nico Huber83693c82016-10-08 22:17:55 +020060private
61
Nico Huber9a4c4c32019-09-16 22:05:11 +020062 type Scaler_Reservation is record
63 Reserved : Boolean;
64 Pipe : Pipe_Index;
65 end record;
66 Null_Scaler_Reservation : constant Scaler_Reservation :=
67 (Reserved => False, Pipe => Pipe_Index'First);
68
Nico Huber83693c82016-10-08 22:17:55 +020069 subtype WM_Levels is Natural range 0 .. 7;
70 type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
71
72 type Controller_Type is
73 record
Nico Huberf3e23662016-12-05 21:33:03 +010074 Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020075 PIPESRC : Registers.Registers_Index;
76 PIPEMISC : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010077 PF_CTRL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020078 PF_WIN_POS : Registers.Registers_Index;
79 PF_WIN_SZ : Registers.Registers_Index;
80 DSPCNTR : Registers.Registers_Index;
81 DSPLINOFF : Registers.Registers_Index;
82 DSPSTRIDE : Registers.Registers_Index;
83 DSPSURF : Registers.Registers_Index;
84 DSPTILEOFF : Registers.Registers_Index;
85 SPCNTR : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020086 -- Skylake registers (partially aliased)
87 PLANE_CTL : Registers.Registers_Index;
88 PLANE_OFFSET : Registers.Registers_Index;
89 PLANE_POS : Registers.Registers_Index;
90 PLANE_SIZE : Registers.Registers_Index;
91 PLANE_STRIDE : Registers.Registers_Index;
92 PLANE_SURF : Registers.Registers_Index;
93 PS_CTRL_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010094 PS_WIN_POS_1 : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020095 PS_WIN_SZ_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010096 PS_CTRL_2 : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +020097 PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
98 WM_LINETIME : Registers.Registers_Index;
99 PLANE_BUF_CFG : Registers.Registers_Index;
100 PLANE_WM : PLANE_WM_Type;
Nico Huber4dc4c612018-01-10 15:55:09 +0100101 CUR_BUF_CFG : Registers.Registers_Index;
102 CUR_WM : PLANE_WM_Type;
Nico Huber83693c82016-10-08 22:17:55 +0200103 end record;
104
Nico Huberf3e23662016-12-05 21:33:03 +0100105 type Controller_Array is array (Pipe_Index) of Controller_Type;
106
Nico Huberf3e23662016-12-05 21:33:03 +0100107 Controllers : constant Controller_Array :=
108 (Primary => Controller_Type'
109 (Pipe => Primary,
Nico Huber83693c82016-10-08 22:17:55 +0200110 PIPESRC => Registers.PIPEASRC,
111 PIPEMISC => Registers.PIPEAMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100112 PF_CTRL => Registers.PFA_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200113 PF_WIN_POS => Registers.PFA_WIN_POS,
114 PF_WIN_SZ => Registers.PFA_WIN_SZ,
115 DSPCNTR => Registers.DSPACNTR,
116 DSPLINOFF => Registers.DSPALINOFF,
117 DSPSTRIDE => Registers.DSPASTRIDE,
118 DSPSURF => Registers.DSPASURF,
119 DSPTILEOFF => Registers.DSPATILEOFF,
120 SPCNTR => Registers.SPACNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200121 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 Huber4916e342016-11-04 14:37:53 +0100128 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_A,
Nico Huber83693c82016-10-08 22:17:55 +0200129 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100130 PS_CTRL_2 => Registers.PS_CTRL_2_A,
Nico Huber83693c82016-10-08 22:17:55 +0200131 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,
Nico Huber4dc4c612018-01-10 15:55:09 +0100142 Registers.PLANE_WM_1_A_7),
143 CUR_BUF_CFG => Registers.CUR_BUF_CFG_A,
144 CUR_WM => PLANE_WM_Type'(
145 Registers.CUR_WM_A_0,
146 Registers.CUR_WM_A_1,
147 Registers.CUR_WM_A_2,
148 Registers.CUR_WM_A_3,
149 Registers.CUR_WM_A_4,
150 Registers.CUR_WM_A_5,
151 Registers.CUR_WM_A_6,
152 Registers.CUR_WM_A_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100153 Secondary => Controller_Type'
154 (Pipe => Secondary,
Nico Huber83693c82016-10-08 22:17:55 +0200155 PIPESRC => Registers.PIPEBSRC,
156 PIPEMISC => Registers.PIPEBMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100157 PF_CTRL => Registers.PFB_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200158 PF_WIN_POS => Registers.PFB_WIN_POS,
159 PF_WIN_SZ => Registers.PFB_WIN_SZ,
160 DSPCNTR => Registers.DSPBCNTR,
161 DSPLINOFF => Registers.DSPBLINOFF,
162 DSPSTRIDE => Registers.DSPBSTRIDE,
163 DSPSURF => Registers.DSPBSURF,
164 DSPTILEOFF => Registers.DSPBTILEOFF,
165 SPCNTR => Registers.SPBCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200166 PLANE_CTL => Registers.DSPBCNTR,
167 PLANE_OFFSET => Registers.DSPBTILEOFF,
168 PLANE_POS => Registers.PLANE_POS_1_B,
169 PLANE_SIZE => Registers.PLANE_SIZE_1_B,
170 PLANE_STRIDE => Registers.DSPBSTRIDE,
171 PLANE_SURF => Registers.DSPBSURF,
172 PS_CTRL_1 => Registers.PS_CTRL_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100173 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
Nico Huber83693c82016-10-08 22:17:55 +0200174 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100175 PS_CTRL_2 => Registers.PS_CTRL_2_B,
Nico Huber83693c82016-10-08 22:17:55 +0200176 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B,
177 WM_LINETIME => Registers.WM_LINETIME_B,
178 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B,
179 PLANE_WM => PLANE_WM_Type'(
180 Registers.PLANE_WM_1_B_0,
181 Registers.PLANE_WM_1_B_1,
182 Registers.PLANE_WM_1_B_2,
183 Registers.PLANE_WM_1_B_3,
184 Registers.PLANE_WM_1_B_4,
185 Registers.PLANE_WM_1_B_5,
186 Registers.PLANE_WM_1_B_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100187 Registers.PLANE_WM_1_B_7),
188 CUR_BUF_CFG => Registers.CUR_BUF_CFG_B,
189 CUR_WM => PLANE_WM_Type'(
190 Registers.CUR_WM_B_0,
191 Registers.CUR_WM_B_1,
192 Registers.CUR_WM_B_2,
193 Registers.CUR_WM_B_3,
194 Registers.CUR_WM_B_4,
195 Registers.CUR_WM_B_5,
196 Registers.CUR_WM_B_6,
197 Registers.CUR_WM_B_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100198 Tertiary => Controller_Type'
199 (Pipe => Tertiary,
Nico Huber83693c82016-10-08 22:17:55 +0200200 PIPESRC => Registers.PIPECSRC,
201 PIPEMISC => Registers.PIPECMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100202 PF_CTRL => Registers.PFC_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200203 PF_WIN_POS => Registers.PFC_WIN_POS,
204 PF_WIN_SZ => Registers.PFC_WIN_SZ,
205 DSPCNTR => Registers.DSPCCNTR,
206 DSPLINOFF => Registers.DSPCLINOFF,
207 DSPSTRIDE => Registers.DSPCSTRIDE,
208 DSPSURF => Registers.DSPCSURF,
209 DSPTILEOFF => Registers.DSPCTILEOFF,
210 SPCNTR => Registers.SPCCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200211 PLANE_CTL => Registers.DSPCCNTR,
212 PLANE_OFFSET => Registers.DSPCTILEOFF,
213 PLANE_POS => Registers.PLANE_POS_1_C,
214 PLANE_SIZE => Registers.PLANE_SIZE_1_C,
215 PLANE_STRIDE => Registers.DSPCSTRIDE,
216 PLANE_SURF => Registers.DSPCSURF,
217 PS_CTRL_1 => Registers.PS_CTRL_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100218 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C,
Nico Huber83693c82016-10-08 22:17:55 +0200219 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100220 PS_CTRL_2 => Registers.Invalid_Register,
Nico Huber83693c82016-10-08 22:17:55 +0200221 PS_WIN_SZ_2 => Registers.Invalid_Register,
222 WM_LINETIME => Registers.WM_LINETIME_C,
223 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C,
224 PLANE_WM => PLANE_WM_Type'(
225 Registers.PLANE_WM_1_C_0,
226 Registers.PLANE_WM_1_C_1,
227 Registers.PLANE_WM_1_C_2,
228 Registers.PLANE_WM_1_C_3,
229 Registers.PLANE_WM_1_C_4,
230 Registers.PLANE_WM_1_C_5,
231 Registers.PLANE_WM_1_C_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100232 Registers.PLANE_WM_1_C_7),
233 CUR_BUF_CFG => Registers.CUR_BUF_CFG_C,
234 CUR_WM => PLANE_WM_Type'(
235 Registers.CUR_WM_C_0,
236 Registers.CUR_WM_C_1,
237 Registers.CUR_WM_C_2,
238 Registers.CUR_WM_C_3,
239 Registers.CUR_WM_C_4,
240 Registers.CUR_WM_C_5,
241 Registers.CUR_WM_C_6,
242 Registers.CUR_WM_C_7)));
Nico Huber83693c82016-10-08 22:17:55 +0200243
Nico Huber75a707f2018-06-18 16:28:33 +0200244 type Cursor_Regs is record
245 CTL : Registers.Registers_Index;
246 BASE : Registers.Registers_Index;
247 POS : Registers.Registers_Index;
248 FBC_CTL : Registers.Registers_Invalid_Index;
249 end record;
250
251 function Cursors (Pipe : Pipe_Index) return Cursor_Regs is
252 (if not Config.Has_Ivybridge_Cursors then
253 (if Pipe = Primary then
254 (CTL => Registers.CURACNTR,
255 BASE => Registers.CURABASE,
256 POS => Registers.CURAPOS,
257 FBC_CTL => Registers.Invalid_Register)
258 else
259 (CTL => Registers.CURBCNTR,
260 BASE => Registers.CURBBASE,
261 POS => Registers.CURBPOS,
262 FBC_CTL => Registers.Invalid_Register))
263 else
264 (if Pipe = Primary then
265 (CTL => Registers.CUR_CTL_A,
266 BASE => Registers.CUR_BASE_A,
267 POS => Registers.CUR_POS_A,
268 FBC_CTL => Registers.CUR_FBC_CTL_A)
269 elsif Pipe = Secondary then
270 (CTL => Registers.CUR_CTL_B,
271 BASE => Registers.CUR_BASE_B,
272 POS => Registers.CUR_POS_B,
273 FBC_CTL => Registers.CUR_FBC_CTL_B)
274 else
275 (CTL => Registers.CUR_CTL_C,
276 BASE => Registers.CUR_BASE_C,
277 POS => Registers.CUR_POS_C,
278 FBC_CTL => Registers.CUR_FBC_CTL_C)));
279
Nico Huber83693c82016-10-08 22:17:55 +0200280end HW.GFX.GMA.Pipe_Setup;