blob: 960e70f103a9f8dbbd41ad55450ecbdd86b49f97 [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 +010019use type HW.Int32;
20
Nico Huber83693c82016-10-08 22:17:55 +020021private package HW.GFX.GMA.Pipe_Setup
22is
23
Nico Huber83693c82016-10-08 22:17:55 +020024 procedure On
Nico Huberf3e23662016-12-05 21:33:03 +010025 (Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020026 Port_Cfg : Port_Config;
Nico Huber4dc4c612018-01-10 15:55:09 +010027 Framebuffer : Framebuffer_Type;
28 Cursor : Cursor_Type)
Nico Huber47ff0692016-11-04 14:29:39 +010029 with
Nico Huber9e96a452019-09-22 20:25:17 +020030 Pre => Config_Helpers.Valid_FB (Framebuffer, Port_Cfg.Mode);
Nico Huber83693c82016-10-08 22:17:55 +020031
Nico Huber7ad2d652016-12-07 15:19:32 +010032 procedure Off (Pipe : Pipe_Index);
Nico Huber83693c82016-10-08 22:17:55 +020033
Nico Huber33912aa2016-12-06 20:36:23 +010034 procedure Legacy_VGA_Off;
35
Nico Huber83693c82016-10-08 22:17:55 +020036 procedure All_Off;
37
Nico Huberf7f537e2018-01-02 14:15:43 +010038 procedure Setup_FB
39 (Pipe : Pipe_Index;
40 Mode : Mode_Type;
41 Framebuffer : Framebuffer_Type)
42 with
Nico Huber9e96a452019-09-22 20:25:17 +020043 Pre => Config_Helpers.Valid_FB (Framebuffer, Mode);
Nico Huber83693c82016-10-08 22:17:55 +020044
Nico Huber4dc4c612018-01-10 15:55:09 +010045 procedure Update_Cursor
46 (Pipe : Pipe_Index;
47 FB : Framebuffer_Type;
48 Cursor : Cursor_Type);
49 procedure Place_Cursor
50 (Pipe : Pipe_Index;
51 FB : Framebuffer_Type;
52 Cursor : Cursor_Type);
53
Nico Huber9a4c4c32019-09-16 22:05:11 +020054 type Scaler_Reservation is private;
55 Null_Scaler_Reservation : constant Scaler_Reservation;
56 procedure Reserve_Scaler
57 (Success : out Boolean;
58 Reservation : in out Scaler_Reservation;
59 Pipe : in Pipe_Index);
Nico Huberf361ec82018-06-02 18:01:45 +020060
Nico Huber83693c82016-10-08 22:17:55 +020061private
62
Nico Huber9a4c4c32019-09-16 22:05:11 +020063 type Scaler_Reservation is record
64 Reserved : Boolean;
65 Pipe : Pipe_Index;
66 end record;
67 Null_Scaler_Reservation : constant Scaler_Reservation :=
68 (Reserved => False, Pipe => Pipe_Index'First);
69
Nico Huber83693c82016-10-08 22:17:55 +020070 subtype WM_Levels is Natural range 0 .. 7;
71 type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
72
73 type Controller_Type is
74 record
Nico Huberf3e23662016-12-05 21:33:03 +010075 Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020076 PIPESRC : Registers.Registers_Index;
77 PIPEMISC : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010078 PF_CTRL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020079 PF_WIN_POS : Registers.Registers_Index;
80 PF_WIN_SZ : Registers.Registers_Index;
81 DSPCNTR : Registers.Registers_Index;
82 DSPLINOFF : Registers.Registers_Index;
83 DSPSTRIDE : Registers.Registers_Index;
84 DSPSURF : Registers.Registers_Index;
85 DSPTILEOFF : Registers.Registers_Index;
86 SPCNTR : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020087 -- Skylake registers (partially aliased)
88 PLANE_CTL : Registers.Registers_Index;
89 PLANE_OFFSET : Registers.Registers_Index;
90 PLANE_POS : Registers.Registers_Index;
91 PLANE_SIZE : Registers.Registers_Index;
92 PLANE_STRIDE : Registers.Registers_Index;
93 PLANE_SURF : Registers.Registers_Index;
94 PS_CTRL_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010095 PS_WIN_POS_1 : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020096 PS_WIN_SZ_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010097 PS_CTRL_2 : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +020098 PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
99 WM_LINETIME : Registers.Registers_Index;
100 PLANE_BUF_CFG : Registers.Registers_Index;
101 PLANE_WM : PLANE_WM_Type;
Nico Huber4dc4c612018-01-10 15:55:09 +0100102 CUR_BUF_CFG : Registers.Registers_Index;
103 CUR_WM : PLANE_WM_Type;
Nico Huber83693c82016-10-08 22:17:55 +0200104 end record;
105
Nico Huberf3e23662016-12-05 21:33:03 +0100106 type Controller_Array is array (Pipe_Index) of Controller_Type;
107
Nico Huberf3e23662016-12-05 21:33:03 +0100108 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,
Nico Huber4dc4c612018-01-10 15:55:09 +0100143 Registers.PLANE_WM_1_A_7),
144 CUR_BUF_CFG => Registers.CUR_BUF_CFG_A,
145 CUR_WM => PLANE_WM_Type'(
146 Registers.CUR_WM_A_0,
147 Registers.CUR_WM_A_1,
148 Registers.CUR_WM_A_2,
149 Registers.CUR_WM_A_3,
150 Registers.CUR_WM_A_4,
151 Registers.CUR_WM_A_5,
152 Registers.CUR_WM_A_6,
153 Registers.CUR_WM_A_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100154 Secondary => Controller_Type'
155 (Pipe => Secondary,
Nico Huber83693c82016-10-08 22:17:55 +0200156 PIPESRC => Registers.PIPEBSRC,
157 PIPEMISC => Registers.PIPEBMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100158 PF_CTRL => Registers.PFB_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200159 PF_WIN_POS => Registers.PFB_WIN_POS,
160 PF_WIN_SZ => Registers.PFB_WIN_SZ,
161 DSPCNTR => Registers.DSPBCNTR,
162 DSPLINOFF => Registers.DSPBLINOFF,
163 DSPSTRIDE => Registers.DSPBSTRIDE,
164 DSPSURF => Registers.DSPBSURF,
165 DSPTILEOFF => Registers.DSPBTILEOFF,
166 SPCNTR => Registers.SPBCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200167 PLANE_CTL => Registers.DSPBCNTR,
168 PLANE_OFFSET => Registers.DSPBTILEOFF,
169 PLANE_POS => Registers.PLANE_POS_1_B,
170 PLANE_SIZE => Registers.PLANE_SIZE_1_B,
171 PLANE_STRIDE => Registers.DSPBSTRIDE,
172 PLANE_SURF => Registers.DSPBSURF,
173 PS_CTRL_1 => Registers.PS_CTRL_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100174 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
Nico Huber83693c82016-10-08 22:17:55 +0200175 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100176 PS_CTRL_2 => Registers.PS_CTRL_2_B,
Nico Huber83693c82016-10-08 22:17:55 +0200177 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B,
178 WM_LINETIME => Registers.WM_LINETIME_B,
179 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B,
180 PLANE_WM => PLANE_WM_Type'(
181 Registers.PLANE_WM_1_B_0,
182 Registers.PLANE_WM_1_B_1,
183 Registers.PLANE_WM_1_B_2,
184 Registers.PLANE_WM_1_B_3,
185 Registers.PLANE_WM_1_B_4,
186 Registers.PLANE_WM_1_B_5,
187 Registers.PLANE_WM_1_B_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100188 Registers.PLANE_WM_1_B_7),
189 CUR_BUF_CFG => Registers.CUR_BUF_CFG_B,
190 CUR_WM => PLANE_WM_Type'(
191 Registers.CUR_WM_B_0,
192 Registers.CUR_WM_B_1,
193 Registers.CUR_WM_B_2,
194 Registers.CUR_WM_B_3,
195 Registers.CUR_WM_B_4,
196 Registers.CUR_WM_B_5,
197 Registers.CUR_WM_B_6,
198 Registers.CUR_WM_B_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100199 Tertiary => Controller_Type'
200 (Pipe => Tertiary,
Nico Huber83693c82016-10-08 22:17:55 +0200201 PIPESRC => Registers.PIPECSRC,
202 PIPEMISC => Registers.PIPECMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100203 PF_CTRL => Registers.PFC_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200204 PF_WIN_POS => Registers.PFC_WIN_POS,
205 PF_WIN_SZ => Registers.PFC_WIN_SZ,
206 DSPCNTR => Registers.DSPCCNTR,
207 DSPLINOFF => Registers.DSPCLINOFF,
208 DSPSTRIDE => Registers.DSPCSTRIDE,
209 DSPSURF => Registers.DSPCSURF,
210 DSPTILEOFF => Registers.DSPCTILEOFF,
211 SPCNTR => Registers.SPCCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200212 PLANE_CTL => Registers.DSPCCNTR,
213 PLANE_OFFSET => Registers.DSPCTILEOFF,
214 PLANE_POS => Registers.PLANE_POS_1_C,
215 PLANE_SIZE => Registers.PLANE_SIZE_1_C,
216 PLANE_STRIDE => Registers.DSPCSTRIDE,
217 PLANE_SURF => Registers.DSPCSURF,
218 PS_CTRL_1 => Registers.PS_CTRL_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100219 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C,
Nico Huber83693c82016-10-08 22:17:55 +0200220 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100221 PS_CTRL_2 => Registers.Invalid_Register,
Nico Huber83693c82016-10-08 22:17:55 +0200222 PS_WIN_SZ_2 => Registers.Invalid_Register,
223 WM_LINETIME => Registers.WM_LINETIME_C,
224 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C,
225 PLANE_WM => PLANE_WM_Type'(
226 Registers.PLANE_WM_1_C_0,
227 Registers.PLANE_WM_1_C_1,
228 Registers.PLANE_WM_1_C_2,
229 Registers.PLANE_WM_1_C_3,
230 Registers.PLANE_WM_1_C_4,
231 Registers.PLANE_WM_1_C_5,
232 Registers.PLANE_WM_1_C_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100233 Registers.PLANE_WM_1_C_7),
234 CUR_BUF_CFG => Registers.CUR_BUF_CFG_C,
235 CUR_WM => PLANE_WM_Type'(
236 Registers.CUR_WM_C_0,
237 Registers.CUR_WM_C_1,
238 Registers.CUR_WM_C_2,
239 Registers.CUR_WM_C_3,
240 Registers.CUR_WM_C_4,
241 Registers.CUR_WM_C_5,
242 Registers.CUR_WM_C_6,
243 Registers.CUR_WM_C_7)));
Nico Huber83693c82016-10-08 22:17:55 +0200244
Nico Huber75a707f2018-06-18 16:28:33 +0200245 type Cursor_Regs is record
246 CTL : Registers.Registers_Index;
247 BASE : Registers.Registers_Index;
248 POS : Registers.Registers_Index;
249 FBC_CTL : Registers.Registers_Invalid_Index;
250 end record;
251
252 function Cursors (Pipe : Pipe_Index) return Cursor_Regs is
253 (if not Config.Has_Ivybridge_Cursors then
254 (if Pipe = Primary then
255 (CTL => Registers.CURACNTR,
256 BASE => Registers.CURABASE,
257 POS => Registers.CURAPOS,
258 FBC_CTL => Registers.Invalid_Register)
259 else
260 (CTL => Registers.CURBCNTR,
261 BASE => Registers.CURBBASE,
262 POS => Registers.CURBPOS,
263 FBC_CTL => Registers.Invalid_Register))
264 else
265 (if Pipe = Primary then
266 (CTL => Registers.CUR_CTL_A,
267 BASE => Registers.CUR_BASE_A,
268 POS => Registers.CUR_POS_A,
269 FBC_CTL => Registers.CUR_FBC_CTL_A)
270 elsif Pipe = Secondary then
271 (CTL => Registers.CUR_CTL_B,
272 BASE => Registers.CUR_BASE_B,
273 POS => Registers.CUR_POS_B,
274 FBC_CTL => Registers.CUR_FBC_CTL_B)
275 else
276 (CTL => Registers.CUR_CTL_C,
277 BASE => Registers.CUR_BASE_C,
278 POS => Registers.CUR_POS_C,
279 FBC_CTL => Registers.CUR_FBC_CTL_C)));
280
Nico Huber83693c82016-10-08 22:17:55 +0200281end HW.GFX.GMA.Pipe_Setup;